author | wenzelm |
Fri, 02 Jan 1998 13:24:53 +0100 | |
changeset 4508 | f102cb0140fe |
parent 4091 | 771b1f6422a8 |
child 5067 | 62b6288e6005 |
permissions | -rw-r--r-- |
1461 | 1 |
(* Title: ZF/bool |
0 | 2 |
ID: $Id$ |
1461 | 3 |
Author: Martin D Coen, Cambridge University Computer Laboratory |
0 | 4 |
Copyright 1992 University of Cambridge |
5 |
||
6 |
For ZF/bool.thy. Booleans in Zermelo-Fraenkel Set Theory |
|
7 |
*) |
|
8 |
||
9 |
open Bool; |
|
10 |
||
14
1c0926788772
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
6
diff
changeset
|
11 |
val bool_defs = [bool_def,cond_def]; |
0 | 12 |
|
2469 | 13 |
goalw Bool.thy [succ_def] "{0} = 1"; |
2493 | 14 |
by (rtac refl 1); |
2469 | 15 |
qed "singleton_0"; |
16 |
||
0 | 17 |
(* Introduction rules *) |
18 |
||
19 |
goalw Bool.thy bool_defs "1 : bool"; |
|
20 |
by (rtac (consI1 RS consI2) 1); |
|
760 | 21 |
qed "bool_1I"; |
0 | 22 |
|
23 |
goalw Bool.thy bool_defs "0 : bool"; |
|
24 |
by (rtac consI1 1); |
|
760 | 25 |
qed "bool_0I"; |
0 | 26 |
|
37 | 27 |
goalw Bool.thy bool_defs "1~=0"; |
0 | 28 |
by (rtac succ_not_0 1); |
760 | 29 |
qed "one_not_0"; |
0 | 30 |
|
31 |
(** 1=0 ==> R **) |
|
32 |
val one_neq_0 = one_not_0 RS notE; |
|
33 |
||
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
34 |
val major::prems = goalw Bool.thy bool_defs |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
35 |
"[| c: bool; c=1 ==> P; c=0 ==> P |] ==> P"; |
129 | 36 |
by (rtac (major RS consE) 1); |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
37 |
by (REPEAT (eresolve_tac (singletonE::prems) 1)); |
760 | 38 |
qed "boolE"; |
0 | 39 |
|
40 |
(** cond **) |
|
41 |
||
42 |
(*1 means true*) |
|
43 |
goalw Bool.thy bool_defs "cond(1,c,d) = c"; |
|
44 |
by (rtac (refl RS if_P) 1); |
|
760 | 45 |
qed "cond_1"; |
0 | 46 |
|
47 |
(*0 means false*) |
|
48 |
goalw Bool.thy bool_defs "cond(0,c,d) = d"; |
|
49 |
by (rtac (succ_not_0 RS not_sym RS if_not_P) 1); |
|
760 | 50 |
qed "cond_0"; |
0 | 51 |
|
2469 | 52 |
Addsimps [cond_1, cond_0]; |
53 |
||
4091 | 54 |
fun bool_tac i = fast_tac (claset() addSEs [boolE] addss (simpset())) i; |
2469 | 55 |
|
56 |
||
57 |
goal Bool.thy |
|
58 |
"!!b. [| b: bool; c: A(1); d: A(0) |] ==> cond(b,c,d): A(b)"; |
|
59 |
by (bool_tac 1); |
|
760 | 60 |
qed "cond_type"; |
0 | 61 |
|
62 |
val [rew] = goal Bool.thy "[| !!b. j(b)==cond(b,c,d) |] ==> j(1) = c"; |
|
63 |
by (rewtac rew); |
|
64 |
by (rtac cond_1 1); |
|
760 | 65 |
qed "def_cond_1"; |
0 | 66 |
|
67 |
val [rew] = goal Bool.thy "[| !!b. j(b)==cond(b,c,d) |] ==> j(0) = d"; |
|
68 |
by (rewtac rew); |
|
69 |
by (rtac cond_0 1); |
|
760 | 70 |
qed "def_cond_0"; |
0 | 71 |
|
72 |
fun conds def = [standard (def RS def_cond_1), standard (def RS def_cond_0)]; |
|
73 |
||
74 |
val [not_1,not_0] = conds not_def; |
|
75 |
val [and_1,and_0] = conds and_def; |
|
2469 | 76 |
val [or_1,or_0] = conds or_def; |
77 |
val [xor_1,xor_0] = conds xor_def; |
|
0 | 78 |
|
2469 | 79 |
Addsimps [not_1,not_0,and_1,and_0,or_1,or_0,xor_1,xor_0]; |
0 | 80 |
|
760 | 81 |
qed_goalw "not_type" Bool.thy [not_def] |
0 | 82 |
"a:bool ==> not(a) : bool" |
83 |
(fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]); |
|
84 |
||
760 | 85 |
qed_goalw "and_type" Bool.thy [and_def] |
0 | 86 |
"[| a:bool; b:bool |] ==> a and b : bool" |
87 |
(fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]); |
|
88 |
||
760 | 89 |
qed_goalw "or_type" Bool.thy [or_def] |
0 | 90 |
"[| a:bool; b:bool |] ==> a or b : bool" |
91 |
(fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]); |
|
92 |
||
760 | 93 |
qed_goalw "xor_type" Bool.thy [xor_def] |
0 | 94 |
"[| a:bool; b:bool |] ==> a xor b : bool" |
95 |
(fn prems=> [ (typechk_tac(prems@[bool_1I, bool_0I, cond_type, not_type])) ]); |
|
96 |
||
97 |
val bool_typechecks = [bool_1I, bool_0I, cond_type, not_type, and_type, |
|
2469 | 98 |
or_type, xor_type]; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
99 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
100 |
(*** Laws for 'not' ***) |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
101 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
102 |
goal Bool.thy "!!a. a:bool ==> not(not(a)) = a"; |
2469 | 103 |
by (bool_tac 1); |
760 | 104 |
qed "not_not"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
105 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
106 |
goal Bool.thy "!!a b. a:bool ==> not(a and b) = not(a) or not(b)"; |
2469 | 107 |
by (bool_tac 1); |
760 | 108 |
qed "not_and"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
109 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
110 |
goal Bool.thy "!!a b. a:bool ==> not(a or b) = not(a) and not(b)"; |
2469 | 111 |
by (bool_tac 1); |
760 | 112 |
qed "not_or"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
113 |
|
2469 | 114 |
Addsimps [not_not, not_and, not_or]; |
115 |
||
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
116 |
(*** Laws about 'and' ***) |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
117 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
118 |
goal Bool.thy "!!a. a: bool ==> a and a = a"; |
2469 | 119 |
by (bool_tac 1); |
760 | 120 |
qed "and_absorb"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
121 |
|
2469 | 122 |
Addsimps [and_absorb]; |
123 |
||
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
124 |
goal Bool.thy "!!a b. [| a: bool; b:bool |] ==> a and b = b and a"; |
2469 | 125 |
by (bool_tac 1); |
760 | 126 |
qed "and_commute"; |
0 | 127 |
|
2469 | 128 |
goal Bool.thy "!!a. a: bool ==> (a and b) and c = a and (b and c)"; |
129 |
by (bool_tac 1); |
|
760 | 130 |
qed "and_assoc"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
131 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
132 |
goal Bool.thy |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
133 |
"!!a. [| a: bool; b:bool; c:bool |] ==> \ |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
134 |
\ (a or b) and c = (a and c) or (b and c)"; |
2469 | 135 |
by (bool_tac 1); |
760 | 136 |
qed "and_or_distrib"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
137 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
138 |
(** binary orion **) |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
139 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
140 |
goal Bool.thy "!!a. a: bool ==> a or a = a"; |
2469 | 141 |
by (bool_tac 1); |
760 | 142 |
qed "or_absorb"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
143 |
|
2469 | 144 |
Addsimps [or_absorb]; |
145 |
||
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
146 |
goal Bool.thy "!!a b. [| a: bool; b:bool |] ==> a or b = b or a"; |
2469 | 147 |
by (bool_tac 1); |
760 | 148 |
qed "or_commute"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
149 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
150 |
goal Bool.thy "!!a. a: bool ==> (a or b) or c = a or (b or c)"; |
2469 | 151 |
by (bool_tac 1); |
760 | 152 |
qed "or_assoc"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
153 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
154 |
goal Bool.thy |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
155 |
"!!a b c. [| a: bool; b: bool; c: bool |] ==> \ |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
156 |
\ (a and b) or c = (a or c) and (b or c)"; |
2469 | 157 |
by (bool_tac 1); |
760 | 158 |
qed "or_and_distrib"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
159 |