81 let |
81 let |
82 fun parse T = if T = propT then Syntax.parse_prop ctxt else Syntax.parse_term ctxt; |
82 fun parse T = if T = propT then Syntax.parse_prop ctxt else Syntax.parse_term ctxt; |
83 val ts = map2 parse Ts ss; |
83 val ts = map2 parse Ts ss; |
84 val ts' = |
84 val ts' = |
85 map2 (Type.constraint o Type_Infer.paramify_vars) Ts ts |
85 map2 (Type.constraint o Type_Infer.paramify_vars) Ts ts |
86 |> Syntax.check_terms ((schematic ? ProofContext.set_mode ProofContext.mode_schematic) ctxt) |
86 |> Syntax.check_terms ((schematic ? Proof_Context.set_mode Proof_Context.mode_schematic) ctxt) |
87 |> Variable.polymorphic ctxt; |
87 |> Variable.polymorphic ctxt; |
88 val Ts' = map Term.fastype_of ts'; |
88 val Ts' = map Term.fastype_of ts'; |
89 val tyenv = fold Type.raw_match (Ts ~~ Ts') Vartab.empty; |
89 val tyenv = fold Type.raw_match (Ts ~~ Ts') Vartab.empty; |
90 in (ts', map (apsnd snd) (Vartab.dest tyenv)) end; |
90 in (ts', map (apsnd snd) (Vartab.dest tyenv)) end; |
91 |
91 |
92 fun read_insts ctxt mixed_insts (tvars, vars) = |
92 fun read_insts ctxt mixed_insts (tvars, vars) = |
93 let |
93 let |
94 val thy = ProofContext.theory_of ctxt; |
94 val thy = Proof_Context.theory_of ctxt; |
95 val cert = Thm.cterm_of thy; |
95 val cert = Thm.cterm_of thy; |
96 val certT = Thm.ctyp_of thy; |
96 val certT = Thm.ctyp_of thy; |
97 |
97 |
98 val (type_insts, term_insts) = List.partition (is_tvar o fst) mixed_insts; |
98 val (type_insts, term_insts) = List.partition (is_tvar o fst) mixed_insts; |
99 val internal_insts = term_insts |> map_filter |
99 val internal_insts = term_insts |> map_filter |
191 |
191 |
192 |
192 |
193 (* instantiation of rule or goal state *) |
193 (* instantiation of rule or goal state *) |
194 |
194 |
195 fun read_instantiate ctxt args thm = |
195 fun read_instantiate ctxt args thm = |
196 read_instantiate_mixed (ctxt |> ProofContext.set_mode ProofContext.mode_schematic) (* FIXME !? *) |
196 read_instantiate_mixed (ctxt |> Proof_Context.set_mode Proof_Context.mode_schematic) (* FIXME !? *) |
197 (map (fn (x, y) => (Token.eof, (x, Token.Text y))) args) thm; |
197 (map (fn (x, y) => (Token.eof, (x, Token.Text y))) args) thm; |
198 |
198 |
199 fun instantiate_tac ctxt args = PRIMITIVE (read_instantiate ctxt args); |
199 fun instantiate_tac ctxt args = PRIMITIVE (read_instantiate ctxt args); |
200 |
200 |
201 |
201 |
258 |
258 |
259 (* FIXME cleanup this mess!!! *) |
259 (* FIXME cleanup this mess!!! *) |
260 |
260 |
261 fun bires_inst_tac bires_flag ctxt insts thm = |
261 fun bires_inst_tac bires_flag ctxt insts thm = |
262 let |
262 let |
263 val thy = ProofContext.theory_of ctxt; |
263 val thy = Proof_Context.theory_of ctxt; |
264 (* Separate type and term insts *) |
264 (* Separate type and term insts *) |
265 fun has_type_var ((x, _), _) = |
265 fun has_type_var ((x, _), _) = |
266 (case Symbol.explode x of "'" :: _ => true | _ => false); |
266 (case Symbol.explode x of "'" :: _ => true | _ => false); |
267 val Tinsts = filter has_type_var insts; |
267 val Tinsts = filter has_type_var insts; |
268 val tinsts = filter_out has_type_var insts; |
268 val tinsts = filter_out has_type_var insts; |
277 (*the same name are renamed during printing*) |
277 (*the same name are renamed during printing*) |
278 |
278 |
279 val (param_names, ctxt') = ctxt |
279 val (param_names, ctxt') = ctxt |
280 |> Variable.declare_thm thm |
280 |> Variable.declare_thm thm |
281 |> Thm.fold_terms Variable.declare_constraints st |
281 |> Thm.fold_terms Variable.declare_constraints st |
282 |> ProofContext.add_fixes (map (fn (x, T) => (Binding.name x, SOME T, NoSyn)) params); |
282 |> Proof_Context.add_fixes (map (fn (x, T) => (Binding.name x, SOME T, NoSyn)) params); |
283 |
283 |
284 (* Process type insts: Tinsts_env *) |
284 (* Process type insts: Tinsts_env *) |
285 fun absent xi = error |
285 fun absent xi = error |
286 ("No such variable in theorem: " ^ Term.string_of_vname xi); |
286 ("No such variable in theorem: " ^ Term.string_of_vname xi); |
287 val (rtypes, rsorts) = Drule.types_sorts thm; |
287 val (rtypes, rsorts) = Drule.types_sorts thm; |