0
|
1 |
(* Title: HOL/hol.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow
|
|
4 |
Copyright 1993 University of Cambridge
|
|
5 |
|
|
6 |
Higher-Order Logic
|
|
7 |
*)
|
|
8 |
|
|
9 |
HOL = Pure +
|
|
10 |
|
|
11 |
classes
|
|
12 |
term < logic
|
|
13 |
plus < term
|
|
14 |
minus < term
|
|
15 |
times < term
|
|
16 |
|
11
|
17 |
default
|
|
18 |
term
|
0
|
19 |
|
|
20 |
types
|
|
21 |
bool 0
|
|
22 |
|
|
23 |
arities
|
|
24 |
fun :: (term, term) term
|
|
25 |
bool :: term
|
|
26 |
|
|
27 |
|
|
28 |
consts
|
|
29 |
|
|
30 |
(* Constants *)
|
|
31 |
|
4
|
32 |
Trueprop :: "bool => prop" ("(_)" 5)
|
|
33 |
not :: "bool => bool" ("~ _" [40] 40)
|
0
|
34 |
True, False :: "bool"
|
|
35 |
if :: "[bool, 'a, 'a] => 'a"
|
|
36 |
Inv :: "('a => 'b) => ('b => 'a)"
|
|
37 |
|
|
38 |
(* Binders *)
|
|
39 |
|
4
|
40 |
Eps :: "('a => bool) => 'a" (binder "@" 10)
|
|
41 |
All :: "('a => bool) => bool" (binder "! " 10)
|
|
42 |
Ex :: "('a => bool) => bool" (binder "? " 10)
|
|
43 |
Ex1 :: "('a => bool) => bool" (binder "?! " 10)
|
0
|
44 |
|
4
|
45 |
Let :: "['a, 'a => 'b] => 'b"
|
|
46 |
"@Let" :: "[idt, 'a, 'b] => 'b" ("(let _ = (2_)/ in (2_))" 10)
|
0
|
47 |
|
|
48 |
(* Alternative Quantifiers *)
|
|
49 |
|
4
|
50 |
"*All" :: "[idts, bool] => bool" ("(3ALL _./ _)" 10)
|
|
51 |
"*Ex" :: "[idts, bool] => bool" ("(3EX _./ _)" 10)
|
|
52 |
"*Ex1" :: "[idts, bool] => bool" ("(3EX! _./ _)" 10)
|
0
|
53 |
|
|
54 |
(* Infixes *)
|
|
55 |
|
4
|
56 |
o :: "['b => 'c, 'a => 'b, 'a] => 'c" (infixr 50)
|
11
|
57 |
"=" :: "['a, 'a] => bool" (infixl 50)
|
|
58 |
"~=" :: "['a, 'a] => bool" ("(_ ~=/ _)" [50, 51] 50)
|
4
|
59 |
"&" :: "[bool, bool] => bool" (infixr 35)
|
|
60 |
"|" :: "[bool, bool] => bool" (infixr 30)
|
|
61 |
"-->" :: "[bool, bool] => bool" (infixr 25)
|
0
|
62 |
|
|
63 |
(* Overloaded Constants *)
|
|
64 |
|
4
|
65 |
"+" :: "['a::plus, 'a] => 'a" (infixl 65)
|
|
66 |
"-" :: "['a::minus, 'a] => 'a" (infixl 65)
|
|
67 |
"*" :: "['a::times, 'a] => 'a" (infixl 70)
|
0
|
68 |
|
|
69 |
|
|
70 |
translations
|
|
71 |
"ALL xs. P" => "! xs. P"
|
|
72 |
"EX xs. P" => "? xs. P"
|
|
73 |
"EX! xs. P" => "?! xs. P"
|
11
|
74 |
"x ~= y" == "~ (x = y)"
|
|
75 |
"let x = s in t" == "Let(s, %x. t)"
|
0
|
76 |
|
|
77 |
|
|
78 |
rules
|
|
79 |
|
|
80 |
eq_reflection "(x=y) ==> (x==y)"
|
|
81 |
|
|
82 |
(* Basic Rules *)
|
|
83 |
|
|
84 |
refl "t = t::'a"
|
|
85 |
subst "[| s = t; P(s) |] ==> P(t::'a)"
|
|
86 |
ext "(!!x::'a. f(x)::'b = g(x)) ==> (%x.f(x)) = (%x.g(x))"
|
|
87 |
selectI "P(x::'a) ==> P(@x.P(x))"
|
|
88 |
|
|
89 |
impI "(P ==> Q) ==> P-->Q"
|
|
90 |
mp "[| P-->Q; P |] ==> Q"
|
|
91 |
|
|
92 |
(* Definitions *)
|
|
93 |
|
|
94 |
True_def "True = ((%x.x)=(%x.x))"
|
|
95 |
All_def "All = (%P. P = (%x.True))"
|
|
96 |
Ex_def "Ex = (%P. P(@x.P(x)))"
|
|
97 |
False_def "False = (!P.P)"
|
|
98 |
not_def "not = (%P. P-->False)"
|
|
99 |
and_def "op & = (%P Q. !R. (P-->Q-->R) --> R)"
|
|
100 |
or_def "op | = (%P Q. !R. (P-->R) --> (Q-->R) --> R)"
|
|
101 |
Ex1_def "Ex1 = (%P. ? x. P(x) & (! y. P(y) --> y=x))"
|
4
|
102 |
Let_def "Let(s, f) = f(s)"
|
0
|
103 |
|
|
104 |
(* Axioms *)
|
|
105 |
|
|
106 |
iff "(P-->Q) --> (Q-->P) --> (P=Q)"
|
|
107 |
True_or_False "(P=True) | (P=False)"
|
|
108 |
|
|
109 |
(* Misc Definitions *)
|
|
110 |
|
|
111 |
Inv_def "Inv = (%(f::'a=>'b) y. @x. f(x)=y)"
|
|
112 |
o_def "op o = (%(f::'b=>'c) g (x::'a). f(g(x)))"
|
|
113 |
|
|
114 |
if_def "if = (%P x y.@z::'a. (P=True --> z=x) & (P=False --> z=y))"
|
|
115 |
|
|
116 |
end
|
|
117 |
|
|
118 |
|
|
119 |
ML
|
|
120 |
|
|
121 |
(** Choice between the HOL and Isabelle style of quantifiers **)
|
|
122 |
|
|
123 |
val HOL_quantifiers = ref true;
|
|
124 |
|
4
|
125 |
fun alt_ast_tr' (name, alt_name) =
|
0
|
126 |
let
|
|
127 |
fun ast_tr' (*name*) args =
|
|
128 |
if ! HOL_quantifiers then raise Match
|
4
|
129 |
else Syntax.mk_appl (Syntax.Constant alt_name) args;
|
0
|
130 |
in
|
|
131 |
(name, ast_tr')
|
|
132 |
end;
|
|
133 |
|
|
134 |
|
|
135 |
val print_ast_translation =
|
7
|
136 |
map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];
|
0
|
137 |
|