src/Pure/Isar/class_declaration.ML
changeset 67450 b0ae74b86ef3
parent 66334 b210ae666a42
child 67671 857da80611ab
equal deleted inserted replaced
67449:1caeb087d957 67450:b0ae74b86ef3
    36       (Const o apsnd (map_atyps (K aT))) param_map;
    36       (Const o apsnd (map_atyps (K aT))) param_map;
    37     val const_morph = Element.inst_morphism thy
    37     val const_morph = Element.inst_morphism thy
    38       (Symtab.empty, Symtab.make param_map_inst);
    38       (Symtab.empty, Symtab.make param_map_inst);
    39     val typ_morph = Element.inst_morphism thy
    39     val typ_morph = Element.inst_morphism thy
    40       (Symtab.empty |> Symtab.update (Name.aT, TFree (Name.aT, [class])), Symtab.empty);
    40       (Symtab.empty |> Symtab.update (Name.aT, TFree (Name.aT, [class])), Symtab.empty);
    41     val (([raw_props], [(_, raw_inst_morph)], export_morph), _) = empty_ctxt
    41     val (([raw_props], _, [(_, raw_inst_morph)], _, export_morph), _) = empty_ctxt
    42       |> Expression.cert_goal_expression ([(class, (("", false),
    42       |> Expression.cert_goal_expression ([(class, (("", false),
    43            Expression.Named param_map_const))], []);
    43            (Expression.Named param_map_const, [])))], []);
    44     val (props, inst_morph) =
    44     val (props, inst_morph) =
    45       if null param_map
    45       if null param_map
    46       then (raw_props |> map (Morphism.term typ_morph),
    46       then (raw_props |> map (Morphism.term typ_morph),
    47         raw_inst_morph $> typ_morph)
    47         raw_inst_morph $> typ_morph)
    48       else (raw_props, raw_inst_morph); (*FIXME proper handling in
    48       else (raw_props, raw_inst_morph); (*FIXME proper handling in
   154         SOME T => map (subst_TVars (map (rpair T) param_namesT)) ts
   154         SOME T => map (subst_TVars (map (rpair T) param_namesT)) ts
   155       end;
   155       end;
   156 
   156 
   157     (* preprocessing elements, retrieving base sort from type-checked elements *)
   157     (* preprocessing elements, retrieving base sort from type-checked elements *)
   158     val raw_supexpr =
   158     val raw_supexpr =
   159       (map (fn sup => (sup, (("", false), Expression.Positional []))) sups, []);
   159       (map (fn sup => (sup, (("", false), (Expression.Positional [], [])))) sups, []);
   160     val init_class_body =
   160     val init_class_body =
   161       fold (Proof_Context.add_const_constraint o apsnd SOME) base_constraints
   161       fold (Proof_Context.add_const_constraint o apsnd SOME) base_constraints
   162       #> Class.redeclare_operations thy sups
   162       #> Class.redeclare_operations thy sups
   163       #> Context.proof_map (Syntax_Phases.term_check 0 "singleton_fixate" (K singleton_fixate));
   163       #> Context.proof_map (Syntax_Phases.term_check 0 "singleton_fixate" (K singleton_fixate));
   164     val ((raw_supparams, _, raw_inferred_elems, _), _) =
   164     val ((raw_supparams, _, raw_inferred_elems, _), _) =
   190     val supparams = map (fn ((c, T), _) =>
   190     val supparams = map (fn ((c, T), _) =>
   191       (c, map_atyps (K (TFree (Name.aT, base_sort))) T)) raw_supparams;
   191       (c, map_atyps (K (TFree (Name.aT, base_sort))) T)) raw_supparams;
   192     val supparam_names = map fst supparams;
   192     val supparam_names = map fst supparams;
   193     fun mk_param ((c, _), _) = Free (c, (the o AList.lookup (op =) supparams) c);
   193     fun mk_param ((c, _), _) = Free (c, (the o AList.lookup (op =) supparams) c);
   194     val supexpr = (map (fn sup => (sup, (("", false),
   194     val supexpr = (map (fn sup => (sup, (("", false),
   195       Expression.Positional (map (SOME o mk_param) (Locale.params_of thy sup))))) sups,
   195       (Expression.Positional (map (SOME o mk_param) (Locale.params_of thy sup)), [])))) sups,
   196         map (fn (c, T) => (Binding.name c, SOME T, NoSyn)) supparams);
   196         map (fn (c, T) => (Binding.name c, SOME T, NoSyn)) supparams);
   197 
   197 
   198   in (base_sort, supparam_names, supexpr, inferred_elems) end;
   198   in (base_sort, supparam_names, supexpr, inferred_elems) end;
   199 
   199 
   200 val cert_class_elems = prep_class_elems Expression.cert_declaration;
   200 val cert_class_elems = prep_class_elems Expression.cert_declaration;
   352       (case Named_Target.class_of lthy of
   352       (case Named_Target.class_of lthy of
   353         SOME class => class
   353         SOME class => class
   354       | NONE => error "Not in a class target");
   354       | NONE => error "Not in a class target");
   355     val (sub, sup) = Axclass.cert_classrel thy (proto_sub, proto_sup);
   355     val (sub, sup) = Axclass.cert_classrel thy (proto_sub, proto_sup);
   356 
   356 
   357     val expr = ([(sup, (("", false), Expression.Positional []))], []);
   357     val expr = ([(sup, (("", false), (Expression.Positional [], [])))], []);
   358     val (([props], deps, export), goal_ctxt) =
   358     val (([props], _, deps, _, export), goal_ctxt) =
   359       Expression.cert_goal_expression expr lthy;
   359       Expression.cert_goal_expression expr lthy;
   360     val some_prop = try the_single props;
   360     val some_prop = try the_single props;
   361     val some_dep_morph = try the_single (map snd deps);
   361     val some_dep_morph = try the_single (map snd deps);
   362     fun after_qed some_wit =
   362     fun after_qed some_wit =
   363       Class.register_subclass (sub, sup) some_dep_morph some_wit export;
   363       Class.register_subclass (sub, sup) some_dep_morph some_wit export;