author | wenzelm |
Tue, 04 Dec 2001 02:01:13 +0100 | |
changeset 12354 | 5f5ee25513c5 |
parent 12338 | de0f4a63baa5 |
child 12386 | 9c38ec9eca1c |
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 |
|
7357 | 8 |
theory HOL = CPure |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
9 |
files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML"): |
923 | 10 |
|
2260 | 11 |
|
11750 | 12 |
subsection {* Primitive logic *} |
13 |
||
14 |
subsubsection {* Core syntax *} |
|
2260 | 15 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
16 |
classes type < logic |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
17 |
defaultsort type |
3947 | 18 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
19 |
global |
923 | 20 |
|
7357 | 21 |
typedecl bool |
923 | 22 |
|
23 |
arities |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
24 |
bool :: type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
25 |
fun :: (type, type) type |
923 | 26 |
|
11750 | 27 |
judgment |
28 |
Trueprop :: "bool => prop" ("(_)" 5) |
|
923 | 29 |
|
11750 | 30 |
consts |
7357 | 31 |
Not :: "bool => bool" ("~ _" [40] 40) |
32 |
True :: bool |
|
33 |
False :: bool |
|
34 |
If :: "[bool, 'a, 'a] => 'a" ("(if (_)/ then (_)/ else (_))" 10) |
|
3947 | 35 |
arbitrary :: 'a |
923 | 36 |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
37 |
The :: "('a => bool) => 'a" |
7357 | 38 |
All :: "('a => bool) => bool" (binder "ALL " 10) |
39 |
Ex :: "('a => bool) => bool" (binder "EX " 10) |
|
40 |
Ex1 :: "('a => bool) => bool" (binder "EX! " 10) |
|
41 |
Let :: "['a, 'a => 'b] => 'b" |
|
923 | 42 |
|
7357 | 43 |
"=" :: "['a, 'a] => bool" (infixl 50) |
44 |
& :: "[bool, bool] => bool" (infixr 35) |
|
45 |
"|" :: "[bool, bool] => bool" (infixr 30) |
|
46 |
--> :: "[bool, bool] => bool" (infixr 25) |
|
923 | 47 |
|
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
48 |
local |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
49 |
|
2260 | 50 |
|
11750 | 51 |
subsubsection {* Additional concrete syntax *} |
2260 | 52 |
|
4868 | 53 |
nonterminals |
923 | 54 |
letbinds letbind |
55 |
case_syn cases_syn |
|
56 |
||
57 |
syntax |
|
7357 | 58 |
~= :: "['a, 'a] => bool" (infixl 50) |
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
59 |
"_The" :: "[pttrn, bool] => 'a" ("(3THE _./ _)" [0, 10] 10) |
923 | 60 |
|
7357 | 61 |
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) |
62 |
"" :: "letbind => letbinds" ("_") |
|
63 |
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") |
|
64 |
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) |
|
923 | 65 |
|
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
66 |
"_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
|
67 |
"_case1" :: "['a, 'b] => case_syn" ("(2_ =>/ _)" 10) |
7357 | 68 |
"" :: "case_syn => cases_syn" ("_") |
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
69 |
"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ | _") |
923 | 70 |
|
71 |
translations |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
72 |
"x ~= y" == "~ (x = y)" |
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
73 |
"THE x. P" == "The (%x. P)" |
923 | 74 |
"_Let (_binds b bs) e" == "_Let b (_Let bs e)" |
1114 | 75 |
"let x = a in e" == "Let a (%x. e)" |
923 | 76 |
|
3820 | 77 |
syntax ("" output) |
11687 | 78 |
"=" :: "['a, 'a] => bool" (infix 50) |
79 |
"~=" :: "['a, 'a] => bool" (infix 50) |
|
2260 | 80 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
81 |
syntax (xsymbols) |
11687 | 82 |
Not :: "bool => bool" ("\<not> _" [40] 40) |
83 |
"op &" :: "[bool, bool] => bool" (infixr "\<and>" 35) |
|
84 |
"op |" :: "[bool, bool] => bool" (infixr "\<or>" 30) |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
85 |
"op -->" :: "[bool, bool] => bool" (infixr "\<longrightarrow>" 25) |
11687 | 86 |
"op ~=" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
87 |
"ALL " :: "[idts, bool] => bool" ("(3\<forall>_./ _)" [0, 10] 10) |
|
88 |
"EX " :: "[idts, bool] => bool" ("(3\<exists>_./ _)" [0, 10] 10) |
|
89 |
"EX! " :: "[idts, bool] => bool" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
90 |
"_case1" :: "['a, 'b] => case_syn" ("(2_ \<Rightarrow>/ _)" 10) |
|
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
91 |
(*"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ \\<orelse> _")*) |
2372 | 92 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
93 |
syntax (xsymbols output) |
11687 | 94 |
"op ~=" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
3820 | 95 |
|
6340 | 96 |
syntax (HTML output) |
11687 | 97 |
Not :: "bool => bool" ("\<not> _" [40] 40) |
6340 | 98 |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
99 |
syntax (HOL) |
7357 | 100 |
"ALL " :: "[idts, bool] => bool" ("(3! _./ _)" [0, 10] 10) |
101 |
"EX " :: "[idts, bool] => bool" ("(3? _./ _)" [0, 10] 10) |
|
102 |
"EX! " :: "[idts, bool] => bool" ("(3?! _./ _)" [0, 10] 10) |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
103 |
|
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
104 |
|
11750 | 105 |
subsubsection {* Axioms and basic definitions *} |
2260 | 106 |
|
7357 | 107 |
axioms |
108 |
eq_reflection: "(x=y) ==> (x==y)" |
|
923 | 109 |
|
7357 | 110 |
refl: "t = (t::'a)" |
111 |
subst: "[| s = t; P(s) |] ==> P(t::'a)" |
|
6289 | 112 |
|
7357 | 113 |
ext: "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" |
11750 | 114 |
-- {* Extensionality is built into the meta-logic, and this rule expresses *} |
115 |
-- {* a related property. It is an eta-expanded version of the traditional *} |
|
116 |
-- {* rule, and similar to the ABS rule of HOL *} |
|
6289 | 117 |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
118 |
the_eq_trivial: "(THE x. x = a) = (a::'a)" |
923 | 119 |
|
7357 | 120 |
impI: "(P ==> Q) ==> P-->Q" |
121 |
mp: "[| P-->Q; P |] ==> Q" |
|
923 | 122 |
|
123 |
defs |
|
7357 | 124 |
True_def: "True == ((%x::bool. x) = (%x. x))" |
125 |
All_def: "All(P) == (P = (%x. True))" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
126 |
Ex_def: "Ex(P) == !Q. (!x. P x --> Q) --> Q" |
7357 | 127 |
False_def: "False == (!P. P)" |
128 |
not_def: "~ P == P-->False" |
|
129 |
and_def: "P & Q == !R. (P-->Q-->R) --> R" |
|
130 |
or_def: "P | Q == !R. (P-->R) --> (Q-->R) --> R" |
|
131 |
Ex1_def: "Ex1(P) == ? x. P(x) & (! y. P(y) --> y=x)" |
|
923 | 132 |
|
7357 | 133 |
axioms |
134 |
iff: "(P-->Q) --> (Q-->P) --> (P=Q)" |
|
135 |
True_or_False: "(P=True) | (P=False)" |
|
923 | 136 |
|
137 |
defs |
|
7357 | 138 |
Let_def: "Let s f == f(s)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
139 |
if_def: "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)" |
5069 | 140 |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
141 |
arbitrary_def: "False ==> arbitrary == (THE x. False)" |
11750 | 142 |
-- {* @{term arbitrary} is completely unspecified, but is made to appear as a |
143 |
definition syntactically *} |
|
923 | 144 |
|
3320 | 145 |
|
11750 | 146 |
subsubsection {* Generic algebraic operations *} |
4868 | 147 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
148 |
axclass zero < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
149 |
axclass one < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
150 |
axclass plus < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
151 |
axclass minus < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
152 |
axclass times < type |
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
153 |
axclass inverse < type |
11750 | 154 |
|
155 |
global |
|
156 |
||
157 |
consts |
|
158 |
"0" :: "'a::zero" ("0") |
|
159 |
"1" :: "'a::one" ("1") |
|
160 |
"+" :: "['a::plus, 'a] => 'a" (infixl 65) |
|
161 |
- :: "['a::minus, 'a] => 'a" (infixl 65) |
|
162 |
uminus :: "['a::minus] => 'a" ("- _" [81] 80) |
|
163 |
* :: "['a::times, 'a] => 'a" (infixl 70) |
|
164 |
||
165 |
local |
|
166 |
||
167 |
typed_print_translation {* |
|
168 |
let |
|
169 |
fun tr' c = (c, fn show_sorts => fn T => fn ts => |
|
170 |
if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match |
|
171 |
else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T); |
|
172 |
in [tr' "0", tr' "1"] end; |
|
173 |
*} -- {* show types that are presumably too general *} |
|
174 |
||
175 |
||
176 |
consts |
|
177 |
abs :: "'a::minus => 'a" |
|
178 |
inverse :: "'a::inverse => 'a" |
|
179 |
divide :: "['a::inverse, 'a] => 'a" (infixl "'/" 70) |
|
180 |
||
181 |
syntax (xsymbols) |
|
182 |
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") |
|
183 |
syntax (HTML output) |
|
184 |
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") |
|
185 |
||
186 |
axclass plus_ac0 < plus, zero |
|
187 |
commute: "x + y = y + x" |
|
188 |
assoc: "(x + y) + z = x + (y + z)" |
|
189 |
zero: "0 + x = x" |
|
190 |
||
191 |
||
192 |
subsection {* Theory and package setup *} |
|
193 |
||
194 |
subsubsection {* Basic lemmas *} |
|
4868 | 195 |
|
9736 | 196 |
use "HOL_lemmas.ML" |
11687 | 197 |
theorems case_split = case_split_thm [case_names True False] |
9869 | 198 |
|
11750 | 199 |
declare trans [trans] |
200 |
declare impE [CPure.elim] iffD1 [CPure.elim] iffD2 [CPure.elim] |
|
201 |
||
11438
3d9222b80989
declare trans [trans] (*overridden in theory Calculation*);
wenzelm
parents:
11432
diff
changeset
|
202 |
|
11750 | 203 |
subsubsection {* Atomizing meta-level connectives *} |
204 |
||
205 |
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)" |
|
12003 | 206 |
proof |
9488 | 207 |
assume "!!x. P x" |
10383 | 208 |
show "ALL x. P x" by (rule allI) |
9488 | 209 |
next |
210 |
assume "ALL x. P x" |
|
10383 | 211 |
thus "!!x. P x" by (rule allE) |
9488 | 212 |
qed |
213 |
||
11750 | 214 |
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)" |
12003 | 215 |
proof |
9488 | 216 |
assume r: "A ==> B" |
10383 | 217 |
show "A --> B" by (rule impI) (rule r) |
9488 | 218 |
next |
219 |
assume "A --> B" and A |
|
10383 | 220 |
thus B by (rule mp) |
9488 | 221 |
qed |
222 |
||
11750 | 223 |
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)" |
12003 | 224 |
proof |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
225 |
assume "x == y" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
226 |
show "x = y" by (unfold prems) (rule refl) |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
227 |
next |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
228 |
assume "x = y" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
229 |
thus "x == y" by (rule eq_reflection) |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
230 |
qed |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
231 |
|
12023 | 232 |
lemma atomize_conj [atomize]: |
233 |
"(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)" |
|
12003 | 234 |
proof |
11953 | 235 |
assume "!!C. (A ==> B ==> PROP C) ==> PROP C" |
236 |
show "A & B" by (rule conjI) |
|
237 |
next |
|
238 |
fix C |
|
239 |
assume "A & B" |
|
240 |
assume "A ==> B ==> PROP C" |
|
241 |
thus "PROP C" |
|
242 |
proof this |
|
243 |
show A by (rule conjunct1) |
|
244 |
show B by (rule conjunct2) |
|
245 |
qed |
|
246 |
qed |
|
247 |
||
11750 | 248 |
|
249 |
subsubsection {* Classical Reasoner setup *} |
|
9529 | 250 |
|
10383 | 251 |
use "cladata.ML" |
252 |
setup hypsubst_setup |
|
11977 | 253 |
|
11770 | 254 |
declare atomize_all [symmetric, rulify] atomize_imp [symmetric, rulify] |
11977 | 255 |
|
10383 | 256 |
setup Classical.setup |
257 |
setup clasetup |
|
258 |
||
11977 | 259 |
declare ext [intro?] |
260 |
declare disjI1 [elim?] disjI2 [elim?] ex1_implies_ex [elim?] sym [elim?] |
|
261 |
||
9869 | 262 |
use "blastdata.ML" |
263 |
setup Blast.setup |
|
4868 | 264 |
|
11750 | 265 |
|
12354 | 266 |
subsubsection {* Intuitionistic Reasoning *} |
267 |
||
268 |
lemma impE': |
|
269 |
(assumes 1: "P --> Q" and 2: "Q ==> R" and 3: "P --> Q ==> P") R |
|
270 |
proof - |
|
271 |
from 3 and 1 have P . |
|
272 |
with 1 have Q .. |
|
273 |
with 2 show R . |
|
274 |
qed |
|
275 |
||
276 |
lemma allE': |
|
277 |
(assumes 1: "ALL x. P x" and 2: "P x ==> ALL x. P x ==> Q") Q |
|
278 |
proof - |
|
279 |
from 1 have "P x" .. |
|
280 |
from this and 1 show Q by (rule 2) |
|
281 |
qed |
|
282 |
||
283 |
lemma notE': (assumes 1: "~ P" and 2: "~ P ==> P") R |
|
284 |
proof - |
|
285 |
from 2 and 1 have P . |
|
286 |
with 1 show R by (rule notE) |
|
287 |
qed |
|
288 |
||
289 |
lemmas [CPure.elim!] = disjE iffE FalseE conjE exE |
|
290 |
and [CPure.intro!] = iffI conjI impI TrueI notI allI refl |
|
291 |
and [CPure.elim 2] = allE notE' impE' |
|
292 |
and [CPure.intro] = exI disjI2 disjI1 |
|
293 |
||
294 |
ML_setup {* |
|
295 |
Context.>> (ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac)); |
|
296 |
*} |
|
297 |
||
298 |
||
11750 | 299 |
subsubsection {* Simplifier setup *} |
300 |
||
12281 | 301 |
lemma meta_eq_to_obj_eq: "x == y ==> x = y" |
302 |
proof - |
|
303 |
assume r: "x == y" |
|
304 |
show "x = y" by (unfold r) (rule refl) |
|
305 |
qed |
|
306 |
||
307 |
lemma eta_contract_eq: "(%s. f s) = f" .. |
|
308 |
||
309 |
lemma simp_thms: |
|
310 |
(not_not: "(~ ~ P) = P" and |
|
311 |
"(x = x) = True" |
|
312 |
"(~True) = False" "(~False) = True" |
|
313 |
"(~P) ~= P" "P ~= (~P)" "(P ~= Q) = (P = (~Q))" |
|
314 |
"(True=P) = P" "(P=True) = P" "(False=P) = (~P)" "(P=False) = (~P)" |
|
315 |
"(True --> P) = P" "(False --> P) = True" |
|
316 |
"(P --> True) = True" "(P --> P) = True" |
|
317 |
"(P --> False) = (~P)" "(P --> ~P) = (~P)" |
|
318 |
"(P & True) = P" "(True & P) = P" |
|
319 |
"(P & False) = False" "(False & P) = False" |
|
320 |
"(P & P) = P" "(P & (P & Q)) = (P & Q)" |
|
321 |
"(P & ~P) = False" "(~P & P) = False" |
|
322 |
"(P | True) = True" "(True | P) = True" |
|
323 |
"(P | False) = P" "(False | P) = P" |
|
324 |
"(P | P) = P" "(P | (P | Q)) = (P | Q)" |
|
325 |
"(P | ~P) = True" "(~P | P) = True" |
|
326 |
"((~P) = (~Q)) = (P=Q)" and |
|
327 |
"(ALL x. P) = P" "(EX x. P) = P" "EX x. x=t" "EX x. t=x" |
|
328 |
-- {* needed for the one-point-rule quantifier simplification procs *} |
|
329 |
-- {* essential for termination!! *} and |
|
330 |
"!!P. (EX x. x=t & P(x)) = P(t)" |
|
331 |
"!!P. (EX x. t=x & P(x)) = P(t)" |
|
332 |
"!!P. (ALL x. x=t --> P(x)) = P(t)" |
|
333 |
"!!P. (ALL x. t=x --> P(x)) = P(t)") |
|
334 |
by blast+ |
|
335 |
||
336 |
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))" |
|
12354 | 337 |
by rules |
12281 | 338 |
|
339 |
lemma ex_simps: |
|
340 |
"!!P Q. (EX x. P x & Q) = ((EX x. P x) & Q)" |
|
341 |
"!!P Q. (EX x. P & Q x) = (P & (EX x. Q x))" |
|
342 |
"!!P Q. (EX x. P x | Q) = ((EX x. P x) | Q)" |
|
343 |
"!!P Q. (EX x. P | Q x) = (P | (EX x. Q x))" |
|
344 |
"!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)" |
|
345 |
"!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))" |
|
346 |
-- {* Miniscoping: pushing in existential quantifiers. *} |
|
347 |
by blast+ |
|
348 |
||
349 |
lemma all_simps: |
|
350 |
"!!P Q. (ALL x. P x & Q) = ((ALL x. P x) & Q)" |
|
351 |
"!!P Q. (ALL x. P & Q x) = (P & (ALL x. Q x))" |
|
352 |
"!!P Q. (ALL x. P x | Q) = ((ALL x. P x) | Q)" |
|
353 |
"!!P Q. (ALL x. P | Q x) = (P | (ALL x. Q x))" |
|
354 |
"!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)" |
|
355 |
"!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))" |
|
356 |
-- {* Miniscoping: pushing in universal quantifiers. *} |
|
357 |
by blast+ |
|
358 |
||
359 |
lemma eq_ac: |
|
360 |
(eq_commute: "(a=b) = (b=a)" and |
|
361 |
eq_left_commute: "(P=(Q=R)) = (Q=(P=R))" and |
|
362 |
eq_assoc: "((P=Q)=R) = (P=(Q=R))") by blast+ |
|
363 |
lemma neq_commute: "(a~=b) = (b~=a)" by blast |
|
364 |
||
365 |
lemma conj_comms: |
|
366 |
(conj_commute: "(P&Q) = (Q&P)" and |
|
367 |
conj_left_commute: "(P&(Q&R)) = (Q&(P&R))") by blast+ |
|
368 |
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by blast |
|
369 |
||
370 |
lemma disj_comms: |
|
371 |
(disj_commute: "(P|Q) = (Q|P)" and |
|
372 |
disj_left_commute: "(P|(Q|R)) = (Q|(P|R))") by blast+ |
|
373 |
lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by blast |
|
374 |
||
375 |
lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by blast |
|
376 |
lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by blast |
|
377 |
||
378 |
lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by blast |
|
379 |
lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by blast |
|
380 |
||
381 |
lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by blast |
|
382 |
lemma imp_conjL: "((P&Q) -->R) = (P --> (Q --> R))" by blast |
|
383 |
lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by blast |
|
384 |
||
385 |
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *} |
|
386 |
lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast |
|
387 |
lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast |
|
388 |
||
389 |
lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast |
|
390 |
lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast |
|
391 |
||
392 |
lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by blast |
|
393 |
lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast |
|
394 |
lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast |
|
395 |
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast |
|
396 |
lemma disj_not1: "(~P | Q) = (P --> Q)" by blast |
|
397 |
lemma disj_not2: "(P | ~Q) = (Q --> P)" -- {* changes orientation :-( *} |
|
398 |
by blast |
|
399 |
lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast |
|
400 |
||
401 |
lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by blast |
|
402 |
||
403 |
||
404 |
lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q" |
|
405 |
-- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *} |
|
406 |
-- {* cases boil down to the same thing. *} |
|
407 |
by blast |
|
408 |
||
409 |
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast |
|
410 |
lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast |
|
411 |
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by blast |
|
412 |
lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by blast |
|
413 |
||
414 |
lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by blast |
|
415 |
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by blast |
|
416 |
||
417 |
text {* |
|
418 |
\medskip The @{text "&"} congruence rule: not included by default! |
|
419 |
May slow rewrite proofs down by as much as 50\% *} |
|
420 |
||
421 |
lemma conj_cong: |
|
422 |
"(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))" |
|
12354 | 423 |
by rules |
12281 | 424 |
|
425 |
lemma rev_conj_cong: |
|
426 |
"(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))" |
|
12354 | 427 |
by rules |
12281 | 428 |
|
429 |
text {* The @{text "|"} congruence rule: not included by default! *} |
|
430 |
||
431 |
lemma disj_cong: |
|
432 |
"(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))" |
|
433 |
by blast |
|
434 |
||
435 |
lemma eq_sym_conv: "(x = y) = (y = x)" |
|
12354 | 436 |
by rules |
12281 | 437 |
|
438 |
||
439 |
text {* \medskip if-then-else rules *} |
|
440 |
||
441 |
lemma if_True: "(if True then x else y) = x" |
|
442 |
by (unfold if_def) blast |
|
443 |
||
444 |
lemma if_False: "(if False then x else y) = y" |
|
445 |
by (unfold if_def) blast |
|
446 |
||
447 |
lemma if_P: "P ==> (if P then x else y) = x" |
|
448 |
by (unfold if_def) blast |
|
449 |
||
450 |
lemma if_not_P: "~P ==> (if P then x else y) = y" |
|
451 |
by (unfold if_def) blast |
|
452 |
||
453 |
lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))" |
|
454 |
apply (rule case_split [of Q]) |
|
455 |
apply (subst if_P) |
|
456 |
prefer 3 apply (subst if_not_P) |
|
457 |
apply blast+ |
|
458 |
done |
|
459 |
||
460 |
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))" |
|
461 |
apply (subst split_if) |
|
462 |
apply blast |
|
463 |
done |
|
464 |
||
465 |
lemmas if_splits = split_if split_if_asm |
|
466 |
||
467 |
lemma if_def2: "(if Q then x else y) = ((Q --> x) & (~ Q --> y))" |
|
468 |
by (rule split_if) |
|
469 |
||
470 |
lemma if_cancel: "(if c then x else x) = x" |
|
471 |
apply (subst split_if) |
|
472 |
apply blast |
|
473 |
done |
|
474 |
||
475 |
lemma if_eq_cancel: "(if x = y then y else x) = x" |
|
476 |
apply (subst split_if) |
|
477 |
apply blast |
|
478 |
done |
|
479 |
||
480 |
lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))" |
|
481 |
-- {* This form is useful for expanding @{text if}s on the RIGHT of the @{text "==>"} symbol. *} |
|
482 |
by (rule split_if) |
|
483 |
||
484 |
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))" |
|
485 |
-- {* And this form is useful for expanding @{text if}s on the LEFT. *} |
|
486 |
apply (subst split_if) |
|
487 |
apply blast |
|
488 |
done |
|
489 |
||
490 |
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) blast |
|
491 |
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) blast |
|
492 |
||
9869 | 493 |
use "simpdata.ML" |
494 |
setup Simplifier.setup |
|
495 |
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup |
|
496 |
setup Splitter.setup setup Clasimp.setup |
|
497 |
||
11750 | 498 |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
499 |
subsubsection {* Generic cases and induction *} |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
500 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
501 |
constdefs |
11989 | 502 |
induct_forall :: "('a => bool) => bool" |
503 |
"induct_forall P == \<forall>x. P x" |
|
504 |
induct_implies :: "bool => bool => bool" |
|
505 |
"induct_implies A B == A --> B" |
|
506 |
induct_equal :: "'a => 'a => bool" |
|
507 |
"induct_equal x y == x = y" |
|
508 |
induct_conj :: "bool => bool => bool" |
|
509 |
"induct_conj A B == A & B" |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
510 |
|
11989 | 511 |
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))" |
512 |
by (simp only: atomize_all induct_forall_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
513 |
|
11989 | 514 |
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)" |
515 |
by (simp only: atomize_imp induct_implies_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
516 |
|
11989 | 517 |
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)" |
518 |
by (simp only: atomize_eq induct_equal_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
519 |
|
11989 | 520 |
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) = |
521 |
induct_conj (induct_forall A) (induct_forall B)" |
|
12354 | 522 |
by (unfold induct_forall_def induct_conj_def) rules |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
523 |
|
11989 | 524 |
lemma induct_implies_conj: "induct_implies C (induct_conj A B) = |
525 |
induct_conj (induct_implies C A) (induct_implies C B)" |
|
12354 | 526 |
by (unfold induct_implies_def induct_conj_def) rules |
11989 | 527 |
|
528 |
lemma induct_conj_curry: "(induct_conj A B ==> C) == (A ==> B ==> C)" |
|
12354 | 529 |
by (simp only: atomize_imp atomize_eq induct_conj_def) (rules intro: equal_intr_rule) |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
530 |
|
11989 | 531 |
lemma induct_impliesI: "(A ==> B) ==> induct_implies A B" |
532 |
by (simp add: induct_implies_def) |
|
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
533 |
|
12161 | 534 |
lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq |
535 |
lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq |
|
536 |
lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def |
|
11989 | 537 |
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
|
538 |
|
11989 | 539 |
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
|
540 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
541 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
542 |
text {* Method setup. *} |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
543 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
544 |
ML {* |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
545 |
structure InductMethod = InductMethodFun |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
546 |
(struct |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
547 |
val dest_concls = HOLogic.dest_concls; |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
548 |
val cases_default = thm "case_split"; |
11989 | 549 |
val local_impI = thm "induct_impliesI"; |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
550 |
val conjI = thm "conjI"; |
11989 | 551 |
val atomize = thms "induct_atomize"; |
552 |
val rulify1 = thms "induct_rulify1"; |
|
553 |
val rulify2 = thms "induct_rulify2"; |
|
12240 | 554 |
val localize = [Thm.symmetric (thm "induct_implies_def")]; |
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
555 |
end); |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
556 |
*} |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
557 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
558 |
setup InductMethod.setup |
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
559 |
|
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset
|
560 |
|
11750 | 561 |
subsection {* Order signatures and orders *} |
562 |
||
563 |
axclass |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset
|
564 |
ord < type |
11750 | 565 |
|
566 |
syntax |
|
567 |
"op <" :: "['a::ord, 'a] => bool" ("op <") |
|
568 |
"op <=" :: "['a::ord, 'a] => bool" ("op <=") |
|
569 |
||
570 |
global |
|
571 |
||
572 |
consts |
|
573 |
"op <" :: "['a::ord, 'a] => bool" ("(_/ < _)" [50, 51] 50) |
|
574 |
"op <=" :: "['a::ord, 'a] => bool" ("(_/ <= _)" [50, 51] 50) |
|
575 |
||
576 |
local |
|
577 |
||
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
578 |
syntax (xsymbols) |
11750 | 579 |
"op <=" :: "['a::ord, 'a] => bool" ("op \<le>") |
580 |
"op <=" :: "['a::ord, 'a] => bool" ("(_/ \<le> _)" [50, 51] 50) |
|
581 |
||
582 |
(*Tell blast about overloading of < and <= to reduce the risk of |
|
583 |
its applying a rule for the wrong type*) |
|
584 |
ML {* |
|
585 |
Blast.overloaded ("op <" , domain_type); |
|
586 |
Blast.overloaded ("op <=", domain_type); |
|
587 |
*} |
|
588 |
||
589 |
||
590 |
subsubsection {* Monotonicity *} |
|
591 |
||
592 |
constdefs |
|
593 |
mono :: "['a::ord => 'b::ord] => bool" |
|
594 |
"mono f == ALL A B. A <= B --> f A <= f B" |
|
595 |
||
596 |
lemma monoI [intro?]: "(!!A B. A <= B ==> f A <= f B) ==> mono f" |
|
12354 | 597 |
by (unfold mono_def) rules |
11750 | 598 |
|
599 |
lemma monoD [dest?]: "mono f ==> A <= B ==> f A <= f B" |
|
12354 | 600 |
by (unfold mono_def) rules |
11750 | 601 |
|
602 |
constdefs |
|
603 |
min :: "['a::ord, 'a] => 'a" |
|
604 |
"min a b == (if a <= b then a else b)" |
|
605 |
max :: "['a::ord, 'a] => 'a" |
|
606 |
"max a b == (if a <= b then b else a)" |
|
607 |
||
608 |
lemma min_leastL: "(!!x. least <= x) ==> min least x = least" |
|
609 |
by (simp add: min_def) |
|
610 |
||
611 |
lemma min_of_mono: |
|
612 |
"ALL x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)" |
|
613 |
by (simp add: min_def) |
|
614 |
||
615 |
lemma max_leastL: "(!!x. least <= x) ==> max least x = x" |
|
616 |
by (simp add: max_def) |
|
617 |
||
618 |
lemma max_of_mono: |
|
619 |
"ALL x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)" |
|
620 |
by (simp add: max_def) |
|
621 |
||
622 |
||
623 |
subsubsection "Orders" |
|
624 |
||
625 |
axclass order < ord |
|
626 |
order_refl [iff]: "x <= x" |
|
627 |
order_trans: "x <= y ==> y <= z ==> x <= z" |
|
628 |
order_antisym: "x <= y ==> y <= x ==> x = y" |
|
629 |
order_less_le: "(x < y) = (x <= y & x ~= y)" |
|
630 |
||
631 |
||
632 |
text {* Reflexivity. *} |
|
633 |
||
634 |
lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y" |
|
635 |
-- {* This form is useful with the classical reasoner. *} |
|
636 |
apply (erule ssubst) |
|
637 |
apply (rule order_refl) |
|
638 |
done |
|
639 |
||
640 |
lemma order_less_irrefl [simp]: "~ x < (x::'a::order)" |
|
641 |
by (simp add: order_less_le) |
|
642 |
||
643 |
lemma order_le_less: "((x::'a::order) <= y) = (x < y | x = y)" |
|
644 |
-- {* NOT suitable for iff, since it can cause PROOF FAILED. *} |
|
645 |
apply (simp add: order_less_le) |
|
12256 | 646 |
apply blast |
11750 | 647 |
done |
648 |
||
649 |
lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard] |
|
650 |
||
651 |
lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y" |
|
652 |
by (simp add: order_less_le) |
|
653 |
||
654 |
||
655 |
text {* Asymmetry. *} |
|
656 |
||
657 |
lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)" |
|
658 |
by (simp add: order_less_le order_antisym) |
|
659 |
||
660 |
lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P" |
|
661 |
apply (drule order_less_not_sym) |
|
662 |
apply (erule contrapos_np) |
|
663 |
apply simp |
|
664 |
done |
|
665 |
||
666 |
||
667 |
text {* Transitivity. *} |
|
668 |
||
669 |
lemma order_less_trans: "!!x::'a::order. [| x < y; y < z |] ==> x < z" |
|
670 |
apply (simp add: order_less_le) |
|
671 |
apply (blast intro: order_trans order_antisym) |
|
672 |
done |
|
673 |
||
674 |
lemma order_le_less_trans: "!!x::'a::order. [| x <= y; y < z |] ==> x < z" |
|
675 |
apply (simp add: order_less_le) |
|
676 |
apply (blast intro: order_trans order_antisym) |
|
677 |
done |
|
678 |
||
679 |
lemma order_less_le_trans: "!!x::'a::order. [| x < y; y <= z |] ==> x < z" |
|
680 |
apply (simp add: order_less_le) |
|
681 |
apply (blast intro: order_trans order_antisym) |
|
682 |
done |
|
683 |
||
684 |
||
685 |
text {* Useful for simplification, but too risky to include by default. *} |
|
686 |
||
687 |
lemma order_less_imp_not_less: "(x::'a::order) < y ==> (~ y < x) = True" |
|
688 |
by (blast elim: order_less_asym) |
|
689 |
||
690 |
lemma order_less_imp_triv: "(x::'a::order) < y ==> (y < x --> P) = True" |
|
691 |
by (blast elim: order_less_asym) |
|
692 |
||
693 |
lemma order_less_imp_not_eq: "(x::'a::order) < y ==> (x = y) = False" |
|
694 |
by auto |
|
695 |
||
696 |
lemma order_less_imp_not_eq2: "(x::'a::order) < y ==> (y = x) = False" |
|
697 |
by auto |
|
698 |
||
699 |
||
700 |
text {* Other operators. *} |
|
701 |
||
702 |
lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least" |
|
703 |
apply (simp add: min_def) |
|
704 |
apply (blast intro: order_antisym) |
|
705 |
done |
|
706 |
||
707 |
lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x" |
|
708 |
apply (simp add: max_def) |
|
709 |
apply (blast intro: order_antisym) |
|
710 |
done |
|
711 |
||
712 |
||
713 |
subsubsection {* Least value operator *} |
|
714 |
||
715 |
constdefs |
|
716 |
Least :: "('a::ord => bool) => 'a" (binder "LEAST " 10) |
|
717 |
"Least P == THE x. P x & (ALL y. P y --> x <= y)" |
|
718 |
-- {* We can no longer use LeastM because the latter requires Hilbert-AC. *} |
|
719 |
||
720 |
lemma LeastI2: |
|
721 |
"[| P (x::'a::order); |
|
722 |
!!y. P y ==> x <= y; |
|
723 |
!!x. [| P x; ALL y. P y --> x \<le> y |] ==> Q x |] |
|
12281 | 724 |
==> Q (Least P)" |
11750 | 725 |
apply (unfold Least_def) |
726 |
apply (rule theI2) |
|
727 |
apply (blast intro: order_antisym)+ |
|
728 |
done |
|
729 |
||
730 |
lemma Least_equality: |
|
12281 | 731 |
"[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k" |
11750 | 732 |
apply (simp add: Least_def) |
733 |
apply (rule the_equality) |
|
734 |
apply (auto intro!: order_antisym) |
|
735 |
done |
|
736 |
||
737 |
||
738 |
subsubsection "Linear / total orders" |
|
739 |
||
740 |
axclass linorder < order |
|
741 |
linorder_linear: "x <= y | y <= x" |
|
742 |
||
743 |
lemma linorder_less_linear: "!!x::'a::linorder. x<y | x=y | y<x" |
|
744 |
apply (simp add: order_less_le) |
|
745 |
apply (insert linorder_linear) |
|
746 |
apply blast |
|
747 |
done |
|
748 |
||
749 |
lemma linorder_cases [case_names less equal greater]: |
|
750 |
"((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P" |
|
751 |
apply (insert linorder_less_linear) |
|
752 |
apply blast |
|
753 |
done |
|
754 |
||
755 |
lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)" |
|
756 |
apply (simp add: order_less_le) |
|
757 |
apply (insert linorder_linear) |
|
758 |
apply (blast intro: order_antisym) |
|
759 |
done |
|
760 |
||
761 |
lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)" |
|
762 |
apply (simp add: order_less_le) |
|
763 |
apply (insert linorder_linear) |
|
764 |
apply (blast intro: order_antisym) |
|
765 |
done |
|
766 |
||
767 |
lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y | y<x)" |
|
768 |
apply (cut_tac x = x and y = y in linorder_less_linear) |
|
769 |
apply auto |
|
770 |
done |
|
771 |
||
772 |
lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R" |
|
773 |
apply (simp add: linorder_neq_iff) |
|
774 |
apply blast |
|
775 |
done |
|
776 |
||
777 |
||
778 |
subsubsection "Min and max on (linear) orders" |
|
779 |
||
780 |
lemma min_same [simp]: "min (x::'a::order) x = x" |
|
781 |
by (simp add: min_def) |
|
782 |
||
783 |
lemma max_same [simp]: "max (x::'a::order) x = x" |
|
784 |
by (simp add: max_def) |
|
785 |
||
786 |
lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x | z <= y)" |
|
787 |
apply (simp add: max_def) |
|
788 |
apply (insert linorder_linear) |
|
789 |
apply (blast intro: order_trans) |
|
790 |
done |
|
791 |
||
792 |
lemma le_maxI1: "(x::'a::linorder) <= max x y" |
|
793 |
by (simp add: le_max_iff_disj) |
|
794 |
||
795 |
lemma le_maxI2: "(y::'a::linorder) <= max x y" |
|
796 |
-- {* CANNOT use with @{text "[intro!]"} because blast will give PROOF FAILED. *} |
|
797 |
by (simp add: le_max_iff_disj) |
|
798 |
||
799 |
lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x | z < y)" |
|
800 |
apply (simp add: max_def order_le_less) |
|
801 |
apply (insert linorder_less_linear) |
|
802 |
apply (blast intro: order_less_trans) |
|
803 |
done |
|
804 |
||
805 |
lemma max_le_iff_conj [simp]: |
|
806 |
"!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)" |
|
807 |
apply (simp add: max_def) |
|
808 |
apply (insert linorder_linear) |
|
809 |
apply (blast intro: order_trans) |
|
810 |
done |
|
811 |
||
812 |
lemma max_less_iff_conj [simp]: |
|
813 |
"!!z::'a::linorder. (max x y < z) = (x < z & y < z)" |
|
814 |
apply (simp add: order_le_less max_def) |
|
815 |
apply (insert linorder_less_linear) |
|
816 |
apply (blast intro: order_less_trans) |
|
817 |
done |
|
818 |
||
819 |
lemma le_min_iff_conj [simp]: |
|
820 |
"!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)" |
|
821 |
-- {* @{text "[iff]"} screws up a Q{text blast} in MiniML *} |
|
822 |
apply (simp add: min_def) |
|
823 |
apply (insert linorder_linear) |
|
824 |
apply (blast intro: order_trans) |
|
825 |
done |
|
826 |
||
827 |
lemma min_less_iff_conj [simp]: |
|
828 |
"!!z::'a::linorder. (z < min x y) = (z < x & z < y)" |
|
829 |
apply (simp add: order_le_less min_def) |
|
830 |
apply (insert linorder_less_linear) |
|
831 |
apply (blast intro: order_less_trans) |
|
832 |
done |
|
833 |
||
834 |
lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z | y <= z)" |
|
835 |
apply (simp add: min_def) |
|
836 |
apply (insert linorder_linear) |
|
837 |
apply (blast intro: order_trans) |
|
838 |
done |
|
839 |
||
840 |
lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z | y < z)" |
|
841 |
apply (simp add: min_def order_le_less) |
|
842 |
apply (insert linorder_less_linear) |
|
843 |
apply (blast intro: order_less_trans) |
|
844 |
done |
|
845 |
||
846 |
lemma split_min: |
|
847 |
"P (min (i::'a::linorder) j) = ((i <= j --> P(i)) & (~ i <= j --> P(j)))" |
|
848 |
by (simp add: min_def) |
|
849 |
||
850 |
lemma split_max: |
|
851 |
"P (max (i::'a::linorder) j) = ((i <= j --> P(j)) & (~ i <= j --> P(i)))" |
|
852 |
by (simp add: max_def) |
|
853 |
||
854 |
||
855 |
subsubsection "Bounded quantifiers" |
|
856 |
||
857 |
syntax |
|
858 |
"_lessAll" :: "[idt, 'a, bool] => bool" ("(3ALL _<_./ _)" [0, 0, 10] 10) |
|
859 |
"_lessEx" :: "[idt, 'a, bool] => bool" ("(3EX _<_./ _)" [0, 0, 10] 10) |
|
860 |
"_leAll" :: "[idt, 'a, bool] => bool" ("(3ALL _<=_./ _)" [0, 0, 10] 10) |
|
861 |
"_leEx" :: "[idt, 'a, bool] => bool" ("(3EX _<=_./ _)" [0, 0, 10] 10) |
|
862 |
||
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset
|
863 |
syntax (xsymbols) |
11750 | 864 |
"_lessAll" :: "[idt, 'a, bool] => bool" ("(3\<forall>_<_./ _)" [0, 0, 10] 10) |
865 |
"_lessEx" :: "[idt, 'a, bool] => bool" ("(3\<exists>_<_./ _)" [0, 0, 10] 10) |
|
866 |
"_leAll" :: "[idt, 'a, bool] => bool" ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10) |
|
867 |
"_leEx" :: "[idt, 'a, bool] => bool" ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10) |
|
868 |
||
869 |
syntax (HOL) |
|
870 |
"_lessAll" :: "[idt, 'a, bool] => bool" ("(3! _<_./ _)" [0, 0, 10] 10) |
|
871 |
"_lessEx" :: "[idt, 'a, bool] => bool" ("(3? _<_./ _)" [0, 0, 10] 10) |
|
872 |
"_leAll" :: "[idt, 'a, bool] => bool" ("(3! _<=_./ _)" [0, 0, 10] 10) |
|
873 |
"_leEx" :: "[idt, 'a, bool] => bool" ("(3? _<=_./ _)" [0, 0, 10] 10) |
|
874 |
||
875 |
translations |
|
876 |
"ALL x<y. P" => "ALL x. x < y --> P" |
|
877 |
"EX x<y. P" => "EX x. x < y & P" |
|
878 |
"ALL x<=y. P" => "ALL x. x <= y --> P" |
|
879 |
"EX x<=y. P" => "EX x. x <= y & P" |
|
880 |
||
923 | 881 |
end |