Debian Codegraph @

Formal_ineqs/lib/ssrbool.hl

raw
1 needs "Formal_ineqs/lib/ssrfun.hl";;
2
3 (* Module Ssrbool*)
4 module Ssrbool = struct
5
6 open Ssreflect;;
7
8 (* Section ApplyIff *)
9 Sections.begin_section "ApplyIff";;
10 (Sections.add_section_var (mk_var ("P", (`:bool`))); Sections.add_section_var (mk_var ("Q", (`:bool`))));;
11 (Sections.add_section_hyp "eqPQ" (`P <=> Q`));;
12
13 (* Lemma iffLR *)
14 let iffLR = Sections.section_proof []
15 `P ==> Q`
16 [
17 (done_tac);
18 ];;
19
20 (* Lemma iffRL *)
21 let iffRL = Sections.section_proof []
22 `Q ==> P`
23 [
24 (done_tac);
25 ];;
26
27 (* Lemma iffLRn *)
28 let iffLRn = Sections.section_proof []
29 `~P ==> ~Q`
30 [
31 (done_tac);
32 ];;
33
34 (* Lemma iffRLn *)
35 let iffRLn = Sections.section_proof []
36 `~Q ==> ~P`
37 [
38 (done_tac);
39 ];;
40
41 (* Finalization of the section ApplyIff *)
42 let iffLR = Sections.finalize_theorem iffLR;;
43 let iffRL = Sections.finalize_theorem iffRL;;
44 let iffLRn = Sections.finalize_theorem iffLRn;;
45 let iffRLn = Sections.finalize_theorem iffRLn;;
46 Sections.end_section "ApplyIff";;
47
48 (* Lemma is_true_true *)
49 let is_true_true = Sections.section_proof []
50 `T`
51 [
52 (done_tac);
53 ];;
54
55 (* Lemma not_false_is_true *)
56 let not_false_is_true = Sections.section_proof []
57 `~F`
58 [
59 (done_tac);
60 ];;
61 let isT = is_true_true;;
62 let notF = not_false_is_true;;
63
64 (* Lemma negbT *)
65 let negbT = Sections.section_proof ["b"]
66 `(b = F) ==> ~b`
67 [
68 (done_tac);
69 ];;
70
71 (* Lemma negbTE *)
72 let negbTE = Sections.section_proof ["b"]
73 `~b ==> b = F`
74 [
75 (done_tac);
76 ];;
77
78 (* Lemma negbF *)
79 let negbF = Sections.section_proof ["b"]
80 `b ==> ~b = F`
81 [
82 (done_tac);
83 ];;
84
85 (* Lemma negbFE *)
86 let negbFE = Sections.section_proof ["b"]
87 `~b = F ==> b`
88 [
89 (done_tac);
90 ];;
91
92 (* Lemma negbK *)
93 let negbK = Sections.section_proof ["b"]
94 `~ ~b = b`
95 [
96 (done_tac);
97 ];;
98
99 (* Lemma negbNE *)
100 let negbNE = Sections.section_proof ["b"]
101 `~ ~ b ==> b`
102 [
103 (done_tac);
104 ];;
105
106 (* Lemma negb_inj *)
107 let negb_inj = Sections.section_proof ["b1";"b2"]
108 `~b1 = ~b2 ==> b1 = b2`
109 [
110 ((((use_arg_then2 ("b1", [])) (disch_tac [])) THEN (clear_assumption "b1") THEN case) THEN (((use_arg_then2 ("b2", [])) (disch_tac [])) THEN (clear_assumption "b2") THEN case THEN (simp_tac)) THEN (done_tac));
111 ];;
112
113 (* Lemma negbLR *)
114 let negbLR = Sections.section_proof ["b";"c"]
115 `b = ~c ==> ~b = c`
116 [
117 ((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("negbK", [negbK]))(thm_tac (new_rewrite [] [])))) THEN (done_tac));
118 ];;
119
120 (* Lemma negbRL *)
121 let negbRL = Sections.section_proof ["b";"c"]
122 `~b = c ==> b = ~c`
123 [
124 ((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then2 ("negbK", [negbK]))(thm_tac (new_rewrite [] [])))) THEN (done_tac));
125 ];;
126
127 (* Lemma contra *)
128 let contra = Sections.section_proof ["c";"b"]
129 `(c ==> b) ==> ~b ==> ~c`
130 [
131 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)));
132 ];;
133 let contraNN = contra;;
134
135 (* Lemma contraL *)
136 let contraL = Sections.section_proof ["c";"b"]
137 `(c ==> ~b) ==> b ==> ~c`
138 [
139 (BETA_TAC THEN (move ["h"]));
140 ((((fun arg_tac -> (use_arg_then2 ("contra", [contra])) (fun fst_arg -> (use_arg_then2 ("h", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((use_arg_then2 ("negbK", [negbK]))(thm_tac (new_rewrite [] [])))) THEN (done_tac));
141 ];;
142
143 (* Lemma contraR *)
144 let contraR = Sections.section_proof ["c";"b"]
145 `(~c ==> b) ==> ~b ==> c`
146 [
147 (BETA_TAC THEN (move ["h"]));
148 ((((fun arg_tac -> (use_arg_then2 ("contra", [contra])) (fun fst_arg -> (use_arg_then2 ("h", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((use_arg_then2 ("negbK", [negbK]))(thm_tac (new_rewrite [] [])))) THEN (done_tac));
149 ];;
150
151 (* Lemma contraLR *)
152 let contraLR = Sections.section_proof ["c";"b"]
153 `(~c ==> ~b) ==> b ==> c`
154 [
155 (BETA_TAC THEN (move ["h"]));
156 ((((fun arg_tac -> (use_arg_then2 ("contra", [contra])) (fun fst_arg -> (use_arg_then2 ("h", [])) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then2 ("negbK", [negbK]))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
157 ];;
158
159 (* Lemma contraT *)
160 let contraT = Sections.section_proof ["b"]
161 `(~b ==> F) ==> b`
162 [
163 (done_tac);
164 ];;
165
166 (* Lemma wlog_neg *)
167 let wlog_neg = Sections.section_proof ["b"]
168 `(~b ==> b) ==> b`
169 [
170 (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac));
171 ];;
172
173 (* Lemma contraFT *)
174 let contraFT = Sections.section_proof ["c";"b"]
175 `(~c ==> b) ==> b = F ==> c`
176 [
177 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)));
178 ];;
179
180 (* Lemma contraFN *)
181 let contraFN = Sections.section_proof ["c";"b"]
182 `(c ==> b) ==> b = F ==> ~c`
183 [
184 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)));
185 ];;
186
187 (* Lemma contraTF *)
188 let contraTF = Sections.section_proof ["c";"b"]
189 `(c ==> ~b) ==> b ==> c = F`
190 [
191 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)));
192 ];;
193
194 (* Lemma contraNF *)
195 let contraNF = Sections.section_proof ["c";"b"]
196 `(c ==> b) ==> ~b ==> c = F`
197 [
198 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)));
199 ];;
200
201 (* Lemma contraFF *)
202 let contraFF = Sections.section_proof ["c";"b"]
203 `(c ==> b) ==> b = F ==> c = F`
204 [
205 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)));
206 ];;
207 let isSome = define `isSome NONE = F /\ (!x. isSome (SOME x) = T)`;;
208
209 (* Section BoolIf *)
210 Sections.begin_section "BoolIf";;
211 (Sections.add_section_var (mk_var ("vT", (`:A`))); Sections.add_section_var (mk_var ("vF", (`:A`))));;
212 (Sections.add_section_var (mk_var ("f", (`:A -> B`))));;
213 (Sections.add_section_var (mk_var ("b", (`:bool`))));;
214
215 (* Lemma if_same *)
216 let if_same = Sections.section_proof []
217 `(if b then vT else vT) = vT`
218 [
219 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
220 ];;
221
222 (* Lemma if_neg *)
223 let if_neg = Sections.section_proof []
224 `(if ~b then vT else vF) = if b then vF else vT`
225 [
226 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
227 ];;
228
229 (* Lemma fun_if *)
230 let fun_if = Sections.section_proof []
231 `f (if b then vT else vF) = if b then f vT else f vF`
232 [
233 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
234 ];;
235
236 (* Lemma if_arg *)
237 let if_arg = Sections.section_proof ["fT";"fF";"x"]
238 `(if b then (fT:A->B) else fF) x = if b then fT x else fF x`
239 [
240 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
241 ];;
242
243 (* Finalization of the section BoolIf *)
244 let if_same = Sections.finalize_theorem if_same;;
245 let if_neg = Sections.finalize_theorem if_neg;;
246 let fun_if = Sections.finalize_theorem fun_if;;
247 let if_arg = Sections.finalize_theorem if_arg;;
248 Sections.end_section "BoolIf";;
249
250 (* Lemma andTb *)
251 let andTb = Sections.section_proof ["b"]
252 `(T /\ b) = b`
253 [
254 (done_tac);
255 ];;
256
257 (* Lemma andFb *)
258 let andFb = Sections.section_proof ["b"]
259 `(F /\ b) = F`
260 [
261 (done_tac);
262 ];;
263
264 (* Lemma andbT *)
265 let andbT = Sections.section_proof ["b"]
266 `(b /\ T) = b`
267 [
268 (done_tac);
269 ];;
270
271 (* Lemma andbF *)
272 let andbF = Sections.section_proof ["b"]
273 `(b /\ F) = F`
274 [
275 (done_tac);
276 ];;
277
278 (* Lemma andbb *)
279 let andbb = Sections.section_proof ["b"]
280 `(b /\ b) = b`
281 [
282 (done_tac);
283 ];;
284
285 (* Lemma andbC *)
286 let andbC = Sections.section_proof ["b";"c"]
287 `(b /\ c) = (c /\ b)`
288 [
289 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
290 ];;
291
292 (* Lemma andbA *)
293 let andbA = Sections.section_proof ["b";"c";"p"]
294 `b /\ (c /\ p) <=> (b /\ c) /\ p`
295 [
296 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
297 ];;
298
299 (* Lemma andbCA *)
300 let andbCA = Sections.section_proof ["b";"c";"p"]
301 `b /\ (c /\ p) <=> c /\ (b /\ p)`
302 [
303 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
304 ];;
305
306 (* Lemma andbAC *)
307 let andbAC = Sections.section_proof ["b";"c";"p"]
308 `(b /\ c) /\ p <=> (b /\ p) /\ c`
309 [
310 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
311 ];;
312
313 (* Lemma orTb *)
314 let orTb = Sections.section_proof ["b"]
315 `T \/ b <=> T`
316 [
317 (done_tac);
318 ];;
319
320 (* Lemma orFb *)
321 let orFb = Sections.section_proof ["b"]
322 `F \/ b <=> b`
323 [
324 (done_tac);
325 ];;
326
327 (* Lemma orbT *)
328 let orbT = Sections.section_proof ["b"]
329 `b \/ T <=> T`
330 [
331 (done_tac);
332 ];;
333
334 (* Lemma orbF *)
335 let orbF = Sections.section_proof ["b"]
336 `b \/ F <=> b`
337 [
338 (done_tac);
339 ];;
340
341 (* Lemma orbb *)
342 let orbb = Sections.section_proof ["b"]
343 `b \/ b <=> b`
344 [
345 (done_tac);
346 ];;
347
348 (* Lemma orbC *)
349 let orbC = Sections.section_proof ["b";"c"]
350 `b \/ c <=> c \/ b`
351 [
352 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
353 ];;
354
355 (* Lemma orbA *)
356 let orbA = Sections.section_proof ["b";"c";"p"]
357 `b \/ (c \/ p) <=> (b \/ c) \/ p`
358 [
359 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
360 ];;
361
362 (* Lemma orbCA *)
363 let orbCA = Sections.section_proof ["b";"c";"p"]
364 `b \/ (c \/ p) <=> c \/ (b \/ p)`
365 [
366 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
367 ];;
368
369 (* Lemma orbAC *)
370 let orbAC = Sections.section_proof ["b";"c";"p"]
371 `(b \/ c) \/ p <=> (b \/ p) \/ c`
372 [
373 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
374 ];;
375
376 (* Lemma andbN *)
377 let andbN = Sections.section_proof ["b"]
378 `b /\ ~b <=> F`
379 [
380 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
381 ];;
382
383 (* Lemma andNb *)
384 let andNb = Sections.section_proof ["b"]
385 `~b /\ b <=> F`
386 [
387 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
388 ];;
389
390 (* Lemma orbN *)
391 let orbN = Sections.section_proof ["b"]
392 `b \/ ~b`
393 [
394 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
395 ];;
396
397 (* Lemma orNb *)
398 let orNb = Sections.section_proof ["b"]
399 `~b \/ b`
400 [
401 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
402 ];;
403
404 (* Lemma andb_orl *)
405 let andb_orl = Sections.section_proof ["b";"c";"p"]
406 `(b \/ c) /\ p <=> (b /\ p) \/ (c /\ p)`
407 [
408 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
409 ];;
410
411 (* Lemma andb_orr *)
412 let andb_orr = Sections.section_proof ["b";"c";"p"]
413 `b /\ (c \/ p) <=> (b /\ c) \/ (b /\ p)`
414 [
415 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
416 ];;
417
418 (* Lemma orb_andl *)
419 let orb_andl = Sections.section_proof ["b";"c";"p"]
420 `(b /\ c) \/ p <=> (b \/ p) /\ (c \/ p)`
421 [
422 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
423 ];;
424
425 (* Lemma orb_andr *)
426 let orb_andr = Sections.section_proof ["b";"c";"p"]
427 `b \/ (c /\ p) <=> (b \/ c) /\ (b \/ p)`
428 [
429 ((((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
430 ];;
431
432 (* Lemma andb_idl *)
433 let andb_idl = Sections.section_proof ["a";"b"]
434 `(b ==> a) ==> (a /\ b <=> b)`
435 [
436 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
437 ];;
438
439 (* Lemma andb_idr *)
440 let andb_idr = Sections.section_proof ["a";"b"]
441 `(a ==> b) ==> (a /\ b <=> a)`
442 [
443 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
444 ];;
445
446 (* Lemma andb_id2l *)
447 let andb_id2l = Sections.section_proof ["a";"b";"c"]
448 `(a ==> (b <=> c)) ==> (a /\ b <=> a /\ c)`
449 [
450 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
451 ];;
452
453 (* Lemma andb_id2r *)
454 let andb_id2r = Sections.section_proof ["a";"b";"c"]
455 `(b ==> (a <=> c)) ==> (a /\ b <=> c /\ b)`
456 [
457 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
458 ];;
459
460 (* Lemma orb_idl *)
461 let orb_idl = Sections.section_proof ["a";"b"]
462 `(a ==> b) ==> (a \/ b <=> b)`
463 [
464 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
465 ];;
466
467 (* Lemma orbb_idr *)
468 let orbb_idr = Sections.section_proof ["a";"b"]
469 `(b ==> a) ==> (a \/ b <=> a)`
470 [
471 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
472 ];;
473
474 (* Lemma orb_id2l *)
475 let orb_id2l = Sections.section_proof ["a";"b";"c"]
476 `(~ a ==> (b <=> c)) ==> (a \/ b <=> a \/ c)`
477 [
478 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
479 ];;
480
481 (* Lemma orb_id2r *)
482 let orb_id2r = Sections.section_proof ["a";"b";"c"]
483 `(~ b ==> (a <=> c)) ==> (a \/ b <=> c \/ b)`
484 [
485 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
486 ];;
487
488 (* Lemma negb_and *)
489 let negb_and = Sections.section_proof ["a";"b"]
490 `~ (a /\ b) <=> ~ a \/ ~ b`
491 [
492 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
493 ];;
494
495 (* Lemma negb_or *)
496 let negb_or = Sections.section_proof ["a";"b"]
497 `~ (a \/ b) <=> ~ a /\ ~ b`
498 [
499 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
500 ];;
501
502 (* Lemma andbK *)
503 let andbK = Sections.section_proof ["a";"b"]
504 `((a /\ b) \/ a) = a`
505 [
506 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
507 ];;
508
509 (* Lemma andKb *)
510 let andKb = Sections.section_proof ["a";"b"]
511 `a \/ b /\ a <=> a`
512 [
513 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
514 ];;
515
516 (* Lemma orbK *)
517 let orbK = Sections.section_proof ["a";"b"]
518 `(a \/ b) /\ a <=> a`
519 [
520 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
521 ];;
522
523 (* Lemma orKb *)
524 let orKb = Sections.section_proof ["a";"b"]
525 `a /\ (b \/ a) <=> a`
526 [
527 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
528 ];;
529
530 (* Lemma implybT *)
531 let implybT = Sections.section_proof ["b"]
532 `b ==> T`
533 [
534 (done_tac);
535 ];;
536
537 (* Lemma implybF *)
538 let implybF = Sections.section_proof ["b"]
539 `(b ==> F) <=> ~ b`
540 [
541 (done_tac);
542 ];;
543
544 (* Lemma implyFb *)
545 let implyFb = Sections.section_proof ["b"]
546 `F ==> b`
547 [
548 (done_tac);
549 ];;
550
551 (* Lemma implyTb *)
552 let implyTb = Sections.section_proof ["b"]
553 `(T ==> b) <=> b`
554 [
555 (done_tac);
556 ];;
557
558 (* Lemma implybb *)
559 let implybb = Sections.section_proof ["b"]
560 `b ==> b`
561 [
562 (done_tac);
563 ];;
564
565 (* Lemma negb_imply *)
566 let negb_imply = Sections.section_proof ["a";"b"]
567 `~ (a ==> b) <=> a /\ ~ b`
568 [
569 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
570 ];;
571
572 (* Lemma implybE *)
573 let implybE = Sections.section_proof ["a";"b"]
574 `(a ==> b) <=> ~ a \/ b`
575 [
576 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
577 ];;
578
579 (* Lemma implyNb *)
580 let implyNb = Sections.section_proof ["a";"b"]
581 `(~ a ==> b) <=> a \/ b`
582 [
583 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
584 ];;
585
586 (* Lemma implybN *)
587 let implybN = Sections.section_proof ["a";"b"]
588 `(a ==> ~ b) <=> (b ==> ~ a)`
589 [
590 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
591 ];;
592
593 (* Lemma implybNN *)
594 let implybNN = Sections.section_proof ["a";"b"]
595 `(~ a ==> ~ b) <=> b ==> a`
596 [
597 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
598 ];;
599
600 (* Lemma implyb_idl *)
601 let implyb_idl = Sections.section_proof ["a";"b"]
602 `(~ a ==> b) ==> ((a ==> b) <=> b)`
603 [
604 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
605 ];;
606
607 (* Lemma implyb_idr *)
608 let implyb_idr = Sections.section_proof ["a";"b"]
609 `(b ==> ~ a) ==> ((a ==> b) <=> ~ a)`
610 [
611 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
612 ];;
613
614 (* Lemma implyb_id2l *)
615 let implyb_id2l = Sections.section_proof ["a";"b";"c"]
616 `(a ==> (b <=> c)) ==> ((a ==> b) <=> (a ==> c))`
617 [
618 ((((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)) THEN (done_tac));
619 ];;
620 let XOR_DEF = new_definition `XOR p q = if p then ~q else q`;;
621 overload_interface("+", `XOR`);;
622
623 (* Lemma addFb *)
624 let addFb = Sections.section_proof ["b"]
625 `F + b <=> b`
626 [
627 ((((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] [])))) THEN (done_tac));
628 ];;
629
630 (* Lemma addbF *)
631 let addbF = Sections.section_proof ["b"]
632 `b + F <=> b`
633 [
634 ((((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
635 ];;
636
637 (* Lemma addbb *)
638 let addbb = Sections.section_proof ["b"]
639 `b + b <=> F`
640 [
641 ((((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
642 ];;
643
644 (* Lemma addbC *)
645 let addbC = Sections.section_proof ["b";"c"]
646 `b + c <=> c + b`
647 [
648 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case THEN (simp_tac)) THEN (done_tac));
649 ];;
650
651 (* Lemma addbA *)
652 let addbA = Sections.section_proof ["a";"b";"c"]
653 `a + (b + c) <=> (a + b) + c`
654 [
655 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case) THEN (((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)));
656 ];;
657
658 (* Lemma addbCA *)
659 let addbCA = Sections.section_proof ["a";"b";"c"]
660 `(a + b) + c <=> (a + c) + b`
661 [
662 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case) THEN (((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)));
663 ];;
664
665 (* Lemma addbAC *)
666 let addbAC = Sections.section_proof ["a";"b";"c"]
667 `a + (b + c) <=> b + (a + c)`
668 [
669 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case) THEN (((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)));
670 ];;
671
672 (* Lemma andb_addl *)
673 let andb_addl = Sections.section_proof ["a";"b";"c"]
674 `(a + b) /\ c <=> (a /\ c) + (b /\ c)`
675 [
676 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case) THEN (((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)));
677 ];;
678
679 (* Lemma andb_addr *)
680 let andb_addr = Sections.section_proof ["a";"b";"c"]
681 `a /\ (b + c) <=> (a /\ b) + (a /\ c)`
682 [
683 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case) THEN (((use_arg_then2 ("c", [])) (disch_tac [])) THEN (clear_assumption "c") THEN case) THEN (((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case THEN (simp_tac)));
684 ];;
685
686 (* Lemma addKb *)
687 let addKb = Sections.section_proof ["x";"y"]
688 `x + (x + y) <=> y`
689 [
690 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("x", [])) (disch_tac [])) THEN (clear_assumption "x") THEN case) THEN (((use_arg_then2 ("y", [])) (disch_tac [])) THEN (clear_assumption "y") THEN case THEN (simp_tac)));
691 ];;
692
693 (* Lemma addbK *)
694 let addbK = Sections.section_proof ["x";"y"]
695 `(y + x) + x <=> y`
696 [
697 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("x", [])) (disch_tac [])) THEN (clear_assumption "x") THEN case) THEN (((use_arg_then2 ("y", [])) (disch_tac [])) THEN (clear_assumption "y") THEN case THEN (simp_tac)));
698 ];;
699
700 (* Lemma addIb *)
701 let addIb = Sections.section_proof ["x";"y1";"y2"]
702 `(y1 + x <=> y2 + x) ==> (y1 = y2)`
703 [
704 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("y1", [])) (disch_tac [])) THEN (clear_assumption "y1") THEN case) THEN (((use_arg_then2 ("y2", [])) (disch_tac [])) THEN (clear_assumption "y2") THEN case) THEN (((use_arg_then2 ("x", [])) (disch_tac [])) THEN (clear_assumption "x") THEN case THEN (simp_tac)));
705 ];;
706
707 (* Lemma addbI *)
708 let addbI = Sections.section_proof ["x";"y1";"y2"]
709 `(x + y1 <=> x + y2) ==> (y1 = y2)`
710 [
711 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("x", [])) (disch_tac [])) THEN (clear_assumption "x") THEN case) THEN (((use_arg_then2 ("y1", [])) (disch_tac [])) THEN (clear_assumption "y1") THEN case) THEN (((use_arg_then2 ("y2", [])) (disch_tac [])) THEN (clear_assumption "y2") THEN case THEN (simp_tac)));
712 ];;
713
714 (* Lemma addTb *)
715 let addTb = Sections.section_proof ["b"]
716 `T + b <=> ~b`
717 [
718 (((((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (done_tac));
719 ];;
720
721 (* Lemma addbT *)
722 let addbT = Sections.section_proof ["b"]
723 `b + T <=> ~ b`
724 [
725 ((((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)) THEN (done_tac));
726 ];;
727
728 (* Lemma addbN *)
729 let addbN = Sections.section_proof ["a";"b"]
730 `a + ~ b <=> ~ (a + b)`
731 [
732 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)));
733 ];;
734
735 (* Lemma addNb *)
736 let addNb = Sections.section_proof ["a";"b"]
737 `~ a + b <=> ~ (a + b)`
738 [
739 ((repeat_tactic 1 9 (((use_arg_then2 ("XOR_DEF", [XOR_DEF]))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then2 ("a", [])) (disch_tac [])) THEN (clear_assumption "a") THEN case) THEN (((use_arg_then2 ("b", [])) (disch_tac [])) THEN (clear_assumption "b") THEN case THEN (simp_tac)));
740 ];;
741 let subpred = new_definition `subpred p1 p2 <=> (!x. p1 x ==> p2 x)`;;
742 let subrel = new_definition `subrel r1 r2 <=> (!x y. r1 x y ==> r2 x y)`;;
743 let pred0 = new_definition `pred0 = (\x. F)`;;
744 let predT = new_definition `predT = (\x. T)`;;
745 let predI = new_definition `predI p1 p2 = (\x. p1 x /\ p2 x)`;;
746 let predU = new_definition `predU p1 p2 = (\x. p1 x \/ p2 x)`;;
747 let predC = new_definition `predC p = (\x. ~p x)`;;
748 let predD = new_definition `predD p1 p2 = (\x. ~p2 x /\ p1 x)`;;
749 let preim = new_definition `preim f (d:A->bool) = (\x. d (f x))`;;
750 let relU = new_definition `relU r1 r2 = (\x y. r1 x y \/ r2 x y)`;;
751
752 (* Lemma subrelUl *)
753 let subrelUl = Sections.section_proof ["r1";"r2"]
754 `subrel r1 (relU r1 r2)`
755 [
756 (((((use_arg_then2 ("relU", [relU]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subrel", [subrel]))(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac));
757 ];;
758
759 (* Lemma subrelUr *)
760 let subrelUr = Sections.section_proof ["r1";"r2"]
761 `subrel r2 (relU r1 r2)`
762 [
763 (((((use_arg_then2 ("relU", [relU]))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then2 ("subrel", [subrel]))(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac));
764 ];;
765
766 (* Close the module *)
767 end;;