57 (inj, embed, return, cong); |
57 (inj, embed, return, cong); |
58 |
58 |
59 fun get_by_direction context (a, D) = |
59 fun get_by_direction context (a, D) = |
60 let |
60 let |
61 val ctxt = Context.proof_of context; |
61 val ctxt = Context.proof_of context; |
62 val a0 = Proof_Context.cterm_of ctxt a; |
62 val a0 = Thm.cterm_of ctxt a; |
63 val D0 = Proof_Context.cterm_of ctxt D; |
63 val D0 = Thm.cterm_of ctxt D; |
64 fun eq_direction ((a, D), thm') = |
64 fun eq_direction ((a, D), thm') = |
65 let |
65 let |
66 val (a', D') = direction_of thm'; |
66 val (a', D') = direction_of thm'; |
67 in a aconvc a' andalso D aconvc D' end; |
67 in a aconvc a' andalso D aconvc D' end; |
68 in case AList.lookup eq_direction (Data.get context) (a0, D0) of |
68 in case AList.lookup eq_direction (Data.get context) (a0, D0) of |
116 |> Variable.declare_thm thm |
116 |> Variable.declare_thm thm |
117 |> Variable.declare_term (Thm.term_of a) |
117 |> Variable.declare_term (Thm.term_of a) |
118 |> Variable.declare_term (Thm.term_of D); |
118 |> Variable.declare_term (Thm.term_of D); |
119 val vars = filter (fn ((v, _), T) => Type.could_unify (T, aT) andalso |
119 val vars = filter (fn ((v, _), T) => Type.could_unify (T, aT) andalso |
120 not (member (op =) leave v)) (Term.add_vars (Thm.prop_of thm) []); |
120 not (member (op =) leave v)) (Term.add_vars (Thm.prop_of thm) []); |
121 val c_vars = map (Proof_Context.cterm_of ctxt3 o Var) vars; |
121 val c_vars = map (Thm.cterm_of ctxt3 o Var) vars; |
122 val (vs', ctxt4) = Variable.variant_fixes (map (fst o fst) vars) ctxt3; |
122 val (vs', ctxt4) = Variable.variant_fixes (map (fst o fst) vars) ctxt3; |
123 val c_vars' = map (Proof_Context.cterm_of ctxt3 o (fn v => Free (v, bT))) vs'; |
123 val c_vars' = map (Thm.cterm_of ctxt3 o (fn v => Free (v, bT))) vs'; |
124 val c_exprs' = map (Thm.apply a) c_vars'; |
124 val c_exprs' = map (Thm.apply a) c_vars'; |
125 |
125 |
126 (* transfer *) |
126 (* transfer *) |
127 val (hyps, ctxt5) = ctxt4 |
127 val (hyps, ctxt5) = ctxt4 |
128 |> Assumption.add_assumes (map transform c_vars'); |
128 |> Assumption.add_assumes (map transform c_vars'); |