author  wenzelm 
Wed, 04 Jun 1997 12:26:42 +0200  
changeset 3395  d8700b008944 
parent 2961  842be30dc336 
child 3632  17527284f100 
permissions  rwrr 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

1 
(* Title: Pure/axclass.ML 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

2 
ID: $Id$ 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

3 
Author: Markus Wenzel, TU Muenchen 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

4 

560  5 
User interfaces for axiomatic type classes. 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

6 
*) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

7 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

8 
signature AX_CLASS = 
1498  9 
sig 
10 
val add_thms_as_axms: (string * thm) list > theory > theory 

11 
val add_classrel_thms: thm list > theory > theory 

12 
val add_arity_thms: thm list > theory > theory 

13 
val add_axclass: class * class list > (string * string) list 

14 
> theory > theory 

15 
val add_axclass_i: class * class list > (string * term) list 

16 
> theory > theory 

17 
val add_inst_subclass: class * class > string list > thm list 

18 
> tactic option > theory > theory 

19 
val add_inst_arity: string * sort list * class list > string list 

20 
> thm list > tactic option > theory > theory 

21 
val axclass_tac: theory > thm list > tactic 

22 
val prove_subclass: theory > class * class > thm list 

23 
> tactic option > thm 

24 
val prove_arity: theory > string * sort list * class > thm list 

25 
> tactic option > thm 

26 
val goal_subclass: theory > class * class > thm list 

27 
val goal_arity: theory > string * sort list * class > thm list 

28 
end; 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

29 

1498  30 
structure AxClass : AX_CLASS = 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

31 
struct 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

32 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

33 
(** utilities **) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

34 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

35 
(* type vars *) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

36 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

37 
fun map_typ_frees f (Type (t, tys)) = Type (t, map (map_typ_frees f) tys) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

38 
 map_typ_frees f (TFree a) = f a 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

39 
 map_typ_frees _ a = a; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

40 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

41 
val map_term_tfrees = map_term_types o map_typ_frees; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

42 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

43 
fun aT S = TFree ("'a", S); 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

44 

3395  45 
fun dest_varT (TFree (x, S)) = ((x, ~1), S) 
46 
 dest_varT (TVar xi_S) = xi_S 

47 
 dest_varT T = raise_type "dest_varT" [T] []; 

48 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

49 

886
9af08725600b
instance: now automatically includes defs of current thy node as witnesses;
wenzelm
parents:
638
diff
changeset

50 
(* get axioms and theorems *) 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

51 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

52 
fun get_ax thy name = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

53 
Some (get_axiom thy name) handle THEORY _ => None; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

54 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

55 
val get_axioms = mapfilter o get_ax; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

56 

1498  57 
val is_def = Logic.is_equals o #prop o rep_thm; 
886
9af08725600b
instance: now automatically includes defs of current thy node as witnesses;
wenzelm
parents:
638
diff
changeset

58 

9af08725600b
instance: now automatically includes defs of current thy node as witnesses;
wenzelm
parents:
638
diff
changeset

59 
fun witnesses thy axms thms = 
1201
de2fc8cf9b6a
minor fix: instance now raises error if witness axioms don't exist;
wenzelm
parents:
886
diff
changeset

60 
map (get_axiom thy) axms @ thms @ filter is_def (map snd (axioms_of thy)); 
886
9af08725600b
instance: now automatically includes defs of current thy node as witnesses;
wenzelm
parents:
638
diff
changeset

61 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

62 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

63 

560  64 
(** abstract syntax operations **) 
423  65 

66 
(* subclass relations as terms *) 

67 

1498  68 
fun mk_classrel (c1, c2) = Logic.mk_inclass (aT [c1], c2); 
423  69 

70 
fun dest_classrel tm = 

71 
let 

72 
fun err () = raise_term "dest_classrel" [tm]; 

73 

3395  74 
val (ty, c2) = Logic.dest_inclass tm handle TERM _ => err (); 
75 
val c1 = (case dest_varT ty of (_, [c]) => c  _ => err ()) 

76 
handle TYPE _ => err (); 

423  77 
in 
78 
(c1, c2) 

79 
end; 

80 

81 

82 
(* arities as terms *) 

83 

84 
fun mk_arity (t, ss, c) = 

85 
let 

449  86 
val names = tl (variantlist (replicate (length ss + 1) "'", [])); 
2266  87 
val tfrees = ListPair.map TFree (names, ss); 
423  88 
in 
1498  89 
Logic.mk_inclass (Type (t, tfrees), c) 
423  90 
end; 
91 

92 
fun dest_arity tm = 

93 
let 

