94 val names = map2 Thm.def_binding_optional bvars bfacts; |
94 val names = map2 Thm.def_binding_optional bvars bfacts; |
95 val eqs = mk_def ctxt (xs ~~ rhss); |
95 val eqs = mk_def ctxt (xs ~~ rhss); |
96 val lhss = map (fst o Logic.dest_equals) eqs; |
96 val lhss = map (fst o Logic.dest_equals) eqs; |
97 in |
97 in |
98 ctxt |
98 ctxt |
99 |> ProofContext.add_fixes_i (map2 (fn x => fn mx => (x, NONE, mx)) bvars mxs) |> #2 |
99 |> ProofContext.add_fixes (map2 (fn x => fn mx => (x, NONE, mx)) bvars mxs) |> #2 |
100 |> fold Variable.declare_term eqs |
100 |> fold Variable.declare_term eqs |
101 |> ProofContext.add_assms_i def_export |
101 |> ProofContext.add_assms_i def_export |
102 (map2 (fn a => fn eq => (a, [(eq, [])])) (names ~~ atts) eqs) |
102 (map2 (fn a => fn eq => (a, [(eq, [])])) (names ~~ atts) eqs) |
103 |>> map2 (fn lhs => fn (name, [th]) => (lhs, (name, th))) lhss |
103 |>> map2 (fn lhs => fn (name, [th]) => (lhs, (name, th))) lhss |
104 end; |
104 end; |
113 fun fixed_abbrev ((x, mx), rhs) ctxt = |
113 fun fixed_abbrev ((x, mx), rhs) ctxt = |
114 let |
114 let |
115 val T = Term.fastype_of rhs; |
115 val T = Term.fastype_of rhs; |
116 val ([x'], ctxt') = ctxt |
116 val ([x'], ctxt') = ctxt |
117 |> Variable.declare_term rhs |
117 |> Variable.declare_term rhs |
118 |> ProofContext.add_fixes_i [(x, SOME T, mx)]; |
118 |> ProofContext.add_fixes [(x, SOME T, mx)]; |
119 val lhs = Free (x', T); |
119 val lhs = Free (x', T); |
120 val _ = cert_def ctxt' (Logic.mk_equals (lhs, rhs)); |
120 val _ = cert_def ctxt' (Logic.mk_equals (lhs, rhs)); |
121 fun abbrev_export _ _ = (I, Envir.expand_term_frees [((x', T), rhs)]); |
121 fun abbrev_export _ _ = (I, Envir.expand_term_frees [((x', T), rhs)]); |
122 val (_, ctxt'') = Assumption.add_assms abbrev_export [] ctxt'; |
122 val (_, ctxt'') = Assumption.add_assms abbrev_export [] ctxt'; |
123 in ((lhs, rhs), ctxt'') end; |
123 in ((lhs, rhs), ctxt'') end; |