author  wenzelm 
Wed, 27 Nov 1996 16:51:15 +0100  
changeset 2260  b59781f2b809 
parent 1674  33aff4d854e4 
child 2368  d394336997cf 
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 

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) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

33 
not :: bool => bool ("~ _" [40] 40) 
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) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

36 
Inv :: ('a => 'b) => ('b => 'a) 
923  37 

38 
(* Binders *) 

39 

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

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

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

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

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

44 
Let :: ['a, 'a => 'b] => 'b 
923  45 

46 
(* Infixes *) 

47 

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

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

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

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

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

52 
">" :: [bool, bool] => bool (infixr 25) 
923  53 

2260  54 

55 
(* Overloaded Constants *) 

56 

57 
axclass 

58 
plus < term 

923  59 

2260  60 
axclass 
61 
minus < term 

62 

63 
axclass 

64 
times < term 

65 

66 
consts 

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

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

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

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

71 

2260  72 

73 
(** Additional concrete syntax **) 

74 

923  75 
types 
76 
letbinds letbind 

77 
case_syn cases_syn 

78 

79 
syntax 

80 

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

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

2260  83 
"@Eps" :: [pttrn, bool] => 'a ("(3@ _./ _)" 10) 
1068  84 

923  85 
(* Alternative Quantifiers *) 
86 

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

87 
"*All" :: [idts, bool] => bool ("(3ALL _./ _)" 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

88 
"*Ex" :: [idts, bool] => bool ("(3EX _./ _)" 10) 
7361ac9b024d
removed quotes from types in consts and syntax sections
clasohm
parents:
1273
diff
changeset

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

91 
(* Let expressions *) 

92 

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

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

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

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

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

98 
(* Case expressions *) 

99 

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

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

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

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

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

105 
translations 

106 
"x ~= y" == "~ (x = y)" 

2260  107 
"@ x.b" == "Eps (%x. b)" 
923  108 
"ALL xs. P" => "! xs. P" 
109 
"EX xs. P" => "? xs. P" 

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

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

1114  112 
"let x = a in e" == "Let a (%x. e)" 
923  113 

2260  114 

115 
syntax (symbols) 

116 
not :: bool => bool ("\\<not> _" [40] 40) 

117 
"op &" :: [bool, bool] => bool (infixr "\\<and>" 35) 

118 
"op " :: [bool, bool] => bool (infixr "\\<or>" 30) 

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

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

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

122 
"@Eps" :: [pttrn, bool] => 'a ("(3\\<epsilon>_./ _)" 10) 

123 
"! " :: [idts, bool] => bool ("(3\\<forall>_./ _)" 10) 

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

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

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

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

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

129 
"@case1" :: ['a, 'b] => case_syn ("(2_ \\<mapsto>/ _)" 10) 

130 

131 

132 

133 
(** Rules and definitions **) 

134 

923  135 
rules 
136 

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

138 

139 
(* Basic Rules *) 

140 

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

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

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

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

145 

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

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

148 

149 
defs 

150 

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

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

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

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

155 
not_def "~ P == P>False" 

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

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

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

159 

160 
rules 

161 
(* Axioms *) 

162 

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

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

165 

166 
defs 

167 
(* Misc Definitions *) 

168 

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

170 
Inv_def "Inv(f::'a=>'b) == (% y. @x. f(x)=y)" 

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

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

1273  174 
(* start 8bit 1 *) 
175 
(* end 8bit 1 *) 

176 

923  177 
end 
178 

2260  179 

923  180 
ML 
181 

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

183 

184 
val HOL_quantifiers = ref true; 

185 

186 
fun alt_ast_tr' (name, alt_name) = 

187 
let 

188 
fun ast_tr' (*name*) args = 

189 
if ! HOL_quantifiers then raise Match 

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

191 
in 

192 
(name, ast_tr') 

193 
end; 

194 

195 

196 
val print_ast_translation = 

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

1273  198 

199 
(* start 8bit 2 *) 

200 
(* end 8bit 2 *) 