src/HOL/Integ/Bin.ML
changeset 7074 e0730ffaafcc
parent 7033 c7479ae352b1
child 7517 bad2f36810e1
equal deleted inserted replaced
7073:a959b4391fd8 7074:e0730ffaafcc
     1 (*  Title:      HOL/Integ/Bin.ML
     1 (*  Title:      HOL/Integ/Bin.ML
       
     2     ID:         $Id$
     2     Authors:    Lawrence C Paulson, Cambridge University Computer Laboratory
     3     Authors:    Lawrence C Paulson, Cambridge University Computer Laboratory
     3                 David Spelt, University of Twente 
     4                 David Spelt, University of Twente 
     4                 Tobias Nipkow, Technical University Munich
     5                 Tobias Nipkow, Technical University Munich
     5     Copyright   1994  University of Cambridge
     6     Copyright   1994  University of Cambridge
     6     Copyright   1996  University of Twente
     7     Copyright   1996  University of Twente
   212 
   213 
   213 (** Special simplification, for constants only **)
   214 (** Special simplification, for constants only **)
   214 
   215 
   215 fun inst x t = read_instantiate_sg (sign_of Bin.thy) [(x,t)];
   216 fun inst x t = read_instantiate_sg (sign_of Bin.thy) [(x,t)];
   216 
   217 
   217 (*Distributive laws*)
   218 (*Distributive laws for literals*)
   218 Addsimps (map (inst "w" "number_of ?v")
   219 Addsimps (map (inst "w" "number_of ?v")
   219 	  [zadd_zmult_distrib, zadd_zmult_distrib2,
   220 	  [zadd_zmult_distrib, zadd_zmult_distrib2,
   220 	   zdiff_zmult_distrib, zdiff_zmult_distrib2]);
   221 	   zdiff_zmult_distrib, zdiff_zmult_distrib2]);
   221 
   222 
   222 Addsimps (map (inst "x" "number_of ?v") 
   223 Addsimps (map (inst "x" "number_of ?v") 
   223 	  [zless_zminus, zle_zminus, equation_zminus]);
   224 	  [zless_zminus, zle_zminus, equation_zminus]);
   224 Addsimps (map (inst "y" "number_of ?v") 
   225 Addsimps (map (inst "y" "number_of ?v") 
   225 	  [zminus_zless, zminus_zle, zminus_equation]);
   226 	  [zminus_zless, zminus_zle, zminus_equation]);
   226 
   227 
       
   228 (*Moving negation out of products*)
       
   229 Addsimps [zmult_zminus, zmult_zminus_right];
   227 
   230 
   228 (** Special-case simplification for small constants **)
   231 (** Special-case simplification for small constants **)
   229 
   232 
   230 Goal "#0 * z = (#0::int)";
   233 Goal "#0 * z = (#0::int)";
   231 by (Simp_tac 1);
   234 by (Simp_tac 1);
   724 Goal "n<=m --> int m - int n = int (m-n)";
   727 Goal "n<=m --> int m - int n = int (m-n)";
   725 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   728 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
   726 by Auto_tac;
   729 by Auto_tac;
   727 qed_spec_mp "zdiff_int";
   730 qed_spec_mp "zdiff_int";
   728 
   731 
   729 (*Towards canonical simplification*)
       
   730 Addsimps zadd_ac;
       
   731 Addsimps zmult_ac;
       
   732 Addsimps [zmult_zminus, zmult_zminus_right];
       
   733 
       
   734 
       
   735 
   732 
   736 (** Products of signs **)
   733 (** Products of signs **)
   737 
   734 
   738 Goal "(m::int) < #0 ==> (#0 < m*n) = (n < #0)";
   735 Goal "(m::int) < #0 ==> (#0 < m*n) = (n < #0)";
   739 by Auto_tac;
   736 by Auto_tac;
   740 by (force_tac (claset() addDs [zmult_zless_mono1_neg], simpset()) 2);
   737 by (force_tac (claset() addDs [zmult_zless_mono1_neg], simpset()) 2);
   741 by (eres_inst_tac [("P", "#0 < m * n")] rev_mp 1);
   738 by (eres_inst_tac [("P", "#0 < m * n")] rev_mp 1);
   742 by (simp_tac (simpset() addsimps [linorder_not_le RS sym]) 1);
   739 by (simp_tac (simpset() addsimps [linorder_not_le RS sym]) 1);
   743 by (force_tac (claset() addDs [zmult_zless_mono1_neg], 
   740 by (force_tac (claset() addDs [inst "k" "m" zmult_zless_mono1_neg], 
   744 	       simpset() addsimps [order_le_less]) 1);
   741 	       simpset()addsimps [order_le_less, zmult_commute]) 1);
   745 qed "neg_imp_zmult_pos_iff";
   742 qed "neg_imp_zmult_pos_iff";
   746 
   743 
   747 Goal "(m::int) < #0 ==> (m*n < #0) = (#0 < n)";
   744 Goal "(m::int) < #0 ==> (m*n < #0) = (#0 < n)";
   748 by Auto_tac;
   745 by Auto_tac;
   749 by (force_tac (claset() addDs [zmult_zless_mono1], simpset()) 2);
   746 by (force_tac (claset() addDs [zmult_zless_mono1], simpset()) 2);
   765 Goal "#0 < (m::int) ==> (#0 < m*n) = (#0 < n)";
   762 Goal "#0 < (m::int) ==> (#0 < m*n) = (#0 < n)";
   766 by Auto_tac;
   763 by Auto_tac;
   767 by (force_tac (claset() addDs [zmult_zless_mono1], simpset()) 2);
   764 by (force_tac (claset() addDs [zmult_zless_mono1], simpset()) 2);
   768 by (eres_inst_tac [("P", "#0 < m * n")] rev_mp 1);
   765 by (eres_inst_tac [("P", "#0 < m * n")] rev_mp 1);
   769 by (simp_tac (simpset() addsimps [linorder_not_le RS sym]) 1);
   766 by (simp_tac (simpset() addsimps [linorder_not_le RS sym]) 1);
   770 by (force_tac (claset() addDs [zmult_zless_mono1], 
   767 by (force_tac (claset() addDs [inst "k" "m" zmult_zless_mono1], 
   771 	       simpset() addsimps [order_le_less]) 1);
   768 	       simpset() addsimps [order_le_less, zmult_commute]) 1);
   772 qed "pos_imp_zmult_pos_iff";
   769 qed "pos_imp_zmult_pos_iff";
   773 
   770 
   774 (** <= versions of the theorems above **)
   771 (** <= versions of the theorems above **)
   775 
   772 
   776 Goal "(m::int) < #0 ==> (m*n <= #0) = (#0 <= n)";
   773 Goal "(m::int) < #0 ==> (m*n <= #0) = (#0 <= n)";