match_term : term -> term -> (term,term) subst * (hol_type,hol_type) subst
When applied to two terms, match_term attempts to find a set of type and term instantiations for the first term (only) to make it alpha-convertible to the second. If it succeeds, it returns the instantiations in the form of a pair containing a term substitution and a type substitution. If the first term represents the conclusion of a theorem, the returned instantiations are of the appropriate form to be passed to INST_TY_TERM.
- val th = REFL ``x:'a``;
th = |- x = x
- match_term (concl th) ``1 = 1``;
val it = ([{redex = ``x``, residue = ``1``}],
[{redex = ``:'a``, residue= ``:num``}])
: term subst * hol_type subst
- INST_TY_TERM it th;
val it = |- 1 = 1
- (show_types := true; show_assums := true);
() : unit
- val th = ASSUME ``x:'a = x``;
val th = [(x :'a) = (x :'a)] |- (x :'a) = (x :'a) : thm
- match_term (concl th) (--`1 = 1`--);
val it = ([{redex = ``x :num``, residue = ``1``}],
[{redex = ``:'a``, residue = ``:num``}])
: term subst * hol_type subst
- INST_TY_TERM it th handle e => Raise e;
Exception raised at Thm.INST_TYPE:
type variable(s) in assumptions would be instantiated in concl
In fact, for instantiating a theorem, PART_MATCH is usually easier.