165 handle THM (msg, _, _) => raise METIS ("inst_inference", msg) |
165 handle THM (msg, _, _) => raise METIS ("inst_inference", msg) |
166 | ERROR msg => raise METIS ("inst_inference", msg) |
166 | ERROR msg => raise METIS ("inst_inference", msg) |
167 |
167 |
168 (* INFERENCE RULE: RESOLVE *) |
168 (* INFERENCE RULE: RESOLVE *) |
169 |
169 |
|
170 (*Increment the indexes of only the type variables*) |
|
171 fun incr_type_indexes inc th = |
|
172 let val tvs = Term.add_tvars (Thm.full_prop_of th) [] |
|
173 and thy = Thm.theory_of_thm th |
|
174 fun inc_tvar ((a,i),s) = pairself (ctyp_of thy) (TVar ((a,i),s), TVar ((a,i+inc),s)) |
|
175 in Thm.instantiate (map inc_tvar tvs, []) th end; |
|
176 |
170 (* Like RSN, but we rename apart only the type variables. Vars here typically |
177 (* Like RSN, but we rename apart only the type variables. Vars here typically |
171 have an index of 1, and the use of RSN would increase this typically to 3. |
178 have an index of 1, and the use of RSN would increase this typically to 3. |
172 Instantiations of those Vars could then fail. *) |
179 Instantiations of those Vars could then fail. *) |
173 fun resolve_inc_tyvars thy tha i thb = |
180 fun resolve_inc_tyvars thy tha i thb = |
174 let |
181 let |
175 val tha = Drule.incr_type_indexes (1 + Thm.maxidx_of thb) tha |
182 val tha = incr_type_indexes (1 + Thm.maxidx_of thb) tha |
176 fun aux tha thb = |
183 fun aux tha thb = |
177 case Thm.bicompose false (false, tha, nprems_of tha) i thb |
184 case Thm.bicompose false (false, tha, nprems_of tha) i thb |
178 |> Seq.list_of |> distinct Thm.eq_thm of |
185 |> Seq.list_of |> distinct Thm.eq_thm of |
179 [th] => th |
186 [th] => th |
180 | _ => raise THM ("resolve_inc_tyvars: unique result expected", i, |
187 | _ => raise THM ("resolve_inc_tyvars: unique result expected", i, |