49 val importT_inst: term list -> Proof.context -> ((indexname * sort) * typ) list * Proof.context |
49 val importT_inst: term list -> Proof.context -> ((indexname * sort) * typ) list * Proof.context |
50 val import_inst: bool -> term list -> Proof.context -> |
50 val import_inst: bool -> term list -> Proof.context -> |
51 (((indexname * sort) * typ) list * ((indexname * typ) * term) list) * Proof.context |
51 (((indexname * sort) * typ) list * ((indexname * typ) * term) list) * Proof.context |
52 val importT_terms: term list -> Proof.context -> term list * Proof.context |
52 val importT_terms: term list -> Proof.context -> term list * Proof.context |
53 val import_terms: bool -> term list -> Proof.context -> term list * Proof.context |
53 val import_terms: bool -> term list -> Proof.context -> term list * Proof.context |
54 val importT: thm list -> Proof.context -> (ctyp list * thm list) * Proof.context |
54 val importT: thm list -> Proof.context -> ((ctyp * ctyp) list * thm list) * Proof.context |
55 val import_prf: bool -> Proofterm.proof -> Proof.context -> Proofterm.proof * Proof.context |
55 val import_prf: bool -> Proofterm.proof -> Proof.context -> Proofterm.proof * Proof.context |
56 val import: bool -> thm list -> Proof.context -> |
56 val import: bool -> thm list -> Proof.context -> |
57 ((ctyp list * cterm list) * thm list) * Proof.context |
57 (((ctyp * ctyp) list * (cterm * cterm) list) * thm list) * Proof.context |
58 val tradeT: (Proof.context -> thm list -> thm list) -> Proof.context -> thm list -> thm list |
58 val tradeT: (Proof.context -> thm list -> thm list) -> Proof.context -> thm list -> thm list |
59 val trade: (Proof.context -> thm list -> thm list) -> Proof.context -> thm list -> thm list |
59 val trade: (Proof.context -> thm list -> thm list) -> Proof.context -> thm list -> thm list |
60 val focus: cterm -> Proof.context -> ((string * cterm) list * cterm) * Proof.context |
60 val focus: cterm -> Proof.context -> ((string * cterm) list * cterm) * Proof.context |
61 val focus_subgoal: int -> thm -> Proof.context -> ((string * cterm) list * cterm) * Proof.context |
61 val focus_subgoal: int -> thm -> Proof.context -> ((string * cterm) list * cterm) * Proof.context |
62 val warn_extra_tfrees: Proof.context -> Proof.context -> unit |
62 val warn_extra_tfrees: Proof.context -> Proof.context -> unit |
425 in (map (Term_Subst.instantiate inst) ts, ctxt') end; |
425 in (map (Term_Subst.instantiate inst) ts, ctxt') end; |
426 |
426 |
427 fun importT ths ctxt = |
427 fun importT ths ctxt = |
428 let |
428 let |
429 val thy = ProofContext.theory_of ctxt; |
429 val thy = ProofContext.theory_of ctxt; |
430 val certT = Thm.ctyp_of thy; |
|
431 val (instT, ctxt') = importT_inst (map Thm.full_prop_of ths) ctxt; |
430 val (instT, ctxt') = importT_inst (map Thm.full_prop_of ths) ctxt; |
432 val instT' = map (fn (v, T) => (certT (TVar v), certT T)) instT; |
431 val insts' as (instT', _) = Thm.certify_inst thy (instT, []); |
433 val ths' = map (Thm.instantiate (instT', [])) ths; |
432 val ths' = map (Thm.instantiate insts') ths; |
434 in ((map #2 instT', ths'), ctxt') end; |
433 in ((instT', ths'), ctxt') end; |
435 |
434 |
436 fun import_prf is_open prf ctxt = |
435 fun import_prf is_open prf ctxt = |
437 let |
436 let |
438 val ts = rev (Proofterm.fold_proof_terms cons (cons o Logic.mk_type) prf []); |
437 val ts = rev (Proofterm.fold_proof_terms cons (cons o Logic.mk_type) prf []); |
439 val (insts, ctxt') = import_inst is_open ts ctxt; |
438 val (insts, ctxt') = import_inst is_open ts ctxt; |
440 in (Proofterm.instantiate insts prf, ctxt') end; |
439 in (Proofterm.instantiate insts prf, ctxt') end; |
441 |
440 |
442 fun import is_open ths ctxt = |
441 fun import is_open ths ctxt = |
443 let |
442 let |
444 val thy = ProofContext.theory_of ctxt; |
443 val thy = ProofContext.theory_of ctxt; |
445 val cert = Thm.cterm_of thy; |
444 val (insts, ctxt') = import_inst is_open (map Thm.full_prop_of ths) ctxt; |
446 val certT = Thm.ctyp_of thy; |
445 val insts' = Thm.certify_inst thy insts; |
447 val ((instT, inst), ctxt') = import_inst is_open (map Thm.full_prop_of ths) ctxt; |
446 val ths' = map (Thm.instantiate insts') ths; |
448 val instT' = map (fn (v, T) => (certT (TVar v), certT T)) instT; |
447 in ((insts', ths'), ctxt') end; |
449 val inst' = map (fn (v, t) => (cert (Var v), cert t)) inst; |
|
450 val ths' = map (Thm.instantiate (instT', inst')) ths; |
|
451 in (((map #2 instT', map #2 inst'), ths'), ctxt') end; |
|
452 |
448 |
453 |
449 |
454 (* import/export *) |
450 (* import/export *) |
455 |
451 |
456 fun gen_trade imp exp f ctxt ths = |
452 fun gen_trade imp exp f ctxt ths = |