Commit a3d0a338 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Tweak the algebraic hierarchy.

- Make the carrier argument of the constructors for the canonical structures
  cofeT and cmraT explicit. This way we make sure the carrier is properly
  exposed, instead of some alias of the carrier.
- Make derived constructions (such as discreteC and discreteR) notations
  instead of definitions. This is yet again to make sure that the carrier is
  properly exposed.
- Turn DRA into a canonical structure (it used to be a type class).

This fixes some issues, notably it fixes some broken rewrites in algebra/sts
and it makes canonical structures work properly with dec_agree.
parent 93792f5c
......@@ -49,7 +49,7 @@ Proof.
- intros n c; apply and_wlog_r; intros;
symmetry; apply (chain_cauchy c); naive_solver.
Qed.
Canonical Structure agreeC := CofeT agree_cofe_mixin.
Canonical Structure agreeC := CofeT (agree A) agree_cofe_mixin.
Lemma agree_car_ne n (x y : agree A) : {n} x x {n} y x n {n} y n.
Proof. by intros [??] Hxy; apply Hxy. Qed.
......@@ -116,7 +116,8 @@ Proof.
+ by rewrite agree_idemp.
+ by move: Hval; rewrite Hx; move=> /agree_op_inv->; rewrite agree_idemp.
Qed.
Canonical Structure agreeR : cmraT := CMRAT agree_cofe_mixin agree_cmra_mixin.
Canonical Structure agreeR : cmraT :=
CMRAT (agree A) agree_cofe_mixin agree_cmra_mixin.
Global Instance agree_persistent (x : agree A) : Persistent x.
Proof. done. Qed.
......
......@@ -51,7 +51,7 @@ Proof.
- intros n c; split. apply (conv_compl n (chain_map authoritative c)).
apply (conv_compl n (chain_map own c)).
Qed.
Canonical Structure authC := CofeT auth_cofe_mixin.
Canonical Structure authC := CofeT (auth A) auth_cofe_mixin.
Global Instance Auth_timeless a b :
Timeless a Timeless b Timeless (Auth a b).
......@@ -128,7 +128,8 @@ Proof.
as (b&?&?&?); auto using own_validN.
by exists (Auth (ea.1) (b.1), Auth (ea.2) (b.2)).
Qed.
Canonical Structure authR : cmraT := CMRAT auth_cofe_mixin auth_cmra_mixin.
Canonical Structure authR : cmraT :=
CMRAT (auth A) auth_cofe_mixin auth_cmra_mixin.
Global Instance auth_cmra_discrete : CMRADiscrete A CMRADiscrete authR.
Proof.
split; first apply _.
......
......@@ -62,7 +62,7 @@ Structure cmraT := CMRAT {
cmra_cofe_mixin : CofeMixin cmra_car;
cmra_mixin : CMRAMixin cmra_car
}.
Arguments CMRAT {_ _ _ _ _ _ _ _} _ _.
Arguments CMRAT _ {_ _ _ _ _ _ _} _ _.
Arguments cmra_car : simpl never.
Arguments cmra_equiv : simpl never.
Arguments cmra_dist : simpl never.
......@@ -75,7 +75,7 @@ Arguments cmra_cofe_mixin : simpl never.
Arguments cmra_mixin : simpl never.
Add Printing Constructor cmraT.
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 A (cmra_cofe_mixin A).
Canonical Structure cmra_cofeC.
(** Lifting properties from the mixin *)
......@@ -474,14 +474,14 @@ End cmra_transport.
(** * Instances *)
(** ** Discrete CMRA *)
Class RA A `{Equiv A, Core A, Op A, Valid A} := {
Record RAMixin A `{Equiv A, Core A, Op A, Valid A} := {
(* setoids *)
ra_op_ne (x : A) : Proper (() ==> ()) (op x);
ra_core_ne :> Proper (() ==> ()) core;
ra_validN_ne :> Proper (() ==> impl) valid;
ra_core_ne : Proper (() ==> ()) core;
ra_validN_ne : Proper (() ==> impl) valid;
(* monoid *)
ra_assoc :> Assoc () ();
ra_comm :> Comm () ();
ra_assoc : Assoc () ();
ra_comm : Comm () ();
ra_core_l x : core x x x;
ra_core_idemp x : core (core x) core x;
ra_core_preserving x y : x y core x core y;
......@@ -489,36 +489,41 @@ Class RA A `{Equiv A, Core A, Op A, Valid A} := {
}.
Section discrete.
Context {A : cofeT} `{Discrete A}.
Context `{Core A, Op A, Valid A} (ra : RA A).
Context `{Equiv A, Core A, Op A, Valid A, @Equivalence A ()}.
Context (ra_mix : RAMixin A).
Existing Instances discrete_dist discrete_compl.
Instance discrete_validN : ValidN A := λ n x, x.
Definition discrete_cmra_mixin : CMRAMixin A.
Proof.
destruct ra; split; unfold Proper, respectful, includedN;
try setoid_rewrite <-(timeless_iff _ _); try done.
destruct ra_mix; split; try done.
- intros x; split; first done. by move=> /(_ 0).
- intros n x y1 y2 ??; exists (y1,y2); split_and?; auto.
apply (timeless _), dist_le with n; auto with lia.
- intros n x y1 y2 ??; by exists (y1,y2).
Qed.
Definition discreteR : cmraT := CMRAT (cofe_mixin A) discrete_cmra_mixin.
Global Instance discrete_cmra_discrete : CMRADiscrete discreteR.
Proof. split. change (Discrete A); apply _. by intros x ?. Qed.
End discrete.
Notation discreteR A ra_mix :=
(CMRAT A discrete_cofe_mixin (discrete_cmra_mixin ra_mix)).
Notation discreteLeibnizR A ra_mix :=
(CMRAT A (@discrete_cofe_mixin _ equivL _) (discrete_cmra_mixin ra_mix)).
Global Instance discrete_cmra_discrete `{Equiv A, Core A, Op A, Valid A,
@Equivalence A ()} (ra_mix : RAMixin A) : CMRADiscrete (discreteR A ra_mix).
Proof. split. apply _. done. Qed.
(** ** CMRA for the unit type *)
Section unit.
Instance unit_valid : Valid () := λ x, True.
Instance unit_validN : ValidN () := λ n x, True.
Instance unit_core : Core () := λ x, x.
Instance unit_op : Op () := λ x y, ().
Global Instance unit_empty : Empty () := ().
Definition unit_ra : RA ().
Proof. by split. Qed.
Canonical Structure unitR : cmraT :=
Eval cbv [unitC discreteR cofe_car] in discreteR unit_ra.
Definition unit_cmra_mixin : CMRAMixin ().
Proof. by split; last exists ((),()). Qed.
Canonical Structure unitR : cmraT := CMRAT () unit_cofe_mixin unit_cmra_mixin.
Global Instance unit_cmra_unit : CMRAUnit unitR.
Global Instance unit_cmra_discrete : CMRADiscrete unitR.
Proof. by apply discrete_cmra_discrete. Qed.
Proof. done. Qed.
Global Instance unit_persistent (x : ()) : Persistent x.
Proof. done. Qed.
End unit.
......@@ -563,7 +568,8 @@ Section prod.
destruct (cmra_extend n (x.2) (y1.2) (y2.2)) as (z2&?&?&?); auto.
by exists ((z1.1,z2.1),(z1.2,z2.2)).
Qed.
Canonical Structure prodR : cmraT := CMRAT prod_cofe_mixin prod_cmra_mixin.
Canonical Structure prodR : cmraT :=
CMRAT (A * B) prod_cofe_mixin prod_cmra_mixin.
Global Instance prod_cmra_unit `{Empty A, Empty B} :
CMRAUnit A CMRAUnit B CMRAUnit prodR.
Proof.
......
......@@ -65,7 +65,7 @@ Structure cofeT := CofeT {
cofe_compl : Compl cofe_car;
cofe_mixin : CofeMixin cofe_car
}.
Arguments CofeT {_ _ _ _} _.
Arguments CofeT _ {_ _ _} _.
Add Printing Constructor cofeT.
Existing Instances cofe_equiv cofe_dist cofe_compl.
Arguments cofe_car : simpl never.
......@@ -239,7 +239,7 @@ Section cofe_mor.
- intros n c x; simpl.
by rewrite (conv_compl n (fun_chain c x)) /=.
Qed.
Canonical Structure cofe_mor : cofeT := CofeT cofe_mor_cofe_mixin.
Canonical Structure cofe_mor : cofeT := CofeT (cofeMor A B) cofe_mor_cofe_mixin.
Global Instance cofe_mor_car_ne n :
Proper (dist n ==> dist n ==> dist n) (@cofe_mor_car A B).
......@@ -291,7 +291,7 @@ Section unit.
Instance unit_compl : Compl unit := λ _, ().
Definition unit_cofe_mixin : CofeMixin unit.
Proof. by repeat split; try exists 0. Qed.
Canonical Structure unitC : cofeT := CofeT unit_cofe_mixin.
Canonical Structure unitC : cofeT := CofeT unit unit_cofe_mixin.
Global Instance unit_discrete_cofe : Discrete unitC.
Proof. done. Qed.
End unit.
......@@ -317,7 +317,7 @@ Section product.
- intros n c; split. apply (conv_compl n (chain_map fst c)).
apply (conv_compl n (chain_map snd c)).
Qed.
Canonical Structure prodC : cofeT := CofeT prod_cofe_mixin.
Canonical Structure prodC : cofeT := CofeT (A * B) prod_cofe_mixin.
Global Instance pair_timeless (x : A) (y : B) :
Timeless x Timeless y Timeless (x,y).
Proof. by intros ?? [x' y'] [??]; split; apply (timeless _). Qed.
......@@ -436,15 +436,16 @@ Section discrete_cofe.
- intros n c. rewrite /compl /discrete_compl /=;
symmetry; apply (chain_cauchy c 0 n). omega.
Qed.
Definition discreteC : cofeT := CofeT discrete_cofe_mixin.
Global Instance discrete_discrete_cofe : Discrete discreteC.
Proof. by intros x y. Qed.
End discrete_cofe.
Arguments discreteC _ {_ _}.
Definition leibnizC (A : Type) : cofeT := @discreteC A equivL _.
Instance leibnizC_leibniz : LeibnizEquiv (leibnizC A).
Proof. by intros A x y. Qed.
Notation discreteC A := (CofeT A discrete_cofe_mixin).
Notation leibnizC A := (CofeT A (@discrete_cofe_mixin _ equivL _)).
Instance discrete_discrete_cofe `{Equiv A, @Equivalence A ()} :
Discrete (discreteC A).
Proof. by intros x y. Qed.
Instance leibnizC_leibniz A : LeibnizEquiv (leibnizC A).
Proof. by intros x y. Qed.
Canonical Structure natC := leibnizC nat.
Canonical Structure boolC := leibnizC bool.
......@@ -478,7 +479,7 @@ Section later.
- intros [|n] [x] [y] ?; [done|]; unfold dist, later_dist; by apply dist_S.
- intros [|n] c; [done|by apply (conv_compl n (later_chain c))].
Qed.
Canonical Structure laterC : cofeT := CofeT later_cofe_mixin.
Canonical Structure laterC : cofeT := CofeT (later A) later_cofe_mixin.
Global Instance Next_contractive : Contractive (@Next A).
Proof. intros [|n] x y Hxy; [done|]; apply Hxy; lia. Qed.
Global Instance Later_inj n : Inj (dist n) (dist (S n)) (@Next A).
......
......@@ -71,7 +71,7 @@ Proof.
- intros n c k; rewrite /= (conv_compl n (tower_chain c k)).
apply (chain_cauchy c); lia.
Qed.
Definition T : cofeT := CofeT tower_cofe_mixin.
Definition T : cofeT := CofeT tower tower_cofe_mixin.
Fixpoint ff {k} (i : nat) : A k -n> A (i + k) :=
match i with 0 => cid | S i => f (i + k) ff i end.
......
......@@ -28,7 +28,7 @@ Instance dec_agree_op : Op (dec_agree A) := λ x y,
end.
Instance dec_agree_core : Core (dec_agree A) := id.
Definition dec_agree_ra : RA (dec_agree A).
Definition dec_agree_ra_mixin : RAMixin (dec_agree A).
Proof.
split.
- apply _.
......@@ -42,7 +42,8 @@ Proof.
- by intros [?|] [?|] ?.
Qed.
Canonical Structure dec_agreeR : cmraT := discreteR dec_agree_ra.
Canonical Structure dec_agreeR : cmraT :=
discreteR (dec_agree A) dec_agree_ra_mixin.
(* Some properties of this CMRA *)
Global Instance dec_agree_persistent (x : dec_agreeR) : Persistent x.
......
From iris.algebra Require Export cmra.
(** From disjoint pcm *)
Record validity {A} (P : A Prop) : Type := Validity {
validity_car : A;
validity_is_valid : Prop;
validity_prf : validity_is_valid P validity_car
}.
Add Printing Constructor validity.
Arguments Validity {_ _} _ _ _.
Arguments validity_car {_ _} _.
Arguments validity_is_valid {_ _} _.
Definition to_validity {A} {P : A Prop} (x : A) : validity P :=
Validity x (P x) id.
Class DRA A `{Equiv A, Valid A, Core A, Disjoint A, Op A} := {
Record DRAMixin A `{Equiv A, Core A, Disjoint A, Op A, Valid A} := {
(* setoids *)
dra_equivalence :> Equivalence (() : relation A);
dra_op_proper :> Proper (() ==> () ==> ()) ();
dra_core_proper :> Proper (() ==> ()) core;
dra_valid_proper :> Proper (() ==> impl) valid;
dra_disjoint_proper :> x, Proper (() ==> impl) (disjoint x);
mixin_dra_equivalence : Equivalence (() : relation A);
mixin_dra_op_proper : Proper (() ==> () ==> ()) ();
mixin_dra_core_proper : Proper (() ==> ()) core;
mixin_dra_valid_proper : Proper (() ==> impl) valid;
mixin_dra_disjoint_proper x : Proper (() ==> impl) (disjoint x);
(* validity *)
dra_op_valid x y : x y x y (x y);
dra_core_valid x : x core x;
mixin_dra_op_valid x y : x y x y (x y);
mixin_dra_core_valid x : x core x;
(* monoid *)
dra_assoc :> Assoc () ();
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_symmetric :> Symmetric (@disjoint A _);
dra_comm x y : x y x y x y y x;
dra_core_disjoint_l x : x core x x;
dra_core_l x : x core x x x;
dra_core_idemp x : x core (core x) core x;
dra_core_preserving x y :
mixin_dra_assoc : Assoc () ();
mixin_dra_disjoint_ll x y z : x y z x y x y z x z;
mixin_dra_disjoint_move_l x y z :
x y z x y x y z x y z;
mixin_dra_symmetric : Symmetric (@disjoint A _);
mixin_dra_comm x y : x y x y x y y x;
mixin_dra_core_disjoint_l x : x core x x;
mixin_dra_core_l x : x core x x x;
mixin_dra_core_idemp x : x core (core x) core x;
mixin_dra_core_preserving x y :
z, x y x y core (x y) core x z z core x z
}.
Structure draT := DRAT {
dra_car :> Type;
dra_equiv : Equiv dra_car;
dra_core : Core dra_car;
dra_disjoint : Disjoint dra_car;
dra_op : Op dra_car;
dra_valid : Valid dra_car;
dra_mixin : DRAMixin dra_car
}.
Arguments DRAT _ {_ _ _ _ _} _.
Arguments dra_car : simpl never.
Arguments dra_equiv : simpl never.
Arguments dra_core : simpl never.
Arguments dra_disjoint : simpl never.
Arguments dra_op : simpl never.
Arguments dra_valid : simpl never.
Arguments dra_mixin : simpl never.
Add Printing Constructor draT.
Existing Instances dra_equiv dra_core dra_disjoint dra_op dra_valid.
(** Lifting properties from the mixin *)
Section dra_mixin.
Context {A : draT}.
Implicit Types x y : A.
Global Instance dra_equivalence : Equivalence (() : relation A).
Proof. apply (mixin_dra_equivalence _ (dra_mixin A)). Qed.
Global Instance dra_op_proper : Proper (() ==> () ==> ()) (@op A _).
Proof. apply (mixin_dra_op_proper _ (dra_mixin A)). Qed.
Global Instance dra_core_proper : Proper (() ==> ()) (@core A _).
Proof. apply (mixin_dra_core_proper _ (dra_mixin A)). Qed.
Global Instance dra_valid_proper : Proper (() ==> impl) (@valid A _).
Proof. apply (mixin_dra_valid_proper _ (dra_mixin A)). Qed.
Global Instance dra_disjoint_proper x : Proper (() ==> impl) (disjoint x).
Proof. apply (mixin_dra_disjoint_proper _ (dra_mixin A)). Qed.
Lemma dra_op_valid x y : x y x y (x y).
Proof. apply (mixin_dra_op_valid _ (dra_mixin A)). Qed.
Lemma dra_core_valid x : x core x.
Proof. apply (mixin_dra_core_valid _ (dra_mixin A)). Qed.
Global Instance dra_assoc : Assoc () (@op A _).
Proof. apply (mixin_dra_assoc _ (dra_mixin A)). Qed.
Lemma dra_disjoint_ll x y z : x y z x y x y z x z.
Proof. apply (mixin_dra_disjoint_ll _ (dra_mixin A)). Qed.
Lemma dra_disjoint_move_l x y z :
x y z x y x y z x y z.
Proof. apply (mixin_dra_disjoint_move_l _ (dra_mixin A)). Qed.
Global Instance dra_symmetric : Symmetric (@disjoint A _).
Proof. apply (mixin_dra_symmetric _ (dra_mixin A)). Qed.
Lemma dra_comm x y : x y x y x y y x.
Proof. apply (mixin_dra_comm _ (dra_mixin A)). Qed.
Lemma dra_core_disjoint_l x : x core x x.
Proof. apply (mixin_dra_core_disjoint_l _ (dra_mixin A)). Qed.
Lemma dra_core_l x : x core x x x.
Proof. apply (mixin_dra_core_l _ (dra_mixin A)). Qed.
Lemma dra_core_idemp x : x core (core x) core x.
Proof. apply (mixin_dra_core_idemp _ (dra_mixin A)). Qed.
Lemma dra_core_preserving x y :
z, x y x y core (x y) core x z z core x z.
Proof. apply (mixin_dra_core_preserving _ (dra_mixin A)). Qed.
End dra_mixin.
Record validity (A : draT) := Validity {
validity_car : A;
validity_is_valid : Prop;
validity_prf : validity_is_valid valid validity_car
}.
Add Printing Constructor validity.
Arguments Validity {_} _ _ _.
Arguments validity_car {_} _.
Arguments validity_is_valid {_} _.
Definition to_validity {A : draT} (x : A) : validity A :=
Validity x (valid x) id.
(* The actual construction *)
Section dra.
Context A `{DRA A}.
Context (A : draT).
Implicit Types a b : A.
Implicit Types x y z : validity A.
Arguments valid _ _ !_ /.
Hint Immediate dra_op_proper : typeclass_instances.
Notation T := (validity (valid : A Prop)).
Instance validity_valid : Valid T := validity_is_valid.
Instance validity_equiv : Equiv T := λ x y,
Instance validity_valid : Valid (validity A) := validity_is_valid.
Instance validity_equiv : Equiv (validity A) := λ x y,
(valid x valid y) (valid x validity_car x validity_car y).
Instance validity_equivalence : Equivalence (() : relation T).
Instance validity_equivalence : Equivalence (@equiv (validity A) _).
Proof.
split; unfold equiv, validity_equiv.
- by intros [x px ?]; simpl.
......@@ -55,40 +114,43 @@ Proof.
- intros [x px ?] [y py ?] [z pz ?] [? Hxy] [? Hyz]; simpl in *.
split; [|intros; trans y]; tauto.
Qed.
Canonical Structure validityC : cofeT := discreteC (validity A).
Instance dra_valid_proper' : Proper (() ==> iff) (valid : A Prop).
Proof. by split; apply dra_valid_proper. Qed.
Instance to_validity_proper : Proper (() ==> ()) to_validity.
Proof. by split; apply: dra_valid_proper. Qed.
Global Instance to_validity_proper : Proper (() ==> ()) to_validity.
Proof. by intros x1 x2 Hx; split; rewrite /= Hx. Qed.
Instance: Proper (() ==> () ==> iff) ().
Instance: Proper (() ==> () ==> iff) (disjoint : relation A).
Proof.
intros x1 x2 Hx y1 y2 Hy; split.
- by rewrite Hy (symmetry_iff () x1) (symmetry_iff () x2) Hx.
- by rewrite -Hy (symmetry_iff () x2) (symmetry_iff () x1) -Hx.
Qed.
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.
Lemma dra_disjoint_lr x y z : x y z x y x y z y z.
Lemma dra_disjoint_rl a b c : a b c b c a b c a b.
Proof. intros ???. rewrite !(symmetry_iff _ a). by apply dra_disjoint_ll. Qed.
Lemma dra_disjoint_lr a b c : a b c a b a b c b c.
Proof. intros ????. rewrite dra_comm //. by apply dra_disjoint_ll. Qed.
Lemma dra_disjoint_move_r x y z :
x y z y z x y z x y z.
Lemma dra_disjoint_move_r a b c :
a b c b c a b c a b c.
Proof.
intros; symmetry; rewrite dra_comm; eauto using dra_disjoint_rl.
apply dra_disjoint_move_l; auto; by rewrite dra_comm.
Qed.
Hint Immediate dra_disjoint_move_l dra_disjoint_move_r.
Lemma validity_valid_car_valid (z : T) : z validity_car z.
Lemma validity_valid_car_valid z : z validity_car z.
Proof. apply validity_prf. Qed.
Hint Resolve validity_valid_car_valid.
Program Instance validity_core : Core T := λ x,
Program Instance validity_core : Core (validity A) := λ x,
Validity (core (validity_car x)) ( x) _.
Solve Obligations with naive_solver auto using dra_core_valid.
Program Instance validity_op : Op T := λ x y,
Solve Obligations with naive_solver eauto using dra_core_valid.
Program Instance validity_op : Op (validity A) := λ x y,
Validity (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 eauto using dra_op_valid.
Definition validity_ra : RA (discreteC T).
Definition validity_ra_mixin : RAMixin (validity A).
Proof.
split.
- intros ??? [? Heq]; split; simpl; [|by intros (?&?&?); rewrite Heq].
......@@ -98,7 +160,7 @@ Proof.
- intros ?? [??]; naive_solver.
- intros [x px ?] [y py ?] [z pz ?]; split; simpl;
[intuition eauto 2 using dra_disjoint_lr, dra_disjoint_rl
|by intros; rewrite assoc].
|intros; by rewrite assoc].
- intros [x px ?] [y py ?]; split; naive_solver eauto using dra_comm.
- intros [x px ?]; split;
naive_solver eauto using dra_core_l, dra_core_disjoint_l.
......@@ -111,21 +173,20 @@ Proof.
+ intros. rewrite Hy //. tauto.
- by intros [x px ?] [y py ?] (?&?&?).
Qed.
Definition validityR : cmraT := discreteR validity_ra.
Instance validity_cmra_discrete :
CMRADiscrete validityR := discrete_cmra_discrete _.
Canonical Structure validityR : cmraT :=
discreteR (validity A) validity_ra_mixin.
Lemma validity_update (x y : validityR) :
( z, x z validity_car x z y validity_car y z) x ~~> y.
Lemma validity_update x y :
( c, x c validity_car x c y validity_car y c) x ~~> y.
Proof.
intros Hxy; apply cmra_discrete_update=> z [?[??]].
split_and!; try eapply Hxy; eauto.
Qed.
Lemma to_validity_op (x y : A) :
( (x y) x y x y)
to_validity (x y) to_validity x to_validity y.
Proof. split; naive_solver auto using dra_op_valid. Qed.
Lemma to_validity_op a b :
( (a b) a b a b)
to_validity (a b) to_validity a to_validity b.
Proof. split; naive_solver eauto using dra_op_valid. Qed.
(* TODO: This has to be proven again. *)
(*
......
......@@ -59,7 +59,7 @@ Proof.
feed inversion (chain_cauchy c 0 n); first auto with lia; constructor.
rewrite (conv_compl n (excl_chain c _)) /=. destruct (c n); naive_solver.
Qed.
Canonical Structure exclC : cofeT := CofeT excl_cofe_mixin.
Canonical Structure exclC : cofeT := CofeT (excl A) excl_cofe_mixin.
Global Instance excl_discrete : Discrete A Discrete exclC.
Proof. by inversion_clear 2; constructor; apply (timeless _). Qed.
Global Instance excl_leibniz : LeibnizEquiv A LeibnizEquiv (excl A).
......@@ -107,7 +107,8 @@ Proof.
| ExclUnit, _ => (ExclUnit, x) | _, ExclUnit => (x, ExclUnit)
end; destruct y1, y2; inversion_clear Hx; repeat constructor.
Qed.
Canonical Structure exclR : cmraT := CMRAT excl_cofe_mixin excl_cmra_mixin.
Canonical Structure exclR : cmraT :=
CMRAT (excl A) excl_cofe_mixin excl_cmra_mixin.
Global Instance excl_cmra_unit : CMRAUnit exclR.
Proof. split. done. by intros []. apply _. Qed.
Global Instance excl_cmra_discrete : Discrete A CMRADiscrete exclR.
......
......@@ -72,7 +72,7 @@ Proof.
feed inversion (chain_cauchy c 0 n); first lia;
constructor; destruct (c 0); simplify_eq/=.
Qed.
Canonical Structure fracC : cofeT := CofeT frac_cofe_mixin.
Canonical Structure fracC : cofeT := CofeT (frac A) frac_cofe_mixin.
Global Instance frac_discrete : Discrete A Discrete fracC.
Proof. by inversion_clear 2; constructor; done || apply (timeless _). Qed.
Global Instance frac_leibniz : LeibnizEquiv A LeibnizEquiv (frac A).
......@@ -157,7 +157,8 @@ Proof.
+ exists (, Frac q a); inversion_clear Hx'; by repeat constructor.
+ exfalso; inversion_clear Hx'.
Qed.
Canonical Structure fracR : cmraT := CMRAT frac_cofe_mixin frac_cmra_mixin.
Canonical Structure fracR : cmraT :=
CMRAT (frac A) frac_cofe_mixin frac_cmra_mixin.
Global Instance frac_cmra_unit : CMRAUnit fracR.
Proof. split. done. by intros []. apply _. Qed.
Global Instance frac_cmra_discrete : CMRADiscrete A CMRADiscrete fracR.
......
......@@ -28,7 +28,7 @@ Proof.
feed inversion (λ H, chain_cauchy c 0 n H k); simpl; auto with lia.
by rewrite conv_compl /=; apply reflexive_eq.
Qed.
Canonical Structure gmapC : cofeT := CofeT gmap_cofe_mixin.
Canonical Structure gmapC : cofeT := CofeT (gmap K A) gmap_cofe_mixin.
Global Instance gmap_discrete : Discrete A Discrete gmapC.
Proof. intros ? m m' ? i. by apply (timeless _). Qed.
(* why doesn't this go automatic? *)
......@@ -152,7 +152,8 @@ Proof.
pose proof (Hm12' i) as Hm12''; rewrite Hx in Hm12''.
by symmetry; apply option_op_positive_dist_r with (m1 !! i).
Qed.
Canonical Structure gmapR : cmraT := CMRAT gmap_cofe_mixin gmap_cmra_mixin.
Canonical Structure gmapR : cmraT :=
CMRAT (gmap K A) gmap_cofe_mixin gmap_cmra_mixin.
Global Instance gmap_cmra_unit : CMRAUnit gmapR.
Proof.
split.
......
......@@ -42,7 +42,7 @@ Section iprod_cofe.
rewrite /compl /iprod_compl (conv_compl n (iprod_chain c x)).
apply (chain_cauchy c); lia.
Qed.
Canonical Structure iprodC : cofeT := CofeT iprod_cofe_mixin.
Canonical Structure iprodC : cofeT := CofeT (iprod B) iprod_cofe_mixin.
(** Properties of empty *)
Section empty.
......@@ -153,7 +153,8 @@ Section iprod_cmra.
exists ((λ x, (proj1_sig (g x)).1), (λ x, (proj1_sig (g x)).2)).
split_and?; intros x; apply (proj2_sig (g x)).
Qed.
Canonical Structure iprodR : cmraT := CMRAT iprod_cofe_mixin iprod_cmra_mixin.
Canonical Structure iprodR : cmraT :=
CMRAT (iprod B) iprod_cofe_mixin iprod_cmra_mixin.
Global Instance iprod_cmra_unit `{ x, Empty (B x)} :
( x, CMRAUnit (B x)) CMRAUnit iprodR.
Proof.
......
......@@ -68,7 +68,7 @@ Proof.