src/HOL/IntDiv.thy
changeset 29045 3c8f48333731
parent 28562 4e74209f113e
child 29403 fe17df4e4ab3
equal deleted inserted replaced
29041:9dbf8249d979 29045:3c8f48333731
  1469   IntDiv.zmod_zadd_right_eq [symmetric]
  1469   IntDiv.zmod_zadd_right_eq [symmetric]
  1470   IntDiv.zmod_zmult1_eq     [symmetric]
  1470   IntDiv.zmod_zmult1_eq     [symmetric]
  1471   IntDiv.zmod_zmult1_eq'    [symmetric]
  1471   IntDiv.zmod_zmult1_eq'    [symmetric]
  1472   IntDiv.zpower_zmod
  1472   IntDiv.zpower_zmod
  1473   zminus_zmod zdiff_zmod_left zdiff_zmod_right
  1473   zminus_zmod zdiff_zmod_left zdiff_zmod_right
       
  1474 
       
  1475 text {* Distributive laws for function @{text nat}. *}
       
  1476 
       
  1477 lemma nat_div_distrib: "0 \<le> x \<Longrightarrow> nat (x div y) = nat x div nat y"
       
  1478 apply (rule linorder_cases [of y 0])
       
  1479 apply (simp add: div_nonneg_neg_le0)
       
  1480 apply simp
       
  1481 apply (simp add: nat_eq_iff pos_imp_zdiv_nonneg_iff zdiv_int)
       
  1482 done
       
  1483 
       
  1484 (*Fails if y<0: the LHS collapses to (nat z) but the RHS doesn't*)
       
  1485 lemma nat_mod_distrib:
       
  1486   "\<lbrakk>0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> nat (x mod y) = nat x mod nat y"
       
  1487 apply (case_tac "y = 0", simp add: DIVISION_BY_ZERO)
       
  1488 apply (simp add: nat_eq_iff zmod_int)
       
  1489 done
       
  1490 
       
  1491 text{*Suggested by Matthias Daum*}
       
  1492 lemma int_div_less_self: "\<lbrakk>0 < x; 1 < k\<rbrakk> \<Longrightarrow> x div k < (x::int)"
       
  1493 apply (subgoal_tac "nat x div nat k < nat x")
       
  1494  apply (simp (asm_lr) add: nat_div_distrib [symmetric])
       
  1495 apply (rule Divides.div_less_dividend, simp_all)
       
  1496 done
  1474 
  1497 
  1475 text {* code generator setup *}
  1498 text {* code generator setup *}
  1476 
  1499 
  1477 context ring_1
  1500 context ring_1
  1478 begin
  1501 begin