| 1 | % ================================================================= % |
| 2 | % BINDER_EQ_TAC: tactic % |
| 3 | % ************* % |
| 4 | % % |
| 5 | % Synopsis: strips matching binders from a top-level equality goal. % |
| 6 | % % |
| 7 | % Description: The tactic effects the inverse of the forward % |
| 8 | % inference rules FORALL_EQ, EXISTS_EQ, and SELECT_EQ. % |
| 9 | % % |
| 10 | % {A} *t. t1[t] = *t'. t2[t'] (* in [!,?,@]) % |
| 11 | % =========================== % |
| 12 | % {A} t1[t''] = t2[t''] % |
| 13 | % % |
| 14 | % (t'' not free in *t.t1 nor t2) % |
| 15 | % % |
| 16 | % The quantified terms need not be identical, but % |
| 17 | % instead only alpha convertable (the types must match). % |
| 18 | % % |
| 19 | % Failure: fails if binders differ, or bound variables have % |
| 20 | % different types. % |
| 21 | % % |
| 22 | % Written by: Brian Graham 05.12.90 % |
| 23 | % ================================================================= % |
| 24 | let BINDER_EQ_TAC:tactic(l,t) = |
| 25 | (let t1,t2 = dest_eq t |
| 26 | in |
| 27 | let q1,n1,w1 = ((I#dest_abs) o dest_comb) t1 |
| 28 | and q2,n2,w2 = ((I#dest_abs) o dest_comb) t2 |
| 29 | in |
| 30 | if (q1 = q2) |
| 31 | then if (type_of n1 = type_of n2) |
| 32 | then if (n1 = n2) |
| 33 | then let p[th] = MK_COMB(REFL(fst(dest_comb t1)), ABS n1 th) |
| 34 | in |
| 35 | ([l,mk_eq(w1,w2)], p) |
| 36 | else let n = variant ((frees t1)@(frees w2)) n1 |
| 37 | in |
| 38 | let p[th] = |
| 39 | let abs_th = (ABS n th) |
| 40 | in |
| 41 | let lhs,rhs = dest_eq(concl abs_th) |
| 42 | in |
| 43 | MK_COMB(REFL(fst(dest_comb t1)), |
| 44 | TRANS (SYM (GEN_ALPHA_CONV n1 lhs)) |
| 45 | (TRANS abs_th |
| 46 | (GEN_ALPHA_CONV n2 rhs))) |
| 47 | |
| 48 | in |
| 49 | ([l,mk_eq(subst [n,n1]w1,(subst [n,n2] w2))], p) |
| 50 | else failwith `BINDER_EQ_TAC: quantified variables have different types` |
| 51 | else failwith `BINDER_EQ_TAC: different binders at top level` |
| 52 | ) ? failwith `BINDER_EQ_TAC`;; |