Commit af80690d authored by Robbert Krebbers's avatar Robbert Krebbers

Define uPred_{equiv,dist,entails} as an inductive.

This better seals off their definition. Although it did not give
much of a speedup, I think it is conceptually nicer.
parent bcfc00b8
......@@ -132,9 +132,9 @@ Proof. intros [??]; split; naive_solver eauto using agree_valid_le. Qed.
(** Internalized properties *)
Lemma agree_equivI {M} a b : (to_agree a to_agree b)%I (a b : uPred M)%I.
Proof. split. by intros [? Hv]; apply (Hv n). apply: to_agree_ne. Qed.
Proof. do 2 split. by intros [? Hv]; apply (Hv n). apply: to_agree_ne. Qed.
Lemma agree_validI {M} x y : (x y) (x y : uPred M).
Proof. by intros r n _ ?; apply: agree_op_inv. Qed.
Proof. split=> r n _ ?; by apply: agree_op_inv. Qed.
End agree.
Arguments agreeC : clear implicits.
......
......@@ -60,8 +60,8 @@ Proof.
Qed.
Lemma dec_agree_equivI {M} a b : (DecAgree a DecAgree b)%I (a = b : uPred M)%I.
Proof. split. by case. by destruct 1. Qed.
Proof. do 2 split. by case. by destruct 1. Qed.
Lemma dec_agree_validI {M} (x y : dec_agreeRA) : (x y) (x = y : uPred M).
Proof. intros r n _ ?. by apply: dec_agree_op_inv. Qed.
Proof. split=> r n _ ?. by apply: dec_agree_op_inv. Qed.
End dec_agree.
......@@ -145,7 +145,7 @@ Lemma excl_equivI {M} (x y : excl A) :
| ExclUnit, ExclUnit | ExclBot, ExclBot => True
| _, _ => False
end : uPred M)%I.
Proof. split. by destruct 1. by destruct x, y; try constructor. Qed.
Proof. do 2 split. by destruct 1. by destruct x, y; try constructor. Qed.
Lemma excl_validI {M} (x : excl A) :
( x)%I (if x is ExclBot then False else True : uPred M)%I.
Proof. by destruct x. Qed.
......
......@@ -138,7 +138,7 @@ Lemma option_equivI {M} (x y : option A) :
(x y)%I (match x, y with
| Some a, Some b => a b | None, None => True | _, _ => False
end : uPred M)%I.
Proof. split. by destruct 1. by destruct x, y; try constructor. Qed.
Proof. do 2 split. by destruct 1. by destruct x, y; try constructor. Qed.
Lemma option_validI {M} (x : option A) :
( x)%I (match x with Some a => a | None => True end : uPred M)%I.
Proof. by destruct x. Qed.
......
......@@ -21,10 +21,13 @@ Arguments uPred_holds {_} _%I _ _.
Section cofe.
Context {M : cmraT}.
Instance uPred_equiv : Equiv (uPred M) := λ P Q, n x,
{n} x P n x Q n x.
Instance uPred_dist : Dist (uPred M) := λ n P Q, n' x,
n' n {n'} x P n' x Q n' x.
Inductive uPred_equiv' (P Q : uPred M) : Prop :=
{ uPred_in_equiv : n x, {n} x P n x Q n x }.
Instance uPred_equiv : Equiv (uPred M) := uPred_equiv'.
Inductive uPred_dist' (n : nat) (P Q : uPred M) : Prop :=
{ uPred_in_dist : n' x, n' n {n'} x P n' x Q n' x }.
Instance uPred_dist : Dist (uPred M) := uPred_dist'.
Program Instance uPred_compl : Compl (uPred M) := λ c,
{| uPred_holds n x := c (S n) n x |}.
Next Obligation. by intros c n x y ??; simpl in *; apply uPred_ne with x. Qed.
......@@ -35,14 +38,16 @@ Section cofe.
Definition uPred_cofe_mixin : CofeMixin (uPred M).
Proof.
split.
- intros P Q; split; [by intros HPQ n x i ??; apply HPQ|].
intros HPQ n x ?; apply HPQ with n; auto.
- intros P Q; split.
+ by intros HPQ n; split=> i x ??; apply HPQ.
+ intros HPQ; split=> n x ?; apply HPQ with n; auto.
- intros n; split.
+ by intros P x i.
+ by intros P Q HPQ x i ??; symmetry; apply HPQ.
+ by intros P Q Q' HP HQ i x ??; trans (Q i x);[apply HP|apply HQ].
- intros n P Q HPQ i x ??; apply HPQ; auto.
- intros n c i x ??; symmetry; apply (chain_cauchy c i (S n)); auto.
+ by intros P; split=> x i.
+ by intros P Q HPQ; split=> x i ??; symmetry; apply HPQ.
+ intros P Q Q' HP HQ; split=> i x ??.
by trans (Q i x);[apply HP|apply HQ].
- 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.
Qed.
Canonical Structure uPredC : cofeT := CofeT uPred_cofe_mixin.
End cofe.
......@@ -71,30 +76,32 @@ Qed.
Instance uPred_map_ne {M1 M2 : cmraT} (f : M2 -n> M1)
`{!CMRAMonotone f} n : Proper (dist n ==> dist n) (uPred_map f).
Proof.
by intros x1 x2 Hx n' y; split; apply Hx; auto using validN_preserving.
intros x1 x2 Hx; split=> n' y ??.
split; apply Hx; auto using validN_preserving.
Qed.
Lemma uPred_map_id {M : cmraT} (P : uPred M): uPred_map cid P P.
Proof. by intros n x ?. Qed.
Proof. by split=> n x ?. Qed.
Lemma uPred_map_compose {M1 M2 M3 : cmraT} (f : M1 -n> M2) (g : M2 -n> M3)
`{!CMRAMonotone f, !CMRAMonotone g} (P : uPred M3):
uPred_map (g f) P uPred_map f (uPred_map g P).
Proof. by intros n x Hx. Qed.
Proof. by split=> n x Hx. Qed.
Lemma uPred_map_ext {M1 M2 : cmraT} (f g : M1 -n> M2)
`{!CMRAMonotone f, !CMRAMonotone g} :
( x, f x g x) x, uPred_map f x uPred_map g x.
Proof. move=> Hfg x P n Hx /=. by rewrite /uPred_holds /= Hfg. Qed.
`{!CMRAMonotone f} `{!CMRAMonotone g}:
( x, f x g x) -> x, uPred_map f x uPred_map g x.
Proof. intros Hf P; split=> n x Hx /=; by rewrite /uPred_holds /= Hf. Qed.
Definition uPredC_map {M1 M2 : cmraT} (f : M2 -n> M1) `{!CMRAMonotone f} :
uPredC M1 -n> uPredC M2 := CofeMor (uPred_map f : uPredC M1 uPredC M2).
Lemma upredC_map_ne {M1 M2 : cmraT} (f g : M2 -n> M1)
`{!CMRAMonotone f, !CMRAMonotone g} n :
f {n} g uPredC_map f {n} uPredC_map g.
Proof.
by intros Hfg P n' y ??;
by intros Hfg P; split=> n' y ??;
rewrite /uPred_holds /= (dist_le _ _ _ _(Hfg y)); last lia.
Qed.
(** logical entailement *)
Definition uPred_entails {M} (P Q : uPred M) := n x, {n} x P n x Q n x.
Inductive uPred_entails {M} (P Q : uPred M) : Prop :=
{ uPred_in_entails : n x, {n} x P n x Q n x }.
Hint Extern 0 (uPred_entails _ _) => reflexivity.
Instance uPred_entails_rewrite_relation M : RewriteRelation (@uPred_entails M).
......@@ -218,9 +225,9 @@ Definition uPred_iff {M} (P Q : uPred M) : uPred M := ((P → Q) ∧ (Q → P))%
Infix "↔" := uPred_iff : uPred_scope.
Class TimelessP {M} (P : uPred M) := timelessP : P (P False).
Arguments timelessP {_} _ {_} _ _ _ _.
Arguments timelessP {_} _ {_}.
Class AlwaysStable {M} (P : uPred M) := always_stable : P P.
Arguments always_stable {_} _ {_} _ _ _ _.
Arguments always_stable {_} _ {_}.
Module uPred. Section uPred_logic.
Context {M : cmraT}.
......@@ -229,15 +236,20 @@ Implicit Types P Q : uPred M.
Implicit Types A : Type.
Notation "P ⊑ Q" := (@uPred_entails M P%I Q%I). (* Force implicit argument M *)
Arguments uPred_holds {_} !_ _ _ /.
Hint Immediate uPred_in_entails.
Global Instance: PreOrder (@uPred_entails M).
Proof. split. by intros P x i. by intros P Q Q' HP HQ x i ??; apply HQ, HP. Qed.
Proof.
split.
* by intros P; split=> x i.
* by intros P Q Q' HP HQ; split=> x i ??; apply HQ, HP.
Qed.
Global Instance: AntiSymm () (@uPred_entails M).
Proof. intros P Q HPQ HQP; split; auto. Qed.
Proof. intros P Q HPQ HQP; split=> x n; by split; [apply HPQ|apply HQP]. Qed.
Lemma equiv_spec P Q : P Q P Q Q P.
Proof.
split; [|by intros [??]; apply (anti_symm ())].
intros HPQ; split; intros x i; apply HPQ.
intros HPQ; split; split=> x i; apply HPQ.
Qed.
Lemma equiv_entails P Q : P Q P Q.
Proof. apply equiv_spec. Qed.
......@@ -253,31 +265,34 @@ Qed.
(** Non-expansiveness and setoid morphisms *)
Global Instance const_proper : Proper (iff ==> ()) (@uPred_const M).
Proof. by intros φ1 φ2 Hφ [|n] ??; try apply Hφ. Qed.
Proof. intros φ1 φ2 Hφ. by split=> -[|n] ?; try apply Hφ. Qed.
Global Instance and_ne n : Proper (dist n ==> dist n ==> dist n) (@uPred_and M).
Proof.
intros P P' HP Q Q' HQ; split; intros [??]; split; by apply HP || by apply HQ.
intros P P' HP Q Q' HQ; split=> x n' ??.
split; (intros [??]; split; [by apply HP|by apply HQ]).
Qed.
Global Instance and_proper :
Proper (() ==> () ==> ()) (@uPred_and M) := ne_proper_2 _.
Global Instance or_ne n : Proper (dist n ==> dist n ==> dist n) (@uPred_or M).
Proof.
intros P P' HP Q Q' HQ; split; intros [?|?];
first [by left; apply HP | by right; apply HQ].
intros P P' HP Q Q' HQ; split=> x n' ??.
split; (intros [?|?]; [left; by apply HP|right; by apply HQ]).
Qed.
Global Instance or_proper :
Proper (() ==> () ==> ()) (@uPred_or M) := ne_proper_2 _.
Global Instance impl_ne n :
Proper (dist n ==> dist n ==> dist n) (@uPred_impl M).
Proof.
intros P P' HP Q Q' HQ; split; intros HPQ x' n'' ????; apply HQ,HPQ,HP; auto.
intros P P' HP Q Q' HQ; split=> x n' ??.
split; intros HPQ x' n'' ????; apply HQ, HPQ, HP; auto.
Qed.
Global Instance impl_proper :
Proper (() ==> () ==> ()) (@uPred_impl M) := ne_proper_2 _.
Global Instance sep_ne n : Proper (dist n ==> dist n ==> dist n) (@uPred_sep M).
Proof.
intros P P' HP Q Q' HQ n' x ??; split; intros (x1&x2&?&?&?); cofe_subst x;
exists x1, x2; split_and?; try (apply HP || apply HQ);
intros P P' HP Q Q' HQ; split=> n' x ??.
split; intros (x1&x2&?&?&?); cofe_subst x;
exists x1, x2; split_and!; try (apply HP || apply HQ);
eauto using cmra_validN_op_l, cmra_validN_op_r.
Qed.
Global Instance sep_proper :
......@@ -285,7 +300,7 @@ Global Instance sep_proper :
Global Instance wand_ne n :
Proper (dist n ==> dist n ==> dist n) (@uPred_wand M).
Proof.
intros P P' HP Q Q' HQ n' x ??; split; intros HPQ n'' x' ???;
intros P P' HP Q Q' HQ; split=> n' x ??; split; intros HPQ x' n'' ???;
apply HQ, HPQ, HP; eauto using cmra_validN_op_r.
Qed.
Global Instance wand_proper :
......@@ -293,41 +308,51 @@ Global Instance wand_proper :
Global Instance eq_ne (A : cofeT) n :
Proper (dist n ==> dist n ==> dist n) (@uPred_eq M A).
Proof.
intros x x' Hx y y' Hy n' z; split; intros; simpl in *.
- by rewrite -(dist_le _ _ _ _ Hx) -?(dist_le _ _ _ _ Hy); auto.
- by rewrite (dist_le _ _ _ _ Hx) ?(dist_le _ _ _ _ Hy); auto.
intros x x' Hx y y' Hy; split=> n' z; split; intros; simpl in *.
* by rewrite -(dist_le _ _ _ _ Hx) -?(dist_le _ _ _ _ Hy); auto.
* by rewrite (dist_le _ _ _ _ Hx) ?(dist_le _ _ _ _ Hy); auto.
Qed.
Global Instance eq_proper (A : cofeT) :
Proper (() ==> () ==> ()) (@uPred_eq M A) := ne_proper_2 _.
Global Instance forall_ne A :
Global Instance forall_ne A n :
Proper (pointwise_relation _ (dist n) ==> dist n) (@uPred_forall M A).
Proof. by intros n Ψ1 Ψ2 HΨ n' x; split; intros HP a; apply HΨ. Qed.
Proof. by intros Ψ1 Ψ2 HΨ; split=> n' x; split; intros HP a; apply HΨ. Qed.
Global Instance forall_proper A :
Proper (pointwise_relation _ () ==> ()) (@uPred_forall M A).
Proof. by intros Ψ1 Ψ2 HΨ n' x; split; intros HP a; apply HΨ. Qed.
Global Instance exist_ne A :
Proof. by intros Ψ1 Ψ2 HΨ; split=> n' x; split; intros HP a; apply HΨ. Qed.
Global Instance exist_ne A n :
Proper (pointwise_relation _ (dist n) ==> dist n) (@uPred_exist M A).
Proof. by intros n P1 P2 HP x; split; intros [a ?]; exists a; apply HP. Qed.
Proof.
intros Ψ1 Ψ2 HΨ; split=> n' x ??; split; intros [a ?]; exists a; by apply HΨ.
Qed.
Global Instance exist_proper A :
Proper (pointwise_relation _ () ==> ()) (@uPred_exist M A).
Proof. by intros P1 P2 HP n' x; split; intros [a ?]; exists a; apply HP. Qed.
Proof.
intros Ψ1 Ψ2 HΨ; split=> n' x ?; split; intros [a ?]; exists a; by apply HΨ.
Qed.
Global Instance later_contractive : Contractive (@uPred_later M).
Proof.
intros n P Q HPQ [|n'] x ??; simpl; [done|].
intros n P Q HPQ; split=> -[|n'] x ??; simpl; [done|].
apply (HPQ n'); eauto using cmra_validN_S.
Qed.
Global Instance later_proper :
Proper (() ==> ()) (@uPred_later M) := ne_proper _.
Global Instance always_ne n: Proper (dist n ==> dist n) (@uPred_always M).
Proof. intros P1 P2 HP n' x; split; apply HP; eauto using cmra_unit_validN. Qed.
Global Instance always_ne n : Proper (dist n ==> dist n) (@uPred_always M).
Proof.
intros P1 P2 HP; split=> n' x; split; apply HP; eauto using cmra_unit_validN.
Qed.
Global Instance always_proper :
Proper (() ==> ()) (@uPred_always M) := ne_proper _.
Global Instance ownM_ne n : Proper (dist n ==> dist n) (@uPred_ownM M).
Proof. move=> a b Ha n' x ? /=. by rewrite (dist_le _ _ _ _ Ha); last lia. Qed.
Proof.
intros a b Ha; split=> n' x ? /=. by rewrite (dist_le _ _ _ _ Ha); last lia.
Qed.
Global Instance ownM_proper: Proper (() ==> ()) (@uPred_ownM M) := ne_proper _.
Global Instance valid_ne {A : cmraT} n :
Proper (dist n ==> dist n) (@uPred_valid M A).
Proof. move=> a b Ha n' x ? /=. by rewrite (dist_le _ _ _ _ Ha); last lia. Qed.
Proper (dist n ==> dist n) (@uPred_valid M A).
Proof.
intros a b Ha; split=> n' x ? /=. by rewrite (dist_le _ _ _ _ Ha); last lia.
Qed.
Global Instance valid_proper {A : cmraT} :
Proper (() ==> ()) (@uPred_valid M A) := ne_proper _.
Global Instance iff_ne n : Proper (dist n ==> dist n ==> dist n) (@uPred_iff M).
......@@ -337,43 +362,45 @@ Global Instance iff_proper :
(** Introduction and elimination rules *)
Lemma const_intro φ P : φ P φ.
Proof. by intros ???. Qed.
Proof. by intros ?; split. Qed.
Lemma const_elim φ Q R : Q φ (φ Q R) Q R.
Proof. intros HQP HQR n x ??; apply HQR; first eapply (HQP n); eauto. Qed.
Proof. intros HQP HQR; split=> n x ??; apply HQR; first eapply HQP; eauto. Qed.
Lemma False_elim P : False P.
Proof. by intros n x ?. Qed.
Proof. by split=> n x ?. Qed.
Lemma and_elim_l P Q : (P Q) P.
Proof. by intros n x ? [??]. Qed.
Proof. by split=> n x ? [??]. Qed.
Lemma and_elim_r P Q : (P Q) Q.
Proof. by intros n x ? [??]. Qed.
Proof. by split=> n x ? [??]. Qed.
Lemma and_intro P Q R : P Q P R P (Q R).
Proof. intros HQ HR n x ??; split; auto. Qed.
Proof. intros HQ HR; split=> n x ??; by split; [apply HQ|apply HR]. Qed.
Lemma or_intro_l P Q : P (P Q).
Proof. intros n x ??; left; auto. Qed.
Proof. split=> n x ??; left; auto. Qed.
Lemma or_intro_r P Q : Q (P Q).
Proof. intros n x ??; right; auto. Qed.
Proof. split=> n x ??; right; auto. Qed.
Lemma or_elim P Q R : P R Q R (P Q) R.
Proof. intros HP HQ n x ? [?|?]. by apply HP. by apply HQ. Qed.
Proof. intros HP HQ; split=> n x ? [?|?]. by apply HP. by apply HQ. Qed.
Lemma impl_intro_r P Q R : (P Q) R P (Q R).
Proof.
intros HQ; repeat intro; apply HQ; naive_solver eauto using uPred_weaken.
intros HQ; split=> n x ?? n' x' ????.
apply HQ; naive_solver eauto using uPred_weaken.
Qed.
Lemma impl_elim P Q R : P (Q R) P Q P R.
Proof. by intros HP HP' n x ??; apply HP with n x, HP'. Qed.
Proof. by intros HP HP'; split=> n x ??; apply HP with n x, HP'. Qed.
Lemma forall_intro {A} P (Ψ : A uPred M): ( a, P Ψ a) P ( a, Ψ a).
Proof. by intros HPΨ n x ?? a; apply HPΨ. Qed.
Proof. by intros HPΨ; split=> n x ?? a; apply HPΨ. Qed.
Lemma forall_elim {A} {Ψ : A uPred M} a : ( a, Ψ a) Ψ a.
Proof. intros n x ? HP; apply HP. Qed.
Proof. split=> n x ? HP; apply HP. Qed.
Lemma exist_intro {A} {Ψ : A uPred M} a : Ψ a ( a, Ψ a).
Proof. by intros n x ??; exists a. Qed.
Proof. by split=> n x ??; exists a. Qed.
Lemma exist_elim {A} (Φ : A uPred M) Q : ( a, Φ a Q) ( a, Φ a) Q.
Proof. by intros HΦΨ n x ? [a ?]; apply HΦΨ with a. Qed.
Proof. by intros HΦΨ; split=> n x ? [a ?]; apply HΦΨ with a. Qed.
Lemma eq_refl {A : cofeT} (a : A) P : P (a a).
Proof. by intros n x ??; simpl. Qed.
Proof. by split=> n x ??; simpl. Qed.
Lemma eq_rewrite {A : cofeT} a b (Ψ : A uPred M) P
`{HΨ : n, Proper (dist n ==> dist n) Ψ} : P (a b) P Ψ a P Ψ b.
Proof.
intros Hab Ha n x ??; apply HΨ with n a; auto. by symmetry; apply Hab with x.
intros Hab Ha; split=> n x ??.
apply HΨ with n a; auto. by symmetry; apply Hab with x. by apply Ha.
Qed.
Lemma eq_equiv `{Empty M, !CMRAIdentity M} {A : cofeT} (a b : A) :
True (a b) a b.
......@@ -382,7 +409,7 @@ Proof.
apply cmra_valid_validN, cmra_empty_valid.
Qed.
Lemma iff_equiv P Q : True (P Q) P Q.
Proof. by intros HPQ n x ?; split; intros; apply HPQ with n x. Qed.
Proof. by intros HPQ; split=> n x ?; split; intros; apply HPQ with n x. Qed.
(* Derived logical stuff *)
Lemma True_intro P : P True.
......@@ -552,23 +579,23 @@ Proof. apply (eq_rewrite a b (λ b, b ≡ a)%I); auto using eq_refl. solve_ne. Q
(* BI connectives *)
Lemma sep_mono P P' Q Q' : P Q P' Q' (P P') (Q Q').
Proof.
intros HQ HQ' n' x ? (x1&x2&?&?&?); exists x1, x2; cofe_subst x;
eauto 7 using cmra_validN_op_l, cmra_validN_op_r.
intros HQ HQ'; split; intros n' x ? (x1&x2&?&?&?); exists x1,x2; cofe_subst x;
eauto 7 using cmra_validN_op_l, cmra_validN_op_r, uPred_in_entails.
Qed.
Global Instance True_sep : LeftId () True%I (@uPred_sep M).
Proof.
intros P n x Hvalid; split.
intros P; split=> n x Hvalid; split.
- intros (x1&x2&?&_&?); cofe_subst; eauto using uPred_weaken, cmra_included_r.
- by intros ?; exists (unit x), x; rewrite cmra_unit_l.
Qed.
Global Instance sep_comm : Comm () (@uPred_sep M).
Proof.
by intros P Q n x ?; split;
by intros P Q; split=> n x ?; split;
intros (x1&x2&?&?&?); exists x2, x1; rewrite (comm op).
Qed.
Global Instance sep_assoc : Assoc () (@uPred_sep M).
Proof.
intros P Q R n x ?; split.
intros P Q R; split=> n x ?; split.
- intros (x1&x2&Hx&?&y1&y2&Hy&?&?); exists (x1 y1), y2; split_and?; auto.
+ by rewrite -(assoc op) -Hy -Hx.
+ by exists x1, y1.
......@@ -578,12 +605,12 @@ Proof.
Qed.
Lemma wand_intro_r P Q R : (P Q) R P (Q - R).
Proof.
intros HPQR n x ?? n' x' ???; apply HPQR; auto.
intros HPQR; split=> n x ?? n' x' ???; apply HPQR; auto.
exists x, x'; split_and?; auto.
eapply uPred_weaken with n x; eauto using cmra_validN_op_l.
Qed.
Lemma wand_elim_l P Q : ((P - Q) P) Q.
Proof. by intros n x ? (x1&x2&Hx&HPQ&?); cofe_subst; apply HPQ. Qed.
Proof. by split; intros n x ? (x1&x2&Hx&HPQ&?); cofe_subst; apply HPQ. Qed.
(* Derived BI Stuff *)
Hint Resolve sep_mono.
......@@ -688,10 +715,10 @@ Proof. by apply forall_intro=> a; rewrite forall_elim. Qed.
Lemma always_const φ : ( φ : uPred M)%I ( φ)%I.
Proof. done. Qed.
Lemma always_elim P : P P.
Proof. intros n x ?; simpl; eauto using uPred_weaken, cmra_included_unit. Qed.
Proof. split=> n x ?; simpl; eauto using uPred_weaken, cmra_included_unit. Qed.
Lemma always_intro' P Q : P Q P Q.
Proof.
intros HPQ n x ??; apply HPQ; simpl in *; auto using cmra_unit_validN.
intros HPQ; split=> n x ??; apply HPQ; simpl in *; auto using cmra_unit_validN.
by rewrite cmra_unit_idemp.
Qed.
Lemma always_and P Q : ( (P Q))%I ( P Q)%I.
......@@ -704,11 +731,11 @@ Lemma always_exist {A} (Ψ : A → uPred M) : (□ ∃ a, Ψ a)%I ≡ (∃ a,
Proof. done. Qed.
Lemma always_and_sep_1 P Q : (P Q) (P Q).
Proof.
intros n x ? [??]; exists (unit x), (unit x); rewrite cmra_unit_unit; auto.
split=> n x ? [??]; exists (unit x), (unit x); rewrite cmra_unit_unit; auto.
Qed.
Lemma always_and_sep_l_1 P Q : ( P Q) ( P Q).
Proof.
intros n x ? [??]; exists (unit x), x; simpl in *.
split=> n x ? [??]; exists (unit x), x; simpl in *.
by rewrite cmra_unit_l cmra_unit_idemp.
Qed.
Lemma always_later P : ( P)%I ( P)%I.
......@@ -720,6 +747,9 @@ Proof. intros. apply always_intro'. by rewrite always_elim. Qed.
Hint Resolve always_mono.
Global Instance always_mono' : Proper (() ==> ()) (@uPred_always M).
Proof. intros P Q; apply always_mono. Qed.
Global Instance always_flip_mono' :
Proper (flip () ==> flip ()) (@uPred_always M).
Proof. intros P Q; apply always_mono. Qed.
Lemma always_impl P Q : (P Q) ( P Q).
Proof.
apply impl_intro_l; rewrite -always_and.
......@@ -730,7 +760,7 @@ Proof.
apply (anti_symm ()); auto using always_elim.
apply (eq_rewrite a b (λ b, (a b))%I); auto.
{ intros n; solve_proper. }
rewrite -(eq_refl _ True) always_const; auto.
rewrite -(eq_refl a True) always_const; auto.
Qed.
Lemma always_and_sep P Q : ( (P Q))%I ( (P Q))%I.
Proof. apply (anti_symm ()); auto using always_and_sep_1. Qed.
......@@ -757,33 +787,35 @@ Proof. intros; rewrite -always_and_sep_r'; auto. Qed.
(* Later *)
Lemma later_mono P Q : P Q P Q.
Proof. intros HP [|n] x ??; [done|apply HP; eauto using cmra_validN_S]. Qed.
Proof.
intros HP; split=>-[|n] x ??; [done|apply HP; eauto using cmra_validN_S].
Qed.
Lemma later_intro P : P P.
Proof.
intros [|n] x ??; simpl in *; [done|].
split=> -[|n] x ??; simpl in *; [done|].
apply uPred_weaken with (S n) x; eauto using cmra_validN_S.
Qed.
Lemma löb P : ( P P) P.
Proof.
intros n x ? HP; induction n as [|n IH]; [by apply HP|].
split=> n x ? HP; induction n as [|n IH]; [by apply HP|].
apply HP, IH, uPred_weaken with (S n) x; eauto using cmra_validN_S.
Qed.
Lemma later_True' : True ( True : uPred M).
Proof. by intros [|n] x. Qed.
Proof. by split=> -[|n] x. Qed.
Lemma later_and P Q : ( (P Q))%I ( P Q)%I.
Proof. by intros [|n] x; split. Qed.
Proof. by split=> -[|n] x; split. Qed.
Lemma later_or P Q : ( (P Q))%I ( P Q)%I.
Proof. intros [|n] x; simpl; tauto. Qed.
Proof. split=> -[|n] x; simpl; tauto. Qed.
Lemma later_forall {A} (Φ : A uPred M) : ( a, Φ a)%I ( a, Φ a)%I.
Proof. by intros [|n] x. Qed.
Proof. by split=> -[|n] x. Qed.
Lemma later_exist_1 {A} (Φ : A uPred M) : ( a, Φ a) ( a, Φ a).
Proof. by intros [|[|n]] x. Qed.
Proof. by split=> -[|[|n]] x. Qed.
Lemma later_exist `{Inhabited A} (Φ : A uPred M) :
( a, Φ a)%I ( a, Φ a)%I.
Proof. intros [|[|n]] x; split; done || by exists inhabitant; simpl. Qed.
Proof. split=> -[|[|n]] x; split; done || by exists inhabitant; simpl. Qed.
Lemma later_sep P Q : ( (P Q))%I ( P Q)%I.
Proof.
intros n x ?; split.
split=> n x ?; split.
- destruct n as [|n]; simpl.
{ by exists x, (unit x); rewrite cmra_unit_r. }
intros (x1&x2&Hx&?&?); destruct (cmra_extend_op n x x1 x2)
......@@ -796,6 +828,9 @@ Qed.
(* Later derived *)
Global Instance later_mono' : Proper (() ==> ()) (@uPred_later M).
Proof. intros P Q; apply later_mono. Qed.
Global Instance later_flip_mono' :
Proper (flip () ==> flip ()) (@uPred_later M).
Proof. intros P Q; apply later_mono. Qed.
Lemma later_True : ( True : uPred M)%I True%I.
Proof. apply (anti_symm ()); auto using later_True'. Qed.
Lemma later_impl P Q : (P Q) ( P Q).
......@@ -825,7 +860,7 @@ Qed.
Lemma ownM_op (a1 a2 : M) :
uPred_ownM (a1 a2) (uPred_ownM a1 uPred_ownM a2)%I.
Proof.
intros n x ?; split.
split=> n x ?; split.
- intros [z ?]; exists a1, (a2 z); split; [by rewrite (assoc op)|].
split. by exists (unit a1); rewrite cmra_unit_r. by exists z.
- intros (y1&y2&Hx&[z1 Hy1]&[z2 Hy2]); exists (z1 z2).
......@@ -834,28 +869,28 @@ Proof.