equal
deleted
inserted
replaced
112 (* notes *) |
112 (* notes *) |
113 |
113 |
114 fun import_export_proof ctxt (name, raw_th) = |
114 fun import_export_proof ctxt (name, raw_th) = |
115 let |
115 let |
116 val thy = ProofContext.theory_of ctxt; |
116 val thy = ProofContext.theory_of ctxt; |
117 val thy_ctxt = ProofContext.init thy; |
117 val thy_ctxt = ProofContext.init_global thy; |
118 val certT = Thm.ctyp_of thy; |
118 val certT = Thm.ctyp_of thy; |
119 val cert = Thm.cterm_of thy; |
119 val cert = Thm.cterm_of thy; |
120 |
120 |
121 (*export assumes/defines*) |
121 (*export assumes/defines*) |
122 val th = Goal.norm_result raw_th; |
122 val th = Goal.norm_result raw_th; |
211 |
211 |
212 (* abbrev *) |
212 (* abbrev *) |
213 |
213 |
214 fun abbrev (ta as Target {target, is_locale, is_class, ...}) prmode ((b, mx), t) lthy = |
214 fun abbrev (ta as Target {target, is_locale, is_class, ...}) prmode ((b, mx), t) lthy = |
215 let |
215 let |
216 val thy_ctxt = ProofContext.init (ProofContext.theory_of lthy); |
216 val thy_ctxt = ProofContext.init_global (ProofContext.theory_of lthy); |
217 val target_ctxt = Local_Theory.target_of lthy; |
217 val target_ctxt = Local_Theory.target_of lthy; |
218 |
218 |
219 val (mx1, mx2, mx3) = fork_mixfix ta mx; |
219 val (mx1, mx2, mx3) = fork_mixfix ta mx; |
220 val t' = Assumption.export_term lthy target_ctxt t; |
220 val t' = Assumption.export_term lthy target_ctxt t; |
221 val xs = map Free (rev (Variable.add_fixed target_ctxt t' [])); |
221 val xs = map Free (rev (Variable.add_fixed target_ctxt t' [])); |
284 in |
284 in |
285 |
285 |
286 fun define ta ((b, mx), ((name, atts), rhs)) lthy = |
286 fun define ta ((b, mx), ((name, atts), rhs)) lthy = |
287 let |
287 let |
288 val thy = ProofContext.theory_of lthy; |
288 val thy = ProofContext.theory_of lthy; |
289 val thy_ctxt = ProofContext.init thy; |
289 val thy_ctxt = ProofContext.init_global thy; |
290 |
290 |
291 val name' = Thm.def_binding_optional b name; |
291 val name' = Thm.def_binding_optional b name; |
292 |
292 |
293 val crhs = Thm.cterm_of thy rhs; |
293 val crhs = Thm.cterm_of thy rhs; |
294 val (defs, rhs') = Local_Defs.export_cterm lthy thy_ctxt crhs ||> Thm.term_of; |
294 val (defs, rhs') = Local_Defs.export_cterm lthy thy_ctxt crhs ||> Thm.term_of; |
340 else error ("No such locale: " ^ quote target); |
340 else error ("No such locale: " ^ quote target); |
341 |
341 |
342 fun init_ctxt (Target {target, is_locale, is_class, instantiation, overloading}) = |
342 fun init_ctxt (Target {target, is_locale, is_class, instantiation, overloading}) = |
343 if not (null (#1 instantiation)) then Class_Target.init_instantiation instantiation |
343 if not (null (#1 instantiation)) then Class_Target.init_instantiation instantiation |
344 else if not (null overloading) then Overloading.init overloading |
344 else if not (null overloading) then Overloading.init overloading |
345 else if not is_locale then ProofContext.init |
345 else if not is_locale then ProofContext.init_global |
346 else if not is_class then Locale.init target |
346 else if not is_class then Locale.init target |
347 else Class_Target.init target; |
347 else Class_Target.init target; |
348 |
348 |
349 fun init_lthy (ta as Target {target, instantiation, overloading, ...}) = |
349 fun init_lthy (ta as Target {target, instantiation, overloading, ...}) = |
350 Data.put ta #> |
350 Data.put ta #> |
362 else I)} |
362 else I)} |
363 and init_lthy_ctxt ta = init_lthy ta o init_ctxt ta; |
363 and init_lthy_ctxt ta = init_lthy ta o init_ctxt ta; |
364 |
364 |
365 fun gen_overloading prep_const raw_ops thy = |
365 fun gen_overloading prep_const raw_ops thy = |
366 let |
366 let |
367 val ctxt = ProofContext.init thy; |
367 val ctxt = ProofContext.init_global thy; |
368 val ops = raw_ops |> map (fn (name, const, checked) => |
368 val ops = raw_ops |> map (fn (name, const, checked) => |
369 (name, Term.dest_Const (prep_const ctxt const), checked)); |
369 (name, Term.dest_Const (prep_const ctxt const), checked)); |
370 in thy |> init_lthy_ctxt (make_target "" false false ([], [], []) ops) end; |
370 in thy |> init_lthy_ctxt (make_target "" false false ([], [], []) ops) end; |
371 |
371 |
372 in |
372 in |