annotate src/logic.agda @ 1439:900c98ffde05

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 04 Jul 2023 09:28:09 +0900
parents 7d2bae0ff36b
children fa52d72f4bb3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
431
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module logic where
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Level
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Relation.Nullary
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Relation.Binary hiding (_⇔_ )
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.Empty
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
1175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
8 data Bool : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
9 true : Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
10 false : Bool
431
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 data Two : Set where
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 i0 : Two
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 i1 : Two
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 record _∧_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 constructor ⟪_,_⟫
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 field
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 proj1 : A
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 proj2 : B
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 data _∨_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 case1 : A → A ∨ B
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 case2 : B → A ∨ B
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 _⇔_ : {n m : Level } → ( A : Set n ) ( B : Set m ) → Set (n ⊔ m)
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 _⇔_ A B = ( A → B ) ∧ ( B → A )
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
1175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
29 ∧-exch : {n m : Level} {A : Set n} { B : Set m } → A ∧ B → B ∧ A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
30 ∧-exch p = ⟪ _∧_.proj2 p , _∧_.proj1 p ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
31
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
32 ∨-exch : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → B ∨ A
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
33 ∨-exch (case1 x) = case2 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
34 ∨-exch (case2 x) = case1 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
35
431
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 contra-position : {n m : Level } {A : Set n} {B : Set m} → (A → B) → ¬ B → ¬ A
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 contra-position {n} {m} {A} {B} f ¬b a = ¬b ( f a )
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 double-neg : {n : Level } {A : Set n} → A → ¬ ¬ A
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 double-neg A notnot = notnot A
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 double-neg2 : {n : Level } {A : Set n} → ¬ ¬ ¬ A → ¬ A
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 double-neg2 notnot A = notnot ( double-neg A )
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 de-morgan : {n : Level } {A B : Set n} → A ∧ B → ¬ ( (¬ A ) ∨ (¬ B ) )
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 de-morgan {n} {A} {B} and (case1 ¬A) = ⊥-elim ( ¬A ( _∧_.proj1 and ))
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 de-morgan {n} {A} {B} and (case2 ¬B) = ⊥-elim ( ¬B ( _∧_.proj2 and ))
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
1175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
49 de-morgan∨ : {n : Level } {A B : Set n} → A ∨ B → ¬ ( (¬ A ) ∧ (¬ B ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
50 de-morgan∨ {n} {A} {B} (case1 a) and = ⊥-elim ( _∧_.proj1 and a )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
51 de-morgan∨ {n} {A} {B} (case2 b) and = ⊥-elim ( _∧_.proj2 and b )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
52
431
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 dont-or : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ A → B
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 dont-or {A} {B} (case1 a) ¬A = ⊥-elim ( ¬A a )
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 dont-or {A} {B} (case2 b) ¬A = b
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 dont-orb : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ B → A
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 dont-orb {A} {B} (case2 b) ¬B = ⊥-elim ( ¬B b )
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 dont-orb {A} {B} (case1 a) ¬B = a
a5f8084b8368 reorganiztion for apkg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
1175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
61 infixr 130 _∧_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
62 infixr 140 _∨_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
63 infixr 150 _⇔_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
65 _/\_ : Bool → Bool → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
66 true /\ true = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
67 _ /\ _ = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
68
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
69 _\/_ : Bool → Bool → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
70 false \/ false = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
71 _ \/ _ = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
72
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
73 not : Bool → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
74 not true = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
75 not false = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
76
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
77 _<=>_ : Bool → Bool → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
78 true <=> true = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
79 false <=> false = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
80 _ <=> _ = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
81
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
82 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
83
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
84 not-not-bool : { b : Bool } → not (not b) ≡ b
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
85 not-not-bool {true} = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
86 not-not-bool {false} = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
88 record Bijection {n m : Level} (R : Set n) (S : Set m) : Set (n Level.⊔ m) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
89 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
90 fun← : S → R
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
91 fun→ : R → S
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
92 fiso← : (x : R) → fun← ( fun→ x ) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
93 fiso→ : (x : S ) → fun→ ( fun← x ) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
94
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
95 injection : {n m : Level} (R : Set n) (S : Set m) (f : R → S ) → Set (n Level.⊔ m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
96 injection R S f = (x y : R) → f x ≡ f y → x ≡ y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
97
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
98
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
99 ¬t=f : (t : Bool ) → ¬ ( not t ≡ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
100 ¬t=f true ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
101 ¬t=f false ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
102
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
103 infixr 130 _\/_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
104 infixr 140 _/\_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
105
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
106 ≡-Bool-func : {A B : Bool } → ( A ≡ true → B ≡ true ) → ( B ≡ true → A ≡ true ) → A ≡ B
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
107 ≡-Bool-func {true} {true} a→b b→a = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
108 ≡-Bool-func {false} {true} a→b b→a with b→a refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
109 ... | ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
110 ≡-Bool-func {true} {false} a→b b→a with a→b refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
111 ... | ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
112 ≡-Bool-func {false} {false} a→b b→a = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
113
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
114 bool-≡-? : (a b : Bool) → Dec ( a ≡ b )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
115 bool-≡-? true true = yes refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
116 bool-≡-? true false = no (λ ())
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
117 bool-≡-? false true = no (λ ())
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
118 bool-≡-? false false = yes refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
119
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
120 ¬-bool-t : {a : Bool} → ¬ ( a ≡ true ) → a ≡ false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
121 ¬-bool-t {true} ne = ⊥-elim ( ne refl )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
122 ¬-bool-t {false} ne = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
123
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
124 ¬-bool-f : {a : Bool} → ¬ ( a ≡ false ) → a ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
125 ¬-bool-f {true} ne = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
126 ¬-bool-f {false} ne = ⊥-elim ( ne refl )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
127
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
128 ¬-bool : {a : Bool} → a ≡ false → a ≡ true → ⊥
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
129 ¬-bool refl ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
130
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
131 lemma-∧-0 : {a b : Bool} → a /\ b ≡ true → a ≡ false → ⊥
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
132 lemma-∧-0 {true} {true} refl ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
133 lemma-∧-0 {true} {false} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
134 lemma-∧-0 {false} {true} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
135 lemma-∧-0 {false} {false} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
136
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
137 lemma-∧-1 : {a b : Bool} → a /\ b ≡ true → b ≡ false → ⊥
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
138 lemma-∧-1 {true} {true} refl ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
139 lemma-∧-1 {true} {false} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
140 lemma-∧-1 {false} {true} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
141 lemma-∧-1 {false} {false} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
142
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
143 bool-and-tt : {a b : Bool} → a ≡ true → b ≡ true → ( a /\ b ) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
144 bool-and-tt refl refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
145
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
146 bool-∧→tt-0 : {a b : Bool} → ( a /\ b ) ≡ true → a ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
147 bool-∧→tt-0 {true} {true} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
148 bool-∧→tt-0 {false} {_} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
149
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
150 bool-∧→tt-1 : {a b : Bool} → ( a /\ b ) ≡ true → b ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
151 bool-∧→tt-1 {true} {true} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
152 bool-∧→tt-1 {true} {false} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
153 bool-∧→tt-1 {false} {false} ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
154
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
155 bool-or-1 : {a b : Bool} → a ≡ false → ( a \/ b ) ≡ b
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
156 bool-or-1 {false} {true} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
157 bool-or-1 {false} {false} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
158 bool-or-2 : {a b : Bool} → b ≡ false → (a \/ b ) ≡ a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
159 bool-or-2 {true} {false} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
160 bool-or-2 {false} {false} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
161
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
162 bool-or-3 : {a : Bool} → ( a \/ true ) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
163 bool-or-3 {true} = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
164 bool-or-3 {false} = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
165
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
166 bool-or-31 : {a b : Bool} → b ≡ true → ( a \/ b ) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
167 bool-or-31 {true} {true} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
168 bool-or-31 {false} {true} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
169
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
170 bool-or-4 : {a : Bool} → ( true \/ a ) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
171 bool-or-4 {true} = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
172 bool-or-4 {false} = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
174 bool-or-41 : {a b : Bool} → a ≡ true → ( a \/ b ) ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
175 bool-or-41 {true} {b} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
176
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
177 bool-and-1 : {a b : Bool} → a ≡ false → (a /\ b ) ≡ false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
178 bool-and-1 {false} {b} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
179 bool-and-2 : {a b : Bool} → b ≡ false → (a /\ b ) ≡ false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
180 bool-and-2 {true} {false} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
181 bool-and-2 {false} {false} refl = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
182
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
183
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
184 open import Data.Nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
185 open import Data.Nat.Properties
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
186
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
187 _≥b_ : ( x y : ℕ) → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
188 x ≥b y with <-cmp x y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
189 ... | tri< a ¬b ¬c = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
190 ... | tri≈ ¬a b ¬c = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
191 ... | tri> ¬a ¬b c = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
192
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
193 _>b_ : ( x y : ℕ) → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
194 x >b y with <-cmp x y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
195 ... | tri< a ¬b ¬c = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
196 ... | tri≈ ¬a b ¬c = false
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
197 ... | tri> ¬a ¬b c = true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
198
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
199 _≤b_ : ( x y : ℕ) → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
200 x ≤b y = y ≥b x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
201
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
202 _<b_ : ( x y : ℕ) → Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
203 x <b y = y >b x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1174
diff changeset
204
1174
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
205 open import Relation.Binary.PropositionalEquality
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
206
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
207 ¬i0≡i1 : ¬ ( i0 ≡ i1 )
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
208 ¬i0≡i1 ()
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
209
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
210 ¬i0→i1 : {x : Two} → ¬ (x ≡ i0 ) → x ≡ i1
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
211 ¬i0→i1 {i0} ne = ⊥-elim ( ne refl )
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
212 ¬i0→i1 {i1} ne = refl
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
213
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
214 ¬i1→i0 : {x : Two} → ¬ (x ≡ i1 ) → x ≡ i0
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
215 ¬i1→i0 {i0} ne = refl
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
216 ¬i1→i0 {i1} ne = ⊥-elim ( ne refl )
375615f9d60f Func and Funcs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 431
diff changeset
217