src/Pure/Isar/class.ML
changeset 25060 17c313217998
parent 25038 522abf8a5f87
child 25062 af5ef0d4d655
equal deleted inserted replaced
25059:e6e0ee56a672 25060:17c313217998
    16 
    16 
    17   val class: bstring -> class list -> Element.context_i Locale.element list
    17   val class: bstring -> class list -> Element.context_i Locale.element list
    18     -> string list -> theory -> string * Proof.context
    18     -> string list -> theory -> string * Proof.context
    19   val class_cmd: bstring -> xstring list -> Element.context Locale.element list
    19   val class_cmd: bstring -> xstring list -> Element.context Locale.element list
    20     -> xstring list -> theory -> string * Proof.context
    20     -> xstring list -> theory -> string * Proof.context
    21   val init: class -> Proof.context -> Proof.context;
    21   val init: class -> Proof.context -> Proof.context
    22   val add_const_in_class: string -> (string * mixfix) * (string * term)
    22   val add_const_in_class: string -> (string * mixfix) * (string * term)
    23     -> theory -> string * theory
    23     -> theory -> string * theory
    24   val add_abbrev_in_class: string -> Syntax.mode -> (string * mixfix) * (string * term)
    24   val add_abbrev_in_class: string -> Syntax.mode -> (string * mixfix) * (string * term)
    25     -> theory -> string * theory
    25     -> theory -> string * theory
    26   val remove_constraint: class -> string -> Proof.context -> Proof.context
    26   val remove_constraint: class -> string -> Proof.context -> Proof.context
   586     val ts' = map (map_aterms
   586     val ts' = map (map_aterms
   587         (fn t as Const (c, ty) => the_default t (AList.lookup (op =) cs (c, ty)) | t => t)
   587         (fn t as Const (c, ty) => the_default t (AList.lookup (op =) cs (c, ty)) | t => t)
   588       #> (map_types o map_type_tvar) (fn var as (vi, _) => if member (op =) typarams vi
   588       #> (map_types o map_type_tvar) (fn var as (vi, _) => if member (op =) typarams vi
   589            then TFree (Name.aT, local_sort) else TVar var)) ts;
   589            then TFree (Name.aT, local_sort) else TVar var)) ts;
   590     val ctxt' = fold (ProofContext.add_const_constraint o apsnd SOME) constraints ctxt;
   590     val ctxt' = fold (ProofContext.add_const_constraint o apsnd SOME) constraints ctxt;
   591   in (ts', ctxt') end;
   591   in if eq_list (op aconv) (ts, ts') then NONE else SOME (ts', ctxt') end;
   592 
   592 
   593 val uncheck = ref false;
   593 val uncheck = ref false;
   594 
   594 
   595 fun sort_term_uncheck sups ts ctxt =
   595 fun sort_term_uncheck sups ts ctxt =
   596   let
   596   let
   603       | globalize (t as Const (c, ty)) = (case global_operation c
   603       | globalize (t as Const (c, ty)) = (case global_operation c
   604          of SOME c => Const (c, ty)
   604          of SOME c => Const (c, ty)
   605           | NONE => t)
   605           | NONE => t)
   606       | globalize t = t;
   606       | globalize t = t;
   607     val ts' = if ! uncheck then (map o map_aterms) globalize ts else ts;
   607     val ts' = if ! uncheck then (map o map_aterms) globalize ts else ts;
   608   in (ts', ctxt) end;
   608   in if eq_list (op aconv) (ts, ts') then NONE else SOME (ts', ctxt) end;
   609 
   609 
   610 fun init_class_ctxt sups local_sort ctxt =
   610 fun init_class_ctxt sups local_sort ctxt =
   611   let
   611   let
   612     val operations = these_operations (ProofContext.theory_of ctxt) sups;
   612     val operations = these_operations (ProofContext.theory_of ctxt) sups;
   613   in
   613   in