94 
fun err () = raise_term "dest_arity" [tm]; 

95 

3395  96 
val (ty, c) = Logic.dest_inclass tm handle TERM _ => err (); 
97 
val (t, tvars) = 

423  98 
(case ty of 
3395  99 
Type (t, tys) => (t, map dest_varT tys handle TYPE _ => err ()) 
423  100 
 _ => err ()); 
101 
val ss = 

3395  102 
if null (gen_duplicates eq_fst tvars) 
103 
then map snd tvars else err (); 

423  104 
in 
105 
(t, ss, c) 

106 
end; 

107 

108 

109 

560  110 
(** add theorems as axioms **) 
423  111 

112 
fun prep_thm_axm thy thm = 

113 
let 

114 
fun err msg = raise THM ("prep_thm_axm: " ^ msg, 0, [thm]); 

115 

1237  116 
val {sign, hyps, prop, ...} = rep_thm thm; 
423  117 
in 
118 
if not (Sign.subsig (sign, sign_of thy)) then 

119 
err "theorem not of same theory" 

1237  120 
else if not (null (extra_shyps thm)) orelse not (null hyps) then 
423  121 
err "theorem may not contain hypotheses" 
122 
else prop 

123 
end; 

124 

125 
(*general theorems*) 

126 
fun add_thms_as_axms thms thy = 

127 
add_axioms_i (map (apsnd (prep_thm_axm thy)) thms) thy; 

128 

129 
(*theorems expressing class relations*) 

130 
fun add_classrel_thms thms thy = 

131 
let 

132 
fun prep_thm thm = 

133 
let 

134 
val prop = prep_thm_axm thy thm; 

135 
val (c1, c2) = dest_classrel prop handle TERM _ => 

136 
raise THM ("add_classrel_thms: theorem is not a class relation", 0, [thm]); 

137 
in (c1, c2) end; 

138 
in 

139 
add_classrel (map prep_thm thms) thy 

140 
end; 

141 

142 
(*theorems expressing arities*) 

143 
fun add_arity_thms thms thy = 

144 
let 

145 
fun prep_thm thm = 

146 
let 

147 
val prop = prep_thm_axm thy thm; 

148 
val (t, ss, c) = dest_arity prop handle TERM _ => 

149 
raise THM ("add_arity_thms: theorem is not an arity", 0, [thm]); 

150 
in (t, ss, [c]) end; 

151 
in 

152 
add_arities (map prep_thm thms) thy 

153 
end; 

154 

155 

156 

157 
(** add axiomatic type classes **) 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

158 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

159 
(* errors *) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

160 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

161 
fun err_not_logic c = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

162 
error ("Axiomatic class " ^ quote c ^ " not subclass of \"logic\""); 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

163 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

164 
fun err_bad_axsort ax c = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

165 
error ("Sort constraint in axiom " ^ quote ax ^ " not supersort of " ^ quote c); 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

166 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

167 
fun err_bad_tfrees ax = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

168 
error ("More than one type variable in axiom " ^ quote ax); 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

169 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

170 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

171 
(* ext_axclass *) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

172 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

173 
fun ext_axclass prep_axm (class, super_classes) raw_axioms old_thy = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

174 
let 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

175 
val axioms = map (prep_axm (sign_of old_thy)) raw_axioms; 
560  176 
val thy = add_classes [(class, super_classes)] old_thy; 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

177 
val sign = sign_of thy; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

178 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

179 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

180 
(* prepare abstract axioms *) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

181 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

182 
fun abs_axm ax = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

183 
if null (term_tfrees ax) then 
1498  184 
Logic.mk_implies (Logic.mk_inclass (aT logicS, class), ax) 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

185 
else 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

186 
map_term_tfrees (K (aT [class])) ax; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

187 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

188 
val abs_axioms = map (apsnd abs_axm) axioms; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

189 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

190 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

191 
(* prepare introduction orule *) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

192 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

193 
val _ = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

194 
if Sign.subsort sign ([class], logicS) then () 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

195 
else err_not_logic class; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

196 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

197 
fun axm_sort (name, ax) = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

198 
(case term_tfrees ax of 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

199 
[] => [] 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

200 
 [(_, S)] => 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

201 
if Sign.subsort sign ([class], S) then S 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

202 
else err_bad_axsort name class 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

203 
 _ => err_bad_tfrees name); 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

204 

2672
85d7e800d754
Replaced "flat" by the Basis Library function List.concat
paulson
parents:
2266
diff
changeset

205 
val axS = Sign.norm_sort sign (logicC :: List.concat(map axm_sort axioms)) 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

206 

