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,7 +38,7 @@ Proof. intros P. rewrite /Affine. by apply bi.pure_intro. Qed.
(* Own and valid derived *)
Lemma persistently_ownM (a : M) : CoreId a uPred_ownM a uPred_ownM a.
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.
Qed.
Lemma ownM_invalid (a : M) : ¬ {0} a uPred_ownM a False.
......@@ -49,7 +49,7 @@ Lemma ownM_unit' : uPred_ownM ε ⊣⊢ True.
Proof. apply (anti_symm _); first by apply pure_intro. apply ownM_empty. Qed.
Lemma persistently_cmra_valid {A : cmraT} (a : A) : a a.
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.
Qed.
......@@ -93,7 +93,7 @@ Qed.
(* Derived lemmas for persistence *)
Global Instance limit_preserving_Persistent {A:ofeT} `{Cofe A} (Φ : A uPred M) :
NonExpansive Φ LimitPreserving (λ x, Persistent (Φ x)).
Proof. intros. apply limit_preserving_equiv; solve_proper. Qed.
Proof. intros. apply limit_preserving_entails; solve_proper. Qed.
(* Persistence *)
Global Instance cmra_valid_persistent {A : cmraT} (a : A) :
......
......@@ -200,6 +200,6 @@ Section proofmode_classes.
FromAnd (own γ a) (own γ b1) (own γ b2).
Proof.
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.
End proofmode_classes.
......@@ -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).
Proof.
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.
Global Instance into_and_ownM p (a b1 b2 : M) :
......
......@@ -137,7 +137,7 @@ Section sep_list.
{ apply forall_intro=> k; apply forall_intro=> x.
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'|].
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.
- rewrite -IH. apply forall_intro=> k; by rewrite (forall_elim (S k)).
Qed.
......@@ -158,21 +158,13 @@ Section sep_list.
apply forall_intro=> k. by rewrite (forall_elim (S k)).
Qed.
Global Instance big_sepL_nil_persistent `{AffineBI PROP} Φ :
Global Instance big_sepL_nil_persistent Φ :
Persistent ([ list] kx [], Φ k x).
Proof. simpl; apply _. Qed.
Global Instance big_sepL_persistent1 Φ 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 :
Global Instance big_sepL_persistent Φ l :
( k x, Persistent (Φ k x)) Persistent ([ list] kx l, Φ k x).
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).
Proof. induction 1; simpl; apply _. Qed.
End sep_list.
......@@ -404,7 +396,7 @@ Section gmap.
{ apply forall_intro=> k; apply forall_intro=> x.
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'.
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.
by rewrite pure_True // True_impl.
- rewrite -IH. apply forall_mono=> k; apply forall_mono=> y.
......@@ -431,15 +423,14 @@ Section gmap.
by rewrite pure_True // True_impl.
Qed.
Global Instance big_sepM_empty_persistent `{AffineBI PROP} Φ :
Global Instance big_sepM_empty_persistent Φ :
Persistent ([ map] kx , Φ k x).
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).
Proof. intros. apply big_sepL_persistent=> _ [??]; apply _. Qed.
End gmap.
(** ** Big ops over finite sets *)
Section gset.
Context `{Countable A}.
......@@ -562,7 +553,7 @@ Section gset.
{ apply forall_intro=> x.
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'.
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.
- rewrite -IH. apply forall_mono=> y. apply impl_intro_l, pure_elim_l=> ?.
by rewrite pure_True ?True_impl; last set_solver.
......@@ -583,11 +574,10 @@ Section gset.
apply forall_mono=> y. apply impl_intro_l, pure_elim_l=> ?.
by rewrite pure_True ?True_impl; last set_solver.
Qed.
Global Instance big_sepS_empty_persistent `{AffineBI PROP} Φ :
Global Instance big_sepS_empty_persistent Φ :
Persistent ([ set] x , Φ x).
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).
Proof. rewrite /big_opS. apply _. Qed.
End gset.
......@@ -658,10 +648,10 @@ Section gmultiset.
([ mset] y X, Φ y) ([ mset] y X, Φ y).
Proof. apply (big_opMS_commute _). Qed.
Global Instance big_sepMS_empty_persistent `{AffineBI PROP} Φ :
Global Instance big_sepMS_empty_persistent Φ :
Persistent ([ mset] x , Φ x).
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).
Proof. rewrite /big_opMS. apply _. Qed.
End gmultiset.
......
......@@ -13,7 +13,7 @@ Arguments bi_wand_iff {_} _%I _%I : simpl never.
Instance: Params (@bi_wand_iff) 1.
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 {_}.
Hint Mode Persistent + ! : typeclass_instances.
......@@ -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.
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.
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.
Proof. rewrite /bi_bare. apply (anti_symm _); auto. Qed.
......@@ -881,29 +885,26 @@ Proof.
Qed.
Lemma persistently_and_emp_elim P : emp P P.
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.
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.
Qed.
Lemma persistently_elim_absorbing P `{!Absorbing P} : P P.
Proof. by rewrite persistently_elim sep_elim_l. Qed.
Lemma persistently_elim P `{!Absorbing P} : P P.
Proof. by rewrite persistently_elim_True sep_elim_l. Qed.
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.
Proof.
apply (anti_symm _); auto using persistently_idemp_1, persistently_idemp_2.
Qed.
Proof. apply (anti_symm _); auto using persistently_idemp_1, persistently_idemp_2. Qed.
Lemma persistently_intro' P Q : ( P Q) P Q.
Proof. intros <-. apply persistently_idemp_2. Qed.
Lemma persistently_pure φ : ⌜φ⌝ ⌜φ⌝.
Proof.
apply (anti_symm _).
- by rewrite persistently_elim sep_elim_l.
- apply pure_elim'=> Hφ.
apply (anti_symm _); first by rewrite persistently_elim.
apply pure_elim'=> Hφ.
trans ( x : False, True : PROP)%I; [by apply forall_intro|].
rewrite persistently_forall_2. auto using persistently_mono, pure_intro.
Qed.
......@@ -929,10 +930,8 @@ Qed.
Lemma persistently_internal_eq {A : ofeT} (a b : A) : (a b) a b.
Proof.
apply (anti_symm ()); auto using persistently_elim.
- rewrite persistently_elim. apply wand_elim_l'.
apply (internal_eq_rewrite' a b (λ b, True - a b)%I); auto using wand_intro_l.
- apply (internal_eq_rewrite' a b (λ b, (a b))%I); auto.
apply (anti_symm ()); first by rewrite persistently_elim.
apply (internal_eq_rewrite' a b (λ b, (a b))%I); auto.
rewrite -(internal_eq_refl emp%I a). apply persistently_emp_intro.
Qed.
......@@ -1017,30 +1016,26 @@ Section persistently_bare_bi.
Proof.
apply (anti_symm ()); auto using persistently_impl_wand_2.
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.
Lemma wand_alt P Q : (P - Q) R, R (P R Q).
Proof.
apply (anti_symm ()).
- rewrite -(right_id True%I bi_sep (P - Q)%I) -(exist_intro (P - Q)%I).
apply sep_mono_r. rewrite -persistently_pure.
apply persistently_intro', impl_intro_l.
apply sep_mono_r. rewrite -persistently_pure. apply persistently_intro', impl_intro_l.
by rewrite wand_elim_r persistently_pure right_id.
- apply exist_elim=> R. apply wand_intro_l.
rewrite assoc -persistently_and_sep_r.
by rewrite persistently_elim_absorbing impl_elim_r.
- apply exist_elim=> R. apply wand_intro_l. rewrite assoc -persistently_and_sep_r.
by rewrite persistently_elim impl_elim_r.
Qed.
Lemma impl_alt P Q : (P Q) R, R (P R - Q).
Proof.
apply (anti_symm ()).
- rewrite -(right_id True%I bi_and (P Q)%I) -(exist_intro (P Q)%I).
apply and_mono_r. rewrite -persistently_pure.
apply persistently_intro', wand_intro_l.
apply and_mono_r. rewrite -persistently_pure. apply persistently_intro', wand_intro_l.
by rewrite impl_elim_r persistently_pure right_id.
- apply exist_elim=> R. apply impl_intro_l.
rewrite assoc persistently_and_sep_r.
by rewrite persistently_elim_absorbing wand_elim_r.
- apply exist_elim=> R. apply impl_intro_l. rewrite assoc persistently_and_sep_r.
by rewrite persistently_elim wand_elim_r.
Qed.
End persistently_bare_bi.
......@@ -1178,33 +1173,30 @@ Proof. destruct p; simpl; auto using bare_persistently_idemp. Qed.
(* Persistence *)
Global Instance Persistent_proper : Proper (() ==> iff) (@Persistent PROP).
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).
Proof. by rewrite /Persistent persistently_pure. Qed.
Global Instance emp_persistent `{AffineBI PROP} : Persistent (emp%I : PROP).
Proof. rewrite -True_emp. apply _. Qed.
Global Instance emp_persistent : Persistent (emp%I : PROP).
Proof. rewrite /Persistent. apply persistently_emp_intro. Qed.
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 :
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 :
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) :
( x, Persistent (Ψ x)) Persistent ( x, Ψ x).
Proof.
intros. rewrite /Persistent persistently_forall.
apply forall_proper=> x. by rewrite !persistent.
apply forall_mono=> x. by rewrite -!persistent.
Qed.
Global Instance exist_persistent {A} (Ψ : A PROP) :
( x, Persistent (Ψ x)) Persistent ( x, Ψ x).
Proof.
intros. rewrite /Persistent persistently_exist.
apply exist_proper=> x. by rewrite !persistent.
apply exist_mono=> x. by rewrite -!persistent.
Qed.
Global Instance internal_eq_persistent {A : ofeT} (a b : A) :
......@@ -1213,61 +1205,74 @@ Proof. by intros; rewrite /Persistent persistently_internal_eq. Qed.
Global Instance pure_impl_persistent φ Q : Persistent Q Persistent (⌜φ⌝ Q).
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.
Global Instance sep_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) :
( x, Persistent (Ψ x)) Persistent P Persistent (from_option Ψ P mx).
Proof. destruct mx; apply _. Qed.
(* Properties of persistent propositions *)
Lemma persistent_persistently P `{!Persistent P} : P P.
Proof. by rewrite persistent. Qed.
Lemma persistent_persistently_2 P `{!Persistent P} : P P.
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.
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.
Proof. by rewrite -(persistent_persistently P) persistently_and_sep_l_1. Qed.
Lemma persistent_and_sep_r_1 P Q `{!Persistent Q} : P Q P Q.
Proof. by rewrite -(persistent_persistently Q) persistently_and_sep_r_1. Qed.
Lemma persistent_sep_and P Q `{!Persistent P, !Persistent Q} : P Q P Q.
Lemma persistent_and_bare_sep_l P Q `{!Persistent P, !Absorbing P} :
P Q P Q.
Proof. by rewrite -(persistent_persistently P) persistently_and_bare_sep_l. Qed.
Lemma persistent_and_bare_sep_r P Q `{!Persistent Q, !Absorbing 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.
by rewrite -(persistent_persistently P) -(persistent_persistently Q)
-and_sep_persistently.
destruct HPQ.
- by rewrite persistent_and_bare_sep_l_1 bare_elim.
- by rewrite persistent_and_bare_sep_r_1 bare_elim.
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.
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.
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.
Proof. by rewrite -(persistent P) persistently_and_sep_assoc. Qed.
Proof. by rewrite -(persistent_persistently P) persistently_and_sep_assoc. Qed.
Lemma impl_wand_2 P `{!Persistent P} Q : (P - Q) P Q.
Proof. apply impl_intro_l. by rewrite persistent_and_sep_l_1 wand_elim_r. Qed.
Lemma persistent_and_bare_sep_l P Q `{!Persistent P} : P Q P Q.
Proof. by rewrite -(persistent_persistently P) persistently_and_bare_sep_l. Qed.
Lemma persistent_and_bare_sep_r P Q `{!Persistent Q} : P Q P Q.
Proof. by rewrite -(persistent_persistently Q) persistently_and_bare_sep_r. Qed.
Proof. apply impl_intro_l. by rewrite persistent_and_sep_1 wand_elim_r. Qed.
Section persistent_bi_absorbing.
Context `{AffineBI PROP}.
Lemma persistent_and_sep_l P Q `{!Persistent P} : P Q P Q.
Proof. by rewrite -(persistent_persistently P) persistently_and_sep_l. Qed.
Lemma persistent_and_sep_r P Q `{!Persistent Q} : P Q P Q.
Proof. by rewrite -(persistent_persistently Q) persistently_and_sep_r. Qed.
Lemma persistent_and_sep P Q `{HPQ : !TCOr (Persistent P) (Persistent Q)} :
P Q P Q.
Proof.
destruct HPQ.
- by rewrite -(persistent_persistently P) persistently_and_sep_l.
- by rewrite -(persistent_persistently Q) persistently_and_sep_r.
Qed.
Lemma impl_wand P `{!Persistent P} Q : (P Q) (P - Q).
Proof. apply (anti_symm _); auto using impl_wand_1, impl_wand_2. Qed.
......@@ -1331,8 +1336,6 @@ Proof.
Qed.
End bi_derived.
Hint Immediate persistent_absorbing : typeclass_instances.
Section sbi_derived.
Context {PROP : sbi}.
Implicit Types φ : Prop.
......@@ -1418,7 +1421,7 @@ Lemma bare_persistently_if_later p P : ⬕?p ▷ P ⊢ ▷ ⬕?p P.
Proof. destruct p; simpl; auto using bare_persistently_later. Qed.
Global Instance later_persistent P : Persistent P Persistent ( P).
Proof. intros. by rewrite /Persistent -later_persistently persistent. Qed.
Proof. intros. by rewrite /Persistent {1}(persistent_persistently_2 P) later_persistently. Qed.
Global Instance later_absorbing P : Absorbing P Absorbing ( P).
Proof. intros ? Q. by rewrite {1}(later_intro Q) -later_sep absorbing. Qed.
......@@ -1606,10 +1609,8 @@ Proof.
Qed.
Global Instance persistently_timeless P : Timeless P Timeless ( P).
Proof.
intros; rewrite /Timeless.
rewrite /bi_except_0 later_persistently_1.
rewrite (timeless P) /bi_except_0 persistently_or {1}persistently_elim.
apply or_mono; last done. by rewrite sep_elim_l.
intros. rewrite /Timeless /bi_except_0 later_persistently_1.
by rewrite (timeless P) /bi_except_0 persistently_or {1}persistently_elim.
Qed.
Global Instance eq_timeless {A : ofeT} (a b : A) :
......
......@@ -51,8 +51,8 @@ Section fractional.
(** Fractional and logical connectives *)
Global Instance persistent_fractional P :
Persistent P Fractional (λ _, P).
Proof. intros HP q q'. by apply bi.persistent_sep_dup. Qed.
Persistent P Absorbing P Fractional (λ _, P).
Proof. intros ?? q q'. by apply bi.persistent_sep_dup. Qed.
Global Instance fractional_sep Φ Ψ :
Fractional Φ Fractional Ψ Fractional (λ q, Φ q Ψ q)%I.
......
......@@ -13,7 +13,7 @@ Global Instance into_internal_eq_internal_eq {A : ofeT} (x y : A) :
Proof. by rewrite /IntoInternalEq. Qed.
Global Instance into_internal_eq_persistently {A : ofeT} (x y : A) P :
IntoInternalEq P x y IntoInternalEq ( P) x y.
Proof. rewrite /IntoInternalEq=> ->. by rewrite persistently_elim_absorbing. Qed.
Proof. rewrite /IntoInternalEq=> ->. by rewrite persistently_elim. Qed.
Global Instance into_internal_eq_bare {A : ofeT} (x y : A) P :
IntoInternalEq P x y IntoInternalEq ( P) x y.
Proof. rewrite /IntoInternalEq=> ->. by rewrite bare_elim. Qed.
......@@ -87,7 +87,7 @@ Proof. rewrite /FromPure /IntoPure=> <- ->. by rewrite pure_impl impl_wand_2. Qe
Global Instance into_pure_bare P φ : IntoPure P φ IntoPure ( P) φ.
Proof. rewrite /IntoPure=> ->. apply bare_elim. Qed.
Global Instance into_pure_persistently P φ : IntoPure P φ IntoPure ( P) φ.
Proof. rewrite /IntoPure=> ->. apply: persistently_elim_absorbing. Qed.
Proof. rewrite /IntoPure=> ->. apply: persistently_elim. Qed.
(* FromPure *)
Global Instance from_pure_pure φ : @FromPure PROP ⌜φ⌝ φ.
......@@ -115,7 +115,7 @@ Proof. rewrite /FromPure=>Hx. rewrite pure_forall. by setoid_rewrite Hx. Qed.
Global Instance from_pure_pure_sep (φ1 φ2 : Prop) P1 P2 :
FromPure P1 φ1 FromPure P2 φ2 FromPure (P1 P2) (φ1 φ2).
Proof. rewrite /FromPure=> <- <-. by rewrite pure_and persistent_and_sep_l_1. Qed.
Proof. rewrite /FromPure=> <- <-. by rewrite pure_and persistent_and_sep_1. Qed.
Global Instance from_pure_pure_wand (φ1 φ2 : Prop) P1 P2 :
IntoPure P1 φ1 FromPure P2 φ2 FromPure (P1 - P2) (φ1 φ2).
Proof.
......@@ -140,7 +140,7 @@ Global Instance into_persistent_persistently P : IntoPersistent true P P | 1.
Proof. by rewrite /IntoPersistent. Qed.
Global Instance into_persistent_persistent P :
Persistent P IntoPersistent false P P | 100.
Proof. intros. by rewrite /IntoPersistent /= persistent_persistently. Qed.
Proof. intros. by rewrite /IntoPersistent. Qed.
(* FromPersistent *)
Global Instance from_persistent_persistently P : FromPersistent ( P) P | 1.
......@@ -169,7 +169,7 @@ Global Instance into_wand_impl_false_true P Q P' :
Proof.
rewrite /IntoWand /FromAssumption /= => ? HP. apply wand_intro_l.
rewrite -(bare_persistently_idemp P) HP.
by rewrite -persistently_and_bare_sep_l persistently_elim_absorbing impl_elim_r.
by rewrite -persistently_and_bare_sep_l persistently_elim impl_elim_r.
Qed.
Global Instance into_wand_impl_true_false P Q P' :
......@@ -205,7 +205,7 @@ Global Instance into_wand_persistently_true q R P Q :
Proof. by rewrite /IntoWand /= persistently_idemp. Qed.
Global Instance into_wand_persistently_false `{!AffineBI PROP} q R P Q :
IntoWand false q R P Q IntoWand false q ( R) P Q.
Proof. by rewrite /IntoWand persistently_elim_absorbing. Qed.
Proof. by rewrite /IntoWand persistently_elim. Qed.
Global Instance into_wand_bare_persistently p q R P Q :
IntoWand p q R P Q IntoWand p q ( R) P Q.
......@@ -217,17 +217,17 @@ Proof. by rewrite /FromAnd. Qed.
Global Instance from_and_sep_persistent_l P1 P1' P2 :
FromBare P1 P1' Persistent P1' FromAnd (P1 P2) P1' P2 | 9.
Proof.
rewrite /FromBare /FromAnd=> <- ?. by rewrite persistent_and_bare_sep_l.
rewrite /FromBare /FromAnd=> <- ?. by rewrite persistent_and_bare_sep_l_1.
Qed.
Global Instance from_and_sep_persistent_r P1 P2 P2' :
FromBare P2 P2' Persistent P2' FromAnd (P1 P2) P1 P2' | 10.
Proof.
rewrite /FromBare /FromAnd=> <- ?. by rewrite persistent_and_bare_sep_r.
rewrite /FromBare /FromAnd=> <- ?. by rewrite persistent_and_bare_sep_r_1.
Qed.
Global Instance from_and_sep_persistent P1 P2 :
Persistent P1 Persistent P2 FromAnd (P1 P2) P1 P2 | 11.
Proof.
rewrite /FromBare /FromAnd. intros ??. by rewrite -persistent_sep_and.
rewrite /FromBare /FromAnd. intros ??. by rewrite -persistent_and_sep_1.
Qed.
Global Instance from_and_pure φ ψ : @FromAnd PROP ⌜φ ψ⌝ ⌜φ⌝ ⌜ψ⌝.
......@@ -243,28 +243,21 @@ Global Instance from_and_persistently_sep P Q1 Q2 :
FromSep P Q1 Q2 FromAnd ( P) ( Q1) ( Q2) | 11.
Proof. rewrite /FromAnd=> <-. by rewrite -persistently_and persistently_and_sep. Qed.
Hint Extern 10 => assumption : typeclass_instances. (* TODO: move *)
Global Instance from_and_big_sepL_cons_persistent {A} (Φ : nat A PROP) x l :
Persistent (Φ 0 x)
FromAnd ([ list] k y x :: l, Φ k y) (Φ 0 x) ([ list] k y l, Φ (S k) y).
Proof. intros. by rewrite /FromAnd big_opL_cons persistent_and_sep_l_1. Qed.
Proof. intros. by rewrite /FromAnd big_opL_cons persistent_and_sep_1. Qed.
Global Instance from_and_big_sepL_app_persistent {A} (Φ : nat A PROP) l1 l2 :
( k y, Persistent (Φ k y))
FromAnd ([ list] k y l1 ++ l2, Φ k y)
([ list] k y l1, Φ k y) ([ list] k y l2, Φ (length l1 + k) y).
Proof.
intros. rewrite /FromAnd big_opL_app.
destruct (decide (l1 = [])) as [->|]; simpl.
- by rewrite left_id and_elim_r.