src/HOL/Nat.thy
changeset 14193 30e41f63712e
parent 14131 a4fc8b1af5e7
child 14208 144f45277d5a
equal deleted inserted replaced
14192:d6cb80cc1d20 14193:30e41f63712e
   625 
   625 
   626 subsection {* Basic rewrite rules for the arithmetic operators *}
   626 subsection {* Basic rewrite rules for the arithmetic operators *}
   627 
   627 
   628 text {* Difference *}
   628 text {* Difference *}
   629 
   629 
   630 lemma diff_0_eq_0 [simp]: "0 - n = (0::nat)"
   630 lemma diff_0_eq_0 [simp, code]: "0 - n = (0::nat)"
   631   by (induct_tac n) simp_all
   631   by (induct_tac n) simp_all
   632 
   632 
   633 lemma diff_Suc_Suc [simp]: "Suc(m) - Suc(n) = m - n"
   633 lemma diff_Suc_Suc [simp, code]: "Suc(m) - Suc(n) = m - n"
   634   by (induct_tac n) simp_all
   634   by (induct_tac n) simp_all
   635 
   635 
   636 
   636 
   637 text {*
   637 text {*
   638   Could be (and is, below) generalized in various ways
   638   Could be (and is, below) generalized in various ways
   640   and I dread to think what happens if I put them in
   640   and I dread to think what happens if I put them in
   641 *}
   641 *}
   642 lemma Suc_pred [simp]: "0 < n ==> Suc (n - Suc 0) = n"
   642 lemma Suc_pred [simp]: "0 < n ==> Suc (n - Suc 0) = n"
   643   by (simp split add: nat.split)
   643   by (simp split add: nat.split)
   644 
   644 
   645 declare diff_Suc [simp del]
   645 declare diff_Suc [simp del, code del]
   646 
   646 
   647 
   647 
   648 subsection {* Addition *}
   648 subsection {* Addition *}
   649 
   649 
   650 lemma add_0_right [simp]: "m + 0 = (m::nat)"
   650 lemma add_0_right [simp]: "m + 0 = (m::nat)"
   651   by (induct m) simp_all
   651   by (induct m) simp_all
   652 
   652 
   653 lemma add_Suc_right [simp]: "m + Suc n = Suc (m + n)"
   653 lemma add_Suc_right [simp]: "m + Suc n = Suc (m + n)"
   654   by (induct m) simp_all
   654   by (induct m) simp_all
       
   655 
       
   656 lemma [code]: "Suc m + n = m + Suc n" by simp
   655 
   657 
   656 
   658 
   657 text {* Associative law for addition *}
   659 text {* Associative law for addition *}
   658 lemma add_assoc: "(m + n) + k = m + ((n + k)::nat)"
   660 lemma add_assoc: "(m + n) + k = m + ((n + k)::nat)"
   659   by (induct m) simp_all
   661   by (induct m) simp_all