author | wenzelm |
Tue, 07 Mar 2023 23:09:30 +0100 | |
changeset 77569 | a8fa53c086a4 |
parent 76215 | a642599ffdea |
permissions | -rw-r--r-- |
41777 | 1 |
(* Title: ZF/Bool.thy |
1478 | 2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
0 | 3 |
Copyright 1992 University of Cambridge |
13328 | 4 |
*) |
837 | 5 |
|
60770 | 6 |
section\<open>Booleans in Zermelo-Fraenkel Set Theory\<close> |
0 | 7 |
|
16417 | 8 |
theory Bool imports pair begin |
0 | 9 |
|
24892 | 10 |
abbreviation |
69587 | 11 |
one (\<open>1\<close>) where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
12 |
"1 \<equiv> succ(0)" |
2539 | 13 |
|
24892 | 14 |
abbreviation |
69587 | 15 |
two (\<open>2\<close>) where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
16 |
"2 \<equiv> succ(1)" |
14
1c0926788772
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
0
diff
changeset
|
17 |
|
60770 | 18 |
text\<open>2 is equal to bool, but is used as a number rather than a type.\<close> |
13328 | 19 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
20 |
definition "bool \<equiv> {0,1}" |
24893 | 21 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
22 |
definition "cond(b,c,d) \<equiv> if(b=1,c,d)" |
13239 | 23 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
24 |
definition "not(b) \<equiv> cond(b,0,1)" |
13239 | 25 |
|
24893 | 26 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
27 |
"and" :: "[i,i]\<Rightarrow>i" (infixl \<open>and\<close> 70) where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
28 |
"a and b \<equiv> cond(a,b,0)" |
13239 | 29 |
|
24893 | 30 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
31 |
or :: "[i,i]\<Rightarrow>i" (infixl \<open>or\<close> 65) where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
32 |
"a or b \<equiv> cond(a,1,b)" |
13239 | 33 |
|
24893 | 34 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
35 |
xor :: "[i,i]\<Rightarrow>i" (infixl \<open>xor\<close> 65) where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
36 |
"a xor b \<equiv> cond(a,not(b),b)" |
13239 | 37 |
|
38 |
||
39 |
lemmas bool_defs = bool_def cond_def |
|
40 |
||
41 |
lemma singleton_0: "{0} = 1" |
|
42 |
by (simp add: succ_def) |
|
43 |
||
44 |
(* Introduction rules *) |
|
45 |
||
46820 | 46 |
lemma bool_1I [simp,TC]: "1 \<in> bool" |
13239 | 47 |
by (simp add: bool_defs ) |
48 |
||
46820 | 49 |
lemma bool_0I [simp,TC]: "0 \<in> bool" |
13239 | 50 |
by (simp add: bool_defs) |
51 |
||
46820 | 52 |
lemma one_not_0: "1\<noteq>0" |
13239 | 53 |
by (simp add: bool_defs ) |
54 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
55 |
(** 1=0 \<Longrightarrow> R **) |
45602 | 56 |
lemmas one_neq_0 = one_not_0 [THEN notE] |
13239 | 57 |
|
58 |
lemma boolE: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
59 |
"\<lbrakk>c: bool; c=1 \<Longrightarrow> P; c=0 \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
24892 | 60 |
by (simp add: bool_defs, blast) |
13239 | 61 |
|
62 |
(** cond **) |
|
63 |
||
64 |
(*1 means true*) |
|
65 |
lemma cond_1 [simp]: "cond(1,c,d) = c" |
|
66 |
by (simp add: bool_defs ) |
|
67 |
||
68 |
(*0 means false*) |
|
69 |
lemma cond_0 [simp]: "cond(0,c,d) = d" |
|
70 |
by (simp add: bool_defs ) |
|
71 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
72 |
lemma cond_type [TC]: "\<lbrakk>b: bool; c: A(1); d: A(0)\<rbrakk> \<Longrightarrow> cond(b,c,d): A(b)" |
13269 | 73 |
by (simp add: bool_defs, blast) |
13239 | 74 |
|
75 |
(*For Simp_tac and Blast_tac*) |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
76 |
lemma cond_simple_type: "\<lbrakk>b: bool; c: A; d: A\<rbrakk> \<Longrightarrow> cond(b,c,d): A" |
13239 | 77 |
by (simp add: bool_defs ) |
78 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
79 |
lemma def_cond_1: "\<lbrakk>\<And>b. j(b)\<equiv>cond(b,c,d)\<rbrakk> \<Longrightarrow> j(1) = c" |
13239 | 80 |
by simp |
81 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
82 |
lemma def_cond_0: "\<lbrakk>\<And>b. j(b)\<equiv>cond(b,c,d)\<rbrakk> \<Longrightarrow> j(0) = d" |
13239 | 83 |
by simp |
84 |
||
45602 | 85 |
lemmas not_1 = not_def [THEN def_cond_1, simp] |
86 |
lemmas not_0 = not_def [THEN def_cond_0, simp] |
|
13239 | 87 |
|
45602 | 88 |
lemmas and_1 = and_def [THEN def_cond_1, simp] |
89 |
lemmas and_0 = and_def [THEN def_cond_0, simp] |
|
13239 | 90 |
|
45602 | 91 |
lemmas or_1 = or_def [THEN def_cond_1, simp] |
92 |
lemmas or_0 = or_def [THEN def_cond_0, simp] |
|
13239 | 93 |
|
45602 | 94 |
lemmas xor_1 = xor_def [THEN def_cond_1, simp] |
95 |
lemmas xor_0 = xor_def [THEN def_cond_0, simp] |
|
13239 | 96 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
97 |
lemma not_type [TC]: "a:bool \<Longrightarrow> not(a) \<in> bool" |
13239 | 98 |
by (simp add: not_def) |
99 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
100 |
lemma and_type [TC]: "\<lbrakk>a:bool; b:bool\<rbrakk> \<Longrightarrow> a and b \<in> bool" |
13239 | 101 |
by (simp add: and_def) |
102 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
103 |
lemma or_type [TC]: "\<lbrakk>a:bool; b:bool\<rbrakk> \<Longrightarrow> a or b \<in> bool" |
13239 | 104 |
by (simp add: or_def) |
105 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
106 |
lemma xor_type [TC]: "\<lbrakk>a:bool; b:bool\<rbrakk> \<Longrightarrow> a xor b \<in> bool" |
13239 | 107 |
by (simp add: xor_def) |
108 |
||
109 |
lemmas bool_typechecks = bool_1I bool_0I cond_type not_type and_type |
|
110 |
or_type xor_type |
|
111 |
||
60770 | 112 |
subsection\<open>Laws About 'not'\<close> |
13239 | 113 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
114 |
lemma not_not [simp]: "a:bool \<Longrightarrow> not(not(a)) = a" |
13239 | 115 |
by (elim boolE, auto) |
116 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
117 |
lemma not_and [simp]: "a:bool \<Longrightarrow> not(a and b) = not(a) or not(b)" |
13239 | 118 |
by (elim boolE, auto) |
119 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
120 |
lemma not_or [simp]: "a:bool \<Longrightarrow> not(a or b) = not(a) and not(b)" |
13239 | 121 |
by (elim boolE, auto) |
122 |
||
60770 | 123 |
subsection\<open>Laws About 'and'\<close> |
13239 | 124 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
125 |
lemma and_absorb [simp]: "a: bool \<Longrightarrow> a and a = a" |
13239 | 126 |
by (elim boolE, auto) |
127 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
128 |
lemma and_commute: "\<lbrakk>a: bool; b:bool\<rbrakk> \<Longrightarrow> a and b = b and a" |
13239 | 129 |
by (elim boolE, auto) |
130 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
131 |
lemma and_assoc: "a: bool \<Longrightarrow> (a and b) and c = a and (b and c)" |
13239 | 132 |
by (elim boolE, auto) |
133 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
134 |
lemma and_or_distrib: "\<lbrakk>a: bool; b:bool; c:bool\<rbrakk> \<Longrightarrow> |
13239 | 135 |
(a or b) and c = (a and c) or (b and c)" |
136 |
by (elim boolE, auto) |
|
137 |
||
60770 | 138 |
subsection\<open>Laws About 'or'\<close> |
13239 | 139 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
140 |
lemma or_absorb [simp]: "a: bool \<Longrightarrow> a or a = a" |
13239 | 141 |
by (elim boolE, auto) |
142 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
143 |
lemma or_commute: "\<lbrakk>a: bool; b:bool\<rbrakk> \<Longrightarrow> a or b = b or a" |
13239 | 144 |
by (elim boolE, auto) |
145 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
146 |
lemma or_assoc: "a: bool \<Longrightarrow> (a or b) or c = a or (b or c)" |
13239 | 147 |
by (elim boolE, auto) |
148 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
149 |
lemma or_and_distrib: "\<lbrakk>a: bool; b: bool; c: bool\<rbrakk> \<Longrightarrow> |
13239 | 150 |
(a and b) or c = (a or c) and (b or c)" |
151 |
by (elim boolE, auto) |
|
152 |
||
13269 | 153 |
|
24893 | 154 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
155 |
bool_of_o :: "o\<Rightarrow>i" where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
156 |
"bool_of_o(P) \<equiv> (if P then 1 else 0)" |
13269 | 157 |
|
158 |
lemma [simp]: "bool_of_o(True) = 1" |
|
24892 | 159 |
by (simp add: bool_of_o_def) |
13269 | 160 |
|
161 |
lemma [simp]: "bool_of_o(False) = 0" |
|
24892 | 162 |
by (simp add: bool_of_o_def) |
13269 | 163 |
|
164 |
lemma [simp,TC]: "bool_of_o(P) \<in> bool" |
|
24892 | 165 |
by (simp add: bool_of_o_def) |
13269 | 166 |
|
46821
ff6b0c1087f2
Using mathematical notation for <-> and cardinal arithmetic
paulson
parents:
46820
diff
changeset
|
167 |
lemma [simp]: "(bool_of_o(P) = 1) \<longleftrightarrow> P" |
24892 | 168 |
by (simp add: bool_of_o_def) |
13269 | 169 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69587
diff
changeset
|
170 |
lemma [simp]: "(bool_of_o(P) = 0) \<longleftrightarrow> \<not>P" |
24892 | 171 |
by (simp add: bool_of_o_def) |
13269 | 172 |
|
0 | 173 |
end |