307 (** Finish locale elements **) |
307 (** Finish locale elements **) |
308 |
308 |
309 fun finish_inst ctxt (loc, (prfx, inst)) = |
309 fun finish_inst ctxt (loc, (prfx, inst)) = |
310 let |
310 let |
311 val thy = Proof_Context.theory_of ctxt; |
311 val thy = Proof_Context.theory_of ctxt; |
312 val (parm_names, parm_types) = Locale.params_of thy loc |> map #1 |> split_list; |
312 val (morph, _) = inst_morphism (Locale.params_types_of thy loc) (prfx, inst) ctxt; |
313 val (morph, _) = inst_morphism (parm_names, parm_types) (prfx, inst) ctxt; |
|
314 in (loc, morph) end; |
313 in (loc, morph) end; |
315 |
314 |
316 fun finish_fixes (parms: (string * typ) list) = map (fn (binding, _, mx) => |
315 fun finish_fixes (parms: (string * typ) list) = map (fn (binding, _, mx) => |
317 let val x = Binding.name_of binding |
316 let val x = Binding.name_of binding |
318 in (binding, AList.lookup (op =) parms x, mx) end); |
317 in (binding, AList.lookup (op =) parms x, mx) end); |
369 |
368 |
370 val (raw_insts, fixed) = parameters_of thy strict (apfst (prep_expr thy) raw_import); |
369 val (raw_insts, fixed) = parameters_of thy strict (apfst (prep_expr thy) raw_import); |
371 |
370 |
372 fun prep_insts_cumulative (loc, (prfx, (inst, eqns))) (i, insts, eqnss, ctxt) = |
371 fun prep_insts_cumulative (loc, (prfx, (inst, eqns))) (i, insts, eqnss, ctxt) = |
373 let |
372 let |
374 val (parm_names, parm_types) = Locale.params_of thy loc |> map #1 |> split_list; |
373 val (parm_names, parm_types) = Locale.params_types_of thy loc; |
375 val inst' = prep_inst ctxt parm_names inst; |
374 val inst' = prep_inst ctxt parm_names inst; |
376 val eqns' = map (apsnd (parse_eqn ctxt)) eqns; |
375 val eqns' = map (apsnd (parse_eqn ctxt)) eqns; |
377 val parm_types' = parm_types |
376 val parm_types' = parm_types |
378 |> map (Type_Infer.paramify_vars o |
377 |> map (Type_Infer.paramify_vars o |
379 Term.map_type_tvar (fn ((x, _), S) => TVar ((x, i), S)) o Logic.varifyT_global); |
378 Term.map_type_tvar (fn ((x, _), S) => TVar ((x, i), S)) o Logic.varifyT_global); |