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