Skip to content

Commit 6ad6c81

Browse files
HeinrichApfelmusjespercockx
authored andcommitted
Add properties about Boolean Algebra to Bool
1 parent c26f3ef commit 6ad6c81

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

lib/Haskell/Law/Bool.agda

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,143 @@ prop-x-||-False
4141
prop-x-||-False True = refl
4242
prop-x-||-False False = refl
4343

44+
{-----------------------------------------------------------------------------
45+
Properties
46+
Boolean algebra
47+
https://en.wikipedia.org/wiki/Boolean_algebra_(structure)
48+
------------------------------------------------------------------------------}
49+
--
50+
prop-||-idem
51+
: (a : Bool)
52+
(a || a) ≡ a
53+
--
54+
prop-||-idem False = refl
55+
prop-||-idem True = refl
56+
57+
--
58+
prop-||-assoc
59+
: (a b c : Bool)
60+
((a || b) || c) ≡ (a || (b || c))
61+
--
62+
prop-||-assoc False b c = refl
63+
prop-||-assoc True b c = refl
64+
65+
--
66+
prop-||-sym
67+
: (a b : Bool)
68+
(a || b) ≡ (b || a)
69+
--
70+
prop-||-sym False False = refl
71+
prop-||-sym False True = refl
72+
prop-||-sym True False = refl
73+
prop-||-sym True True = refl
74+
75+
--
76+
prop-||-absorb
77+
: (a b : Bool)
78+
(a || (a && b)) ≡ a
79+
--
80+
prop-||-absorb False b = refl
81+
prop-||-absorb True b = refl
82+
83+
--
84+
prop-||-identity
85+
: (a : Bool)
86+
(a || False) ≡ a
87+
--
88+
prop-||-identity False = refl
89+
prop-||-identity True = refl
90+
91+
--
92+
prop-||-&&-distribute
93+
: (a b c : Bool)
94+
(a || (b && c)) ≡ ((a || b) && (a || c))
95+
--
96+
prop-||-&&-distribute False b c = refl
97+
prop-||-&&-distribute True b c = refl
98+
99+
--
100+
prop-||-complement
101+
: (a : Bool)
102+
(a || not a) ≡ True
103+
--
104+
prop-||-complement False = refl
105+
prop-||-complement True = refl
106+
107+
--
108+
prop-&&-idem
109+
: (a : Bool)
110+
(a && a) ≡ a
111+
--
112+
prop-&&-idem False = refl
113+
prop-&&-idem True = refl
114+
115+
--
116+
prop-&&-assoc
117+
: (a b c : Bool)
118+
((a && b) && c) ≡ (a && (b && c))
119+
--
120+
prop-&&-assoc False b c = refl
121+
prop-&&-assoc True b c = refl
122+
123+
--
124+
prop-&&-sym
125+
: (a b : Bool)
126+
(a && b) ≡ (b && a)
127+
--
128+
prop-&&-sym False False = refl
129+
prop-&&-sym False True = refl
130+
prop-&&-sym True False = refl
131+
prop-&&-sym True True = refl
132+
133+
--
134+
prop-&&-absorb
135+
: (a b : Bool)
136+
(a && (a || b)) ≡ a
137+
--
138+
prop-&&-absorb False b = refl
139+
prop-&&-absorb True b = refl
140+
141+
--
142+
prop-&&-identity
143+
: (a : Bool)
144+
(a && True) ≡ a
145+
--
146+
prop-&&-identity False = refl
147+
prop-&&-identity True = refl
148+
149+
--
150+
prop-&&-||-distribute
151+
: (a b c : Bool)
152+
(a && (b || c)) ≡ ((a && b) || (a && c))
153+
--
154+
prop-&&-||-distribute False b c = refl
155+
prop-&&-||-distribute True b c = refl
156+
157+
--
158+
prop-&&-complement
159+
: (a : Bool)
160+
(a && not a) ≡ False
161+
--
162+
prop-&&-complement False = refl
163+
prop-&&-complement True = refl
164+
165+
--
166+
prop-deMorgan-not-&&
167+
: (a b : Bool)
168+
not (a && b) ≡ (not a || not b)
169+
--
170+
prop-deMorgan-not-&& False b = refl
171+
prop-deMorgan-not-&& True b = refl
172+
173+
--
174+
prop-deMorgan-not-||
175+
: (a b : Bool)
176+
not (a || b) ≡ (not a && not b)
177+
--
178+
prop-deMorgan-not-|| False b = refl
179+
prop-deMorgan-not-|| True b = refl
180+
44181
{-----------------------------------------------------------------------------
45182
Properties
46183
Other

0 commit comments

Comments
 (0)