author  wenzelm 
Tue, 20 May 1997 12:22:33 +0200  
changeset 3248  3e1664348551 
parent 3230  3772723c5e41 
child 3320  3a5e4930fb77 
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 

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 

3230
3772723c5e41
improved output syntax of op =, op ~= (more parentheses);
wenzelm
parents:
3068
diff
changeset

28 
syntax ("" output) 
3772723c5e41
improved output syntax of op =, op ~= (more parentheses);
wenzelm
parents:
3068
diff
changeset

29 
"op =" :: ['a, 'a] => bool ("(_ =/ _)" [51, 51] 50) 
3772723c5e41
improved output syntax of op =, op ~= (more parentheses);
wenzelm
parents:
3068
diff
changeset

30 
"op ~=" :: ['a, 'a] => bool ("(_ ~=/ _)" [51, 51] 50) 
3772723c5e41
improved output syntax of op =, op ~= (more parentheses);
wenzelm
parents:
3068
diff
changeset

31 

923  32 
consts 
33 

34 
(* Constants *) 

35 

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

36 
Trueprop :: bool => prop ("(_)" 5) 
2720  37 
Not :: bool => bool ("~ _" [40] 40) 
1370
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

38 
True, False :: bool 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

39 
If :: [bool, 'a, 'a] => 'a ("(if (_)/ then (_)/ else (_))" 10) 
923  40 

41 
(* Binders *) 

42 

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

43 
Eps :: ('a => bool) => 'a 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

44 
All :: ('a => bool) => bool (binder "! " 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

45 
Ex :: ('a => bool) => bool (binder "? " 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

46 
Ex1 :: ('a => bool) => bool (binder "?! " 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

47 
Let :: ['a, 'a => 'b] => 'b 
923  48 

49 
(* Infixes *) 

50 

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

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

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

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

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

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

2260  57 

58 
(* Overloaded Constants *) 

59 

60 
axclass 

61 
plus < term 

923  62 

2260  63 
axclass 
64 
minus < term 

65 

66 
axclass 

67 
times < term 

68 

69 
consts 

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

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

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

72 
"*" :: ['a::times, 'a] => 'a (infixl 70) 
923  73 

74 

2260  75 

76 
(** Additional concrete syntax **) 

77 

923  78 
types 
79 
letbinds letbind 

80 
case_syn cases_syn 

81 

82 
syntax 

83 

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

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

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

923  88 
(* Alternative Quantifiers *) 
89 

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

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

923  93 

94 
(* Let expressions *) 

95 

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

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

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

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

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

101 
(* Case expressions *) 

102 

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

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

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

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

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

108 
translations 

109 
"x ~= y" == "~ (x = y)" 

2260  110 
"@ x.b" == "Eps (%x. b)" 
923  111 
"ALL xs. P" => "! xs. P" 
112 
"EX xs. P" => "? xs. P" 

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

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

1114  115 
"let x = a in e" == "Let a (%x. e)" 
923  116 

3230
3772723c5e41
improved output syntax of op =, op ~= (more parentheses);
wenzelm
parents:
3068
diff
changeset

117 
syntax (symbols output) 
3772723c5e41
improved output syntax of op =, op ~= (more parentheses);
wenzelm
parents:
3068
diff
changeset

118 
"op ~=" :: ['a, 'a] => bool ("(_ \\<noteq>/ _)" [51, 51] 50) 
3248  119 
"*All" :: [idts, bool] => bool ("(3\\<forall>_./ _)" [0, 10] 10) 
120 
"*Ex" :: [idts, bool] => bool ("(3\\<exists>_./ _)" [0, 10] 10) 

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

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 

2260  137 

138 

139 
(** Rules and definitions **) 

140 

923  141 
rules 
142 

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

144 

145 
(* Basic Rules *) 

146 

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

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

149 
ext "(!!x::'a. (f(x)::'b) = g(x)) ==> (%x.f(x)) = (%x.g(x))" 

150 
selectI "P(x::'a) ==> P(@x.P(x))" 

151 

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

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

154 

155 
defs 

156 

157 
True_def "True == ((%x::bool.x)=(%x.x))" 

158 
All_def "All(P) == (P = (%x.True))" 

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

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

161 
not_def "~ P == P>False" 

162 
and_def "P & Q == !R. (P>Q>R) > R" 

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

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

165 

166 
rules 

167 
(* Axioms *) 

168 

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

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

171 

172 
defs 

173 
(* Misc Definitions *) 

174 

175 
Let_def "Let s f == f(s)" 

176 
o_def "(f::'b=>'c) o g == (%(x::'a). f(g(x)))" 

973  177 
if_def "If P x y == @z::'a. (P=True > z=x) & (P=False > z=y)" 
923  178 

179 
end 

180 

2260  181 

923  182 
ML 
183 

184 
(** Choice between the HOL and Isabelle style of quantifiers **) 

185 

186 
val HOL_quantifiers = ref true; 

187 

188 
fun alt_ast_tr' (name, alt_name) = 

189 
let 

190 
fun ast_tr' (*name*) args = 

191 
if ! HOL_quantifiers then raise Match 

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

193 
in 

194 
(name, ast_tr') 

195 
end; 

196 

197 

198 
val print_ast_translation = 

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