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