Commit 96501a4f authored by Robbert Krebbers's avatar Robbert Krebbers Committed by Jacques-Henri Jourdan
Browse files

Define `Persistent P` as `P ⊢ □ P` instead of `□ P ⊣⊢ P`.

Otherwise, ownership of cores in our ordered RA model will not be persistent.
parent 77056b1b
...@@ -38,8 +38,8 @@ Proof. intros P. rewrite /Affine. by apply bi.pure_intro. Qed. ...@@ -38,8 +38,8 @@ Proof. intros P. rewrite /Affine. by apply bi.pure_intro. Qed.
(* Own and valid derived *) (* Own and valid derived *)
Lemma persistently_ownM (a : M) : CoreId a uPred_ownM a uPred_ownM a. Lemma persistently_ownM (a : M) : CoreId a uPred_ownM a uPred_ownM a.
Proof. Proof.
intros; apply (anti_symm _); first by apply: persistently_elim_absorbing. intros; apply (anti_symm _); first by rewrite persistently_elim.
by rewrite {1}persistently_ownM_core core_id_core. by rewrite {1}persistently_ownM_core core_id_core.
Qed. Qed.
Lemma ownM_invalid (a : M) : ¬ {0} a uPred_ownM a False. Lemma ownM_invalid (a : M) : ¬ {0} a uPred_ownM a False.
Proof. by intros; rewrite ownM_valid cmra_valid_elim. Qed. Proof. by intros; rewrite ownM_valid cmra_valid_elim. Qed.
...@@ -49,7 +49,7 @@ Lemma ownM_unit' : uPred_ownM ε ⊣⊢ True. ...@@ -49,7 +49,7 @@ Lemma ownM_unit' : uPred_ownM ε ⊣⊢ True.
Proof. apply (anti_symm _); first by apply pure_intro. apply ownM_empty. Qed. Proof. apply (anti_symm _); first by apply pure_intro. apply ownM_empty. Qed.
Lemma persistently_cmra_valid {A : cmraT} (a : A) : a a. Lemma persistently_cmra_valid {A : cmraT} (a : A) : a a.
Proof. Proof.
intros; apply (anti_symm _); first by apply: persistently_elim_absorbing. intros; apply (anti_symm _); first by rewrite persistently_elim.
apply:persistently_cmra_valid_1. apply:persistently_cmra_valid_1.
Qed. Qed.
...@@ -93,7 +93,7 @@ Qed. ...@@ -93,7 +93,7 @@ Qed.
(* Derived lemmas for persistence *) (* Derived lemmas for persistence *)
Global Instance limit_preserving_Persistent {A:ofeT} `{Cofe A} (Φ : A uPred M) : Global Instance limit_preserving_Persistent {A:ofeT} `{Cofe A} (Φ : A uPred M) :
NonExpansive Φ LimitPreserving (λ x, Persistent (Φ x)). NonExpansive Φ LimitPreserving (λ x, Persistent (Φ x)).
Proof. intros. apply limit_preserving_equiv; solve_proper. Qed. Proof. intros. apply limit_preserving_entails; solve_proper. Qed.
(* Persistence *) (* Persistence *)
Global Instance cmra_valid_persistent {A : cmraT} (a : A) : Global Instance cmra_valid_persistent {A : cmraT} (a : A) :
......
...@@ -200,6 +200,6 @@ Section proofmode_classes. ...@@ -200,6 +200,6 @@ Section proofmode_classes.
FromAnd (own γ a) (own γ b1) (own γ b2). FromAnd (own γ a) (own γ b1) (own γ b2).
Proof. Proof.
intros ? Hb. rewrite /FromAnd (is_op a) own_op. intros ? Hb. rewrite /FromAnd (is_op a) own_op.
destruct Hb. by rewrite persistent_and_sep_l. by rewrite persistent_and_sep_r. destruct Hb; by rewrite persistent_and_sep.
Qed. Qed.
End proofmode_classes. End proofmode_classes.
...@@ -79,7 +79,7 @@ Global Instance from_sep_ownM_core_id (a b1 b2 : M) : ...@@ -79,7 +79,7 @@ Global Instance from_sep_ownM_core_id (a b1 b2 : M) :
FromAnd (uPred_ownM a) (uPred_ownM b1) (uPred_ownM b2). FromAnd (uPred_ownM a) (uPred_ownM b1) (uPred_ownM b2).
Proof. Proof.
intros ? H. rewrite /FromAnd (is_op a) ownM_op. intros ? H. rewrite /FromAnd (is_op a) ownM_op.
destruct H. by rewrite persistent_and_sep_l. by rewrite persistent_and_sep_r. destruct H; by rewrite persistent_and_sep.
Qed. Qed.
Global Instance into_and_ownM p (a b1 b2 : M) : Global Instance into_and_ownM p (a b1 b2 : M) :
......
...@@ -137,7 +137,7 @@ Section sep_list. ...@@ -137,7 +137,7 @@ Section sep_list.
{ apply forall_intro=> k; apply forall_intro=> x. { apply forall_intro=> k; apply forall_intro=> x.
apply impl_intro_l, pure_elim_l=> ?; by apply: big_sepL_lookup. } apply impl_intro_l, pure_elim_l=> ?; by apply: big_sepL_lookup. }
revert Φ HΦ. induction l as [|x l IH]=> Φ HΦ; [by auto using big_sepL_nil'|]. revert Φ HΦ. induction l as [|x l IH]=> Φ HΦ; [by auto using big_sepL_nil'|].
rewrite big_sepL_cons. rewrite -persistent_and_sep_l; apply and_intro. rewrite big_sepL_cons. rewrite -persistent_and_sep; apply and_intro.
- by rewrite (forall_elim 0) (forall_elim x) pure_True // True_impl. - by rewrite (forall_elim 0) (forall_elim x) pure_True // True_impl.
- rewrite -IH. apply forall_intro=> k; by rewrite (forall_elim (S k)). - rewrite -IH. apply forall_intro=> k; by rewrite (forall_elim (S k)).
Qed. Qed.
...@@ -158,21 +158,13 @@ Section sep_list. ...@@ -158,21 +158,13 @@ Section sep_list.
apply forall_intro=> k. by rewrite (forall_elim (S k)). apply forall_intro=> k. by rewrite (forall_elim (S k)).
Qed. Qed.
Global Instance big_sepL_nil_persistent `{AffineBI PROP} Φ : Global Instance big_sepL_nil_persistent Φ :
Persistent ([ list] kx [], Φ k x). Persistent ([ list] kx [], Φ k x).
Proof. simpl; apply _. Qed. Proof. simpl; apply _. Qed.
Global Instance big_sepL_persistent1 Φ l : Global Instance big_sepL_persistent Φ l :
( k x, Persistent (Φ k x))
l []
Persistent ([ list] kx l, Φ k x).
Proof.
intros. rewrite /Persistent (big_opL_commute1 bi_persistently (R:=())) //.
apply big_opL_proper=> k y ?. by apply persistent_persistently.
Qed.
Global Instance big_sepL_persistent `{AffineBI PROP} Φ l :
( k x, Persistent (Φ k x)) Persistent ([ list] kx l, Φ k x). ( k x, Persistent (Φ k x)) Persistent ([ list] kx l, Φ k x).
Proof. revert Φ. induction l as [|x l IH]=> Φ ? /=; apply _. Qed. Proof. revert Φ. induction l as [|x l IH]=> Φ ? /=; apply _. Qed.
Global Instance big_sepL_persistent_id `{AffineBI PROP} Ps : Global Instance big_sepL_persistent_id Ps :
TCForall Persistent Ps Persistent ([] Ps). TCForall Persistent Ps Persistent ([] Ps).
Proof. induction 1; simpl; apply _. Qed. Proof. induction 1; simpl; apply _. Qed.
End sep_list. End sep_list.
...@@ -404,7 +396,7 @@ Section gmap. ...@@ -404,7 +396,7 @@ Section gmap.
{ apply forall_intro=> k; apply forall_intro=> x. { apply forall_intro=> k; apply forall_intro=> x.
apply impl_intro_l, pure_elim_l=> ?; by apply: big_sepM_lookup. } apply impl_intro_l, pure_elim_l=> ?; by apply: big_sepM_lookup. }
induction m as [|i x m ? IH] using map_ind; auto using big_sepM_empty'. induction m as [|i x m ? IH] using map_ind; auto using big_sepM_empty'.
rewrite big_sepM_insert // -persistent_and_sep_l. apply and_intro. rewrite big_sepM_insert // -persistent_and_sep. apply and_intro.
- rewrite (forall_elim i) (forall_elim x) lookup_insert. - rewrite (forall_elim i) (forall_elim x) lookup_insert.
by rewrite pure_True // True_impl. by rewrite pure_True // True_impl.
- rewrite -IH. apply forall_mono=> k; apply forall_mono=> y. - rewrite -IH. apply forall_mono=> k; apply forall_mono=> y.
...@@ -431,15 +423,14 @@ Section gmap. ...@@ -431,15 +423,14 @@ Section gmap.
by rewrite pure_True // True_impl. by rewrite pure_True // True_impl.
Qed. Qed.
Global Instance big_sepM_empty_persistent `{AffineBI PROP} Φ : Global Instance big_sepM_empty_persistent Φ :
Persistent ([ map] kx , Φ k x). Persistent ([ map] kx , Φ k x).
Proof. rewrite /big_opM map_to_list_empty. apply _. Qed. Proof. rewrite /big_opM map_to_list_empty. apply _. Qed.
Global Instance big_sepM_persistent `{AffineBI PROP} Φ m : Global Instance big_sepM_persistent Φ m :
( k x, Persistent (Φ k x)) Persistent ([ map] kx m, Φ k x). ( k x, Persistent (Φ k x)) Persistent ([ map] kx m, Φ k x).
Proof. intros. apply big_sepL_persistent=> _ [??]; apply _. Qed. Proof. intros. apply big_sepL_persistent=> _ [??]; apply _. Qed.
End gmap. End gmap.
(** ** Big ops over finite sets *) (** ** Big ops over finite sets *)
Section gset. Section gset.
Context `{Countable A}. Context `{Countable A}.
...@@ -562,7 +553,7 @@ Section gset. ...@@ -562,7 +553,7 @@ Section gset.
{ apply forall_intro=> x. { apply forall_intro=> x.
apply impl_intro_l, pure_elim_l=> ?; by apply: big_sepS_elem_of. } apply impl_intro_l, pure_elim_l=> ?; by apply: big_sepS_elem_of. }
induction X as [|x X ? IH] using collection_ind_L; auto using big_sepS_empty'. induction X as [|x X ? IH] using collection_ind_L; auto using big_sepS_empty'.
rewrite big_sepS_insert // -persistent_and_sep_l. apply and_intro. rewrite big_sepS_insert // -persistent_and_sep. apply and_intro.
- by rewrite (forall_elim x) pure_True ?True_impl; last set_solver. - by rewrite (forall_elim x) pure_True ?True_impl; last set_solver.
- rewrite -IH. apply forall_mono=> y. apply impl_intro_l, pure_elim_l=> ?. - rewrite -IH. apply forall_mono=> y. apply impl_intro_l, pure_elim_l=> ?.
by rewrite pure_True ?True_impl; last set_solver. by rewrite pure_True ?True_impl; last set_solver.
...@@ -583,11 +574,10 @@ Section gset. ...@@ -583,11 +574,10 @@ Section gset.
apply forall_mono=> y. apply impl_intro_l, pure_elim_l=> ?. apply forall_mono=> y. apply impl_intro_l, pure_elim_l=> ?.
by rewrite pure_True ?True_impl; last set_solver. by rewrite pure_True ?True_impl; last set_solver.
Qed. Qed.
Global Instance big_sepS_empty_persistent Φ :
Global Instance big_sepS_empty_persistent `{AffineBI PROP} Φ :
Persistent ([ set] x , Φ x). Persistent ([ set] x , Φ x).
Proof. rewrite /big_opS elements_empty. apply _. Qed. Proof. rewrite /big_opS elements_empty. apply _. Qed.
Global Instance big_sepS_persistent `{AffineBI PROP} Φ X : Global Instance big_sepS_persistent Φ X :
( x, Persistent (Φ x)) Persistent ([ set] x X, Φ x). ( x, Persistent (Φ x)) Persistent ([ set] x X, Φ x).
Proof. rewrite /big_opS. apply _. Qed. Proof. rewrite /big_opS. apply _. Qed.
End gset. End gset.
...@@ -658,10 +648,10 @@ Section gmultiset. ...@@ -658,10 +648,10 @@ Section gmultiset.
([ mset] y X, Φ y) ([ mset] y X, Φ y). ([ mset] y X, Φ y) ([ mset] y X, Φ y).
Proof. apply (big_opMS_commute _). Qed. Proof. apply (big_opMS_commute _). Qed.
Global Instance big_sepMS_empty_persistent `{AffineBI PROP} Φ : Global Instance big_sepMS_empty_persistent Φ :
Persistent ([ mset] x , Φ x). Persistent ([ mset] x , Φ x).
Proof. rewrite /big_opMS gmultiset_elements_empty. apply _. Qed. Proof. rewrite /big_opMS gmultiset_elements_empty. apply _. Qed.
Global Instance big_sepMS_persistent `{AffineBI PROP} Φ X : Global Instance big_sepMS_persistent Φ X :
( x, Persistent (Φ x)) Persistent ([ mset] x X, Φ x). ( x, Persistent (Φ x)) Persistent ([ mset] x X, Φ x).
Proof. rewrite /big_opMS. apply _. Qed. Proof. rewrite /big_opMS. apply _. Qed.
End gmultiset. End gmultiset.
......
...@@ -13,7 +13,7 @@ Arguments bi_wand_iff {_} _%I _%I : simpl never. ...@@ -13,7 +13,7 @@ Arguments bi_wand_iff {_} _%I _%I : simpl never.
Instance: Params (@bi_wand_iff) 1. Instance: Params (@bi_wand_iff) 1.
Infix "∗-∗" := bi_wand_iff (at level 95, no associativity) : bi_scope. Infix "∗-∗" := bi_wand_iff (at level 95, no associativity) : bi_scope.
Class Persistent {PROP : bi} (P : PROP) := persistent : P P. Class Persistent {PROP : bi} (P : PROP) := persistent : P P.
Arguments Persistent {_} _%I : simpl never. Arguments Persistent {_} _%I : simpl never.
Arguments persistent {_} _%I {_}. Arguments persistent {_} _%I {_}.
Hint Mode Persistent + ! : typeclass_instances. Hint Mode Persistent + ! : typeclass_instances.
...@@ -808,9 +808,13 @@ Proof. destruct H. by rewrite (affine Q) right_id. by rewrite absorbing. Qed. ...@@ -808,9 +808,13 @@ Proof. destruct H. by rewrite (affine Q) right_id. by rewrite absorbing. Qed.
Lemma sep_elim_r P Q `{H : TCOr (Affine P) (Absorbing Q)} : P Q Q. Lemma sep_elim_r P Q `{H : TCOr (Affine P) (Absorbing Q)} : P Q Q.
Proof. by rewrite comm sep_elim_l. Qed. Proof. by rewrite comm sep_elim_l. Qed.
Lemma sep_and P Q `{TCOr (Affine P) (Absorbing Q), TCOr (Affine Q) (Absorbing P)} : Lemma sep_and P Q
`{HPQ : TCOr (TCAnd (Affine P) (Affine Q)) (TCAnd (Absorbing P) (Absorbing Q))} :
P Q P Q. P Q P Q.
Proof. auto using and_intro, sep_elim_l, sep_elim_r. Qed. Proof.
destruct HPQ as [[??]|[??]];
apply and_intro; apply: sep_elim_l || apply: sep_elim_r.
Qed.
Lemma affine_bare P `{!Affine P} : P P. Lemma affine_bare P `{!Affine P} : P P.
Proof. rewrite /bi_bare. apply (anti_symm _); auto. Qed. Proof. rewrite /bi_bare. apply (anti_symm _); auto. Qed.
...@@ -881,31 +885,28 @@ Proof. ...@@ -881,31 +885,28 @@ Proof.
Qed. Qed.
Lemma persistently_and_emp_elim P : emp P P. Lemma persistently_and_emp_elim P : emp P P.
Proof. by rewrite comm persistently_and_sep_elim right_id and_elim_r. Qed. Proof. by rewrite comm persistently_and_sep_elim right_id and_elim_r. Qed.
Lemma persistently_elim P : P P True. Lemma persistently_elim_True P : P P True.
Proof. Proof.
rewrite -(right_id True%I _ ( _)%I) -{1}(left_id emp%I _ True%I). rewrite -(right_id True%I _ ( _)%I) -{1}(left_id emp%I _ True%I).
by rewrite persistently_and_sep_assoc_1 (comm bi_and) persistently_and_emp_elim. by rewrite persistently_and_sep_assoc_1 (comm bi_and) persistently_and_emp_elim.
Qed. Qed.
Lemma persistently_elim_absorbing P `{!Absorbing P} : P P. Lemma persistently_elim P `{!Absorbing P} : P P.
Proof. by rewrite persistently_elim sep_elim_l. Qed. Proof. by rewrite persistently_elim_True sep_elim_l. Qed.
Lemma persistently_idemp_1 P : P P. Lemma persistently_idemp_1 P : P P.
Proof. by rewrite persistently_elim persistently_absorbing. Qed. Proof. by rewrite persistently_elim_True persistently_absorbing. Qed.
Lemma persistently_idemp P : P P. Lemma persistently_idemp P : P P.
Proof. Proof. apply (anti_symm _); auto using persistently_idemp_1, persistently_idemp_2. Qed.
apply (anti_symm _); auto using persistently_idemp_1, persistently_idemp_2.
Qed.
Lemma persistently_intro' P Q : ( P Q) P Q. Lemma persistently_intro' P Q : ( P Q) P Q.
Proof. intros <-. apply persistently_idemp_2. Qed. Proof. intros <-. apply persistently_idemp_2. Qed.
Lemma persistently_pure φ : ⌜φ⌝ ⌜φ⌝. Lemma persistently_pure φ : ⌜φ⌝ ⌜φ⌝.
Proof. Proof.
apply (anti_symm _). apply (anti_symm _); first by rewrite persistently_elim.
- by rewrite persistently_elim sep_elim_l. apply pure_elim'=> Hφ.
- apply pure_elim'=> Hφ. trans ( x : False, True : PROP)%I; [by apply forall_intro|].
trans ( x : False, True : PROP)%I; [by apply forall_intro|]. rewrite persistently_forall_2. auto using persistently_mono, pure_intro.
rewrite persistently_forall_2. auto using persistently_mono, pure_intro.
Qed. Qed.
Lemma persistently_forall {A} (Ψ : A PROP) : ( a, Ψ a) ( a, Ψ a). Lemma persistently_forall {A} (Ψ : A PROP) : ( a, Ψ a) ( a, Ψ a).
Proof. Proof.
...@@ -929,11 +930,9 @@ Qed. ...@@ -929,11 +930,9 @@ Qed.
Lemma persistently_internal_eq {A : ofeT} (a b : A) : (a b) a b. Lemma persistently_internal_eq {A : ofeT} (a b : A) : (a b) a b.
Proof. Proof.
apply (anti_symm ()); auto using persistently_elim. apply (anti_symm ()); first by rewrite persistently_elim.
- rewrite persistently_elim. apply wand_elim_l'. apply (internal_eq_rewrite' a b (λ b, (a b))%I); auto.
apply (internal_eq_rewrite' a b (λ b, True - a b)%I); auto using wand_intro_l. rewrite -(internal_eq_refl emp%I a). apply persistently_emp_intro.
- apply (internal_eq_rewrite' a b (λ b, (a b))%I); auto.
rewrite -(internal_eq_refl emp%I a). apply persistently_emp_intro.
Qed. Qed.
Lemma persistently_sep_dup P : P P P. Lemma persistently_sep_dup P : P P P.
...@@ -1017,30 +1016,26 @@ Section persistently_bare_bi. ...@@ -1017,30 +1016,26 @@ Section persistently_bare_bi.
Proof. Proof.
apply (anti_symm ()); auto using persistently_impl_wand_2. apply (anti_symm ()); auto using persistently_impl_wand_2.
apply persistently_intro', wand_intro_l. apply persistently_intro', wand_intro_l.
by rewrite -persistently_and_sep_r persistently_elim_absorbing impl_elim_r. by rewrite -persistently_and_sep_r persistently_elim impl_elim_r.
Qed. Qed.
Lemma wand_alt P Q : (P - Q) R, R (P R Q). Lemma wand_alt P Q : (P - Q) R, R (P R Q).
Proof. Proof.
apply (anti_symm ()). apply (anti_symm ()).
- rewrite -(right_id True%I bi_sep (P - Q)%I) -(exist_intro (P - Q)%I). - rewrite -(right_id True%I bi_sep (P - Q)%I) -(exist_intro (P - Q)%I).
apply sep_mono_r. rewrite -persistently_pure. apply sep_mono_r. rewrite -persistently_pure. apply persistently_intro', impl_intro_l.
apply persistently_intro', impl_intro_l.
by rewrite wand_elim_r persistently_pure right_id. by rewrite wand_elim_r persistently_pure right_id.
- apply exist_elim=> R. apply wand_intro_l. - apply exist_elim=> R. apply wand_intro_l. rewrite assoc -persistently_and_sep_r.
rewrite assoc -persistently_and_sep_r. by rewrite persistently_elim impl_elim_r.
by rewrite persistently_elim_absorbing impl_elim_r.
Qed. Qed.
Lemma impl_alt P Q : (P Q) R, R (P R - Q). Lemma impl_alt P Q : (P Q) R, R (P R - Q).
Proof. Proof.
apply (anti_symm ()). apply (anti_symm ()).
- rewrite -(right_id True%I bi_and (P Q)%I) -(exist_intro (P Q)%I). - rewrite -(right_id True%I bi_and (P Q)%I) -(exist_intro (P Q)%I).
apply and_mono_r. rewrite -persistently_pure. apply and_mono_r. rewrite -persistently_pure. apply persistently_intro', wand_intro_l.
apply persistently_intro', wand_intro_l.
by rewrite impl_elim_r persistently_pure right_id. by rewrite impl_elim_r persistently_pure right_id.
- apply exist_elim=> R. apply impl_intro_l. - apply exist_elim=> R. apply impl_intro_l. rewrite assoc persistently_and_sep_r.
rewrite assoc persistently_and_sep_r. by rewrite persistently_elim wand_elim_r.
by rewrite persistently_elim_absorbing wand_elim_r.
Qed. Qed.
End persistently_bare_bi. End persistently_bare_bi.
...@@ -1178,33 +1173,30 @@ Proof. destruct p; simpl; auto using bare_persistently_idemp. Qed. ...@@ -1178,33 +1173,30 @@ Proof. destruct p; simpl; auto using bare_persistently_idemp. Qed.
(* Persistence *) (* Persistence *)
Global Instance Persistent_proper : Proper (() ==> iff) (@Persistent PROP). Global Instance Persistent_proper : Proper (() ==> iff) (@Persistent PROP).
Proof. solve_proper. Qed. Proof. solve_proper. Qed.
Lemma persistent_absorbing P : Persistent P Absorbing P.
Proof. rewrite /Persistent=> <-. apply _. Qed.
Hint Immediate persistent_absorbing : typeclass_instances.
Global Instance pure_persistent φ : Persistent (⌜φ⌝%I : PROP). Global Instance pure_persistent φ : Persistent (⌜φ⌝%I : PROP).
Proof. by rewrite /Persistent persistently_pure. Qed. Proof. by rewrite /Persistent persistently_pure. Qed.
Global Instance emp_persistent `{AffineBI PROP} : Persistent (emp%I : PROP). Global Instance emp_persistent : Persistent (emp%I : PROP).
Proof. rewrite -True_emp. apply _. Qed. Proof. rewrite /Persistent. apply persistently_emp_intro. Qed.
Global Instance persistently_persistent P : Persistent ( P). Global Instance persistently_persistent P : Persistent ( P).
Proof. apply persistently_idemp. Qed. Proof. by rewrite /Persistent persistently_idemp. Qed.
Global Instance and_persistent P Q : Global Instance and_persistent P Q :
Persistent P Persistent Q Persistent (P Q). Persistent P Persistent Q Persistent (P Q).
Proof. intros. by rewrite /Persistent persistently_and !persistent. Qed. Proof. intros. by rewrite /Persistent persistently_and -!persistent. Qed.
Global Instance or_persistent P Q : Global Instance or_persistent P Q :
Persistent P Persistent Q Persistent (P Q). Persistent P Persistent Q Persistent (P Q).
Proof. intros. by rewrite /Persistent persistently_or !persistent. Qed. Proof. intros. by rewrite /Persistent persistently_or -!persistent. Qed.
Global Instance forall_persistent {A} (Ψ : A PROP) : Global Instance forall_persistent {A} (Ψ : A PROP) :
( x, Persistent (Ψ x)) Persistent ( x, Ψ x). ( x, Persistent (Ψ x)) Persistent ( x, Ψ x).
Proof. Proof.
intros. rewrite /Persistent persistently_forall. intros. rewrite /Persistent persistently_forall.
apply forall_proper=> x. by rewrite !persistent. apply forall_mono=> x. by rewrite -!persistent.
Qed. Qed.
Global Instance exist_persistent {A} (Ψ : A PROP) : Global Instance exist_persistent {A} (Ψ : A PROP) :
( x, Persistent (Ψ x)) Persistent ( x, Ψ x). ( x, Persistent (Ψ x)) Persistent ( x, Ψ x).
Proof. Proof.
intros. rewrite /Persistent persistently_exist. intros. rewrite /Persistent persistently_exist.
apply exist_proper=> x. by rewrite !persistent. apply exist_mono=> x. by rewrite -!persistent.
Qed. Qed.
Global Instance internal_eq_persistent {A : ofeT} (a b : A) : Global Instance internal_eq_persistent {A : ofeT} (a b : A) :
...@@ -1213,61 +1205,74 @@ Proof. by intros; rewrite /Persistent persistently_internal_eq. Qed. ...@@ -1213,61 +1205,74 @@ Proof. by intros; rewrite /Persistent persistently_internal_eq. Qed.
Global Instance pure_impl_persistent φ Q : Persistent Q Persistent (⌜φ⌝ Q). Global Instance pure_impl_persistent φ Q : Persistent Q Persistent (⌜φ⌝ Q).
Proof. rewrite pure_impl_forall. apply _. Qed. Proof. rewrite pure_impl_forall. apply _. Qed.
Global Instance pure_wand_persistent φ Q : Persistent Q Persistent (⌜φ⌝ - Q). Global Instance pure_wand_persistent φ Q :
Persistent Q Absorbing Q Persistent (⌜φ⌝ - Q).
Proof. intros. rewrite pure_wand_forall. apply _. Qed. Proof. intros. rewrite pure_wand_forall. apply _. Qed.
Global Instance sep_persistent P Q : Global Instance sep_persistent P Q :
Persistent P Persistent Q Persistent (P Q). Persistent P Persistent Q Persistent (P Q).
Proof. intros. by rewrite /Persistent persistently_sep !persistent. Qed. Proof. intros. by rewrite /Persistent persistently_sep -!persistent. Qed.
Global Instance from_option_persistent {A} P (Ψ : A PROP) (mx : option A) : Global Instance from_option_persistent {A} P (Ψ : A PROP) (mx : option A) :
( x, Persistent (Ψ x)) Persistent P Persistent (from_option Ψ P mx). ( x, Persistent (Ψ x)) Persistent P Persistent (from_option Ψ P mx).
Proof. destruct mx; apply _. Qed. Proof. destruct mx; apply _. Qed.
(* Properties of persistent propositions *) (* Properties of persistent propositions *)
Lemma persistent_persistently P `{!Persistent P} : P P. Lemma persistent_persistently_2 P `{!Persistent P} : P P.
Proof. by rewrite persistent. Qed. Proof. done. Qed.
Lemma persistent_persistently P `{!Persistent P, !Absorbing P} : P P.
Proof. apply (anti_symm _); auto using persistent_persistently_2, persistently_elim. Qed.
Lemma persistently_intro P Q `{!Persistent P} : (P Q) P Q. Lemma persistently_intro P Q `{!Persistent P} : (P Q) P Q.
Proof. rewrite -(persistent_persistently P); apply persistently_intro'. Qed. Proof. intros HP. by rewrite (persistent P) HP. Qed.
Lemma persistent_and_bare_sep_l_1 P Q `{!Persistent P} : P Q P Q.
Proof.
rewrite {1}(persistent_persistently_2 P) persistently_and_bare_sep_l.
by rewrite -bare_idemp bare_persistently_elim.
Qed.
Lemma persistent_and_bare_sep_r_1 P Q `{!Persistent Q} : P Q P Q.
Proof. by rewrite !(comm _ P) persistent_and_bare_sep_l_1. Qed.
Lemma persistent_and_sep_l_1 P Q `{!Persistent P} : P Q P Q. Lemma persistent_and_bare_sep_l P Q `{!Persistent P, !Absorbing P} :
Proof. by rewrite -(persistent_persistently P) persistently_and_sep_l_1. Qed. P Q P Q.
Lemma persistent_and_sep_r_1 P Q `{!Persistent Q} : P Q P Q. Proof. by rewrite -(persistent_persistently P) persistently_and_bare_sep_l. Qed.
Proof. by rewrite -(persistent_persistently Q) persistently_and_sep_r_1. Qed. Lemma persistent_and_bare_sep_r P Q `{!Persistent Q, !Absorbing Q} :
Lemma persistent_sep_and P Q `{!Persistent P, !Persistent Q} : P Q P Q. P Q P Q.
Proof. by rewrite -(persistent_persistently Q) persistently_and_bare_sep_r. Qed.
Lemma persistent_and_sep_1 P Q `{HPQ : !TCOr (Persistent P) (Persistent Q)} :
P Q P Q.
Proof. Proof.
by rewrite -(persistent_persistently P) -(persistent_persistently Q) destruct HPQ.
-and_sep_persistently. - by rewrite persistent_and_bare_sep_l_1 bare_elim.
- by rewrite persistent_and_bare_sep_r_1 bare_elim.
Qed. Qed.
Lemma persistent_sep_dup P `{!Persistent P} : P P P. Lemma persistent_sep_dup P `{!Persistent P, !Absorbing P} : P P P.
Proof. by rewrite -(persistent_persistently P) -persistently_sep_dup. Qed. Proof. by rewrite -(persistent_persistently P) -persistently_sep_dup. Qed.
Lemma persistent_entails_l P Q `{!Persistent Q} : (P Q) P Q P. Lemma persistent_entails_l P Q `{!Persistent Q} : (P Q) P Q P.
Proof. by rewrite -(persistent_persistently Q); apply persistently_entails_l. Qed. Proof. intros. rewrite -persistent_and_sep_1; auto. Qed.
Lemma persistent_entails_r P Q `{!Persistent Q} : (P Q) P P Q. Lemma persistent_entails_r P Q `{!Persistent Q} : (P Q) P P Q.
Proof. by rewrite -(persistent_persistently Q); apply persistently_entails_r. Qed. Proof. intros. rewrite -persistent_and_sep_1; auto. Qed.
Lemma persistent_and_sep_assoc P `{!Persistent P} Q R : Lemma persistent_and_sep_assoc P `{!Persistent P, !Absorbing P} Q R :
P (Q R) (P Q) R. P (Q R) (P Q) R.
Proof. by rewrite -(persistent P) persistently_and_sep_assoc. Qed. Proof. by rewrite -(persistent_persistently P) persistently_and_sep_assoc. Qed.