Commit c05f2a06 authored by Robbert Krebbers's avatar Robbert Krebbers

Remove CMRA division.

The only drawback is that we have to restrict iprod to finite types,
but that is fine.
parent e15c090e
...@@ -61,7 +61,6 @@ Program Instance agree_op : Op (agree A) := λ x y, ...@@ -61,7 +61,6 @@ Program Instance agree_op : Op (agree A) := λ x y,
agree_is_valid n := agree_is_valid x n agree_is_valid y n x {n} y |}. agree_is_valid n := agree_is_valid x n agree_is_valid y n x {n} y |}.
Next Obligation. naive_solver eauto using agree_valid_S, dist_S. Qed. Next Obligation. naive_solver eauto using agree_valid_S, dist_S. Qed.
Instance agree_core : Core (agree A) := id. Instance agree_core : Core (agree A) := id.
Instance agree_div : Div (agree A) := λ x y, x.
Instance: Comm () (@op (agree A) _). Instance: Comm () (@op (agree A) _).
Proof. intros x y; split; [naive_solver|by intros n (?&?&Hxy); apply Hxy]. Qed. Proof. intros x y; split; [naive_solver|by intros n (?&?&Hxy); apply Hxy]. Qed.
...@@ -108,13 +107,11 @@ Qed. ...@@ -108,13 +107,11 @@ Qed.
Definition agree_cmra_mixin : CMRAMixin (agree A). Definition agree_cmra_mixin : CMRAMixin (agree A).
Proof. Proof.
split; try (apply _ || done). split; try (apply _ || done).
- by intros n x1 x2 Hx y1 y2 Hy.
- intros n x [? Hx]; split; [by apply agree_valid_S|intros n' ?]. - intros n x [? Hx]; split; [by apply agree_valid_S|intros n' ?].
rewrite -(Hx n'); last auto. rewrite -(Hx n'); last auto.
symmetry; apply dist_le with n; try apply Hx; auto. symmetry; apply dist_le with n; try apply Hx; auto.
- intros x; apply agree_idemp. - intros x; apply agree_idemp.
- by intros n x y [(?&?&?) ?]. - by intros n x y [(?&?&?) ?].
- by intros x y; rewrite agree_included.
- intros n x y1 y2 Hval Hx; exists (x,x); simpl; split. - intros n x y1 y2 Hval Hx; exists (x,x); simpl; split.
+ 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.
......
...@@ -73,7 +73,7 @@ Implicit Types x y : auth A. ...@@ -73,7 +73,7 @@ Implicit Types x y : auth A.
Global Instance auth_empty `{Empty A} : Empty (auth A) := Auth . Global Instance auth_empty `{Empty A} : Empty (auth A) := Auth .
Instance auth_valid : Valid (auth A) := λ x, Instance auth_valid : Valid (auth A) := λ x,
match authoritative x with match authoritative x with
| Excl a => own x a a | Excl a => ( n, own x {n} a) a
| ExclUnit => own x | ExclUnit => own x
| ExclBot => False | ExclBot => False
end. end.
...@@ -89,8 +89,6 @@ Instance auth_core : Core (auth A) := λ x, ...@@ -89,8 +89,6 @@ Instance auth_core : Core (auth A) := λ x,
Auth (core (authoritative x)) (core (own x)). Auth (core (authoritative x)) (core (own x)).
Instance auth_op : Op (auth A) := λ x y, Instance auth_op : Op (auth A) := λ x y,
Auth (authoritative x authoritative y) (own x own y). Auth (authoritative x authoritative y) (own x own y).
Instance auth_div : Div (auth A) := λ x y,
Auth (authoritative x ÷ authoritative y) (own x ÷ own y).
Lemma auth_included (x y : auth A) : Lemma auth_included (x y : auth A) :
x y authoritative x authoritative y own x own y. x y authoritative x authoritative y own x own y.
...@@ -110,8 +108,6 @@ Proof. ...@@ -110,8 +108,6 @@ Proof.
- by intros n y1 y2 [Hy Hy']; split; simpl; rewrite ?Hy ?Hy'. - by intros n y1 y2 [Hy Hy']; split; simpl; rewrite ?Hy ?Hy'.
- intros n [x a] [y b] [Hx Ha]; simpl in *; - intros n [x a] [y b] [Hx Ha]; simpl in *;
destruct Hx; intros ?; cofe_subst; auto. destruct Hx; intros ?; cofe_subst; auto.
- by intros n x1 x2 [Hx Hx'] y1 y2 [Hy Hy'];
split; simpl; rewrite ?Hy ?Hy' ?Hx ?Hx'.
- intros [[] ?]; rewrite /= ?cmra_included_includedN ?cmra_valid_validN; - intros [[] ?]; rewrite /= ?cmra_included_includedN ?cmra_valid_validN;
naive_solver eauto using O. naive_solver eauto using O.
- intros n [[] ?] ?; naive_solver eauto using cmra_includedN_S, cmra_validN_S. - intros n [[] ?] ?; naive_solver eauto using cmra_includedN_S, cmra_validN_S.
...@@ -125,8 +121,6 @@ Proof. ...@@ -125,8 +121,6 @@ Proof.
{ intros n a b1 b2 <-; apply cmra_includedN_l. } { intros n a b1 b2 <-; apply cmra_includedN_l. }
intros n [[a1| |] b1] [[a2| |] b2]; intros n [[a1| |] b1] [[a2| |] b2];
naive_solver eauto using cmra_validN_op_l, cmra_validN_includedN. naive_solver eauto using cmra_validN_op_l, cmra_validN_includedN.
- by intros ??; rewrite auth_included;
intros [??]; split; simpl; apply cmra_op_div.
- intros n x y1 y2 ? [??]; simpl in *. - intros n x y1 y2 ? [??]; simpl in *.
destruct (cmra_extend n (authoritative x) (authoritative y1) destruct (cmra_extend n (authoritative x) (authoritative y1)
(authoritative y2)) as (ea&?&?&?); auto using authoritative_validN. (authoritative y2)) as (ea&?&?&?); auto using authoritative_validN.
...@@ -138,9 +132,9 @@ Canonical Structure authR : cmraT := CMRAT auth_cofe_mixin auth_cmra_mixin. ...@@ -138,9 +132,9 @@ Canonical Structure authR : cmraT := CMRAT auth_cofe_mixin auth_cmra_mixin.
Global Instance auth_cmra_discrete : CMRADiscrete A CMRADiscrete authR. 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 [[] ?]; rewrite /= /cmra_valid /cmra_validN /=
-?cmra_discrete_included_iff -?cmra_discrete_valid_iff. -?cmra_discrete_included_iff -?cmra_discrete_valid_iff; auto.
Qed. Admitted.
(** Internalized properties *) (** Internalized properties *)
Lemma auth_equivI {M} (x y : auth A) : Lemma auth_equivI {M} (x y : auth A) :
......
...@@ -14,10 +14,6 @@ Notation "(≼)" := included (only parsing) : C_scope. ...@@ -14,10 +14,6 @@ Notation "(≼)" := included (only parsing) : C_scope.
Hint Extern 0 (_ _) => reflexivity. Hint Extern 0 (_ _) => reflexivity.
Instance: Params (@included) 3. Instance: Params (@included) 3.
Class Div (A : Type) := div : A A A.
Instance: Params (@div) 2.
Infix "÷" := div : C_scope.
Class ValidN (A : Type) := validN : nat A Prop. Class ValidN (A : Type) := validN : nat A Prop.
Instance: Params (@validN) 3. Instance: Params (@validN) 3.
Notation "✓{ n } x" := (validN n x) Notation "✓{ n } x" := (validN n x)
...@@ -33,13 +29,11 @@ Notation "x ≼{ n } y" := (includedN n x y) ...@@ -33,13 +29,11 @@ Notation "x ≼{ n } y" := (includedN n x y)
Instance: Params (@includedN) 4. Instance: Params (@includedN) 4.
Hint Extern 0 (_ {_} _) => reflexivity. Hint Extern 0 (_ {_} _) => reflexivity.
Record CMRAMixin A Record CMRAMixin A `{Dist A, Equiv A, Core A, Op A, Valid A, ValidN A} := {
`{Dist A, Equiv A, Core A, Op A, Valid A, ValidN A, Div A} := {
(* setoids *) (* setoids *)
mixin_cmra_op_ne n (x : A) : Proper (dist n ==> dist n) (op x); mixin_cmra_op_ne n (x : A) : Proper (dist n ==> dist n) (op x);
mixin_cmra_core_ne n : Proper (dist n ==> dist n) core; mixin_cmra_core_ne n : Proper (dist n ==> dist n) core;
mixin_cmra_validN_ne n : Proper (dist n ==> impl) (validN n); mixin_cmra_validN_ne n : Proper (dist n ==> impl) (validN n);
mixin_cmra_div_ne n : Proper (dist n ==> dist n ==> dist n) div;
(* valid *) (* valid *)
mixin_cmra_valid_validN x : x n, {n} x; mixin_cmra_valid_validN x : x n, {n} x;
mixin_cmra_validN_S n x : {S n} x {n} x; mixin_cmra_validN_S n x : {S n} x {n} x;
...@@ -50,7 +44,6 @@ Record CMRAMixin A ...@@ -50,7 +44,6 @@ Record CMRAMixin A
mixin_cmra_core_idemp x : core (core x) core x; mixin_cmra_core_idemp x : core (core x) core x;
mixin_cmra_core_preserving x y : x y core x core y; mixin_cmra_core_preserving x y : x y core x core y;
mixin_cmra_validN_op_l n x y : {n} (x y) {n} x; mixin_cmra_validN_op_l n x y : {n} (x y) {n} x;
mixin_cmra_op_div x y : x y x y ÷ x y;
mixin_cmra_extend n x y1 y2 : mixin_cmra_extend n x y1 y2 :
{n} x x {n} y1 y2 {n} x x {n} y1 y2
{ z | x z.1 z.2 z.1 {n} y1 z.2 {n} y2 } { z | x z.1 z.2 z.1 {n} y1 z.2 {n} y2 }
...@@ -66,11 +59,10 @@ Structure cmraT := CMRAT { ...@@ -66,11 +59,10 @@ Structure cmraT := CMRAT {
cmra_op : Op cmra_car; cmra_op : Op cmra_car;
cmra_valid : Valid cmra_car; cmra_valid : Valid cmra_car;
cmra_validN : ValidN cmra_car; cmra_validN : ValidN cmra_car;
cmra_div : Div cmra_car;
cmra_cofe_mixin : CofeMixin cmra_car; cmra_cofe_mixin : CofeMixin cmra_car;
cmra_mixin : CMRAMixin cmra_car cmra_mixin : CMRAMixin cmra_car
}. }.
Arguments CMRAT {_ _ _ _ _ _ _ _ _} _ _. Arguments CMRAT {_ _ _ _ _ _ _ _} _ _.
Arguments cmra_car : simpl never. Arguments cmra_car : simpl never.
Arguments cmra_equiv : simpl never. Arguments cmra_equiv : simpl never.
Arguments cmra_dist : simpl never. Arguments cmra_dist : simpl never.
...@@ -79,11 +71,10 @@ Arguments cmra_core : simpl never. ...@@ -79,11 +71,10 @@ Arguments cmra_core : simpl never.
Arguments cmra_op : simpl never. Arguments cmra_op : simpl never.
Arguments cmra_valid : simpl never. Arguments cmra_valid : simpl never.
Arguments cmra_validN : simpl never. Arguments cmra_validN : simpl never.
Arguments cmra_div : simpl never.
Arguments cmra_cofe_mixin : simpl never. Arguments cmra_cofe_mixin : simpl never.
Arguments cmra_mixin : simpl never. Arguments cmra_mixin : simpl never.
Add Printing Constructor cmraT. Add Printing Constructor cmraT.
Existing Instances cmra_core cmra_op cmra_valid cmra_validN cmra_div. Existing Instances cmra_core cmra_op cmra_valid cmra_validN.
Coercion cmra_cofeC (A : cmraT) : cofeT := CofeT (cmra_cofe_mixin A). Coercion cmra_cofeC (A : cmraT) : cofeT := CofeT (cmra_cofe_mixin A).
Canonical Structure cmra_cofeC. Canonical Structure cmra_cofeC.
...@@ -97,9 +88,6 @@ Section cmra_mixin. ...@@ -97,9 +88,6 @@ Section cmra_mixin.
Proof. apply (mixin_cmra_core_ne _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_core_ne _ (cmra_mixin A)). Qed.
Global Instance cmra_validN_ne n : Proper (dist n ==> impl) (@validN A _ n). Global Instance cmra_validN_ne n : Proper (dist n ==> impl) (@validN A _ n).
Proof. apply (mixin_cmra_validN_ne _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_validN_ne _ (cmra_mixin A)). Qed.
Global Instance cmra_div_ne n :
Proper (dist n ==> dist n ==> dist n) (@div A _).
Proof. apply (mixin_cmra_div_ne _ (cmra_mixin A)). Qed.
Lemma cmra_valid_validN x : x n, {n} x. Lemma cmra_valid_validN x : x n, {n} x.
Proof. apply (mixin_cmra_valid_validN _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_valid_validN _ (cmra_mixin A)). Qed.
Lemma cmra_validN_S n x : {S n} x {n} x. Lemma cmra_validN_S n x : {S n} x {n} x.
...@@ -116,8 +104,6 @@ Section cmra_mixin. ...@@ -116,8 +104,6 @@ Section cmra_mixin.
Proof. apply (mixin_cmra_core_preserving _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_core_preserving _ (cmra_mixin A)). Qed.
Lemma cmra_validN_op_l n x y : {n} (x y) {n} x. Lemma cmra_validN_op_l n x y : {n} (x y) {n} x.
Proof. apply (mixin_cmra_validN_op_l _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_validN_op_l _ (cmra_mixin A)). Qed.
Lemma cmra_op_div x y : x y x y ÷ x y.
Proof. apply (mixin_cmra_op_div _ (cmra_mixin A)). Qed.
Lemma cmra_extend n x y1 y2 : Lemma cmra_extend n x y1 y2 :
{n} x x {n} y1 y2 {n} x x {n} y1 y2
{ z | x z.1 z.2 z.1 {n} y1 z.2 {n} y2 }. { z | x z.1 z.2 z.1 {n} y1 z.2 {n} y2 }.
...@@ -188,8 +174,6 @@ Global Instance cmra_validN_ne' : Proper (dist n ==> iff) (@validN A _ n) | 1. ...@@ -188,8 +174,6 @@ Global Instance cmra_validN_ne' : Proper (dist n ==> iff) (@validN A _ n) | 1.
Proof. by split; apply cmra_validN_ne. Qed. Proof. by split; apply cmra_validN_ne. Qed.
Global Instance cmra_validN_proper : Proper (() ==> iff) (@validN A _ n) | 1. Global Instance cmra_validN_proper : Proper (() ==> iff) (@validN A _ n) | 1.
Proof. by intros n x1 x2 Hx; apply cmra_validN_ne', equiv_dist. Qed. Proof. by intros n x1 x2 Hx; apply cmra_validN_ne', equiv_dist. Qed.
Global Instance cmra_div_proper : Proper (() ==> () ==> ()) (@div A _).
Proof. apply (ne_proper_2 _). Qed.
Global Instance cmra_valid_proper : Proper (() ==> iff) (@valid A _). Global Instance cmra_valid_proper : Proper (() ==> iff) (@valid A _).
Proof. Proof.
...@@ -246,17 +230,9 @@ Proof. rewrite -{1}(cmra_core_l x); apply cmra_validN_op_l. Qed. ...@@ -246,17 +230,9 @@ Proof. rewrite -{1}(cmra_core_l x); apply cmra_validN_op_l. Qed.
Lemma cmra_core_valid x : x core x. Lemma cmra_core_valid x : x core x.
Proof. rewrite -{1}(cmra_core_l x); apply cmra_valid_op_l. Qed. Proof. rewrite -{1}(cmra_core_l x); apply cmra_valid_op_l. Qed.
(** ** Div *)
Lemma cmra_op_div' n x y : x {n} y x y ÷ x {n} y.
Proof. intros [z ->]. by rewrite cmra_op_div; last exists z. Qed.
(** ** Order *) (** ** Order *)
Lemma cmra_included_includedN x y : x y n, x {n} y. Lemma cmra_included_includedN n x y : x y x {n} y.
Proof. Proof. intros [z ->]. by exists z. Qed.
split; [by intros [z Hz] n; exists z; rewrite Hz|].
intros Hxy; exists (y ÷ x); apply equiv_dist=> n.
by rewrite cmra_op_div'.
Qed.
Global Instance cmra_includedN_preorder n : PreOrder (@includedN A _ _ n). Global Instance cmra_includedN_preorder n : PreOrder (@includedN A _ _ n).
Proof. Proof.
split. split.
...@@ -266,13 +242,15 @@ Proof. ...@@ -266,13 +242,15 @@ Proof.
Qed. Qed.
Global Instance cmra_included_preorder: PreOrder (@included A _ _). Global Instance cmra_included_preorder: PreOrder (@included A _ _).
Proof. Proof.
split; red; intros until 0; rewrite !cmra_included_includedN; first done. split.
intros; etrans; eauto. - by intros x; exists (core x); rewrite cmra_core_r.
- intros x y z [z1 Hy] [z2 Hz]; exists (z1 z2).
by rewrite assoc -Hy -Hz.
Qed. Qed.
Lemma cmra_validN_includedN n x y : {n} y x {n} y {n} x. Lemma cmra_validN_includedN n x y : {n} y x {n} y {n} x.
Proof. intros Hyv [z ?]; cofe_subst y; eauto using cmra_validN_op_l. Qed. Proof. intros Hyv [z ?]; cofe_subst y; eauto using cmra_validN_op_l. Qed.
Lemma cmra_validN_included n x y : {n} y x y {n} x. Lemma cmra_validN_included n x y : {n} y x y {n} x.
Proof. rewrite cmra_included_includedN; eauto using cmra_validN_includedN. Qed. Proof. intros Hyv [z ?]; setoid_subst; eauto using cmra_validN_op_l. Qed.
Lemma cmra_includedN_S n x y : x {S n} y x {n} y. Lemma cmra_includedN_S n x y : x {S n} y x {n} y.
Proof. by intros [z Hz]; exists z; apply dist_S. Qed. Proof. by intros [z Hz]; exists z; apply dist_S. Qed.
...@@ -337,7 +315,7 @@ Proof. ...@@ -337,7 +315,7 @@ Proof.
Qed. Qed.
Lemma cmra_discrete_included_iff `{Discrete A} n x y : x y x {n} y. Lemma cmra_discrete_included_iff `{Discrete A} n x y : x y x {n} y.
Proof. Proof.
split; first by rewrite cmra_included_includedN. split; first by apply cmra_included_includedN.
intros [z ->%(timeless_iff _ _)]; eauto using cmra_included_l. intros [z ->%(timeless_iff _ _)]; eauto using cmra_included_l.
Qed. Qed.
Lemma cmra_discrete_updateP `{CMRADiscrete A} (x : A) (P : A Prop) : Lemma cmra_discrete_updateP `{CMRADiscrete A} (x : A) (P : A Prop) :
...@@ -486,25 +464,23 @@ End cmra_transport. ...@@ -486,25 +464,23 @@ End cmra_transport.
(** * Instances *) (** * Instances *)
(** ** Discrete CMRA *) (** ** Discrete CMRA *)
Class RA A `{Equiv A, Core A, Op A, Valid A, Div A} := { Class RA A `{Equiv A, Core A, Op A, Valid A} := {
(* setoids *) (* setoids *)
ra_op_ne (x : A) : Proper (() ==> ()) (op x); ra_op_ne (x : A) : Proper (() ==> ()) (op x);
ra_core_ne :> Proper (() ==> ()) core; ra_core_ne :> Proper (() ==> ()) core;
ra_validN_ne :> Proper (() ==> impl) valid; ra_validN_ne :> Proper (() ==> impl) valid;
ra_div_ne :> Proper (() ==> () ==> ()) div;
(* monoid *) (* monoid *)
ra_assoc :> Assoc () (); ra_assoc :> Assoc () ();
ra_comm :> Comm () (); ra_comm :> Comm () ();
ra_core_l x : core x x x; ra_core_l x : core x x x;
ra_core_idemp x : core (core x) core x; ra_core_idemp x : core (core x) core x;
ra_core_preserving x y : x y core x core y; ra_core_preserving x y : x y core x core y;
ra_valid_op_l x y : (x y) x; ra_valid_op_l x y : (x y) x
ra_op_div x y : x y x y ÷ x y
}. }.
Section discrete. Section discrete.
Context {A : cofeT} `{Discrete A}. Context {A : cofeT} `{Discrete A}.
Context `{Core A, Op A, Valid A, Div A} (ra : RA A). Context `{Core A, Op A, Valid A} (ra : RA A).
Instance discrete_validN : ValidN A := λ n x, x. Instance discrete_validN : ValidN A := λ n x, x.
Definition discrete_cmra_mixin : CMRAMixin A. Definition discrete_cmra_mixin : CMRAMixin A.
...@@ -525,7 +501,6 @@ Section unit. ...@@ -525,7 +501,6 @@ Section unit.
Instance unit_valid : Valid () := λ x, True. Instance unit_valid : Valid () := λ x, True.
Instance unit_core : Core () := λ x, x. Instance unit_core : Core () := λ x, x.
Instance unit_op : Op () := λ x y, (). Instance unit_op : Op () := λ x y, ().
Instance unit_div : Div () := λ x y, ().
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.
...@@ -544,7 +519,6 @@ Section prod. ...@@ -544,7 +519,6 @@ Section prod.
Instance prod_core : Core (A * B) := λ x, (core (x.1), core (x.2)). Instance prod_core : Core (A * B) := λ x, (core (x.1), core (x.2)).
Instance prod_valid : Valid (A * B) := λ x, x.1 x.2. Instance prod_valid : Valid (A * B) := λ x, x.1 x.2.
Instance prod_validN : ValidN (A * B) := λ n x, {n} x.1 {n} x.2. Instance prod_validN : ValidN (A * B) := λ n x, {n} x.1 {n} x.2.
Instance prod_div : Div (A * B) := λ x y, (x.1 ÷ y.1, x.2 ÷ y.2).
Lemma prod_included (x y : A * B) : x y x.1 y.1 x.2 y.2. Lemma prod_included (x y : A * B) : x y x.1 y.1 x.2 y.2.
Proof. Proof.
split; [intros [z Hz]; split; [exists (z.1)|exists (z.2)]; apply Hz|]. split; [intros [z Hz]; split; [exists (z.1)|exists (z.2)]; apply Hz|].
...@@ -561,8 +535,6 @@ Section prod. ...@@ -561,8 +535,6 @@ Section prod.
- by intros n x y1 y2 [Hy1 Hy2]; split; rewrite /= ?Hy1 ?Hy2. - by intros n x y1 y2 [Hy1 Hy2]; split; rewrite /= ?Hy1 ?Hy2.
- by intros n y1 y2 [Hy1 Hy2]; split; rewrite /= ?Hy1 ?Hy2. - by intros n y1 y2 [Hy1 Hy2]; split; rewrite /= ?Hy1 ?Hy2.
- by intros n y1 y2 [Hy1 Hy2] [??]; split; rewrite /= -?Hy1 -?Hy2. - by intros n y1 y2 [Hy1 Hy2] [??]; split; rewrite /= -?Hy1 -?Hy2.
- by intros n x1 x2 [Hx1 Hx2] y1 y2 [Hy1 Hy2];
split; rewrite /= ?Hx1 ?Hx2 ?Hy1 ?Hy2.
- intros x; split. - intros x; split.
+ intros [??] n; split; by apply cmra_valid_validN. + intros [??] n; split; by apply cmra_valid_validN.
+ intros Hxy; split; apply cmra_valid_validN=> n; apply Hxy. + intros Hxy; split; apply cmra_valid_validN=> n; apply Hxy.
...@@ -574,8 +546,6 @@ Section prod. ...@@ -574,8 +546,6 @@ Section prod.
- intros x y; rewrite !prod_included. - intros x y; rewrite !prod_included.
by intros [??]; split; apply cmra_core_preserving. by intros [??]; split; apply cmra_core_preserving.
- intros n x y [??]; split; simpl in *; eauto using cmra_validN_op_l. - intros n x y [??]; split; simpl in *; eauto using cmra_validN_op_l.
- intros x y; rewrite prod_included; intros [??].
by split; apply cmra_op_div.
- intros n x y1 y2 [??] [??]; simpl in *. - intros n x y1 y2 [??] [??]; simpl in *.
destruct (cmra_extend n (x.1) (y1.1) (y2.1)) as (z1&?&?&?); auto. destruct (cmra_extend n (x.1) (y1.1) (y2.1)) as (z1&?&?&?); auto.
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.
......
...@@ -27,7 +27,6 @@ Instance dec_agree_op : Op (dec_agree A) := λ x y, ...@@ -27,7 +27,6 @@ Instance dec_agree_op : Op (dec_agree A) := λ x y,
| _, _ => DecAgreeBot | _, _ => DecAgreeBot
end. end.
Instance dec_agree_core : Core (dec_agree A) := id. Instance dec_agree_core : Core (dec_agree A) := id.
Instance dec_agree_div : Div (dec_agree A) := λ x y, x.
Definition dec_agree_ra : RA (dec_agree A). Definition dec_agree_ra : RA (dec_agree A).
Proof. Proof.
...@@ -35,15 +34,12 @@ Proof. ...@@ -35,15 +34,12 @@ Proof.
- apply _. - apply _.
- apply _. - apply _.
- apply _. - apply _.
- apply _.
- 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).
- 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 [?|] [?|] ?.
- by intros [?|] [?|] ?. - by intros [?|] [?|] ?.
- intros [?|] [?|] [[?|]]; fold_leibniz;
intros; by repeat (simplify_eq/= || case_match).
Qed. Qed.
Canonical Structure dec_agreeR : cmraT := discreteR dec_agree_ra. Canonical Structure dec_agreeR : cmraT := discreteR dec_agree_ra.
......
...@@ -6,6 +6,7 @@ Record validity {A} (P : A → Prop) : Type := Validity { ...@@ -6,6 +6,7 @@ Record validity {A} (P : A → Prop) : Type := Validity {
validity_is_valid : Prop; validity_is_valid : Prop;
validity_prf : validity_is_valid P validity_car validity_prf : validity_is_valid P validity_car
}. }.
Add Printing Constructor validity.
Arguments Validity {_ _} _ _ _. Arguments Validity {_ _} _ _ _.
Arguments validity_car {_ _} _. Arguments validity_car {_ _} _.
Arguments validity_is_valid {_ _} _. Arguments validity_is_valid {_ _} _.
...@@ -13,23 +14,16 @@ Arguments validity_is_valid {_ _} _. ...@@ -13,23 +14,16 @@ Arguments validity_is_valid {_ _} _.
Definition to_validity {A} {P : A Prop} (x : A) : validity P := Definition to_validity {A} {P : A Prop} (x : A) : validity P :=
Validity x (P x) id. Validity x (P x) id.
Definition dra_included `{Equiv A, Valid A, Disjoint A, Op A} := λ x y, Class DRA A `{Equiv A, Valid A, Core A, Disjoint A, Op A} := {
z, y x z z x z.
Instance: Params (@dra_included) 4.
Local Infix "≼" := dra_included.
Class DRA A `{Equiv A, Valid A, Core A, Disjoint A, Op A, Div A} := {
(* setoids *) (* setoids *)
dra_equivalence :> Equivalence (() : relation A); dra_equivalence :> Equivalence (() : relation A);
dra_op_proper :> Proper (() ==> () ==> ()) (); dra_op_proper :> Proper (() ==> () ==> ()) ();
dra_core_proper :> Proper (() ==> ()) core; dra_core_proper :> Proper (() ==> ()) core;
dra_valid_proper :> Proper (() ==> impl) valid; dra_valid_proper :> Proper (() ==> impl) valid;
dra_disjoint_proper :> x, Proper (() ==> impl) (disjoint x); dra_disjoint_proper :> x, Proper (() ==> impl) (disjoint x);
dra_div_proper :> Proper (() ==> () ==> ()) div;
(* validity *) (* validity *)
dra_op_valid x y : x y x y (x y); dra_op_valid x y : x y x y (x y);
dra_core_valid x : x core x; dra_core_valid x : x core x;
dra_div_valid x y : x y x y (y ÷ x);
(* monoid *) (* monoid *)
dra_assoc :> Assoc () (); dra_assoc :> Assoc () ();
dra_disjoint_ll x y z : x y z x y x y z x z; dra_disjoint_ll x y z : x y z x y x y z x z;
...@@ -39,9 +33,8 @@ Class DRA A `{Equiv A, Valid A, Core A, Disjoint A, Op A, Div A} := { ...@@ -39,9 +33,8 @@ Class DRA A `{Equiv A, Valid A, Core A, Disjoint A, Op A, Div A} := {
dra_core_disjoint_l x : x core x x; dra_core_disjoint_l x : x core x x;
dra_core_l x : x core x x x; dra_core_l x : x core x x x;
dra_core_idemp x : x core (core x) core x; dra_core_idemp x : x core (core x) core x;
dra_core_preserving x y : x y x y core x core y; dra_core_preserving x y :
dra_disjoint_div x y : x y x y x y ÷ x; z, x y x y core (x y) core x z z core x z
dra_op_div x y : x y x y x y ÷ x y
}. }.
Section dra. Section dra.
...@@ -83,7 +76,6 @@ Proof. ...@@ -83,7 +76,6 @@ Proof.
apply dra_disjoint_move_l; auto; by rewrite dra_comm. apply dra_disjoint_move_l; auto; by rewrite dra_comm.
Qed. Qed.
Hint Immediate dra_disjoint_move_l dra_disjoint_move_r. Hint Immediate dra_disjoint_move_l dra_disjoint_move_r.
Hint Unfold dra_included.
Lemma validity_valid_car_valid (z : T) : z validity_car z. Lemma validity_valid_car_valid (z : T) : z validity_car z.
Proof. apply validity_prf. Qed. Proof. apply validity_prf. Qed.
...@@ -95,10 +87,6 @@ Program Instance validity_op : Op T := λ x y, ...@@ -95,10 +87,6 @@ Program Instance validity_op : Op T := λ x y,
Validity (validity_car x validity_car y) Validity (validity_car x validity_car y)
( x y validity_car x validity_car y) _. ( x y validity_car x validity_car y) _.
Solve Obligations with naive_solver auto using dra_op_valid. Solve Obligations with naive_solver auto using dra_op_valid.
Program Instance validity_div : Div T := λ x y,
Validity (validity_car x ÷ validity_car y)
( x y validity_car y validity_car x) _.
Solve Obligations with naive_solver auto using dra_div_valid.
Definition validity_ra : RA (discreteC T). Definition validity_ra : RA (discreteC T).
Proof. Proof.
...@@ -108,11 +96,6 @@ Proof. ...@@ -108,11 +96,6 @@ Proof.
first [rewrite ?Heq; tauto|rewrite -?Heq; tauto|tauto]. first [rewrite ?Heq; tauto|rewrite -?Heq; tauto|tauto].
- by intros ?? [? Heq]; split; [done|]; simpl; intros ?; rewrite Heq. - by intros ?? [? Heq]; split; [done|]; simpl; intros ?; rewrite Heq.
- intros ?? [??]; naive_solver. - intros ?? [??]; naive_solver.
- intros x1 x2 [? Hx] y1 y2 [? Hy];
split;