author | paulson |
Tue, 28 Jun 2005 15:27:45 +0200 | |
changeset 16587 | b34c8aa657a5 |
parent 16417 | 9bc16273c2d4 |
child 16633 | 208ebc9311f2 |
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 |
16417 | 10 |
uses ("cladata.ML") ("blastdata.ML") ("simpdata.ML") ("eqrule_HOL_data.ML") |
15481 | 11 |
("~~/src/Provers/eqsubst.ML") |
15131 | 12 |
begin |
2260 | 13 |
|
11750 | 14 |
subsection {* Primitive logic *} |
15 |
||
16 |
subsubsection {* Core syntax *} |
|
2260 | 17 |
|
14854 | 18 |
classes type |
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
19 |
defaultsort type |
3947 | 20 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
21 |
global |
923 | 22 |
|
7357 | 23 |
typedecl bool |
923 | 24 |
|
25 |
arities |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
26 |
bool :: type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
27 |
fun :: (type, type) type |
923 | 28 |
|
11750 | 29 |
judgment |
30 |
Trueprop :: "bool => prop" ("(_)" 5) |
|
923 | 31 |
|
11750 | 32 |
consts |
7357 | 33 |
Not :: "bool => bool" ("~ _" [40] 40) |
34 |
True :: bool |
|
35 |
False :: bool |
|
3947 | 36 |
arbitrary :: 'a |
923 | 37 |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
38 |
The :: "('a => bool) => 'a" |
7357 | 39 |
All :: "('a => bool) => bool" (binder "ALL " 10) |
40 |
Ex :: "('a => bool) => bool" (binder "EX " 10) |
|
41 |
Ex1 :: "('a => bool) => bool" (binder "EX! " 10) |
|
42 |
Let :: "['a, 'a => 'b] => 'b" |
|
923 | 43 |
|
7357 | 44 |
"=" :: "['a, 'a] => bool" (infixl 50) |
45 |
& :: "[bool, bool] => bool" (infixr 35) |
|
46 |
"|" :: "[bool, bool] => bool" (infixr 30) |
|
47 |
--> :: "[bool, bool] => bool" (infixr 25) |
|
923 | 48 |
|
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
49 |
local |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
50 |
|
16587 | 51 |
consts |
52 |
If :: "[bool, 'a, 'a] => 'a" ("(if (_)/ then (_)/ else (_))" 10) |
|
2260 | 53 |
|
11750 | 54 |
subsubsection {* Additional concrete syntax *} |
2260 | 55 |
|
4868 | 56 |
nonterminals |
923 | 57 |
letbinds letbind |
58 |
case_syn cases_syn |
|
59 |
||
60 |
syntax |
|
12650 | 61 |
"_not_equal" :: "['a, 'a] => bool" (infixl "~=" 50) |
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
62 |
"_The" :: "[pttrn, bool] => 'a" ("(3THE _./ _)" [0, 10] 10) |
923 | 63 |
|
7357 | 64 |
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) |
65 |
"" :: "letbind => letbinds" ("_") |
|
66 |
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") |
|
67 |
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) |
|
923 | 68 |
|
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
69 |
"_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
|
70 |
"_case1" :: "['a, 'b] => case_syn" ("(2_ =>/ _)" 10) |
7357 | 71 |
"" :: "case_syn => cases_syn" ("_") |
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
72 |
"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ | _") |
923 | 73 |
|
74 |
translations |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
75 |
"x ~= y" == "~ (x = y)" |
13764 | 76 |
"THE x. P" == "The (%x. P)" |
923 | 77 |
"_Let (_binds b bs) e" == "_Let b (_Let bs e)" |
1114 | 78 |
"let x = a in e" == "Let a (%x. e)" |
923 | 79 |
|
13763
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
80 |
print_translation {* |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
81 |
(* To avoid eta-contraction of body: *) |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
82 |
[("The", fn [Abs abs] => |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
83 |
let val (x,t) = atomic_abs_tr' abs |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
84 |
in Syntax.const "_The" $ x $ t end)] |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
85 |
*} |
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset
|
86 |
|
12633 | 87 |
syntax (output) |
11687 | 88 |
"=" :: "['a, 'a] => bool" (infix 50) |
12650 | 89 |
"_not_equal" :: "['a, 'a] => bool" (infix "~=" 50) |
2260 | 90 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
91 |
syntax (xsymbols) |
11687 | 92 |
Not :: "bool => bool" ("\<not> _" [40] 40) |
93 |
"op &" :: "[bool, bool] => bool" (infixr "\<and>" 35) |
|
94 |
"op |" :: "[bool, bool] => bool" (infixr "\<or>" 30) |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
95 |
"op -->" :: "[bool, bool] => bool" (infixr "\<longrightarrow>" 25) |
12650 | 96 |
"_not_equal" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
11687 | 97 |
"ALL " :: "[idts, bool] => bool" ("(3\<forall>_./ _)" [0, 10] 10) |
98 |
"EX " :: "[idts, bool] => bool" ("(3\<exists>_./ _)" [0, 10] 10) |
|
99 |
"EX! " :: "[idts, bool] => bool" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
100 |
"_case1" :: "['a, 'b] => case_syn" ("(2_ \<Rightarrow>/ _)" 10) |
|
14361
ad2f5da643b4
* Support for raw latex output in control symbols: \<^raw...>
schirmer
parents:
14357
diff
changeset
|
101 |
(*"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ \<orelse> _")*) |
2372 | 102 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
103 |
syntax (xsymbols output) |
12650 | 104 |
"_not_equal" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
3820 | 105 |
|
6340 | 106 |
syntax (HTML output) |
14565 | 107 |
"_not_equal" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
11687 | 108 |
Not :: "bool => bool" ("\<not> _" [40] 40) |
14565 | 109 |
"op &" :: "[bool, bool] => bool" (infixr "\<and>" 35) |
110 |
"op |" :: "[bool, bool] => bool" (infixr "\<or>" 30) |
|
111 |
"_not_equal" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
|
112 |
"ALL " :: "[idts, bool] => bool" ("(3\<forall>_./ _)" [0, 10] 10) |
|
113 |
"EX " :: "[idts, bool] => bool" ("(3\<exists>_./ _)" [0, 10] 10) |
|
114 |
"EX! " :: "[idts, bool] => bool" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
6340 | 115 |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
116 |
syntax (HOL) |
7357 | 117 |
"ALL " :: "[idts, bool] => bool" ("(3! _./ _)" [0, 10] 10) |
118 |
"EX " :: "[idts, bool] => bool" ("(3? _./ _)" [0, 10] 10) |
|
119 |
"EX! " :: "[idts, bool] => bool" ("(3?! _./ _)" [0, 10] 10) |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
120 |
|
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
121 |
|
11750 | 122 |
subsubsection {* Axioms and basic definitions *} |
2260 | 123 |
|
7357 | 124 |
axioms |
15380 | 125 |
eq_reflection: "(x=y) ==> (x==y)" |
923 | 126 |
|
15380 | 127 |
refl: "t = (t::'a)" |
6289 | 128 |
|
15380 | 129 |
ext: "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" |
130 |
-- {*Extensionality is built into the meta-logic, and this rule expresses |
|
131 |
a related property. It is an eta-expanded version of the traditional |
|
132 |
rule, and similar to the ABS rule of HOL*} |
|
6289 | 133 |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
134 |
the_eq_trivial: "(THE x. x = a) = (a::'a)" |
923 | 135 |
|
15380 | 136 |
impI: "(P ==> Q) ==> P-->Q" |
137 |
mp: "[| P-->Q; P |] ==> Q" |
|
138 |
||
139 |
||
140 |
text{*Thanks to Stephan Merz*} |
|
141 |
theorem subst: |
|
142 |
assumes eq: "s = t" and p: "P(s)" |
|
143 |
shows "P(t::'a)" |
|
144 |
proof - |
|
145 |
from eq have meta: "s \<equiv> t" |
|
146 |
by (rule eq_reflection) |
|
147 |
from p show ?thesis |
|
148 |
by (unfold meta) |
|
149 |
qed |
|
923 | 150 |
|
151 |
defs |
|
7357 | 152 |
True_def: "True == ((%x::bool. x) = (%x. x))" |
153 |
All_def: "All(P) == (P = (%x. True))" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
154 |
Ex_def: "Ex(P) == !Q. (!x. P x --> Q) --> Q" |
7357 | 155 |
False_def: "False == (!P. P)" |
156 |
not_def: "~ P == P-->False" |
|
157 |
and_def: "P & Q == !R. (P-->Q-->R) --> R" |
|
158 |
or_def: "P | Q == !R. (P-->R) --> (Q-->R) --> R" |
|
159 |
Ex1_def: "Ex1(P) == ? x. P(x) & (! y. P(y) --> y=x)" |
|
923 | 160 |
|
7357 | 161 |
axioms |
162 |
iff: "(P-->Q) --> (Q-->P) --> (P=Q)" |
|
163 |
True_or_False: "(P=True) | (P=False)" |
|
923 | 164 |
|
165 |
defs |
|
7357 | 166 |
Let_def: "Let s f == f(s)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
167 |
if_def: "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)" |
5069 | 168 |
|
14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
169 |
finalconsts |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
170 |
"op =" |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
171 |
"op -->" |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
172 |
The |
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset
|
173 |
arbitrary |
3320 | 174 |
|
11750 | 175 |
subsubsection {* Generic algebraic operations *} |
4868 | 176 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
177 |
axclass zero < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
178 |
axclass one < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
179 |
axclass plus < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
180 |
axclass minus < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
181 |
axclass times < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
182 |
axclass inverse < type |
11750 | 183 |
|
184 |
global |
|
185 |
||
186 |
consts |
|
187 |
"0" :: "'a::zero" ("0") |
|
188 |
"1" :: "'a::one" ("1") |
|
189 |
"+" :: "['a::plus, 'a] => 'a" (infixl 65) |
|
190 |
- :: "['a::minus, 'a] => 'a" (infixl 65) |
|
191 |
uminus :: "['a::minus] => 'a" ("- _" [81] 80) |
|
192 |
* :: "['a::times, 'a] => 'a" (infixl 70) |
|
193 |
||
13456
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset
|
194 |
syntax |
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset
|
195 |
"_index1" :: index ("\<^sub>1") |
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset
|
196 |
translations |
14690 | 197 |
(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
|
198 |
|
11750 | 199 |
local |
200 |
||
201 |
typed_print_translation {* |
|
202 |
let |
|
203 |
fun tr' c = (c, fn show_sorts => fn T => fn ts => |
|
204 |
if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match |
|
205 |
else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T); |
|
206 |
in [tr' "0", tr' "1"] end; |
|
207 |
*} -- {* show types that are presumably too general *} |
|
208 |
||
209 |
||
210 |
consts |
|
211 |
abs :: "'a::minus => 'a" |
|
212 |
inverse :: "'a::inverse => 'a" |
|
213 |
divide :: "['a::inverse, 'a] => 'a" (infixl "'/" 70) |
|
214 |
||
215 |
syntax (xsymbols) |
|
216 |
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") |
|
217 |
syntax (HTML output) |
|
218 |
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") |
|
219 |
||
220 |
||
15411 | 221 |
subsection {*Equality*} |
222 |
||
223 |
lemma sym: "s=t ==> t=s" |
|
224 |
apply (erule subst) |
|
225 |
apply (rule refl) |
|
226 |
done |
|
227 |
||
228 |
(*calling "standard" reduces maxidx to 0*) |
|
229 |
lemmas ssubst = sym [THEN subst, standard] |
|
230 |
||
231 |
lemma trans: "[| r=s; s=t |] ==> r=t" |
|
232 |
apply (erule subst , assumption) |
|
233 |
done |
|
234 |
||
235 |
lemma def_imp_eq: assumes meq: "A == B" shows "A = B" |
|
236 |
apply (unfold meq) |
|
237 |
apply (rule refl) |
|
238 |
done |
|
239 |
||
240 |
(*Useful with eresolve_tac for proving equalties from known equalities. |
|
241 |
a = b |
|
242 |
| | |
|
243 |
c = d *) |
|
244 |
lemma box_equals: "[| a=b; a=c; b=d |] ==> c=d" |
|
245 |
apply (rule trans) |
|
246 |
apply (rule trans) |
|
247 |
apply (rule sym) |
|
248 |
apply assumption+ |
|
249 |
done |
|
250 |
||
15524
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
251 |
text {* For calculational reasoning: *} |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
252 |
|
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
253 |
lemma forw_subst: "a = b ==> P b ==> P a" |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
254 |
by (rule ssubst) |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
255 |
|
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
256 |
lemma back_subst: "P a ==> a = b ==> P b" |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
257 |
by (rule subst) |
2ef571f80a55
Moved oderings from HOL into the new Orderings.thy
nipkow
parents:
15481
diff
changeset
|
258 |
|
15411 | 259 |
|
260 |
subsection {*Congruence rules for application*} |
|
261 |
||
262 |
(*similar to AP_THM in Gordon's HOL*) |
|
263 |
lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)" |
|
264 |
apply (erule subst) |
|
265 |
apply (rule refl) |
|
266 |
done |
|
267 |
||
268 |
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*) |
|
269 |
lemma arg_cong: "x=y ==> f(x)=f(y)" |
|
270 |
apply (erule subst) |
|
271 |
apply (rule refl) |
|
272 |
done |
|
273 |
||
15655 | 274 |
lemma arg_cong2: "\<lbrakk> a = b; c = d \<rbrakk> \<Longrightarrow> f a c = f b d" |
275 |
apply (erule ssubst)+ |
|
276 |
apply (rule refl) |
|
277 |
done |
|
278 |
||
279 |
||
15411 | 280 |
lemma cong: "[| f = g; (x::'a) = y |] ==> f(x) = g(y)" |
281 |
apply (erule subst)+ |
|
282 |
apply (rule refl) |
|
283 |
done |
|
284 |
||
285 |
||
286 |
subsection {*Equality of booleans -- iff*} |
|
287 |
||
288 |
lemma iffI: assumes prems: "P ==> Q" "Q ==> P" shows "P=Q" |
|
289 |
apply (rules intro: iff [THEN mp, THEN mp] impI prems) |
|
290 |
done |
|
291 |
||
292 |
lemma iffD2: "[| P=Q; Q |] ==> P" |
|
293 |
apply (erule ssubst) |
|
294 |
apply assumption |
|
295 |
done |
|
296 |
||
297 |
lemma rev_iffD2: "[| Q; P=Q |] ==> P" |
|
298 |
apply (erule iffD2) |
|
299 |
apply assumption |
|
300 |
done |
|
301 |
||
302 |
lemmas iffD1 = sym [THEN iffD2, standard] |
|
303 |
lemmas rev_iffD1 = sym [THEN [2] rev_iffD2, standard] |
|
304 |
||
305 |
lemma iffE: |
|
306 |
assumes major: "P=Q" |
|
307 |
and minor: "[| P --> Q; Q --> P |] ==> R" |
|
308 |
shows "R" |
|
309 |
by (rules intro: minor impI major [THEN iffD2] major [THEN iffD1]) |
|
310 |
||
311 |
||
312 |
subsection {*True*} |
|
313 |
||
314 |
lemma TrueI: "True" |
|
315 |
apply (unfold True_def) |
|
316 |
apply (rule refl) |
|
317 |
done |
|
318 |
||
319 |
lemma eqTrueI: "P ==> P=True" |
|
320 |
by (rules intro: iffI TrueI) |
|
321 |
||
322 |
lemma eqTrueE: "P=True ==> P" |
|
323 |
apply (erule iffD2) |
|
324 |
apply (rule TrueI) |
|
325 |
done |
|
326 |
||
327 |
||
328 |
subsection {*Universal quantifier*} |
|
329 |
||
330 |
lemma allI: assumes p: "!!x::'a. P(x)" shows "ALL x. P(x)" |
|
331 |
apply (unfold All_def) |
|
332 |
apply (rules intro: ext eqTrueI p) |
|
333 |
done |
|
334 |
||
335 |
lemma spec: "ALL x::'a. P(x) ==> P(x)" |
|
336 |
apply (unfold All_def) |
|
337 |
apply (rule eqTrueE) |
|
338 |
apply (erule fun_cong) |
|
339 |
done |
|
340 |
||
341 |
lemma allE: |
|
342 |
assumes major: "ALL x. P(x)" |
|
343 |
and minor: "P(x) ==> R" |
|
344 |
shows "R" |
|
345 |
by (rules intro: minor major [THEN spec]) |
|
346 |
||
347 |
lemma all_dupE: |
|
348 |
assumes major: "ALL x. P(x)" |
|
349 |
and minor: "[| P(x); ALL x. P(x) |] ==> R" |
|
350 |
shows "R" |
|
351 |
by (rules intro: minor major major [THEN spec]) |
|
352 |
||
353 |
||
354 |
subsection {*False*} |
|
355 |
(*Depends upon spec; it is impossible to do propositional logic before quantifiers!*) |
|
356 |
||
357 |
lemma FalseE: "False ==> P" |
|
358 |
apply (unfold False_def) |
|
359 |
apply (erule spec) |
|
360 |
done |
|
361 |
||
362 |
lemma False_neq_True: "False=True ==> P" |
|
363 |
by (erule eqTrueE [THEN FalseE]) |
|
364 |
||
365 |
||
366 |
subsection {*Negation*} |
|
367 |
||
368 |
lemma notI: |
|
369 |
assumes p: "P ==> False" |
|
370 |
shows "~P" |
|
371 |
apply (unfold not_def) |
|
372 |
apply (rules intro: impI p) |
|
373 |
done |
|
374 |
||
375 |
lemma False_not_True: "False ~= True" |
|
376 |
apply (rule notI) |
|
377 |
apply (erule False_neq_True) |
|
378 |
done |
|
379 |
||
380 |
lemma True_not_False: "True ~= False" |
|
381 |
apply (rule notI) |
|
382 |
apply (drule sym) |
|
383 |
apply (erule False_neq_True) |
|
384 |
done |
|
385 |
||
386 |
lemma notE: "[| ~P; P |] ==> R" |
|
387 |
apply (unfold not_def) |
|
388 |
apply (erule mp [THEN FalseE]) |
|
389 |
apply assumption |
|
390 |
done |
|
391 |
||
392 |
(* Alternative ~ introduction rule: [| P ==> ~ Pa; P ==> Pa |] ==> ~ P *) |
|
393 |
lemmas notI2 = notE [THEN notI, standard] |
|
394 |
||
395 |
||
396 |
subsection {*Implication*} |
|
397 |
||
398 |
lemma impE: |
|
399 |
assumes "P-->Q" "P" "Q ==> R" |
|
400 |
shows "R" |
|
401 |
by (rules intro: prems mp) |
|
402 |
||
403 |
(* Reduces Q to P-->Q, allowing substitution in P. *) |
|
404 |
lemma rev_mp: "[| P; P --> Q |] ==> Q" |
|
405 |
by (rules intro: mp) |
|
406 |
||
407 |
lemma contrapos_nn: |
|
408 |
assumes major: "~Q" |
|
409 |
and minor: "P==>Q" |
|
410 |
shows "~P" |
|
411 |
by (rules intro: notI minor major [THEN notE]) |
|
412 |
||
413 |
(*not used at all, but we already have the other 3 combinations *) |
|
414 |
lemma contrapos_pn: |
|
415 |
assumes major: "Q" |
|
416 |
and minor: "P ==> ~Q" |
|
417 |
shows "~P" |
|
418 |
by (rules intro: notI minor major notE) |
|
419 |
||
420 |
lemma not_sym: "t ~= s ==> s ~= t" |
|
421 |
apply (erule contrapos_nn) |
|
422 |
apply (erule sym) |
|
423 |
done |
|
424 |
||
425 |
(*still used in HOLCF*) |
|
426 |
lemma rev_contrapos: |
|
427 |
assumes pq: "P ==> Q" |
|
428 |
and nq: "~Q" |
|
429 |
shows "~P" |
|
430 |
apply (rule nq [THEN contrapos_nn]) |
|
431 |
apply (erule pq) |
|
432 |
done |
|
433 |
||
434 |
subsection {*Existential quantifier*} |
|
435 |
||
436 |
lemma exI: "P x ==> EX x::'a. P x" |
|
437 |
apply (unfold Ex_def) |
|
438 |
apply (rules intro: allI allE impI mp) |
|
439 |
done |
|
440 |
||
441 |
lemma exE: |
|
442 |
assumes major: "EX x::'a. P(x)" |
|
443 |
and minor: "!!x. P(x) ==> Q" |
|
444 |
shows "Q" |
|
445 |
apply (rule major [unfolded Ex_def, THEN spec, THEN mp]) |
|
446 |
apply (rules intro: impI [THEN allI] minor) |
|
447 |
done |
|
448 |
||
449 |
||
450 |
subsection {*Conjunction*} |
|
451 |
||
452 |
lemma conjI: "[| P; Q |] ==> P&Q" |
|
453 |
apply (unfold and_def) |
|
454 |
apply (rules intro: impI [THEN allI] mp) |
|
455 |
done |
|
456 |
||
457 |
lemma conjunct1: "[| P & Q |] ==> P" |
|
458 |
apply (unfold and_def) |
|
459 |
apply (rules intro: impI dest: spec mp) |
|
460 |
done |
|
461 |
||
462 |
lemma conjunct2: "[| P & Q |] ==> Q" |
|
463 |
apply (unfold and_def) |
|
464 |
apply (rules intro: impI dest: spec mp) |
|
465 |
done |
|
466 |
||
467 |
lemma conjE: |
|
468 |
assumes major: "P&Q" |
|
469 |
and minor: "[| P; Q |] ==> R" |
|
470 |
shows "R" |
|
471 |
apply (rule minor) |
|
472 |
apply (rule major [THEN conjunct1]) |
|
473 |
apply (rule major [THEN conjunct2]) |
|
474 |
done |
|
475 |
||
476 |
lemma context_conjI: |
|
477 |
assumes prems: "P" "P ==> Q" shows "P & Q" |
|
478 |
by (rules intro: conjI prems) |
|
479 |
||
480 |
||
481 |
subsection {*Disjunction*} |
|
482 |
||
483 |
lemma disjI1: "P ==> P|Q" |
|
484 |
apply (unfold or_def) |
|
485 |
apply (rules intro: allI impI mp) |
|
486 |
done |
|
487 |
||
488 |
lemma disjI2: "Q ==> P|Q" |
|
489 |
apply (unfold or_def) |
|
490 |
apply (rules intro: allI impI mp) |
|
491 |
done |
|
492 |
||
493 |
lemma disjE: |
|
494 |
assumes major: "P|Q" |
|
495 |
and minorP: "P ==> R" |
|
496 |
and minorQ: "Q ==> R" |
|
497 |
shows "R" |
|
498 |
by (rules intro: minorP minorQ impI |
|
499 |
major [unfolded or_def, THEN spec, THEN mp, THEN mp]) |
|
500 |
||
501 |
||
502 |
subsection {*Classical logic*} |
|
503 |
||
504 |
||
505 |
lemma classical: |
|
506 |
assumes prem: "~P ==> P" |
|
507 |
shows "P" |
|
508 |
apply (rule True_or_False [THEN disjE, THEN eqTrueE]) |
|
509 |
apply assumption |
|
510 |
apply (rule notI [THEN prem, THEN eqTrueI]) |
|
511 |
apply (erule subst) |
|
512 |
apply assumption |
|
513 |
done |
|
514 |
||
515 |
lemmas ccontr = FalseE [THEN classical, standard] |
|
516 |
||
517 |
(*notE with premises exchanged; it discharges ~R so that it can be used to |
|
518 |
make elimination rules*) |
|
519 |
lemma rev_notE: |
|
520 |
assumes premp: "P" |
|
521 |
and premnot: "~R ==> ~P" |
|
522 |
shows "R" |
|
523 |
apply (rule ccontr) |
|
524 |
apply (erule notE [OF premnot premp]) |
|
525 |
done |
|
526 |
||
527 |
(*Double negation law*) |
|
528 |
lemma notnotD: "~~P ==> P" |
|
529 |
apply (rule classical) |
|
530 |
apply (erule notE) |
|
531 |
apply assumption |
|
532 |
done |
|
533 |
||
534 |
lemma contrapos_pp: |
|
535 |
assumes p1: "Q" |
|
536 |
and p2: "~P ==> ~Q" |
|
537 |
shows "P" |
|
538 |
by (rules intro: classical p1 p2 notE) |
|
539 |
||
540 |
||
541 |
subsection {*Unique existence*} |
|
542 |
||
543 |
lemma ex1I: |
|
544 |
assumes prems: "P a" "!!x. P(x) ==> x=a" |
|
545 |
shows "EX! x. P(x)" |
|
546 |
by (unfold Ex1_def, rules intro: prems exI conjI allI impI) |
|
547 |
||
548 |
text{*Sometimes easier to use: the premises have no shared variables. Safe!*} |
|
549 |
lemma ex_ex1I: |
|
550 |
assumes ex_prem: "EX x. P(x)" |
|
551 |
and eq: "!!x y. [| P(x); P(y) |] ==> x=y" |
|
552 |
shows "EX! x. P(x)" |
|
553 |
by (rules intro: ex_prem [THEN exE] ex1I eq) |
|
554 |
||
555 |
lemma ex1E: |
|
556 |
assumes major: "EX! x. P(x)" |
|
557 |
and minor: "!!x. [| P(x); ALL y. P(y) --> y=x |] ==> R" |
|
558 |
shows "R" |
|
559 |
apply (rule major [unfolded Ex1_def, THEN exE]) |
|
560 |
apply (erule conjE) |
|
561 |
apply (rules intro: minor) |
|
562 |
done |
|
563 |
||
564 |
lemma ex1_implies_ex: "EX! x. P x ==> EX x. P x" |
|
565 |
apply (erule ex1E) |
|
566 |
apply (rule exI) |
|
567 |
apply assumption |
|
568 |
done |
|
569 |
||
570 |
||
571 |
subsection {*THE: definite description operator*} |
|
572 |
||
573 |
lemma the_equality: |
|
574 |
assumes prema: "P a" |
|
575 |
and premx: "!!x. P x ==> x=a" |
|
576 |
shows "(THE x. P x) = a" |
|
577 |
apply (rule trans [OF _ the_eq_trivial]) |
|
578 |
apply (rule_tac f = "The" in arg_cong) |
|
579 |
apply (rule ext) |
|
580 |
apply (rule iffI) |
|
581 |
apply (erule premx) |
|
582 |
apply (erule ssubst, rule prema) |
|
583 |
done |
|
584 |
||
585 |
lemma theI: |
|
586 |
assumes "P a" and "!!x. P x ==> x=a" |
|
587 |
shows "P (THE x. P x)" |
|
588 |
by (rules intro: prems the_equality [THEN ssubst]) |
|
589 |
||
590 |
lemma theI': "EX! x. P x ==> P (THE x. P x)" |
|
591 |
apply (erule ex1E) |
|
592 |
apply (erule theI) |
|
593 |
apply (erule allE) |
|
594 |
apply (erule mp) |
|
595 |
apply assumption |
|
596 |
done |
|
597 |
||
598 |
(*Easier to apply than theI: only one occurrence of P*) |
|
599 |
lemma theI2: |
|
600 |
assumes "P a" "!!x. P x ==> x=a" "!!x. P x ==> Q x" |
|
601 |
shows "Q (THE x. P x)" |
|
602 |
by (rules intro: prems theI) |
|
603 |
||
604 |
lemma the1_equality: "[| EX!x. P x; P a |] ==> (THE x. P x) = a" |
|
605 |
apply (rule the_equality) |
|
606 |
apply assumption |
|
607 |
apply (erule ex1E) |
|
608 |
apply (erule all_dupE) |
|
609 |
apply (drule mp) |
|
610 |
apply assumption |
|
611 |
apply (erule ssubst) |
|
612 |
apply (erule allE) |
|
613 |
apply (erule mp) |
|
614 |
apply assumption |
|
615 |
done |
|
616 |
||
617 |
lemma the_sym_eq_trivial: "(THE y. x=y) = x" |
|
618 |
apply (rule the_equality) |
|
619 |
apply (rule refl) |
|
620 |
apply (erule sym) |
|
621 |
done |
|
622 |
||
623 |
||
624 |
subsection {*Classical intro rules for disjunction and existential quantifiers*} |
|
625 |
||
626 |
lemma disjCI: |
|
627 |
assumes "~Q ==> P" shows "P|Q" |
|
628 |
apply (rule classical) |
|
629 |
apply (rules intro: prems disjI1 disjI2 notI elim: notE) |
|
630 |
done |
|
631 |
||
632 |
lemma excluded_middle: "~P | P" |
|
633 |
by (rules intro: disjCI) |
|
634 |
||
635 |
text{*case distinction as a natural deduction rule. Note that @{term "~P"} |
|
636 |
is the second case, not the first.*} |
|
637 |
lemma case_split_thm: |
|
638 |
assumes prem1: "P ==> Q" |
|
639 |
and prem2: "~P ==> Q" |
|
640 |
shows "Q" |
|
641 |
apply (rule excluded_middle [THEN disjE]) |
|
642 |
apply (erule prem2) |
|
643 |
apply (erule prem1) |
|
644 |
done |
|
645 |
||
646 |
(*Classical implies (-->) elimination. *) |
|
647 |
lemma impCE: |
|
648 |
assumes major: "P-->Q" |
|
649 |
and minor: "~P ==> R" "Q ==> R" |
|
650 |
shows "R" |
|
651 |
apply (rule excluded_middle [of P, THEN disjE]) |
|
652 |
apply (rules intro: minor major [THEN mp])+ |
|
653 |
done |
|
654 |
||
655 |
(*This version of --> elimination works on Q before P. It works best for |
|
656 |
those cases in which P holds "almost everywhere". Can't install as |
|
657 |
default: would break old proofs.*) |
|
658 |
lemma impCE': |
|
659 |
assumes major: "P-->Q" |
|
660 |
and minor: "Q ==> R" "~P ==> R" |
|
661 |
shows "R" |
|
662 |
apply (rule excluded_middle [of P, THEN disjE]) |
|
663 |
apply (rules intro: minor major [THEN mp])+ |
|
664 |
done |
|
665 |
||
666 |
(*Classical <-> elimination. *) |
|
667 |
lemma iffCE: |
|
668 |
assumes major: "P=Q" |
|
669 |
and minor: "[| P; Q |] ==> R" "[| ~P; ~Q |] ==> R" |
|
670 |
shows "R" |
|
671 |
apply (rule major [THEN iffE]) |
|
672 |
apply (rules intro: minor elim: impCE notE) |
|
673 |
done |
|
674 |
||
675 |
lemma exCI: |
|
676 |
assumes "ALL x. ~P(x) ==> P(a)" |
|
677 |
shows "EX x. P(x)" |
|
678 |
apply (rule ccontr) |
|
679 |
apply (rules intro: prems exI allI notI notE [of "\<exists>x. P x"]) |
|
680 |
done |
|
681 |
||
682 |
||
683 |
||
11750 | 684 |
subsection {* Theory and package setup *} |
685 |
||
15411 | 686 |
ML |
687 |
{* |
|
688 |
val plusI = thm "plusI" |
|
689 |
val minusI = thm "minusI" |
|
690 |
val timesI = thm "timesI" |
|
691 |
val eq_reflection = thm "eq_reflection" |
|
692 |
val refl = thm "refl" |
|
693 |
val subst = thm "subst" |
|
694 |
val ext = thm "ext" |
|
695 |
val impI = thm "impI" |
|
696 |
val mp = thm "mp" |
|
697 |
val True_def = thm "True_def" |
|
698 |
val All_def = thm "All_def" |
|
699 |
val Ex_def = thm "Ex_def" |
|
700 |
val False_def = thm "False_def" |
|
701 |
val not_def = thm "not_def" |
|
702 |
val and_def = thm "and_def" |
|
703 |
val or_def = thm "or_def" |
|
704 |
val Ex1_def = thm "Ex1_def" |
|
705 |
val iff = thm "iff" |
|
706 |
val True_or_False = thm "True_or_False" |
|
707 |
val Let_def = thm "Let_def" |
|
708 |
val if_def = thm "if_def" |
|
709 |
val sym = thm "sym" |
|
710 |
val ssubst = thm "ssubst" |
|
711 |
val trans = thm "trans" |
|
712 |
val def_imp_eq = thm "def_imp_eq" |
|
713 |
val box_equals = thm "box_equals" |
|
714 |
val fun_cong = thm "fun_cong" |
|
715 |
val arg_cong = thm "arg_cong" |
|
716 |
val cong = thm "cong" |
|
717 |
val iffI = thm "iffI" |
|
718 |
val iffD2 = thm "iffD2" |
|
719 |
val rev_iffD2 = thm "rev_iffD2" |
|
720 |
val iffD1 = thm "iffD1" |
|
721 |
val rev_iffD1 = thm "rev_iffD1" |
|
722 |
val iffE = thm "iffE" |
|
723 |
val TrueI = thm "TrueI" |
|
724 |
val eqTrueI = thm "eqTrueI" |
|
725 |
val eqTrueE = thm "eqTrueE" |
|
726 |
val allI = thm "allI" |
|
727 |
val spec = thm "spec" |
|
728 |
val allE = thm "allE" |
|
729 |
val all_dupE = thm "all_dupE" |
|
730 |
val FalseE = thm "FalseE" |
|
731 |
val False_neq_True = thm "False_neq_True" |
|
732 |
val notI = thm "notI" |
|
733 |
val False_not_True = thm "False_not_True" |
|
734 |
val True_not_False = thm "True_not_False" |
|
735 |
val notE = thm "notE" |
|
736 |
val notI2 = thm "notI2" |
|
737 |
val impE = thm "impE" |
|
738 |
val rev_mp = thm "rev_mp" |
|
739 |
val contrapos_nn = thm "contrapos_nn" |
|
740 |
val contrapos_pn = thm "contrapos_pn" |
|
741 |
val not_sym = thm "not_sym" |
|
742 |
val rev_contrapos = thm "rev_contrapos" |
|
743 |
val exI = thm "exI" |
|
744 |
val exE = thm "exE" |
|
745 |
val conjI = thm "conjI" |
|
746 |
val conjunct1 = thm "conjunct1" |
|
747 |
val conjunct2 = thm "conjunct2" |
|
748 |
val conjE = thm "conjE" |
|
749 |
val context_conjI = thm "context_conjI" |
|
750 |
val disjI1 = thm "disjI1" |
|
751 |
val disjI2 = thm "disjI2" |
|
752 |
val disjE = thm "disjE" |
|
753 |
val classical = thm "classical" |
|
754 |
val ccontr = thm "ccontr" |
|
755 |
val rev_notE = thm "rev_notE" |
|
756 |
val notnotD = thm "notnotD" |
|
757 |
val contrapos_pp = thm "contrapos_pp" |
|
758 |
val ex1I = thm "ex1I" |
|
759 |
val ex_ex1I = thm "ex_ex1I" |
|
760 |
val ex1E = thm "ex1E" |
|
761 |
val ex1_implies_ex = thm "ex1_implies_ex" |
|
762 |
val the_equality = thm "the_equality" |
|
763 |
val theI = thm "theI" |
|
764 |
val theI' = thm "theI'" |
|
765 |
val theI2 = thm "theI2" |
|
766 |
val the1_equality = thm "the1_equality" |
|
767 |
val the_sym_eq_trivial = thm "the_sym_eq_trivial" |
|
768 |
val disjCI = thm "disjCI" |
|
769 |
val excluded_middle = thm "excluded_middle" |
|
770 |
val case_split_thm = thm "case_split_thm" |
|
771 |
val impCE = thm "impCE" |
|
772 |
val impCE = thm "impCE" |
|
773 |
val iffCE = thm "iffCE" |
|
774 |
val exCI = thm "exCI" |
|
4868 | 775 |
|
15411 | 776 |
(* combination of (spec RS spec RS ...(j times) ... spec RS mp) *) |
777 |
local |
|
778 |
fun wrong_prem (Const ("All", _) $ (Abs (_, _, t))) = wrong_prem t |
|
779 |
| wrong_prem (Bound _) = true |
|
780 |
| wrong_prem _ = false |
|
15570 | 781 |
val filter_right = List.filter (fn t => not (wrong_prem (HOLogic.dest_Trueprop (hd (Thm.prems_of t))))) |
15411 | 782 |
in |
783 |
fun smp i = funpow i (fn m => filter_right ([spec] RL m)) ([mp]) |
|
784 |
fun smp_tac j = EVERY'[dresolve_tac (smp j), atac] |
|
785 |
end |
|
786 |
||
787 |
||
788 |
fun strip_tac i = REPEAT(resolve_tac [impI,allI] i) |
|
789 |
||
790 |
(*Obsolete form of disjunctive case analysis*) |
|
791 |
fun excluded_middle_tac sP = |
|
792 |
res_inst_tac [("Q",sP)] (excluded_middle RS disjE) |
|
793 |
||
794 |
fun case_tac a = res_inst_tac [("P",a)] case_split_thm |
|
795 |
*} |
|
796 |
||
11687 | 797 |
theorems case_split = case_split_thm [case_names True False] |
9869 | 798 |
|
12386 | 799 |
|
800 |
subsubsection {* Intuitionistic Reasoning *} |
|
801 |
||
802 |
lemma impE': |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
803 |
assumes 1: "P --> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
804 |
and 2: "Q ==> R" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
805 |
and 3: "P --> Q ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
806 |
shows R |
12386 | 807 |
proof - |
808 |
from 3 and 1 have P . |
|
809 |
with 1 have Q by (rule impE) |
|
810 |
with 2 show R . |
|
811 |
qed |
|
812 |
||
813 |
lemma allE': |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
814 |
assumes 1: "ALL x. P x" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
815 |
and 2: "P x ==> ALL x. P x ==> Q" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
816 |
shows Q |
12386 | 817 |
proof - |
818 |
from 1 have "P x" by (rule spec) |
|
819 |
from this and 1 show Q by (rule 2) |
|
820 |
qed |
|
821 |
||
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
822 |
lemma notE': |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
823 |
assumes 1: "~ P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
824 |
and 2: "~ P ==> P" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
825 |
shows R |
12386 | 826 |
proof - |
827 |
from 2 and 1 have P . |
|
828 |
with 1 show R by (rule notE) |
|
829 |
qed |
|
830 |
||
15801 | 831 |
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE |
832 |
and [Pure.intro!] = iffI conjI impI TrueI notI allI refl |
|
833 |
and [Pure.elim 2] = allE notE' impE' |
|
834 |
and [Pure.intro] = exI disjI2 disjI1 |
|
12386 | 835 |
|
836 |
lemmas [trans] = trans |
|
837 |
and [sym] = sym not_sym |
|
15801 | 838 |
and [Pure.elim?] = iffD1 iffD2 impE |
11750 | 839 |
|
11438
3d9222b80989
declare trans [trans] (*overridden in theory Calculation*);
wenzelm
parents:
11432
diff
changeset
|
840 |
|
11750 | 841 |
subsubsection {* Atomizing meta-level connectives *} |
842 |
||
843 |
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)" |
|
12003 | 844 |
proof |
9488 | 845 |
assume "!!x. P x" |
10383 | 846 |
show "ALL x. P x" by (rule allI) |
9488 | 847 |
next |
848 |
assume "ALL x. P x" |
|
10383 | 849 |
thus "!!x. P x" by (rule allE) |
9488 | 850 |
qed |
851 |
||
11750 | 852 |
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)" |
12003 | 853 |
proof |
9488 | 854 |
assume r: "A ==> B" |
10383 | 855 |
show "A --> B" by (rule impI) (rule r) |
9488 | 856 |
next |
857 |
assume "A --> B" and A |
|
10383 | 858 |
thus B by (rule mp) |
9488 | 859 |
qed |
860 |
||
14749 | 861 |
lemma atomize_not: "(A ==> False) == Trueprop (~A)" |
862 |
proof |
|
863 |
assume r: "A ==> False" |
|
864 |
show "~A" by (rule notI) (rule r) |
|
865 |
next |
|
866 |
assume "~A" and A |
|
867 |
thus False by (rule notE) |
|
868 |
qed |
|
869 |
||
11750 | 870 |
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)" |
12003 | 871 |
proof |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
872 |
assume "x == y" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
873 |
show "x = y" by (unfold prems) (rule refl) |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
874 |
next |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
875 |
assume "x = y" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
876 |
thus "x == y" by (rule eq_reflection) |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
877 |
qed |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
878 |
|
12023 | 879 |
lemma atomize_conj [atomize]: |
880 |
"(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)" |
|
12003 | 881 |
proof |
11953 | 882 |
assume "!!C. (A ==> B ==> PROP C) ==> PROP C" |
883 |
show "A & B" by (rule conjI) |
|
884 |
next |
|
885 |
fix C |
|
886 |
assume "A & B" |
|
887 |
assume "A ==> B ==> PROP C" |
|
888 |
thus "PROP C" |
|
889 |
proof this |
|
890 |
show A by (rule conjunct1) |
|
891 |
show B by (rule conjunct2) |
|
892 |
qed |
|
893 |
qed |
|
894 |
||
12386 | 895 |
lemmas [symmetric, rulify] = atomize_all atomize_imp |
896 |
||
11750 | 897 |
|
898 |
subsubsection {* Classical Reasoner setup *} |
|
9529 | 899 |
|
10383 | 900 |
use "cladata.ML" |
901 |
setup hypsubst_setup |
|
11977 | 902 |
|
16121 | 903 |
setup {* |
904 |
[ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac)] |
|
12386 | 905 |
*} |
11977 | 906 |
|
10383 | 907 |
setup Classical.setup |
908 |
setup clasetup |
|
909 |
||
12386 | 910 |
lemmas [intro?] = ext |
911 |
and [elim?] = ex1_implies_ex |
|
11977 | 912 |
|
9869 | 913 |
use "blastdata.ML" |
914 |
setup Blast.setup |
|
4868 | 915 |
|
11750 | 916 |
|
15481 | 917 |
subsection {* Simplifier setup *} |
11750 | 918 |
|
12281 | 919 |
lemma meta_eq_to_obj_eq: "x == y ==> x = y" |
920 |
proof - |
|
921 |
assume r: "x == y" |
|
922 |
show "x = y" by (unfold r) (rule refl) |
|
923 |
qed |
|
924 |
||
925 |
lemma eta_contract_eq: "(%s. f s) = f" .. |
|
926 |
||
927 |
lemma simp_thms: |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
928 |
shows not_not: "(~ ~ P) = P" |
15354 | 929 |
and Not_eq_iff: "((~P) = (~Q)) = (P = Q)" |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
930 |
and |
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
931 |
"(P ~= Q) = (P = (~Q))" |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
932 |
"(P | ~P) = True" "(~P | P) = True" |
12281 | 933 |
"(x = x) = True" |
934 |
"(~True) = False" "(~False) = True" |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
935 |
"(~P) ~= P" "P ~= (~P)" |
12281 | 936 |
"(True=P) = P" "(P=True) = P" "(False=P) = (~P)" "(P=False) = (~P)" |
937 |
"(True --> P) = P" "(False --> P) = True" |
|
938 |
"(P --> True) = True" "(P --> P) = True" |
|
939 |
"(P --> False) = (~P)" "(P --> ~P) = (~P)" |
|
940 |
"(P & True) = P" "(True & P) = P" |
|
941 |
"(P & False) = False" "(False & P) = False" |
|
942 |
"(P & P) = P" "(P & (P & Q)) = (P & Q)" |
|
943 |
"(P & ~P) = False" "(~P & P) = False" |
|
944 |
"(P | True) = True" "(True | P) = True" |
|
945 |
"(P | False) = P" "(False | P) = P" |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
946 |
"(P | P) = P" "(P | (P | Q)) = (P | Q)" and |
12281 | 947 |
"(ALL x. P) = P" "(EX x. P) = P" "EX x. x=t" "EX x. t=x" |
948 |
-- {* needed for the one-point-rule quantifier simplification procs *} |
|
949 |
-- {* essential for termination!! *} and |
|
950 |
"!!P. (EX x. x=t & P(x)) = P(t)" |
|
951 |
"!!P. (EX x. t=x & P(x)) = P(t)" |
|
952 |
"!!P. (ALL x. x=t --> P(x)) = P(t)" |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
953 |
"!!P. (ALL x. t=x --> P(x)) = P(t)" |
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
954 |
by (blast, blast, blast, blast, blast, rules+) |
13421 | 955 |
|
12281 | 956 |
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))" |
12354 | 957 |
by rules |
12281 | 958 |
|
959 |
lemma ex_simps: |
|
960 |
"!!P Q. (EX x. P x & Q) = ((EX x. P x) & Q)" |
|
961 |
"!!P Q. (EX x. P & Q x) = (P & (EX x. Q x))" |
|
962 |
"!!P Q. (EX x. P x | Q) = ((EX x. P x) | Q)" |
|
963 |
"!!P Q. (EX x. P | Q x) = (P | (EX x. Q x))" |
|
964 |
"!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)" |
|
965 |
"!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))" |
|
966 |
-- {* Miniscoping: pushing in existential quantifiers. *} |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
967 |
by (rules | blast)+ |
12281 | 968 |
|
969 |
lemma all_simps: |
|
970 |
"!!P Q. (ALL x. P x & Q) = ((ALL x. P x) & Q)" |
|
971 |
"!!P Q. (ALL x. P & Q x) = (P & (ALL x. Q x))" |
|
972 |
"!!P Q. (ALL x. P x | Q) = ((ALL x. P x) | Q)" |
|
973 |
"!!P Q. (ALL x. P | Q x) = (P | (ALL x. Q x))" |
|
974 |
"!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)" |
|
975 |
"!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))" |
|
976 |
-- {* Miniscoping: pushing in universal quantifiers. *} |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
977 |
by (rules | blast)+ |
12281 | 978 |
|
14201 | 979 |
lemma disj_absorb: "(A | A) = A" |
980 |
by blast |
|
981 |
||
982 |
lemma disj_left_absorb: "(A | (A | B)) = (A | B)" |
|
983 |
by blast |
|
984 |
||
985 |
lemma conj_absorb: "(A & A) = A" |
|
986 |
by blast |
|
987 |
||
988 |
lemma conj_left_absorb: "(A & (A & B)) = (A & B)" |
|
989 |
by blast |
|
990 |
||
12281 | 991 |
lemma eq_ac: |
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
992 |
shows eq_commute: "(a=b) = (b=a)" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
993 |
and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
994 |
and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (rules, blast+) |
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
995 |
lemma neq_commute: "(a~=b) = (b~=a)" by rules |
12281 | 996 |
|
997 |
lemma conj_comms: |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
998 |
shows conj_commute: "(P&Q) = (Q&P)" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
999 |
and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by rules+ |
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1000 |
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by rules |
12281 | 1001 |
|
1002 |
lemma disj_comms: |
|
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1003 |
shows disj_commute: "(P|Q) = (Q|P)" |
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset
|
1004 |
and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by rules+ |
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1005 |
lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by rules |
12281 | 1006 |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1007 |
lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by rules |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1008 |
lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by rules |
12281 | 1009 |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1010 |
lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by rules |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1011 |
lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by rules |
12281 | 1012 |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1013 |
lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by rules |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1014 |
lemma imp_conjL: "((P&Q) -->R) = (P --> (Q --> R))" by rules |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1015 |
lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by rules |
12281 | 1016 |
|
1017 |
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *} |
|
1018 |
lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast |
|
1019 |
lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast |
|
1020 |
||
1021 |
lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast |
|
1022 |
lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast |
|
1023 |
||
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1024 |
lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by rules |
12281 | 1025 |
lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast |
1026 |
lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast |
|
1027 |
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast |
|
1028 |
lemma disj_not1: "(~P | Q) = (P --> Q)" by blast |
|
1029 |
lemma disj_not2: "(P | ~Q) = (Q --> P)" -- {* changes orientation :-( *} |
|
1030 |
by blast |
|
1031 |
lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast |
|
1032 |
||
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1033 |
lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by rules |
12281 | 1034 |
|
1035 |
||
1036 |
lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q" |
|
1037 |
-- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *} |
|
1038 |
-- {* cases boil down to the same thing. *} |
|
1039 |
by blast |
|
1040 |
||
1041 |
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast |
|
1042 |
lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1043 |
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by rules |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1044 |
lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by rules |
12281 | 1045 |
|
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1046 |
lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by rules |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1047 |
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by rules |
12281 | 1048 |
|
1049 |
text {* |
|
1050 |
\medskip The @{text "&"} congruence rule: not included by default! |
|
1051 |
May slow rewrite proofs down by as much as 50\% *} |
|
1052 |
||
1053 |
lemma conj_cong: |
|
1054 |
"(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))" |
|
12354 | 1055 |
by rules |
12281 | 1056 |
|
1057 |
lemma rev_conj_cong: |
|
1058 |
"(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))" |
|
12354 | 1059 |
by rules |
12281 | 1060 |
|
1061 |
text {* The @{text "|"} congruence rule: not included by default! *} |
|
1062 |
||
1063 |
lemma disj_cong: |
|
1064 |
"(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))" |
|
1065 |
by blast |
|
1066 |
||
1067 |
lemma eq_sym_conv: "(x = y) = (y = x)" |
|
12354 | 1068 |
by rules |
12281 | 1069 |
|
1070 |
||
1071 |
text {* \medskip if-then-else rules *} |
|
1072 |
||
1073 |
lemma if_True: "(if True then x else y) = x" |
|
1074 |
by (unfold if_def) blast |
|
1075 |
||
1076 |
lemma if_False: "(if False then x else y) = y" |
|
1077 |
by (unfold if_def) blast |
|
1078 |
||
1079 |
lemma if_P: "P ==> (if P then x else y) = x" |
|
1080 |
by (unfold if_def) blast |
|
1081 |
||
1082 |
lemma if_not_P: "~P ==> (if P then x else y) = y" |
|
1083 |
by (unfold if_def) blast |
|
1084 |
||
1085 |
lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))" |
|
1086 |
apply (rule case_split [of Q]) |
|
15481 | 1087 |
apply (simplesubst if_P) |
1088 |
prefer 3 apply (simplesubst if_not_P, blast+) |
|
12281 | 1089 |
done |
1090 |
||
1091 |
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))" |
|
15481 | 1092 |
by (simplesubst split_if, blast) |
12281 | 1093 |
|
1094 |
lemmas if_splits = split_if split_if_asm |
|
1095 |
||
1096 |
lemma if_def2: "(if Q then x else y) = ((Q --> x) & (~ Q --> y))" |
|
1097 |
by (rule split_if) |
|
1098 |
||
1099 |
lemma if_cancel: "(if c then x else x) = x" |
|
15481 | 1100 |
by (simplesubst split_if, blast) |
12281 | 1101 |
|
1102 |
lemma if_eq_cancel: "(if x = y then y else x) = x" |
|
15481 | 1103 |
by (simplesubst split_if, blast) |
12281 | 1104 |
|
1105 |
lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))" |
|
1106 |
-- {* This form is useful for expanding @{text if}s on the RIGHT of the @{text "==>"} symbol. *} |
|
1107 |
by (rule split_if) |
|
1108 |
||
1109 |
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))" |
|
1110 |
-- {* And this form is useful for expanding @{text if}s on the LEFT. *} |
|
15481 | 1111 |
apply (simplesubst split_if, blast) |
12281 | 1112 |
done |
1113 |
||
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1114 |
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) rules |
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset
|
1115 |
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) rules |
12281 | 1116 |
|
15423 | 1117 |
text {* \medskip let rules for simproc *} |
1118 |
||
1119 |
lemma Let_folded: "f x \<equiv> g x \<Longrightarrow> Let x f \<equiv> Let x g" |
|
1120 |
by (unfold Let_def) |
|
1121 |
||
1122 |
lemma Let_unfold: "f x \<equiv> g \<Longrightarrow> Let x f \<equiv> g" |
|
1123 |
by (unfold Let_def) |
|
1124 |
||
14201 | 1125 |
subsubsection {* Actual Installation of the Simplifier *} |
1126 |
||
9869 | 1127 |
use "simpdata.ML" |
1128 |
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup |
|
1129 |
setup Splitter.setup setup Clasimp.setup |
|
1130 |
||
15481 | 1131 |
|
1132 |
subsubsection {* Lucas Dixon's eqstep tactic *} |
|
1133 |
||
1134 |
use "~~/src/Provers/eqsubst.ML"; |
|
1135 |
use "eqrule_HOL_data.ML"; |
|
1136 |
||
1137 |
setup EQSubstTac.setup |
|
1138 |
||
1139 |
||
1140 |
subsection {* Other simple lemmas *} |
|
1141 |
||
15411 | 1142 |
declare disj_absorb [simp] conj_absorb [simp] |
14201 | 1143 |
|
13723 | 1144 |
lemma ex1_eq[iff]: "EX! x. x = t" "EX! x. t = x" |
1145 |
by blast+ |
|
1146 |
||
15481 | 1147 |
|
13638 | 1148 |
theorem choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))" |
1149 |
apply (rule iffI) |
|
1150 |
apply (rule_tac a = "%x. THE y. P x y" in ex1I) |
|
1151 |
apply (fast dest!: theI') |
|
1152 |
apply (fast intro: ext the1_equality [symmetric]) |
|
1153 |
apply (erule ex1E) |
|
1154 |
apply (rule allI) |
|
1155 |
apply (rule ex1I) |
|
1156 |
apply (erule spec) |
|
1157 |
apply (erule_tac x = "%z. if z = x then y else f z" in allE) |
|
1158 |
apply (erule impE) |
|
1159 |
apply (rule allI) |
|
1160 |
apply (rule_tac P = "xa = x" in case_split_thm) |
|
14208 | 1161 |
apply (drule_tac [3] x = x in fun_cong, simp_all) |
13638 | 1162 |
done |
1163 |
||
13438
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset
|
1164 |
text{*Needs only HOL-lemmas:*} |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset
|
1165 |
lemma mk_left_commute: |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset
|
1166 |
assumes a: "\<And>x y z. f (f x y) z = f x (f y z)" and |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset
|
1167 |
c: "\<And>x y. f x y = f y x" |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset
|
1168 |
shows "f x (f y z) = f y (f x z)" |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset
|
1169 |
by(rule trans[OF trans[OF c a] arg_cong[OF c, of "f y"]]) |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset
|
1170 |
|
11750 | 1171 |
|
15481 | 1172 |
subsection {* Generic cases and induction *} |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1173 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1174 |
constdefs |
11989 | 1175 |
induct_forall :: "('a => bool) => bool" |
1176 |
"induct_forall P == \<forall>x. P x" |
|
1177 |
induct_implies :: "bool => bool => bool" |
|
1178 |
"induct_implies A B == A --> B" |
|
1179 |
induct_equal :: "'a => 'a => bool" |
|
1180 |
"induct_equal x y == x = y" |
|
1181 |
induct_conj :: "bool => bool => bool" |
|
1182 |
"induct_conj A B == A & B" |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1183 |
|
11989 | 1184 |
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))" |
1185 |
by (simp only: atomize_all induct_forall_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1186 |
|
11989 | 1187 |
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)" |
1188 |
by (simp only: atomize_imp induct_implies_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1189 |
|
11989 | 1190 |
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)" |
1191 |
by (simp only: atomize_eq induct_equal_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1192 |
|
11989 | 1193 |
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) = |
1194 |
induct_conj (induct_forall A) (induct_forall B)" |
|
12354 | 1195 |
by (unfold induct_forall_def induct_conj_def) rules |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1196 |
|
11989 | 1197 |
lemma induct_implies_conj: "induct_implies C (induct_conj A B) = |
1198 |
induct_conj (induct_implies C A) (induct_implies C B)" |
|
12354 | 1199 |
by (unfold induct_implies_def induct_conj_def) rules |
11989 | 1200 |
|
13598
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1201 |
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
|
1202 |
proof |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1203 |
assume r: "induct_conj A B ==> PROP C" and A B |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1204 |
show "PROP C" by (rule r) (simp! add: induct_conj_def) |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1205 |
next |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1206 |
assume r: "A ==> B ==> PROP C" and "induct_conj A B" |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1207 |
show "PROP C" by (rule r) (simp! add: induct_conj_def)+ |
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset
|
1208 |
qed |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1209 |
|
11989 | 1210 |
lemma induct_impliesI: "(A ==> B) ==> induct_implies A B" |
1211 |
by (simp add: induct_implies_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1212 |
|
12161 | 1213 |
lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq |
1214 |
lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq |
|
1215 |
lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def |
|
11989 | 1216 |
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
|
1217 |
|
11989 | 1218 |
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
|
1219 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1220 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1221 |
text {* Method setup. *} |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1222 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1223 |
ML {* |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1224 |
structure InductMethod = InductMethodFun |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1225 |
(struct |
15411 | 1226 |
val dest_concls = HOLogic.dest_concls |
1227 |
val cases_default = thm "case_split" |
|
1228 |
val local_impI = thm "induct_impliesI" |
|
1229 |
val conjI = thm "conjI" |
|
1230 |
val atomize = thms "induct_atomize" |
|
1231 |
val rulify1 = thms "induct_rulify1" |
|
1232 |
val rulify2 = thms "induct_rulify2" |
|
1233 |
val localize = [Thm.symmetric (thm "induct_implies_def")] |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1234 |
end); |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1235 |
*} |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1236 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1237 |
setup InductMethod.setup |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1238 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
1239 |
|
14357 | 1240 |
end |
15411 | 1241 |