462 fun fix_params params = |
462 fun fix_params params = |
463 Proof_Context.add_fixes (map (fn ((x, T), mx) => (Binding.name x, SOME T, mx)) params) #> snd; |
463 Proof_Context.add_fixes (map (fn ((x, T), mx) => (Binding.name x, SOME T, mx)) params) #> snd; |
464 |
464 |
465 local |
465 local |
466 |
466 |
467 fun prep_declaration prep activate raw_import init_body raw_elems context = |
467 fun prep_declaration prep activate raw_import init_body raw_elems ctxt = |
468 let |
468 let |
469 val ((fixed, deps, elems, _), (parms, ctxt')) = |
469 val ((fixed, deps, elems, _), (parms, ctxt0)) = |
470 prep {strict = false, do_close = true, fixed_frees = false} |
470 prep {strict = false, do_close = true, fixed_frees = false} |
471 raw_import init_body raw_elems (Element.Shows []) context; |
471 raw_import init_body raw_elems (Element.Shows []) ctxt; |
472 (* Declare parameters and imported facts *) |
472 (* Declare parameters and imported facts *) |
473 val context' = context |> |
473 val ctxt' = ctxt |
474 fix_params fixed |> |
474 |> fix_params fixed |
475 fold (Context.proof_map o Locale.activate_facts NONE) deps; |
475 |> fold (Context.proof_map o Locale.activate_facts NONE) deps; |
476 val (elems', context'') = context' |> |
476 val (elems', ctxt'') = ctxt' |
477 Proof_Context.set_stmt true |> |
477 |> Proof_Context.set_stmt true |
478 fold_map activate elems; |
478 |> fold_map activate elems; |
479 in ((fixed, deps, elems', context''), (parms, ctxt')) end; |
479 in ((fixed, deps, elems', ctxt''), (parms, ctxt0)) end; |
480 |
480 |
481 in |
481 in |
482 |
482 |
483 fun cert_declaration x = prep_declaration cert_full_context_statement Element.activate_i x; |
483 fun cert_declaration x = prep_declaration cert_full_context_statement Element.activate_i x; |
484 fun cert_read_declaration x = prep_declaration cert_read_full_context_statement Element.activate x; |
484 fun cert_read_declaration x = prep_declaration cert_read_full_context_statement Element.activate x; |