src/Pure/axclass.ML
changeset 30344 10a67c5ddddb
parent 30280 eb98b49ef835
child 30364 577edc39b501
     1.1 --- a/src/Pure/axclass.ML	Sat Mar 07 22:12:07 2009 +0100
     1.2 +++ b/src/Pure/axclass.ML	Sat Mar 07 22:16:50 2009 +0100
     1.3 @@ -7,7 +7,7 @@
     1.4  
     1.5  signature AX_CLASS =
     1.6  sig
     1.7 -  val define_class: bstring * class list -> string list ->
     1.8 +  val define_class: binding * class list -> string list ->
     1.9      (Thm.binding * term list) list -> theory -> class * theory
    1.10    val add_classrel: thm -> theory -> theory
    1.11    val add_arity: thm -> theory -> theory
    1.12 @@ -19,8 +19,8 @@
    1.13    val class_of_param: theory -> string -> class option
    1.14    val cert_classrel: theory -> class * class -> class * class
    1.15    val read_classrel: theory -> xstring * xstring -> class * class
    1.16 -  val axiomatize_class: bstring * class list -> theory -> theory
    1.17 -  val axiomatize_class_cmd: bstring * xstring list -> theory -> theory
    1.18 +  val axiomatize_class: binding * class list -> theory -> theory
    1.19 +  val axiomatize_class_cmd: binding * xstring list -> theory -> theory
    1.20    val axiomatize_classrel: (class * class) list -> theory -> theory
    1.21    val axiomatize_classrel_cmd: (xstring * xstring) list -> theory -> theory
    1.22    val axiomatize_arity: arity -> theory -> theory
    1.23 @@ -325,8 +325,7 @@
    1.24    let
    1.25      val ctxt = ProofContext.init thy;
    1.26      val (c1, c2) = cert_classrel thy raw_rel;
    1.27 -    val th = Goal.prove ctxt [] []
    1.28 -        (Logic.mk_classrel (c1, c2)) (fn _ => tac) handle ERROR msg =>
    1.29 +    val th = Goal.prove ctxt [] [] (Logic.mk_classrel (c1, c2)) (K tac) handle ERROR msg =>
    1.30        cat_error msg ("The error(s) above occurred while trying to prove class relation " ^
    1.31          quote (Syntax.string_of_classrel ctxt [c1, c2]));
    1.32    in
    1.33 @@ -374,14 +373,15 @@
    1.34      |> Sign.sticky_prefix name_inst
    1.35      |> Sign.no_base_names
    1.36      |> Sign.declare_const [] ((Binding.name c', T'), NoSyn)
    1.37 -    |-> (fn const' as Const (c'', _) => Thm.add_def false true
    1.38 -          (Binding.name (Thm.def_name c'), Logic.mk_equals (Const (c, T'), const'))
    1.39 -    #>> Thm.varifyT
    1.40 -    #-> (fn thm => add_inst_param (c, tyco) (c'', thm)
    1.41 -    #> PureThy.add_thm ((Binding.name c', thm), [Thm.kind_internal])
    1.42 -    #> snd
    1.43 -    #> Sign.restore_naming thy
    1.44 -    #> pair (Const (c, T))))
    1.45 +    |-> (fn const' as Const (c'', _) =>
    1.46 +      Thm.add_def false true
    1.47 +        (Binding.name (Thm.def_name c'), Logic.mk_equals (Const (c, T'), const'))
    1.48 +      #>> Thm.varifyT
    1.49 +      #-> (fn thm => add_inst_param (c, tyco) (c'', thm)
    1.50 +      #> PureThy.add_thm ((Binding.name c', thm), [Thm.kind_internal])
    1.51 +      #> snd
    1.52 +      #> Sign.restore_naming thy
    1.53 +      #> pair (Const (c, T))))
    1.54    end;
    1.55  
    1.56  fun define_overloaded name (c, t) thy =
    1.57 @@ -390,8 +390,7 @@
    1.58      val SOME tyco = inst_tyco_of thy (c, T);
    1.59      val (c', eq) = get_inst_param thy (c, tyco);
    1.60      val prop = Logic.mk_equals (Const (c', T), t);
    1.61 -    val name' = Thm.def_name_optional
    1.62 -      (NameSpace.base_name c ^ "_" ^ NameSpace.base_name tyco) name;
    1.63 +    val name' = Thm.def_name_optional (NameSpace.base_name c ^ "_" ^ NameSpace.base_name tyco) name;
    1.64    in
    1.65      thy
    1.66      |> Thm.add_def false false (Binding.name name', prop)
    1.67 @@ -424,8 +423,8 @@
    1.68  
    1.69      (* class *)
    1.70  
    1.71 -    val bconst = Logic.const_of_class bclass;
    1.72 -    val class = Sign.full_bname thy bclass;
    1.73 +    val bconst = Binding.map_name Logic.const_of_class bclass;
    1.74 +    val class = Sign.full_name thy bclass;
    1.75      val super = Sign.minimize_sort thy (Sign.certify_sort thy raw_super);
    1.76  
    1.77      fun check_constraint (a, S) =
    1.78 @@ -472,7 +471,7 @@
    1.79      val ([def], def_thy) =
    1.80        thy
    1.81        |> Sign.primitive_class (bclass, super)
    1.82 -      |> PureThy.add_defs false [((Binding.name (Thm.def_name bconst), class_eq), [])];
    1.83 +      |> PureThy.add_defs false [((Binding.map_name Thm.def_name bconst, class_eq), [])];
    1.84      val (raw_intro, (raw_classrel, raw_axioms)) =
    1.85        split_defined (length conjs) def ||> chop (length super);
    1.86  
    1.87 @@ -482,7 +481,7 @@
    1.88      val class_triv = Thm.class_triv def_thy class;
    1.89      val ([(_, [intro]), (_, classrel), (_, axioms)], facts_thy) =
    1.90        def_thy
    1.91 -      |> Sign.add_path bconst
    1.92 +      |> Sign.add_path (Binding.name_of bconst)
    1.93        |> Sign.no_base_names
    1.94        |> PureThy.note_thmss ""
    1.95          [((Binding.name introN, []), [([Drule.standard raw_intro], [])]),
    1.96 @@ -498,7 +497,7 @@
    1.97      val result_thy =
    1.98        facts_thy
    1.99        |> fold put_classrel (map (pair class) super ~~ classrel)
   1.100 -      |> Sign.add_path bconst
   1.101 +      |> Sign.add_path (Binding.name_of bconst)
   1.102        |> PureThy.note_thmss "" (name_atts ~~ map Thm.simple_fact (unflat axiomss axioms)) |> snd
   1.103        |> Sign.restore_naming facts_thy
   1.104        |> map_axclasses (fn (axclasses, parameters) =>
   1.105 @@ -537,7 +536,7 @@
   1.106  
   1.107  fun ax_class prep_class prep_classrel (bclass, raw_super) thy =
   1.108    let
   1.109 -    val class = Sign.full_bname thy bclass;
   1.110 +    val class = Sign.full_name thy bclass;
   1.111      val super = map (prep_class thy) raw_super |> Sign.minimize_sort thy;
   1.112    in
   1.113      thy