equal
deleted
inserted
replaced
29 text{*No longer required as a simprule because of the @{text inverse_fold} |
29 text{*No longer required as a simprule because of the @{text inverse_fold} |
30 simproc*} |
30 simproc*} |
31 lemma Suc_diff_number_of: |
31 lemma Suc_diff_number_of: |
32 "neg (number_of (bin_minus v)::int) ==> |
32 "neg (number_of (bin_minus v)::int) ==> |
33 Suc m - (number_of v) = m - (number_of (bin_pred v))" |
33 Suc m - (number_of v) = m - (number_of (bin_pred v))" |
34 apply (subst Suc_diff_eq_diff_pred, simp, simp) |
34 apply (subst Suc_diff_eq_diff_pred) |
35 apply (force simp only: diff_nat_number_of less_0_number_of [symmetric] |
35 apply (simp add: ); |
|
36 apply (simp del: nat_numeral_1_eq_1); |
|
37 apply (auto simp only: diff_nat_number_of less_0_number_of [symmetric] |
36 neg_number_of_bin_pred_iff_0) |
38 neg_number_of_bin_pred_iff_0) |
37 done |
39 done |
38 |
40 |
39 lemma diff_Suc_eq_diff_pred: "m - Suc n = (m - 1) - n" |
41 lemma diff_Suc_eq_diff_pred: "m - Suc n = (m - 1) - n" |
40 by (simp add: numerals split add: nat_diff_split) |
42 by (simp add: numerals split add: nat_diff_split) |
52 "nat_case a f ((number_of v) + n) = |
54 "nat_case a f ((number_of v) + n) = |
53 (let pv = number_of (bin_pred v) in |
55 (let pv = number_of (bin_pred v) in |
54 if neg pv then nat_case a f n else f (nat pv + n))" |
56 if neg pv then nat_case a f n else f (nat pv + n))" |
55 apply (subst add_eq_if) |
57 apply (subst add_eq_if) |
56 apply (simp split add: nat.split |
58 apply (simp split add: nat.split |
57 add: numeral_1_eq_Suc_0 [symmetric] Let_def |
59 del: nat_numeral_1_eq_1 |
|
60 add: numeral_1_eq_Suc_0 [symmetric] Let_def |
58 neg_imp_number_of_eq_0 neg_number_of_bin_pred_iff_0) |
61 neg_imp_number_of_eq_0 neg_number_of_bin_pred_iff_0) |
59 done |
62 done |
60 |
63 |
61 lemma nat_rec_number_of [simp]: |
64 lemma nat_rec_number_of [simp]: |
62 "nat_rec a f (number_of v) = |
65 "nat_rec a f (number_of v) = |
72 (let pv = number_of (bin_pred v) in |
75 (let pv = number_of (bin_pred v) in |
73 if neg pv then nat_rec a f n |
76 if neg pv then nat_rec a f n |
74 else f (nat pv + n) (nat_rec a f (nat pv + n)))" |
77 else f (nat pv + n) (nat_rec a f (nat pv + n)))" |
75 apply (subst add_eq_if) |
78 apply (subst add_eq_if) |
76 apply (simp split add: nat.split |
79 apply (simp split add: nat.split |
|
80 del: nat_numeral_1_eq_1 |
77 add: numeral_1_eq_Suc_0 [symmetric] Let_def neg_imp_number_of_eq_0 |
81 add: numeral_1_eq_Suc_0 [symmetric] Let_def neg_imp_number_of_eq_0 |
78 neg_number_of_bin_pred_iff_0) |
82 neg_number_of_bin_pred_iff_0) |
79 done |
83 done |
80 |
84 |
81 |
85 |
103 lemma add_2_eq_Suc [simp]: "2 + n = Suc (Suc n)" |
107 lemma add_2_eq_Suc [simp]: "2 + n = Suc (Suc n)" |
104 by simp |
108 by simp |
105 |
109 |
106 lemma add_2_eq_Suc' [simp]: "n + 2 = Suc (Suc n)" |
110 lemma add_2_eq_Suc' [simp]: "n + 2 = Suc (Suc n)" |
107 by simp |
111 by simp |
108 |
|
109 declare numeral_0_eq_0 [simp] numeral_1_eq_1 [simp] |
|
110 |
112 |
111 text{*Can be used to eliminate long strings of Sucs, but not by default*} |
113 text{*Can be used to eliminate long strings of Sucs, but not by default*} |
112 lemma Suc3_eq_add_3: "Suc (Suc (Suc n)) = 3 + n" |
114 lemma Suc3_eq_add_3: "Suc (Suc (Suc n)) = 3 + n" |
113 by simp |
115 by simp |
114 |
116 |
192 declare divide_less_eq [of _ "number_of w", standard, simp] |
194 declare divide_less_eq [of _ "number_of w", standard, simp] |
193 declare eq_divide_eq [of _ _ "number_of w", standard, simp] |
195 declare eq_divide_eq [of _ _ "number_of w", standard, simp] |
194 declare divide_eq_eq [of _ "number_of w", standard, simp] |
196 declare divide_eq_eq [of _ "number_of w", standard, simp] |
195 |
197 |
196 |
198 |
|
199 subsubsection{*Division By @{term "-1"}*} |
|
200 |
|
201 lemma divide_minus1 [simp]: |
|
202 "x/-1 = -(x::'a::{field,division_by_zero,number_ring})" |
|
203 by simp |
|
204 |
|
205 lemma minus1_divide [simp]: |
|
206 "-1 / (x::'a::{field,division_by_zero,number_ring}) = - (1/x)" |
|
207 by (simp add: divide_inverse_zero inverse_minus_eq) |
|
208 |
|
209 ML |
|
210 {* |
|
211 val divide_minus1 = thm "divide_minus1"; |
|
212 val minus1_divide = thm "minus1_divide"; |
|
213 *} |
|
214 |
197 end |
215 end |