Commit 8c96ad4e authored by Robbert Krebbers's avatar Robbert Krebbers

Shorter names for common math notions.

Also do some minor clean up.
parent ba6d9390
...@@ -59,9 +59,9 @@ Program Instance agree_op : Op (agree A) := λ x y, ...@@ -59,9 +59,9 @@ Program Instance agree_op : Op (agree A) := λ x 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_unit : Unit (agree A) := id. Instance agree_unit : Unit (agree A) := id.
Instance agree_minus : Minus (agree A) := λ x y, x. Instance agree_minus : Minus (agree A) := λ x y, x.
Instance: Commutative () (@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.
Definition agree_idempotent (x : agree A) : x x x. Definition agree_idemp (x : agree A) : x x x.
Proof. split; naive_solver. Qed. Proof. split; naive_solver. Qed.
Instance: n : nat, Proper (dist n ==> impl) (@validN (agree A) _ n). Instance: n : nat, Proper (dist n ==> impl) (@validN (agree A) _ n).
Proof. Proof.
...@@ -79,18 +79,18 @@ Proof. ...@@ -79,18 +79,18 @@ Proof.
eauto using agree_valid_le. eauto using agree_valid_le.
Qed. Qed.
Instance: Proper (dist n ==> dist n ==> dist n) (@op (agree A) _). Instance: Proper (dist n ==> dist n ==> dist n) (@op (agree A) _).
Proof. by intros n x1 x2 Hx y1 y2 Hy; rewrite Hy !(commutative _ _ y2) Hx. Qed. Proof. by intros n x1 x2 Hx y1 y2 Hy; rewrite Hy !(comm _ _ y2) Hx. Qed.
Instance: Proper (() ==> () ==> ()) op := ne_proper_2 _. Instance: Proper (() ==> () ==> ()) op := ne_proper_2 _.
Instance: Associative () (@op (agree A) _). Instance: Assoc () (@op (agree A) _).
Proof. Proof.
intros x y z; split; simpl; intuition; intros x y z; split; simpl; intuition;
repeat match goal with H : agree_is_valid _ _ |- _ => clear H end; repeat match goal with H : agree_is_valid _ _ |- _ => clear H end;
by cofe_subst; rewrite !agree_idempotent. by cofe_subst; rewrite !agree_idemp.
Qed. Qed.
Lemma agree_includedN (x y : agree A) n : x {n} y y {n} x y. Lemma agree_includedN (x y : agree A) n : x {n} y y {n} x y.
Proof. Proof.
split; [|by intros ?; exists y]. split; [|by intros ?; exists y].
by intros [z Hz]; rewrite Hz (associative _) agree_idempotent. by intros [z Hz]; rewrite Hz assoc agree_idemp.
Qed. Qed.
Definition agree_cmra_mixin : CMRAMixin (agree A). Definition agree_cmra_mixin : CMRAMixin (agree A).
Proof. Proof.
...@@ -99,7 +99,7 @@ Proof. ...@@ -99,7 +99,7 @@ Proof.
* 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_idempotent. * intros x; apply agree_idemp.
* by intros x y n [(?&?&?) ?]. * by intros x y n [(?&?&?) ?].
* by intros x y n; rewrite agree_includedN. * by intros x y n; rewrite agree_includedN.
Qed. Qed.
...@@ -108,13 +108,13 @@ Proof. intros Hxy; apply Hxy. Qed. ...@@ -108,13 +108,13 @@ Proof. intros Hxy; apply Hxy. Qed.
Lemma agree_valid_includedN (x y : agree A) n : {n} y x {n} y x {n} y. Lemma agree_valid_includedN (x y : agree A) n : {n} y x {n} y x {n} y.
Proof. Proof.
move=> Hval [z Hy]; move: Hval; rewrite Hy. move=> Hval [z Hy]; move: Hval; rewrite Hy.
by move=> /agree_op_inv->; rewrite agree_idempotent. by move=> /agree_op_inv->; rewrite agree_idemp.
Qed. Qed.
Definition agree_cmra_extend_mixin : CMRAExtendMixin (agree A). Definition agree_cmra_extend_mixin : CMRAExtendMixin (agree A).
Proof. Proof.
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_idempotent. * by rewrite agree_idemp.
* by move: Hval; rewrite Hx; move=> /agree_op_inv->; rewrite agree_idempotent. * by move: Hval; rewrite Hx; move=> /agree_op_inv->; rewrite agree_idemp.
Qed. Qed.
Canonical Structure agreeRA : cmraT := Canonical Structure agreeRA : cmraT :=
CMRAT agree_cofe_mixin agree_cmra_mixin agree_cmra_extend_mixin. CMRAT agree_cofe_mixin agree_cmra_mixin agree_cmra_extend_mixin.
...@@ -125,7 +125,7 @@ Solve Obligations with done. ...@@ -125,7 +125,7 @@ Solve Obligations with done.
Global Instance to_agree_ne n : Proper (dist n ==> dist n) to_agree. Global Instance to_agree_ne n : Proper (dist n ==> dist n) to_agree.
Proof. intros x1 x2 Hx; split; naive_solver eauto using @dist_le. Qed. Proof. intros x1 x2 Hx; split; naive_solver eauto using @dist_le. Qed.
Global Instance to_agree_proper : Proper (() ==> ()) to_agree := ne_proper _. Global Instance to_agree_proper : Proper (() ==> ()) to_agree := ne_proper _.
Global Instance to_agree_inj n : Injective (dist n) (dist n) (to_agree). Global Instance to_agree_inj n : Inj (dist n) (dist n) (to_agree).
Proof. by intros x y [_ Hxy]; apply Hxy. Qed. Proof. by intros x y [_ Hxy]; apply Hxy. Qed.
Lemma to_agree_car n (x : agree A) : {n} x to_agree (x n) {n} x. Lemma to_agree_car n (x : agree A) : {n} x to_agree (x n) {n} x.
Proof. intros [??]; split; naive_solver eauto using agree_valid_le. Qed. Proof. intros [??]; split; naive_solver eauto using agree_valid_le. Qed.
......
...@@ -106,10 +106,10 @@ Proof. ...@@ -106,10 +106,10 @@ Proof.
* by intros n x1 x2 [Hx Hx'] y1 y2 [Hy Hy']; * by intros n x1 x2 [Hx Hx'] y1 y2 [Hy Hy'];
split; simpl; rewrite ?Hy ?Hy' ?Hx ?Hx'. split; simpl; rewrite ?Hy ?Hy' ?Hx ?Hx'.
* intros n [[] ?] ?; naive_solver eauto using cmra_includedN_S, cmra_validN_S. * intros n [[] ?] ?; naive_solver eauto using cmra_includedN_S, cmra_validN_S.
* by split; simpl; rewrite associative. * by split; simpl; rewrite assoc.
* by split; simpl; rewrite commutative. * by split; simpl; rewrite comm.
* by split; simpl; rewrite ?cmra_unit_l. * by split; simpl; rewrite ?cmra_unit_l.
* by split; simpl; rewrite ?cmra_unit_idempotent. * by split; simpl; rewrite ?cmra_unit_idemp.
* intros n ??; rewrite! auth_includedN; intros [??]. * intros n ??; rewrite! auth_includedN; intros [??].
by split; simpl; apply cmra_unit_preservingN. by split; simpl; apply cmra_unit_preservingN.
* assert ( n (a b1 b2 : A), b1 b2 {n} a b1 {n} a). * assert ( n (a b1 b2 : A), b1 b2 {n} a b1 {n} a).
...@@ -153,8 +153,8 @@ Lemma auth_update a a' b b' : ...@@ -153,8 +153,8 @@ Lemma auth_update a a' b b' :
Proof. Proof.
move=> Hab [[?| |] bf1] n // =>-[[bf2 Ha] ?]; do 2 red; simpl in *. move=> Hab [[?| |] bf1] n // =>-[[bf2 Ha] ?]; do 2 red; simpl in *.
destruct (Hab n (bf1 bf2)) as [Ha' ?]; auto. destruct (Hab n (bf1 bf2)) as [Ha' ?]; auto.
{ by rewrite Ha left_id associative. } { by rewrite Ha left_id assoc. }
split; [by rewrite Ha' left_id associative; apply cmra_includedN_l|done]. split; [by rewrite Ha' left_id assoc; apply cmra_includedN_l|done].
Qed. Qed.
Lemma auth_local_update L `{!LocalUpdate Lv L} a a' : Lemma auth_local_update L `{!LocalUpdate Lv L} a a' :
...@@ -170,7 +170,7 @@ Lemma auth_update_op_l a a' b : ...@@ -170,7 +170,7 @@ Lemma auth_update_op_l a a' b :
Proof. by intros; apply (auth_local_update _). Qed. Proof. by intros; apply (auth_local_update _). Qed.
Lemma auth_update_op_r a a' b : Lemma auth_update_op_r a a' b :
(a b) a a' ~~> (a b) (a' b). (a b) a a' ~~> (a b) (a' b).
Proof. rewrite -!(commutative _ b); apply auth_update_op_l. Qed. Proof. rewrite -!(comm _ b); apply auth_update_op_l. Qed.
(* This does not seem to follow from auth_local_update. (* This does not seem to follow from auth_local_update.
The trouble is that given ✓ (L a ⋅ a'), Lv a The trouble is that given ✓ (L a ⋅ a'), Lv a
......
...@@ -43,10 +43,10 @@ Record CMRAMixin A `{Dist A, Equiv A, Unit A, Op A, ValidN A, Minus A} := { ...@@ -43,10 +43,10 @@ Record CMRAMixin A `{Dist A, Equiv A, Unit A, Op A, ValidN A, Minus A} := {
(* valid *) (* valid *)
mixin_cmra_validN_S n x : {S n} x {n} x; mixin_cmra_validN_S n x : {S n} x {n} x;
(* monoid *) (* monoid *)
mixin_cmra_associative : Associative () (); mixin_cmra_assoc : Assoc () ();
mixin_cmra_commutative : Commutative () (); mixin_cmra_comm : Comm () ();
mixin_cmra_unit_l x : unit x x x; mixin_cmra_unit_l x : unit x x x;
mixin_cmra_unit_idempotent x : unit (unit x) unit x; mixin_cmra_unit_idemp x : unit (unit x) unit x;
mixin_cmra_unit_preservingN n x y : x {n} y unit x {n} unit y; mixin_cmra_unit_preservingN n x y : x {n} y unit x {n} unit 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_minus n x y : x {n} y x y x {n} y mixin_cmra_op_minus n x y : x {n} y x y x {n} y
...@@ -101,14 +101,14 @@ Section cmra_mixin. ...@@ -101,14 +101,14 @@ Section cmra_mixin.
Proof. apply (mixin_cmra_minus_ne _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_minus_ne _ (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.
Proof. apply (mixin_cmra_validN_S _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_validN_S _ (cmra_mixin A)). Qed.
Global Instance cmra_associative : Associative () (@op A _). Global Instance cmra_assoc : Assoc () (@op A _).
Proof. apply (mixin_cmra_associative _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_assoc _ (cmra_mixin A)). Qed.
Global Instance cmra_commutative : Commutative () (@op A _). Global Instance cmra_comm : Comm () (@op A _).
Proof. apply (mixin_cmra_commutative _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_comm _ (cmra_mixin A)). Qed.
Lemma cmra_unit_l x : unit x x x. Lemma cmra_unit_l x : unit x x x.
Proof. apply (mixin_cmra_unit_l _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_unit_l _ (cmra_mixin A)). Qed.
Lemma cmra_unit_idempotent x : unit (unit x) unit x. Lemma cmra_unit_idemp x : unit (unit x) unit x.
Proof. apply (mixin_cmra_unit_idempotent _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_unit_idemp _ (cmra_mixin A)). Qed.
Lemma cmra_unit_preservingN n x y : x {n} y unit x {n} unit y. Lemma cmra_unit_preservingN n x y : x {n} y unit x {n} unit y.
Proof. apply (mixin_cmra_unit_preservingN _ (cmra_mixin A)). Qed. Proof. apply (mixin_cmra_unit_preservingN _ (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.
...@@ -166,7 +166,7 @@ Proof. apply (ne_proper _). Qed. ...@@ -166,7 +166,7 @@ Proof. apply (ne_proper _). Qed.
Global Instance cmra_op_ne' n : Proper (dist n ==> dist n ==> dist n) (@op A _). Global Instance cmra_op_ne' n : Proper (dist n ==> dist n ==> dist n) (@op A _).
Proof. Proof.
intros x1 x2 Hx y1 y2 Hy. intros x1 x2 Hx y1 y2 Hy.
by rewrite Hy (commutative _ x1) Hx (commutative _ y2). by rewrite Hy (comm _ x1) Hx (comm _ y2).
Qed. Qed.
Global Instance ra_op_proper' : Proper (() ==> () ==> ()) (@op A _). Global Instance ra_op_proper' : Proper (() ==> () ==> ()) (@op A _).
Proof. apply (ne_proper_2 _). Qed. Proof. apply (ne_proper_2 _). Qed.
...@@ -217,15 +217,15 @@ Proof. induction 2; eauto using cmra_validN_S. Qed. ...@@ -217,15 +217,15 @@ Proof. induction 2; eauto using cmra_validN_S. Qed.
Lemma cmra_valid_op_l x y : (x y) x. Lemma cmra_valid_op_l x y : (x y) x.
Proof. rewrite !cmra_valid_validN; eauto using cmra_validN_op_l. Qed. Proof. rewrite !cmra_valid_validN; eauto using cmra_validN_op_l. Qed.
Lemma cmra_validN_op_r x y n : {n} (x y) {n} y. Lemma cmra_validN_op_r x y n : {n} (x y) {n} y.
Proof. rewrite (commutative _ x); apply cmra_validN_op_l. Qed. Proof. rewrite (comm _ x); apply cmra_validN_op_l. Qed.
Lemma cmra_valid_op_r x y : (x y) y. Lemma cmra_valid_op_r x y : (x y) y.
Proof. rewrite !cmra_valid_validN; eauto using cmra_validN_op_r. Qed. Proof. rewrite !cmra_valid_validN; eauto using cmra_validN_op_r. Qed.
(** ** Units *) (** ** Units *)
Lemma cmra_unit_r x : x unit x x. Lemma cmra_unit_r x : x unit x x.
Proof. by rewrite (commutative _ x) cmra_unit_l. Qed. Proof. by rewrite (comm _ x) cmra_unit_l. Qed.
Lemma cmra_unit_unit x : unit x unit x unit x. Lemma cmra_unit_unit x : unit x unit x unit x.
Proof. by rewrite -{2}(cmra_unit_idempotent x) cmra_unit_r. Qed. Proof. by rewrite -{2}(cmra_unit_idemp x) cmra_unit_r. Qed.
Lemma cmra_unit_validN x n : {n} x {n} unit x. Lemma cmra_unit_validN x n : {n} x {n} unit x.
Proof. rewrite -{1}(cmra_unit_l x); apply cmra_validN_op_l. Qed. Proof. rewrite -{1}(cmra_unit_l x); apply cmra_validN_op_l. Qed.
Lemma cmra_unit_valid x : x unit x. Lemma cmra_unit_valid x : x unit x.
...@@ -243,7 +243,7 @@ Proof. ...@@ -243,7 +243,7 @@ Proof.
split. split.
* by intros x; exists (unit x); rewrite cmra_unit_r. * by intros x; exists (unit x); rewrite cmra_unit_r.
* intros x y z [z1 Hy] [z2 Hz]; exists (z1 z2). * intros x y z [z1 Hy] [z2 Hz]; exists (z1 z2).
by rewrite (associative _) -Hy -Hz. by rewrite assoc -Hy -Hz.
Qed. Qed.
Global Instance cmra_included_preorder: PreOrder (@included A _ _). Global Instance cmra_included_preorder: PreOrder (@included A _ _).
Proof. Proof.
...@@ -265,22 +265,22 @@ Proof. by exists y. Qed. ...@@ -265,22 +265,22 @@ Proof. by exists y. Qed.
Lemma cmra_included_l x y : x x y. Lemma cmra_included_l x y : x x y.
Proof. by exists y. Qed. Proof. by exists y. Qed.
Lemma cmra_includedN_r n x y : y {n} x y. Lemma cmra_includedN_r n x y : y {n} x y.
Proof. rewrite (commutative op); apply cmra_includedN_l. Qed. Proof. rewrite (comm op); apply cmra_includedN_l. Qed.
Lemma cmra_included_r x y : y x y. Lemma cmra_included_r x y : y x y.
Proof. rewrite (commutative op); apply cmra_included_l. Qed. Proof. rewrite (comm op); apply cmra_included_l. Qed.
Lemma cmra_unit_preserving x y : x y unit x unit y. Lemma cmra_unit_preserving x y : x y unit x unit y.
Proof. rewrite !cmra_included_includedN; eauto using cmra_unit_preservingN. Qed. Proof. rewrite !cmra_included_includedN; eauto using cmra_unit_preservingN. Qed.
Lemma cmra_included_unit x : unit x x. Lemma cmra_included_unit x : unit x x.
Proof. by exists x; rewrite cmra_unit_l. Qed. Proof. by exists x; rewrite cmra_unit_l. Qed.
Lemma cmra_preservingN_l n x y z : x {n} y z x {n} z y. Lemma cmra_preservingN_l n x y z : x {n} y z x {n} z y.
Proof. by intros [z1 Hz1]; exists z1; rewrite Hz1 (associative op). Qed. Proof. by intros [z1 Hz1]; exists z1; rewrite Hz1 (assoc op). Qed.
Lemma cmra_preserving_l x y z : x y z x z y. Lemma cmra_preserving_l x y z : x y z x z y.
Proof. by intros [z1 Hz1]; exists z1; rewrite Hz1 (associative op). Qed. Proof. by intros [z1 Hz1]; exists z1; rewrite Hz1 (assoc op). Qed.
Lemma cmra_preservingN_r n x y z : x {n} y x z {n} y z. Lemma cmra_preservingN_r n x y z : x {n} y x z {n} y z.
Proof. by intros; rewrite -!(commutative _ z); apply cmra_preservingN_l. Qed. Proof. by intros; rewrite -!(comm _ z); apply cmra_preservingN_l. Qed.
Lemma cmra_preserving_r x y z : x y x z y z. Lemma cmra_preserving_r x y z : x y x z y z.
Proof. by intros; rewrite -!(commutative _ z); apply cmra_preserving_l. Qed. Proof. by intros; rewrite -!(comm _ z); apply cmra_preserving_l. Qed.
Lemma cmra_included_dist_l x1 x2 x1' n : Lemma cmra_included_dist_l x1 x2 x1' n :
x1 x2 x1' {n} x1 x2', x1' x2' x2' {n} x2. x1 x2 x1' {n} x1 x2', x1' x2' x2' {n} x2.
...@@ -321,7 +321,7 @@ Section identity. ...@@ -321,7 +321,7 @@ Section identity.
Lemma cmra_empty_least x : x. Lemma cmra_empty_least x : x.
Proof. by exists x; rewrite left_id. Qed. Proof. by exists x; rewrite left_id. Qed.
Global Instance cmra_empty_right_id : RightId () (). Global Instance cmra_empty_right_id : RightId () ().
Proof. by intros x; rewrite (commutative op) left_id. Qed. Proof. by intros x; rewrite (comm op) left_id. Qed.
Lemma cmra_unit_empty : unit . Lemma cmra_unit_empty : unit .
Proof. by rewrite -{2}(cmra_unit_l ) right_id. Qed. Proof. by rewrite -{2}(cmra_unit_l ) right_id. Qed.
End identity. End identity.
...@@ -336,7 +336,7 @@ Lemma local_update L `{!LocalUpdate Lv L} x y : ...@@ -336,7 +336,7 @@ Lemma local_update L `{!LocalUpdate Lv L} x y :
Proof. by rewrite equiv_dist=>?? n; apply (local_updateN L). Qed. Proof. by rewrite equiv_dist=>?? n; apply (local_updateN L). Qed.
Global Instance local_update_op x : LocalUpdate (λ _, True) (op x). Global Instance local_update_op x : LocalUpdate (λ _, True) (op x).
Proof. split. apply _. by intros n y1 y2 _ _; rewrite associative. Qed. Proof. split. apply _. by intros n y1 y2 _ _; rewrite assoc. Qed.
(** ** Updates *) (** ** Updates *)
Global Instance cmra_update_preorder : PreOrder (@cmra_update A). Global Instance cmra_update_preorder : PreOrder (@cmra_update A).
...@@ -366,10 +366,10 @@ Lemma cmra_updateP_op (P1 P2 Q : A → Prop) x1 x2 : ...@@ -366,10 +366,10 @@ Lemma cmra_updateP_op (P1 P2 Q : A → Prop) x1 x2 :
x1 ~~>: P1 x2 ~~>: P2 ( y1 y2, P1 y1 P2 y2 Q (y1 y2)) x1 x2 ~~>: Q. x1 ~~>: P1 x2 ~~>: P2 ( y1 y2, P1 y1 P2 y2 Q (y1 y2)) x1 x2 ~~>: Q.
Proof. Proof.
intros Hx1 Hx2 Hy z n ?. intros Hx1 Hx2 Hy z n ?.
destruct (Hx1 (x2 z) n) as (y1&?&?); first by rewrite associative. destruct (Hx1 (x2 z) n) as (y1&?&?); first by rewrite assoc.
destruct (Hx2 (y1 z) n) as (y2&?&?); destruct (Hx2 (y1 z) n) as (y2&?&?);
first by rewrite associative (commutative _ x2) -associative. first by rewrite assoc (comm _ x2) -assoc.
exists (y1 y2); split; last rewrite (commutative _ y1) -associative; auto. exists (y1 y2); split; last rewrite (comm _ y1) -assoc; auto.
Qed. Qed.
Lemma cmra_updateP_op' (P1 P2 : A Prop) x1 x2 : Lemma cmra_updateP_op' (P1 P2 : A Prop) x1 x2 :
x1 ~~>: P1 x2 ~~>: P2 x1 x2 ~~>: λ y, y1 y2, y = y1 y2 P1 y1 P2 y2. x1 ~~>: P1 x2 ~~>: P2 x1 x2 ~~>: λ y, y1 y2, y = y1 y2 P1 y1 P2 y2.
...@@ -448,10 +448,10 @@ Class RA A `{Equiv A, Unit A, Op A, Valid A, Minus A} := { ...@@ -448,10 +448,10 @@ Class RA A `{Equiv A, Unit A, Op A, Valid A, Minus A} := {
ra_validN_ne :> Proper (() ==> impl) valid; ra_validN_ne :> Proper (() ==> impl) valid;
ra_minus_ne :> Proper (() ==> () ==> ()) minus; ra_minus_ne :> Proper (() ==> () ==> ()) minus;
(* monoid *) (* monoid *)
ra_associative :> Associative () (); ra_assoc :> Assoc () ();
ra_commutative :> Commutative () (); ra_comm :> Comm () ();
ra_unit_l x : unit x x x; ra_unit_l x : unit x x x;
ra_unit_idempotent x : unit (unit x) unit x; ra_unit_idemp x : unit (unit x) unit x;
ra_unit_preserving x y : x y unit x unit y; ra_unit_preserving x y : x y unit x unit y;
ra_valid_op_l x y : (x y) x; ra_valid_op_l x y : (x y) x;
ra_op_minus x y : x y x y x y ra_op_minus x y : x y x y x y
...@@ -524,10 +524,10 @@ Section prod. ...@@ -524,10 +524,10 @@ Section prod.
* by intros n x1 x2 [Hx1 Hx2] y1 y2 [Hy1 Hy2]; * by intros n x1 x2 [Hx1 Hx2] y1 y2 [Hy1 Hy2];
split; rewrite /= ?Hx1 ?Hx2 ?Hy1 ?Hy2. split; rewrite /= ?Hx1 ?Hx2 ?Hy1 ?Hy2.
* by intros n x [??]; split; apply cmra_validN_S. * by intros n x [??]; split; apply cmra_validN_S.
* split; simpl; apply (associative _). * by split; rewrite /= assoc.
* split; simpl; apply (commutative _). * by split; rewrite /= comm.
* split; simpl; apply cmra_unit_l. * by split; rewrite /= cmra_unit_l.
* split; simpl; apply cmra_unit_idempotent. * by split; rewrite /= cmra_unit_idemp.
* intros n x y; rewrite !prod_includedN. * intros n x y; rewrite !prod_includedN.
by intros [??]; split; apply cmra_unit_preservingN. by intros [??]; split; apply cmra_unit_preservingN.
* 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.
......
...@@ -22,21 +22,21 @@ Global Instance big_op_permutation : Proper ((≡ₚ) ==> (≡)) big_op. ...@@ -22,21 +22,21 @@ Global Instance big_op_permutation : Proper ((≡ₚ) ==> (≡)) big_op.
Proof. Proof.
induction 1 as [|x xs1 xs2 ? IH|x y xs|xs1 xs2 xs3]; simpl; auto. induction 1 as [|x xs1 xs2 ? IH|x y xs|xs1 xs2 xs3]; simpl; auto.
* by rewrite IH. * by rewrite IH.
* by rewrite !(associative _) (commutative _ x). * by rewrite !assoc (comm _ x).
* by transitivity (big_op xs2). * by transitivity (big_op xs2).
Qed. Qed.
Global Instance big_op_proper : Proper (() ==> ()) big_op. Global Instance big_op_proper : Proper (() ==> ()) big_op.
Proof. by induction 1; simpl; repeat apply (_ : Proper (_ ==> _ ==> _) op). Qed. Proof. by induction 1; simpl; repeat apply (_ : Proper (_ ==> _ ==> _) op). Qed.
Lemma big_op_app xs ys : big_op (xs ++ ys) big_op xs big_op ys. Lemma big_op_app xs ys : big_op (xs ++ ys) big_op xs big_op ys.
Proof. Proof.
induction xs as [|x xs IH]; simpl; first by rewrite ?(left_id _ _). induction xs as [|x xs IH]; simpl; first by rewrite ?left_id.
by rewrite IH (associative _). by rewrite IH assoc.
Qed. Qed.
Lemma big_op_contains xs ys : xs `contains` ys big_op xs big_op ys. Lemma big_op_contains xs ys : xs `contains` ys big_op xs big_op ys.
Proof. Proof.
induction 1 as [|x xs ys|x y xs|x xs ys|xs ys zs]; rewrite //=. induction 1 as [|x xs ys|x y xs|x xs ys|xs ys zs]; rewrite //=.
* by apply cmra_preserving_l. * by apply cmra_preserving_l.
* by rewrite !associative (commutative _ y). * by rewrite !assoc (comm _ y).
* by transitivity (big_op ys); last apply cmra_included_r. * by transitivity (big_op ys); last apply cmra_included_r.
* by transitivity (big_op ys). * by transitivity (big_op ys).
Qed. Qed.
...@@ -58,7 +58,7 @@ Qed. ...@@ -58,7 +58,7 @@ Qed.
Lemma big_opM_singleton i x : big_opM ({[i x]} : M A) x. Lemma big_opM_singleton i x : big_opM ({[i x]} : M A) x.
Proof. Proof.
rewrite -insert_empty big_opM_insert /=; last auto using lookup_empty. rewrite -insert_empty big_opM_insert /=; last auto using lookup_empty.
by rewrite big_opM_empty (right_id _ _). by rewrite big_opM_empty right_id.
Qed. Qed.
Global Instance big_opM_proper : Proper (() ==> ()) (big_opM : M A _). Global Instance big_opM_proper : Proper (() ==> ()) (big_opM : M A _).
Proof. Proof.
......
...@@ -25,7 +25,7 @@ Module ra_reflection. Section ra_reflection. ...@@ -25,7 +25,7 @@ Module ra_reflection. Section ra_reflection.
eval Σ e big_op ((λ n, from_option (Σ !! n)) <$> flatten e). eval Σ e big_op ((λ n, from_option (Σ !! n)) <$> flatten e).
Proof. Proof.
by induction e as [| |e1 IH1 e2 IH2]; by induction e as [| |e1 IH1 e2 IH2];
rewrite /= ?(right_id _ _) ?fmap_app ?big_op_app ?IH1 ?IH2. rewrite /= ?right_id ?fmap_app ?big_op_app ?IH1 ?IH2.
Qed. Qed.
Lemma flatten_correct Σ e1 e2 : Lemma flatten_correct Σ e1 e2 :
flatten e1 `contains` flatten e2 eval Σ e1 eval Σ e2. flatten e1 `contains` flatten e2 eval Σ e1 eval Σ e2.
......
...@@ -337,7 +337,7 @@ Section later. ...@@ -337,7 +337,7 @@ Section later.
Canonical Structure laterC : cofeT := CofeT later_cofe_mixin. Canonical Structure laterC : cofeT := CofeT later_cofe_mixin.
Global Instance Next_contractive : Contractive (@Next A). Global Instance Next_contractive : Contractive (@Next A).
Proof. intros [|n] x y Hxy; [done|]; apply Hxy; lia. Qed. Proof. intros [|n] x y Hxy; [done|]; apply Hxy; lia. Qed.
Global Instance Later_inj n : Injective (dist n) (dist (S n)) (@Next A). Global Instance Later_inj n : Inj (dist n) (dist (S n)) (@Next A).
Proof. by intros x y. Qed. Proof. by intros x y. Qed.
End later. End later.
......
...@@ -46,14 +46,14 @@ Class DRA A `{Equiv A, Valid A, Unit A, Disjoint A, Op A, Minus A} := { ...@@ -46,14 +46,14 @@ Class DRA A `{Equiv A, Valid A, Unit A, Disjoint A, Op A, Minus A} := {
dra_unit_valid x : x unit x; dra_unit_valid x : x unit x;
dra_minus_valid x y : x y x y (y x); dra_minus_valid x y : x y x y (y x);
(* monoid *) (* monoid *)
dra_associative :> Associative () (); 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;
dra_disjoint_move_l x y z : x y z x y x y z x y z; dra_disjoint_move_l x y z : x y z x y x y z x y z;
dra_symmetric :> Symmetric (@disjoint A _); dra_symmetric :> Symmetric (@disjoint A _);
dra_commutative x y : x y x y x y y x; dra_comm x y : x y x y x y y x;
dra_unit_disjoint_l x : x unit x x; dra_unit_disjoint_l x : x unit x x;
dra_unit_l x : x unit x x x; dra_unit_l x : x unit x x x;
dra_unit_idempotent x : x unit (unit x) unit x; dra_unit_idemp x : x unit (unit x) unit x;
dra_unit_preserving x y : x y x y unit x unit y; dra_unit_preserving x y : x y x y unit x unit y;
dra_disjoint_minus x y : x y x y x y x; dra_disjoint_minus x y : x y x y x y x;
dra_op_minus x y : x y x y x y x y dra_op_minus x y : x y x y x y x y
...@@ -73,12 +73,12 @@ Qed. ...@@ -73,12 +73,12 @@ Qed.
Lemma dra_disjoint_rl x y z : x y z y z x y z x y. Lemma dra_disjoint_rl x y z : x y z y z x y z x y.
Proof. intros ???. rewrite !(symmetry_iff _ x). by apply dra_disjoint_ll. Qed. Proof. intros ???. rewrite !(symmetry_iff _ x). by apply dra_disjoint_ll. Qed.
Lemma dra_disjoint_lr x y z : x y z x y x y z y z. Lemma dra_disjoint_lr x y z : x y z x y x y z y z.
Proof. intros ????. rewrite dra_commutative //. by apply dra_disjoint_ll. Qed. Proof. intros ????. rewrite dra_comm //. by apply dra_disjoint_ll. Qed.
Lemma dra_disjoint_move_r x y z : Lemma dra_disjoint_move_r x y z :
x y z y z x y z x y z. x y z y z x y z x y z.
Proof. Proof.
intros; symmetry; rewrite dra_commutative; eauto using dra_disjoint_rl. intros; symmetry; rewrite dra_comm; eauto using dra_disjoint_rl.
apply dra_disjoint_move_l; auto; by rewrite dra_commutative. 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. Hint Unfold dra_included.
...@@ -114,11 +114,11 @@ Proof. ...@@ -114,11 +114,11 @@ Proof.
+ exists z. by rewrite Hx ?Hy; tauto. + exists z. by rewrite Hx ?Hy; tauto.
* intros [x px ?] [y py ?] [z pz ?]; split; simpl; * intros [x px ?] [y py ?] [z pz ?]; split; simpl;
[intuition eauto 2 using dra_disjoint_lr, dra_disjoint_rl [intuition eauto 2 using dra_disjoint_lr, dra_disjoint_rl
|intros; apply (associative _)]. |by intros; rewrite assoc].
* intros [x px ?] [y py ?]; split; naive_solver eauto using dra_commutative. * intros [x px ?] [y py ?]; split; naive_solver eauto using dra_comm.
* intros [x px ?]; split; * intros [x px ?]; split;
naive_solver eauto using dra_unit_l, dra_unit_disjoint_l. naive_solver eauto using dra_unit_l, dra_unit_disjoint_l.
* intros [x px ?]; split; naive_solver eauto using dra_unit_idempotent. * intros [x px ?]; split; naive_solver eauto using dra_unit_idemp.
* intros x y Hxy; exists (unit y unit x). * intros x y Hxy; exists (unit y unit x).
destruct x as [x px ?], y as [y py ?], Hxy as [[z pz ?] [??]]; simpl in *. destruct x as [x px ?], y as [y py ?], Hxy as [[z pz ?] [??]]; simpl in *.
assert (py unit x unit y) assert (py unit x unit y)
......
...@@ -31,9 +31,9 @@ Global Instance Excl_ne : Proper (dist n ==> dist n) (@Excl A). ...@@ -31,9 +31,9 @@ Global Instance Excl_ne : Proper (dist n ==> dist n) (@Excl A).
Proof. by constructor. Qed. Proof. by constructor. Qed.
Global Instance Excl_proper : Proper (() ==> ()) (@Excl A). Global Instance Excl_proper : Proper (() ==> ()) (@Excl A).
Proof. by constructor. Qed. Proof. by constructor. Qed.
Global Instance Excl_inj : Injective () () (@Excl A). Global Instance Excl_inj : Inj () () (@Excl A).
Proof. by inversion_clear 1. Qed. Proof. by inversion_clear 1. Qed.
Global Instance Excl_dist_inj n : Injective (dist n) (dist n) (@Excl A). Global Instance Excl_dist_inj n : Inj (dist n) (dist n) (@Excl A).
Proof. by inversion_clear 1. Qed. Proof. by inversion_clear 1. Qed.
Program Definition excl_chain Program Definition excl_chain
(c : chain (excl A)) (x : A) (H : maybe Excl (c 1) = Some x) : chain A := (c : chain (excl A)) (x : A) (H : maybe Excl (c 1) = Some x) : chain A :=
......
...@@ -121,10 +121,10 @@ Proof. ...@@ -121,10 +121,10 @@ Proof.
* by intros n m1 m2 Hm ? i; rewrite -(Hm i). * by intros n m1 m2 Hm ? i; rewrite -(Hm i).
* by intros n m1 m1' Hm1 m2 m2' Hm2 i; rewrite !lookup_minus (Hm1 i) (Hm2 i). * by intros n m1 m1' Hm1 m2 m2' Hm2 i; rewrite !lookup_minus (Hm1 i) (Hm2 i).
* intros n m Hm i; apply cmra_validN_S, Hm. * intros n m Hm i; apply cmra_validN_S, Hm.
* by intros m1 m2 m3 i; rewrite !lookup_op associative. * by intros m1 m2 m3 i; rewrite !lookup_op assoc.
* by intros m1 m2 i; rewrite !lookup_op commutative.