src/Pure/axclass.ML
changeset 24589 d3fca349736c
parent 24271 499608101177
child 24681 9d4982db0742
equal deleted inserted replaced
24588:ed9a1254d674 24589:d3fca349736c
     6 definitions and proofs.
     6 definitions and proofs.
     7 *)
     7 *)
     8 
     8 
     9 signature AX_CLASS =
     9 signature AX_CLASS =
    10 sig
    10 sig
       
    11   val define_class: bstring * class list -> string list ->
       
    12     ((bstring * attribute list) * term list) list -> theory -> class * theory
       
    13   val define_class_params: bstring * class list -> ((bstring * typ) * mixfix) list ->
       
    14     (theory -> (string * typ) list -> ((bstring * attribute list) * term list) list) ->
       
    15     string list -> theory ->
       
    16     (class * ((string * typ) list * thm list)) * theory
       
    17   val add_classrel: thm -> theory -> theory
       
    18   val add_arity: thm -> theory -> theory
       
    19   val prove_classrel: class * class -> tactic -> theory -> theory
       
    20   val prove_arity: string * sort list * sort -> tactic -> theory -> theory
    11   val get_definition: theory -> class -> {def: thm, intro: thm, axioms: thm list,
    21   val get_definition: theory -> class -> {def: thm, intro: thm, axioms: thm list,
    12     params: (string * typ) list}
    22     params: (string * typ) list}
    13   val class_intros: theory -> thm list
    23   val class_intros: theory -> thm list
    14   val class_of_param: theory -> string -> class option
    24   val class_of_param: theory -> string -> class option
    15   val params_of_class: theory -> class -> string * (string * typ) list
    25   val params_of_class: theory -> class -> string * (string * typ) list
    16   val param_tyvarname: string
    26   val param_tyvarname: string
    17   val print_axclasses: theory -> unit
    27   val print_axclasses: theory -> unit
    18   val cert_classrel: theory -> class * class -> class * class
    28   val cert_classrel: theory -> class * class -> class * class
    19   val read_classrel: theory -> xstring * xstring -> class * class
    29   val read_classrel: theory -> xstring * xstring -> class * class
    20   val add_classrel: thm -> theory -> theory
       
    21   val add_arity: thm -> theory -> theory
       
    22   val prove_classrel: class * class -> tactic -> theory -> theory
       
    23   val prove_arity: string * sort list * sort -> tactic -> theory -> theory
       
    24   val define_class: bstring * class list -> string list ->
       
    25     ((bstring * attribute list) * term list) list -> theory -> class * theory
       
    26   val axiomatize_class: bstring * xstring list -> theory -> theory
    30   val axiomatize_class: bstring * xstring list -> theory -> theory
    27   val axiomatize_class_i: bstring * class list -> theory -> theory
    31   val axiomatize_class_i: bstring * class list -> theory -> theory
    28   val axiomatize_classrel: (xstring * xstring) list -> theory -> theory
    32   val axiomatize_classrel: (xstring * xstring) list -> theory -> theory
    29   val axiomatize_classrel_i: (class * class) list -> theory -> theory
    33   val axiomatize_classrel_i: (class * class) list -> theory -> theory
    30   val axiomatize_arity: xstring * string list * string -> theory -> theory
    34   val axiomatize_arity: xstring * string list * string -> theory -> theory
   354       |> map_axclasses (fn (axclasses, parameters) =>
   358       |> map_axclasses (fn (axclasses, parameters) =>
   355         (Symtab.update (class, axclass) axclasses,
   359         (Symtab.update (class, axclass) axclasses,
   356           fold (fn x => add_param pp (x, class)) params parameters));
   360           fold (fn x => add_param pp (x, class)) params parameters));
   357 
   361 
   358   in (class, result_thy) end;
   362   in (class, result_thy) end;
       
   363 
       
   364 
       
   365 
       
   366 (** axclasses with implicit parameter handling **)
       
   367 
       
   368 fun define_class_params (name, raw_superclasses) raw_consts raw_dep_axioms other_consts thy =
       
   369   let
       
   370     val superclasses = map (Sign.certify_class thy) raw_superclasses;
       
   371     val consts = (map o apfst o apsnd) (Sign.certify_typ thy) raw_consts;
       
   372     val prefix = Logic.const_of_class name;
       
   373     fun mk_const_name c = NameSpace.map_base (NameSpace.append prefix)
       
   374       (Sign.full_name thy c);
       
   375     fun add_const ((c, ty), syn) =
       
   376       Sign.add_consts_authentic [(c, ty, syn)]
       
   377       #> pair (mk_const_name c, ty);
       
   378     fun mk_axioms cs thy =
       
   379       raw_dep_axioms thy cs
       
   380       |> (map o apsnd o map) (Sign.cert_prop thy)
       
   381       |> rpair thy;
       
   382     fun add_constraint class (c, ty) =
       
   383       Sign.add_const_constraint_i (c, SOME
       
   384         (Term.map_type_tfree (fn (v, _) => TFree (v, [class])) ty));
       
   385   in
       
   386     thy
       
   387     |> Theory.add_path prefix
       
   388     |> fold_map add_const consts
       
   389     ||> Theory.restore_naming thy
       
   390     |-> (fn cs => mk_axioms cs
       
   391     #-> (fn axioms_prop => define_class (name, superclasses)
       
   392            (map fst cs @ other_consts) axioms_prop
       
   393     #-> (fn class => `(fn thy => get_definition thy class)
       
   394     #-> (fn {axioms, ...} => fold (add_constraint class) cs
       
   395     #> pair (class, (cs, axioms))))))
       
   396   end;
   359 
   397 
   360 
   398 
   361 
   399 
   362 (** axiomatizations **)
   400 (** axiomatizations **)
   363 
   401