27 val axclass_tac: thm list -> tactic |
27 val axclass_tac: thm list -> tactic |
28 val instance_subclass_proof: xclass * xclass -> bool -> theory -> ProofHistory.T |
28 val instance_subclass_proof: xclass * xclass -> bool -> theory -> ProofHistory.T |
29 val instance_subclass_proof_i: class * class -> bool -> theory -> ProofHistory.T |
29 val instance_subclass_proof_i: class * class -> bool -> theory -> ProofHistory.T |
30 val instance_arity_proof: xstring * string list * string -> bool -> theory -> ProofHistory.T |
30 val instance_arity_proof: xstring * string list * string -> bool -> theory -> ProofHistory.T |
31 val instance_arity_proof_i: string * sort list * sort -> bool -> theory -> ProofHistory.T |
31 val instance_arity_proof_i: string * sort list * sort -> bool -> theory -> ProofHistory.T |
32 val setup: (theory -> theory) list |
|
33 end; |
32 end; |
34 |
33 |
35 structure AxClass : AX_CLASS = |
34 structure AxClass: AX_CLASS = |
36 struct |
35 struct |
37 |
36 |
38 |
37 |
39 (** utilities **) |
38 (** utilities **) |
40 |
39 |
190 [pretty_class name super_classes, pretty_thms introN [intro], pretty_thms axiomsN axioms]); |
189 [pretty_class name super_classes, pretty_thms introN [intro], pretty_thms axiomsN axioms]); |
191 in Pretty.writeln (Pretty.chunks (map pretty_axclass (Symtab.dest tab))) end; |
190 in Pretty.writeln (Pretty.chunks (map pretty_axclass (Symtab.dest tab))) end; |
192 end; |
191 end; |
193 |
192 |
194 structure AxclassesData = TheoryDataFun(AxclassesArgs); |
193 structure AxclassesData = TheoryDataFun(AxclassesArgs); |
|
194 val _ = Context.add_setup [AxclassesData.init]; |
195 val print_axclasses = AxclassesData.print; |
195 val print_axclasses = AxclassesData.print; |
196 |
196 |
197 |
197 |
198 (* get and put data *) |
198 (* get and put data *) |
199 |
199 |
290 map (Thm.class_triv sign) classes @ |
290 map (Thm.class_triv sign) classes @ |
291 List.mapPartial (Option.map #intro o lookup_axclass_info_sg sign) classes |
291 List.mapPartial (Option.map #intro o lookup_axclass_info_sg sign) classes |
292 end; |
292 end; |
293 |
293 |
294 |
294 |
295 (* intro_classes *) |
295 (* proof methods *) |
296 |
296 |
297 fun intro_classes_tac facts st = |
297 fun intro_classes_tac facts st = |
298 (ALLGOALS (Method.insert_tac facts THEN' |
298 (ALLGOALS (Method.insert_tac facts THEN' |
299 REPEAT_ALL_NEW (resolve_tac (class_axms (Thm.sign_of_thm st)))) |
299 REPEAT_ALL_NEW (resolve_tac (class_axms (Thm.sign_of_thm st)))) |
300 THEN Tactic.distinct_subgoals_tac) st; |
300 THEN Tactic.distinct_subgoals_tac) st; |
301 |
301 |
302 val intro_classes_method = |
|
303 ("intro_classes", Method.no_args (Method.METHOD intro_classes_tac), |
|
304 "back-chain introduction rules of axiomatic type classes"); |
|
305 |
|
306 |
|
307 (* default method *) |
|
308 |
|
309 fun default_intro_classes_tac [] = intro_classes_tac [] |
302 fun default_intro_classes_tac [] = intro_classes_tac [] |
310 | default_intro_classes_tac _ = Tactical.no_tac; (*no error message!*) |
303 | default_intro_classes_tac _ = Tactical.no_tac; (*no error message!*) |
311 |
304 |
312 fun default_tac rules ctxt facts = |
305 fun default_tac rules ctxt facts = |
313 HEADGOAL (Method.some_rule_tac rules ctxt facts) ORELSE |
306 HEADGOAL (Method.some_rule_tac rules ctxt facts) ORELSE |
314 default_intro_classes_tac facts; |
307 default_intro_classes_tac facts; |
315 |
308 |
316 val default_method = |
309 val _ = Context.add_setup [Method.add_methods |
317 ("default", Method.thms_ctxt_args (Method.METHOD oo default_tac), "apply some intro/elim rule"); |
310 [("intro_classes", Method.no_args (Method.METHOD intro_classes_tac), |
|
311 "back-chain introduction rules of axiomatic type classes"), |
|
312 ("default", Method.thms_ctxt_args (Method.METHOD oo default_tac), "apply some intro/elim rule")]]; |
318 |
313 |
319 |
314 |
320 (* old-style axclass_tac *) |
315 (* old-style axclass_tac *) |
321 |
316 |
322 (*(1) repeatedly resolve goals of form "OFCLASS(ty, c_class)", |
317 (*(1) repeatedly resolve goals of form "OFCLASS(ty, c_class)", |
417 inst_proof (single oo (mk_classrel oo cert_classrel)) add_classrel_thms; |
412 inst_proof (single oo (mk_classrel oo cert_classrel)) add_classrel_thms; |
418 val instance_arity_proof = inst_proof (mk_arities oo read_arity) add_arity_thms; |
413 val instance_arity_proof = inst_proof (mk_arities oo read_arity) add_arity_thms; |
419 val instance_arity_proof_i = inst_proof (mk_arities oo cert_arity) add_arity_thms; |
414 val instance_arity_proof_i = inst_proof (mk_arities oo cert_arity) add_arity_thms; |
420 |
415 |
421 |
416 |
422 |
|
423 (** package setup **) |
|
424 |
|
425 (* setup theory *) |
|
426 |
|
427 val setup = |
|
428 [AxclassesData.init, |
|
429 Method.add_methods [intro_classes_method, default_method]]; |
|
430 |
|
431 |
|
432 (* outer syntax *) |
417 (* outer syntax *) |
433 |
418 |
434 local structure P = OuterParse and K = OuterSyntax.Keyword in |
419 local structure P = OuterParse and K = OuterSyntax.Keyword in |
435 |
420 |
436 val axclassP = |
421 val axclassP = |