Commit 448a8b62 authored by Robbert Krebbers's avatar Robbert Krebbers

Use "R"-suffixes for CMRA instances.

parent cca77f9f
Pipeline #199 passed with stage
...@@ -119,7 +119,7 @@ Proof. ...@@ -119,7 +119,7 @@ Proof.
+ by rewrite agree_idemp. + by rewrite agree_idemp.
+ by move: Hval; rewrite Hx; move=> /agree_op_inv->; rewrite agree_idemp. + by move: Hval; rewrite Hx; move=> /agree_op_inv->; rewrite agree_idemp.
Qed. Qed.
Canonical Structure agreeRA : cmraT := CMRAT agree_cofe_mixin agree_cmra_mixin. Canonical Structure agreeR : cmraT := CMRAT agree_cofe_mixin agree_cmra_mixin.
Program Definition to_agree (x : A) : agree A := Program Definition to_agree (x : A) : agree A :=
{| agree_car n := x; agree_is_valid n := True |}. {| agree_car n := x; agree_is_valid n := True |}.
...@@ -142,7 +142,7 @@ Proof. uPred.unseal; split=> r n _ ?; by apply: agree_op_inv. Qed. ...@@ -142,7 +142,7 @@ Proof. uPred.unseal; split=> r n _ ?; by apply: agree_op_inv. Qed.
End agree. End agree.
Arguments agreeC : clear implicits. Arguments agreeC : clear implicits.
Arguments agreeRA : clear implicits. Arguments agreeR : clear implicits.
Program Definition agree_map {A B} (f : A B) (x : agree A) : agree B := Program Definition agree_map {A B} (f : A B) (x : agree A) : agree B :=
{| agree_car n := f (x n); agree_is_valid := agree_is_valid x |}. {| agree_car n := f (x n); agree_is_valid := agree_is_valid x |}.
...@@ -181,5 +181,5 @@ Proof. ...@@ -181,5 +181,5 @@ Proof.
Qed. Qed.
Program Definition agreeF : iFunctor := Program Definition agreeF : iFunctor :=
{| ifunctor_car := agreeRA; ifunctor_map := @agreeC_map |}. {| ifunctor_car := agreeR; ifunctor_map := @agreeC_map |}.
Solve Obligations with done. Solve Obligations with done.
...@@ -134,8 +134,8 @@ Proof. ...@@ -134,8 +134,8 @@ Proof.
as (b&?&?&?); auto using own_validN. as (b&?&?&?); auto using own_validN.
by exists (Auth (ea.1) (b.1), Auth (ea.2) (b.2)). by exists (Auth (ea.1) (b.1), Auth (ea.2) (b.2)).
Qed. Qed.
Canonical Structure authRA : cmraT := CMRAT auth_cofe_mixin auth_cmra_mixin. Canonical Structure authR : cmraT := CMRAT auth_cofe_mixin auth_cmra_mixin.
Global Instance auth_cmra_discrete : CMRADiscrete A CMRADiscrete authRA. Global Instance auth_cmra_discrete : CMRADiscrete A CMRADiscrete authR.
Proof. Proof.
split; first apply _. split; first apply _.
intros [[] ?]; by rewrite /= /cmra_valid /cmra_validN /= intros [[] ?]; by rewrite /= /cmra_valid /cmra_validN /=
...@@ -158,7 +158,7 @@ Proof. uPred.unseal. by destruct x as [[]]. Qed. ...@@ -158,7 +158,7 @@ Proof. uPred.unseal. by destruct x as [[]]. Qed.
what follows, we assume we have an empty element. *) what follows, we assume we have an empty element. *)
Context `{Empty A, !CMRAIdentity A}. Context `{Empty A, !CMRAIdentity A}.
Global Instance auth_cmra_identity : CMRAIdentity authRA. Global Instance auth_cmra_identity : CMRAIdentity authR.
Proof. Proof.
split; simpl. split; simpl.
- by apply (@cmra_empty_valid A _). - by apply (@cmra_empty_valid A _).
...@@ -208,7 +208,7 @@ Proof. ...@@ -208,7 +208,7 @@ Proof.
Qed. Qed.
End cmra. End cmra.
Arguments authRA : clear implicits. Arguments authR : clear implicits.
(* Functor *) (* Functor *)
Definition auth_map {A B} (f : A B) (x : auth A) : auth B := Definition auth_map {A B} (f : A B) (x : auth A) : auth B :=
...@@ -241,7 +241,7 @@ Lemma authC_map_ne A B n : Proper (dist n ==> dist n) (@authC_map A B). ...@@ -241,7 +241,7 @@ Lemma authC_map_ne A B n : Proper (dist n ==> dist n) (@authC_map A B).
Proof. intros f f' Hf [[a| |] b]; repeat constructor; apply Hf. Qed. Proof. intros f f' Hf [[a| |] b]; repeat constructor; apply Hf. Qed.
Program Definition authF (Σ : iFunctor) : iFunctor := {| Program Definition authF (Σ : iFunctor) : iFunctor := {|
ifunctor_car := authRA Σ; ifunctor_map A B := authC_map ifunctor_map Σ ifunctor_car := authR Σ; ifunctor_map A B := authC_map ifunctor_map Σ
|}. |}.
Next Obligation. Next Obligation.
by intros Σ A B n f g Hfg; apply authC_map_ne, ifunctor_map_ne. by intros Σ A B n f g Hfg; apply authC_map_ne, ifunctor_map_ne.
......
...@@ -515,8 +515,8 @@ Section discrete. ...@@ -515,8 +515,8 @@ Section discrete.
- intros n x y1 y2 ??; exists (y1,y2); split_and?; auto. - intros n x y1 y2 ??; exists (y1,y2); split_and?; auto.
apply (timeless _), dist_le with n; auto with lia. apply (timeless _), dist_le with n; auto with lia.
Qed. Qed.
Definition discreteRA : cmraT := CMRAT (cofe_mixin A) discrete_cmra_mixin. Definition discreteR : cmraT := CMRAT (cofe_mixin A) discrete_cmra_mixin.
Global Instance discrete_cmra_discrete : CMRADiscrete discreteRA. Global Instance discrete_cmra_discrete : CMRADiscrete discreteR.
Proof. split. change (Discrete A); apply _. by intros x ?. Qed. Proof. split. change (Discrete A); apply _. by intros x ?. Qed.
End discrete. End discrete.
...@@ -529,10 +529,10 @@ Section unit. ...@@ -529,10 +529,10 @@ Section unit.
Global Instance unit_empty : Empty () := (). Global Instance unit_empty : Empty () := ().
Definition unit_ra : RA (). Definition unit_ra : RA ().
Proof. by split. Qed. Proof. by split. Qed.
Canonical Structure unitRA : cmraT := Canonical Structure unitR : cmraT :=
Eval cbv [unitC discreteRA cofe_car] in discreteRA unit_ra. Eval cbv [unitC discreteR cofe_car] in discreteR unit_ra.
Global Instance unit_cmra_identity : CMRAIdentity unitRA. Global Instance unit_cmra_identity : CMRAIdentity unitR.
Global Instance unit_cmra_discrete : CMRADiscrete unitRA. Global Instance unit_cmra_discrete : CMRADiscrete unitR.
Proof. by apply discrete_cmra_discrete. Qed. Proof. by apply discrete_cmra_discrete. Qed.
End unit. End unit.
...@@ -581,9 +581,9 @@ Section prod. ...@@ -581,9 +581,9 @@ Section prod.
destruct (cmra_extend n (x.2) (y1.2) (y2.2)) as (z2&?&?&?); auto. destruct (cmra_extend n (x.2) (y1.2) (y2.2)) as (z2&?&?&?); auto.
by exists ((z1.1,z2.1),(z1.2,z2.2)). by exists ((z1.1,z2.1),(z1.2,z2.2)).
Qed. Qed.
Canonical Structure prodRA : cmraT := CMRAT prod_cofe_mixin prod_cmra_mixin. Canonical Structure prodR : cmraT := CMRAT prod_cofe_mixin prod_cmra_mixin.
Global Instance prod_cmra_identity `{Empty A, Empty B} : Global Instance prod_cmra_identity `{Empty A, Empty B} :
CMRAIdentity A CMRAIdentity B CMRAIdentity prodRA. CMRAIdentity A CMRAIdentity B CMRAIdentity prodR.
Proof. Proof.
split. split.
- split; apply cmra_empty_valid. - split; apply cmra_empty_valid.
...@@ -591,7 +591,7 @@ Section prod. ...@@ -591,7 +591,7 @@ Section prod.
- by intros ? [??]; split; apply (timeless _). - by intros ? [??]; split; apply (timeless _).
Qed. Qed.
Global Instance prod_cmra_discrete : Global Instance prod_cmra_discrete :
CMRADiscrete A CMRADiscrete B CMRADiscrete prodRA. CMRADiscrete A CMRADiscrete B CMRADiscrete prodR.
Proof. split. apply _. by intros ? []; split; apply cmra_discrete_valid. Qed. Proof. split. apply _. by intros ? []; split; apply cmra_discrete_valid. Qed.
Lemma prod_update x y : x.1 ~~> y.1 x.2 ~~> y.2 x ~~> y. Lemma prod_update x y : x.1 ~~> y.1 x.2 ~~> y.2 x ~~> y.
...@@ -607,7 +607,7 @@ Section prod. ...@@ -607,7 +607,7 @@ Section prod.
x.1 ~~>: P1 x.2 ~~>: P2 x ~~>: λ y, P1 (y.1) P2 (y.2). x.1 ~~>: P1 x.2 ~~>: P2 x ~~>: λ y, P1 (y.1) P2 (y.2).
Proof. eauto using prod_updateP. Qed. Proof. eauto using prod_updateP. Qed.
End prod. End prod.
Arguments prodRA : clear implicits. Arguments prodR : clear implicits.
Instance prod_map_cmra_monotone {A A' B B' : cmraT} (f : A A') (g : B B') : Instance prod_map_cmra_monotone {A A' B B' : cmraT} (f : A A') (g : B B') :
CMRAMonotone f CMRAMonotone g CMRAMonotone (prod_map f g). CMRAMonotone f CMRAMonotone g CMRAMonotone (prod_map f g).
......
...@@ -46,7 +46,7 @@ Proof. ...@@ -46,7 +46,7 @@ Proof.
intros; by repeat (simplify_eq/= || case_match). intros; by repeat (simplify_eq/= || case_match).
Qed. Qed.
Canonical Structure dec_agreeRA : cmraT := discreteRA dec_agree_ra. Canonical Structure dec_agreeR : cmraT := discreteR dec_agree_ra.
(* Some properties of this CMRA *) (* Some properties of this CMRA *)
Lemma dec_agree_ne a b : a b DecAgree a DecAgree b = DecAgreeBot. Lemma dec_agree_ne a b : a b DecAgree a DecAgree b = DecAgreeBot.
...@@ -59,4 +59,4 @@ Lemma dec_agree_op_inv (x1 x2 : dec_agree A) : ✓ (x1 ⋅ x2) → x1 = x2. ...@@ -59,4 +59,4 @@ Lemma dec_agree_op_inv (x1 x2 : dec_agree A) : ✓ (x1 ⋅ x2) → x1 = x2.
Proof. destruct x1, x2; by repeat (simplify_eq/= || case_match). Qed. Proof. destruct x1, x2; by repeat (simplify_eq/= || case_match). Qed.
End dec_agree. End dec_agree.
Arguments dec_agreeRA _ {_}. Arguments dec_agreeR _ {_}.
...@@ -130,11 +130,11 @@ Proof. ...@@ -130,11 +130,11 @@ Proof.
- intros [x px ?] [y py ?] [[z pz ?] [??]]; split; simpl in *; - intros [x px ?] [y py ?] [[z pz ?] [??]]; split; simpl in *;
intuition eauto 10 using dra_disjoint_div, dra_op_div. intuition eauto 10 using dra_disjoint_div, dra_op_div.
Qed. Qed.
Definition validityRA : cmraT := discreteRA validity_ra. Definition validityR : cmraT := discreteR validity_ra.
Instance validity_cmra_discrete : Instance validity_cmra_discrete :
CMRADiscrete validityRA := discrete_cmra_discrete _. CMRADiscrete validityR := discrete_cmra_discrete _.
Lemma validity_update (x y : validityRA) : Lemma validity_update (x y : validityR) :
( z, x z validity_car x z y validity_car y z) x ~~> y. ( z, x z validity_car x z y validity_car y z) x ~~> y.
Proof. Proof.
intros Hxy; apply cmra_discrete_update=> z [?[??]]. intros Hxy; apply cmra_discrete_update=> z [?[??]].
......
...@@ -127,10 +127,10 @@ Proof. ...@@ -127,10 +127,10 @@ Proof.
| ExclUnit, _ => (ExclUnit, x) | _, ExclUnit => (x, ExclUnit) | ExclUnit, _ => (ExclUnit, x) | _, ExclUnit => (x, ExclUnit)
end; destruct y1, y2; inversion_clear Hx; repeat constructor. end; destruct y1, y2; inversion_clear Hx; repeat constructor.
Qed. Qed.
Canonical Structure exclRA : cmraT := CMRAT excl_cofe_mixin excl_cmra_mixin. Canonical Structure exclR : cmraT := CMRAT excl_cofe_mixin excl_cmra_mixin.
Global Instance excl_cmra_identity : CMRAIdentity exclRA. Global Instance excl_cmra_identity : CMRAIdentity exclR.
Proof. split. done. by intros []. apply _. Qed. Proof. split. done. by intros []. apply _. Qed.
Global Instance excl_cmra_discrete : Discrete A CMRADiscrete exclRA. Global Instance excl_cmra_discrete : Discrete A CMRADiscrete exclR.
Proof. split. apply _. by intros []. Qed. Proof. split. apply _. by intros []. Qed.
Lemma excl_validN_inv_l n x a : {n} (Excl a x) x = . Lemma excl_validN_inv_l n x a : {n} (Excl a x) x = .
...@@ -170,7 +170,7 @@ Proof. intros ?? n z ?; exists y. by destruct y, z as [?| |]. Qed. ...@@ -170,7 +170,7 @@ Proof. intros ?? n z ?; exists y. by destruct y, z as [?| |]. Qed.
End excl. End excl.
Arguments exclC : clear implicits. Arguments exclC : clear implicits.
Arguments exclRA : clear implicits. Arguments exclR : clear implicits.
(* Functor *) (* Functor *)
Definition excl_map {A B} (f : A B) (x : excl A) : excl B := Definition excl_map {A B} (f : A B) (x : excl A) : excl B :=
...@@ -202,6 +202,6 @@ Instance exclC_map_ne A B n : Proper (dist n ==> dist n) (@exclC_map A B). ...@@ -202,6 +202,6 @@ Instance exclC_map_ne A B n : Proper (dist n ==> dist n) (@exclC_map A B).
Proof. by intros f f' Hf []; constructor; apply Hf. Qed. Proof. by intros f f' Hf []; constructor; apply Hf. Qed.
Program Definition exclF : iFunctor := Program Definition exclF : iFunctor :=
{| ifunctor_car := exclRA; ifunctor_map := @exclC_map |}. {| ifunctor_car := exclR; ifunctor_map := @exclC_map |}.
Next Obligation. by intros A x; rewrite /= excl_map_id. Qed. Next Obligation. by intros A x; rewrite /= excl_map_id. Qed.
Next Obligation. by intros A B C f g x; rewrite /= excl_map_compose. Qed. Next Obligation. by intros A B C f g x; rewrite /= excl_map_compose. Qed.
...@@ -158,15 +158,15 @@ Proof. ...@@ -158,15 +158,15 @@ Proof.
pose proof (Hm12' i) as Hm12''; rewrite Hx in Hm12''. pose proof (Hm12' i) as Hm12''; rewrite Hx in Hm12''.
by symmetry; apply option_op_positive_dist_r with (m1 !! i). by symmetry; apply option_op_positive_dist_r with (m1 !! i).
Qed. Qed.
Canonical Structure mapRA : cmraT := CMRAT map_cofe_mixin map_cmra_mixin. Canonical Structure mapR : cmraT := CMRAT map_cofe_mixin map_cmra_mixin.
Global Instance map_cmra_identity : CMRAIdentity mapRA. Global Instance map_cmra_identity : CMRAIdentity mapR.
Proof. Proof.
split. split.
- by intros i; rewrite lookup_empty. - by intros i; rewrite lookup_empty.
- by intros m i; rewrite /= lookup_op lookup_empty (left_id_L None _). - by intros m i; rewrite /= lookup_op lookup_empty (left_id_L None _).
- apply map_empty_timeless. - apply map_empty_timeless.
Qed. Qed.
Global Instance map_cmra_discrete : CMRADiscrete A CMRADiscrete mapRA. Global Instance map_cmra_discrete : CMRADiscrete A CMRADiscrete mapR.
Proof. split; [apply _|]. intros m ? i. by apply: cmra_discrete_valid. Qed. Proof. split; [apply _|]. intros m ? i. by apply: cmra_discrete_valid. Qed.
(** Internalized properties *) (** Internalized properties *)
...@@ -176,7 +176,7 @@ Lemma map_validI {M} m : (✓ m)%I ≡ (∀ i, ✓ (m !! i) : uPred M)%I. ...@@ -176,7 +176,7 @@ Lemma map_validI {M} m : (✓ m)%I ≡ (∀ i, ✓ (m !! i) : uPred M)%I.
Proof. by uPred.unseal. Qed. Proof. by uPred.unseal. Qed.
End cmra. End cmra.
Arguments mapRA _ {_ _} _. Arguments mapR _ {_ _} _.
Section properties. Section properties.
Context `{Countable K} {A : cmraT}. Context `{Countable K} {A : cmraT}.
...@@ -353,7 +353,7 @@ Proof. ...@@ -353,7 +353,7 @@ Proof.
Qed. Qed.
Program Definition mapF K `{Countable K} (Σ : iFunctor) : iFunctor := {| Program Definition mapF K `{Countable K} (Σ : iFunctor) : iFunctor := {|
ifunctor_car := mapRA K Σ; ifunctor_map A B := mapC_map ifunctor_map Σ ifunctor_car := mapR K Σ; ifunctor_map A B := mapC_map ifunctor_map Σ
|}. |}.
Next Obligation. Next Obligation.
by intros K ?? Σ A B n f g Hfg; apply mapC_map_ne, ifunctor_map_ne. by intros K ?? Σ A B n f g Hfg; apply mapC_map_ne, ifunctor_map_ne.
......
...@@ -171,10 +171,10 @@ Proof. ...@@ -171,10 +171,10 @@ Proof.
+ exists (, Frac q a); inversion_clear Hx'; by repeat constructor. + exists (, Frac q a); inversion_clear Hx'; by repeat constructor.
+ exfalso; inversion_clear Hx'. + exfalso; inversion_clear Hx'.
Qed. Qed.
Canonical Structure fracRA : cmraT := CMRAT frac_cofe_mixin frac_cmra_mixin. Canonical Structure fracR : cmraT := CMRAT frac_cofe_mixin frac_cmra_mixin.
Global Instance frac_cmra_identity : CMRAIdentity fracRA. Global Instance frac_cmra_identity : CMRAIdentity fracR.
Proof. split. done. by intros []. apply _. Qed. Proof. split. done. by intros []. apply _. Qed.
Global Instance frac_cmra_discrete : CMRADiscrete A CMRADiscrete fracRA. Global Instance frac_cmra_discrete : CMRADiscrete A CMRADiscrete fracR.
Proof. Proof.
split; first apply _. split; first apply _.
intros [q a|]; destruct 1; split; auto using cmra_discrete_valid. intros [q a|]; destruct 1; split; auto using cmra_discrete_valid.
...@@ -229,7 +229,7 @@ Proof. ...@@ -229,7 +229,7 @@ Proof.
Qed. Qed.
End cmra. End cmra.
Arguments fracRA : clear implicits. Arguments fracR : clear implicits.
(* Functor *) (* Functor *)
Instance frac_map_cmra_monotone {A B : cmraT} (f : A B) : Instance frac_map_cmra_monotone {A B : cmraT} (f : A B) :
...@@ -245,7 +245,7 @@ Proof. ...@@ -245,7 +245,7 @@ Proof.
Qed. Qed.
Program Definition fracF (Σ : iFunctor) : iFunctor := {| Program Definition fracF (Σ : iFunctor) : iFunctor := {|
ifunctor_car := fracRA Σ; ifunctor_map A B := fracC_map ifunctor_map Σ ifunctor_car := fracR Σ; ifunctor_map A B := fracC_map ifunctor_map Σ
|}. |}.
Next Obligation. Next Obligation.
by intros Σ A B n f g Hfg; apply fracC_map_ne, ifunctor_map_ne. by intros Σ A B n f g Hfg; apply fracC_map_ne, ifunctor_map_ne.
......
...@@ -29,7 +29,7 @@ Program Definition constF (B : cmraT) : iFunctor := ...@@ -29,7 +29,7 @@ Program Definition constF (B : cmraT) : iFunctor :=
Solve Obligations with done. Solve Obligations with done.
Program Definition prodF (Σ1 Σ2 : iFunctor) : iFunctor := {| Program Definition prodF (Σ1 Σ2 : iFunctor) : iFunctor := {|
ifunctor_car A := prodRA (Σ1 A) (Σ2 A); ifunctor_car A := prodR (Σ1 A) (Σ2 A);
ifunctor_map A B f := prodC_map (ifunctor_map Σ1 f) (ifunctor_map Σ2 f) ifunctor_map A B f := prodC_map (ifunctor_map Σ1 f) (ifunctor_map Σ2 f)
|}. |}.
Next Obligation. Next Obligation.
......
...@@ -159,9 +159,9 @@ Section iprod_cmra. ...@@ -159,9 +159,9 @@ Section iprod_cmra.
exists ((λ x, (proj1_sig (g x)).1), (λ x, (proj1_sig (g x)).2)). exists ((λ x, (proj1_sig (g x)).1), (λ x, (proj1_sig (g x)).2)).
split_and?; intros x; apply (proj2_sig (g x)). split_and?; intros x; apply (proj2_sig (g x)).
Qed. Qed.
Canonical Structure iprodRA : cmraT := CMRAT iprod_cofe_mixin iprod_cmra_mixin. Canonical Structure iprodR : cmraT := CMRAT iprod_cofe_mixin iprod_cmra_mixin.
Global Instance iprod_cmra_identity `{ x, Empty (B x)} : Global Instance iprod_cmra_identity `{ x, Empty (B x)} :
( x, CMRAIdentity (B x)) CMRAIdentity iprodRA. ( x, CMRAIdentity (B x)) CMRAIdentity iprodR.
Proof. Proof.
intros ?; split. intros ?; split.
- intros x; apply cmra_empty_valid. - intros x; apply cmra_empty_valid.
...@@ -253,7 +253,7 @@ Section iprod_cmra. ...@@ -253,7 +253,7 @@ Section iprod_cmra.
Proof. eauto using iprod_singleton_updateP_empty. Qed. Proof. eauto using iprod_singleton_updateP_empty. Qed.
End iprod_cmra. End iprod_cmra.
Arguments iprodRA {_} _. Arguments iprodR {_} _.
(** * Functor *) (** * Functor *)
Definition iprod_map {A} {B1 B2 : A cofeT} (f : x, B1 x B2 x) Definition iprod_map {A} {B1 B2 : A cofeT} (f : x, B1 x B2 x)
...@@ -289,7 +289,7 @@ Instance iprodC_map_ne {A} {B1 B2 : A → cofeT} n : ...@@ -289,7 +289,7 @@ Instance iprodC_map_ne {A} {B1 B2 : A → cofeT} n :
Proof. intros f1 f2 Hf g x; apply Hf. Qed. Proof. intros f1 f2 Hf g x; apply Hf. Qed.
Program Definition iprodF {A} (Σ : A iFunctor) : iFunctor := {| Program Definition iprodF {A} (Σ : A iFunctor) : iFunctor := {|
ifunctor_car B := iprodRA (λ x, Σ x B); ifunctor_car B := iprodR (λ x, Σ x B);
ifunctor_map B1 B2 f := iprodC_map (λ x, ifunctor_map (Σ x) f); ifunctor_map B1 B2 f := iprodC_map (λ x, ifunctor_map (Σ x) f);
|}. |}.
Next Obligation. Next Obligation.
......
...@@ -118,10 +118,10 @@ Proof. ...@@ -118,10 +118,10 @@ Proof.
+ by exists (None,Some x); inversion Hx'; repeat constructor. + by exists (None,Some x); inversion Hx'; repeat constructor.
+ exists (None,None); repeat constructor. + exists (None,None); repeat constructor.
Qed. Qed.
Canonical Structure optionRA := CMRAT option_cofe_mixin option_cmra_mixin. Canonical Structure optionR := CMRAT option_cofe_mixin option_cmra_mixin.
Global Instance option_cmra_identity : CMRAIdentity optionRA. Global Instance option_cmra_identity : CMRAIdentity optionR.
Proof. split. done. by intros []. by inversion_clear 1. Qed. Proof. split. done. by intros []. by inversion_clear 1. Qed.
Global Instance option_cmra_discrete : CMRADiscrete A CMRADiscrete optionRA. Global Instance option_cmra_discrete : CMRADiscrete A CMRADiscrete optionR.
Proof. split; [apply _|]. by intros [x|]; [apply (cmra_discrete_valid x)|]. Qed. Proof. split; [apply _|]. by intros [x|]; [apply (cmra_discrete_valid x)|]. Qed.
(** Misc *) (** Misc *)
...@@ -170,7 +170,7 @@ Proof. ...@@ -170,7 +170,7 @@ Proof.
auto using cmra_empty_validN. auto using cmra_empty_validN.
Qed. Qed.
End cmra. End cmra.
Arguments optionRA : clear implicits. Arguments optionR : clear implicits.
(** Functor *) (** Functor *)
Instance option_fmap_ne {A B : cofeT} (f : A B) n: Instance option_fmap_ne {A B : cofeT} (f : A B) n:
...@@ -190,7 +190,7 @@ Instance optionC_map_ne A B n : Proper (dist n ==> dist n) (@optionC_map A B). ...@@ -190,7 +190,7 @@ Instance optionC_map_ne A B n : Proper (dist n ==> dist n) (@optionC_map A B).
Proof. by intros f f' Hf []; constructor; apply Hf. Qed. Proof. by intros f f' Hf []; constructor; apply Hf. Qed.
Program Definition optionF (Σ : iFunctor) : iFunctor := {| Program Definition optionF (Σ : iFunctor) : iFunctor := {|
ifunctor_car := optionRA Σ; ifunctor_map A B := optionC_map ifunctor_map Σ ifunctor_car := optionR Σ; ifunctor_map A B := optionC_map ifunctor_map Σ
|}. |}.
Next Obligation. Next Obligation.
by intros Σ A B n f g Hfg; apply optionC_map_ne, ifunctor_map_ne. by intros Σ A B n f g Hfg; apply optionC_map_ne, ifunctor_map_ne.
......
...@@ -287,20 +287,20 @@ Proof. ...@@ -287,20 +287,20 @@ Proof.
unfold up_set; rewrite elem_of_bind; intros (?&s1&?&?&?). unfold up_set; rewrite elem_of_bind; intros (?&s1&?&?&?).
apply closed_steps with T2 s1; auto with sts. apply closed_steps with T2 s1; auto with sts.
Qed. Qed.
Canonical Structure RA : cmraT := validityRA (car sts). Canonical Structure R : cmraT := validityR (car sts).
End sts_dra. End sts_dra. End sts_dra. End sts_dra.
(** * The STS Resource Algebra *) (** * The STS Resource Algebra *)
(** Finally, the general theory of STS that should be used by users *) (** Finally, the general theory of STS that should be used by users *)
Notation stsRA := (@sts_dra.RA). Notation stsR := (@sts_dra.R).
Section sts_definitions. Section sts_definitions.
Context {sts : stsT}. Context {sts : stsT}.
Definition sts_auth (s : sts.state sts) (T : sts.tokens sts) : stsRA sts := Definition sts_auth (s : sts.state sts) (T : sts.tokens sts) : stsR sts :=
to_validity (sts_dra.auth s T). to_validity (sts_dra.auth s T).
Definition sts_frag (S : sts.states sts) (T : sts.tokens sts) : stsRA sts := Definition sts_frag (S : sts.states sts) (T : sts.tokens sts) : stsR sts :=
to_validity (sts_dra.frag S T). to_validity (sts_dra.frag S T).
Definition sts_frag_up (s : sts.state sts) (T : sts.tokens sts) : stsRA sts := Definition sts_frag_up (s : sts.state sts) (T : sts.tokens sts) : stsR sts :=
sts_frag (sts.up s T) T. sts_frag (sts.up s T) T.
End sts_definitions. End sts_definitions.
Instance: Params (@sts_auth) 2. Instance: Params (@sts_auth) 2.
...@@ -314,7 +314,7 @@ Implicit Types s : state sts. ...@@ -314,7 +314,7 @@ Implicit Types s : state sts.
Implicit Types S : states sts. Implicit Types S : states sts.
Implicit Types T : tokens sts. Implicit Types T : tokens sts.
Global Instance sts_cmra_discrete : CMRADiscrete (stsRA sts). Global Instance sts_cmra_discrete : CMRADiscrete (stsR sts).
Proof. apply validity_cmra_discrete. Qed. Proof. apply validity_cmra_discrete. Qed.
(** Setoids *) (** Setoids *)
......
...@@ -7,18 +7,18 @@ Import uPred. ...@@ -7,18 +7,18 @@ Import uPred.
a finmap as their state. Or maybe even beyond "as their state", i.e. arbitrary a finmap as their state. Or maybe even beyond "as their state", i.e. arbitrary
predicates over finmaps instead of just ownP. *) predicates over finmaps instead of just ownP. *)
Definition heapRA : cmraT := mapRA loc (fracRA (dec_agreeRA val)). Definition heapR : cmraT := mapR loc (fracR (dec_agreeR val)).
Definition heapGF : iFunctor := authGF heapRA. Definition heapGF : iFunctor := authGF heapR.
Class heapG Σ := HeapG { Class heapG Σ := HeapG {
heap_inG : inG heap_lang Σ (authRA heapRA); heap_inG : inG heap_lang Σ (authR heapR);
heap_name : gname heap_name : gname
}. }.
Instance heap_authG `{i : heapG Σ} : authG heap_lang Σ heapRA := Instance heap_authG `{i : heapG Σ} : authG heap_lang Σ heapR :=
{| auth_inG := heap_inG |}. {| auth_inG := heap_inG |}.
Definition to_heap : state heapRA := fmap (λ v, Frac 1 (DecAgree v)). Definition to_heap : state heapR := fmap (λ v, Frac 1 (DecAgree v)).
Definition of_heap : heapRA state := Definition of_heap : heapR state :=
omap (mbind (maybe DecAgree snd) maybe2 Frac). omap (mbind (maybe DecAgree snd) maybe2 Frac).
(* heap_mapsto is defined strongly opaquely, to prevent unification from (* heap_mapsto is defined strongly opaquely, to prevent unification from
...@@ -28,7 +28,7 @@ Definition heap_mapsto `{heapG Σ} ...@@ -28,7 +28,7 @@ Definition heap_mapsto `{heapG Σ}
auth_own heap_name {[ l := Frac q (DecAgree v) ]}. auth_own heap_name {[ l := Frac q (DecAgree v) ]}.
Typeclasses Opaque heap_mapsto. Typeclasses Opaque heap_mapsto.
Definition heap_inv `{i : heapG Σ} (h : heapRA) : iPropG heap_lang Σ := Definition heap_inv `{i : heapG Σ} (h : heapR) : iPropG heap_lang Σ :=
ownP (of_heap h). ownP (of_heap h).
Definition heap_ctx `{i : heapG Σ} (N : namespace) : iPropG heap_lang Σ := Definition heap_ctx `{i : heapG Σ} (N : namespace) : iPropG heap_lang Σ :=
auth_ctx heap_name N heap_inv. auth_ctx heap_name N heap_inv.
...@@ -43,7 +43,7 @@ Section heap. ...@@ -43,7 +43,7 @@ Section heap.
Implicit Types P Q : iPropG heap_lang Σ. Implicit Types P Q : iPropG heap_lang Σ.