Commit 035f0b29 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Put step-indexes first.

parent 88679d3e
...@@ -16,7 +16,7 @@ Context {A : cofeT}. ...@@ -16,7 +16,7 @@ Context {A : cofeT}.
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 n n' (x : agree A) :
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.
Instance agree_equiv : Equiv (agree A) := λ x y, Instance agree_equiv : Equiv (agree A) := λ x y,
...@@ -43,14 +43,14 @@ Proof. ...@@ -43,14 +43,14 @@ Proof.
* transitivity (agree_is_valid y n'). by apply Hxy. by apply Hyz. * transitivity (agree_is_valid y n'). by apply Hxy. by apply Hyz.
* transitivity (y n'). by apply Hxy. by apply Hyz, Hxy. * transitivity (y n'). by apply Hxy. by apply Hyz, Hxy.
- intros n x y Hxy; split; intros; apply Hxy; auto. - intros n x y Hxy; split; intros; apply Hxy; auto.
- intros c n; apply and_wlog_r; intros; - intros n c; apply and_wlog_r; intros;
symmetry; apply (chain_cauchy c); naive_solver. symmetry; apply (chain_cauchy c); naive_solver.
Qed. Qed.
Canonical Structure agreeC := CofeT agree_cofe_mixin. Canonical Structure agreeC := CofeT agree_cofe_mixin.
Lemma agree_car_ne (x y : agree A) n : {n} x x {n} y x n {n} y n. 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. Proof. by intros [??] Hxy; apply Hxy. Qed.
Lemma agree_cauchy (x : agree A) n i : {n} x i n x i {i} x n. Lemma agree_cauchy n (x : agree A) i : {n} x i n x i {i} x n.
Proof. by intros [? Hx]; apply Hx. Qed. Proof. by intros [? Hx]; apply Hx. Qed.
Program Instance agree_op : Op (agree A) := λ x y, Program Instance agree_op : Op (agree A) := λ x y,
...@@ -87,7 +87,7 @@ Proof. ...@@ -87,7 +87,7 @@ Proof.
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_idemp. 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 n (x y : agree A) : 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 assoc agree_idemp. by intros [z Hz]; rewrite Hz assoc agree_idemp.
...@@ -100,12 +100,12 @@ Proof. ...@@ -100,12 +100,12 @@ Proof.
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 x y n [(?&?&?) ?]. - by intros n x y [(?&?&?) ?].
- by intros x y n; rewrite agree_includedN. - by intros n x y; rewrite agree_includedN.
Qed. Qed.
Lemma agree_op_inv (x1 x2 : agree A) n : {n} (x1 x2) x1 {n} x2. Lemma agree_op_inv n (x1 x2 : agree A) : {n} (x1 x2) x1 {n} x2.
Proof. intros Hxy; apply Hxy. Qed. 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 n (x y : agree A) : {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_idemp. by move=> /agree_op_inv->; rewrite agree_idemp.
...@@ -161,7 +161,7 @@ Section agree_map. ...@@ -161,7 +161,7 @@ Section agree_map.
Global Instance agree_map_monotone : CMRAMonotone (agree_map f). Global Instance agree_map_monotone : CMRAMonotone (agree_map f).
Proof. Proof.
split; [|by intros n x [? Hx]; split; simpl; [|by intros n' ?; rewrite Hx]]. split; [|by intros n x [? Hx]; split; simpl; [|by intros n' ?; rewrite Hx]].
intros x y n; rewrite !agree_includedN; intros Hy; rewrite Hy. intros n x y; rewrite !agree_includedN; intros Hy; rewrite Hy.
split; last done; split; simpl; last tauto. split; last done; split; simpl; last tauto.
by intros (?&?&Hxy); repeat split; intros; by intros (?&?&Hxy); repeat split; intros;
try apply Hxy; try apply Hf; eauto using @agree_valid_le. try apply Hxy; try apply Hf; eauto using @agree_valid_le.
......
...@@ -46,8 +46,8 @@ Proof. ...@@ -46,8 +46,8 @@ Proof.
+ by intros ?? [??]; split; symmetry. + by intros ?? [??]; split; symmetry.
+ intros ??? [??] [??]; split; etransitivity; eauto. + intros ??? [??] [??]; split; etransitivity; eauto.
- by intros ? [??] [??] [??]; split; apply dist_S. - by intros ? [??] [??] [??]; split; apply dist_S.
- intros c n; split. apply (conv_compl (chain_map authoritative c) n). - intros n c; split. apply (conv_compl n (chain_map authoritative c)).
apply (conv_compl (chain_map own c) n). apply (conv_compl n (chain_map own c)).
Qed. Qed.
Canonical Structure authC := CofeT auth_cofe_mixin. Canonical Structure authC := CofeT auth_cofe_mixin.
Global Instance auth_timeless (x : auth A) : Global Instance auth_timeless (x : auth A) :
...@@ -163,7 +163,7 @@ Lemma auth_update a a' b b' : ...@@ -163,7 +163,7 @@ Lemma auth_update a a' b b' :
( n af, {n} a a {n} a' af b {n} b' af {n} b) ( n af, {n} a a {n} a' af b {n} b' af {n} b)
a a' ~~> b b'. a a' ~~> b b'.
Proof. Proof.
move=> Hab [[?| |] bf1] n // =>-[[bf2 Ha] ?]; do 2 red; simpl in *. move=> Hab n [[?| |] bf1] // =>-[[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 assoc. } { by rewrite Ha left_id assoc. }
split; [by rewrite Ha' left_id assoc; apply cmra_includedN_l|done]. split; [by rewrite Ha' left_id assoc; apply cmra_includedN_l|done].
......
...@@ -147,11 +147,11 @@ Class LocalUpdate {A : cmraT} (Lv : A → Prop) (L : A → A) := { ...@@ -147,11 +147,11 @@ Class LocalUpdate {A : cmraT} (Lv : A → Prop) (L : A → A) := {
Arguments local_updateN {_ _} _ {_} _ _ _ _ _. Arguments local_updateN {_ _} _ {_} _ _ _ _ _.
(** * Frame preserving updates *) (** * Frame preserving updates *)
Definition cmra_updateP {A : cmraT} (x : A) (P : A Prop) := z n, Definition cmra_updateP {A : cmraT} (x : A) (P : A Prop) := n z,
{n} (x z) y, P y {n} (y z). {n} (x z) y, P y {n} (y z).
Instance: Params (@cmra_updateP) 1. Instance: Params (@cmra_updateP) 1.
Infix "~~>:" := cmra_updateP (at level 70). Infix "~~>:" := cmra_updateP (at level 70).
Definition cmra_update {A : cmraT} (x y : A) := z n, Definition cmra_update {A : cmraT} (x y : A) := n z,
{n} (x z) {n} (y z). {n} (x z) {n} (y z).
Infix "~~>" := cmra_update (at level 70). Infix "~~>" := cmra_update (at level 70).
Instance: Params (@cmra_update) 1. Instance: Params (@cmra_update) 1.
...@@ -202,23 +202,23 @@ Qed. ...@@ -202,23 +202,23 @@ Qed.
Global Instance cmra_update_proper : Global Instance cmra_update_proper :
Proper (() ==> () ==> iff) (@cmra_update A). Proper (() ==> () ==> iff) (@cmra_update A).
Proof. Proof.
intros x1 x2 Hx y1 y2 Hy; split=>? z n; [rewrite -Hx -Hy|rewrite Hx Hy]; auto. intros x1 x2 Hx y1 y2 Hy; split=>? n z; [rewrite -Hx -Hy|rewrite Hx Hy]; auto.
Qed. Qed.
Global Instance cmra_updateP_proper : Global Instance cmra_updateP_proper :
Proper (() ==> pointwise_relation _ iff ==> iff) (@cmra_updateP A). Proper (() ==> pointwise_relation _ iff ==> iff) (@cmra_updateP A).
Proof. Proof.
intros x1 x2 Hx P1 P2 HP; split=>Hup z n; intros x1 x2 Hx P1 P2 HP; split=>Hup n z;
[rewrite -Hx; setoid_rewrite <-HP|rewrite Hx; setoid_rewrite HP]; auto. [rewrite -Hx; setoid_rewrite <-HP|rewrite Hx; setoid_rewrite HP]; auto.
Qed. Qed.
(** ** Validity *) (** ** Validity *)
Lemma cmra_valid_validN x : x n, {n} x. Lemma cmra_valid_validN x : x n, {n} x.
Proof. done. Qed. Proof. done. Qed.
Lemma cmra_validN_le x n n' : {n} x n' n {n'} x. Lemma cmra_validN_le n n' x : {n} x n' n {n'} x.
Proof. induction 2; eauto using cmra_validN_S. Qed. 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 n x y : {n} (x y) {n} y.
Proof. rewrite (comm _ 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.
...@@ -228,7 +228,7 @@ Lemma cmra_unit_r x : x ⋅ unit x ≡ x. ...@@ -228,7 +228,7 @@ Lemma cmra_unit_r x : x ⋅ unit x ≡ x.
Proof. by rewrite (comm _ 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_idemp 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 n x : {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.
Proof. rewrite -{1}(cmra_unit_l x); apply cmra_valid_op_l. Qed. Proof. rewrite -{1}(cmra_unit_l x); apply cmra_valid_op_l. Qed.
...@@ -237,7 +237,7 @@ Proof. rewrite -{1}(cmra_unit_l x); apply cmra_valid_op_l. Qed. ...@@ -237,7 +237,7 @@ Proof. rewrite -{1}(cmra_unit_l x); apply cmra_valid_op_l. Qed.
Lemma cmra_included_includedN x y : x y n, x {n} y. Lemma cmra_included_includedN x y : x y n, x {n} y.
Proof. Proof.
split; [by intros [z Hz] n; exists z; rewrite Hz|]. split; [by intros [z Hz] n; exists z; rewrite Hz|].
intros Hxy; exists (y x); apply equiv_dist; intros n. intros Hxy; exists (y x); apply equiv_dist=> n.
symmetry; apply cmra_op_minus, Hxy. symmetry; apply cmra_op_minus, Hxy.
Qed. Qed.
Global Instance cmra_includedN_preorder n : PreOrder (@includedN A _ _ n). Global Instance cmra_includedN_preorder n : PreOrder (@includedN A _ _ n).
...@@ -252,14 +252,14 @@ Proof. ...@@ -252,14 +252,14 @@ Proof.
split; red; intros until 0; rewrite !cmra_included_includedN; first done. split; red; intros until 0; rewrite !cmra_included_includedN; first done.
intros; etransitivity; eauto. intros; etransitivity; eauto.
Qed. Qed.
Lemma cmra_validN_includedN x y n : {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 x y n : {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. rewrite cmra_included_includedN; eauto using cmra_validN_includedN. Qed.
Lemma cmra_includedN_S x y n : 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.
Lemma cmra_includedN_le x y n n' : x {n} y n' n x {n'} y. Lemma cmra_includedN_le n n' x y : x {n} y n' n x {n'} y.
Proof. induction 2; auto using cmra_includedN_S. Qed. Proof. induction 2; auto using cmra_includedN_S. Qed.
Lemma cmra_includedN_l n x y : x {n} x y. Lemma cmra_includedN_l n x y : x {n} x y.
...@@ -284,7 +284,7 @@ Proof. by intros; rewrite -!(comm _ z); apply cmra_preservingN_l. Qed. ...@@ -284,7 +284,7 @@ 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 -!(comm _ 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 n x1 x2 x1' :
x1 x2 x1' {n} x1 x2', x1' x2' x2' {n} x2. x1 x2 x1' {n} x1 x2', x1' x2' x2' {n} x2.
Proof. Proof.
intros [z Hx2] Hx1; exists (x1' z); split; auto using cmra_included_l. intros [z Hx2] Hx1; exists (x1' z); split; auto using cmra_included_l.
...@@ -318,7 +318,7 @@ Qed. ...@@ -318,7 +318,7 @@ Qed.
(** ** RAs with an empty element *) (** ** RAs with an empty element *)
Section identity. Section identity.
Context `{Empty A, !CMRAIdentity A}. Context `{Empty A, !CMRAIdentity A}.
Lemma cmra_empty_leastN n x : {n} x. Lemma cmra_empty_leastN n x : {n} x.
Proof. by exists x; rewrite left_id. Qed. Proof. by exists x; rewrite left_id. Qed.
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.
...@@ -350,14 +350,14 @@ Lemma cmra_update_updateP x y : x ~~> y ↔ x ~~>: (y =). ...@@ -350,14 +350,14 @@ Lemma cmra_update_updateP x y : x ~~> y ↔ x ~~>: (y =).
Proof. Proof.
split. split.
- by intros Hx z ?; exists y; split; [done|apply (Hx z)]. - by intros Hx z ?; exists y; split; [done|apply (Hx z)].
- by intros Hx z n ?; destruct (Hx z n) as (?&<-&?). - by intros Hx n z ?; destruct (Hx n z) as (?&<-&?).
Qed. Qed.
Lemma cmra_updateP_id (P : A Prop) x : P x x ~~>: P. Lemma cmra_updateP_id (P : A Prop) x : P x x ~~>: P.
Proof. by intros ? z n ?; exists x. Qed. Proof. by intros ? n z ?; exists x. Qed.
Lemma cmra_updateP_compose (P Q : A Prop) x : Lemma cmra_updateP_compose (P Q : A Prop) x :
x ~~>: P ( y, P y y ~~>: Q) x ~~>: Q. x ~~>: P ( y, P y y ~~>: Q) x ~~>: Q.
Proof. Proof.
intros Hx Hy z n ?. destruct (Hx z n) as (y&?&?); auto. by apply (Hy y). intros Hx Hy n z ?. destruct (Hx n z) as (y&?&?); auto. by apply (Hy y).
Qed. Qed.
Lemma cmra_updateP_compose_l (Q : A Prop) x y : x ~~> y y ~~>: Q x ~~>: Q. Lemma cmra_updateP_compose_l (Q : A Prop) x y : x ~~> y y ~~>: Q x ~~>: Q.
Proof. Proof.
...@@ -370,9 +370,9 @@ Proof. eauto using cmra_updateP_compose, cmra_updateP_id. Qed. ...@@ -370,9 +370,9 @@ Proof. eauto using cmra_updateP_compose, cmra_updateP_id. Qed.
Lemma cmra_updateP_op (P1 P2 Q : A Prop) x1 x2 : 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 n z ?.
destruct (Hx1 (x2 z) n) as (y1&?&?); first by rewrite assoc. destruct (Hx1 n (x2 z)) as (y1&?&?); first by rewrite assoc.
destruct (Hx2 (y1 z) n) as (y2&?&?); destruct (Hx2 n (y1 z)) as (y2&?&?);
first by rewrite assoc (comm _ x2) -assoc. first by rewrite assoc (comm _ x2) -assoc.
exists (y1 y2); split; last rewrite (comm _ y1) -assoc; auto. exists (y1 y2); split; last rewrite (comm _ y1) -assoc; auto.
Qed. Qed.
...@@ -389,7 +389,7 @@ Proof. intro. auto. Qed. ...@@ -389,7 +389,7 @@ Proof. intro. auto. Qed.
Section identity_updates. Section identity_updates.
Context `{Empty A, !CMRAIdentity A}. Context `{Empty A, !CMRAIdentity A}.
Lemma cmra_update_empty x : x ~~> . Lemma cmra_update_empty x : x ~~> .
Proof. intros z n; rewrite left_id; apply cmra_validN_op_r. Qed. Proof. intros n z; rewrite left_id; apply cmra_validN_op_r. Qed.
Lemma cmra_update_empty_alt y : ~~> y x, x ~~> y. Lemma cmra_update_empty_alt y : ~~> y x, x ~~> y.
Proof. split; [intros; transitivity |]; auto using cmra_update_empty. Qed. Proof. split; [intros; transitivity |]; auto using cmra_update_empty. Qed.
End identity_updates. End identity_updates.
...@@ -472,7 +472,7 @@ Section discrete. ...@@ -472,7 +472,7 @@ Section discrete.
Definition discrete_cmra_mixin : CMRAMixin A. Definition discrete_cmra_mixin : CMRAMixin A.
Proof. Proof.
by destruct ra; split; unfold Proper, respectful, includedN; by destruct ra; split; unfold Proper, respectful, includedN;
try setoid_rewrite <-(timeless_iff _ _ _ _). try setoid_rewrite <-(timeless_iff _ _).
Qed. Qed.
Definition discrete_extend_mixin : CMRAExtendMixin A. Definition discrete_extend_mixin : CMRAExtendMixin A.
Proof. Proof.
...@@ -483,10 +483,10 @@ Section discrete. ...@@ -483,10 +483,10 @@ Section discrete.
CMRAT (cofe_mixin A) discrete_cmra_mixin discrete_extend_mixin. CMRAT (cofe_mixin A) discrete_cmra_mixin discrete_extend_mixin.
Lemma discrete_updateP (x : discreteRA) (P : A Prop) : Lemma discrete_updateP (x : discreteRA) (P : A Prop) :
( z, (x z) y, P y (y z)) x ~~>: P. ( z, (x z) y, P y (y z)) x ~~>: P.
Proof. intros Hvalid z n; apply Hvalid. Qed. Proof. intros Hvalid n z; apply Hvalid. Qed.
Lemma discrete_update (x y : discreteRA) : Lemma discrete_update (x y : discreteRA) :
( z, (x z) (y z)) x ~~> y. ( z, (x z) (y z)) x ~~> y.
Proof. intros Hvalid z n; apply Hvalid. Qed. Proof. intros Hvalid n z; apply Hvalid. Qed.
Lemma discrete_valid (x : discreteRA) : v x validN_valid x. Lemma discrete_valid (x : discreteRA) : v x validN_valid x.
Proof. move=>Hx n. exact Hx. Qed. Proof. move=>Hx n. exact Hx. Qed.
End discrete. End discrete.
...@@ -540,7 +540,7 @@ Section prod. ...@@ -540,7 +540,7 @@ Section prod.
- 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.
- intros x y n; rewrite prod_includedN; intros [??]. - intros n x y; rewrite prod_includedN; intros [??].
by split; apply cmra_op_minus. by split; apply cmra_op_minus.
Qed. Qed.
Definition prod_cmra_extend_mixin : CMRAExtendMixin (A * B). Definition prod_cmra_extend_mixin : CMRAExtendMixin (A * B).
...@@ -561,12 +561,12 @@ Section prod. ...@@ -561,12 +561,12 @@ Section prod.
- by intros ? [??]; split; apply (timeless _). - by intros ? [??]; split; apply (timeless _).
Qed. Qed.
Lemma prod_update x y : x.1 ~~> y.1 x.2 ~~> y.2 x ~~> y. Lemma prod_update x y : x.1 ~~> y.1 x.2 ~~> y.2 x ~~> y.
Proof. intros ?? z n [??]; split; simpl in *; auto. Qed. Proof. intros ?? n z [??]; split; simpl in *; auto. Qed.
Lemma prod_updateP P1 P2 (Q : A * B Prop) x : Lemma prod_updateP P1 P2 (Q : A * B Prop) x :
x.1 ~~>: P1 x.2 ~~>: P2 ( a b, P1 a P2 b Q (a,b)) x ~~>: Q. x.1 ~~>: P1 x.2 ~~>: P2 ( a b, P1 a P2 b Q (a,b)) x ~~>: Q.
Proof. Proof.
intros Hx1 Hx2 HP z n [??]; simpl in *. intros Hx1 Hx2 HP n z [??]; simpl in *.
destruct (Hx1 (z.1) n) as (a&?&?), (Hx2 (z.2) n) as (b&?&?); auto. destruct (Hx1 n (z.1)) as (a&?&?), (Hx2 n (z.2)) as (b&?&?); auto.
exists (a,b); repeat split; auto. exists (a,b); repeat split; auto.
Qed. Qed.
Lemma prod_updateP' P1 P2 x : Lemma prod_updateP' P1 P2 x :
......
...@@ -54,7 +54,7 @@ Record CofeMixin A `{Equiv A, Compl A} := { ...@@ -54,7 +54,7 @@ Record CofeMixin A `{Equiv A, Compl A} := {
mixin_equiv_dist x y : x y n, x {n} y; mixin_equiv_dist x y : x y n, x {n} y;
mixin_dist_equivalence n : Equivalence (dist n); mixin_dist_equivalence n : Equivalence (dist n);
mixin_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;
mixin_conv_compl (c : chain A) n : compl c {n} c (S n) mixin_conv_compl n c : compl c {n} c (S n)
}. }.
Class Contractive `{Dist A, Dist B} (f : A -> B) := Class Contractive `{Dist A, Dist B} (f : A -> B) :=
contractive n x y : ( i, i < n x {i} y) f x {n} f y. contractive n x y : ( i, i < n x {i} y) f x {n} f y.
...@@ -86,7 +86,7 @@ Section cofe_mixin. ...@@ -86,7 +86,7 @@ Section cofe_mixin.
Proof. apply (mixin_dist_equivalence _ (cofe_mixin A)). Qed. Proof. apply (mixin_dist_equivalence _ (cofe_mixin A)). Qed.
Lemma dist_S n x y : x {S n} y x {n} y. Lemma dist_S n x y : x {S n} y x {n} y.
Proof. apply (mixin_dist_S _ (cofe_mixin A)). Qed. Proof. apply (mixin_dist_S _ (cofe_mixin A)). Qed.
Lemma conv_compl (c : chain A) n : compl c {n} c (S n). Lemma conv_compl n (c : chain A) : compl c {n} c (S n).
Proof. apply (mixin_conv_compl _ (cofe_mixin A)). Qed. Proof. apply (mixin_conv_compl _ (cofe_mixin A)). Qed.
End cofe_mixin. End cofe_mixin.
...@@ -113,7 +113,7 @@ Section cofe. ...@@ -113,7 +113,7 @@ Section cofe.
Qed. Qed.
Global Instance dist_proper_2 n x : Proper (() ==> iff) (dist n x). Global Instance dist_proper_2 n x : Proper (() ==> iff) (dist n x).
Proof. by apply dist_proper. Qed. Proof. by apply dist_proper. Qed.
Lemma dist_le (x y : A) n n' : x {n} y n' n x {n'} y. Lemma dist_le n n' x y : x {n} y n' n x {n'} y.
Proof. induction 2; eauto using dist_S. Qed. Proof. induction 2; eauto using dist_S. Qed.
Instance ne_proper {B : cofeT} (f : A B) Instance ne_proper {B : cofeT} (f : A B)
`{! n, Proper (dist n ==> dist n) f} : Proper (() ==> ()) f | 100. `{! n, Proper (dist n ==> dist n) f} : Proper (() ==> ()) f | 100.
...@@ -147,7 +147,7 @@ Next Obligation. by intros ? A ? B f Hf c n i ?; apply Hf, chain_cauchy. Qed. ...@@ -147,7 +147,7 @@ Next Obligation. by intros ? A ? B f Hf c n i ?; apply Hf, chain_cauchy. Qed.
(** Timeless elements *) (** Timeless elements *)
Class Timeless {A : cofeT} (x : A) := timeless y : x {0} y x y. Class Timeless {A : cofeT} (x : A) := timeless y : x {0} y x y.
Arguments timeless {_} _ {_} _ _. Arguments timeless {_} _ {_} _ _.
Lemma timeless_iff {A : cofeT} (x y : A) n : Timeless x x y x {n} y. Lemma timeless_iff {A : cofeT} n (x : A) `{!Timeless x} y : x y x {n} y.
Proof. Proof.
split; intros; [by apply equiv_dist|]. split; intros; [by apply equiv_dist|].
apply (timeless _), dist_le with n; auto with lia. apply (timeless _), dist_le with n; auto with lia.
...@@ -168,14 +168,14 @@ Section fixpoint. ...@@ -168,14 +168,14 @@ Section fixpoint.
Context {A : cofeT} `{Inhabited A} (f : A A) `{!Contractive f}. Context {A : cofeT} `{Inhabited A} (f : A A) `{!Contractive f}.
Lemma fixpoint_unfold : fixpoint f f (fixpoint f). Lemma fixpoint_unfold : fixpoint f f (fixpoint f).
Proof. Proof.
apply equiv_dist=>n; rewrite /fixpoint (conv_compl (fixpoint_chain f) n) //. apply equiv_dist=>n; rewrite /fixpoint (conv_compl n (fixpoint_chain f)) //.
induction n as [|n IH]; simpl; eauto using contractive_0, contractive_S. induction n as [|n IH]; simpl; eauto using contractive_0, contractive_S.
Qed. Qed.
Lemma fixpoint_ne (g : A A) `{!Contractive g} n : Lemma fixpoint_ne (g : A A) `{!Contractive g} n :
( z, f z {n} g z) fixpoint f {n} fixpoint g. ( z, f z {n} g z) fixpoint f {n} fixpoint g.
Proof. Proof.
intros Hfg. rewrite /fixpoint intros Hfg. rewrite /fixpoint
(conv_compl (fixpoint_chain f) n) (conv_compl (fixpoint_chain g) n) /=. (conv_compl n (fixpoint_chain f)) (conv_compl n (fixpoint_chain g)) /=.
induction n as [|n IH]; simpl in *; [by rewrite !Hfg|]. induction n as [|n IH]; simpl in *; [by rewrite !Hfg|].
rewrite Hfg; apply contractive_S, IH; auto using dist_S. rewrite Hfg; apply contractive_S, IH; auto using dist_S.
Qed. Qed.
...@@ -206,21 +206,21 @@ Section cofe_mor. ...@@ -206,21 +206,21 @@ Section cofe_mor.
Program Instance cofe_mor_compl : Compl (cofeMor A B) := λ c, Program Instance cofe_mor_compl : Compl (cofeMor A B) := λ c,
{| cofe_mor_car x := compl (fun_chain c x) |}. {| cofe_mor_car x := compl (fun_chain c x) |}.
Next Obligation. Next Obligation.
intros c n x y Hx. by rewrite (conv_compl (fun_chain c x) n) intros c n x y Hx. by rewrite (conv_compl n (fun_chain c x))
(conv_compl (fun_chain c y) n) /= Hx. (conv_compl n (fun_chain c y)) /= Hx.
Qed. Qed.
Definition cofe_mor_cofe_mixin : CofeMixin (cofeMor A B). Definition cofe_mor_cofe_mixin : CofeMixin (cofeMor A B).
Proof. Proof.
split. split.
- intros f g; split; [intros Hfg n k; apply equiv_dist, Hfg|]. - intros f g; split; [intros Hfg n k; apply equiv_dist, Hfg|].
intros Hfg k; apply equiv_dist; intros n; apply Hfg. intros Hfg k; apply equiv_dist=> n; apply Hfg.