73 have "real_is_int (-1::real) = real_is_int(real (-1::int))" by auto |
73 have "real_is_int (-1::real) = real_is_int(real (-1::int))" by auto |
74 also have "\<dots> = True" by (simp only: real_is_int_real) |
74 also have "\<dots> = True" by (simp only: real_is_int_real) |
75 ultimately show ?thesis by auto |
75 ultimately show ?thesis by auto |
76 qed |
76 qed |
77 |
77 |
78 lemma real_is_int_number_of[simp]: "real_is_int ((number_of \<Colon> int \<Rightarrow> real) x)" |
78 lemma real_is_int_numeral[simp]: "real_is_int (numeral x)" |
79 by (auto simp: real_is_int_def intro!: exI[of _ "number_of x"]) |
79 by (auto simp: real_is_int_def intro!: exI[of _ "numeral x"]) |
|
80 |
|
81 lemma real_is_int_neg_numeral[simp]: "real_is_int (neg_numeral x)" |
|
82 by (auto simp: real_is_int_def intro!: exI[of _ "neg_numeral x"]) |
80 |
83 |
81 lemma int_of_real_0[simp]: "int_of_real (0::real) = (0::int)" |
84 lemma int_of_real_0[simp]: "int_of_real (0::real) = (0::int)" |
82 by (simp add: int_of_real_def) |
85 by (simp add: int_of_real_def) |
83 |
86 |
84 lemma int_of_real_1[simp]: "int_of_real (1::real) = (1::int)" |
87 lemma int_of_real_1[simp]: "int_of_real (1::real) = (1::int)" |
85 proof - |
88 proof - |
86 have 1: "(1::real) = real (1::int)" by auto |
89 have 1: "(1::real) = real (1::int)" by auto |
87 show ?thesis by (simp only: 1 int_of_real_real) |
90 show ?thesis by (simp only: 1 int_of_real_real) |
88 qed |
91 qed |
89 |
92 |
90 lemma int_of_real_number_of[simp]: "int_of_real (number_of b) = number_of b" |
93 lemma int_of_real_numeral[simp]: "int_of_real (numeral b) = numeral b" |
91 unfolding int_of_real_def |
94 unfolding int_of_real_def |
92 by (intro some_equality) |
95 by (intro some_equality) |
93 (auto simp add: real_of_int_inject[symmetric] simp del: real_of_int_inject) |
96 (auto simp add: real_of_int_inject[symmetric] simp del: real_of_int_inject) |
94 |
97 |
|
98 lemma int_of_real_neg_numeral[simp]: "int_of_real (neg_numeral b) = neg_numeral b" |
|
99 unfolding int_of_real_def |
|
100 by (intro some_equality) |
|
101 (auto simp add: real_of_int_inject[symmetric] simp del: real_of_int_inject) |
|
102 |
95 lemma int_div_zdiv: "int (a div b) = (int a) div (int b)" |
103 lemma int_div_zdiv: "int (a div b) = (int a) div (int b)" |
96 by (rule zdiv_int) |
104 by (rule zdiv_int) |
97 |
105 |
98 lemma int_mod_zmod: "int (a mod b) = (int a) mod (int b)" |
106 lemma int_mod_zmod: "int (a mod b) = (int a) mod (int b)" |
99 by (rule zmod_int) |
107 by (rule zmod_int) |
100 |
108 |
101 lemma abs_div_2_less: "a \<noteq> 0 \<Longrightarrow> a \<noteq> -1 \<Longrightarrow> abs((a::int) div 2) < abs a" |
109 lemma abs_div_2_less: "a \<noteq> 0 \<Longrightarrow> a \<noteq> -1 \<Longrightarrow> abs((a::int) div 2) < abs a" |
102 by arith |
110 by arith |
103 |
111 |
104 lemma norm_0_1: "(0::_::number_ring) = Numeral0 & (1::_::number_ring) = Numeral1" |
112 lemma norm_0_1: "(1::_::numeral) = Numeral1" |
105 by auto |
113 by auto |
106 |
114 |
107 lemma add_left_zero: "0 + a = (a::'a::comm_monoid_add)" |
115 lemma add_left_zero: "0 + a = (a::'a::comm_monoid_add)" |
108 by simp |
116 by simp |
109 |
117 |
114 by simp |
122 by simp |
115 |
123 |
116 lemma mult_right_one: "a * 1 = (a::'a::semiring_1)" |
124 lemma mult_right_one: "a * 1 = (a::'a::semiring_1)" |
117 by simp |
125 by simp |
118 |
126 |
119 lemma int_pow_0: "(a::int)^(Numeral0) = 1" |
127 lemma int_pow_0: "(a::int)^0 = 1" |
120 by simp |
128 by simp |
121 |
129 |
122 lemma int_pow_1: "(a::int)^(Numeral1) = a" |
130 lemma int_pow_1: "(a::int)^(Numeral1) = a" |
123 by simp |
131 by simp |
124 |
132 |
125 lemma zero_eq_Numeral0_nring: "(0::'a::number_ring) = Numeral0" |
133 lemma one_eq_Numeral1_nring: "(1::'a::numeral) = Numeral1" |
126 by simp |
|
127 |
|
128 lemma one_eq_Numeral1_nring: "(1::'a::number_ring) = Numeral1" |
|
129 by simp |
|
130 |
|
131 lemma zero_eq_Numeral0_nat: "(0::nat) = Numeral0" |
|
132 by simp |
134 by simp |
133 |
135 |
134 lemma one_eq_Numeral1_nat: "(1::nat) = Numeral1" |
136 lemma one_eq_Numeral1_nat: "(1::nat) = Numeral1" |
135 by simp |
137 by simp |
136 |
138 |
137 lemma zpower_Pls: "(z::int)^Numeral0 = Numeral1" |
139 lemma zpower_Pls: "(z::int)^0 = Numeral1" |
138 by simp |
140 by simp |
139 |
|
140 lemma zpower_Min: "(z::int)^((-1)::nat) = Numeral1" |
|
141 proof - |
|
142 have 1:"((-1)::nat) = 0" |
|
143 by simp |
|
144 show ?thesis by (simp add: 1) |
|
145 qed |
|
146 |
141 |
147 lemma fst_cong: "a=a' \<Longrightarrow> fst (a,b) = fst (a',b)" |
142 lemma fst_cong: "a=a' \<Longrightarrow> fst (a,b) = fst (a',b)" |
148 by simp |
143 by simp |
149 |
144 |
150 lemma snd_cong: "b=b' \<Longrightarrow> snd (a,b) = snd (a,b')" |
145 lemma snd_cong: "b=b' \<Longrightarrow> snd (a,b) = snd (a,b')" |
158 |
153 |
159 lemma not_false_eq_true: "(~ False) = True" by simp |
154 lemma not_false_eq_true: "(~ False) = True" by simp |
160 |
155 |
161 lemma not_true_eq_false: "(~ True) = False" by simp |
156 lemma not_true_eq_false: "(~ True) = False" by simp |
162 |
157 |
163 lemmas binarith = |
158 lemmas powerarith = nat_numeral zpower_numeral_even |
164 normalize_bin_simps |
159 zpower_numeral_odd zpower_Pls |
165 pred_bin_simps succ_bin_simps |
|
166 add_bin_simps minus_bin_simps mult_bin_simps |
|
167 |
|
168 lemma int_eq_number_of_eq: |
|
169 "(((number_of v)::int)=(number_of w)) = iszero ((number_of (v + uminus w))::int)" |
|
170 by (rule eq_number_of_eq) |
|
171 |
|
172 lemma int_iszero_number_of_Pls: "iszero (Numeral0::int)" |
|
173 by (simp only: iszero_number_of_Pls) |
|
174 |
|
175 lemma int_nonzero_number_of_Min: "~(iszero ((-1)::int))" |
|
176 by simp |
|
177 |
|
178 lemma int_iszero_number_of_Bit0: "iszero ((number_of (Int.Bit0 w))::int) = iszero ((number_of w)::int)" |
|
179 by simp |
|
180 |
|
181 lemma int_iszero_number_of_Bit1: "\<not> iszero ((number_of (Int.Bit1 w))::int)" |
|
182 by simp |
|
183 |
|
184 lemma int_less_number_of_eq_neg: "(((number_of x)::int) < number_of y) = neg ((number_of (x + (uminus y)))::int)" |
|
185 unfolding neg_def number_of_is_id by simp |
|
186 |
|
187 lemma int_not_neg_number_of_Pls: "\<not> (neg (Numeral0::int))" |
|
188 by simp |
|
189 |
|
190 lemma int_neg_number_of_Min: "neg (-1::int)" |
|
191 by simp |
|
192 |
|
193 lemma int_neg_number_of_Bit0: "neg ((number_of (Int.Bit0 w))::int) = neg ((number_of w)::int)" |
|
194 by simp |
|
195 |
|
196 lemma int_neg_number_of_Bit1: "neg ((number_of (Int.Bit1 w))::int) = neg ((number_of w)::int)" |
|
197 by simp |
|
198 |
|
199 lemma int_le_number_of_eq: "(((number_of x)::int) \<le> number_of y) = (\<not> neg ((number_of (y + (uminus x)))::int))" |
|
200 unfolding neg_def number_of_is_id by (simp add: not_less) |
|
201 |
|
202 lemmas intarithrel = |
|
203 int_eq_number_of_eq |
|
204 lift_bool[OF int_iszero_number_of_Pls] nlift_bool[OF int_nonzero_number_of_Min] int_iszero_number_of_Bit0 |
|
205 lift_bool[OF int_iszero_number_of_Bit1] int_less_number_of_eq_neg nlift_bool[OF int_not_neg_number_of_Pls] lift_bool[OF int_neg_number_of_Min] |
|
206 int_neg_number_of_Bit0 int_neg_number_of_Bit1 int_le_number_of_eq |
|
207 |
|
208 lemma int_number_of_add_sym: "((number_of v)::int) + number_of w = number_of (v + w)" |
|
209 by simp |
|
210 |
|
211 lemma int_number_of_diff_sym: "((number_of v)::int) - number_of w = number_of (v + (uminus w))" |
|
212 by simp |
|
213 |
|
214 lemma int_number_of_mult_sym: "((number_of v)::int) * number_of w = number_of (v * w)" |
|
215 by simp |
|
216 |
|
217 lemma int_number_of_minus_sym: "- ((number_of v)::int) = number_of (uminus v)" |
|
218 by simp |
|
219 |
|
220 lemmas intarith = int_number_of_add_sym int_number_of_minus_sym int_number_of_diff_sym int_number_of_mult_sym |
|
221 |
|
222 lemmas natarith = add_nat_number_of diff_nat_number_of mult_nat_number_of eq_nat_number_of less_nat_number_of |
|
223 |
|
224 lemmas powerarith = nat_number_of zpower_number_of_even |
|
225 zpower_number_of_odd[simplified zero_eq_Numeral0_nring one_eq_Numeral1_nring] |
|
226 zpower_Pls zpower_Min |
|
227 |
160 |
228 definition float :: "(int \<times> int) \<Rightarrow> real" where |
161 definition float :: "(int \<times> int) \<Rightarrow> real" where |
229 "float = (\<lambda>(a, b). real a * 2 powr real b)" |
162 "float = (\<lambda>(a, b). real a * 2 powr real b)" |
230 |
163 |
231 lemma float_add_l0: "float (0, e) + x = x" |
164 lemma float_add_l0: "float (0, e) + x = x" |
300 |
233 |
301 lemmas floatarith[simplified norm_0_1] = float_add float_add_l0 float_add_r0 float_mult float_mult_l0 float_mult_r0 |
234 lemmas floatarith[simplified norm_0_1] = float_add float_add_l0 float_add_r0 float_mult float_mult_l0 float_mult_r0 |
302 float_minus float_abs zero_le_float float_pprt float_nprt pprt_lbound nprt_ubound |
235 float_minus float_abs zero_le_float float_pprt float_nprt pprt_lbound nprt_ubound |
303 |
236 |
304 (* for use with the compute oracle *) |
237 (* for use with the compute oracle *) |
305 lemmas arith = binarith intarith intarithrel natarith powerarith floatarith not_false_eq_true not_true_eq_false |
238 lemmas arith = arith_simps rel_simps diff_nat_numeral nat_0 |
|
239 nat_neg_numeral powerarith floatarith not_false_eq_true not_true_eq_false |
306 |
240 |
307 use "~~/src/HOL/Tools/float_arith.ML" |
241 use "~~/src/HOL/Tools/float_arith.ML" |
308 |
242 |
309 end |
243 end |