frac.v 1.84 KB
 1 ``````From Coq.QArith Require Import Qcanon. `````` Robbert Krebbers committed Mar 10, 2016 2 ``````From iris.algebra Require Export cmra. `````` Robbert Krebbers committed Jun 08, 2017 3 ``````From iris.proofmode Require Import classes. `````` Ralf Jung committed Jan 05, 2017 4 ``````Set Default Proof Using "Type". `````` Robbert Krebbers committed Feb 26, 2016 5 `````` `````` Robbert Krebbers committed Jun 01, 2016 6 ``````Notation frac := Qp (only parsing). `````` Robbert Krebbers committed Feb 26, 2016 7 `````` `````` Jacques-Henri Jourdan committed Jun 01, 2016 8 9 ``````Section frac. Canonical Structure fracC := leibnizC frac. `````` Robbert Krebbers committed Feb 26, 2016 10 `````` `````` Jacques-Henri Jourdan committed Jun 01, 2016 11 12 13 ``````Instance frac_valid : Valid frac := λ x, (x ≤ 1)%Qc. Instance frac_pcore : PCore frac := λ _, None. Instance frac_op : Op frac := λ x y, (x + y)%Qp. `````` Robbert Krebbers committed May 28, 2016 14 `````` `````` Ralf Jung committed Mar 10, 2017 15 ``````Lemma frac_included (x y : frac) : x ≼ y ↔ (x < y)%Qc. `````` Robbert Krebbers committed Mar 11, 2017 16 ``````Proof. by rewrite Qp_lt_sum. Qed. `````` Ralf Jung committed Mar 10, 2017 17 `````` `````` Robbert Krebbers committed Oct 02, 2016 18 19 20 ``````Corollary frac_included_weak (x y : frac) : x ≼ y → (x ≤ y)%Qc. Proof. intros ?%frac_included. auto using Qclt_le_weak. Qed. `````` Jacques-Henri Jourdan committed Jun 01, 2016 21 ``````Definition frac_ra_mixin : RAMixin frac. `````` Robbert Krebbers committed Feb 26, 2016 22 ``````Proof. `````` Jacques-Henri Jourdan committed Jun 01, 2016 23 `````` split; try apply _; try done. `````` Robbert Krebbers committed Jun 01, 2016 24 `````` unfold valid, op, frac_op, frac_valid. intros x y. trans (x+y)%Qp; last done. `````` Jacques-Henri Jourdan committed Jun 01, 2016 25 `````` rewrite -{1}(Qcplus_0_r x) -Qcplus_le_mono_l; auto using Qclt_le_weak. `````` Robbert Krebbers committed Feb 26, 2016 26 ``````Qed. `````` Jacques-Henri Jourdan committed Jun 01, 2016 27 ``````Canonical Structure fracR := discreteR frac frac_ra_mixin. `````` Robbert Krebbers committed Feb 09, 2017 28 29 30 `````` Global Instance frac_cmra_discrete : CMRADiscrete fracR. Proof. apply discrete_cmra_discrete. Qed. `````` Jacques-Henri Jourdan committed Jun 01, 2016 31 ``````End frac. `````` Robbert Krebbers committed Feb 26, 2016 32 `````` `````` Jacques-Henri Jourdan committed Jun 01, 2016 33 ``````Global Instance frac_full_exclusive : Exclusive 1%Qp. `````` Jacques-Henri Jourdan committed May 31, 2016 34 ``````Proof. `````` Robbert Krebbers committed Jun 01, 2016 35 `````` move=> y /Qcle_not_lt [] /=. by rewrite -{1}(Qcplus_0_r 1) -Qcplus_lt_mono_l. `````` Jacques-Henri Jourdan committed May 31, 2016 36 ``````Qed. `````` Zhen Zhang committed Oct 10, 2016 37 `````` `````` Jacques-Henri Jourdan committed Feb 01, 2017 38 39 40 41 42 43 44 45 46 ``````Global Instance frac_cancelable (q : frac) : Cancelable q. Proof. intros ?????. by apply Qp_eq, (inj (Qcplus q)), (Qp_eq (q+y) (q+z))%Qp. Qed. Global Instance frac_id_free (q : frac) : IdFree q. Proof. intros [q0 Hq0] ? EQ%Qp_eq. rewrite -{1}(Qcplus_0_r q) in EQ. eapply Qclt_not_eq; first done. by apply (inj (Qcplus q)). Qed. `````` Ralf Jung committed Mar 09, 2017 47 48 49 50 ``````Lemma frac_op' (q p : Qp) : (p ⋅ q) = (p + q)%Qp. Proof. done. Qed. Lemma frac_valid' (p : Qp) : ✓ p ↔ (p ≤ 1%Qp)%Qc. `````` Zhen Zhang committed Oct 10, 2016 51 ``````Proof. done. Qed. `````` Robbert Krebbers committed Jun 08, 2017 52 53 54 55 56 `````` Global Instance frac_into_op q : IntoOp q (q/2)%Qp (q/2)%Qp. Proof. by rewrite /IntoOp frac_op' Qp_div_2. Qed. Global Instance frac_from_op q : FromOp q (q/2)%Qp (q/2)%Qp. Proof. by rewrite /FromOp frac_op' Qp_div_2. Qed.``````