760 maxidx = maxidx, |
760 maxidx = maxidx, |
761 shyps = Sorts.union sorts shyps, |
761 shyps = Sorts.union sorts shyps, |
762 hyps = hyps, |
762 hyps = hyps, |
763 tpairs = tpairs, |
763 tpairs = tpairs, |
764 prop = all T $ Abs (a, T, abstract_over (x, prop))}; |
764 prop = all T $ Abs (a, T, abstract_over (x, prop))}; |
765 fun check_occs x ts = |
765 fun check_occs a x ts = |
766 if exists (fn t => Logic.occs (x, t)) ts then |
766 if exists (fn t => Logic.occs (x, t)) ts then |
767 raise THM("forall_intr: variable free in assumptions", 0, [th]) |
767 raise THM ("forall_intr: variable " ^ quote a ^ " free in assumptions", 0, [th]) |
768 else (); |
768 else (); |
769 in |
769 in |
770 case x of |
770 case x of |
771 Free (a, _) => (check_occs x hyps; check_occs x (terms_of_tpairs tpairs); result a) |
771 Free (a, _) => (check_occs a x hyps; check_occs a x (terms_of_tpairs tpairs); result a) |
772 | Var ((a, _), _) => (check_occs x (terms_of_tpairs tpairs); result a) |
772 | Var ((a, _), _) => (check_occs a x (terms_of_tpairs tpairs); result a) |
773 | _ => raise THM ("forall_intr: not a variable", 0, [th]) |
773 | _ => raise THM ("forall_intr: not a variable", 0, [th]) |
774 end; |
774 end; |
775 |
775 |
776 (*Forall elimination |
776 (*Forall elimination |
777 !!x. A |
777 !!x. A |
897 *) |
897 *) |
898 fun abstract_rule a |
898 fun abstract_rule a |
899 (Cterm {t = x, T, sorts, ...}) |
899 (Cterm {t = x, T, sorts, ...}) |
900 (th as Thm {thy_ref, der, maxidx, hyps, shyps, tpairs, prop, ...}) = |
900 (th as Thm {thy_ref, der, maxidx, hyps, shyps, tpairs, prop, ...}) = |
901 let |
901 let |
902 val string_of = Sign.string_of_term (Theory.deref thy_ref); |
|
903 val (t, u) = Logic.dest_equals prop |
902 val (t, u) = Logic.dest_equals prop |
904 handle TERM _ => raise THM ("abstract_rule: premise not an equality", 0, [th]); |
903 handle TERM _ => raise THM ("abstract_rule: premise not an equality", 0, [th]); |
905 val result = |
904 val result = |
906 Thm {thy_ref = thy_ref, |
905 Thm {thy_ref = thy_ref, |
907 der = Pt.infer_derivs' (Pt.abstract_rule x a) der, |
906 der = Pt.infer_derivs' (Pt.abstract_rule x a) der, |
910 shyps = Sorts.union sorts shyps, |
909 shyps = Sorts.union sorts shyps, |
911 hyps = hyps, |
910 hyps = hyps, |
912 tpairs = tpairs, |
911 tpairs = tpairs, |
913 prop = Logic.mk_equals |
912 prop = Logic.mk_equals |
914 (Abs (a, T, abstract_over (x, t)), Abs (a, T, abstract_over (x, u)))}; |
913 (Abs (a, T, abstract_over (x, t)), Abs (a, T, abstract_over (x, u)))}; |
915 fun check_occs x ts = |
914 fun check_occs a x ts = |
916 if exists (fn t => Logic.occs (x, t)) ts then |
915 if exists (fn t => Logic.occs (x, t)) ts then |
917 raise THM ("abstract_rule: variable free in assumptions " ^ string_of x, 0, [th]) |
916 raise THM ("abstract_rule: variable " ^ quote a ^ " free in assumptions", 0, [th]) |
918 else (); |
917 else (); |
919 in |
918 in |
920 case x of |
919 case x of |
921 Free _ => (check_occs x hyps; check_occs x (terms_of_tpairs tpairs); result) |
920 Free (a, _) => (check_occs a x hyps; check_occs a x (terms_of_tpairs tpairs); result) |
922 | Var _ => (check_occs x (terms_of_tpairs tpairs); result) |
921 | Var ((a, _), _) => (check_occs a x (terms_of_tpairs tpairs); result) |
923 | _ => raise THM ("abstract_rule: not a variable " ^ string_of x, 0, [th]) |
922 | _ => raise THM ("abstract_rule: not a variable", 0, [th]) |
924 end; |
923 end; |
925 |
924 |
926 (*The combination rule |
925 (*The combination rule |
927 f == g t == u |
926 f == g t == u |
928 -------------- |
927 -------------- |