@@ -104,6 +104,20 @@ begin
104104 { simplify ; assume h0 h1; refine h1 }
105105end ;
106106
107+ opaque symbol notK b : π (not (not b) = b) ≔
108+ begin
109+ induction
110+ { reflexivity }
111+ { reflexivity }
112+ end ;
113+
114+ opaque symbol negb_false_eq_true b : π (not b = false ⇔ b = true) ≔
115+ begin
116+ induction
117+ {simplify ; apply ∧ᵢ { assume h; reflexivity } { assume h; reflexivity }}
118+ {simplify ; apply ∧ᵢ { assume h; apply ⊥ₑ (true≠false h) } { assume h; apply ⊥ₑ (false≠true h) }}
119+ end ;
120+
107121// or
108122
109123symbol or : 𝔹 → 𝔹 → 𝔹;
@@ -129,6 +143,65 @@ begin
129143 {reflexivity }
130144end ;
131145
146+ // imp
147+
148+ symbol imp : 𝔹 → 𝔹 → 𝔹;
149+
150+ notation imp infix left 20;
151+
152+ rule true imp true ↪ true
153+ with true imp false ↪ false
154+ with false imp true ↪ true
155+ with false imp false ↪ true;
156+
157+ opaque symbol ⇒_istrue [p q : 𝔹] : π(p imp q) → π(p ⇒ q) ≔
158+ begin
159+ induction
160+ { induction
161+ {
162+ simplify ;
163+ assume h1; refine (λ x, x)
164+ }
165+ {
166+ simplify ; assume h1 h2; refine h1
167+ }
168+ }
169+ {
170+ induction
171+ {
172+ simplify ;
173+ assume h1 h2; apply h1
174+ }
175+ {
176+ simplify ;
177+ assume h1; refine (λ x, x)
178+ }
179+ }
180+ end ;
181+
182+ opaque symbol istrue_imp [p q : 𝔹] : π(p ⇒ q) → π(p imp q) ≔
183+ begin
184+ induction
185+ { induction
186+ { assume h; apply ⊤ᵢ }
187+ { assume h; apply h ⊤ᵢ }
188+ }
189+ { induction
190+ { assume h; apply ⊤ᵢ }
191+ { assume h; apply ⊤ᵢ }
192+ }
193+ end ;
194+
195+ opaque symbol impᵢ [p q : 𝔹] : (π p → π q) → π (p imp q) ≔
196+ begin
197+ assume p q h; apply @istrue_imp p q h;
198+ end ;
199+
200+ opaque symbol impₑ [p q : 𝔹] : π (p imp q) → π p → π q ≔
201+ begin
202+ assume p q h; refine @⇒_istrue p q h;
203+ end ;
204+
132205opaque symbol ∨_istrue [p q : 𝔹] : π(p or q) → π(p ∨ q) ≔
133206begin
134207 induction
@@ -226,9 +299,110 @@ begin
226299 { assume q i; apply ⊥ₑ i; }
227300end ;
228301
302+ // xorb
303+
304+ symbol xorb : 𝔹 → 𝔹 → 𝔹;
305+
306+ notation xorb infix left 22;
307+
308+ rule false xorb false ↪ false
309+ with false xorb true ↪ true
310+ with true xorb false ↪ true
311+ with true xorb true ↪ false;
312+
313+ opaque symbol xorbᵢ₁ [p q : 𝔹] : π p → π (not q) → π (p xorb q) ≔
314+ begin
315+ induction
316+ { induction
317+ { simplify ; assume h i; apply i }
318+ { simplify ; assume h i; apply ⊤ᵢ }
319+ }
320+ { induction
321+ { simplify ; assume h i; apply ⊥ₑ h }
322+ { simplify ; assume h i; apply ⊥ₑ h }
323+ }
324+ end ;
325+
326+ opaque symbol xorbᵢ₂ [p q : 𝔹] : π (not p) → π q → π (p xorb q) ≔
327+ begin
328+ induction
329+ { induction
330+ { simplify ; assume h i; apply ⊥ₑ h }
331+ { simplify ; assume h i; apply ⊥ₑ h }
332+ }
333+ { induction
334+ { simplify ; assume h i; apply ⊤ᵢ }
335+ { simplify ; assume h i; apply ⊥ₑ i }
336+ }
337+ end ;
338+
339+ opaque symbol xorbₑ [p q : 𝔹] (r : 𝔹) :
340+ π (p xorb q) → (π p → π (not q) → π r) → (π (not p) → π q → π r) → π r ≔
341+ begin
342+ induction
343+ { induction
344+ { simplify ; assume r h h1 h2; apply ⊥ₑ h }
345+ { simplify ; assume r h h1 h2; apply h1 ⊤ᵢ ⊤ᵢ }
346+ }
347+ { induction
348+ { simplify ; assume r h h1 h2; apply h2 ⊤ᵢ ⊤ᵢ }
349+ { simplify ; assume r h h1 h2; apply ⊥ₑ h }
350+ }
351+ end ;
352+
229353// if-then-else
230354
231355symbol if : 𝔹 → Π [a], τ a → τ a → τ a;
232356
233357rule if true $x _ ↪ $x
234358with if false _ $y ↪ $y;
359+
360+ opaque symbol if_true [a] (x y : τ a) : π (if true x y = x) ≔
361+ begin
362+ assume a x y; reflexivity
363+ end ;
364+
365+ opaque symbol if_false [a] (x y : τ a) : π (if false x y = y) ≔
366+ begin
367+ assume a x y; reflexivity
368+ end ;
369+
370+ opaque symbol if_same b [a] (x : τ a) : π (if b x x = x) ≔
371+ begin
372+ assume b a x;
373+ refine ∨ₑ (case_𝔹 b) _ _
374+ { assume h; rewrite h; reflexivity }
375+ { assume h; rewrite h; reflexivity }
376+ end ;
377+
378+ opaque symbol if_id b : π (if b true false = b) ≔
379+ begin
380+ induction
381+ { reflexivity }
382+ { reflexivity }
383+ end ;
384+
385+ opaque symbol if_not b [a] (x y : τ a) : π (if (not b) x y = if b y x) ≔
386+ begin
387+ assume b a x y;
388+ refine ∨ₑ (case_𝔹 b) _ _
389+ { assume h; rewrite h; reflexivity }
390+ { assume h; rewrite h; reflexivity }
391+ end ;
392+
393+ opaque symbol if_istrue [b : 𝔹] [a] (x y : τ a) : π b → π (if b x y = x) ≔
394+ begin
395+ assume b a x y h;
396+ refine ∨ₑ (case_𝔹 b) _ _
397+ { assume h1; rewrite h1; reflexivity }
398+ { assume h1; apply ⊥ₑ (false=¬istrue h1 h) }
399+ end ;
400+
401+ opaque symbol if_isfalse [b : 𝔹] [a] (x y : τ a) : π (not b) → π (if b x y = y) ≔
402+ begin
403+ assume b a x y h;
404+ refine ∨ₑ (case_𝔹 b) _ _
405+ { assume h1; apply ⊥ₑ (istrue_not h (true=istrue h1)) }
406+ { assume h1; rewrite h1; reflexivity }
407+ end ;
408+
0 commit comments