src/HOL/Divides.thy
changeset 55085 0e8e4dc55866
parent 54489 03ff4d1e6784
child 55172 92735f0d5302
equal deleted inserted replaced
55084:8ee9aabb2bca 55085:0e8e4dc55866
  1060 lemma divmod_nat_rel_mult2_eq:
  1060 lemma divmod_nat_rel_mult2_eq:
  1061   "divmod_nat_rel a b (q, r)
  1061   "divmod_nat_rel a b (q, r)
  1062    \<Longrightarrow> divmod_nat_rel a (b * c) (q div c, b *(q mod c) + r)"
  1062    \<Longrightarrow> divmod_nat_rel a (b * c) (q div c, b *(q mod c) + r)"
  1063 by (auto simp add: mult_ac divmod_nat_rel_def add_mult_distrib2 [symmetric] mod_lemma)
  1063 by (auto simp add: mult_ac divmod_nat_rel_def add_mult_distrib2 [symmetric] mod_lemma)
  1064 
  1064 
  1065 lemma div_mult2_eq: "a div (b*c) = (a div b) div (c::nat)"
  1065 lemma div_mult2_eq: "a div (b * c) = (a div b) div (c::nat)"
  1066 by (force simp add: divmod_nat_rel [THEN divmod_nat_rel_mult2_eq, THEN div_nat_unique])
  1066 by (force simp add: divmod_nat_rel [THEN divmod_nat_rel_mult2_eq, THEN div_nat_unique])
  1067 
  1067 
  1068 lemma mod_mult2_eq: "a mod (b*c) = b*(a div b mod c) + a mod (b::nat)"
  1068 lemma mod_mult2_eq: "a mod (b * c) = b * (a div b mod c) + a mod (b::nat)"
  1069 by (auto simp add: mult_commute divmod_nat_rel [THEN divmod_nat_rel_mult2_eq, THEN mod_nat_unique])
  1069 by (auto simp add: mult_commute divmod_nat_rel [THEN divmod_nat_rel_mult2_eq, THEN mod_nat_unique])
  1070 
  1070 
  1071 
  1071 
  1072 subsubsection {* Further Facts about Quotient and Remainder *}
  1072 subsubsection {* Further Facts about Quotient and Remainder *}
  1073 
  1073 
  2134 lemma zmod_zdiv_equality':
  2134 lemma zmod_zdiv_equality':
  2135   "(m\<Colon>int) mod n = m - (m div n) * n"
  2135   "(m\<Colon>int) mod n = m - (m div n) * n"
  2136   using mod_div_equality [of m n] by arith
  2136   using mod_div_equality [of m n] by arith
  2137 
  2137 
  2138 
  2138 
  2139 subsubsection {* Proving  @{term "a div (b*c) = (a div b) div c"} *}
  2139 subsubsection {* Proving  @{term "a div (b * c) = (a div b) div c"} *}
  2140 
  2140 
  2141 (*The condition c>0 seems necessary.  Consider that 7 div ~6 = ~2 but
  2141 (*The condition c>0 seems necessary.  Consider that 7 div ~6 = ~2 but
  2142   7 div 2 div ~3 = 3 div ~3 = ~1.  The subcase (a div b) mod c = 0 seems
  2142   7 div 2 div ~3 = 3 div ~3 = ~1.  The subcase (a div b) mod c = 0 seems
  2143   to cause particular problems.*)
  2143   to cause particular problems.*)
  2144 
  2144 
  2145 text{*first, four lemmas to bound the remainder for the cases b<0 and b>0 *}
  2145 text{*first, four lemmas to bound the remainder for the cases b<0 and b>0 *}
  2146 
  2146 
  2147 lemma zmult2_lemma_aux1: "[| (0::int) < c;  b < r;  r \<le> 0 |] ==> b*c < b*(q mod c) + r"
  2147 lemma zmult2_lemma_aux1: "[| (0::int) < c;  b < r;  r \<le> 0 |] ==> b * c < b * (q mod c) + r"
  2148 apply (subgoal_tac "b * (c - q mod c) < r * 1")
  2148 apply (subgoal_tac "b * (c - q mod c) < r * 1")
  2149  apply (simp add: algebra_simps)
  2149  apply (simp add: algebra_simps)
  2150 apply (rule order_le_less_trans)
  2150 apply (rule order_le_less_trans)
  2151  apply (erule_tac [2] mult_strict_right_mono)
  2151  apply (erule_tac [2] mult_strict_right_mono)
  2152  apply (rule mult_left_mono_neg)
  2152  apply (rule mult_left_mono_neg)