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