src/Pure/Isar/class.ML
changeset 30240 5b25fee0362c
parent 29816 78e0a90694dd
child 30242 aea5d7fa7ef5
equal deleted inserted replaced
30239:179ff9cb160b 30240:5b25fee0362c
   199           maps (fn (_, ts_pss) => map
   199           maps (fn (_, ts_pss) => map
   200             (fn (t, _) => check_vars e (Term.add_tfrees t [])) ts_pss) assms
   200             (fn (t, _) => check_vars e (Term.add_tfrees t [])) ts_pss) assms
   201       | check_element e = [()];
   201       | check_element e = [()];
   202     val _ = map check_element syntax_elems;
   202     val _ = map check_element syntax_elems;
   203     fun fork_syn (Element.Fixes xs) =
   203     fun fork_syn (Element.Fixes xs) =
   204           fold_map (fn (c, ty, syn) => cons (Binding.base_name c, syn) #> pair (c, ty, NoSyn)) xs
   204           fold_map (fn (c, ty, syn) => cons (Binding.name_of c, syn) #> pair (c, ty, NoSyn)) xs
   205           #>> Element.Fixes
   205           #>> Element.Fixes
   206       | fork_syn x = pair x;
   206       | fork_syn x = pair x;
   207     val (elems, global_syntax) = fold_map fork_syn syntax_elems [];
   207     val (elems, global_syntax) = fold_map fork_syn syntax_elems [];
   208     val constrain = Element.Constrains ((map o apsnd o map_atyps)
   208     val constrain = Element.Constrains ((map o apsnd o map_atyps)
   209       (K (TFree (Name.aT, base_sort))) supparams);
   209       (K (TFree (Name.aT, base_sort))) supparams);
   226       |> (map o apsnd o apsnd o map_atyps o K o TFree) (Name.aT, [class]);
   226       |> (map o apsnd o apsnd o map_atyps o K o TFree) (Name.aT, [class]);
   227     val all_params = Locale.params_of thy class;
   227     val all_params = Locale.params_of thy class;
   228     val raw_params = (snd o chop (length supparams)) all_params;
   228     val raw_params = (snd o chop (length supparams)) all_params;
   229     fun add_const (b, SOME raw_ty, _) thy =
   229     fun add_const (b, SOME raw_ty, _) thy =
   230       let
   230       let
   231         val v = Binding.base_name b;
   231         val v = Binding.name_of b;
   232         val c = Sign.full_bname thy v;
   232         val c = Sign.full_bname thy v;
   233         val ty = map_atyps (K (TFree (Name.aT, base_sort))) raw_ty;
   233         val ty = map_atyps (K (TFree (Name.aT, base_sort))) raw_ty;
   234         val ty0 = Type.strip_sorts ty;
   234         val ty0 = Type.strip_sorts ty;
   235         val ty' = map_atyps (K (TFree (Name.aT, [class]))) ty0;
   235         val ty' = map_atyps (K (TFree (Name.aT, [class]))) ty0;
   236         val syn = (the_default NoSyn o AList.lookup (op =) global_syntax) v;
   236         val syn = (the_default NoSyn o AList.lookup (op =) global_syntax) v;
   263   in
   263   in
   264     thy
   264     thy
   265     |> add_consts bname class base_sort sups supparams global_syntax
   265     |> add_consts bname class base_sort sups supparams global_syntax
   266     |-> (fn (param_map, params) => AxClass.define_class (bname, supsort)
   266     |-> (fn (param_map, params) => AxClass.define_class (bname, supsort)
   267           (map (fst o snd) params)
   267           (map (fst o snd) params)
   268           [((Binding.empty, []),
   268           [(Thm.empty_binding, Option.map (globalize param_map) raw_pred |> the_list)]
   269             Option.map (globalize param_map) raw_pred |> the_list)]
       
   270     #> snd
   269     #> snd
   271     #> `get_axiom
   270     #> `get_axiom
   272     #-> (fn assm_axiom => fold (Sign.add_const_constraint o apsnd SOME o snd) params
   271     #-> (fn assm_axiom => fold (Sign.add_const_constraint o apsnd SOME o snd) params
   273     #> pair (param_map, params, assm_axiom)))
   272     #> pair (param_map, params, assm_axiom)))
   274   end;
   273   end;