author | oheimb |
Wed, 12 Aug 1998 16:23:25 +0200 | |
changeset 5305 | 513925de8962 |
parent 5186 | 439e292b5b87 |
child 5492 | d9fc3457554e |
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 |
||
9 |
HOL = CPure + |
|
10 |
||
2260 | 11 |
|
12 |
(** Core syntax **) |
|
13 |
||
3947 | 14 |
global |
15 |
||
923 | 16 |
classes |
17 |
term < logic |
|
18 |
||
19 |
default |
|
20 |
term |
|
21 |
||
22 |
types |
|
23 |
bool |
|
24 |
||
25 |
arities |
|
26 |
fun :: (term, term) term |
|
27 |
bool :: term |
|
28 |
||
29 |
||
30 |
consts |
|
31 |
||
32 |
(* Constants *) |
|
33 |
||
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
34 |
Trueprop :: bool => prop ("(_)" 5) |
2720 | 35 |
Not :: bool => bool ("~ _" [40] 40) |
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
36 |
True, False :: bool |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
37 |
If :: [bool, 'a, 'a] => 'a ("(if (_)/ then (_)/ else (_))" 10) |
3947 | 38 |
arbitrary :: 'a |
923 | 39 |
|
40 |
(* Binders *) |
|
41 |
||
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
42 |
Eps :: ('a => bool) => 'a |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
43 |
All :: ('a => bool) => bool (binder "! " 10) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
44 |
Ex :: ('a => bool) => bool (binder "? " 10) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
45 |
Ex1 :: ('a => bool) => bool (binder "?! " 10) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
46 |
Let :: ['a, 'a => 'b] => 'b |
923 | 47 |
|
48 |
(* Infixes *) |
|
49 |
||
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
50 |
"=" :: ['a, 'a] => bool (infixl 50) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
51 |
"&" :: [bool, bool] => bool (infixr 35) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
52 |
"|" :: [bool, bool] => bool (infixr 30) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
53 |
"-->" :: [bool, bool] => bool (infixr 25) |
923 | 54 |
|
2260 | 55 |
|
56 |
(* Overloaded Constants *) |
|
57 |
||
58 |
axclass |
|
59 |
plus < term |
|
923 | 60 |
|
2260 | 61 |
axclass |
62 |
minus < term |
|
63 |
||
64 |
axclass |
|
65 |
times < term |
|
66 |
||
3370
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset
|
67 |
axclass |
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset
|
68 |
power < term |
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset
|
69 |
|
2260 | 70 |
consts |
3370
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset
|
71 |
"+" :: ['a::plus, 'a] => 'a (infixl 65) |
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
72 |
"-" :: ['a::minus, 'a] => 'a (infixl 65) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
73 |
"*" :: ['a::times, 'a] => 'a (infixl 70) |
3370
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset
|
74 |
(*See Nat.thy for "^"*) |
2260 | 75 |
|
3820 | 76 |
|
2260 | 77 |
(** Additional concrete syntax **) |
78 |
||
4868 | 79 |
nonterminals |
923 | 80 |
letbinds letbind |
81 |
case_syn cases_syn |
|
82 |
||
83 |
syntax |
|
84 |
||
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
85 |
"~=" :: ['a, 'a] => bool (infixl 50) |
923 | 86 |
|
2368 | 87 |
"@Eps" :: [pttrn, bool] => 'a ("(3@ _./ _)" [0, 10] 10) |
1068 | 88 |
|
923 | 89 |
(* Alternative Quantifiers *) |
90 |
||
2368 | 91 |
"*All" :: [idts, bool] => bool ("(3ALL _./ _)" [0, 10] 10) |
92 |
"*Ex" :: [idts, bool] => bool ("(3EX _./ _)" [0, 10] 10) |
|
93 |
"*Ex1" :: [idts, bool] => bool ("(3EX! _./ _)" [0, 10] 10) |
|
923 | 94 |
|
95 |
(* Let expressions *) |
|
96 |
||
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
97 |
"_bind" :: [pttrn, 'a] => letbind ("(2_ =/ _)" 10) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
98 |
"" :: letbind => letbinds ("_") |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
99 |
"_binds" :: [letbind, letbinds] => letbinds ("_;/ _") |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
100 |
"_Let" :: [letbinds, 'a] => 'a ("(let (_)/ in (_))" 10) |
923 | 101 |
|
102 |
(* Case expressions *) |
|
103 |
||
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
104 |
"@case" :: ['a, cases_syn] => 'b ("(case _ of/ _)" 10) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
105 |
"@case1" :: ['a, 'b] => case_syn ("(2_ =>/ _)" 10) |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
106 |
"" :: case_syn => cases_syn ("_") |
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset
|
107 |
"@case2" :: [case_syn, cases_syn] => cases_syn ("_/ | _") |
923 | 108 |
|
109 |
translations |
|
110 |
"x ~= y" == "~ (x = y)" |
|
3842 | 111 |
"@ x. b" == "Eps (%x. b)" |
923 | 112 |
"ALL xs. P" => "! xs. P" |
113 |
"EX xs. P" => "? xs. P" |
|
114 |
"EX! xs. P" => "?! xs. P" |
|
115 |
"_Let (_binds b bs) e" == "_Let b (_Let bs e)" |
|
1114 | 116 |
"let x = a in e" == "Let a (%x. e)" |
923 | 117 |
|
3820 | 118 |
syntax ("" output) |
119 |
"op =" :: ['a, 'a] => bool ("(_ =/ _)" [51, 51] 50) |
|
120 |
"op ~=" :: ['a, 'a] => bool ("(_ ~=/ _)" [51, 51] 50) |
|
2260 | 121 |
|
122 |
syntax (symbols) |
|
2762 | 123 |
Not :: bool => bool ("\\<not> _" [40] 40) |
2260 | 124 |
"op &" :: [bool, bool] => bool (infixr "\\<and>" 35) |
125 |
"op |" :: [bool, bool] => bool (infixr "\\<or>" 30) |
|
126 |
"op -->" :: [bool, bool] => bool (infixr "\\<midarrow>\\<rightarrow>" 25) |
|
127 |
"op o" :: ['b => 'c, 'a => 'b, 'a] => 'c (infixl "\\<circ>" 55) |
|
128 |
"op ~=" :: ['a, 'a] => bool (infixl "\\<noteq>" 50) |
|
2368 | 129 |
"@Eps" :: [pttrn, bool] => 'a ("(3\\<epsilon>_./ _)" [0, 10] 10) |
130 |
"! " :: [idts, bool] => bool ("(3\\<forall>_./ _)" [0, 10] 10) |
|
131 |
"? " :: [idts, bool] => bool ("(3\\<exists>_./ _)" [0, 10] 10) |
|
132 |
"?! " :: [idts, bool] => bool ("(3\\<exists>!_./ _)" [0, 10] 10) |
|
2552 | 133 |
"@case1" :: ['a, 'b] => case_syn ("(2_ \\<Rightarrow>/ _)" 10) |
3068
b7562e452816
deactivated new symbols (not yet printable on xterm, emacs);
wenzelm
parents:
3066
diff
changeset
|
134 |
(*"@case2" :: [case_syn, cases_syn] => cases_syn ("_/ \\<orelse> _")*) |
2372 | 135 |
|
3820 | 136 |
syntax (symbols output) |
137 |
"op ~=" :: ['a, 'a] => bool ("(_ \\<noteq>/ _)" [51, 51] 50) |
|
138 |
"*All" :: [idts, bool] => bool ("(3\\<forall>_./ _)" [0, 10] 10) |
|
139 |
"*Ex" :: [idts, bool] => bool ("(3\\<exists>_./ _)" [0, 10] 10) |
|
140 |
"*Ex1" :: [idts, bool] => bool ("(3\\<exists>!_./ _)" [0, 10] 10) |
|
141 |
||
2260 | 142 |
|
143 |
||
144 |
(** Rules and definitions **) |
|
145 |
||
3947 | 146 |
local |
147 |
||
923 | 148 |
rules |
149 |
||
150 |
eq_reflection "(x=y) ==> (x==y)" |
|
151 |
||
152 |
(* Basic Rules *) |
|
153 |
||
154 |
refl "t = (t::'a)" |
|
155 |
subst "[| s = t; P(s) |] ==> P(t::'a)" |
|
3842 | 156 |
ext "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" |
157 |
selectI "P (x::'a) ==> P (@x. P x)" |
|
923 | 158 |
|
159 |
impI "(P ==> Q) ==> P-->Q" |
|
160 |
mp "[| P-->Q; P |] ==> Q" |
|
161 |
||
162 |
defs |
|
163 |
||
3842 | 164 |
True_def "True == ((%x::bool. x) = (%x. x))" |
165 |
All_def "All(P) == (P = (%x. True))" |
|
166 |
Ex_def "Ex(P) == P(@x. P(x))" |
|
167 |
False_def "False == (!P. P)" |
|
923 | 168 |
not_def "~ P == P-->False" |
169 |
and_def "P & Q == !R. (P-->Q-->R) --> R" |
|
170 |
or_def "P | Q == !R. (P-->R) --> (Q-->R) --> R" |
|
171 |
Ex1_def "Ex1(P) == ? x. P(x) & (! y. P(y) --> y=x)" |
|
172 |
||
173 |
rules |
|
174 |
(* Axioms *) |
|
175 |
||
176 |
iff "(P-->Q) --> (Q-->P) --> (P=Q)" |
|
177 |
True_or_False "(P=True) | (P=False)" |
|
178 |
||
179 |
defs |
|
5069 | 180 |
(*misc definitions*) |
923 | 181 |
Let_def "Let s f == f(s)" |
973 | 182 |
if_def "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)" |
5069 | 183 |
|
184 |
(*arbitrary is completely unspecified, but is made to appear as a |
|
185 |
definition syntactically*) |
|
4371
8755cdbbf6b3
improved arbitrary_def: we now really don't know nothing about it!
wenzelm
parents:
4083
diff
changeset
|
186 |
arbitrary_def "False ==> arbitrary == (@x. False)" |
923 | 187 |
|
3320 | 188 |
|
4868 | 189 |
|
190 |
(** initial HOL theory setup **) |
|
191 |
||
192 |
setup Simplifier.setup |
|
193 |
setup ClasetThyData.setup |
|
194 |
||
195 |
||
923 | 196 |
end |
197 |
||
2260 | 198 |
|
923 | 199 |
ML |
200 |
||
4793 | 201 |
|
923 | 202 |
(** Choice between the HOL and Isabelle style of quantifiers **) |
203 |
||
204 |
val HOL_quantifiers = ref true; |
|
205 |
||
206 |
fun alt_ast_tr' (name, alt_name) = |
|
207 |
let |
|
208 |
fun ast_tr' (*name*) args = |
|
209 |
if ! HOL_quantifiers then raise Match |
|
210 |
else Syntax.mk_appl (Syntax.Constant alt_name) args; |
|
211 |
in |
|
212 |
(name, ast_tr') |
|
213 |
end; |
|
214 |
||
215 |
||
216 |
val print_ast_translation = |
|
217 |
map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")]; |