equal
deleted
inserted
replaced
54 val t = Var v; |
54 val t = Var v; |
55 val t' = f t; |
55 val t' = f t; |
56 in if t aconv t' then NONE else SOME (t, t') end; |
56 in if t aconv t' then NONE else SOME (t, t') end; |
57 |
57 |
58 in |
58 in |
|
59 |
|
60 fun read_termTs ctxt ss Ts = |
|
61 let |
|
62 fun parse T = if T = propT then Syntax.parse_prop ctxt else Syntax.parse_term ctxt; |
|
63 val ts = map2 parse Ts ss; |
|
64 val ts' = |
|
65 map2 (TypeInfer.constrain o TypeInfer.paramify_vars) Ts ts |
|
66 |> Syntax.check_terms (ProofContext.set_mode ProofContext.mode_schematic ctxt) (* FIXME !? *) |
|
67 |> Variable.polymorphic ctxt; |
|
68 val Ts' = map Term.fastype_of ts'; |
|
69 val tyenv = fold Type.raw_match (Ts ~~ Ts') Vartab.empty; |
|
70 in (ts', map (apsnd snd) (Vartab.dest tyenv)) end; |
59 |
71 |
60 fun read_insts ctxt mixed_insts (tvars, vars) = |
72 fun read_insts ctxt mixed_insts (tvars, vars) = |
61 let |
73 let |
62 val thy = ProofContext.theory_of ctxt; |
74 val thy = ProofContext.theory_of ctxt; |
63 val cert = Thm.cterm_of thy; |
75 val cert = Thm.cterm_of thy; |
103 |
115 |
104 (* external term instantiations *) |
116 (* external term instantiations *) |
105 |
117 |
106 val (xs, strs) = split_list external_insts; |
118 val (xs, strs) = split_list external_insts; |
107 val Ts = map (the_type vars2) xs; |
119 val Ts = map (the_type vars2) xs; |
108 val (ts, inferred) = (* FIXME polymorphic!? schematic vs. 'for' context!? *) |
120 val (ts, inferred) = read_termTs ctxt strs Ts; |
109 ProofContext.read_termTs_schematic ctxt (K false) (K NONE) (K NONE) [] (strs ~~ Ts); |
|
110 |
121 |
111 val instT3 = Term.typ_subst_TVars inferred; |
122 val instT3 = Term.typ_subst_TVars inferred; |
112 val vars3 = map (apsnd instT3) vars2; |
123 val vars3 = map (apsnd instT3) vars2; |
113 val internal_insts3 = map (apsnd (map_types instT3)) internal_insts2; |
124 val internal_insts3 = map (apsnd (map_types instT3)) internal_insts2; |
114 val external_insts3 = xs ~~ ts; |
125 val external_insts3 = xs ~~ ts; |