dec_agree.v 2.01 KB
 Robbert Krebbers committed Mar 10, 2016 1 ``````From iris.algebra Require Export cmra. `````` Ralf Jung committed Feb 23, 2016 2 3 4 ``````Local Arguments validN _ _ _ !_ /. Local Arguments valid _ _ !_ /. Local Arguments op _ _ _ !_ /. `````` Ralf Jung committed Mar 08, 2016 5 ``````Local Arguments core _ _ !_ /. `````` Ralf Jung committed Feb 23, 2016 6 `````` `````` Robbert Krebbers committed Feb 24, 2016 7 ``````(* This is isomorphic to option, but has a very different RA structure. *) `````` Ralf Jung committed Feb 23, 2016 8 9 10 11 12 ``````Inductive dec_agree (A : Type) : Type := | DecAgree : A → dec_agree A | DecAgreeBot : dec_agree A. Arguments DecAgree {_} _. Arguments DecAgreeBot {_}. `````` Robbert Krebbers committed Feb 26, 2016 13 14 ``````Instance maybe_DecAgree {A} : Maybe (@DecAgree A) := λ x, match x with DecAgree a => Some a | _ => None end. `````` Ralf Jung committed Feb 23, 2016 15 16 17 18 19 20 21 22 23 24 25 26 27 28 `````` Section dec_agree. Context {A : Type} `{∀ x y : A, Decision (x = y)}. Instance dec_agree_valid : Valid (dec_agree A) := λ x, if x is DecAgree _ then True else False. Instance dec_agree_equiv : Equiv (dec_agree A) := equivL. Canonical Structure dec_agreeC : cofeT := leibnizC (dec_agree A). Instance dec_agree_op : Op (dec_agree A) := λ x y, match x, y with | DecAgree a, DecAgree b => if decide (a = b) then DecAgree a else DecAgreeBot | _, _ => DecAgreeBot end. `````` Ralf Jung committed Mar 08, 2016 29 ``````Instance dec_agree_core : Core (dec_agree A) := id. `````` Ralf Jung committed Feb 23, 2016 30 31 32 33 34 35 36 `````` Definition dec_agree_ra : RA (dec_agree A). Proof. split. - apply _. - apply _. - apply _. `````` Robbert Krebbers committed Feb 24, 2016 37 38 39 40 41 42 `````` - intros [?|] [?|] [?|]; by repeat (simplify_eq/= || case_match). - intros [?|] [?|]; by repeat (simplify_eq/= || case_match). - intros [?|]; by repeat (simplify_eq/= || case_match). - intros [?|]; by repeat (simplify_eq/= || case_match). - by intros [?|] [?|] ?. - by intros [?|] [?|] ?. `````` Ralf Jung committed Feb 23, 2016 43 44 ``````Qed. `````` Robbert Krebbers committed Mar 01, 2016 45 ``````Canonical Structure dec_agreeR : cmraT := discreteR dec_agree_ra. `````` Ralf Jung committed Feb 23, 2016 46 `````` `````` Ralf Jung committed Feb 23, 2016 47 ``````(* Some properties of this CMRA *) `````` Robbert Krebbers committed Mar 15, 2016 48 49 50 ``````Lemma dec_agree_core_id (x : dec_agree A) : core x = x. Proof. done. Qed. `````` Robbert Krebbers committed Feb 26, 2016 51 52 ``````Lemma dec_agree_ne a b : a ≠ b → DecAgree a ⋅ DecAgree b = DecAgreeBot. Proof. intros. by rewrite /= decide_False. Qed. `````` Ralf Jung committed Feb 23, 2016 53 `````` `````` Robbert Krebbers committed Feb 26, 2016 54 55 56 57 ``````Lemma dec_agree_idemp (x : dec_agree A) : x ⋅ x = x. Proof. destruct x; by rewrite /= ?decide_True. Qed. Lemma dec_agree_op_inv (x1 x2 : dec_agree A) : ✓ (x1 ⋅ x2) → x1 = x2. `````` Robbert Krebbers committed Feb 24, 2016 58 ``````Proof. destruct x1, x2; by repeat (simplify_eq/= || case_match). Qed. `````` Ralf Jung committed Feb 23, 2016 59 ``````End dec_agree. `````` Robbert Krebbers committed Feb 26, 2016 60 `````` `````` Robbert Krebbers committed Mar 01, 2016 61 ``Arguments dec_agreeR _ {_}.``