Commit 9ac5d31a by Ralf Jung

### simplify cauchy condition on chains

parent dc1a177c
Pipeline #194 passed with stage
 ... @@ -15,7 +15,7 @@ Section agree. ... @@ -15,7 +15,7 @@ Section agree. Context {A : cofeT}. 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'. Instance agree_valid : Valid (agree A) := λ x, ∀ n, ✓{n} x. Instance agree_valid : Valid (agree A) := λ x, ∀ n, ✓{n} x. Lemma agree_valid_le n n' (x : agree A) : Lemma agree_valid_le n n' (x : agree A) : ... @@ -29,9 +29,9 @@ Instance agree_dist : Dist (agree A) := λ n x y, ... @@ -29,9 +29,9 @@ 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'). Program Instance agree_compl : Compl (agree A) := λ c, Program Instance agree_compl : Compl (agree A) := λ c, {| agree_car n := c (S n) n; agree_is_valid n := agree_is_valid (c (S n)) n |}. {| agree_car n := c n n; agree_is_valid n := agree_is_valid (c n) n |}. Next Obligation. Next Obligation. intros c n ?. apply (chain_cauchy c n (S (S n))), agree_valid_S; auto. intros c n ?. apply (chain_cauchy c n (S n)), agree_valid_S; auto. Qed. Qed. Definition agree_cofe_mixin : CofeMixin (agree A). Definition agree_cofe_mixin : CofeMixin (agree A). Proof. Proof. ... @@ -53,7 +53,7 @@ Canonical Structure agreeC := CofeT agree_cofe_mixin. ... @@ -53,7 +53,7 @@ Canonical Structure agreeC := CofeT agree_cofe_mixin. Lemma agree_car_ne n (x y : agree A) : ✓{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 n (x : agree A) i : ✓{n} x → i ≤ n → x i ≡{i}≡ x n. Lemma agree_cauchy n (x : agree A) i : ✓{n} x → i ≤ n → x n ≡{i}≡ x i. 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, ... @@ -70,8 +70,8 @@ Proof. split; naive_solver. Qed. ... @@ -70,8 +70,8 @@ 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. intros n x y Hxy [? Hx]; split; [by apply Hxy|intros n' ?]. intros n x y Hxy [? Hx]; split; [by apply Hxy|intros n' ?]. rewrite -(proj2 Hxy n') 1?(Hx n'); eauto using agree_valid_le. rewrite -(proj2 Hxy n') -1?(Hx n'); eauto using agree_valid_le. by apply dist_le with n; try apply Hxy. symmetry. by apply dist_le with n; try apply Hxy. Qed. Qed. Instance: ∀ x : agree A, Proper (dist n ==> dist n) (op x). Instance: ∀ x : agree A, Proper (dist n ==> dist n) (op x). Proof. Proof. ... @@ -110,7 +110,7 @@ Proof. ... @@ -110,7 +110,7 @@ Proof. split; try (apply _ || done). split; try (apply _ || done). - by intros n x1 x2 Hx y1 y2 Hy. - by intros n x1 x2 Hx y1 y2 Hy. - intros n x [? Hx]; split; [by apply agree_valid_S|intros n' ?]. - intros n x [? Hx]; split; [by apply agree_valid_S|intros n' ?]. rewrite (Hx n'); last auto. rewrite -(Hx n'); last auto. symmetry; apply dist_le with n; try apply Hx; auto. symmetry; apply dist_le with n; try apply Hx; auto. - intros x; apply agree_idemp. - intros x; apply agree_idemp. - by intros n x y [(?&?&?) ?]. - by intros n x y [(?&?&?) ?]. ... ...
 ... @@ -42,7 +42,7 @@ Tactic Notation "cofe_subst" := ... @@ -42,7 +42,7 @@ Tactic Notation "cofe_subst" := Record chain (A : Type) `{Dist A} := { Record chain (A : Type) `{Dist A} := { chain_car :> nat → A; chain_car :> nat → A; chain_cauchy n i : n < i → chain_car i ≡{n}≡ chain_car (S n) chain_cauchy n i : n ≤ i → chain_car i ≡{n}≡ chain_car n }. }. Arguments chain_car {_ _} _ _. Arguments chain_car {_ _} _ _. Arguments chain_cauchy {_ _} _ _ _ _. Arguments chain_cauchy {_ _} _ _ _ _. ... @@ -52,7 +52,7 @@ Record CofeMixin A `{Equiv A, Compl A} := { ... @@ -52,7 +52,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 n c : compl c ≡{n}≡ c (S n) mixin_conv_compl n c : compl c ≡{n}≡ c 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. ... @@ -84,7 +84,7 @@ Section cofe_mixin. ... @@ -84,7 +84,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 n (c : chain A) : compl c ≡{n}≡ c (S n). Lemma conv_compl n (c : chain A) : compl c ≡{n}≡ c 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. ... @@ -118,6 +118,8 @@ Section cofe. ... @@ -118,6 +118,8 @@ Section cofe. Proof. by apply dist_proper. Qed. Proof. by apply dist_proper. Qed. Lemma dist_le n n' x y : 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. Lemma dist_le' n n' x y : n' ≤ n → x ≡{n}≡ y → x ≡{n'}≡ y. Proof. intros; eauto using dist_le. 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. Proof. by intros x1 x2; rewrite !equiv_dist; intros Hx n; rewrite (Hx n). Qed. Proof. by intros x1 x2; rewrite !equiv_dist; intros Hx n; rewrite (Hx n). Qed. ... @@ -140,6 +142,11 @@ Section cofe. ... @@ -140,6 +142,11 @@ Section cofe. Global Instance contractive_proper {B : cofeT} (f : A → B) `{!Contractive f} : Global Instance contractive_proper {B : cofeT} (f : A → B) `{!Contractive f} : Proper ((≡) ==> (≡)) f | 100 := _. Proper ((≡) ==> (≡)) f | 100 := _. Lemma conv_compl' n (c : chain A) : compl c ≡{n}≡ c (S n). Proof. transitivity (c n); first by apply conv_compl. symmetry. apply chain_cauchy. omega. Qed. Lemma timeless_iff n (x : A) `{!Timeless x} y : x ≡ y ↔ x ≡{n}≡ y. Lemma timeless_iff 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|]. ... @@ -157,7 +164,8 @@ Next Obligation. by intros ? A ? B f Hf c n i ?; apply Hf, chain_cauchy. Qed. ... @@ -157,7 +164,8 @@ Next Obligation. by intros ? A ? B f Hf c n i ?; apply Hf, chain_cauchy. Qed. Program Definition fixpoint_chain {A : cofeT} `{Inhabited A} (f : A → A) Program Definition fixpoint_chain {A : cofeT} `{Inhabited A} (f : A → A) `{!Contractive f} : chain A := {| chain_car i := Nat.iter (S i) f inhabitant |}. `{!Contractive f} : chain A := {| chain_car i := Nat.iter (S i) f inhabitant |}. Next Obligation. Next Obligation. intros A ? f ? n. induction n as [|n IH]; intros [|i] ?; simpl; try omega. intros A ? f ? n. induction n as [|n IH]; intros [|i] ?; simpl; try reflexivity || omega; [|]. - apply (contractive_0 f). - apply (contractive_0 f). - apply (contractive_S f), IH; auto with omega. - apply (contractive_S f), IH; auto with omega. Qed. Qed. ... @@ -306,15 +314,15 @@ Proof. intros f f' Hf g g' Hg [??]; split; [apply Hf|apply Hg]. Qed. ... @@ -306,15 +314,15 @@ Proof. intros f f' Hf g g' Hg [??]; split; [apply Hf|apply Hg]. Qed. Section discrete_cofe. Section discrete_cofe. Context `{Equiv A, @Equivalence A (≡)}. Context `{Equiv A, @Equivalence A (≡)}. Instance discrete_dist : Dist A := λ n x y, x ≡ y. Instance discrete_dist : Dist A := λ n x y, x ≡ y. Instance discrete_compl : Compl A := λ c, c 1. Instance discrete_compl : Compl A := λ c, c 0. Definition discrete_cofe_mixin : CofeMixin A. Definition discrete_cofe_mixin : CofeMixin A. Proof. Proof. split. split. - intros x y; split; [done|intros Hn; apply (Hn 0)]. - intros x y; split; [done|intros Hn; apply (Hn 0)]. - done. - done. - done. - done. - intros n c. rewrite /compl /discrete_compl /=. - intros n c. rewrite /compl /discrete_compl /=; symmetry; apply (chain_cauchy c 0 (S n)); omega. symmetry; apply (chain_cauchy c 0 n). omega. Qed. Qed. Definition discreteC : cofeT := CofeT discrete_cofe_mixin. Definition discreteC : cofeT := CofeT discrete_cofe_mixin. Global Instance discrete_discrete_cofe : Discrete discreteC. Global Instance discrete_discrete_cofe : Discrete discreteC. ... ...
 ... @@ -61,7 +61,7 @@ Program Instance tower_compl : Compl tower := λ c, ... @@ -61,7 +61,7 @@ Program Instance tower_compl : Compl tower := λ c, Next Obligation. Next Obligation. intros c k; apply equiv_dist=> n. intros c k; apply equiv_dist=> n. by rewrite (conv_compl n (tower_chain c k)) by rewrite (conv_compl n (tower_chain c k)) (conv_compl n (tower_chain c (S k))) /= (g_tower (c (S n)) k). (conv_compl n (tower_chain c (S k))) /= (g_tower (c _) k). Qed. Qed. Definition tower_cofe_mixin : CofeMixin tower. Definition tower_cofe_mixin : CofeMixin tower. Proof. Proof. ... @@ -179,9 +179,7 @@ Program Definition unfold_chain (X : T) : chain (F T T) := ... @@ -179,9 +179,7 @@ Program Definition unfold_chain (X : T) : chain (F T T) := Next Obligation. Next Obligation. intros X n i Hi. intros X n i Hi. assert (∃ k, i = k + n) as [k ?] by (exists (i - n); lia); subst; clear Hi. assert (∃ k, i = k + n) as [k ?] by (exists (i - n); lia); subst; clear Hi. induction k as [|k IH]; simpl. induction k as [|k IH]; simpl; first done. { rewrite -f_tower f_S -map_comp. by apply (contractive_ne map); split=> Y /=; rewrite ?g_tower ?embed_f. } rewrite -IH -(dist_le _ _ _ _ (f_tower (k + n) _)); last lia. rewrite -IH -(dist_le _ _ _ _ (f_tower (k + n) _)); last lia. rewrite f_S -map_comp. rewrite f_S -map_comp. by apply (contractive_ne map); split=> Y /=; rewrite ?g_tower ?embed_f. by apply (contractive_ne map); split=> Y /=; rewrite ?g_tower ?embed_f. ... @@ -190,7 +188,7 @@ Definition unfold (X : T) : F T T := compl (unfold_chain X). ... @@ -190,7 +188,7 @@ Definition unfold (X : T) : F T T := compl (unfold_chain X). Instance unfold_ne : Proper (dist n ==> dist n) unfold. Instance unfold_ne : Proper (dist n ==> dist n) unfold. Proof. Proof. intros n X Y HXY. by rewrite /unfold (conv_compl n (unfold_chain X)) intros n X Y HXY. by rewrite /unfold (conv_compl n (unfold_chain X)) (conv_compl n (unfold_chain Y)) /= (HXY (S (S n))). (conv_compl n (unfold_chain Y)) /= (HXY (S n)). Qed. Qed. Program Definition fold (X : F T T) : T := Program Definition fold (X : F T T) : T := ... @@ -229,11 +227,10 @@ Proof. ... @@ -229,11 +227,10 @@ Proof. rewrite (map_ff_gg _ _ _ H). rewrite (map_ff_gg _ _ _ H). apply (_ : Proper (_ ==> _) (gg _)); by destruct H. apply (_ : Proper (_ ==> _) (gg _)); by destruct H. - intros X; rewrite equiv_dist=> n /=. - intros X; rewrite equiv_dist=> n /=. rewrite /unfold /= (conv_compl n (unfold_chain (fold X))) /=. rewrite /unfold /= (conv_compl' n (unfold_chain (fold X))) /=. rewrite g_S -!map_comp -{2}(map_id _ _ X). rewrite g_S -!map_comp -{2}(map_id _ _ X). apply (contractive_ne map); split => Y /=. apply (contractive_ne map); split => Y /=. + apply dist_le with n; last omega. + rewrite f_tower. apply dist_S. by rewrite embed_tower. rewrite f_tower. apply dist_S. by rewrite embed_tower. + etrans; [apply embed_ne, equiv_dist, g_tower|apply embed_tower]. + etrans; [apply embed_ne, equiv_dist, g_tower|apply embed_tower]. Qed. Qed. End solver. End solver. End solver. End solver.
 ... @@ -40,16 +40,16 @@ Global Instance Excl_dist_inj n : Inj (dist n) (dist n) (@Excl A). ... @@ -40,16 +40,16 @@ 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)) (a : A) (H : maybe Excl (c 1) = Some a) : chain A := (c : chain (excl A)) (a : A) (H : maybe Excl (c 0) = Some a) : chain A := {| chain_car n := match c n return _ with Excl y => y | _ => a end |}. {| chain_car n := match c n return _ with Excl y => y | _ => a end |}. Next Obligation. Next Obligation. intros c a ? n [|i] ?; [omega|]; simpl. intros c a ? n i ?; simpl. destruct (c 1) eqn:?; simplify_eq/=. destruct (c 0) eqn:?; simplify_eq/=. by feed inversion (chain_cauchy c n (S i)). by feed inversion (chain_cauchy c n i). Qed. Qed. Instance excl_compl : Compl (excl A) := λ c, Instance excl_compl : Compl (excl A) := λ c, match Some_dec (maybe Excl (c 1)) with match Some_dec (maybe Excl (c 0)) with | inleft (exist a H) => Excl (compl (excl_chain c a H)) | inright _ => c 1 | inleft (exist a H) => Excl (compl (excl_chain c a H)) | inright _ => c 0 end. end. Definition excl_cofe_mixin : CofeMixin (excl A). Definition excl_cofe_mixin : CofeMixin (excl A). Proof. Proof. ... @@ -63,14 +63,14 @@ Proof. ... @@ -63,14 +63,14 @@ Proof. + destruct 1; inversion_clear 1; constructor; etrans; eauto. + destruct 1; inversion_clear 1; constructor; etrans; eauto. - by inversion_clear 1; constructor; apply dist_S. - by inversion_clear 1; constructor; apply dist_S. - intros n c; unfold compl, excl_compl. - intros n c; unfold compl, excl_compl. destruct (Some_dec (maybe Excl (c 1))) as [[a Ha]|]. destruct (Some_dec (maybe Excl (c 0))) as [[a Ha]|]. { assert (c 1 = Excl a) by (by destruct (c 1); simplify_eq/=). { assert (c 0 = Excl a) by (by destruct (c 0); simplify_eq/=). assert (∃ b, c (S n) = Excl b) as [b Hb]. assert (∃ b, c n = Excl b) as [b Hb]. { feed inversion (chain_cauchy c 0 (S n)); eauto with lia congruence. } { feed inversion (chain_cauchy c 0 n); eauto with lia congruence. } rewrite Hb; constructor. rewrite Hb; constructor. by rewrite (conv_compl n (excl_chain c a Ha)) /= Hb. } by rewrite (conv_compl n (excl_chain c a Ha)) /= Hb. } feed inversion (chain_cauchy c 0 (S n)); first lia; feed inversion (chain_cauchy c 0 n); first lia; constructor; destruct (c 1); simplify_eq/=. constructor; destruct (c 0); simplify_eq/=. Qed. Qed. Canonical Structure exclC : cofeT := CofeT excl_cofe_mixin. Canonical Structure exclC : cofeT := CofeT excl_cofe_mixin. Global Instance excl_discrete : Discrete A → Discrete exclC. Global Instance excl_discrete : Discrete A → Discrete exclC. ... ...
 ... @@ -12,7 +12,7 @@ Program Definition map_chain (c : chain (gmap K A)) ... @@ -12,7 +12,7 @@ Program Definition map_chain (c : chain (gmap K A)) (k : K) : chain (option A) := {| chain_car n := c n !! k |}. (k : K) : chain (option A) := {| chain_car n := c n !! k |}. Next Obligation. by intros c k n i ?; apply (chain_cauchy c). Qed. Next Obligation. by intros c k n i ?; apply (chain_cauchy c). Qed. Instance map_compl : Compl (gmap K A) := λ c, Instance map_compl : Compl (gmap K A) := λ c, map_imap (λ i _, compl (map_chain c i)) (c 1). map_imap (λ i _, compl (map_chain c i)) (c 0). Definition map_cofe_mixin : CofeMixin (gmap K A). Definition map_cofe_mixin : CofeMixin (gmap K A). Proof. Proof. split. split. ... @@ -25,7 +25,7 @@ Proof. ... @@ -25,7 +25,7 @@ Proof. + by intros m1 m2 m3 ?? k; trans (m2 !! k). + by intros m1 m2 m3 ?? k; trans (m2 !! k). - by intros n m1 m2 ? k; apply dist_S. - by intros n m1 m2 ? k; apply dist_S. - intros n c k; rewrite /compl /map_compl lookup_imap. - intros n c k; rewrite /compl /map_compl lookup_imap. feed inversion (λ H, chain_cauchy c 0 (S n) H k); simpl; auto with lia. feed inversion (λ H, chain_cauchy c 0 n H k); simpl; auto with lia. by rewrite conv_compl /=; apply reflexive_eq. by rewrite conv_compl /=; apply reflexive_eq. Qed. Qed. Canonical Structure mapC : cofeT := CofeT map_cofe_mixin. Canonical Structure mapC : cofeT := CofeT map_cofe_mixin. ... ...
 ... @@ -39,17 +39,17 @@ Global Instance Frac_dist_inj n : Inj2 (=) (dist n) (dist n) (@Frac A). ... @@ -39,17 +39,17 @@ Global Instance Frac_dist_inj n : Inj2 (=) (dist n) (dist n) (@Frac A). Proof. by inversion_clear 1. Qed. Proof. by inversion_clear 1. Qed. Program Definition frac_chain (c : chain (frac A)) (q : Qp) (a : A) Program Definition frac_chain (c : chain (frac A)) (q : Qp) (a : A) (H : maybe2 Frac (c 1) = Some (q,a)) : chain A := (H : maybe2 Frac (c 0) = Some (q,a)) : chain A := {| chain_car n := match c n return _ with Frac _ b => b | _ => a end |}. {| chain_car n := match c n return _ with Frac _ b => b | _ => a end |}. Next Obligation. Next Obligation. intros c q a ? n [|i] ?; [omega|]; simpl. intros c q a ? n i ?; simpl. destruct (c 1) eqn:?; simplify_eq/=. destruct (c 0) eqn:?; simplify_eq/=. by feed inversion (chain_cauchy c n (S i)). by feed inversion (chain_cauchy c n i). Qed. Qed. Instance frac_compl : Compl (frac A) := λ c, Instance frac_compl : Compl (frac A) := λ c, match Some_dec (maybe2 Frac (c 1)) with match Some_dec (maybe2 Frac (c 0)) with | inleft (exist (q,a) H) => Frac q (compl (frac_chain c q a H)) | inleft (exist (q,a) H) => Frac q (compl (frac_chain c q a H)) | inright _ => c 1 | inright _ => c 0 end. end. Definition frac_cofe_mixin : CofeMixin (frac A). Definition frac_cofe_mixin : CofeMixin (frac A). Proof. Proof. ... @@ -64,15 +64,15 @@ Proof. ... @@ -64,15 +64,15 @@ Proof. + destruct 1; inversion_clear 1; constructor; etrans; eauto. + destruct 1; inversion_clear 1; constructor; etrans; eauto. - by inversion_clear 1; constructor; done || apply dist_S. - by inversion_clear 1; constructor; done || apply dist_S. - intros n c; unfold compl, frac_compl. - intros n c; unfold compl, frac_compl. destruct (Some_dec (maybe2 Frac (c 1))) as [[[q a] Hx]|]. destruct (Some_dec (maybe2 Frac (c 0))) as [[[q a] Hx]|]. { assert (c 1 = Frac q a) by (by destruct (c 1); simplify_eq/=). { assert (c 0 = Frac q a) by (by destruct (c 0); simplify_eq/=). assert (∃ b, c (S n) = Frac q b) as [y Hy]. assert (∃ b, c n = Frac q b) as [y Hy]. { feed inversion (chain_cauchy c 0 (S n)); { feed inversion (chain_cauchy c 0 n); eauto with lia congruence f_equal. } eauto with lia congruence f_equal. } rewrite Hy; constructor; auto. rewrite Hy; constructor; auto. by rewrite (conv_compl n (frac_chain c q a Hx)) /= Hy. } by rewrite (conv_compl n (frac_chain c q a Hx)) /= Hy. } feed inversion (chain_cauchy c 0 (S n)); first lia; feed inversion (chain_cauchy c 0 n); first lia; constructor; destruct (c 1); simplify_eq/=. constructor; destruct (c 0); simplify_eq/=. Qed. Qed. Canonical Structure fracC : cofeT := CofeT frac_cofe_mixin. Canonical Structure fracC : cofeT := CofeT frac_cofe_mixin. Global Instance frac_discrete : Discrete A → Discrete fracC. Global Instance frac_discrete : Discrete A → Discrete fracC. ... ...
 ... @@ -9,15 +9,15 @@ Inductive option_dist : Dist (option A) := ... @@ -9,15 +9,15 @@ Inductive option_dist : Dist (option A) := | None_dist n : None ≡{n}≡ None. | None_dist n : None ≡{n}≡ None. Existing Instance option_dist. Existing Instance option_dist. Program Definition option_chain Program Definition option_chain (c : chain (option A)) (x : A) (H : c 1 = Some x) : chain A := (c : chain (option A)) (x : A) (H : c 0 = Some x) : chain A := {| chain_car n := from_option x (c n) |}. {| chain_car n := from_option x (c n) |}. Next Obligation. Next Obligation. intros c x ? n [|i] ?; [omega|]; simpl. intros c x ? n i ?; simpl. destruct (c 1) eqn:?; simplify_eq/=. destruct (c 0) eqn:?; simplify_eq/=. by feed inversion (chain_cauchy c n (S i)). by feed inversion (chain_cauchy c n i). Qed. Qed. Instance option_compl : Compl (option A) := λ c, Instance option_compl : Compl (option A) := λ c, match Some_dec (c 1) with match Some_dec (c 0) with | inleft (exist x H) => Some (compl (option_chain c x H)) | inright _ => None | inleft (exist x H) => Some (compl (option_chain c x H)) | inright _ => None end. end. Definition option_cofe_mixin : CofeMixin (option A). Definition option_cofe_mixin : CofeMixin (option A). ... @@ -32,12 +32,12 @@ Proof. ... @@ -32,12 +32,12 @@ Proof. + destruct 1; inversion_clear 1; constructor; etrans; eauto. + destruct 1; inversion_clear 1; constructor; etrans; eauto. - by inversion_clear 1; constructor; apply dist_S. - by inversion_clear 1; constructor; apply dist_S. - intros n c; unfold compl, option_compl. - intros n c; unfold compl, option_compl. destruct (Some_dec (c 1)) as [[x Hx]|]. destruct (Some_dec (c 0)) as [[x Hx]|]. { assert (is_Some (c (S n))) as [y Hy]. { assert (is_Some (c n)) as [y Hy]. { feed inversion (chain_cauchy c 0 (S n)); eauto with lia congruence. } { feed inversion (chain_cauchy c 0 n); eauto with lia congruence. } rewrite Hy; constructor. rewrite Hy; constructor. by rewrite (conv_compl n (option_chain c x Hx)) /= Hy. } by rewrite (conv_compl n (option_chain c x Hx)) /= Hy. } feed inversion (chain_cauchy c 0 (S n)); eauto with lia congruence. feed inversion (chain_cauchy c 0 n); eauto with lia congruence. constructor. constructor. Qed. Qed. Canonical Structure optionC := CofeT option_cofe_mixin. Canonical Structure optionC := CofeT option_cofe_mixin. ... ...
 ... @@ -27,11 +27,11 @@ Section cofe. ... @@ -27,11 +27,11 @@ Section cofe. { uPred_in_dist : ∀ n' x, n' ≤ n → ✓{n'} x → P n' x ↔ Q n' x }. { uPred_in_dist : ∀ n' x, n' ≤ n → ✓{n'} x → P n' x ↔ Q n' x }. Instance uPred_dist : Dist (uPred M) := uPred_dist'. Instance uPred_dist : Dist (uPred M) := uPred_dist'. Program Instance uPred_compl : Compl (uPred M) := λ c, Program Instance uPred_compl : Compl (uPred M) := λ c, {| uPred_holds n x := c (S n) n x |}. {| uPred_holds n x := c n n x |}. Next Obligation. by intros c n x y ??; simpl in *; apply uPred_ne with x. Qed. Next Obligation. by intros c n x y ??; simpl in *; apply uPred_ne with x. Qed. Next Obligation. Next Obligation. intros c n1 n2 x1 x2 ????; simpl in *. intros c n1 n2 x1 x2 ????; simpl in *. apply (chain_cauchy c n2 (S n1)); eauto using uPred_weaken. apply (chain_cauchy c n2 n1); eauto using uPred_weaken. Qed. Qed. Definition uPred_cofe_mixin : CofeMixin (uPred M). Definition uPred_cofe_mixin : CofeMixin (uPred M). Proof. Proof. ... @@ -45,7 +45,7 @@ Section cofe. ... @@ -45,7 +45,7 @@ Section cofe. + intros P Q Q' HP HQ; split=> i x ??. + intros P Q Q' HP HQ; split=> i x ??. by trans (Q i x);[apply HP|apply HQ]. by trans (Q i x);[apply HP|apply HQ]. - intros n P Q HPQ; split=> i x ??; apply HPQ; auto. - intros n P Q HPQ; split=> i x ??; apply HPQ; auto. - intros n c; split=>i x ??; symmetry; apply (chain_cauchy c i (S n)); auto. - intros n c; split=>i x ??; symmetry; apply (chain_cauchy c i n); auto. Qed. Qed. Canonical Structure uPredC : cofeT := CofeT uPred_cofe_mixin. Canonical Structure uPredC : cofeT := CofeT uPred_cofe_mixin. End cofe. End cofe. ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!