src/Pure/Isar/class.ML
changeset 27684 f45fd1159a4b
parent 27281 b457537e789a
child 27690 24738db98d34
equal deleted inserted replaced
27683:add9a605d562 27684:f45fd1159a4b
    20     -> (string * mixfix) * term -> theory -> theory
    20     -> (string * mixfix) * term -> theory -> theory
    21   val refresh_syntax: class -> Proof.context -> Proof.context
    21   val refresh_syntax: class -> Proof.context -> Proof.context
    22 
    22 
    23   val intro_classes_tac: thm list -> tactic
    23   val intro_classes_tac: thm list -> tactic
    24   val default_intro_tac: Proof.context -> thm list -> tactic
    24   val default_intro_tac: Proof.context -> thm list -> tactic
    25   val prove_subclass: class * class -> thm -> theory -> theory
    25   val prove_subclass: class * class -> thm option -> theory -> theory
    26 
    26 
    27   val class_prefix: string -> string
    27   val class_prefix: string -> string
    28   val is_class: theory -> class -> bool
    28   val is_class: theory -> class -> bool
    29   val these_params: theory -> sort -> (string * (class * (string * typ))) list
    29   val these_params: theory -> sort -> (string * (class * (string * typ))) list
    30   val print_classes: theory -> unit
    30   val print_classes: theory -> unit
   336       |> Thm.close_derivation;
   336       |> Thm.close_derivation;
   337     val this_intro = assm_intro |> the_default class_intro;
   337     val this_intro = assm_intro |> the_default class_intro;
   338   in
   338   in
   339     thy
   339     thy
   340     |> Sign.sticky_prefix (class_prefix class ^ "_" ^ AxClass.axiomsN)
   340     |> Sign.sticky_prefix (class_prefix class ^ "_" ^ AxClass.axiomsN)
   341     |> PureThy.note Thm.internalK (AxClass.introN, this_intro)
   341     |> PureThy.store_thm (AxClass.introN, this_intro)
   342     |> snd
   342     |> snd
   343     |> Sign.restore_naming thy
   343     |> Sign.restore_naming thy
   344     |> pair (morphism, axiom, assm_intro, of_class)
   344     |> pair (morphism, axiom, assm_intro, of_class)
   345   end;
   345   end;
   346 
   346 
   360     |> prove_interpretation tac ((false, prfx), []) (Locale.Locale class)
   360     |> prove_interpretation tac ((false, prfx), []) (Locale.Locale class)
   361           (inst, map (fn def => (("", []), def)) defs)
   361           (inst, map (fn def => (("", []), def)) defs)
   362     |> fold2 add_constraint (map snd consts) constraints
   362     |> fold2 add_constraint (map snd consts) constraints
   363   end;
   363   end;
   364 
   364 
   365 fun prove_subclass (sub, sup) thm thy =
   365 fun prove_subclass (sub, sup) some_thm thy =
   366   let
   366   let
   367     val of_class = (#of_class o the_class_data thy) sup;
   367     val of_class = (#of_class o the_class_data thy) sup;
   368     val intro = Drule.standard' (of_class OF [Drule.standard' thm]);
   368     val intro = case some_thm
   369     val classrel = intro OF (the_list o #axiom o the_class_data thy) sub;
   369      of SOME thm => Drule.standard' (of_class OF [Drule.standard' thm])
       
   370       | NONE => Thm.instantiate ([pairself (Thm.ctyp_of thy o TVar o pair (Name.aT, 0))
       
   371           ([], [sub])], []) of_class;
       
   372     val classrel = (intro OF (the_list o #axiom o the_class_data thy) sub)
       
   373       |> Thm.close_derivation;
   370   in
   374   in
   371     thy
   375     thy
   372     |> AxClass.add_classrel classrel
   376     |> AxClass.add_classrel classrel
   373     |> prove_interpretation_in (ALLGOALS (ProofContext.fact_tac [thm]))
   377     |> prove_interpretation_in (ALLGOALS (ProofContext.fact_tac (the_list some_thm)))
   374          I (sub, Locale.Locale sup)
   378          I (sub, Locale.Locale sup)
   375     |> ClassData.map (Graph.add_edge (sub, sup))
   379     |> ClassData.map (Graph.add_edge (sub, sup))
   376   end;
   380   end;
   377 
   381 
   378 fun intro_classes_tac facts st =
   382 fun intro_classes_tac facts st =
   555     val class = Sign.full_name thy bname;
   559     val class = Sign.full_name thy bname;
   556     val (((sups, supparams), (supsort, base_sort, mergeexpr)), (elems, global_syntax)) =
   560     val (((sups, supparams), (supsort, base_sort, mergeexpr)), (elems, global_syntax)) =
   557       prep_spec thy raw_supclasses raw_elems;
   561       prep_spec thy raw_supclasses raw_elems;
   558   in
   562   in
   559     thy
   563     thy
   560     |> Locale.add_locale_i (SOME "") bname mergeexpr elems
   564     |> Locale.add_locale_i "" bname mergeexpr elems
   561     |> snd
   565     |> snd
   562     |> ProofContext.theory_of
   566     |> ProofContext.theory_of
   563     |> adjungate_axclass bname class base_sort sups supsort supparams global_syntax
   567     |> adjungate_axclass bname class base_sort sups supsort supparams global_syntax
   564     |-> (fn (param_map, params, assm_axiom) =>
   568     |-> (fn (param_map, params, assm_axiom) =>
   565         calculate sups base_sort assm_axiom param_map class
   569         calculate sups base_sort assm_axiom param_map class
   600     |> Thm.add_def false false (c, def_eq)
   604     |> Thm.add_def false false (c, def_eq)
   601     |>> Thm.symmetric
   605     |>> Thm.symmetric
   602     ||>> get_axiom
   606     ||>> get_axiom
   603     |-> (fn (def, def') => class_interpretation class [def] [Thm.prop_of def]
   607     |-> (fn (def, def') => class_interpretation class [def] [Thm.prop_of def]
   604       #> register_operation class (c', (dict', SOME (Thm.symmetric def')))
   608       #> register_operation class (c', (dict', SOME (Thm.symmetric def')))
   605       #> PureThy.note Thm.internalK (c ^ "_raw", def')
   609       #> PureThy.store_thm (c ^ "_raw", def')
   606       #> snd)
   610       #> snd)
   607     |> Sign.restore_naming thy
   611     |> Sign.restore_naming thy
   608     |> Sign.add_const_constraint (c', SOME ty')
   612     |> Sign.add_const_constraint (c', SOME ty')
   609   end;
   613   end;
   610 
   614