equal
deleted
inserted
replaced
218 |
218 |
219 lemma of_int_minus [simp]: "of_int (-z) = - (of_int z)" |
219 lemma of_int_minus [simp]: "of_int (-z) = - (of_int z)" |
220 by (transfer fixing: uminus) clarsimp |
220 by (transfer fixing: uminus) clarsimp |
221 |
221 |
222 lemma of_int_diff [simp]: "of_int (w - z) = of_int w - of_int z" |
222 lemma of_int_diff [simp]: "of_int (w - z) = of_int w - of_int z" |
223 by (simp add: diff_minus Groups.diff_minus) |
223 using of_int_add [of w "- z"] by simp |
224 |
224 |
225 lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z" |
225 lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z" |
226 by (transfer fixing: times) (clarsimp simp add: algebra_simps of_nat_mult) |
226 by (transfer fixing: times) (clarsimp simp add: algebra_simps of_nat_mult) |
227 |
227 |
228 text{*Collapse nested embeddings*} |
228 text{*Collapse nested embeddings*} |
747 |
747 |
748 subsection {* Setting up simplification procedures *} |
748 subsection {* Setting up simplification procedures *} |
749 |
749 |
750 lemmas int_arith_rules = |
750 lemmas int_arith_rules = |
751 neg_le_iff_le numeral_One |
751 neg_le_iff_le numeral_One |
752 minus_zero diff_minus left_minus right_minus |
752 minus_zero left_minus right_minus |
753 mult_zero_left mult_zero_right mult_1_left mult_1_right |
753 mult_zero_left mult_zero_right mult_1_left mult_1_right |
754 mult_minus_left mult_minus_right |
754 mult_minus_left mult_minus_right |
755 minus_add_distrib minus_minus mult_assoc |
755 minus_add_distrib minus_minus mult_assoc |
756 of_nat_0 of_nat_1 of_nat_Suc of_nat_add of_nat_mult |
756 of_nat_0 of_nat_1 of_nat_Suc of_nat_add of_nat_mult |
757 of_int_0 of_int_1 of_int_add of_int_mult |
757 of_int_0 of_int_1 of_int_add of_int_mult |
791 |
791 |
792 |
792 |
793 subsection{*The functions @{term nat} and @{term int}*} |
793 subsection{*The functions @{term nat} and @{term int}*} |
794 |
794 |
795 text{*Simplify the term @{term "w + - z"}*} |
795 text{*Simplify the term @{term "w + - z"}*} |
796 lemmas diff_int_def_symmetric = diff_def [where 'a=int, symmetric, simp] |
|
797 |
796 |
798 lemma one_less_nat_eq [simp]: "(Suc 0 < nat z) = (1 < z)" |
797 lemma one_less_nat_eq [simp]: "(Suc 0 < nat z) = (1 < z)" |
799 apply (insert zless_nat_conj [of 1 z]) |
798 apply (insert zless_nat_conj [of 1 z]) |
800 apply auto |
799 apply auto |
801 done |
800 done |
1508 "sub Num.One (Num.Bit1 n) = Neg (Num.Bit0 n)" |
1507 "sub Num.One (Num.Bit1 n) = Neg (Num.Bit0 n)" |
1509 "sub (Num.Bit0 m) (Num.Bit0 n) = dup (sub m n)" |
1508 "sub (Num.Bit0 m) (Num.Bit0 n) = dup (sub m n)" |
1510 "sub (Num.Bit1 m) (Num.Bit1 n) = dup (sub m n)" |
1509 "sub (Num.Bit1 m) (Num.Bit1 n) = dup (sub m n)" |
1511 "sub (Num.Bit1 m) (Num.Bit0 n) = dup (sub m n) + 1" |
1510 "sub (Num.Bit1 m) (Num.Bit0 n) = dup (sub m n) + 1" |
1512 "sub (Num.Bit0 m) (Num.Bit1 n) = dup (sub m n) - 1" |
1511 "sub (Num.Bit0 m) (Num.Bit1 n) = dup (sub m n) - 1" |
1513 unfolding sub_def dup_def numeral.simps Pos_def Neg_def |
1512 apply (simp_all only: sub_def dup_def numeral.simps Pos_def Neg_def |
1514 neg_numeral_def numeral_BitM |
1513 neg_numeral_def numeral_BitM) |
1515 by (simp_all only: algebra_simps) |
1514 apply (simp_all only: algebra_simps minus_diff_eq) |
1516 |
1515 apply (simp_all only: add.commute [of _ "- (numeral n + numeral n)"]) |
|
1516 apply (simp_all only: minus_add add.assoc left_minus) |
|
1517 apply (simp_all only: algebra_simps right_minus) |
|
1518 done |
1517 |
1519 |
1518 text {* Implementations *} |
1520 text {* Implementations *} |
1519 |
1521 |
1520 lemma one_int_code [code, code_unfold]: |
1522 lemma one_int_code [code, code_unfold]: |
1521 "1 = Pos Num.One" |
1523 "1 = Pos Num.One" |