src/HOL/Numeral_Simprocs.thy
 changeset 33366 b0096ac3b731 child 37886 2f9d3fc1a8ac
```     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/HOL/Numeral_Simprocs.thy	Fri Oct 30 18:33:07 2009 +0100
1.3 @@ -0,0 +1,120 @@
1.4 +(* Author: Various *)
1.5 +
1.6 +header {* Combination and Cancellation Simprocs for Numeral Expressions *}
1.7 +
1.8 +theory Numeral_Simprocs
1.9 +imports Divides
1.10 +uses
1.11 +  "~~/src/Provers/Arith/assoc_fold.ML"
1.12 +  "~~/src/Provers/Arith/cancel_numerals.ML"
1.13 +  "~~/src/Provers/Arith/combine_numerals.ML"
1.14 +  "~~/src/Provers/Arith/cancel_numeral_factor.ML"
1.15 +  "~~/src/Provers/Arith/extract_common_term.ML"
1.16 +  ("Tools/numeral_simprocs.ML")
1.17 +  ("Tools/nat_numeral_simprocs.ML")
1.18 +begin
1.19 +
1.20 +declare split_div [of _ _ "number_of k", standard, arith_split]
1.21 +declare split_mod [of _ _ "number_of k", standard, arith_split]
1.22 +
1.23 +text {* For @{text combine_numerals} *}
1.24 +
1.25 +lemma left_add_mult_distrib: "i*u + (j*u + k) = (i+j)*u + (k::nat)"
1.27 +
1.28 +text {* For @{text cancel_numerals} *}
1.29 +
1.31 +     "j <= (i::nat) ==> ((i*u + m) - (j*u + n)) = (((i-j)*u + m) - n)"
1.33 +
1.35 +     "i <= (j::nat) ==> ((i*u + m) - (j*u + n)) = (m - ((j-i)*u + n))"
1.37 +
1.39 +     "j <= (i::nat) ==> (i*u + m = j*u + n) = ((i-j)*u + m = n)"
1.41 +
1.43 +     "i <= (j::nat) ==> (i*u + m = j*u + n) = (m = (j-i)*u + n)"
1.45 +
1.47 +     "j <= (i::nat) ==> (i*u + m < j*u + n) = ((i-j)*u + m < n)"
1.49 +
1.51 +     "i <= (j::nat) ==> (i*u + m < j*u + n) = (m < (j-i)*u + n)"
1.53 +
1.55 +     "j <= (i::nat) ==> (i*u + m <= j*u + n) = ((i-j)*u + m <= n)"
1.57 +
1.59 +     "i <= (j::nat) ==> (i*u + m <= j*u + n) = (m <= (j-i)*u + n)"
1.61 +
1.62 +text {* For @{text cancel_numeral_factors} *}
1.63 +
1.64 +lemma nat_mult_le_cancel1: "(0::nat) < k ==> (k*m <= k*n) = (m<=n)"
1.65 +by auto
1.66 +
1.67 +lemma nat_mult_less_cancel1: "(0::nat) < k ==> (k*m < k*n) = (m<n)"
1.68 +by auto
1.69 +
1.70 +lemma nat_mult_eq_cancel1: "(0::nat) < k ==> (k*m = k*n) = (m=n)"
1.71 +by auto
1.72 +
1.73 +lemma nat_mult_div_cancel1: "(0::nat) < k ==> (k*m) div (k*n) = (m div n)"
1.74 +by auto
1.75 +
1.76 +lemma nat_mult_dvd_cancel_disj[simp]:
1.77 +  "(k*m) dvd (k*n) = (k=0 | m dvd (n::nat))"
1.78 +by(auto simp: dvd_eq_mod_eq_0 mod_mult_distrib2[symmetric])
1.79 +
1.80 +lemma nat_mult_dvd_cancel1: "0 < k \<Longrightarrow> (k*m) dvd (k*n::nat) = (m dvd n)"
1.81 +by(auto)
1.82 +
1.83 +text {* For @{text cancel_factor} *}
1.84 +
1.85 +lemma nat_mult_le_cancel_disj: "(k*m <= k*n) = ((0::nat) < k --> m<=n)"
1.86 +by auto
1.87 +
1.88 +lemma nat_mult_less_cancel_disj: "(k*m < k*n) = ((0::nat) < k & m<n)"
1.89 +by auto
1.90 +
1.91 +lemma nat_mult_eq_cancel_disj: "(k*m = k*n) = (k = (0::nat) | m=n)"
1.92 +by auto
1.93 +
1.94 +lemma nat_mult_div_cancel_disj[simp]:
1.95 +     "(k*m) div (k*n) = (if k = (0::nat) then 0 else m div n)"
1.97 +
1.98 +
1.99 +use "Tools/numeral_simprocs.ML"
1.100 +
1.101 +use "Tools/nat_numeral_simprocs.ML"
1.102 +
1.103 +declaration {*
1.104 +  K (Lin_Arith.add_simps (@{thms neg_simps} @ [@{thm Suc_nat_number_of}, @{thm int_nat_number_of}])
1.105 +  #> Lin_Arith.add_simps (@{thms ring_distribs} @ [@{thm Let_number_of}, @{thm Let_0}, @{thm Let_1},
1.106 +     @{thm nat_0}, @{thm nat_1},
1.107 +     @{thm add_nat_number_of}, @{thm diff_nat_number_of}, @{thm mult_nat_number_of},
1.108 +     @{thm eq_nat_number_of}, @{thm less_nat_number_of}, @{thm le_number_of_eq_not_less},
1.109 +     @{thm le_Suc_number_of}, @{thm le_number_of_Suc},
1.110 +     @{thm less_Suc_number_of}, @{thm less_number_of_Suc},
1.111 +     @{thm Suc_eq_number_of}, @{thm eq_number_of_Suc},
1.112 +     @{thm mult_Suc}, @{thm mult_Suc_right},