| 1 |
Require Import CoRN.algebra.RSetoid. |
| 2 |
Require Import CoRN.metric2.Metric. |
| 3 |
Require Import CoRN.metric2.UniformContinuity. |
| 4 |
From Coq Require Import Qabs Qround. |
| 5 |
Require Import CoRN.model.metric2.Qmetric |
| 6 |
CoRN.metric2.ProductMetric |
| 7 |
CoRN.metric2.Prelength |
| 8 |
CoRN.metric2.Compact |
| 9 |
CoRN.model.totalorder.QposMinMax |
| 10 |
CoRN.model.totalorder.QMinMax |
| 11 |
CoRN.reals.faster.ARArith |
| 12 |
CoRN.reals.fast.Interval. |
| 13 |
|
| 14 |
|
| 15 |
(** Proof that intervals are compact. *) |
| 16 |
|
| 17 |
Local Open Scope uc_scope. |
| 18 |
|
| 19 |
Section ARintervalRational. |
| 20 |
Context `{AppRationals AQ}. |
| 21 |
|
| 22 |
(* The computations of the subdivisions are faster when the bounds are |
| 23 |
rational numbers, and this is what we'll use to plot graphs, by |
| 24 |
slightly extending the domains to get rational end points. *) |
| 25 |
Variable a b : Q. |
| 26 |
Hypothesis leab : a <= b. |
| 27 |
|
| 28 |
Lemma plFEQ : PrelengthSpace (FinEnum Q_as_MetricSpace). |
| 29 |
Proof. |
| 30 |
apply FinEnum_prelength. |
| 31 |
apply locatedQ. |
| 32 |
apply QPrelengthSpace. |
| 33 |
Qed. |
| 34 |
|
| 35 |
(* TODO this has twice as many points as CompactIntervalQ, |
| 36 |
fine tune the subdivision. *) |
| 37 |
Lemma Iab_reg_prf |
| 38 |
: is_RegularFunction |
| 39 |
(FinEnum_ball AQ_as_MetricSpace) |
| 40 |
(fun d0:QposInf |
| 41 |
=> match d0 with |
| 42 |
| Qpos2QposInf d |
| 43 |
=> map (λ x : Q, AppInverse0 x ((1 # 2) * d)%Qpos) |
| 44 |
(UniformPartition |
| 45 |
a b |
| 46 |
(Z.to_pos (Qround.Qceiling ((b - a) / (inject_Z 2 * ((1 # 2) * ` d)))))) |
| 47 |
| QposInfinity => nil |
| 48 |
end). |
| 49 |
Proof. |
| 50 |
pose (CompactCompleteCompact |
| 51 |
_ (CompactImage (1#1)%Qpos plFEQ |
| 52 |
(Build_UniformlyContinuousFunction inject_Q_AR_uc) |
| 53 |
(CompactIntervalQ leab))) as K. |
| 54 |
apply (@is_RegularFunction_wd _ (approximate K)). |
| 55 |
2: apply (regFun_prf K). |
| 56 |
intro d. simpl. unfold Cjoin_raw; simpl. |
| 57 |
unfold FinCompact_raw; simpl. |
| 58 |
rewrite map_map; simpl. |
| 59 |
unfold MetricMorphisms.app_inverse. |
| 60 |
unfold canonical_names.equiv. |
| 61 |
unfold FinEnum_eq. simpl. |
| 62 |
apply (@ball_refl (FinEnum AQ_as_MetricSpace) 0). |
| 63 |
discriminate. |
| 64 |
Qed. |
| 65 |
|
| 66 |
Definition IabCompact : Compact AQ_as_MetricSpace |
| 67 |
:= Build_RegularFunction Iab_reg_prf. |
| 68 |
|
| 69 |
End ARintervalRational. |
| 70 |
|