5 "HOL-Decision_Procs.Approximation"
8 section \<open> Real numbers and the basic unary and binary operators \<close>
10 why3_open "real/Real.xml"
12 why3_vc infix_lseqqtdef by auto
16 why3_vc Unit_def_l by auto
18 why3_vc Unit_def_r by auto
20 why3_vc Inv_def_l by auto
22 why3_vc Inv_def_r by auto
26 why3_vc Assoc1 by simp
28 why3_vc Mul_distr_l by (simp add: algebra_simps)
30 why3_vc Mul_distr_r by (simp add: Rings.comm_semiring_class.distrib)
32 why3_vc infix_mnqtdef by auto
36 why3_vc Unitary by auto
38 why3_vc NonTrivialRing by auto
40 why3_vc Inverse by (simp add: assms)
42 why3_vc add_div by (simp add: Fields.division_ring_class.add_divide_distrib)
44 why3_vc sub_div by (simp add: Fields.division_ring_class.diff_divide_distrib)
46 why3_vc neg_div by auto
48 why3_vc assoc_mul_div by auto
50 why3_vc assoc_div_mul by auto
52 why3_vc assoc_div_div by auto
66 why3_vc ZeroLessOne by auto
68 why3_vc CompatOrderAdd
72 why3_vc CompatOrderMult
74 by (simp add: Rings.ordered_semiring_class.mult_right_mono)
76 why3_vc infix_slqtdef by (simp add: Real.divide_real_def)
80 section \<open> Alternative Infix Operators \<close>
82 why3_open "real/RealInfix.xml"
86 section \<open> Absolute Value \<close>
88 why3_open "real/Abs.xml"
90 why3_vc Abs_le by auto
92 why3_vc Abs_pos by auto
94 why3_vc Abs_sum by auto
96 why3_vc absqtdef by (simp add: Real.abs_real_def)
98 why3_vc Abs_prod by (simp add: abs_mult)
100 why3_vc triangular_inequality by (simp add: Real.abs_real_def)
104 section \<open> Minimum and Maximum \<close>
106 why3_open "real/MinMax.xml"
116 why3_vc maxqtdef by auto
118 why3_vc minqtdef by auto
120 why3_vc Max_comm by auto
122 why3_vc Min_comm by auto
124 why3_vc Max_assoc by auto
126 why3_vc Min_assoc by auto
130 section \<open> Injection of integers into reals \<close>
132 why3_open "real/FromInt.xml"
148 why3_vc Monotonic using assms by auto
150 why3_vc Injective using assms by auto
154 section \<open> Various truncation functions \<close>
156 (* truncate: rounds towards zero *)
158 definition truncate :: "real \<Rightarrow> int" where
159 "truncate x = (if x \<ge> 0 then floor x else ceiling x)"
161 why3_open "real/Truncate.xml"
167 subsection \<open> Roundings up and down \<close>
170 by (simp_all add: ceiling_correct)
172 why3_vc Ceil_int by auto
174 why3_vc Floor_int by auto
177 by (simp_all add: floor_correct [simplified])
179 why3_vc Ceil_monotonic
181 by (simp add:ceiling_mono)
183 why3_vc Floor_monotonic
185 by (simp add:floor_mono)
187 subsection \<open> Rounding towards zero \<close>
189 why3_vc Real_of_truncate
190 using floor_correct [of x] ceiling_correct [of x]
191 by (simp_all add: truncate_def del: of_int_floor_le le_of_int_ceiling)
193 why3_vc Truncate_int by (simp add: truncate_def)
195 why3_vc Truncate_up_neg
196 using assms ceiling_correct [of x]
197 by (simp_all add: truncate_def)
199 why3_vc Truncate_down_pos
200 using assms floor_correct [of x]
201 by (simp_all add: truncate_def)
203 why3_vc Truncate_monotonic
205 unfolding truncate_def
206 by (simp add: floor_mono ceiling_mono order_trans [of "\<lceil>x\<rceil>" 0 "\<lfloor>y\<rfloor>"])
208 why3_vc Truncate_monotonic_int1
210 by (simp add: truncate_def floor_le_iff ceiling_le_iff)
212 why3_vc Truncate_monotonic_int2
214 by (simp add: truncate_def le_floor_iff le_ceiling_iff)
218 section \<open> Square and Square Root \<close>
220 why3_open "real/Square.xml"
228 why3_vc Sqrt_mul by (simp add: NthRoot.real_sqrt_mult)
232 by (simp add: sqr_def)
238 why3_vc Sqrt_positive
244 section \<open> Exponential and Logarithm \<close>
246 why3_open "real/ExpLog.xml"
255 why3_vc Exp_sum by (simp add: Transcendental.exp_add)
257 why3_vc exp_increasing
264 by (simp add: exp_minus)
266 why3_vc exp_sum_opposite
267 by (simp add: exp_minus exp_plus_inverse_exp)
269 why3_vc Log_exp by auto
273 by (simp add: Transcendental.ln_mult)
275 why3_vc Log_one by auto
277 why3_vc Exp_zero by auto
279 why3_vc log_increasing
282 why3_vc log2_increasing
283 using H1 H2 divide_real_def log2_def by auto
285 why3_vc log10_increasing
286 using H1 H2 divide_real_def log10_def by force
290 section \<open> Power of a real to an integer \<close>
292 (* TODO: clones int.Exponentiation which is not yet realized *)
294 why3_open "real/PowerInt.xml"
296 why3_vc Power_0 by auto
298 why3_vc Power_1 by auto
302 by (simp add: nat_add_distrib)
306 by (simp add: nat_add_distrib power_add)
308 why3_vc Pow_ge_one using assms by auto
312 by (simp add: nat_mult_distrib power_mult)
314 why3_vc Power_comm1 by simp
316 why3_vc Power_comm2 by (simp add: semiring_normalization_rules(30))
320 have "nat n = Suc (nat (n - 1))" using assms by auto
321 then show ?thesis by simp
326 section \<open> Power of a real to a real exponent \<close>
328 (* TODO: no power to a real exponent in Isabelle? *)
330 section \<open> Trigonometric Functions \<close>
333 "why3_divide \<equiv> divide"
335 why3_open "real/Trigonometry.xml"
342 why3_vc Cos_0 by auto
344 why3_vc Sin_0 by auto
346 why3_vc Cos_pi by auto
348 why3_vc Sin_pi by auto
350 why3_vc Cos_neg by auto
352 why3_vc Cos_pi2 by auto
354 why3_vc Cos_sum by (simp add: Transcendental.cos_add)
356 why3_vc Sin_neg by auto
358 why3_vc Sin_pi2 by auto
360 why3_vc Sin_sum by (simp add: Transcendental.sin_add)
362 why3_vc tanqtdef by (simp add: Transcendental.tan_def)
364 why3_vc Tan_atan by (simp add: Transcendental.tan_arctan)
366 why3_vc Cos_le_one by auto
368 why3_vc Sin_le_one by auto
370 why3_vc Cos_plus_pi by auto
372 why3_vc Pi_double_precision_bounds
374 have "884279719003555 / 281474976710656 < pi"
375 by (approximation 57)
376 then show ?C1 by simp
377 have "pi < 7074237752028441 / 2251799813685248"
378 by (approximation 55)
379 then show ?C2 by simp
382 why3_vc Sin_plus_pi by auto
384 why3_vc Cos_plus_pi2 by (simp add: Transcendental.minus_sin_cos_eq)
386 why3_vc Sin_plus_pi2 by (simp add: sin_add)
388 why3_vc Pythagorean_identity
389 by (simp add: sqr_def)
393 section \<open> Hyperbolic Functions \<close>
395 (* TODO: missing acosh *)
397 section \<open> Polar Coordinates \<close>
399 (* TODO: missing atan2 *)