author | wenzelm |
Sun, 29 Jul 2007 14:29:49 +0200 | |
changeset 24035 | 74c032aea9ed |
parent 23948 | 261bd4678076 |
child 24166 | 7b28dc69bdbb |
permissions | -rw-r--r-- |
923 | 1 |
(* Title: HOL/HOL.thy |
2 |
ID: $Id$ |
|
11750 | 3 |
Author: Tobias Nipkow, Markus Wenzel, and Larry Paulson |
4 |
*) |
|
923 | 5 |
|
11750 | 6 |
header {* The basis of Higher-Order Logic *} |
923 | 7 |
|
15131 | 8 |
theory HOL |
15140 | 9 |
imports CPure |
23163 | 10 |
uses |
23247 | 11 |
"~~/src/Tools/integer.ML" |
23553 | 12 |
("hologic.ML") |
23171 | 13 |
"~~/src/Tools/IsaPlanner/zipper.ML" |
14 |
"~~/src/Tools/IsaPlanner/isand.ML" |
|
15 |
"~~/src/Tools/IsaPlanner/rw_tools.ML" |
|
16 |
"~~/src/Tools/IsaPlanner/rw_inst.ML" |
|
23263 | 17 |
"~~/src/Provers/project_rule.ML" |
23163 | 18 |
"~~/src/Provers/induct_method.ML" |
23263 | 19 |
"~~/src/Provers/hypsubst.ML" |
20 |
"~~/src/Provers/splitter.ML" |
|
23163 | 21 |
"~~/src/Provers/classical.ML" |
22 |
"~~/src/Provers/blast.ML" |
|
23 |
"~~/src/Provers/clasimp.ML" |
|
23263 | 24 |
"~~/src/Provers/eqsubst.ML" |
23163 | 25 |
"~~/src/Provers/quantifier1.ML" |
26 |
("simpdata.ML") |
|
23247 | 27 |
("~~/src/HOL/Tools/recfun_codegen.ML") |
15131 | 28 |
begin |
2260 | 29 |
|
11750 | 30 |
subsection {* Primitive logic *} |
31 |
||
32 |
subsubsection {* Core syntax *} |
|
2260 | 33 |
|
14854 | 34 |
classes type |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
35 |
defaultsort type |
3947 | 36 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
37 |
global |
923 | 38 |
|
7357 | 39 |
typedecl bool |
923 | 40 |
|
41 |
arities |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
42 |
bool :: type |
20590
bf92900995f8
introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents:
20453
diff
changeset
|
43 |
"fun" :: (type, type) type |
923 | 44 |
|
11750 | 45 |
judgment |
46 |
Trueprop :: "bool => prop" ("(_)" 5) |
|
923 | 47 |
|
11750 | 48 |
consts |
7357 | 49 |
Not :: "bool => bool" ("~ _" [40] 40) |
50 |
True :: bool |
|
51 |
False :: bool |
|
3947 | 52 |
arbitrary :: 'a |
923 | 53 |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
54 |
The :: "('a => bool) => 'a" |
7357 | 55 |
All :: "('a => bool) => bool" (binder "ALL " 10) |
56 |
Ex :: "('a => bool) => bool" (binder "EX " 10) |
|
57 |
Ex1 :: "('a => bool) => bool" (binder "EX! " 10) |
|
58 |
Let :: "['a, 'a => 'b] => 'b" |
|
923 | 59 |
|
22839 | 60 |
"op =" :: "['a, 'a] => bool" (infixl "=" 50) |
61 |
"op &" :: "[bool, bool] => bool" (infixr "&" 35) |
|
62 |
"op |" :: "[bool, bool] => bool" (infixr "|" 30) |
|
63 |
"op -->" :: "[bool, bool] => bool" (infixr "-->" 25) |
|
923 | 64 |
|
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
65 |
local |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
66 |
|
16587 | 67 |
consts |
68 |
If :: "[bool, 'a, 'a] => 'a" ("(if (_)/ then (_)/ else (_))" 10) |
|
2260 | 69 |
|
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
70 |
|
11750 | 71 |
subsubsection {* Additional concrete syntax *} |
2260 | 72 |
|
21210 | 73 |
notation (output) |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
74 |
"op =" (infix "=" 50) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
75 |
|
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
76 |
abbreviation |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
77 |
not_equal :: "['a, 'a] => bool" (infixl "~=" 50) where |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
78 |
"x ~= y == ~ (x = y)" |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
79 |
|
21210 | 80 |
notation (output) |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
81 |
not_equal (infix "~=" 50) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
82 |
|
21210 | 83 |
notation (xsymbols) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
84 |
Not ("\<not> _" [40] 40) and |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
85 |
"op &" (infixr "\<and>" 35) and |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
86 |
"op |" (infixr "\<or>" 30) and |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
87 |
"op -->" (infixr "\<longrightarrow>" 25) and |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
88 |
not_equal (infix "\<noteq>" 50) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
89 |
|
21210 | 90 |
notation (HTML output) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
91 |
Not ("\<not> _" [40] 40) and |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
92 |
"op &" (infixr "\<and>" 35) and |
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
93 |
"op |" (infixr "\<or>" 30) and |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
94 |
not_equal (infix "\<noteq>" 50) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
95 |
|
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
96 |
abbreviation (iff) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21250
diff
changeset
|
97 |
iff :: "[bool, bool] => bool" (infixr "<->" 25) where |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
98 |
"A <-> B == A = B" |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
99 |
|
21210 | 100 |
notation (xsymbols) |
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
101 |
iff (infixr "\<longleftrightarrow>" 25) |
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
102 |
|
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
103 |
|
4868 | 104 |
nonterminals |
923 | 105 |
letbinds letbind |
106 |
case_syn cases_syn |
|
107 |
||
108 |
syntax |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
109 |
"_The" :: "[pttrn, bool] => 'a" ("(3THE _./ _)" [0, 10] 10) |
923 | 110 |
|
7357 | 111 |
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) |
112 |
"" :: "letbind => letbinds" ("_") |
|
113 |
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") |
|
114 |
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) |
|
923 | 115 |
|
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
116 |
"_case_syntax":: "['a, cases_syn] => 'b" ("(case _ of/ _)" 10) |
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
117 |
"_case1" :: "['a, 'b] => case_syn" ("(2_ =>/ _)" 10) |
7357 | 118 |
"" :: "case_syn => cases_syn" ("_") |
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
119 |
"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ | _") |
923 | 120 |
|
121 |
translations |
|
13764 | 122 |
"THE x. P" == "The (%x. P)" |
923 | 123 |
"_Let (_binds b bs) e" == "_Let b (_Let bs e)" |
1114 | 124 |
"let x = a in e" == "Let a (%x. e)" |
923 | 125 |
|
13763
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
126 |
print_translation {* |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
127 |
(* To avoid eta-contraction of body: *) |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
128 |
[("The", fn [Abs abs] => |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
129 |
let val (x,t) = atomic_abs_tr' abs |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
130 |
in Syntax.const "_The" $ x $ t end)] |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
131 |
*} |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
132 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
133 |
syntax (xsymbols) |
11687 | 134 |
"_case1" :: "['a, 'b] => case_syn" ("(2_ \<Rightarrow>/ _)" 10) |
21524 | 135 |
|
136 |
notation (xsymbols) |
|
137 |
All (binder "\<forall>" 10) and |
|
138 |
Ex (binder "\<exists>" 10) and |
|
139 |
Ex1 (binder "\<exists>!" 10) |
|
2372 | 140 |
|
21524 | 141 |
notation (HTML output) |
142 |
All (binder "\<forall>" 10) and |
|
143 |
Ex (binder "\<exists>" 10) and |
|
144 |
Ex1 (binder "\<exists>!" 10) |
|
6340 | 145 |
|
21524 | 146 |
notation (HOL) |
147 |
All (binder "! " 10) and |
|
148 |
Ex (binder "? " 10) and |
|
149 |
Ex1 (binder "?! " 10) |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
150 |
|
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
151 |
|
11750 | 152 |
subsubsection {* Axioms and basic definitions *} |
2260 | 153 |
|
7357 | 154 |
axioms |
15380 | 155 |
eq_reflection: "(x=y) ==> (x==y)" |
923 | 156 |
|
15380 | 157 |
refl: "t = (t::'a)" |
6289 | 158 |
|
15380 | 159 |
ext: "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" |
160 |
-- {*Extensionality is built into the meta-logic, and this rule expresses |
|
161 |
a related property. It is an eta-expanded version of the traditional |
|
162 |
rule, and similar to the ABS rule of HOL*} |
|
6289 | 163 |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
164 |
the_eq_trivial: "(THE x. x = a) = (a::'a)" |
923 | 165 |
|
15380 | 166 |
impI: "(P ==> Q) ==> P-->Q" |
167 |
mp: "[| P-->Q; P |] ==> Q" |
|
168 |
||
169 |
||
923 | 170 |
defs |
7357 | 171 |
True_def: "True == ((%x::bool. x) = (%x. x))" |
172 |
All_def: "All(P) == (P = (%x. True))" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
173 |
Ex_def: "Ex(P) == !Q. (!x. P x --> Q) --> Q" |
7357 | 174 |
False_def: "False == (!P. P)" |
175 |
not_def: "~ P == P-->False" |
|
176 |
and_def: "P & Q == !R. (P-->Q-->R) --> R" |
|
177 |
or_def: "P | Q == !R. (P-->R) --> (Q-->R) --> R" |
|
178 |
Ex1_def: "Ex1(P) == ? x. P(x) & (! y. P(y) --> y=x)" |
|
923 | 179 |
|
7357 | 180 |
axioms |
181 |
iff: "(P-->Q) --> (Q-->P) --> (P=Q)" |
|
182 |
True_or_False: "(P=True) | (P=False)" |
|
923 | 183 |
|
184 |
defs |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22481
diff
changeset
|
185 |
Let_def [code func]: "Let s f == f(s)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
186 |
if_def: "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)" |
5069 | 187 |
|
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
188 |
finalconsts |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
189 |
"op =" |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
190 |
"op -->" |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
191 |
The |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
192 |
arbitrary |
22481
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
193 |
|
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
194 |
axiomatization |
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
195 |
undefined :: 'a |
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
196 |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22481
diff
changeset
|
197 |
axiomatization where |
22481
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
198 |
undefined_fun: "undefined x = undefined" |
3320 | 199 |
|
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19607
diff
changeset
|
200 |
|
22481
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
201 |
subsubsection {* Generic classes and algebraic operations *} |
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
202 |
|
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
203 |
class default = type + |
79c2724c36b5
added class "default" and expansion axioms for undefined
haftmann
parents:
22473
diff
changeset
|
204 |
fixes default :: "'a" |
4868 | 205 |
|
22473 | 206 |
class zero = type + |
21524 | 207 |
fixes zero :: "'a" ("\<^loc>0") |
20713
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
208 |
|
22473 | 209 |
class one = type + |
21524 | 210 |
fixes one :: "'a" ("\<^loc>1") |
20713
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
211 |
|
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
212 |
hide (open) const zero one |
20590
bf92900995f8
introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents:
20453
diff
changeset
|
213 |
|
22473 | 214 |
class plus = type + |
21524 | 215 |
fixes plus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>+" 65) |
11750 | 216 |
|
22473 | 217 |
class minus = type + |
20590
bf92900995f8
introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents:
20453
diff
changeset
|
218 |
fixes uminus :: "'a \<Rightarrow> 'a" |
21524 | 219 |
and minus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>-" 65) |
20590
bf92900995f8
introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents:
20453
diff
changeset
|
220 |
|
22473 | 221 |
class times = type + |
20713
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
222 |
fixes times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>*" 70) |
20590
bf92900995f8
introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents:
20453
diff
changeset
|
223 |
|
22473 | 224 |
class inverse = type + |
20590
bf92900995f8
introduced syntactic classes; moved some setup to Pure/codegen, Pure/nbe or OperationalEquality.thy
haftmann
parents:
20453
diff
changeset
|
225 |
fixes inverse :: "'a \<Rightarrow> 'a" |
21524 | 226 |
and divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>'/" 70) |
227 |
||
23878 | 228 |
class abs = type + |
229 |
fixes abs :: "'a \<Rightarrow> 'a" |
|
230 |
||
21524 | 231 |
notation |
232 |
uminus ("- _" [81] 80) |
|
233 |
||
234 |
notation (xsymbols) |
|
235 |
abs ("\<bar>_\<bar>") |
|
236 |
notation (HTML output) |
|
237 |
abs ("\<bar>_\<bar>") |
|
11750 | 238 |
|
23878 | 239 |
class ord = type + |
240 |
fixes less_eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubseteq>" 50) |
|
241 |
and less :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubset>" 50) |
|
242 |
begin |
|
243 |
||
244 |
notation |
|
245 |
less_eq ("op \<^loc><=") and |
|
246 |
less_eq ("(_/ \<^loc><= _)" [51, 51] 50) and |
|
247 |
less ("op \<^loc><") and |
|
248 |
less ("(_/ \<^loc>< _)" [51, 51] 50) |
|
249 |
||
250 |
notation (xsymbols) |
|
251 |
less_eq ("op \<^loc>\<le>") and |
|
252 |
less_eq ("(_/ \<^loc>\<le> _)" [51, 51] 50) |
|
253 |
||
254 |
notation (HTML output) |
|
255 |
less_eq ("op \<^loc>\<le>") and |
|
256 |
less_eq ("(_/ \<^loc>\<le> _)" [51, 51] 50) |
|
257 |
||
258 |
abbreviation (input) |
|
259 |
greater (infix "\<^loc>>" 50) where |
|
260 |
"x \<^loc>> y \<equiv> y \<^loc>< x" |
|
261 |
||
262 |
abbreviation (input) |
|
263 |
greater_eq (infix "\<^loc>>=" 50) where |
|
264 |
"x \<^loc>>= y \<equiv> y \<^loc><= x" |
|
265 |
||
266 |
notation (input) |
|
267 |
greater_eq (infix "\<^loc>\<ge>" 50) |
|
268 |
||
269 |
definition |
|
270 |
Least :: "('a \<Rightarrow> bool) \<Rightarrow> 'a" (binder "\<^loc>LEAST " 10) |
|
271 |
where |
|
272 |
"Least P == (THE x. P x \<and> (\<forall>y. P y \<longrightarrow> x \<^loc>\<le> y))" |
|
273 |
||
274 |
end |
|
275 |
||
276 |
notation |
|
277 |
less_eq ("op <=") and |
|
278 |
less_eq ("(_/ <= _)" [51, 51] 50) and |
|
279 |
less ("op <") and |
|
280 |
less ("(_/ < _)" [51, 51] 50) |
|
281 |
||
282 |
notation (xsymbols) |
|
283 |
less_eq ("op \<le>") and |
|
284 |
less_eq ("(_/ \<le> _)" [51, 51] 50) |
|
285 |
||
286 |
notation (HTML output) |
|
287 |
less_eq ("op \<le>") and |
|
288 |
less_eq ("(_/ \<le> _)" [51, 51] 50) |
|
289 |
||
290 |
abbreviation (input) |
|
291 |
greater (infix ">" 50) where |
|
292 |
"x > y \<equiv> y < x" |
|
293 |
||
294 |
abbreviation (input) |
|
295 |
greater_eq (infix ">=" 50) where |
|
296 |
"x >= y \<equiv> y <= x" |
|
297 |
||
298 |
notation (input) |
|
299 |
greater_eq (infix "\<ge>" 50) |
|
300 |
||
13456
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset
|
301 |
syntax |
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset
|
302 |
"_index1" :: index ("\<^sub>1") |
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset
|
303 |
translations |
14690 | 304 |
(index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>" |
13456
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset
|
305 |
|
11750 | 306 |
typed_print_translation {* |
20713
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
307 |
let |
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
308 |
fun tr' c = (c, fn show_sorts => fn T => fn ts => |
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
309 |
if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match |
823967ef47f1
renamed 0 and 1 to HOL.zero and HOL.one respectivly; introduced corresponding syntactic classes
haftmann
parents:
20698
diff
changeset
|
310 |
else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T); |
22993 | 311 |
in map tr' [@{const_syntax HOL.one}, @{const_syntax HOL.zero}] end; |
11750 | 312 |
*} -- {* show types that are presumably too general *} |
313 |
||
314 |
||
20944 | 315 |
subsection {* Fundamental rules *} |
316 |
||
20973 | 317 |
subsubsection {* Equality *} |
20944 | 318 |
|
319 |
text {* Thanks to Stephan Merz *} |
|
320 |
lemma subst: |
|
321 |
assumes eq: "s = t" and p: "P s" |
|
322 |
shows "P t" |
|
323 |
proof - |
|
324 |
from eq have meta: "s \<equiv> t" |
|
325 |
by (rule eq_reflection) |
|
326 |
from p show ?thesis |
|
327 |
by (unfold meta) |
|
328 |
qed |
|
15411 | 329 |
|
18457 | 330 |
lemma sym: "s = t ==> t = s" |
331 |
by (erule subst) (rule refl) |
|
15411 | 332 |
|
18457 | 333 |
lemma ssubst: "t = s ==> P s ==> P t" |
334 |
by (drule sym) (erule subst) |
|
15411 | 335 |
|
336 |
lemma trans: "[| r=s; s=t |] ==> r=t" |
|
18457 | 337 |
by (erule subst) |
15411 | 338 |
|
20944 | 339 |
lemma meta_eq_to_obj_eq: |
340 |
assumes meq: "A == B" |
|
341 |
shows "A = B" |
|
342 |
by (unfold meq) (rule refl) |
|
15411 | 343 |
|
21502 | 344 |
text {* Useful with @{text erule} for proving equalities from known equalities. *} |
20944 | 345 |
(* a = b |
15411 | 346 |
| | |
347 |
c = d *) |
|
348 |
lemma box_equals: "[| a=b; a=c; b=d |] ==> c=d" |
|
349 |
apply (rule trans) |
|
350 |
apply (rule trans) |
|
351 |
apply (rule sym) |
|
352 |
apply assumption+ |
|
353 |
done |
|
354 |
||
15524
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
355 |
text {* For calculational reasoning: *} |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
356 |
|
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
357 |
lemma forw_subst: "a = b ==> P b ==> P a" |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
358 |
by (rule ssubst) |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
359 |
|
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
360 |
lemma back_subst: "P a ==> a = b ==> P b" |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
361 |
by (rule subst) |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
362 |
|
15411 | 363 |
|
20944 | 364 |
subsubsection {*Congruence rules for application*} |
15411 | 365 |
|
366 |
(*similar to AP_THM in Gordon's HOL*) |
|
367 |
lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)" |
|
368 |
apply (erule subst) |
|
369 |
apply (rule refl) |
|
370 |
done |
|
371 |
||
372 |
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*) |
|
373 |
lemma arg_cong: "x=y ==> f(x)=f(y)" |
|
374 |
apply (erule subst) |
|
375 |
apply (rule refl) |
|
376 |
done |
|
377 |
||
15655 | 378 |
lemma arg_cong2: "\<lbrakk> a = b; c = d \<rbrakk> \<Longrightarrow> f a c = f b d" |
379 |
apply (erule ssubst)+ |
|
380 |
apply (rule refl) |
|
381 |
done |
|
382 |
||
15411 | 383 |
lemma cong: "[| f = g; (x::'a) = y |] ==> f(x) = g(y)" |
384 |
apply (erule subst)+ |
|
385 |
apply (rule refl) |
|
386 |
done |
|
387 |
||
388 |
||
20944 | 389 |
subsubsection {*Equality of booleans -- iff*} |
15411 | 390 |
|
21504 | 391 |
lemma iffI: assumes "P ==> Q" and "Q ==> P" shows "P=Q" |
392 |
by (iprover intro: iff [THEN mp, THEN mp] impI assms) |
|
15411 | 393 |
|
394 |
lemma iffD2: "[| P=Q; Q |] ==> P" |
|
18457 | 395 |
by (erule ssubst) |
15411 | 396 |
|
397 |
lemma rev_iffD2: "[| Q; P=Q |] ==> P" |
|
18457 | 398 |
by (erule iffD2) |
15411 | 399 |
|
21504 | 400 |
lemma iffD1: "Q = P \<Longrightarrow> Q \<Longrightarrow> P" |
401 |
by (drule sym) (rule iffD2) |
|
402 |
||
403 |
lemma rev_iffD1: "Q \<Longrightarrow> Q = P \<Longrightarrow> P" |
|
404 |
by (drule sym) (rule rev_iffD2) |
|
15411 | 405 |
|
406 |
lemma iffE: |
|
407 |
assumes major: "P=Q" |
|
21504 | 408 |
and minor: "[| P --> Q; Q --> P |] ==> R" |
18457 | 409 |
shows R |
410 |
by (iprover intro: minor impI major [THEN iffD2] major [THEN iffD1]) |
|
15411 | 411 |
|
412 |
||
20944 | 413 |
subsubsection {*True*} |
15411 | 414 |
|
415 |
lemma TrueI: "True" |
|
21504 | 416 |
unfolding True_def by (rule refl) |
15411 | 417 |
|
21504 | 418 |
lemma eqTrueI: "P ==> P = True" |
18457 | 419 |
by (iprover intro: iffI TrueI) |
15411 | 420 |
|
21504 | 421 |
lemma eqTrueE: "P = True ==> P" |
422 |
by (erule iffD2) (rule TrueI) |
|
15411 | 423 |
|
424 |
||
20944 | 425 |
subsubsection {*Universal quantifier*} |
15411 | 426 |
|
21504 | 427 |
lemma allI: assumes "!!x::'a. P(x)" shows "ALL x. P(x)" |
428 |
unfolding All_def by (iprover intro: ext eqTrueI assms) |
|
15411 | 429 |
|
430 |
lemma spec: "ALL x::'a. P(x) ==> P(x)" |
|
431 |
apply (unfold All_def) |
|
432 |
apply (rule eqTrueE) |
|
433 |
apply (erule fun_cong) |
|
434 |
done |
|
435 |
||
436 |
lemma allE: |
|
437 |
assumes major: "ALL x. P(x)" |
|
21504 | 438 |
and minor: "P(x) ==> R" |
439 |
shows R |
|
440 |
by (iprover intro: minor major [THEN spec]) |
|
15411 | 441 |
|
442 |
lemma all_dupE: |
|
443 |
assumes major: "ALL x. P(x)" |
|
21504 | 444 |
and minor: "[| P(x); ALL x. P(x) |] ==> R" |
445 |
shows R |
|
446 |
by (iprover intro: minor major major [THEN spec]) |
|
15411 | 447 |
|
448 |
||
21504 | 449 |
subsubsection {* False *} |
450 |
||
451 |
text {* |
|
452 |
Depends upon @{text spec}; it is impossible to do propositional |
|
453 |
logic before quantifiers! |
|
454 |
*} |
|
15411 | 455 |
|
456 |
lemma FalseE: "False ==> P" |
|
21504 | 457 |
apply (unfold False_def) |
458 |
apply (erule spec) |
|
459 |
done |
|
15411 | 460 |
|
21504 | 461 |
lemma False_neq_True: "False = True ==> P" |
462 |
by (erule eqTrueE [THEN FalseE]) |
|
15411 | 463 |
|
464 |
||
21504 | 465 |
subsubsection {* Negation *} |
15411 | 466 |
|
467 |
lemma notI: |
|
21504 | 468 |
assumes "P ==> False" |
15411 | 469 |
shows "~P" |
21504 | 470 |
apply (unfold not_def) |
471 |
apply (iprover intro: impI assms) |
|
472 |
done |
|
15411 | 473 |
|
474 |
lemma False_not_True: "False ~= True" |
|
21504 | 475 |
apply (rule notI) |
476 |
apply (erule False_neq_True) |
|
477 |
done |
|
15411 | 478 |
|
479 |
lemma True_not_False: "True ~= False" |
|
21504 | 480 |
apply (rule notI) |
481 |
apply (drule sym) |
|
482 |
apply (erule False_neq_True) |
|
483 |
done |
|
15411 | 484 |
|
485 |
lemma notE: "[| ~P; P |] ==> R" |
|
21504 | 486 |
apply (unfold not_def) |
487 |
apply (erule mp [THEN FalseE]) |
|
488 |
apply assumption |
|
489 |
done |
|
15411 | 490 |
|
21504 | 491 |
lemma notI2: "(P \<Longrightarrow> \<not> Pa) \<Longrightarrow> (P \<Longrightarrow> Pa) \<Longrightarrow> \<not> P" |
492 |
by (erule notE [THEN notI]) (erule meta_mp) |
|
15411 | 493 |
|
494 |
||
20944 | 495 |
subsubsection {*Implication*} |
15411 | 496 |
|
497 |
lemma impE: |
|
498 |
assumes "P-->Q" "P" "Q ==> R" |
|
499 |
shows "R" |
|
23553 | 500 |
by (iprover intro: assms mp) |
15411 | 501 |
|
502 |
(* Reduces Q to P-->Q, allowing substitution in P. *) |
|
503 |
lemma rev_mp: "[| P; P --> Q |] ==> Q" |
|
17589 | 504 |
by (iprover intro: mp) |
15411 | 505 |
|
506 |
lemma contrapos_nn: |
|
507 |
assumes major: "~Q" |
|
508 |
and minor: "P==>Q" |
|
509 |
shows "~P" |
|
17589 | 510 |
by (iprover intro: notI minor major [THEN notE]) |
15411 | 511 |
|
512 |
(*not used at all, but we already have the other 3 combinations *) |
|
513 |
lemma contrapos_pn: |
|
514 |
assumes major: "Q" |
|
515 |
and minor: "P ==> ~Q" |
|
516 |
shows "~P" |
|
17589 | 517 |
by (iprover intro: notI minor major notE) |
15411 | 518 |
|
519 |
lemma not_sym: "t ~= s ==> s ~= t" |
|
21250 | 520 |
by (erule contrapos_nn) (erule sym) |
521 |
||
522 |
lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y" |
|
523 |
by (erule subst, erule ssubst, assumption) |
|
15411 | 524 |
|
525 |
(*still used in HOLCF*) |
|
526 |
lemma rev_contrapos: |
|
527 |
assumes pq: "P ==> Q" |
|
528 |
and nq: "~Q" |
|
529 |
shows "~P" |
|
530 |
apply (rule nq [THEN contrapos_nn]) |
|
531 |
apply (erule pq) |
|
532 |
done |
|
533 |
||
20944 | 534 |
subsubsection {*Existential quantifier*} |
15411 | 535 |
|
536 |
lemma exI: "P x ==> EX x::'a. P x" |
|
537 |
apply (unfold Ex_def) |
|
17589 | 538 |
apply (iprover intro: allI allE impI mp) |
15411 | 539 |
done |
540 |
||
541 |
lemma exE: |
|
542 |
assumes major: "EX x::'a. P(x)" |
|
543 |
and minor: "!!x. P(x) ==> Q" |
|
544 |
shows "Q" |
|
545 |
apply (rule major [unfolded Ex_def, THEN spec, THEN mp]) |
|
17589 | 546 |
apply (iprover intro: impI [THEN allI] minor) |
15411 | 547 |
done |
548 |
||
549 |
||
20944 | 550 |
subsubsection {*Conjunction*} |
15411 | 551 |
|
552 |
lemma conjI: "[| P; Q |] ==> P&Q" |
|
553 |
apply (unfold and_def) |
|
17589 | 554 |
apply (iprover intro: impI [THEN allI] mp) |
15411 | 555 |
done |
556 |
||
557 |
lemma conjunct1: "[| P & Q |] ==> P" |
|
558 |
apply (unfold and_def) |
|
17589 | 559 |
apply (iprover intro: impI dest: spec mp) |
15411 | 560 |
done |
561 |
||
562 |
lemma conjunct2: "[| P & Q |] ==> Q" |
|
563 |
apply (unfold and_def) |
|
17589 | 564 |
apply (iprover intro: impI dest: spec mp) |
15411 | 565 |
done |
566 |
||
567 |
lemma conjE: |
|
568 |
assumes major: "P&Q" |
|
569 |
and minor: "[| P; Q |] ==> R" |
|
570 |
shows "R" |
|
571 |
apply (rule minor) |
|
572 |
apply (rule major [THEN conjunct1]) |
|
573 |
apply (rule major [THEN conjunct2]) |
|
574 |
done |
|
575 |
||
576 |
lemma context_conjI: |
|
23553 | 577 |
assumes "P" "P ==> Q" shows "P & Q" |
578 |
by (iprover intro: conjI assms) |
|
15411 | 579 |
|
580 |
||
20944 | 581 |
subsubsection {*Disjunction*} |
15411 | 582 |
|
583 |
lemma disjI1: "P ==> P|Q" |
|
584 |
apply (unfold or_def) |
|
17589 | 585 |
apply (iprover intro: allI impI mp) |
15411 | 586 |
done |
587 |
||
588 |
lemma disjI2: "Q ==> P|Q" |
|
589 |
apply (unfold or_def) |
|
17589 | 590 |
apply (iprover intro: allI impI mp) |
15411 | 591 |
done |
592 |
||
593 |
lemma disjE: |
|
594 |
assumes major: "P|Q" |
|
595 |
and minorP: "P ==> R" |
|
596 |
and minorQ: "Q ==> R" |
|
597 |
shows "R" |
|
17589 | 598 |
by (iprover intro: minorP minorQ impI |
15411 | 599 |
major [unfolded or_def, THEN spec, THEN mp, THEN mp]) |
600 |
||
601 |
||
20944 | 602 |
subsubsection {*Classical logic*} |
15411 | 603 |
|
604 |
lemma classical: |
|
605 |
assumes prem: "~P ==> P" |
|
606 |
shows "P" |
|
607 |
apply (rule True_or_False [THEN disjE, THEN eqTrueE]) |
|
608 |
apply assumption |
|
609 |
apply (rule notI [THEN prem, THEN eqTrueI]) |
|
610 |
apply (erule subst) |
|
611 |
apply assumption |
|
612 |
done |
|
613 |
||
614 |
lemmas ccontr = FalseE [THEN classical, standard] |
|
615 |
||
616 |
(*notE with premises exchanged; it discharges ~R so that it can be used to |
|
617 |
make elimination rules*) |
|
618 |
lemma rev_notE: |
|
619 |
assumes premp: "P" |
|
620 |
and premnot: "~R ==> ~P" |
|
621 |
shows "R" |
|
622 |
apply (rule ccontr) |
|
623 |
apply (erule notE [OF premnot premp]) |
|
624 |
done |
|
625 |
||
626 |
(*Double negation law*) |
|
627 |
lemma notnotD: "~~P ==> P" |
|
628 |
apply (rule classical) |
|
629 |
apply (erule notE) |
|
630 |
apply assumption |
|
631 |
done |
|
632 |
||
633 |
lemma contrapos_pp: |
|
634 |
assumes p1: "Q" |
|
635 |
and p2: "~P ==> ~Q" |
|
636 |
shows "P" |
|
17589 | 637 |
by (iprover intro: classical p1 p2 notE) |
15411 | 638 |
|
639 |
||
20944 | 640 |
subsubsection {*Unique existence*} |
15411 | 641 |
|
642 |
lemma ex1I: |
|
23553 | 643 |
assumes "P a" "!!x. P(x) ==> x=a" |
15411 | 644 |
shows "EX! x. P(x)" |
23553 | 645 |
by (unfold Ex1_def, iprover intro: assms exI conjI allI impI) |
15411 | 646 |
|
647 |
text{*Sometimes easier to use: the premises have no shared variables. Safe!*} |
|
648 |
lemma ex_ex1I: |
|
649 |
assumes ex_prem: "EX x. P(x)" |
|
650 |
and eq: "!!x y. [| P(x); P(y) |] ==> x=y" |
|
651 |
shows "EX! x. P(x)" |
|
17589 | 652 |
by (iprover intro: ex_prem [THEN exE] ex1I eq) |
15411 | 653 |
|
654 |
lemma ex1E: |
|
655 |
assumes major: "EX! x. P(x)" |
|
656 |
and minor: "!!x. [| P(x); ALL y. P(y) --> y=x |] ==> R" |
|
657 |
shows "R" |
|
658 |
apply (rule major [unfolded Ex1_def, THEN exE]) |
|
659 |
apply (erule conjE) |
|
17589 | 660 |
apply (iprover intro: minor) |
15411 | 661 |
done |
662 |
||
663 |
lemma ex1_implies_ex: "EX! x. P x ==> EX x. P x" |
|
664 |
apply (erule ex1E) |
|
665 |
apply (rule exI) |
|
666 |
apply assumption |
|
667 |
done |
|
668 |
||
669 |
||
20944 | 670 |
subsubsection {*THE: definite description operator*} |
15411 | 671 |
|
672 |
lemma the_equality: |
|
673 |
assumes prema: "P a" |
|
674 |
and premx: "!!x. P x ==> x=a" |
|
675 |
shows "(THE x. P x) = a" |
|
676 |
apply (rule trans [OF _ the_eq_trivial]) |
|
677 |
apply (rule_tac f = "The" in arg_cong) |
|
678 |
apply (rule ext) |
|
679 |
apply (rule iffI) |
|
680 |
apply (erule premx) |
|
681 |
apply (erule ssubst, rule prema) |
|
682 |
done |
|
683 |
||
684 |
lemma theI: |
|
685 |
assumes "P a" and "!!x. P x ==> x=a" |
|
686 |
shows "P (THE x. P x)" |
|
23553 | 687 |
by (iprover intro: assms the_equality [THEN ssubst]) |
15411 | 688 |
|
689 |
lemma theI': "EX! x. P x ==> P (THE x. P x)" |
|
690 |
apply (erule ex1E) |
|
691 |
apply (erule theI) |
|
692 |
apply (erule allE) |
|
693 |
apply (erule mp) |
|
694 |
apply assumption |
|
695 |
done |
|
696 |
||
697 |
(*Easier to apply than theI: only one occurrence of P*) |
|
698 |
lemma theI2: |
|
699 |
assumes "P a" "!!x. P x ==> x=a" "!!x. P x ==> Q x" |
|
700 |
shows "Q (THE x. P x)" |
|
23553 | 701 |
by (iprover intro: assms theI) |
15411 | 702 |
|
18697 | 703 |
lemma the1_equality [elim?]: "[| EX!x. P x; P a |] ==> (THE x. P x) = a" |
15411 | 704 |
apply (rule the_equality) |
705 |
apply assumption |
|
706 |
apply (erule ex1E) |
|
707 |
apply (erule all_dupE) |
|
708 |
apply (drule mp) |
|
709 |
apply assumption |
|
710 |
apply (erule ssubst) |
|
711 |
apply (erule allE) |
|
712 |
apply (erule mp) |
|
713 |
apply assumption |
|
714 |
done |
|
715 |
||
716 |
lemma the_sym_eq_trivial: "(THE y. x=y) = x" |
|
717 |
apply (rule the_equality) |
|
718 |
apply (rule refl) |
|
719 |
apply (erule sym) |
|
720 |
done |
|
721 |
||
722 |
||
20944 | 723 |
subsubsection {*Classical intro rules for disjunction and existential quantifiers*} |
15411 | 724 |
|
725 |
lemma disjCI: |
|
726 |
assumes "~Q ==> P" shows "P|Q" |
|
727 |
apply (rule classical) |
|
23553 | 728 |
apply (iprover intro: assms disjI1 disjI2 notI elim: notE) |
15411 | 729 |
done |
730 |
||
731 |
lemma excluded_middle: "~P | P" |
|
17589 | 732 |
by (iprover intro: disjCI) |
15411 | 733 |
|
20944 | 734 |
text {* |
735 |
case distinction as a natural deduction rule. |
|
736 |
Note that @{term "~P"} is the second case, not the first |
|
737 |
*} |
|
15411 | 738 |
lemma case_split_thm: |
739 |
assumes prem1: "P ==> Q" |
|
740 |
and prem2: "~P ==> Q" |
|
741 |
shows "Q" |
|
742 |
apply (rule excluded_middle [THEN disjE]) |
|
743 |
apply (erule prem2) |
|
744 |
apply (erule prem1) |
|
745 |
done |
|
20944 | 746 |
lemmas case_split = case_split_thm [case_names True False] |
15411 | 747 |
|
748 |
(*Classical implies (-->) elimination. *) |
|
749 |
lemma impCE: |
|
750 |
assumes major: "P-->Q" |
|
751 |
and minor: "~P ==> R" "Q ==> R" |
|
752 |
shows "R" |
|
753 |
apply (rule excluded_middle [of P, THEN disjE]) |
|
17589 | 754 |
apply (iprover intro: minor major [THEN mp])+ |
15411 | 755 |
done |
756 |
||
757 |
(*This version of --> elimination works on Q before P. It works best for |
|
758 |
those cases in which P holds "almost everywhere". Can't install as |
|
759 |
default: would break old proofs.*) |
|
760 |
lemma impCE': |
|
761 |
assumes major: "P-->Q" |
|
762 |
and minor: "Q ==> R" "~P ==> R" |
|
763 |
shows "R" |
|
764 |
apply (rule excluded_middle [of P, THEN disjE]) |
|
17589 | 765 |
apply (iprover intro: minor major [THEN mp])+ |
15411 | 766 |
done |
767 |
||
768 |
(*Classical <-> elimination. *) |
|
769 |
lemma iffCE: |
|
770 |
assumes major: "P=Q" |
|
771 |
and minor: "[| P; Q |] ==> R" "[| ~P; ~Q |] ==> R" |
|
772 |
shows "R" |
|
773 |
apply (rule major [THEN iffE]) |
|
17589 | 774 |
apply (iprover intro: minor elim: impCE notE) |
15411 | 775 |
done |
776 |
||
777 |
lemma exCI: |
|
778 |
assumes "ALL x. ~P(x) ==> P(a)" |
|
779 |
shows "EX x. P(x)" |
|
780 |
apply (rule ccontr) |
|
23553 | 781 |
apply (iprover intro: assms exI allI notI notE [of "\<exists>x. P x"]) |
15411 | 782 |
done |
783 |
||
784 |
||
12386 | 785 |
subsubsection {* Intuitionistic Reasoning *} |
786 |
||
787 |
lemma impE': |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
788 |
assumes 1: "P --> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
789 |
and 2: "Q ==> R" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
790 |
and 3: "P --> Q ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
791 |
shows R |
12386 | 792 |
proof - |
793 |
from 3 and 1 have P . |
|
794 |
with 1 have Q by (rule impE) |
|
795 |
with 2 show R . |
|
796 |
qed |
|
797 |
||
798 |
lemma allE': |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
799 |
assumes 1: "ALL x. P x" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
800 |
and 2: "P x ==> ALL x. P x ==> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
801 |
shows Q |
12386 | 802 |
proof - |
803 |
from 1 have "P x" by (rule spec) |
|
804 |
from this and 1 show Q by (rule 2) |
|
805 |
qed |
|
806 |
||
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
807 |
lemma notE': |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
808 |
assumes 1: "~ P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
809 |
and 2: "~ P ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
810 |
shows R |
12386 | 811 |
proof - |
812 |
from 2 and 1 have P . |
|
813 |
with 1 show R by (rule notE) |
|
814 |
qed |
|
815 |
||
22444
fb80fedd192d
added safe intro rules for removing "True" subgoals as well as "~ False" ones.
dixon
parents:
22377
diff
changeset
|
816 |
lemma TrueE: "True ==> P ==> P" . |
fb80fedd192d
added safe intro rules for removing "True" subgoals as well as "~ False" ones.
dixon
parents:
22377
diff
changeset
|
817 |
lemma notFalseE: "~ False ==> P ==> P" . |
fb80fedd192d
added safe intro rules for removing "True" subgoals as well as "~ False" ones.
dixon
parents:
22377
diff
changeset
|
818 |
|
22467
c9357ef01168
TrueElim and notTrueElim tested and added as safe elim rules.
dixon
parents:
22445
diff
changeset
|
819 |
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE TrueE notFalseE |
15801 | 820 |
and [Pure.intro!] = iffI conjI impI TrueI notI allI refl |
821 |
and [Pure.elim 2] = allE notE' impE' |
|
822 |
and [Pure.intro] = exI disjI2 disjI1 |
|
12386 | 823 |
|
824 |
lemmas [trans] = trans |
|
825 |
and [sym] = sym not_sym |
|
15801 | 826 |
and [Pure.elim?] = iffD1 iffD2 impE |
11750 | 827 |
|
23553 | 828 |
use "hologic.ML" |
829 |
||
11438
3d9222b80989
declare trans [trans] (*overridden in theory Calculation*);
wenzelm
parents:
11432
diff
changeset
|
830 |
|
11750 | 831 |
subsubsection {* Atomizing meta-level connectives *} |
832 |
||
833 |
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)" |
|
12003 | 834 |
proof |
9488 | 835 |
assume "!!x. P x" |
23389 | 836 |
then show "ALL x. P x" .. |
9488 | 837 |
next |
838 |
assume "ALL x. P x" |
|
23553 | 839 |
then show "!!x. P x" by (rule allE) |
9488 | 840 |
qed |
841 |
||
11750 | 842 |
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)" |
12003 | 843 |
proof |
9488 | 844 |
assume r: "A ==> B" |
10383 | 845 |
show "A --> B" by (rule impI) (rule r) |
9488 | 846 |
next |
847 |
assume "A --> B" and A |
|
23553 | 848 |
then show B by (rule mp) |
9488 | 849 |
qed |
850 |
||
14749 | 851 |
lemma atomize_not: "(A ==> False) == Trueprop (~A)" |
852 |
proof |
|
853 |
assume r: "A ==> False" |
|
854 |
show "~A" by (rule notI) (rule r) |
|
855 |
next |
|
856 |
assume "~A" and A |
|
23553 | 857 |
then show False by (rule notE) |
14749 | 858 |
qed |
859 |
||
11750 | 860 |
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)" |
12003 | 861 |
proof |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
862 |
assume "x == y" |
23553 | 863 |
show "x = y" by (unfold `x == y`) (rule refl) |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
864 |
next |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
865 |
assume "x = y" |
23553 | 866 |
then show "x == y" by (rule eq_reflection) |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
867 |
qed |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
868 |
|
12023 | 869 |
lemma atomize_conj [atomize]: |
19121 | 870 |
includes meta_conjunction_syntax |
871 |
shows "(A && B) == Trueprop (A & B)" |
|
12003 | 872 |
proof |
19121 | 873 |
assume conj: "A && B" |
874 |
show "A & B" |
|
875 |
proof (rule conjI) |
|
876 |
from conj show A by (rule conjunctionD1) |
|
877 |
from conj show B by (rule conjunctionD2) |
|
878 |
qed |
|
11953 | 879 |
next |
19121 | 880 |
assume conj: "A & B" |
881 |
show "A && B" |
|
882 |
proof - |
|
883 |
from conj show A .. |
|
884 |
from conj show B .. |
|
11953 | 885 |
qed |
886 |
qed |
|
887 |
||
12386 | 888 |
lemmas [symmetric, rulify] = atomize_all atomize_imp |
18832 | 889 |
and [symmetric, defn] = atomize_all atomize_imp atomize_eq |
12386 | 890 |
|
11750 | 891 |
|
20944 | 892 |
subsection {* Package setup *} |
893 |
||
11750 | 894 |
subsubsection {* Classical Reasoner setup *} |
9529 | 895 |
|
20944 | 896 |
lemma thin_refl: |
897 |
"\<And>X. \<lbrakk> x=x; PROP W \<rbrakk> \<Longrightarrow> PROP W" . |
|
898 |
||
21151 | 899 |
ML {* |
900 |
structure Hypsubst = HypsubstFun( |
|
901 |
struct |
|
902 |
structure Simplifier = Simplifier |
|
21218 | 903 |
val dest_eq = HOLogic.dest_eq |
21151 | 904 |
val dest_Trueprop = HOLogic.dest_Trueprop |
905 |
val dest_imp = HOLogic.dest_imp |
|
22129 | 906 |
val eq_reflection = @{thm HOL.eq_reflection} |
22218 | 907 |
val rev_eq_reflection = @{thm HOL.meta_eq_to_obj_eq} |
22129 | 908 |
val imp_intr = @{thm HOL.impI} |
909 |
val rev_mp = @{thm HOL.rev_mp} |
|
910 |
val subst = @{thm HOL.subst} |
|
911 |
val sym = @{thm HOL.sym} |
|
912 |
val thin_refl = @{thm thin_refl}; |
|
21151 | 913 |
end); |
21671 | 914 |
open Hypsubst; |
21151 | 915 |
|
916 |
structure Classical = ClassicalFun( |
|
917 |
struct |
|
22129 | 918 |
val mp = @{thm HOL.mp} |
919 |
val not_elim = @{thm HOL.notE} |
|
920 |
val classical = @{thm HOL.classical} |
|
21151 | 921 |
val sizef = Drule.size_of_thm |
922 |
val hyp_subst_tacs = [Hypsubst.hyp_subst_tac] |
|
923 |
end); |
|
924 |
||
925 |
structure BasicClassical: BASIC_CLASSICAL = Classical; |
|
21671 | 926 |
open BasicClassical; |
22129 | 927 |
|
928 |
ML_Context.value_antiq "claset" |
|
929 |
(Scan.succeed ("claset", "Classical.local_claset_of (ML_Context.the_local_context ())")); |
|
24035 | 930 |
|
931 |
structure ResAtpset = NamedThmsFun(val name = "atp" val description = "ATP rules"); |
|
21151 | 932 |
*} |
933 |
||
21009 | 934 |
setup {* |
935 |
let |
|
936 |
(*prevent substitution on bool*) |
|
937 |
fun hyp_subst_tac' i thm = if i <= Thm.nprems_of thm andalso |
|
938 |
Term.exists_Const (fn ("op =", Type (_, [T, _])) => T <> Type ("bool", []) | _ => false) |
|
939 |
(nth (Thm.prems_of thm) (i - 1)) then Hypsubst.hyp_subst_tac i thm else no_tac thm; |
|
940 |
in |
|
21151 | 941 |
Hypsubst.hypsubst_setup |
942 |
#> ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac) |
|
943 |
#> Classical.setup |
|
944 |
#> ResAtpset.setup |
|
21009 | 945 |
end |
946 |
*} |
|
947 |
||
948 |
declare iffI [intro!] |
|
949 |
and notI [intro!] |
|
950 |
and impI [intro!] |
|
951 |
and disjCI [intro!] |
|
952 |
and conjI [intro!] |
|
953 |
and TrueI [intro!] |
|
954 |
and refl [intro!] |
|
955 |
||
956 |
declare iffCE [elim!] |
|
957 |
and FalseE [elim!] |
|
958 |
and impCE [elim!] |
|
959 |
and disjE [elim!] |
|
960 |
and conjE [elim!] |
|
961 |
and conjE [elim!] |
|
962 |
||
963 |
declare ex_ex1I [intro!] |
|
964 |
and allI [intro!] |
|
965 |
and the_equality [intro] |
|
966 |
and exI [intro] |
|
967 |
||
968 |
declare exE [elim!] |
|
969 |
allE [elim] |
|
970 |
||
22377 | 971 |
ML {* val HOL_cs = @{claset} *} |
19162 | 972 |
|
20223 | 973 |
lemma contrapos_np: "~ Q ==> (~ P ==> Q) ==> P" |
974 |
apply (erule swap) |
|
975 |
apply (erule (1) meta_mp) |
|
976 |
done |
|
10383 | 977 |
|
18689
a50587cd8414
prefer ex1I over ex_ex1I in single-step reasoning;
wenzelm
parents:
18595
diff
changeset
|
978 |
declare ex_ex1I [rule del, intro! 2] |
a50587cd8414
prefer ex1I over ex_ex1I in single-step reasoning;
wenzelm
parents:
18595
diff
changeset
|
979 |
and ex1I [intro] |
a50587cd8414
prefer ex1I over ex_ex1I in single-step reasoning;
wenzelm
parents:
18595
diff
changeset
|
980 |
|
12386 | 981 |
lemmas [intro?] = ext |
982 |
and [elim?] = ex1_implies_ex |
|
11977 | 983 |
|
20944 | 984 |
(*Better then ex1E for classical reasoner: needs no quantifier duplication!*) |
20973 | 985 |
lemma alt_ex1E [elim!]: |
20944 | 986 |
assumes major: "\<exists>!x. P x" |
987 |
and prem: "\<And>x. \<lbrakk> P x; \<forall>y y'. P y \<and> P y' \<longrightarrow> y = y' \<rbrakk> \<Longrightarrow> R" |
|
988 |
shows R |
|
989 |
apply (rule ex1E [OF major]) |
|
990 |
apply (rule prem) |
|
22129 | 991 |
apply (tactic {* ares_tac @{thms allI} 1 *})+ |
992 |
apply (tactic {* etac (Classical.dup_elim @{thm allE}) 1 *}) |
|
993 |
apply iprover |
|
994 |
done |
|
20944 | 995 |
|
21151 | 996 |
ML {* |
997 |
structure Blast = BlastFun( |
|
998 |
struct |
|
999 |
type claset = Classical.claset |
|
22744
5cbe966d67a2
Isar definitions are now added explicitly to code theorem table
haftmann
parents:
22481
diff
changeset
|
1000 |
val equality_name = @{const_name "op ="} |
22993 | 1001 |
val not_name = @{const_name Not} |
22129 | 1002 |
val notE = @{thm HOL.notE} |
1003 |
val ccontr = @{thm HOL.ccontr} |
|
21151 | 1004 |
val contr_tac = Classical.contr_tac |
1005 |
val dup_intr = Classical.dup_intr |
|
1006 |
val hyp_subst_tac = Hypsubst.blast_hyp_subst_tac |
|
21671 | 1007 |
val claset = Classical.claset |
21151 | 1008 |
val rep_cs = Classical.rep_cs |
1009 |
val cla_modifiers = Classical.cla_modifiers |
|
1010 |
val cla_meth' = Classical.cla_meth' |
|
1011 |
end); |
|
21671 | 1012 |
val Blast_tac = Blast.Blast_tac; |
1013 |
val blast_tac = Blast.blast_tac; |
|
20944 | 1014 |
*} |
1015 |
||
21151 | 1016 |
setup Blast.setup |
1017 |
||
20944 | 1018 |
|
1019 |
subsubsection {* Simplifier *} |
|
12281 | 1020 |
|
1021 |
lemma eta_contract_eq: "(%s. f s) = f" .. |
|
1022 |
||
1023 |
lemma simp_thms: |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1024 |
shows not_not: "(~ ~ P) = P" |
15354 | 1025 |
and Not_eq_iff: "((~P) = (~Q)) = (P = Q)" |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1026 |
and |
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1027 |
"(P ~= Q) = (P = (~Q))" |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1028 |
"(P | ~P) = True" "(~P | P) = True" |
12281 | 1029 |
"(x = x) = True" |
20944 | 1030 |
and not_True_eq_False: "(\<not> True) = False" |
1031 |
and not_False_eq_True: "(\<not> False) = True" |
|
1032 |
and |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1033 |
"(~P) ~= P" "P ~= (~P)" |
20944 | 1034 |
"(True=P) = P" |
1035 |
and eq_True: "(P = True) = P" |
|
1036 |
and "(False=P) = (~P)" |
|
1037 |
and eq_False: "(P = False) = (\<not> P)" |
|
1038 |
and |
|
12281 | 1039 |
"(True --> P) = P" "(False --> P) = True" |
1040 |
"(P --> True) = True" "(P --> P) = True" |
|
1041 |
"(P --> False) = (~P)" "(P --> ~P) = (~P)" |
|
1042 |
"(P & True) = P" "(True & P) = P" |
|
1043 |
"(P & False) = False" "(False & P) = False" |
|
1044 |
"(P & P) = P" "(P & (P & Q)) = (P & Q)" |
|
1045 |
"(P & ~P) = False" "(~P & P) = False" |
|
1046 |
"(P | True) = True" "(True | P) = True" |
|
1047 |
"(P | False) = P" "(False | P) = P" |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1048 |
"(P | P) = P" "(P | (P | Q)) = (P | Q)" and |
12281 | 1049 |
"(ALL x. P) = P" "(EX x. P) = P" "EX x. x=t" "EX x. t=x" |
1050 |
-- {* needed for the one-point-rule quantifier simplification procs *} |
|
1051 |
-- {* essential for termination!! *} and |
|
1052 |
"!!P. (EX x. x=t & P(x)) = P(t)" |
|
1053 |
"!!P. (EX x. t=x & P(x)) = P(t)" |
|
1054 |
"!!P. (ALL x. x=t --> P(x)) = P(t)" |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1055 |
"!!P. (ALL x. t=x --> P(x)) = P(t)" |
17589 | 1056 |
by (blast, blast, blast, blast, blast, iprover+) |
13421 | 1057 |
|
14201 | 1058 |
lemma disj_absorb: "(A | A) = A" |
1059 |
by blast |
|
1060 |
||
1061 |
lemma disj_left_absorb: "(A | (A | B)) = (A | B)" |
|
1062 |
by blast |
|
1063 |
||
1064 |
lemma conj_absorb: "(A & A) = A" |
|
1065 |
by blast |
|
1066 |
||
1067 |
lemma conj_left_absorb: "(A & (A & B)) = (A & B)" |
|
1068 |
by blast |
|
1069 |
||
12281 | 1070 |
lemma eq_ac: |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1071 |
shows eq_commute: "(a=b) = (b=a)" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1072 |
and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))" |
17589 | 1073 |
and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (iprover, blast+) |
1074 |
lemma neq_commute: "(a~=b) = (b~=a)" by iprover |
|
12281 | 1075 |
|
1076 |
lemma conj_comms: |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1077 |
shows conj_commute: "(P&Q) = (Q&P)" |
17589 | 1078 |
and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by iprover+ |
1079 |
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by iprover |
|
12281 | 1080 |
|
19174 | 1081 |
lemmas conj_ac = conj_commute conj_left_commute conj_assoc |
1082 |
||
12281 | 1083 |
lemma disj_comms: |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1084 |
shows disj_commute: "(P|Q) = (Q|P)" |
17589 | 1085 |
and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by iprover+ |
1086 |
lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by iprover |
|
12281 | 1087 |
|
19174 | 1088 |
lemmas disj_ac = disj_commute disj_left_commute disj_assoc |
1089 |
||
17589 | 1090 |
lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by iprover |
1091 |
lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by iprover |
|
12281 | 1092 |
|
17589 | 1093 |
lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by iprover |
1094 |
lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by iprover |
|
12281 | 1095 |
|
17589 | 1096 |
lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by iprover |
1097 |
lemma imp_conjL: "((P&Q) -->R) = (P --> (Q --> R))" by iprover |
|
1098 |
lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by iprover |
|
12281 | 1099 |
|
1100 |
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *} |
|
1101 |
lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast |
|
1102 |
lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast |
|
1103 |
||
1104 |
lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast |
|
1105 |
lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast |
|
1106 |
||
21151 | 1107 |
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))" |
1108 |
by iprover |
|
1109 |
||
17589 | 1110 |
lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by iprover |
12281 | 1111 |
lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast |
1112 |
lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast |
|
1113 |
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast |
|
1114 |
lemma disj_not1: "(~P | Q) = (P --> Q)" by blast |
|
1115 |
lemma disj_not2: "(P | ~Q) = (Q --> P)" -- {* changes orientation :-( *} |
|
1116 |
by blast |
|
1117 |
lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast |
|
1118 |
||
17589 | 1119 |
lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by iprover |
12281 | 1120 |
|
1121 |
||
1122 |
lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q" |
|
1123 |
-- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *} |
|
1124 |
-- {* cases boil down to the same thing. *} |
|
1125 |
by blast |
|
1126 |
||
1127 |
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast |
|
1128 |
lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast |
|
17589 | 1129 |
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by iprover |
1130 |
lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by iprover |
|
23403 | 1131 |
lemma all_not_ex: "(ALL x. P x) = (~ (EX x. ~ P x ))" by blast |
12281 | 1132 |
|
17589 | 1133 |
lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by iprover |
1134 |
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by iprover |
|
12281 | 1135 |
|
1136 |
text {* |
|
1137 |
\medskip The @{text "&"} congruence rule: not included by default! |
|
1138 |
May slow rewrite proofs down by as much as 50\% *} |
|
1139 |
||
1140 |
lemma conj_cong: |
|
1141 |
"(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))" |
|
17589 | 1142 |
by iprover |
12281 | 1143 |
|
1144 |
lemma rev_conj_cong: |
|
1145 |
"(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))" |
|
17589 | 1146 |
by iprover |
12281 | 1147 |
|
1148 |
text {* The @{text "|"} congruence rule: not included by default! *} |
|
1149 |
||
1150 |
lemma disj_cong: |
|
1151 |
"(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))" |
|
1152 |
by blast |
|
1153 |
||
1154 |
||
1155 |
text {* \medskip if-then-else rules *} |
|
1156 |
||
1157 |
lemma if_True: "(if True then x else y) = x" |
|
1158 |
by (unfold if_def) blast |
|
1159 |
||
1160 |
lemma if_False: "(if False then x else y) = y" |
|
1161 |
by (unfold if_def) blast |
|
1162 |
||
1163 |
lemma if_P: "P ==> (if P then x else y) = x" |
|
1164 |
by (unfold if_def) blast |
|
1165 |
||
1166 |
lemma if_not_P: "~P ==> (if P then x else y) = y" |
|
1167 |
by (unfold if_def) blast |
|
1168 |
||
1169 |
lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))" |
|
1170 |
apply (rule case_split [of Q]) |
|
15481 | 1171 |
apply (simplesubst if_P) |
1172 |
prefer 3 apply (simplesubst if_not_P, blast+) |
|
12281 | 1173 |
done |
1174 |
||
1175 |
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))" |
|
15481 | 1176 |
by (simplesubst split_if, blast) |
12281 | 1177 |
|
1178 |
lemmas if_splits = split_if split_if_asm |
|
1179 |
||
1180 |
lemma if_cancel: "(if c then x else x) = x" |
|
15481 | 1181 |
by (simplesubst split_if, blast) |
12281 | 1182 |
|
1183 |
lemma if_eq_cancel: "(if x = y then y else x) = x" |
|
15481 | 1184 |
by (simplesubst split_if, blast) |
12281 | 1185 |
|
1186 |
lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))" |
|
19796 | 1187 |
-- {* This form is useful for expanding @{text "if"}s on the RIGHT of the @{text "==>"} symbol. *} |
12281 | 1188 |
by (rule split_if) |
1189 |
||
1190 |
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))" |
|
19796 | 1191 |
-- {* And this form is useful for expanding @{text "if"}s on the LEFT. *} |
15481 | 1192 |
apply (simplesubst split_if, blast) |
12281 | 1193 |
done |
1194 |
||
17589 | 1195 |
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) iprover |
1196 |
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) iprover |
|
12281 | 1197 |
|
15423 | 1198 |
text {* \medskip let rules for simproc *} |
1199 |
||
1200 |
lemma Let_folded: "f x \<equiv> g x \<Longrightarrow> Let x f \<equiv> Let x g" |
|
1201 |
by (unfold Let_def) |
|
1202 |
||
1203 |
lemma Let_unfold: "f x \<equiv> g \<Longrightarrow> Let x f \<equiv> g" |
|
1204 |
by (unfold Let_def) |
|
1205 |
||
16633
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1206 |
text {* |
16999 | 1207 |
The following copy of the implication operator is useful for |
1208 |
fine-tuning congruence rules. It instructs the simplifier to simplify |
|
1209 |
its premise. |
|
16633
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1210 |
*} |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1211 |
|
17197 | 1212 |
constdefs |
1213 |
simp_implies :: "[prop, prop] => prop" (infixr "=simp=>" 1) |
|
1214 |
"simp_implies \<equiv> op ==>" |
|
16633
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1215 |
|
18457 | 1216 |
lemma simp_impliesI: |
16633
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1217 |
assumes PQ: "(PROP P \<Longrightarrow> PROP Q)" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1218 |
shows "PROP P =simp=> PROP Q" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1219 |
apply (unfold simp_implies_def) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1220 |
apply (rule PQ) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1221 |
apply assumption |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1222 |
done |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1223 |
|
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1224 |
lemma simp_impliesE: |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1225 |
assumes PQ:"PROP P =simp=> PROP Q" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1226 |
and P: "PROP P" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1227 |
and QR: "PROP Q \<Longrightarrow> PROP R" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1228 |
shows "PROP R" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1229 |
apply (rule QR) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1230 |
apply (rule PQ [unfolded simp_implies_def]) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1231 |
apply (rule P) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1232 |
done |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1233 |
|
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1234 |
lemma simp_implies_cong: |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1235 |
assumes PP' :"PROP P == PROP P'" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1236 |
and P'QQ': "PROP P' ==> (PROP Q == PROP Q')" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1237 |
shows "(PROP P =simp=> PROP Q) == (PROP P' =simp=> PROP Q')" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1238 |
proof (unfold simp_implies_def, rule equal_intr_rule) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1239 |
assume PQ: "PROP P \<Longrightarrow> PROP Q" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1240 |
and P': "PROP P'" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1241 |
from PP' [symmetric] and P' have "PROP P" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1242 |
by (rule equal_elim_rule1) |
23553 | 1243 |
then have "PROP Q" by (rule PQ) |
16633
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1244 |
with P'QQ' [OF P'] show "PROP Q'" by (rule equal_elim_rule1) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1245 |
next |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1246 |
assume P'Q': "PROP P' \<Longrightarrow> PROP Q'" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1247 |
and P: "PROP P" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1248 |
from PP' and P have P': "PROP P'" by (rule equal_elim_rule1) |
23553 | 1249 |
then have "PROP Q'" by (rule P'Q') |
16633
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1250 |
with P'QQ' [OF P', symmetric] show "PROP Q" |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1251 |
by (rule equal_elim_rule1) |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1252 |
qed |
208ebc9311f2
Implemented trick (due to Tobias Nipkow) for fine-tuning simplification
berghofe
parents:
16587
diff
changeset
|
1253 |
|
20944 | 1254 |
lemma uncurry: |
1255 |
assumes "P \<longrightarrow> Q \<longrightarrow> R" |
|
1256 |
shows "P \<and> Q \<longrightarrow> R" |
|
23553 | 1257 |
using assms by blast |
20944 | 1258 |
|
1259 |
lemma iff_allI: |
|
1260 |
assumes "\<And>x. P x = Q x" |
|
1261 |
shows "(\<forall>x. P x) = (\<forall>x. Q x)" |
|
23553 | 1262 |
using assms by blast |
20944 | 1263 |
|
1264 |
lemma iff_exI: |
|
1265 |
assumes "\<And>x. P x = Q x" |
|
1266 |
shows "(\<exists>x. P x) = (\<exists>x. Q x)" |
|
23553 | 1267 |
using assms by blast |
20944 | 1268 |
|
1269 |
lemma all_comm: |
|
1270 |
"(\<forall>x y. P x y) = (\<forall>y x. P x y)" |
|
1271 |
by blast |
|
1272 |
||
1273 |
lemma ex_comm: |
|
1274 |
"(\<exists>x y. P x y) = (\<exists>y x. P x y)" |
|
1275 |
by blast |
|
1276 |
||
9869 | 1277 |
use "simpdata.ML" |
21671 | 1278 |
ML {* open Simpdata *} |
1279 |
||
21151 | 1280 |
setup {* |
1281 |
Simplifier.method_setup Splitter.split_modifiers |
|
21547
9c9fdf4c2949
moved order arities for fun and bool to Fun/Orderings
haftmann
parents:
21524
diff
changeset
|
1282 |
#> (fn thy => (change_simpset_of thy (fn _ => Simpdata.simpset_simprocs); thy)) |
21151 | 1283 |
#> Splitter.setup |
1284 |
#> Clasimp.setup |
|
1285 |
#> EqSubst.setup |
|
1286 |
*} |
|
1287 |
||
24035 | 1288 |
text {* Simproc for proving @{text "(y = x) == False"} from premise @{text "~(x = y)"}: *} |
1289 |
||
1290 |
simproc_setup neq ("x = y") = {* fn _ => |
|
1291 |
let |
|
1292 |
val neq_to_EQ_False = @{thm not_sym} RS @{thm Eq_FalseI}; |
|
1293 |
fun is_neq eq lhs rhs thm = |
|
1294 |
(case Thm.prop_of thm of |
|
1295 |
_ $ (Not $ (eq' $ l' $ r')) => |
|
1296 |
Not = HOLogic.Not andalso eq' = eq andalso |
|
1297 |
r' aconv lhs andalso l' aconv rhs |
|
1298 |
| _ => false); |
|
1299 |
fun proc ss ct = |
|
1300 |
(case Thm.term_of ct of |
|
1301 |
eq $ lhs $ rhs => |
|
1302 |
(case find_first (is_neq eq lhs rhs) (Simplifier.prems_of_ss ss) of |
|
1303 |
SOME thm => SOME (thm RS neq_to_EQ_False) |
|
1304 |
| NONE => NONE) |
|
1305 |
| _ => NONE); |
|
1306 |
in proc end; |
|
1307 |
*} |
|
1308 |
||
1309 |
simproc_setup let_simp ("Let x f") = {* |
|
1310 |
let |
|
1311 |
val (f_Let_unfold, x_Let_unfold) = |
|
1312 |
let val [(_$(f$x)$_)] = prems_of @{thm Let_unfold} |
|
1313 |
in (cterm_of @{theory} f, cterm_of @{theory} x) end |
|
1314 |
val (f_Let_folded, x_Let_folded) = |
|
1315 |
let val [(_$(f$x)$_)] = prems_of @{thm Let_folded} |
|
1316 |
in (cterm_of @{theory} f, cterm_of @{theory} x) end; |
|
1317 |
val g_Let_folded = |
|
1318 |
let val [(_$_$(g$_))] = prems_of @{thm Let_folded} in cterm_of @{theory} g end; |
|
1319 |
||
1320 |
fun proc _ ss ct = |
|
1321 |
let |
|
1322 |
val ctxt = Simplifier.the_context ss; |
|
1323 |
val thy = ProofContext.theory_of ctxt; |
|
1324 |
val t = Thm.term_of ct; |
|
1325 |
val ([t'], ctxt') = Variable.import_terms false [t] ctxt; |
|
1326 |
in Option.map (hd o Variable.export ctxt' ctxt o single) |
|
1327 |
(case t' of Const ("Let",_) $ x $ f => (* x and f are already in normal form *) |
|
1328 |
if is_Free x orelse is_Bound x orelse is_Const x |
|
1329 |
then SOME @{thm Let_def} |
|
1330 |
else |
|
1331 |
let |
|
1332 |
val n = case f of (Abs (x,_,_)) => x | _ => "x"; |
|
1333 |
val cx = cterm_of thy x; |
|
1334 |
val {T=xT,...} = rep_cterm cx; |
|
1335 |
val cf = cterm_of thy f; |
|
1336 |
val fx_g = Simplifier.rewrite ss (Thm.capply cf cx); |
|
1337 |
val (_$_$g) = prop_of fx_g; |
|
1338 |
val g' = abstract_over (x,g); |
|
1339 |
in (if (g aconv g') |
|
1340 |
then |
|
1341 |
let |
|
1342 |
val rl = |
|
1343 |
cterm_instantiate [(f_Let_unfold,cf),(x_Let_unfold,cx)] @{thm Let_unfold}; |
|
1344 |
in SOME (rl OF [fx_g]) end |
|
1345 |
else if Term.betapply (f,x) aconv g then NONE (*avoid identity conversion*) |
|
1346 |
else let |
|
1347 |
val abs_g'= Abs (n,xT,g'); |
|
1348 |
val g'x = abs_g'$x; |
|
1349 |
val g_g'x = symmetric (beta_conversion false (cterm_of thy g'x)); |
|
1350 |
val rl = cterm_instantiate |
|
1351 |
[(f_Let_folded,cterm_of thy f),(x_Let_folded,cx), |
|
1352 |
(g_Let_folded,cterm_of thy abs_g')] |
|
1353 |
@{thm Let_folded}; |
|
1354 |
in SOME (rl OF [transitive fx_g g_g'x]) |
|
1355 |
end) |
|
1356 |
end |
|
1357 |
| _ => NONE) |
|
1358 |
end |
|
1359 |
in proc end *} |
|
1360 |
||
1361 |
||
21151 | 1362 |
lemma True_implies_equals: "(True \<Longrightarrow> PROP P) \<equiv> PROP P" |
1363 |
proof |
|
23389 | 1364 |
assume "True \<Longrightarrow> PROP P" |
1365 |
from this [OF TrueI] show "PROP P" . |
|
21151 | 1366 |
next |
1367 |
assume "PROP P" |
|
23389 | 1368 |
then show "PROP P" . |
21151 | 1369 |
qed |
1370 |
||
1371 |
lemma ex_simps: |
|
1372 |
"!!P Q. (EX x. P x & Q) = ((EX x. P x) & Q)" |
|
1373 |
"!!P Q. (EX x. P & Q x) = (P & (EX x. Q x))" |
|
1374 |
"!!P Q. (EX x. P x | Q) = ((EX x. P x) | Q)" |
|
1375 |
"!!P Q. (EX x. P | Q x) = (P | (EX x. Q x))" |
|
1376 |
"!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)" |
|
1377 |
"!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))" |
|
1378 |
-- {* Miniscoping: pushing in existential quantifiers. *} |
|
1379 |
by (iprover | blast)+ |
|
1380 |
||
1381 |
lemma all_simps: |
|
1382 |
"!!P Q. (ALL x. P x & Q) = ((ALL x. P x) & Q)" |
|
1383 |
"!!P Q. (ALL x. P & Q x) = (P & (ALL x. Q x))" |
|
1384 |
"!!P Q. (ALL x. P x | Q) = ((ALL x. P x) | Q)" |
|
1385 |
"!!P Q. (ALL x. P | Q x) = (P | (ALL x. Q x))" |
|
1386 |
"!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)" |
|
1387 |
"!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))" |
|
1388 |
-- {* Miniscoping: pushing in universal quantifiers. *} |
|
1389 |
by (iprover | blast)+ |
|
15481 | 1390 |
|
21671 | 1391 |
lemmas [simp] = |
1392 |
triv_forall_equality (*prunes params*) |
|
1393 |
True_implies_equals (*prune asms `True'*) |
|
1394 |
if_True |
|
1395 |
if_False |
|
1396 |
if_cancel |
|
1397 |
if_eq_cancel |
|
1398 |
imp_disjL |
|
20973 | 1399 |
(*In general it seems wrong to add distributive laws by default: they |
1400 |
might cause exponential blow-up. But imp_disjL has been in for a while |
|
1401 |
and cannot be removed without affecting existing proofs. Moreover, |
|
1402 |
rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the |
|
1403 |
grounds that it allows simplification of R in the two cases.*) |
|
21671 | 1404 |
conj_assoc |
1405 |
disj_assoc |
|
1406 |
de_Morgan_conj |
|
1407 |
de_Morgan_disj |
|
1408 |
imp_disj1 |
|
1409 |
imp_disj2 |
|
1410 |
not_imp |
|
1411 |
disj_not1 |
|
1412 |
not_all |
|
1413 |
not_ex |
|
1414 |
cases_simp |
|
1415 |
the_eq_trivial |
|
1416 |
the_sym_eq_trivial |
|
1417 |
ex_simps |
|
1418 |
all_simps |
|
1419 |
simp_thms |
|
1420 |
||
1421 |
lemmas [cong] = imp_cong simp_implies_cong |
|
1422 |
lemmas [split] = split_if |
|
20973 | 1423 |
|
22377 | 1424 |
ML {* val HOL_ss = @{simpset} *} |
20973 | 1425 |
|
20944 | 1426 |
text {* Simplifies x assuming c and y assuming ~c *} |
1427 |
lemma if_cong: |
|
1428 |
assumes "b = c" |
|
1429 |
and "c \<Longrightarrow> x = u" |
|
1430 |
and "\<not> c \<Longrightarrow> y = v" |
|
1431 |
shows "(if b then x else y) = (if c then u else v)" |
|
23553 | 1432 |
unfolding if_def using assms by simp |
20944 | 1433 |
|
1434 |
text {* Prevents simplification of x and y: |
|
1435 |
faster and allows the execution of functional programs. *} |
|
1436 |
lemma if_weak_cong [cong]: |
|
1437 |
assumes "b = c" |
|
1438 |
shows "(if b then x else y) = (if c then x else y)" |
|
23553 | 1439 |
using assms by (rule arg_cong) |
20944 | 1440 |
|
1441 |
text {* Prevents simplification of t: much faster *} |
|
1442 |
lemma let_weak_cong: |
|
1443 |
assumes "a = b" |
|
1444 |
shows "(let x = a in t x) = (let x = b in t x)" |
|
23553 | 1445 |
using assms by (rule arg_cong) |
20944 | 1446 |
|
1447 |
text {* To tidy up the result of a simproc. Only the RHS will be simplified. *} |
|
1448 |
lemma eq_cong2: |
|
1449 |
assumes "u = u'" |
|
1450 |
shows "(t \<equiv> u) \<equiv> (t \<equiv> u')" |
|
23553 | 1451 |
using assms by simp |
20944 | 1452 |
|
1453 |
lemma if_distrib: |
|
1454 |
"f (if c then x else y) = (if c then f x else f y)" |
|
1455 |
by simp |
|
1456 |
||
1457 |
text {* This lemma restricts the effect of the rewrite rule u=v to the left-hand |
|
21502 | 1458 |
side of an equality. Used in @{text "{Integ,Real}/simproc.ML"} *} |
20944 | 1459 |
lemma restrict_to_left: |
1460 |
assumes "x = y" |
|
1461 |
shows "(x = z) = (y = z)" |
|
23553 | 1462 |
using assms by simp |
20944 | 1463 |
|
17459 | 1464 |
|
20944 | 1465 |
subsubsection {* Generic cases and induction *} |
17459 | 1466 |
|
20944 | 1467 |
text {* Rule projections: *} |
18887 | 1468 |
|
20944 | 1469 |
ML {* |
1470 |
structure ProjectRule = ProjectRuleFun |
|
1471 |
(struct |
|
22129 | 1472 |
val conjunct1 = @{thm conjunct1}; |
1473 |
val conjunct2 = @{thm conjunct2}; |
|
1474 |
val mp = @{thm mp}; |
|
20944 | 1475 |
end) |
17459 | 1476 |
*} |
1477 |
||
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1478 |
constdefs |
18457 | 1479 |
induct_forall where "induct_forall P == \<forall>x. P x" |
1480 |
induct_implies where "induct_implies A B == A \<longrightarrow> B" |
|
1481 |
induct_equal where "induct_equal x y == x = y" |
|
1482 |
induct_conj where "induct_conj A B == A \<and> B" |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1483 |
|
11989 | 1484 |
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))" |
18457 | 1485 |
by (unfold atomize_all induct_forall_def) |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1486 |
|
11989 | 1487 |
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)" |
18457 | 1488 |
by (unfold atomize_imp induct_implies_def) |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1489 |
|
11989 | 1490 |
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)" |
18457 | 1491 |
by (unfold atomize_eq induct_equal_def) |
1492 |
||
1493 |
lemma induct_conj_eq: |
|
1494 |
includes meta_conjunction_syntax |
|
1495 |
shows "(A && B) == Trueprop (induct_conj A B)" |
|
1496 |
by (unfold atomize_conj induct_conj_def) |
|
1497 |
||
1498 |
lemmas induct_atomize = induct_forall_eq induct_implies_eq induct_equal_eq induct_conj_eq |
|
1499 |
lemmas induct_rulify [symmetric, standard] = induct_atomize |
|
1500 |
lemmas induct_rulify_fallback = |
|
1501 |
induct_forall_def induct_implies_def induct_equal_def induct_conj_def |
|
1502 |
||
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1503 |
|
11989 | 1504 |
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) = |
1505 |
induct_conj (induct_forall A) (induct_forall B)" |
|
17589 | 1506 |
by (unfold induct_forall_def induct_conj_def) iprover |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1507 |
|
11989 | 1508 |
lemma induct_implies_conj: "induct_implies C (induct_conj A B) = |
1509 |
induct_conj (induct_implies C A) (induct_implies C B)" |
|
17589 | 1510 |
by (unfold induct_implies_def induct_conj_def) iprover |
11989 | 1511 |
|
13598
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1512 |
lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)" |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1513 |
proof |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1514 |
assume r: "induct_conj A B ==> PROP C" and A B |
18457 | 1515 |
show "PROP C" by (rule r) (simp add: induct_conj_def `A` `B`) |
13598
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1516 |
next |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1517 |
assume r: "A ==> B ==> PROP C" and "induct_conj A B" |
18457 | 1518 |
show "PROP C" by (rule r) (simp_all add: `induct_conj A B` [unfolded induct_conj_def]) |
13598
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1519 |
qed |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1520 |
|
11989 | 1521 |
lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1522 |
|
11989 | 1523 |
hide const induct_forall induct_implies induct_equal induct_conj |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1524 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1525 |
text {* Method setup. *} |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1526 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1527 |
ML {* |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1528 |
structure InductMethod = InductMethodFun |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1529 |
(struct |
22129 | 1530 |
val cases_default = @{thm case_split} |
1531 |
val atomize = @{thms induct_atomize} |
|
1532 |
val rulify = @{thms induct_rulify} |
|
1533 |
val rulify_fallback = @{thms induct_rulify_fallback} |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1534 |
end); |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1535 |
*} |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1536 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1537 |
setup InductMethod.setup |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1538 |
|
18457 | 1539 |
|
20944 | 1540 |
|
1541 |
subsection {* Other simple lemmas and lemma duplicates *} |
|
1542 |
||
1543 |
lemma ex1_eq [iff]: "EX! x. x = t" "EX! x. t = x" |
|
1544 |
by blast+ |
|
1545 |
||
1546 |
lemma choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))" |
|
1547 |
apply (rule iffI) |
|
1548 |
apply (rule_tac a = "%x. THE y. P x y" in ex1I) |
|
1549 |
apply (fast dest!: theI') |
|
1550 |
apply (fast intro: ext the1_equality [symmetric]) |
|
1551 |
apply (erule ex1E) |
|
1552 |
apply (rule allI) |
|
1553 |
apply (rule ex1I) |
|
1554 |
apply (erule spec) |
|
1555 |
apply (erule_tac x = "%z. if z = x then y else f z" in allE) |
|
1556 |
apply (erule impE) |
|
1557 |
apply (rule allI) |
|
1558 |
apply (rule_tac P = "xa = x" in case_split_thm) |
|
1559 |
apply (drule_tac [3] x = x in fun_cong, simp_all) |
|
1560 |
done |
|
1561 |
||
1562 |
lemma mk_left_commute: |
|
21547
9c9fdf4c2949
moved order arities for fun and bool to Fun/Orderings
haftmann
parents:
21524
diff
changeset
|
1563 |
fixes f (infix "\<otimes>" 60) |
9c9fdf4c2949
moved order arities for fun and bool to Fun/Orderings
haftmann
parents:
21524
diff
changeset
|
1564 |
assumes a: "\<And>x y z. (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)" and |
9c9fdf4c2949
moved order arities for fun and bool to Fun/Orderings
haftmann
parents:
21524
diff
changeset
|
1565 |
c: "\<And>x y. x \<otimes> y = y \<otimes> x" |
9c9fdf4c2949
moved order arities for fun and bool to Fun/Orderings
haftmann
parents:
21524
diff
changeset
|
1566 |
shows "x \<otimes> (y \<otimes> z) = y \<otimes> (x \<otimes> z)" |
20944 | 1567 |
by (rule trans [OF trans [OF c a] arg_cong [OF c, of "f y"]]) |
1568 |
||
22218 | 1569 |
lemmas eq_sym_conv = eq_commute |
1570 |
||
23037
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1571 |
lemma nnf_simps: |
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1572 |
"(\<not>(P \<and> Q)) = (\<not> P \<or> \<not> Q)" "(\<not> (P \<or> Q)) = (\<not> P \<and> \<not>Q)" "(P \<longrightarrow> Q) = (\<not>P \<or> Q)" |
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1573 |
"(P = Q) = ((P \<and> Q) \<or> (\<not>P \<and> \<not> Q))" "(\<not>(P = Q)) = ((P \<and> \<not> Q) \<or> (\<not>P \<and> Q))" |
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1574 |
"(\<not> \<not>(P)) = P" |
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1575 |
by blast+ |
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1576 |
|
21671 | 1577 |
|
1578 |
subsection {* Basic ML bindings *} |
|
1579 |
||
1580 |
ML {* |
|
22129 | 1581 |
val FalseE = @{thm FalseE} |
1582 |
val Let_def = @{thm Let_def} |
|
1583 |
val TrueI = @{thm TrueI} |
|
1584 |
val allE = @{thm allE} |
|
1585 |
val allI = @{thm allI} |
|
1586 |
val all_dupE = @{thm all_dupE} |
|
1587 |
val arg_cong = @{thm arg_cong} |
|
1588 |
val box_equals = @{thm box_equals} |
|
1589 |
val ccontr = @{thm ccontr} |
|
1590 |
val classical = @{thm classical} |
|
1591 |
val conjE = @{thm conjE} |
|
1592 |
val conjI = @{thm conjI} |
|
1593 |
val conjunct1 = @{thm conjunct1} |
|
1594 |
val conjunct2 = @{thm conjunct2} |
|
1595 |
val disjCI = @{thm disjCI} |
|
1596 |
val disjE = @{thm disjE} |
|
1597 |
val disjI1 = @{thm disjI1} |
|
1598 |
val disjI2 = @{thm disjI2} |
|
1599 |
val eq_reflection = @{thm eq_reflection} |
|
1600 |
val ex1E = @{thm ex1E} |
|
1601 |
val ex1I = @{thm ex1I} |
|
1602 |
val ex1_implies_ex = @{thm ex1_implies_ex} |
|
1603 |
val exE = @{thm exE} |
|
1604 |
val exI = @{thm exI} |
|
1605 |
val excluded_middle = @{thm excluded_middle} |
|
1606 |
val ext = @{thm ext} |
|
1607 |
val fun_cong = @{thm fun_cong} |
|
1608 |
val iffD1 = @{thm iffD1} |
|
1609 |
val iffD2 = @{thm iffD2} |
|
1610 |
val iffI = @{thm iffI} |
|
1611 |
val impE = @{thm impE} |
|
1612 |
val impI = @{thm impI} |
|
1613 |
val meta_eq_to_obj_eq = @{thm meta_eq_to_obj_eq} |
|
1614 |
val mp = @{thm mp} |
|
1615 |
val notE = @{thm notE} |
|
1616 |
val notI = @{thm notI} |
|
1617 |
val not_all = @{thm not_all} |
|
1618 |
val not_ex = @{thm not_ex} |
|
1619 |
val not_iff = @{thm not_iff} |
|
1620 |
val not_not = @{thm not_not} |
|
1621 |
val not_sym = @{thm not_sym} |
|
1622 |
val refl = @{thm refl} |
|
1623 |
val rev_mp = @{thm rev_mp} |
|
1624 |
val spec = @{thm spec} |
|
1625 |
val ssubst = @{thm ssubst} |
|
1626 |
val subst = @{thm subst} |
|
1627 |
val sym = @{thm sym} |
|
1628 |
val trans = @{thm trans} |
|
21671 | 1629 |
*} |
1630 |
||
1631 |
||
23247 | 1632 |
subsection {* Code generator setup *} |
1633 |
||
1634 |
subsubsection {* SML code generator setup *} |
|
1635 |
||
1636 |
use "~~/src/HOL/Tools/recfun_codegen.ML" |
|
1637 |
||
1638 |
types_code |
|
1639 |
"bool" ("bool") |
|
1640 |
attach (term_of) {* |
|
1641 |
fun term_of_bool b = if b then HOLogic.true_const else HOLogic.false_const; |
|
1642 |
*} |
|
1643 |
attach (test) {* |
|
1644 |
fun gen_bool i = one_of [false, true]; |
|
1645 |
*} |
|
1646 |
"prop" ("bool") |
|
1647 |
attach (term_of) {* |
|
1648 |
fun term_of_prop b = |
|
1649 |
HOLogic.mk_Trueprop (if b then HOLogic.true_const else HOLogic.false_const); |
|
1650 |
*} |
|
1651 |
||
1652 |
consts_code |
|
1653 |
"Trueprop" ("(_)") |
|
1654 |
"True" ("true") |
|
1655 |
"False" ("false") |
|
1656 |
"Not" ("Bool.not") |
|
1657 |
"op |" ("(_ orelse/ _)") |
|
1658 |
"op &" ("(_ andalso/ _)") |
|
1659 |
"If" ("(if _/ then _/ else _)") |
|
1660 |
||
1661 |
setup {* |
|
1662 |
let |
|
1663 |
||
1664 |
fun eq_codegen thy defs gr dep thyname b t = |
|
1665 |
(case strip_comb t of |
|
1666 |
(Const ("op =", Type (_, [Type ("fun", _), _])), _) => NONE |
|
1667 |
| (Const ("op =", _), [t, u]) => |
|
1668 |
let |
|
1669 |
val (gr', pt) = Codegen.invoke_codegen thy defs dep thyname false (gr, t); |
|
1670 |
val (gr'', pu) = Codegen.invoke_codegen thy defs dep thyname false (gr', u); |
|
1671 |
val (gr''', _) = Codegen.invoke_tycodegen thy defs dep thyname false (gr'', HOLogic.boolT) |
|
1672 |
in |
|
1673 |
SOME (gr''', Codegen.parens |
|
1674 |
(Pretty.block [pt, Pretty.str " =", Pretty.brk 1, pu])) |
|
1675 |
end |
|
1676 |
| (t as Const ("op =", _), ts) => SOME (Codegen.invoke_codegen |
|
1677 |
thy defs dep thyname b (gr, Codegen.eta_expand t ts 2)) |
|
1678 |
| _ => NONE); |
|
1679 |
||
1680 |
in |
|
1681 |
||
1682 |
Codegen.add_codegen "eq_codegen" eq_codegen |
|
1683 |
#> RecfunCodegen.setup |
|
1684 |
||
1685 |
end |
|
1686 |
*} |
|
1687 |
||
1688 |
text {* Evaluation *} |
|
1689 |
||
1690 |
method_setup evaluation = {* |
|
23530 | 1691 |
Method.no_args (Method.SIMPLE_METHOD' (CONVERSION Codegen.evaluation_conv THEN' rtac TrueI)) |
23247 | 1692 |
*} "solve goal by evaluation" |
1693 |
||
1694 |
||
1695 |
subsubsection {* Generic code generator setup *} |
|
1696 |
||
1697 |
text {* operational equality for code generation *} |
|
1698 |
||
1699 |
class eq (attach "op =") = type |
|
1700 |
||
1701 |
||
1702 |
text {* using built-in Haskell equality *} |
|
1703 |
||
1704 |
code_class eq |
|
1705 |
(Haskell "Eq" where "op =" \<equiv> "(==)") |
|
1706 |
||
1707 |
code_const "op =" |
|
1708 |
(Haskell infixl 4 "==") |
|
1709 |
||
1710 |
||
1711 |
text {* type bool *} |
|
1712 |
||
1713 |
code_datatype True False |
|
1714 |
||
1715 |
lemma [code func]: |
|
1716 |
shows "(False \<and> x) = False" |
|
1717 |
and "(True \<and> x) = x" |
|
1718 |
and "(x \<and> False) = False" |
|
1719 |
and "(x \<and> True) = x" by simp_all |
|
1720 |
||
1721 |
lemma [code func]: |
|
1722 |
shows "(False \<or> x) = x" |
|
1723 |
and "(True \<or> x) = True" |
|
1724 |
and "(x \<or> False) = x" |
|
1725 |
and "(x \<or> True) = True" by simp_all |
|
1726 |
||
1727 |
lemma [code func]: |
|
1728 |
shows "(\<not> True) = False" |
|
1729 |
and "(\<not> False) = True" by (rule HOL.simp_thms)+ |
|
1730 |
||
1731 |
lemmas [code] = imp_conv_disj |
|
1732 |
||
1733 |
lemmas [code func] = if_True if_False |
|
1734 |
||
1735 |
instance bool :: eq .. |
|
1736 |
||
1737 |
lemma [code func]: |
|
1738 |
shows "True = P \<longleftrightarrow> P" |
|
1739 |
and "False = P \<longleftrightarrow> \<not> P" |
|
1740 |
and "P = True \<longleftrightarrow> P" |
|
1741 |
and "P = False \<longleftrightarrow> \<not> P" by simp_all |
|
1742 |
||
1743 |
code_type bool |
|
1744 |
(SML "bool") |
|
1745 |
(OCaml "bool") |
|
1746 |
(Haskell "Bool") |
|
1747 |
||
1748 |
code_instance bool :: eq |
|
1749 |
(Haskell -) |
|
1750 |
||
1751 |
code_const "op = \<Colon> bool \<Rightarrow> bool \<Rightarrow> bool" |
|
1752 |
(Haskell infixl 4 "==") |
|
1753 |
||
1754 |
code_const True and False and Not and "op &" and "op |" and If |
|
1755 |
(SML "true" and "false" and "not" |
|
1756 |
and infixl 1 "andalso" and infixl 0 "orelse" |
|
1757 |
and "!(if (_)/ then (_)/ else (_))") |
|
1758 |
(OCaml "true" and "false" and "not" |
|
1759 |
and infixl 4 "&&" and infixl 2 "||" |
|
1760 |
and "!(if (_)/ then (_)/ else (_))") |
|
1761 |
(Haskell "True" and "False" and "not" |
|
1762 |
and infixl 3 "&&" and infixl 2 "||" |
|
1763 |
and "!(if (_)/ then (_)/ else (_))") |
|
1764 |
||
1765 |
code_reserved SML |
|
1766 |
bool true false not |
|
1767 |
||
1768 |
code_reserved OCaml |
|
23511 | 1769 |
bool not |
23247 | 1770 |
|
1771 |
||
1772 |
text {* type prop *} |
|
1773 |
||
1774 |
code_datatype Trueprop "prop" |
|
1775 |
||
1776 |
||
1777 |
text {* type itself *} |
|
1778 |
||
1779 |
code_datatype "TYPE('a)" |
|
1780 |
||
1781 |
||
1782 |
text {* code generation for undefined as exception *} |
|
1783 |
||
1784 |
code_const undefined |
|
1785 |
(SML "raise/ Fail/ \"undefined\"") |
|
1786 |
(OCaml "failwith/ \"undefined\"") |
|
1787 |
(Haskell "error/ \"undefined\"") |
|
1788 |
||
1789 |
code_reserved SML Fail |
|
1790 |
code_reserved OCaml failwith |
|
1791 |
||
1792 |
||
1793 |
subsubsection {* Evaluation oracle *} |
|
1794 |
||
1795 |
oracle eval_oracle ("term") = {* fn thy => fn t => |
|
1796 |
if CodegenPackage.satisfies thy (HOLogic.dest_Trueprop t) [] |
|
1797 |
then t |
|
1798 |
else HOLogic.Trueprop $ HOLogic.true_const (*dummy*) |
|
1799 |
*} |
|
1800 |
||
1801 |
method_setup eval = {* |
|
1802 |
let |
|
1803 |
fun eval_tac thy = |
|
1804 |
SUBGOAL (fn (t, i) => rtac (eval_oracle thy t) i) |
|
1805 |
in |
|
1806 |
Method.ctxt_args (fn ctxt => |
|
1807 |
Method.SIMPLE_METHOD' (eval_tac (ProofContext.theory_of ctxt))) |
|
1808 |
end |
|
1809 |
*} "solve goal by evaluation" |
|
1810 |
||
1811 |
||
1812 |
subsubsection {* Normalization by evaluation *} |
|
1813 |
||
1814 |
method_setup normalization = {* |
|
23530 | 1815 |
Method.no_args (Method.SIMPLE_METHOD' |
23566
b65692d4adcd
replaced HOLogic.Trueprop_conv by ObjectLogic.judgment_conv;
wenzelm
parents:
23553
diff
changeset
|
1816 |
(CONVERSION (ObjectLogic.judgment_conv NBE.normalization_conv) |
b65692d4adcd
replaced HOLogic.Trueprop_conv by ObjectLogic.judgment_conv;
wenzelm
parents:
23553
diff
changeset
|
1817 |
THEN' resolve_tac [TrueI, refl])) |
23247 | 1818 |
*} "solve goal by normalization" |
1819 |
||
1820 |
||
1821 |
text {* lazy @{const If} *} |
|
1822 |
||
1823 |
definition |
|
1824 |
if_delayed :: "bool \<Rightarrow> (bool \<Rightarrow> 'a) \<Rightarrow> (bool \<Rightarrow> 'a) \<Rightarrow> 'a" where |
|
1825 |
[code func del]: "if_delayed b f g = (if b then f True else g False)" |
|
1826 |
||
1827 |
lemma [code func]: |
|
1828 |
shows "if_delayed True f g = f True" |
|
1829 |
and "if_delayed False f g = g False" |
|
1830 |
unfolding if_delayed_def by simp_all |
|
1831 |
||
1832 |
lemma [normal pre, symmetric, normal post]: |
|
1833 |
"(if b then x else y) = if_delayed b (\<lambda>_. x) (\<lambda>_. y)" |
|
1834 |
unfolding if_delayed_def .. |
|
1835 |
||
1836 |
hide (open) const if_delayed |
|
1837 |
||
1838 |
||
22839 | 1839 |
subsection {* Legacy tactics and ML bindings *} |
21671 | 1840 |
|
1841 |
ML {* |
|
1842 |
fun strip_tac i = REPEAT (resolve_tac [impI, allI] i); |
|
1843 |
||
1844 |
(* combination of (spec RS spec RS ...(j times) ... spec RS mp) *) |
|
1845 |
local |
|
1846 |
fun wrong_prem (Const ("All", _) $ (Abs (_, _, t))) = wrong_prem t |
|
1847 |
| wrong_prem (Bound _) = true |
|
1848 |
| wrong_prem _ = false; |
|
1849 |
val filter_right = filter (not o wrong_prem o HOLogic.dest_Trueprop o hd o Thm.prems_of); |
|
1850 |
in |
|
1851 |
fun smp i = funpow i (fn m => filter_right ([spec] RL m)) ([mp]); |
|
1852 |
fun smp_tac j = EVERY'[dresolve_tac (smp j), atac]; |
|
1853 |
end; |
|
22839 | 1854 |
|
1855 |
val all_conj_distrib = thm "all_conj_distrib"; |
|
1856 |
val all_simps = thms "all_simps"; |
|
1857 |
val atomize_not = thm "atomize_not"; |
|
1858 |
val case_split = thm "case_split_thm"; |
|
1859 |
val case_split_thm = thm "case_split_thm" |
|
1860 |
val cases_simp = thm "cases_simp"; |
|
1861 |
val choice_eq = thm "choice_eq" |
|
1862 |
val cong = thm "cong" |
|
1863 |
val conj_comms = thms "conj_comms"; |
|
1864 |
val conj_cong = thm "conj_cong"; |
|
1865 |
val de_Morgan_conj = thm "de_Morgan_conj"; |
|
1866 |
val de_Morgan_disj = thm "de_Morgan_disj"; |
|
1867 |
val disj_assoc = thm "disj_assoc"; |
|
1868 |
val disj_comms = thms "disj_comms"; |
|
1869 |
val disj_cong = thm "disj_cong"; |
|
1870 |
val eq_ac = thms "eq_ac"; |
|
1871 |
val eq_cong2 = thm "eq_cong2" |
|
1872 |
val Eq_FalseI = thm "Eq_FalseI"; |
|
1873 |
val Eq_TrueI = thm "Eq_TrueI"; |
|
1874 |
val Ex1_def = thm "Ex1_def" |
|
1875 |
val ex_disj_distrib = thm "ex_disj_distrib"; |
|
1876 |
val ex_simps = thms "ex_simps"; |
|
1877 |
val if_cancel = thm "if_cancel"; |
|
1878 |
val if_eq_cancel = thm "if_eq_cancel"; |
|
1879 |
val if_False = thm "if_False"; |
|
1880 |
val iff_conv_conj_imp = thm "iff_conv_conj_imp"; |
|
1881 |
val iff = thm "iff" |
|
1882 |
val if_splits = thms "if_splits"; |
|
1883 |
val if_True = thm "if_True"; |
|
1884 |
val if_weak_cong = thm "if_weak_cong" |
|
1885 |
val imp_all = thm "imp_all"; |
|
1886 |
val imp_cong = thm "imp_cong"; |
|
1887 |
val imp_conjL = thm "imp_conjL"; |
|
1888 |
val imp_conjR = thm "imp_conjR"; |
|
1889 |
val imp_conv_disj = thm "imp_conv_disj"; |
|
1890 |
val simp_implies_def = thm "simp_implies_def"; |
|
1891 |
val simp_thms = thms "simp_thms"; |
|
1892 |
val split_if = thm "split_if"; |
|
1893 |
val the1_equality = thm "the1_equality" |
|
1894 |
val theI = thm "theI" |
|
1895 |
val theI' = thm "theI'" |
|
1896 |
val True_implies_equals = thm "True_implies_equals"; |
|
23037
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1897 |
val nnf_conv = Simplifier.rewrite (HOL_basic_ss addsimps simp_thms @ @{thms "nnf_simps"}) |
6c72943a71b1
added a set of NNF normalization lemmas and nnf_conv
chaieb
parents:
22993
diff
changeset
|
1898 |
|
21671 | 1899 |
*} |
1900 |
||
14357 | 1901 |
end |