Commit 36c6dc3a by Robbert Krebbers

### Better use of canonical structures.

parent a198e45b
 ... @@ -12,27 +12,27 @@ Arguments agree_car {_} _ _. ... @@ -12,27 +12,27 @@ Arguments agree_car {_} _ _. Arguments agree_is_valid {_} _ _. Arguments agree_is_valid {_} _ _. Section agree. Section agree. Context `{Cofe A}. Context {A : cofeT}. Global Instance agree_validN : ValidN (agree A) := λ n x, Instance agree_validN : ValidN (agree A) := λ n x, agree_is_valid x n ∧ ∀ n', n' ≤ n → x n' ={n'}= x n. agree_is_valid x n ∧ ∀ n', n' ≤ n → x n' ={n'}= x n. Lemma agree_valid_le (x : agree A) n n' : Lemma agree_valid_le (x : agree A) n n' : agree_is_valid x n → n' ≤ n → agree_is_valid x n'. agree_is_valid x n → n' ≤ n → agree_is_valid x n'. Proof. induction 2; eauto using agree_valid_S. Qed. Proof. induction 2; eauto using agree_valid_S. Qed. Global Instance agree_valid : Valid (agree A) := λ x, ∀ n, ✓{n} x. Instance agree_valid : Valid (agree A) := λ x, ∀ n, ✓{n} x. Global Instance agree_equiv : Equiv (agree A) := λ x y, Instance agree_equiv : Equiv (agree A) := λ x y, (∀ n, agree_is_valid x n ↔ agree_is_valid y n) ∧ (∀ n, agree_is_valid x n ↔ agree_is_valid y n) ∧ (∀ n, agree_is_valid x n → x n ={n}= y n). (∀ n, agree_is_valid x n → x n ={n}= y n). Global Instance agree_dist : Dist (agree A) := λ n x y, Instance agree_dist : Dist (agree A) := λ n x y, (∀ n', n' ≤ n → agree_is_valid x n' ↔ agree_is_valid y n') ∧ (∀ n', n' ≤ n → agree_is_valid x n' ↔ agree_is_valid y n') ∧ (∀ n', n' ≤ n → agree_is_valid x n' → x n' ={n'}= y n'). (∀ n', n' ≤ n → agree_is_valid x n' → x n' ={n'}= y n'). Global Program Instance agree_compl : Compl (agree A) := λ c, Program Instance agree_compl : Compl (agree A) := λ c, {| agree_car n := c n n; agree_is_valid n := agree_is_valid (c n) n |}. {| agree_car n := c n n; agree_is_valid n := agree_is_valid (c n) n |}. Next Obligation. intros; apply agree_valid_0. Qed. Next Obligation. intros; apply agree_valid_0. Qed. Next Obligation. Next Obligation. intros c n ?; apply (chain_cauchy c n (S n)), agree_valid_S; auto. intros c n ?; apply (chain_cauchy c n (S n)), agree_valid_S; auto. Qed. Qed. Instance agree_cofe : Cofe (agree A). Definition agree_cofe_mixin : CofeMixin (agree A). Proof. Proof. split. split. * intros x y; split. * intros x y; split. ... @@ -49,14 +49,15 @@ Proof. ... @@ -49,14 +49,15 @@ Proof. by split; intros; apply agree_valid_0. by split; intros; apply agree_valid_0. * by intros c n; split; intros; apply (chain_cauchy c). * by intros c n; split; intros; apply (chain_cauchy c). Qed. Qed. Canonical Structure agreeC := CofeT agree_cofe_mixin. Global Program Instance agree_op : Op (agree A) := λ x y, Program Instance agree_op : Op (agree A) := λ x y, {| agree_car := x; {| agree_car := x; 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. by intros; simpl; split_ands; try apply agree_valid_0. Qed. Next Obligation. by intros; simpl; split_ands; try apply agree_valid_0. Qed. Next Obligation. naive_solver eauto using agree_valid_S, dist_S. Qed. Next Obligation. naive_solver eauto using agree_valid_S, dist_S. Qed. Global Instance agree_unit : Unit (agree A) := id. Instance agree_unit : Unit (agree A) := id. Global Instance agree_minus : Minus (agree A) := λ x y, x. Instance agree_minus : Minus (agree A) := λ x y, x. Instance: Commutative (≡) (@op (agree A) _). Instance: Commutative (≡) (@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_idempotent (x : agree A) : x ⋅ x ≡ x. ... @@ -70,7 +71,7 @@ Proof. ... @@ -70,7 +71,7 @@ Proof. * etransitivity; [apply Hxy|symmetry; apply Hy, Hy']; * etransitivity; [apply Hxy|symmetry; apply Hy, Hy']; eauto using agree_valid_le. eauto using agree_valid_le. Qed. Qed. Instance: Proper (dist n ==> dist n ==> dist n) op. 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 !(commutative _ _ y2) Hx. Qed. Instance: Proper ((≡) ==> (≡) ==> (≡)) op := ne_proper_2 _. Instance: Proper ((≡) ==> (≡) ==> (≡)) op := ne_proper_2 _. Instance: Associative (≡) (@op (agree A) _). Instance: Associative (≡) (@op (agree A) _). ... @@ -84,7 +85,7 @@ Proof. ... @@ -84,7 +85,7 @@ 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 (associative _) agree_idempotent. Qed. Qed. Global Instance agree_cmra : CMRA (agree A). Definition agree_cmra_mixin : CMRAMixin (agree A). Proof. Proof. split; try (apply _ || done). split; try (apply _ || done). * intros n x y Hxy [? Hx]; split; [by apply Hxy|intros n' ?]. * intros n x y Hxy [? Hx]; split; [by apply Hxy|intros n' ?]. ... @@ -103,12 +104,15 @@ Qed. ... @@ -103,12 +104,15 @@ Qed. Lemma agree_op_inv (x y1 y2 : agree A) n : Lemma agree_op_inv (x y1 y2 : agree A) n : ✓{n} x → x ={n}= y1 ⋅ y2 → y1 ={n}= y2. ✓{n} x → x ={n}= y1 ⋅ y2 → y1 ={n}= y2. Proof. by intros [??] Hxy; apply Hxy. Qed. Proof. by intros [??] Hxy; apply Hxy. Qed. Global Instance agree_extend : CMRAExtend (agree A). Definition agree_cmra_extend_mixin : CMRAExtendMixin (agree A). Proof. Proof. intros n x y1 y2 ? Hx; exists (x,x); simpl; split. intros n x y1 y2 ? Hx; exists (x,x); simpl; split. * by rewrite agree_idempotent. * by rewrite agree_idempotent. * by rewrite Hx (agree_op_inv x y1 y2) // agree_idempotent. * by rewrite Hx (agree_op_inv x y1 y2) // agree_idempotent. Qed. Qed. Canonical Structure agreeRA : cmraT := CMRAT agree_cofe_mixin agree_cmra_mixin agree_cmra_extend_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 |}. Solve Obligations with done. Solve Obligations with done. ... @@ -125,12 +129,20 @@ Proof. ... @@ -125,12 +129,20 @@ Proof. Qed. Qed. End agree. End agree. Arguments agreeC : clear implicits. Arguments agreeRA : 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 |}. Solve Obligations with auto using agree_valid_0, agree_valid_S. Solve Obligations with auto using agree_valid_0, agree_valid_S. Lemma agree_map_id {A} (x : agree A) : agree_map id x = x. Proof. by destruct x. Qed. Lemma agree_map_compose {A B C} (f : A → B) (g : B → C) (x : agree A) : agree_map (g ∘ f) x = agree_map g (agree_map f x). Proof. done. Qed. Section agree_map. Section agree_map. Context `{Cofe A, Cofe B} (f : A → B) `{Hf: ∀ n, Proper (dist n ==> dist n) f}. Context {A B : cofeT} (f : A → B) `{Hf: ∀ n, Proper (dist n ==> dist n) f}. Global Instance agree_map_ne n : Proper (dist n ==> dist n) (agree_map f). Global Instance agree_map_ne n : Proper (dist n ==> dist n) (agree_map f). Proof. by intros x1 x2 Hx; split; simpl; intros; [apply Hx|apply Hf, Hx]. Qed. Proof. by intros x1 x2 Hx; split; simpl; intros; [apply Hx|apply Hf, Hx]. Qed. Global Instance agree_map_proper : Global Instance agree_map_proper : ... @@ -147,13 +159,7 @@ Section agree_map. ... @@ -147,13 +159,7 @@ Section agree_map. try apply Hxy; try apply Hf; eauto using @agree_valid_le. try apply Hxy; try apply Hf; eauto using @agree_valid_le. Qed. Qed. End agree_map. End agree_map. Lemma agree_map_id {A} (x : agree A) : agree_map id x = x. Proof. by destruct x. Qed. Lemma agree_map_compose {A B C} (f : A → B) (g : B → C) (x : agree A) : agree_map (g ∘ f) x = agree_map g (agree_map f x). Proof. done. Qed. Canonical Structure agreeRA (A : cofeT) : cmraT := CMRAT (agree A). Definition agreeRA_map {A B} (f : A -n> B) : agreeRA A -n> agreeRA B := Definition agreeRA_map {A B} (f : A -n> B) : agreeRA A -n> agreeRA B := CofeMor (agree_map f : agreeRA A → agreeRA B). CofeMor (agree_map f : agreeRA A → agreeRA B). Instance agreeRA_map_ne A B n : Proper (dist n ==> dist n) (@agreeRA_map A B). Instance agreeRA_map_ne A B n : Proper (dist n ==> dist n) (@agreeRA_map A B). ... ...
 ... @@ -10,22 +10,24 @@ Notation "◯ x" := (Auth ExclUnit x) (at level 20). ... @@ -10,22 +10,24 @@ Notation "◯ x" := (Auth ExclUnit x) (at level 20). Notation "● x" := (Auth (Excl x) ∅) (at level 20). Notation "● x" := (Auth (Excl x) ∅) (at level 20). (* COFE *) (* COFE *) Instance auth_equiv `{Equiv A} : Equiv (auth A) := λ x y, Section cofe. Context {A : cofeT}. Instance auth_equiv : Equiv (auth A) := λ x y, authoritative x ≡ authoritative y ∧ own x ≡ own y. authoritative x ≡ authoritative y ∧ own x ≡ own y. Instance auth_dist `{Dist A} : Dist (auth A) := λ n x y, Instance auth_dist : Dist (auth A) := λ n x y, authoritative x ={n}= authoritative y ∧ own x ={n}= own y. authoritative x ={n}= authoritative y ∧ own x ={n}= own y. Instance Auth_ne `{Dist A} : Proper (dist n ==> dist n ==> dist n) (@Auth A). Global Instance Auth_ne : Proper (dist n ==> dist n ==> dist n) (@Auth A). Proof. by split. Qed. Proof. by split. Qed. Instance authoritative_ne `{Dist A} : Global Instance authoritative_ne: Proper (dist n ==> dist n) (@authoritative A). Proper (dist n ==> dist n) (@authoritative A). Proof. by destruct 1. Qed. Proof. by destruct 1. Qed. Instance own_ne `{Dist A} : Proper (dist n ==> dist n) (@own A). Global Instance own_ne : Proper (dist n ==> dist n) (@own A). Proof. by destruct 1. Qed. Proof. by destruct 1. Qed. Instance auth_compl `{Cofe A} : Compl (auth A) := λ c, Instance auth_compl : Compl (auth A) := λ c, Auth (compl (chain_map authoritative c)) (compl (chain_map own c)). Auth (compl (chain_map authoritative c)) (compl (chain_map own c)). Local Instance auth_cofe `{Cofe A} : Cofe (auth A). Definition auth_cofe_mixin : CofeMixin (auth A). Proof. Proof. split. split. * intros x y; unfold dist, auth_dist, equiv, auth_equiv. * intros x y; unfold dist, auth_dist, equiv, auth_equiv. ... @@ -39,53 +41,59 @@ Proof. ... @@ -39,53 +41,59 @@ Proof. * intros c n; split. apply (conv_compl (chain_map authoritative c) n). * intros c n; split. apply (conv_compl (chain_map authoritative c) n). apply (conv_compl (chain_map own c) n). apply (conv_compl (chain_map own c) n). Qed. Qed. Instance Auth_timeless `{Dist A, Equiv A} (x : excl A) (y : A) : Canonical Structure authC := CofeT auth_cofe_mixin. Instance Auth_timeless (x : excl A) (y : A) : Timeless x → Timeless y → Timeless (Auth x y). Timeless x → Timeless y → Timeless (Auth x y). Proof. by intros ?? [??] [??]; split; apply (timeless _). Qed. Proof. by intros ?? [??] [??]; split; simpl in *; apply (timeless _). Qed. End cofe. Arguments authC : clear implicits. (* CMRA *) (* CMRA *) Instance auth_empty `{Empty A} : Empty (auth A) := Auth ∅ ∅. Section cmra. Instance auth_valid `{Equiv A, Valid A, Op A} : Valid (auth A) := λ x, Context {A : cmraT}. Global Instance auth_empty `{Empty A} : Empty (auth A) := Auth ∅ ∅. Instance auth_valid : Valid (auth A) := λ x, match authoritative x with match authoritative x with | Excl a => own x ≼ a ∧ ✓ a | Excl a => own x ≼ a ∧ ✓ a | ExclUnit => ✓ (own x) | ExclUnit => ✓ (own x) | ExclBot => False | ExclBot => False end. end. Arguments auth_valid _ _ _ _ !_ /. Global Arguments auth_valid !_ /. Instance auth_validN `{Dist A, ValidN A, Op A} : ValidN (auth A) := λ n x, Instance auth_validN : ValidN (auth A) := λ n x, match authoritative x with match authoritative x with | Excl a => own x ≼{n} a ∧ ✓{n} a | Excl a => own x ≼{n} a ∧ ✓{n} a | ExclUnit => ✓{n} (own x) | ExclUnit => ✓{n} (own x) | ExclBot => n = 0 | ExclBot => n = 0 end. end. Arguments auth_validN _ _ _ _ _ !_ /. Global Arguments auth_validN _ !_ /. Instance auth_unit `{Unit A} : Unit (auth A) := λ x, Instance auth_unit : Unit (auth A) := λ x, Auth (unit (authoritative x)) (unit (own x)). Auth (unit (authoritative x)) (unit (own x)). Instance auth_op `{Op A} : 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_minus `{Minus A} : Minus (auth A) := λ x y, Instance auth_minus : Minus (auth A) := λ x y, Auth (authoritative x ⩪ authoritative y) (own x ⩪ own y). Auth (authoritative x ⩪ authoritative y) (own x ⩪ own y). Lemma auth_included `{Equiv A, Op A} (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. Proof. Proof. split; [intros [[z1 z2] Hz]; split; [exists z1|exists z2]; apply Hz|]. split; [intros [[z1 z2] Hz]; split; [exists z1|exists z2]; apply Hz|]. intros [[z1 Hz1] [z2 Hz2]]; exists (Auth z1 z2); split; auto. intros [[z1 Hz1] [z2 Hz2]]; exists (Auth z1 z2); split; auto. Qed. Qed. Lemma auth_includedN `{Dist A, Op A} n (x y : auth A) : Lemma auth_includedN n (x y : auth A) : x ≼{n} y ↔ authoritative x ≼{n} authoritative y ∧ own x ≼{n} own y. x ≼{n} y ↔ authoritative x ≼{n} authoritative y ∧ own x ≼{n} own y. Proof. Proof. split; [intros [[z1 z2] Hz]; split; [exists z1|exists z2]; apply Hz|]. split; [intros [[z1 z2] Hz]; split; [exists z1|exists z2]; apply Hz|]. intros [[z1 Hz1] [z2 Hz2]]; exists (Auth z1 z2); split; auto. intros [[z1 Hz1] [z2 Hz2]]; exists (Auth z1 z2); split; auto. Qed. Qed. Lemma authoritative_validN `{CMRA A} n (x : auth A) : Lemma authoritative_validN n (x : auth A) : ✓{n} x → ✓{n} (authoritative x). ✓{n} x → ✓{n} (authoritative x). Proof. by destruct x as [[]]. Qed. Proof. by destruct x as [[]]. Qed. Lemma own_validN `{CMRA A} n (x : auth A) : ✓{n} x → ✓{n} (own x). Lemma own_validN n (x : auth A) : ✓{n} x → ✓{n} (own x). Proof. destruct x as [[]]; naive_solver eauto using cmra_valid_includedN. Qed. Proof. destruct x as [[]]; naive_solver eauto using cmra_valid_includedN. Qed. Instance auth_cmra `{CMRA A} : CMRA (auth A). Definition auth_cmra_mixin : CMRAMixin (auth A). Proof. Proof. split. split. * apply _. * by intros n x y1 y2 [Hy Hy']; split; simpl; rewrite ?Hy ?Hy'. * by intros n x y1 y2 [Hy Hy']; split; simpl; rewrite ?Hy ?Hy'. * 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 *; ... @@ -103,14 +111,14 @@ Proof. ... @@ -103,14 +111,14 @@ Proof. * by split; simpl; rewrite ?(ra_unit_idempotent _). * by split; simpl; rewrite ?(ra_unit_idempotent _). * intros n ??; rewrite! auth_includedN; intros [??]. * intros n ??; rewrite! auth_includedN; intros [??]. by split; simpl; apply cmra_unit_preserving. by split; simpl; apply cmra_unit_preserving. * assert (∀ n a b1 b2, b1 ⋅ b2 ≼{n} a → b1 ≼{n} a). * assert (∀ n (a b1 b2 : A), b1 ⋅ b2 ≼{n} a → b1 ≼{n} a). { intros n a b1 b2 <-; apply cmra_included_l. } { intros n a b1 b2 <-; apply cmra_included_l. } intros n [[a1| |] b1] [[a2| |] b2]; intros n [[a1| |] b1] [[a2| |] b2]; naive_solver eauto using cmra_valid_op_l, cmra_valid_includedN. naive_solver eauto using cmra_valid_op_l, cmra_valid_includedN. * by intros n ??; rewrite auth_includedN; * by intros n ??; rewrite auth_includedN; intros [??]; split; simpl; apply cmra_op_minus. intros [??]; split; simpl; apply cmra_op_minus. Qed. Qed. Instance auth_cmra_extend `{CMRA A, !CMRAExtend A} : CMRAExtend (auth A). Definition auth_cmra_extend_mixin : CMRAExtendMixin (auth A). Proof. Proof. intros n x y1 y2 ? [??]; simpl in *. intros n x y1 y2 ? [??]; simpl in *. destruct (cmra_extend_op n (authoritative x) (authoritative y1) destruct (cmra_extend_op n (authoritative x) (authoritative y1) ... @@ -119,39 +127,49 @@ Proof. ... @@ -119,39 +127,49 @@ Proof. as (z2&?&?&?); auto using own_validN. as (z2&?&?&?); auto using own_validN. by exists (Auth (z1.1) (z2.1), Auth (z1.2) (z2.2)). by exists (Auth (z1.1) (z2.1), Auth (z1.2) (z2.2)). Qed. Qed. Instance auth_ra_empty `{CMRA A, Empty A, !RAIdentity A} : RAIdentity (auth A). Canonical Structure authRA : cmraT := CMRAT auth_cofe_mixin auth_cmra_mixin auth_cmra_extend_mixin. Instance auth_ra_empty `{Empty A} : RAIdentity A → RAIdentity (auth A). Proof. Proof. split; [apply (ra_empty_valid (A:=A))|]. split; simpl; [apply ra_empty_valid|]. by intros x; constructor; simpl; rewrite (left_id _ _). by intros x; constructor; simpl; rewrite (left_id _ _). Qed. Qed. Instance auth_frag_valid_timeless `{CMRA A} (x : A) : Global Instance auth_frag_valid_timeless (x : A) : ValidTimeless x → ValidTimeless (◯ x). ValidTimeless x → ValidTimeless (◯ x). Proof. by intros ??; apply (valid_timeless x). Qed. Proof. by intros ??; apply (valid_timeless x). Qed. Instance auth_valid_timeless `{CMRA A, Empty A, !RAIdentity A} (x : A) : Global Instance auth_valid_timeless `{Empty A, !RAIdentity A} (x : A) : ValidTimeless x → ValidTimeless (● x). ValidTimeless x → ValidTimeless (● x). Proof. Proof. by intros ? [??]; split; [apply ra_empty_least|apply (valid_timeless x)]. by intros ? [??]; split; [apply ra_empty_least|apply (valid_timeless x)]. Qed. Qed. Lemma auth_frag_op `{CMRA A} a b : ◯ (a ⋅ b) ≡ ◯ a ⋅ ◯ b. Lemma auth_frag_op (a b : A) : ◯ (a ⋅ b) ≡ ◯ a ⋅ ◯ b. Proof. done. Qed. Proof. done. Qed. Lemma auth_includedN' n (x y : authC A) : x ≼{n} y ↔ authoritative x ≼{n} authoritative y ∧ own x ≼{n} own y. Proof. split; [intros [[z1 z2] Hz]; split; [exists z1|exists z2]; apply Hz|]. intros [[z1 Hz1] [z2 Hz2]]; exists (Auth z1 z2); split; auto. Qed. End cmra. Arguments authRA : clear implicits. (* Functor *) (* Functor *) Definition authRA (A : cmraT) : cmraT := CMRAT (auth A). Instance auth_fmap : FMap auth := λ A B f x, Instance auth_fmap : FMap auth := λ A B f x, Auth (f <\$> authoritative x) (f (own x)). Auth (f <\$> authoritative x) (f (own x)). Instance auth_fmap_cmra_ne `{Dist A, Dist B} n : Instance auth_fmap_cmra_ne {A B : cmraT} n : Proper ((dist n ==> dist n) ==> dist n ==> dist n) (@fmap auth _ A B). Proper ((dist n ==> dist n) ==> dist n ==> dist n) (@fmap auth _ A B). Proof. Proof. intros f g Hf [??] [??] [??]; split; [by apply excl_fmap_cmra_ne|by apply Hf]. intros f g Hf [??] [??] [??]; split; [by apply excl_fmap_cmra_ne|by apply Hf]. Qed. Qed. Instance auth_fmap_cmra_monotone `{CMRA A, CMRA B} (f : A → B) : Instance auth_fmap_cmra_monotone {A B : cmraT} (f : A → B) : (∀ n, Proper (dist n ==> dist n) f) → CMRAMonotone f → (∀ n, Proper (dist n ==> dist n) f) → CMRAMonotone f → CMRAMonotone (fmap f : auth A → auth B). CMRAMonotone (fmap f : auth A → auth B). Proof. Proof. split. split. * by intros n [x a] [y b]; rewrite !auth_includedN; simpl; * by intros n [x a] [y b]; rewrite !auth_includedN /=; intros [??]; split; apply includedN_preserving. intros [??]; split; simpl; apply: includedN_preserving. * intros n [[a| |] b]; * intros n [[a| |] b]; rewrite /= /cmra_validN; naive_solver eauto using @includedN_preserving, @validN_preserving. naive_solver eauto using @includedN_preserving, @validN_preserving. Qed. Qed. Definition authRA_map {A B : cmraT} (f : A -n> B) : authRA A -n> authRA B := Definition authRA_map {A B : cmraT} (f : A -n> B) : authRA A -n> authRA B := ... ...
This diff is collapsed.
 ... @@ -29,14 +29,13 @@ Arguments chain_car {_ _} _ _. ... @@ -29,14 +29,13 @@ Arguments chain_car {_ _} _ _. Arguments chain_cauchy {_ _} _ _ _ _. Arguments chain_cauchy {_ _} _ _ _ _. Class Compl A `{Dist A} := compl : chain A → A. Class Compl A `{Dist A} := compl : chain A → A. Class Cofe A `{Equiv A, Compl A} := { Record CofeMixin A `{Equiv A, Compl A} := { equiv_dist x y : x ≡ y ↔ ∀ n, x ={n}= y; mixin_equiv_dist x y : x ≡ y ↔ ∀ n, x ={n}= y; dist_equivalence n :> Equivalence (dist n); mixin_dist_equivalence n : Equivalence (dist n); dist_S n x y : x ={S n}= y → x ={n}= y; mixin_dist_S n x y : x ={S n}= y → x ={n}= y; dist_0 x y : x ={0}= y; mixin_dist_0 x y : x ={0}= y; conv_compl (c : chain A) n : compl c ={n}= c n mixin_conv_compl (c : chain A) n : compl c ={n}= c n }. }. Hint Extern 0 (_ ={0}= _) => apply dist_0. Class Contractive `{Dist A, Dist B} (f : A -> B) := Class Contractive `{Dist A, Dist B} (f : A -> B) := contractive n : Proper (dist n ==> dist (S n)) f. contractive n : Proper (dist n ==> dist (S n)) f. ... @@ -46,20 +45,39 @@ Structure cofeT := CofeT { ... @@ -46,20 +45,39 @@ Structure cofeT := CofeT { cofe_equiv : Equiv cofe_car; cofe_equiv : Equiv cofe_car; cofe_dist : Dist cofe_car; cofe_dist : Dist cofe_car; cofe_compl : Compl cofe_car; cofe_compl : Compl cofe_car; cofe_cofe : Cofe cofe_car cofe_mixin : CofeMixin cofe_car }. }. Arguments CofeT _ {_ _ _ _}. Arguments CofeT {_ _ _ _} _. Add Printing Constructor cofeT. Add Printing Constructor cofeT. Existing Instances cofe_equiv cofe_dist cofe_compl cofe_cofe. Existing Instances cofe_equiv cofe_dist cofe_compl. Arguments cofe_car _ : simpl never. Arguments cofe_car : simpl never. Arguments cofe_equiv _ _ _ : simpl never. Arguments cofe_equiv : simpl never. Arguments cofe_dist _ _ _ _ : simpl never. Arguments cofe_dist : simpl never. Arguments cofe_compl _ _ : simpl never. Arguments cofe_compl : simpl never. Arguments cofe_cofe _ : simpl never. Arguments cofe_mixin : simpl never. (** Lifting properties from the mixin *) Section cofe_mixin. Context {A : cofeT}. Implicit Types x y : A. Lemma equiv_dist x y : x ≡ y ↔ ∀ n, x ={n}= y. Proof. apply (mixin_equiv_dist _ (cofe_mixin A)). Qed. Global Instance dist_equivalence n : Equivalence (@dist A _ n). Proof. apply (mixin_dist_equivalence _ (cofe_mixin A)). Qed. Lemma dist_S n x y : x ={S n}= y → x ={n}= y. Proof. apply (mixin_dist_S _ (cofe_mixin A)). Qed. Lemma dist_0 x y : x ={0}= y. Proof. apply (mixin_dist_0 _ (cofe_mixin A)). Qed. Lemma conv_compl (c : chain A) n : compl c ={n}= c n. Proof. apply (mixin_conv_compl _ (cofe_mixin A)). Qed. End cofe_mixin. Hint Extern 0 (_ ={0}= _) => apply dist_0. (** General properties *) (** General properties *) Section cofe. Section cofe. Context `{Cofe A}. Context {A : cofeT}. Implicit Types x y : A. Global Instance cofe_equivalence : Equivalence ((≡) : relation A). Global Instance cofe_equivalence : Equivalence ((≡) : relation A). Proof. Proof.