author | nipkow |
Tue, 12 Jan 1999 15:48:59 +0100 | |
changeset 6099 | d4866f6ff2f9 |
parent 6053 | 8a1059aa01f0 |
child 6153 | bff90585cce5 |
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 |
||
5268 | 6 |
Booleans in Zermelo-Fraenkel Set Theory |
0 | 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 |
|
5067 | 13 |
Goalw [succ_def] "{0} = 1"; |
2493 | 14 |
by (rtac refl 1); |
2469 | 15 |
qed "singleton_0"; |
16 |
||
0 | 17 |
(* Introduction rules *) |
18 |
||
5067 | 19 |
Goalw bool_defs "1 : bool"; |
0 | 20 |
by (rtac (consI1 RS consI2) 1); |
760 | 21 |
qed "bool_1I"; |
0 | 22 |
|
5067 | 23 |
Goalw bool_defs "0 : bool"; |
0 | 24 |
by (rtac consI1 1); |
760 | 25 |
qed "bool_0I"; |
0 | 26 |
|
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
27 |
Addsimps [bool_1I, bool_0I]; |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
28 |
|
5067 | 29 |
Goalw bool_defs "1~=0"; |
0 | 30 |
by (rtac succ_not_0 1); |
760 | 31 |
qed "one_not_0"; |
0 | 32 |
|
33 |
(** 1=0 ==> R **) |
|
34 |
val one_neq_0 = one_not_0 RS notE; |
|
35 |
||
5268 | 36 |
val major::prems = Goalw bool_defs |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
37 |
"[| c: bool; c=1 ==> P; c=0 ==> P |] ==> P"; |
129 | 38 |
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
|
39 |
by (REPEAT (eresolve_tac (singletonE::prems) 1)); |
760 | 40 |
qed "boolE"; |
0 | 41 |
|
42 |
(** cond **) |
|
43 |
||
44 |
(*1 means true*) |
|
5067 | 45 |
Goalw bool_defs "cond(1,c,d) = c"; |
0 | 46 |
by (rtac (refl RS if_P) 1); |
760 | 47 |
qed "cond_1"; |
0 | 48 |
|
49 |
(*0 means false*) |
|
5067 | 50 |
Goalw bool_defs "cond(0,c,d) = d"; |
0 | 51 |
by (rtac (succ_not_0 RS not_sym RS if_not_P) 1); |
760 | 52 |
qed "cond_0"; |
0 | 53 |
|
2469 | 54 |
Addsimps [cond_1, cond_0]; |
55 |
||
4091 | 56 |
fun bool_tac i = fast_tac (claset() addSEs [boolE] addss (simpset())) i; |
2469 | 57 |
|
58 |
||
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
59 |
Goal "[| b: bool; c: A(1); d: A(0) |] ==> cond(b,c,d): A(b)"; |
2469 | 60 |
by (bool_tac 1); |
760 | 61 |
qed "cond_type"; |
0 | 62 |
|
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
63 |
(*For Simp_tac and Blast_tac*) |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
64 |
Goal "[| b: bool; c: A; d: A |] ==> cond(b,c,d): A"; |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
65 |
by (bool_tac 1); |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
66 |
qed "cond_simple_type"; |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
67 |
Addsimps [cond_simple_type]; |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
68 |
|
5268 | 69 |
val [rew] = Goal "[| !!b. j(b)==cond(b,c,d) |] ==> j(1) = c"; |
0 | 70 |
by (rewtac rew); |
71 |
by (rtac cond_1 1); |
|
760 | 72 |
qed "def_cond_1"; |
0 | 73 |
|
5268 | 74 |
val [rew] = Goal "[| !!b. j(b)==cond(b,c,d) |] ==> j(0) = d"; |
0 | 75 |
by (rewtac rew); |
76 |
by (rtac cond_0 1); |
|
760 | 77 |
qed "def_cond_0"; |
0 | 78 |
|
79 |
fun conds def = [standard (def RS def_cond_1), standard (def RS def_cond_0)]; |
|
80 |
||
81 |
val [not_1,not_0] = conds not_def; |
|
82 |
val [and_1,and_0] = conds and_def; |
|
2469 | 83 |
val [or_1,or_0] = conds or_def; |
84 |
val [xor_1,xor_0] = conds xor_def; |
|
0 | 85 |
|
2469 | 86 |
Addsimps [not_1,not_0,and_1,and_0,or_1,or_0,xor_1,xor_0]; |
0 | 87 |
|
760 | 88 |
qed_goalw "not_type" Bool.thy [not_def] |
0 | 89 |
"a:bool ==> not(a) : bool" |
90 |
(fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]); |
|
91 |
||
760 | 92 |
qed_goalw "and_type" Bool.thy [and_def] |
0 | 93 |
"[| a:bool; b:bool |] ==> a and b : bool" |
94 |
(fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]); |
|
95 |
||
760 | 96 |
qed_goalw "or_type" Bool.thy [or_def] |
0 | 97 |
"[| a:bool; b:bool |] ==> a or b : bool" |
98 |
(fn prems=> [ (typechk_tac (prems@[bool_1I, bool_0I, cond_type])) ]); |
|
99 |
||
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
100 |
Addsimps [not_type, and_type, or_type]; |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
101 |
|
760 | 102 |
qed_goalw "xor_type" Bool.thy [xor_def] |
0 | 103 |
"[| a:bool; b:bool |] ==> a xor b : bool" |
104 |
(fn prems=> [ (typechk_tac(prems@[bool_1I, bool_0I, cond_type, not_type])) ]); |
|
105 |
||
6053
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
106 |
Addsimps [xor_type]; |
8a1059aa01f0
new inductive, datatype and primrec packages, etc.
paulson
parents:
5268
diff
changeset
|
107 |
|
0 | 108 |
val bool_typechecks = [bool_1I, bool_0I, cond_type, not_type, and_type, |
2469 | 109 |
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
|
110 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
111 |
(*** Laws for 'not' ***) |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
112 |
|
5137 | 113 |
Goal "a:bool ==> not(not(a)) = a"; |
2469 | 114 |
by (bool_tac 1); |
760 | 115 |
qed "not_not"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
116 |
|
5137 | 117 |
Goal "a:bool ==> not(a and b) = not(a) or not(b)"; |
2469 | 118 |
by (bool_tac 1); |
760 | 119 |
qed "not_and"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
120 |
|
5137 | 121 |
Goal "a:bool ==> not(a or b) = not(a) and not(b)"; |
2469 | 122 |
by (bool_tac 1); |
760 | 123 |
qed "not_or"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
124 |
|
2469 | 125 |
Addsimps [not_not, not_and, not_or]; |
126 |
||
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
127 |
(*** Laws about 'and' ***) |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
128 |
|
5137 | 129 |
Goal "a: bool ==> a and a = a"; |
2469 | 130 |
by (bool_tac 1); |
760 | 131 |
qed "and_absorb"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
132 |
|
2469 | 133 |
Addsimps [and_absorb]; |
134 |
||
5137 | 135 |
Goal "[| a: bool; b:bool |] ==> a and b = b and a"; |
2469 | 136 |
by (bool_tac 1); |
760 | 137 |
qed "and_commute"; |
0 | 138 |
|
5137 | 139 |
Goal "a: bool ==> (a and b) and c = a and (b and c)"; |
2469 | 140 |
by (bool_tac 1); |
760 | 141 |
qed "and_assoc"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
142 |
|
5268 | 143 |
Goal "[| a: bool; b:bool; c:bool |] ==> \ |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
144 |
\ (a or b) and c = (a and c) or (b and c)"; |
2469 | 145 |
by (bool_tac 1); |
760 | 146 |
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
|
147 |
|
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
148 |
(** binary orion **) |
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
149 |
|
5137 | 150 |
Goal "a: bool ==> a or a = a"; |
2469 | 151 |
by (bool_tac 1); |
760 | 152 |
qed "or_absorb"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
153 |
|
2469 | 154 |
Addsimps [or_absorb]; |
155 |
||
5137 | 156 |
Goal "[| a: bool; b:bool |] ==> a or b = b or a"; |
2469 | 157 |
by (bool_tac 1); |
760 | 158 |
qed "or_commute"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
159 |
|
5137 | 160 |
Goal "a: bool ==> (a or b) or c = a or (b or c)"; |
2469 | 161 |
by (bool_tac 1); |
760 | 162 |
qed "or_assoc"; |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
163 |
|
5268 | 164 |
Goal "[| a: bool; b: bool; c: bool |] ==> \ |
119
0e58da397b1d
boolE: changed to have equality assumptions instead of P(c); proved many boolean laws
lcp
parents:
37
diff
changeset
|
165 |
\ (a and b) or c = (a or c) and (b or c)"; |
2469 | 166 |
by (bool_tac 1); |
760 | 167 |
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
|
168 |