author  wenzelm 
Mon, 22 Jun 1998 17:26:46 +0200  
changeset 5069  3ea049f7979d 
parent 4868  843a9f5b3c3d 
child 5186  439e292b5b87 
permissions  rwrr 
923  1 
(* Title: HOL/HOL.thy 
2 
ID: $Id$ 

3 
Author: Tobias Nipkow 

4 
Copyright 1993 University of Cambridge 

5 

2260  6 
HigherOrder 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 
o :: ['b => 'c, 'a => 'b, 'a] => 'c (infixl 55) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

51 
"=" :: ['a, 'a] => bool (infixl 50) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

52 
"&" :: [bool, bool] => bool (infixr 35) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

53 
"" :: [bool, bool] => bool (infixr 30) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

54 
">" :: [bool, bool] => bool (infixr 25) 
923  55 

2260  56 

57 
(* Overloaded Constants *) 

58 

59 
axclass 

60 
plus < term 

923  61 

2260  62 
axclass 
63 
minus < term 

64 

65 
axclass 

66 
times < term 

67 

3370
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset

68 
axclass 
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset

69 
power < term 
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset

70 

2260  71 
consts 
3370
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset

72 
"+" :: ['a::plus, 'a] => 'a (infixl 65) 
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

73 
"" :: ['a::minus, 'a] => 'a (infixl 65) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

74 
"*" :: ['a::times, 'a] => 'a (infixl 70) 
3370
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
paulson
parents:
3320
diff
changeset

75 
(*See Nat.thy for "^"*) 
2260  76 

3820  77 

2260  78 
(** Additional concrete syntax **) 
79 

4868  80 
nonterminals 
923  81 
letbinds letbind 
82 
case_syn cases_syn 

83 

84 
syntax 

85 

1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

86 
"~=" :: ['a, 'a] => bool (infixl 50) 
923  87 

2368  88 
"@Eps" :: [pttrn, bool] => 'a ("(3@ _./ _)" [0, 10] 10) 
1068  89 

923  90 
(* Alternative Quantifiers *) 
91 

2368  92 
"*All" :: [idts, bool] => bool ("(3ALL _./ _)" [0, 10] 10) 
93 
"*Ex" :: [idts, bool] => bool ("(3EX _./ _)" [0, 10] 10) 

94 
"*Ex1" :: [idts, bool] => bool ("(3EX! _./ _)" [0, 10] 10) 

923  95 

96 
(* Let expressions *) 

97 

1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

98 
"_bind" :: [pttrn, 'a] => letbind ("(2_ =/ _)" 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

99 
"" :: letbind => letbinds ("_") 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

100 
"_binds" :: [letbind, letbinds] => letbinds ("_;/ _") 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

101 
"_Let" :: [letbinds, 'a] => 'a ("(let (_)/ in (_))" 10) 
923  102 

103 
(* Case expressions *) 

104 

1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

105 
"@case" :: ['a, cases_syn] => 'b ("(case _ of/ _)" 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

106 
"@case1" :: ['a, 'b] => case_syn ("(2_ =>/ _)" 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

107 
"" :: case_syn => cases_syn ("_") 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

108 
"@case2" :: [case_syn, cases_syn] => cases_syn ("_/  _") 
923  109 

110 
translations 

111 
"x ~= y" == "~ (x = y)" 

3842  112 
"@ x. b" == "Eps (%x. b)" 
923  113 
"ALL xs. P" => "! xs. P" 
114 
"EX xs. P" => "? xs. P" 

115 
"EX! xs. P" => "?! xs. P" 

116 
"_Let (_binds b bs) e" == "_Let b (_Let bs e)" 

1114  117 
"let x = a in e" == "Let a (%x. e)" 
923  118 

3820  119 
syntax ("" output) 
120 
"op =" :: ['a, 'a] => bool ("(_ =/ _)" [51, 51] 50) 

121 
"op ~=" :: ['a, 'a] => bool ("(_ ~=/ _)" [51, 51] 50) 

2260  122 

123 
syntax (symbols) 

2762  124 
Not :: bool => bool ("\\<not> _" [40] 40) 
2260  125 
"op &" :: [bool, bool] => bool (infixr "\\<and>" 35) 
126 
"op " :: [bool, bool] => bool (infixr "\\<or>" 30) 

127 
"op >" :: [bool, bool] => bool (infixr "\\<midarrow>\\<rightarrow>" 25) 

128 
"op o" :: ['b => 'c, 'a => 'b, 'a] => 'c (infixl "\\<circ>" 55) 

129 
"op ~=" :: ['a, 'a] => bool (infixl "\\<noteq>" 50) 

2368  130 
"@Eps" :: [pttrn, bool] => 'a ("(3\\<epsilon>_./ _)" [0, 10] 10) 
131 
"! " :: [idts, bool] => bool ("(3\\<forall>_./ _)" [0, 10] 10) 

132 
"? " :: [idts, bool] => bool ("(3\\<exists>_./ _)" [0, 10] 10) 

133 
"?! " :: [idts, bool] => bool ("(3\\<exists>!_./ _)" [0, 10] 10) 

2552  134 
"@case1" :: ['a, 'b] => case_syn ("(2_ \\<Rightarrow>/ _)" 10) 
3068
b7562e452816
deactivated new symbols (not yet printable on xterm, emacs);
wenzelm
parents:
3066
diff
changeset

135 
(*"@case2" :: [case_syn, cases_syn] => cases_syn ("_/ \\<orelse> _")*) 
2372  136 

3820  137 
syntax (symbols output) 
138 
"op ~=" :: ['a, 'a] => bool ("(_ \\<noteq>/ _)" [51, 51] 50) 

139 
"*All" :: [idts, bool] => bool ("(3\\<forall>_./ _)" [0, 10] 10) 

140 
"*Ex" :: [idts, bool] => bool ("(3\\<exists>_./ _)" [0, 10] 10) 

141 
"*Ex1" :: [idts, bool] => bool ("(3\\<exists>!_./ _)" [0, 10] 10) 

142 

2260  143 

144 

145 
(** Rules and definitions **) 

146 

3947  147 
local 
148 

923  149 
rules 
150 

151 
eq_reflection "(x=y) ==> (x==y)" 

152 

153 
(* Basic Rules *) 

154 

155 
refl "t = (t::'a)" 

156 
subst "[ s = t; P(s) ] ==> P(t::'a)" 

3842  157 
ext "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" 
158 
selectI "P (x::'a) ==> P (@x. P x)" 

923  159 

160 
impI "(P ==> Q) ==> P>Q" 

161 
mp "[ P>Q; P ] ==> Q" 

162 

163 
defs 

164 

3842  165 
True_def "True == ((%x::bool. x) = (%x. x))" 
166 
All_def "All(P) == (P = (%x. True))" 

167 
Ex_def "Ex(P) == P(@x. P(x))" 

168 
False_def "False == (!P. P)" 

923  169 
not_def "~ P == P>False" 
170 
and_def "P & Q == !R. (P>Q>R) > R" 

171 
or_def "P  Q == !R. (P>R) > (Q>R) > R" 

172 
Ex1_def "Ex1(P) == ? x. P(x) & (! y. P(y) > y=x)" 

173 

174 
rules 

175 
(* Axioms *) 

176 

177 
iff "(P>Q) > (Q>P) > (P=Q)" 

178 
True_or_False "(P=True)  (P=False)" 

179 

180 
defs 

5069  181 
(*misc definitions*) 
923  182 
Let_def "Let s f == f(s)" 
183 
o_def "(f::'b=>'c) o g == (%(x::'a). f(g(x)))" 

973  184 
if_def "If P x y == @z::'a. (P=True > z=x) & (P=False > z=y)" 
5069  185 

186 
(*arbitrary is completely unspecified, but is made to appear as a 

187 
definition syntactically*) 

4371
8755cdbbf6b3
improved arbitrary_def: we now really don't know nothing about it!
wenzelm
parents:
4083
diff
changeset

188 
arbitrary_def "False ==> arbitrary == (@x. False)" 
923  189 

3320  190 

4868  191 

192 
(** initial HOL theory setup **) 

193 

194 
setup Simplifier.setup 

195 
setup ClasetThyData.setup 

196 
setup ThyData.setup 

197 

198 

923  199 
end 
200 

2260  201 

923  202 
ML 
203 

4793  204 

923  205 
(** Choice between the HOL and Isabelle style of quantifiers **) 
206 

207 
val HOL_quantifiers = ref true; 

208 

209 
fun alt_ast_tr' (name, alt_name) = 

210 
let 

211 
fun ast_tr' (*name*) args = 

212 
if ! HOL_quantifiers then raise Match 

213 
else Syntax.mk_appl (Syntax.Constant alt_name) args; 

214 
in 

215 
(name, ast_tr') 

216 
end; 

217 

218 

219 
val print_ast_translation = 

220 
map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")]; 