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