406
|
1 {-# OPTIONS --cubical-compatible --safe #-}
|
|
2
|
59
|
3 module logic where
|
|
4
|
|
5 open import Level
|
|
6 open import Relation.Nullary
|
141
|
7 open import Relation.Binary hiding (_⇔_)
|
59
|
8 open import Data.Empty
|
|
9
|
|
10
|
|
11 data Bool : Set where
|
|
12 true : Bool
|
|
13 false : Bool
|
|
14
|
|
15 record _∧_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where
|
|
16 field
|
|
17 proj1 : A
|
|
18 proj2 : B
|
|
19
|
|
20 data _∨_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where
|
|
21 case1 : A → A ∨ B
|
|
22 case2 : B → A ∨ B
|
|
23
|
330
|
24 -- data ⊥ : Set where
|
|
25
|
|
26 -- ⊥-elim : {n : Level} {A : Set n } → ⊥ → A
|
|
27 --⊥-elim ()
|
|
28
|
|
29 -- ¬_ : {n : Level } → Set n → Set n
|
|
30 -- ¬ A = A → ⊥
|
|
31
|
59
|
32 _⇔_ : {n m : Level } → ( A : Set n ) ( B : Set m ) → Set (n ⊔ m)
|
|
33 _⇔_ A B = ( A → B ) ∧ ( B → A )
|
|
34
|
|
35 contra-position : {n m : Level } {A : Set n} {B : Set m} → (A → B) → ¬ B → ¬ A
|
|
36 contra-position {n} {m} {A} {B} f ¬b a = ¬b ( f a )
|
|
37
|
|
38 double-neg : {n : Level } {A : Set n} → A → ¬ ¬ A
|
|
39 double-neg A notnot = notnot A
|
|
40
|
|
41 double-neg2 : {n : Level } {A : Set n} → ¬ ¬ ¬ A → ¬ A
|
|
42 double-neg2 notnot A = notnot ( double-neg A )
|
|
43
|
|
44 de-morgan : {n : Level } {A B : Set n} → A ∧ B → ¬ ( (¬ A ) ∨ (¬ B ) )
|
|
45 de-morgan {n} {A} {B} and (case1 ¬A) = ⊥-elim ( ¬A ( _∧_.proj1 and ))
|
|
46 de-morgan {n} {A} {B} and (case2 ¬B) = ⊥-elim ( ¬B ( _∧_.proj2 and ))
|
|
47
|
|
48 dont-or : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ A → B
|
|
49 dont-or {A} {B} (case1 a) ¬A = ⊥-elim ( ¬A a )
|
|
50 dont-or {A} {B} (case2 b) ¬A = b
|
|
51
|
|
52 dont-orb : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ B → A
|
|
53 dont-orb {A} {B} (case2 b) ¬B = ⊥-elim ( ¬B b )
|
|
54 dont-orb {A} {B} (case1 a) ¬B = a
|
|
55
|
|
56
|
|
57 infixr 130 _∧_
|
|
58 infixr 140 _∨_
|
|
59 infixr 150 _⇔_
|
|
60
|