1498  207 
val int_axm = Logic.close_form o map_term_tfrees (K (aT axS)); 
208 
fun inclass c = Logic.mk_inclass (aT axS, c); 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

209 

1498  210 
val intro_axm = Logic.list_implies 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

211 
(map inclass super_classes @ map (int_axm o snd) axioms, inclass class); 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

212 
in 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

213 
add_axioms_i ((class ^ "I", intro_axm) :: abs_axioms) thy 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

214 
end; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

215 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

216 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

217 
(* external interfaces *) 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

218 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

219 
val add_axclass = ext_axclass read_axm; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

220 
val add_axclass_i = ext_axclass cert_axm; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

221 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

222 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

223 

423  224 
(** prove class relations and type arities **) 
225 

226 
(* class_axms *) 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

227 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

228 
fun class_axms thy = 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

229 
let 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

230 
val classes = Sign.classes (sign_of thy); 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

231 
val intros = map (fn c => c ^ "I") classes; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

232 
in 
1217  233 
map (class_triv thy) classes @ 
234 
get_axioms thy intros 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

235 
end; 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

236 

423  237 

238 
(* axclass_tac *) 

239 

487
af83700cb771
added experimental add_defns (actually should be moved somewhere else);
wenzelm
parents:
474
diff
changeset

240 
(*(1) repeatedly resolve goals of form "OFCLASS(ty, c_class)", 
1217  241 
try class_trivs first, then "cI" axioms 
423  242 
(2) rewrite goals using user supplied definitions 
243 
(3) repeatedly resolve goals with user supplied nondefinitions*) 

244 

245 
fun axclass_tac thy thms = 

1217  246 
let 
247 
val defs = filter is_def thms; 

248 
val non_defs = filter_out is_def thms; 

249 
in 

250 
TRY (REPEAT_FIRST (resolve_tac (class_axms thy))) THEN 

251 
TRY (rewrite_goals_tac defs) THEN 

252 
TRY (REPEAT_FIRST (fn i => assume_tac i ORELSE resolve_tac non_defs i)) 

253 
end; 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

254 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

255 

423  256 
(* provers *) 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

257 

423  258 
fun prove term_of str_of thy sig_prop thms usr_tac = 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

259 
let 
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

260 
val sign = sign_of thy; 
423  261 
val goal = cterm_of sign (term_of sig_prop); 
262 
val tac = axclass_tac thy thms THEN (if_none usr_tac all_tac); 

263 
in 

264 
prove_goalw_cterm [] goal (K [tac]) 

265 
end 

266 
handle ERROR => error ("The error(s) above occurred while trying to prove " 

267 
^ quote (str_of sig_prop)); 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

268 

638  269 
val prove_subclass = 
423  270 
prove mk_classrel (fn (c1, c2) => c1 ^ " < " ^ c2); 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

271 

423  272 
val prove_arity = 
2961  273 
prove mk_arity (fn (t, ss, c) => Sorts.str_of_arity (t, ss, [c])); 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

274 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

275 

423  276 
(* make goals (for interactive use) *) 
277 

278 
fun mk_goal term_of thy sig_prop = 

279 
goalw_cterm [] (cterm_of (sign_of thy) (term_of sig_prop)); 

280 

281 
val goal_subclass = mk_goal mk_classrel; 

282 
val goal_arity = mk_goal mk_arity; 

283 

284 

285 

449  286 
(** add proved subclass relations and arities **) 
404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

287 

449  288 
fun add_inst_subclass (c1, c2) axms thms usr_tac thy = 
423  289 
add_classrel_thms 
886
9af08725600b
instance: now automatically includes defs of current thy node as witnesses;
wenzelm
parents:
638
diff
changeset

290 
[prove_subclass thy (c1, c2) (witnesses thy axms thms) usr_tac] thy; 
423  291 

449  292 
fun add_inst_arity (t, ss, cs) axms thms usr_tac thy = 
423  293 
let 
886
9af08725600b
instance: now automatically includes defs of current thy node as witnesses;
wenzelm
parents:
638
diff
changeset

294 
val wthms = witnesses thy axms thms; 
423  295 
fun prove c = 
886
9af08725600b
instance: now automatically includes defs of current thy node as witnesses;
wenzelm
parents:
638
diff
changeset

296 
prove_arity thy (t, ss, c) wthms usr_tac; 
423  297 
in 
298 
add_arity_thms (map prove cs) thy 

299 
end; 

404
dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

300 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

301 

dd3d3d6467db
axiomatic type class 'package' for Pure (alpha version);
wenzelm
parents:
diff
changeset

302 
end; 