600 |
600 |
601 (*Contract all eta-redexes in the theorem, lest they give rise to needless abstractions*) |
601 (*Contract all eta-redexes in the theorem, lest they give rise to needless abstractions*) |
602 fun eta_contraction_rule th = |
602 fun eta_contraction_rule th = |
603 equal_elim (eta_conversion (cprop_of th)) th; |
603 equal_elim (eta_conversion (cprop_of th)) th; |
604 |
604 |
605 val abs_def = |
605 |
606 let |
606 (* abs_def *) |
607 fun contract_lhs th = |
607 |
608 Thm.transitive (Thm.symmetric (beta_eta_conversion |
608 (* |
609 (fst (Thm.dest_equals (cprop_of th))))) th; |
609 f ?x1 ... ?xn == u |
610 fun abstract cx th = Thm.abstract_rule |
610 -------------------- |
611 (case Thm.term_of cx of Var ((x, _), _) => x | Free (x, _) => x | _ => "x") cx th |
611 f == %x1 ... xn. u |
612 handle THM _ => raise THM ("Malformed definitional equation", 0, [th]); |
612 *) |
613 in |
613 |
614 contract_lhs |
614 local |
615 #> `(snd o strip_comb o fst o Thm.dest_equals o cprop_of) |
615 |
616 #-> fold_rev abstract |
616 fun contract_lhs th = |
617 #> contract_lhs |
617 Thm.transitive (Thm.symmetric (beta_eta_conversion |
618 end; |
618 (fst (Thm.dest_equals (cprop_of th))))) th; |
|
619 |
|
620 fun var_args ct = |
|
621 (case try Thm.dest_comb ct of |
|
622 SOME (f, arg) => |
|
623 (case Thm.term_of arg of |
|
624 Var ((x, _), _) => update (eq_snd (op aconvc)) (x, arg) (var_args f) |
|
625 | _ => []) |
|
626 | NONE => []); |
|
627 |
|
628 in |
|
629 |
|
630 fun abs_def th = |
|
631 let |
|
632 val th' = contract_lhs th; |
|
633 val args = var_args (Thm.lhs_of th'); |
|
634 in contract_lhs (fold (uncurry Thm.abstract_rule) args th') end; |
|
635 |
|
636 end; |
|
637 |
619 |
638 |
620 |
639 |
621 (*** Some useful meta-theorems ***) |
640 (*** Some useful meta-theorems ***) |
622 |
641 |
623 (*The rule V/V, obtains assumption solving for eresolve_tac*) |
642 (*The rule V/V, obtains assumption solving for eresolve_tac*) |