author | wenzelm |
Fri, 05 Oct 2001 21:49:15 +0200 | |
changeset 11698 | 3b3feb92207a |
parent 11687 | b0fe6e522559 |
child 11724 | f727aa96ae2e |
permissions | -rw-r--r-- |
923 | 1 |
(* Title: HOL/HOL.thy |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow |
|
4 |
Copyright 1993 University of Cambridge |
|
5 |
||
2260 | 6 |
Higher-Order Logic. |
923 | 7 |
*) |
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 |
|
13 |
(** Core syntax **) |
|
14 |
||
3947 | 15 |
global |
16 |
||
7357 | 17 |
classes "term" < logic |
18 |
defaultsort "term" |
|
923 | 19 |
|
7357 | 20 |
typedecl bool |
923 | 21 |
|
22 |
arities |
|
7357 | 23 |
bool :: "term" |
24 |
fun :: ("term", "term") "term" |
|
923 | 25 |
|
26 |
consts |
|
27 |
||
28 |
(* Constants *) |
|
29 |
||
7357 | 30 |
Trueprop :: "bool => prop" ("(_)" 5) |
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 |
|
37 |
(* Binders *) |
|
38 |
||
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
39 |
The :: "('a => bool) => 'a" |
7357 | 40 |
All :: "('a => bool) => bool" (binder "ALL " 10) |
41 |
Ex :: "('a => bool) => bool" (binder "EX " 10) |
|
42 |
Ex1 :: "('a => bool) => bool" (binder "EX! " 10) |
|
43 |
Let :: "['a, 'a => 'b] => 'b" |
|
923 | 44 |
|
45 |
(* Infixes *) |
|
46 |
||
7357 | 47 |
"=" :: "['a, 'a] => bool" (infixl 50) |
48 |
& :: "[bool, bool] => bool" (infixr 35) |
|
49 |
"|" :: "[bool, bool] => bool" (infixr 30) |
|
50 |
--> :: "[bool, bool] => bool" (infixr 25) |
|
923 | 51 |
|
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
52 |
local |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
53 |
|
2260 | 54 |
|
55 |
(* Overloaded Constants *) |
|
56 |
||
11698 | 57 |
axclass zero < "term" |
58 |
axclass one < "term" |
|
59 |
axclass plus < "term" |
|
7357 | 60 |
axclass minus < "term" |
61 |
axclass times < "term" |
|
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
62 |
axclass inverse < "term" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
63 |
|
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
64 |
global |
3370
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset
|
65 |
|
2260 | 66 |
consts |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
67 |
"0" :: "'a::zero" ("0") |
11698 | 68 |
"1" :: "'a::one" ("1") |
7357 | 69 |
"+" :: "['a::plus, 'a] => 'a" (infixl 65) |
70 |
- :: "['a::minus, 'a] => 'a" (infixl 65) |
|
71 |
uminus :: "['a::minus] => 'a" ("- _" [81] 80) |
|
7426 | 72 |
* :: "['a::times, 'a] => 'a" (infixl 70) |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
73 |
|
11698 | 74 |
typed_print_translation {* |
75 |
let |
|
76 |
fun tr' c = (c, fn show_sorts => fn T => fn ts => |
|
77 |
if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match |
|
78 |
else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T); |
|
79 |
in [tr' "0", tr' "1"] end; |
|
80 |
*} |
|
81 |
||
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
82 |
local |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
83 |
|
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
84 |
consts |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
85 |
abs :: "'a::minus => 'a" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
86 |
inverse :: "'a::inverse => 'a" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
87 |
divide :: "['a::inverse, 'a] => 'a" (infixl "'/" 70) |
2260 | 88 |
|
10489 | 89 |
syntax (xsymbols) |
11687 | 90 |
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") |
10489 | 91 |
syntax (HTML output) |
11687 | 92 |
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") |
10489 | 93 |
|
8959 | 94 |
axclass plus_ac0 < plus, zero |
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
95 |
commute: "x + y = y + x" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
96 |
assoc: "(x + y) + z = x + (y + z)" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
97 |
zero: "0 + x = x" |
3820 | 98 |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
99 |
|
2260 | 100 |
(** Additional concrete syntax **) |
101 |
||
4868 | 102 |
nonterminals |
923 | 103 |
letbinds letbind |
104 |
case_syn cases_syn |
|
105 |
||
106 |
syntax |
|
7357 | 107 |
~= :: "['a, 'a] => bool" (infixl 50) |
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
108 |
"_The" :: "[pttrn, bool] => 'a" ("(3THE _./ _)" [0, 10] 10) |
923 | 109 |
|
110 |
(* Let expressions *) |
|
111 |
||
7357 | 112 |
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) |
113 |
"" :: "letbind => letbinds" ("_") |
|
114 |
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") |
|
115 |
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) |
|
923 | 116 |
|
117 |
(* Case expressions *) |
|
118 |
||
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
119 |
"_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
|
120 |
"_case1" :: "['a, 'b] => case_syn" ("(2_ =>/ _)" 10) |
7357 | 121 |
"" :: "case_syn => cases_syn" ("_") |
9060
b0dd884b1848
rename @case to _case_syntax (improves on low-level errors);
wenzelm
parents:
8959
diff
changeset
|
122 |
"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ | _") |
923 | 123 |
|
124 |
translations |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
125 |
"x ~= y" == "~ (x = y)" |
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
126 |
"THE x. P" == "The (%x. P)" |
923 | 127 |
"_Let (_binds b bs) e" == "_Let b (_Let bs e)" |
1114 | 128 |
"let x = a in e" == "Let a (%x. e)" |
923 | 129 |
|
3820 | 130 |
syntax ("" output) |
11687 | 131 |
"=" :: "['a, 'a] => bool" (infix 50) |
132 |
"~=" :: "['a, 'a] => bool" (infix 50) |
|
2260 | 133 |
|
134 |
syntax (symbols) |
|
11687 | 135 |
Not :: "bool => bool" ("\<not> _" [40] 40) |
136 |
"op &" :: "[bool, bool] => bool" (infixr "\<and>" 35) |
|
137 |
"op |" :: "[bool, bool] => bool" (infixr "\<or>" 30) |
|
138 |
"op -->" :: "[bool, bool] => bool" (infixr "\<midarrow>\<rightarrow>" 25) |
|
139 |
"op ~=" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
|
140 |
"ALL " :: "[idts, bool] => bool" ("(3\<forall>_./ _)" [0, 10] 10) |
|
141 |
"EX " :: "[idts, bool] => bool" ("(3\<exists>_./ _)" [0, 10] 10) |
|
142 |
"EX! " :: "[idts, bool] => bool" ("(3\<exists>!_./ _)" [0, 10] 10) |
|
143 |
"_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
|
144 |
(*"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ \\<orelse> _")*) |
2372 | 145 |
|
3820 | 146 |
syntax (symbols output) |
11687 | 147 |
"op ~=" :: "['a, 'a] => bool" (infix "\<noteq>" 50) |
3820 | 148 |
|
6027
9dd06eeda95c
added new print_mode "xsymbols" for extended symbol support
oheimb
parents:
5786
diff
changeset
|
149 |
syntax (xsymbols) |
11687 | 150 |
"op -->" :: "[bool, bool] => bool" (infixr "\<longrightarrow>" 25) |
2260 | 151 |
|
6340 | 152 |
syntax (HTML output) |
11687 | 153 |
Not :: "bool => bool" ("\<not> _" [40] 40) |
6340 | 154 |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
155 |
syntax (HOL) |
7357 | 156 |
"ALL " :: "[idts, bool] => bool" ("(3! _./ _)" [0, 10] 10) |
157 |
"EX " :: "[idts, bool] => bool" ("(3? _./ _)" [0, 10] 10) |
|
158 |
"EX! " :: "[idts, bool] => bool" ("(3?! _./ _)" [0, 10] 10) |
|
7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
159 |
|
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset
|
160 |
|
6340 | 161 |
|
2260 | 162 |
(** Rules and definitions **) |
163 |
||
7357 | 164 |
axioms |
923 | 165 |
|
7357 | 166 |
eq_reflection: "(x=y) ==> (x==y)" |
923 | 167 |
|
168 |
(* Basic Rules *) |
|
169 |
||
7357 | 170 |
refl: "t = (t::'a)" |
171 |
subst: "[| s = t; P(s) |] ==> P(t::'a)" |
|
6289 | 172 |
|
173 |
(*Extensionality is built into the meta-logic, and this rule expresses |
|
174 |
a related property. It is an eta-expanded version of the traditional |
|
175 |
rule, and similar to the ABS rule of HOL.*) |
|
7357 | 176 |
ext: "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" |
6289 | 177 |
|
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset
|
178 |
the_eq_trivial: "(THE x. x = a) = (a::'a)" |
923 | 179 |
|
7357 | 180 |
impI: "(P ==> Q) ==> P-->Q" |
181 |
mp: "[| P-->Q; P |] ==> Q" |
|
923 | 182 |
|
183 |
defs |
|
184 |
||
7357 | 185 |
True_def: "True == ((%x::bool. x) = (%x. x))" |
186 |
All_def: "All(P) == (P = (%x. True))" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
187 |
Ex_def: "Ex(P) == !Q. (!x. P x --> Q) --> Q" |
7357 | 188 |
False_def: "False == (!P. P)" |
189 |
not_def: "~ P == P-->False" |
|
190 |
and_def: "P & Q == !R. (P-->Q-->R) --> R" |
|
191 |
or_def: "P | Q == !R. (P-->R) --> (Q-->R) --> R" |
|
192 |
Ex1_def: "Ex1(P) == ? x. P(x) & (! y. P(y) --> y=x)" |
|
923 | 193 |
|
7357 | 194 |
axioms |
923 | 195 |
(* Axioms *) |
196 |
||
7357 | 197 |
iff: "(P-->Q) --> (Q-->P) --> (P=Q)" |
198 |
True_or_False: "(P=True) | (P=False)" |
|
923 | 199 |
|
200 |
defs |
|
5069 | 201 |
(*misc definitions*) |
7357 | 202 |
Let_def: "Let s f == f(s)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
203 |
if_def: "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)" |
5069 | 204 |
|
205 |
(*arbitrary is completely unspecified, but is made to appear as a |
|
206 |
definition syntactically*) |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset
|
207 |
arbitrary_def: "False ==> arbitrary == (THE x. False)" |
923 | 208 |
|
3320 | 209 |
|
4868 | 210 |
|
7357 | 211 |
(* theory and package setup *) |
4868 | 212 |
|
9736 | 213 |
use "HOL_lemmas.ML" |
11687 | 214 |
theorems case_split = case_split_thm [case_names True False] |
9869 | 215 |
|
11438
3d9222b80989
declare trans [trans] (*overridden in theory Calculation*);
wenzelm
parents:
11432
diff
changeset
|
216 |
declare trans [trans] (*overridden in theory Calculation*) |
3d9222b80989
declare trans [trans] (*overridden in theory Calculation*);
wenzelm
parents:
11432
diff
changeset
|
217 |
|
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
218 |
lemma atomize_all: "(!!x. P x) == Trueprop (ALL x. P x)" |
9488 | 219 |
proof (rule equal_intr_rule) |
220 |
assume "!!x. P x" |
|
10383 | 221 |
show "ALL x. P x" by (rule allI) |
9488 | 222 |
next |
223 |
assume "ALL x. P x" |
|
10383 | 224 |
thus "!!x. P x" by (rule allE) |
9488 | 225 |
qed |
226 |
||
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
227 |
lemma atomize_imp: "(A ==> B) == Trueprop (A --> B)" |
9488 | 228 |
proof (rule equal_intr_rule) |
229 |
assume r: "A ==> B" |
|
10383 | 230 |
show "A --> B" by (rule impI) (rule r) |
9488 | 231 |
next |
232 |
assume "A --> B" and A |
|
10383 | 233 |
thus B by (rule mp) |
9488 | 234 |
qed |
235 |
||
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
236 |
lemma atomize_eq: "(x == y) == Trueprop (x = y)" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
237 |
proof (rule equal_intr_rule) |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
238 |
assume "x == y" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
239 |
show "x = y" by (unfold prems) (rule refl) |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
240 |
next |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
241 |
assume "x = y" |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
242 |
thus "x == y" by (rule eq_reflection) |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
243 |
qed |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
244 |
|
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
245 |
lemmas atomize = atomize_all atomize_imp |
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset
|
246 |
lemmas atomize' = atomize atomize_eq |
9529 | 247 |
|
10383 | 248 |
use "cladata.ML" |
249 |
setup hypsubst_setup |
|
250 |
setup Classical.setup |
|
251 |
setup clasetup |
|
252 |
||
9869 | 253 |
use "blastdata.ML" |
254 |
setup Blast.setup |
|
4868 | 255 |
|
9869 | 256 |
use "simpdata.ML" |
257 |
setup Simplifier.setup |
|
258 |
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup |
|
259 |
setup Splitter.setup setup Clasimp.setup |
|
260 |
||
923 | 261 |
end |