| 1 |
Require Import |
| 2 |
MathClasses.interfaces.abstract_algebra |
| 3 |
CoRN.stdlib_omissions.Q |
| 4 |
CoRN.algebra.RSetoid |
| 5 |
CoRN.metric2.Metric |
| 6 |
CoRN.metric2.UniformContinuity |
| 7 |
CoRN.reals.fast.CRpi_fast |
| 8 |
CoRN.reals.fast.CRarctan_small |
| 9 |
CoRN.reals.faster.ARarctan_small. |
| 10 |
|
| 11 |
Section ARpi. |
| 12 |
Context `{AppRationals AQ}. |
| 13 |
|
| 14 |
Lemma AQpi_prf (x : Z) : 1 < x → -('x : AQ) < 1 < ('x : AQ). |
| 15 |
Proof. |
| 16 |
split. 2: apply semirings.preserves_gt_1, H5. |
| 17 |
rewrite <- (rings.preserves_1 (f:=cast Z AQ)). |
| 18 |
rewrite <- (rings.preserves_negate (f:=cast Z AQ)). |
| 19 |
apply (strictly_order_preserving (cast Z AQ)). |
| 20 |
unfold one, stdlib_binary_integers.Z_1. |
| 21 |
rewrite <- (Z.opp_involutive 1). |
| 22 |
apply Z.gt_lt, CornBasics.Zlt_opp. |
| 23 |
apply (Z.lt_trans _ 1). reflexivity. exact H5. |
| 24 |
Qed. |
| 25 |
|
| 26 |
Lemma ZtoAQ_pos : forall (z:Z), 0 < z -> 0 < ('z : AQ). |
| 27 |
Proof. |
| 28 |
intros z zpos. |
| 29 |
pose proof (rings.preserves_0 (f:=cast Z AQ)). |
| 30 |
rewrite <- H5. |
| 31 |
exact (strictly_order_preserving (cast Z AQ) 0 z zpos). |
| 32 |
Qed. |
| 33 |
|
| 34 |
Definition AQpi (x : AQ) : msp_car AR := |
| 35 |
ucFun (ARscale (' 176%Z * x)) |
| 36 |
(AQarctan_small (AQpi_prf 57 eq_refl) (ZtoAQ_pos 57 eq_refl)) + |
| 37 |
ucFun (ARscale (' 28%Z * x)) |
| 38 |
(AQarctan_small (AQpi_prf 239 eq_refl) (ZtoAQ_pos 239 eq_refl)) + |
| 39 |
(ucFun (ARscale (' (-48)%Z * x)) |
| 40 |
(AQarctan_small (AQpi_prf 682 eq_refl) (ZtoAQ_pos 682 eq_refl)) + |
| 41 |
ucFun (ARscale (' 96%Z * x)) |
| 42 |
(AQarctan_small (AQpi_prf 12943 eq_refl) (ZtoAQ_pos 12943 eq_refl))). |
| 43 |
|
| 44 |
Lemma ARtoCR_preserves_AQpi x : 'AQpi x = r_pi ('x). |
| 45 |
Proof. |
| 46 |
unfold AQpi, r_pi. |
| 47 |
assert (∀ (k : Z) (d : positive) |
| 48 |
(Pnd: -(cast Z AQ (Zpos d)) < 1 < cast Z AQ (Zpos d)) |
| 49 |
(dpos : 0 < cast Z AQ (Zpos d)) |
| 50 |
(Pa : (-1 <= 1#d <= 1)%Q), |
| 51 |
' ucFun (ARscale ('k * x)) (AQarctan_small Pnd dpos) |
| 52 |
= ucFun (scale (inject_Z k * 'x)) (rational_arctan_small Pa)) as PP. |
| 53 |
{ intros. |
| 54 |
rewrite ARtoCR_preserves_scale. |
| 55 |
apply Cmap_wd. |
| 56 |
rewrite rings.preserves_mult, AQtoQ_ZtoAQ. |
| 57 |
reflexivity. |
| 58 |
rewrite AQarctan_small_correct. |
| 59 |
rewrite rational_arctan_small_wd. |
| 60 |
reflexivity. |
| 61 |
rewrite rings.preserves_1. |
| 62 |
pose proof (AQtoQ_ZtoAQ (Zpos d)). rewrite H5. |
| 63 |
reflexivity. } |
| 64 |
assert (forall x y : msp_car AR, ARtoCR (x+y) = 'x + 'y) as plusMorph. |
| 65 |
{ intros x0 y. apply (rings.preserves_plus x0 y). } |
| 66 |
unfold cast. unfold cast in plusMorph. |
| 67 |
rewrite plusMorph. apply ucFun2_wd. |
| 68 |
rewrite plusMorph. apply ucFun2_wd. |
| 69 |
apply PP. apply PP. |
| 70 |
rewrite plusMorph. |
| 71 |
apply ucFun2_wd. apply PP. apply PP. |
| 72 |
Qed. |
| 73 |
|
| 74 |
Definition ARpi := AQpi 1. |
| 75 |
|
| 76 |
Lemma ARtoCR_preserves_pi : 'ARpi = CRpi. |
| 77 |
Proof. |
| 78 |
unfold ARpi, CRpi. |
| 79 |
rewrite ARtoCR_preserves_AQpi. |
| 80 |
rewrite rings.preserves_1. |
| 81 |
reflexivity. |
| 82 |
Qed. |
| 83 |
|
| 84 |
End ARpi. |