Commit f5a5f1f1 authored by Ralf Jung's avatar Ralf Jung
Browse files

Merge branch 'naught' into 'master'

The plainness modality

See merge request FP/iris-coq!71
parents 65bde879 3b226c83
...@@ -31,7 +31,7 @@ Context management ...@@ -31,7 +31,7 @@ Context management
- `iRevert (x1 ... xn) "selpat"` : revert the hypotheses given by the selection - `iRevert (x1 ... xn) "selpat"` : revert the hypotheses given by the selection
pattern `selpat` into wands, and the Coq level hypotheses/variables pattern `selpat` into wands, and the Coq level hypotheses/variables
`x1 ... xn` into universal quantifiers. Persistent hypotheses are wrapped into `x1 ... xn` into universal quantifiers. Persistent hypotheses are wrapped into
the always modality. the persistence modality.
- `iRename "H1" into "H2"` : rename the hypothesis `H1` into `H2`. - `iRename "H1" into "H2"` : rename the hypothesis `H1` into `H2`.
- `iSpecialize pm_trm` : instantiate universal quantifiers and eliminate - `iSpecialize pm_trm` : instantiate universal quantifiers and eliminate
implications/wands of a hypothesis `pm_trm`. See proof mode terms below. implications/wands of a hypothesis `pm_trm`. See proof mode terms below.
...@@ -162,8 +162,8 @@ Miscellaneous ...@@ -162,8 +162,8 @@ Miscellaneous
introduces pure connectives. introduces pure connectives.
- The proof mode adds hints to the core `eauto` database so that `eauto` - The proof mode adds hints to the core `eauto` database so that `eauto`
automatically introduces: conjunctions and disjunctions, universal and automatically introduces: conjunctions and disjunctions, universal and
existential quantifiers, implications and wand, always, later and update existential quantifiers, implications and wand, plainness, persistence, later
modalities, and pure connectives. and update modalities, and pure connectives.
Selection patterns Selection patterns
================== ==================
...@@ -207,7 +207,9 @@ appear at the top level: ...@@ -207,7 +207,9 @@ appear at the top level:
Items of the selection pattern can be prefixed with `$`, which cause them to Items of the selection pattern can be prefixed with `$`, which cause them to
be framed instead of cleared. be framed instead of cleared.
- `!%` : introduce a pure goal (and leave the proof mode). - `!%` : introduce a pure goal (and leave the proof mode).
- `!#` : introduce an always modality and clear the spatial context. - `!#` : introduce an persistence or plainness modality and clear the spatial
context. In case of a plainness modality, it will prune all persistent
hypotheses that are not plain.
- `!>` : introduce a modality. - `!>` : introduce a modality.
- `/=` : perform `simpl`. - `/=` : perform `simpl`.
- `//` : perform `try done` on all goals. - `//` : perform `try done` on all goals.
......
...@@ -149,6 +149,14 @@ Section list. ...@@ -149,6 +149,14 @@ Section list.
by rewrite persistently_impl_wand persistently_elim wand_elim_l. by rewrite persistently_impl_wand persistently_elim wand_elim_l.
Qed. Qed.
Global Instance big_sepL_nil_plain Φ : Plain ([ list] kx [], Φ k x).
Proof. simpl; apply _. Qed.
Global Instance big_sepL_plain Φ l :
( k x, Plain (Φ k x)) Plain ([ list] kx l, Φ k x).
Proof. revert Φ. induction l as [|x l IH]=> Φ ? /=; apply _. Qed.
Global Instance big_sepL_plain_id Ps : TCForall Plain Ps Plain ([] Ps).
Proof. induction 1; simpl; apply _. Qed.
Global Instance big_sepL_nil_persistent Φ : Global Instance big_sepL_nil_persistent Φ :
Persistent ([ list] kx [], Φ k x). Persistent ([ list] kx [], Φ k x).
Proof. simpl; apply _. Qed. Proof. simpl; apply _. Qed.
...@@ -342,12 +350,19 @@ Section gmap. ...@@ -342,12 +350,19 @@ Section gmap.
by rewrite persistently_impl_wand persistently_elim wand_elim_l. by rewrite persistently_impl_wand persistently_elim wand_elim_l.
Qed. Qed.
Global Instance big_sepM_empty_plain Φ : Plain ([ map] kx , Φ k x).
Proof. rewrite /big_opM map_to_list_empty. apply _. Qed.
Global Instance big_sepM_plain Φ m :
( k x, Plain (Φ k x)) Plain ([ map] kx m, Φ k x).
Proof. intros. apply big_sepL_plain=> _ [??]; apply _. Qed.
Global Instance big_sepM_empty_persistent Φ : 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 Φ 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.
Global Instance big_sepM_nil_timeless Φ : Global Instance big_sepM_nil_timeless Φ :
Timeless ([ map] kx , Φ k x). Timeless ([ map] kx , Φ k x).
Proof. rewrite /big_opM map_to_list_empty. apply _. Qed. Proof. rewrite /big_opM map_to_list_empty. apply _. Qed.
...@@ -490,11 +505,18 @@ Section gset. ...@@ -490,11 +505,18 @@ Section gset.
by rewrite persistently_impl_wand persistently_elim wand_elim_l. by rewrite persistently_impl_wand persistently_elim wand_elim_l.
Qed. Qed.
Global Instance big_sepS_empty_plain Φ : Plain ([ set] x , Φ x).
Proof. rewrite /big_opS elements_empty. apply _. Qed.
Global Instance big_sepS_plain Φ X :
( x, Plain (Φ x)) Plain ([ set] x X, Φ x).
Proof. rewrite /big_opS. apply _. Qed.
Global Instance big_sepS_empty_persistent Φ : Persistent ([ set] x , Φ x). Global Instance big_sepS_empty_persistent Φ : 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 Φ 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.
Global Instance big_sepS_nil_timeless Φ : Timeless ([ set] x , Φ x). Global Instance big_sepS_nil_timeless Φ : Timeless ([ set] x , Φ x).
Proof. rewrite /big_opS elements_empty. apply _. Qed. Proof. rewrite /big_opS elements_empty. apply _. Qed.
Global Instance big_sepS_timeless Φ X : Global Instance big_sepS_timeless Φ X :
...@@ -578,11 +600,18 @@ Section gmultiset. ...@@ -578,11 +600,18 @@ Section gmultiset.
?q ([ mset] y X, Φ y) ([ mset] y X, ?q Φ y). ?q ([ mset] y X, Φ y) ([ mset] y X, ?q Φ y).
Proof. apply (big_opMS_commute _). Qed. Proof. apply (big_opMS_commute _). Qed.
Global Instance big_sepMS_empty_plain Φ : Plain ([ mset] x , Φ x).
Proof. rewrite /big_opMS gmultiset_elements_empty. apply _. Qed.
Global Instance big_sepMS_plain Φ X :
( x, Plain (Φ x)) Plain ([ mset] x X, Φ x).
Proof. rewrite /big_opMS. apply _. Qed.
Global Instance big_sepMS_empty_persistent Φ : Persistent ([ mset] x , Φ x). Global Instance big_sepMS_empty_persistent Φ : 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 Φ 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.
Global Instance big_sepMS_nil_timeless Φ : Timeless ([ mset] x , Φ x). Global Instance big_sepMS_nil_timeless Φ : Timeless ([ 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_timeless Φ X : Global Instance big_sepMS_timeless Φ X :
......
...@@ -39,6 +39,11 @@ Arguments persistent {_} _ {_}. ...@@ -39,6 +39,11 @@ Arguments persistent {_} _ {_}.
Hint Mode Persistent + ! : typeclass_instances. Hint Mode Persistent + ! : typeclass_instances.
Instance: Params (@Persistent) 1. Instance: Params (@Persistent) 1.
Class Plain {M} (P : uPred M) := plain : P P.
Arguments plain {_} _ {_}.
Hint Mode Plain + ! : typeclass_instances.
Instance: Params (@Plain) 1.
Module uPred. Module uPred.
Section derived. Section derived.
Context {M : ucmraT}. Context {M : ucmraT}.
...@@ -471,6 +476,104 @@ Proof. by apply forall_intro=> a; rewrite forall_elim. Qed. ...@@ -471,6 +476,104 @@ Proof. by apply forall_intro=> a; rewrite forall_elim. Qed.
Lemma sep_forall_r {A} (Φ : A uPred M) Q : ( a, Φ a) Q a, Φ a Q. Lemma sep_forall_r {A} (Φ : A uPred M) Q : ( a, Φ a) Q a, Φ a Q.
Proof. by apply forall_intro=> a; rewrite forall_elim. Qed. Proof. by apply forall_intro=> a; rewrite forall_elim. Qed.
(* Plainness modality *)
Global Instance plainly_mono' : Proper (() ==> ()) (@uPred_plainly M).
Proof. intros P Q; apply plainly_mono. Qed.
Global Instance naugth_flip_mono' :
Proper (flip () ==> flip ()) (@uPred_plainly M).
Proof. intros P Q; apply plainly_mono. Qed.
Lemma plainly_elim P : P P.
Proof. by rewrite plainly_elim' persistently_elim. Qed.
Hint Resolve plainly_mono plainly_elim.
Lemma plainly_intro' P Q : ( P Q) P Q.
Proof. intros <-. apply plainly_idemp. Qed.
Lemma plainly_idemp P : P P.
Proof. apply (anti_symm _); auto using plainly_idemp. Qed.
Lemma persistently_plainly P : P P.
Proof.
apply (anti_symm _); auto using persistently_elim.
by rewrite -plainly_elim' plainly_idemp.
Qed.
Lemma plainly_persistently P : P P.
Proof.
apply (anti_symm _); auto using plainly_mono, persistently_elim.
by rewrite -plainly_elim' plainly_idemp.
Qed.
Lemma plainly_pure φ : ⌜φ⌝ ⌜φ⌝.
Proof.
apply (anti_symm _); auto.
apply pure_elim'=> Hφ.
trans ( x : False, True : uPred M)%I; [by apply forall_intro|].
rewrite plainly_forall_2. auto using plainly_mono, pure_intro.
Qed.
Lemma plainly_forall {A} (Ψ : A uPred M) : ( a, Ψ a) ( a, Ψ a).
Proof.
apply (anti_symm _); auto using plainly_forall_2.
apply forall_intro=> x. by rewrite (forall_elim x).
Qed.
Lemma plainly_exist {A} (Ψ : A uPred M) : ( a, Ψ a) ( a, Ψ a).
Proof.
apply (anti_symm _); auto using plainly_exist_1.
apply exist_elim=> x. by rewrite (exist_intro x).
Qed.
Lemma plainly_and P Q : (P Q) P Q.
Proof. rewrite !and_alt plainly_forall. by apply forall_proper=> -[]. Qed.
Lemma plainly_or P Q : (P Q) P Q.
Proof. rewrite !or_alt plainly_exist. by apply exist_proper=> -[]. Qed.
Lemma plainly_impl P Q : (P Q) P Q.
Proof.
apply impl_intro_l; rewrite -plainly_and.
apply plainly_mono, impl_elim with P; auto.
Qed.
Lemma plainly_internal_eq {A:ofeT} (a b : A) : (a b) a b.
Proof.
apply (anti_symm ()); auto using persistently_elim.
apply (internal_eq_rewrite a b (λ b, (a b))%I); auto.
{ intros n; solve_proper. }
rewrite -(internal_eq_refl a) plainly_pure; auto.
Qed.
Lemma plainly_and_sep_l_1 P Q : P Q P Q.
Proof. by rewrite -persistently_plainly persistently_and_sep_l_1. Qed.
Lemma plainly_and_sep_l' P Q : P Q P Q.
Proof. apply (anti_symm ()); auto using plainly_and_sep_l_1. Qed.
Lemma plainly_and_sep_r' P Q : P Q P Q.
Proof. by rewrite !(comm _ P) plainly_and_sep_l'. Qed.
Lemma plainly_sep_dup' P : P P P.
Proof. by rewrite -plainly_and_sep_l' idemp. Qed.
Lemma plainly_and_sep P Q : (P Q) (P Q).
Proof.
apply (anti_symm ()); auto.
rewrite -{1}plainly_idemp plainly_and plainly_and_sep_l'; auto.
Qed.
Lemma plainly_sep P Q : (P Q) P Q.
Proof. by rewrite -plainly_and_sep -plainly_and_sep_l' plainly_and. Qed.
Lemma plainly_wand P Q : (P - Q) P - Q.
Proof. by apply wand_intro_r; rewrite -plainly_sep wand_elim_l. Qed.
Lemma plainly_impl_wand P Q : (P Q) (P - Q).
Proof.
apply (anti_symm ()); [by rewrite -impl_wand_1|].
apply plainly_intro', impl_intro_r.
by rewrite plainly_and_sep_l' plainly_elim wand_elim_l.
Qed.
Lemma wand_impl_plainly P Q : ( P - Q) ( P Q).
Proof.
apply (anti_symm ()); [|by rewrite -impl_wand_1].
apply impl_intro_l. by rewrite plainly_and_sep_l' wand_elim_r.
Qed.
Lemma plainly_entails_l' P Q : (P Q) P Q P.
Proof. intros; rewrite -plainly_and_sep_l'; auto. Qed.
Lemma plainly_entails_r' P Q : (P Q) P P Q.
Proof. intros; rewrite -plainly_and_sep_r'; auto. Qed.
Lemma plainly_laterN n P : ^n P ^n P.
Proof. induction n as [|n IH]; simpl; auto. by rewrite plainly_later IH. Qed.
(* Always derived *) (* Always derived *)
Hint Resolve persistently_mono persistently_elim. Hint Resolve persistently_mono persistently_elim.
Global Instance persistently_mono' : Proper (() ==> ()) (@uPred_persistently M). Global Instance persistently_mono' : Proper (() ==> ()) (@uPred_persistently M).
...@@ -485,12 +588,7 @@ Lemma persistently_idemp P : □ □ P ⊣⊢ □ P. ...@@ -485,12 +588,7 @@ Lemma persistently_idemp P : □ □ P ⊣⊢ □ P.
Proof. apply (anti_symm _); auto using persistently_idemp_2. Qed. Proof. apply (anti_symm _); auto using persistently_idemp_2. Qed.
Lemma persistently_pure φ : ⌜φ⌝ ⌜φ⌝. Lemma persistently_pure φ : ⌜φ⌝ ⌜φ⌝.
Proof. Proof. by rewrite -plainly_pure persistently_plainly. Qed.
apply (anti_symm _); auto.
apply pure_elim'=> Hφ.
trans ( x : False, True : uPred M)%I; [by apply forall_intro|].
rewrite persistently_forall_2. auto using persistently_mono, pure_intro.
Qed.
Lemma persistently_forall {A} (Ψ : A uPred M) : ( a, Ψ a) ( a, Ψ a). Lemma persistently_forall {A} (Ψ : A uPred M) : ( a, Ψ a) ( a, Ψ a).
Proof. Proof.
apply (anti_symm _); auto using persistently_forall_2. apply (anti_symm _); auto using persistently_forall_2.
...@@ -511,12 +609,7 @@ Proof. ...@@ -511,12 +609,7 @@ Proof.
apply persistently_mono, impl_elim with P; auto. apply persistently_mono, impl_elim with P; auto.
Qed. 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. by rewrite -plainly_internal_eq persistently_plainly. Qed.
apply (anti_symm ()); auto using persistently_elim.
apply (internal_eq_rewrite a b (λ b, (a b))%I); auto.
{ intros n; solve_proper. }
rewrite -(internal_eq_refl a) persistently_pure; auto.
Qed.
Lemma persistently_and_sep_l P Q : P Q P Q. Lemma persistently_and_sep_l P Q : P Q P Q.
Proof. apply (anti_symm ()); auto using persistently_and_sep_l_1. Qed. Proof. apply (anti_symm ()); auto using persistently_and_sep_l_1. Qed.
...@@ -616,7 +709,6 @@ Proof. apply wand_intro_r; rewrite -later_sep; eauto using wand_elim_l. Qed. ...@@ -616,7 +709,6 @@ Proof. apply wand_intro_r; rewrite -later_sep; eauto using wand_elim_l. Qed.
Lemma later_iff P Q : (P Q) P Q. Lemma later_iff P Q : (P Q) P Q.
Proof. by rewrite /uPred_iff later_and !later_impl. Qed. Proof. by rewrite /uPred_iff later_and !later_impl. Qed.
(* Iterated later modality *) (* Iterated later modality *)
Global Instance laterN_ne m : NonExpansive (@uPred_laterN M m). Global Instance laterN_ne m : NonExpansive (@uPred_laterN M m).
Proof. induction m; simpl. by intros ???. solve_proper. Qed. Proof. induction m; simpl. by intros ???. solve_proper. Qed.
...@@ -747,6 +839,8 @@ Lemma except_0_persistently P : ◇ □ P ⊣⊢ □ ◇ P. ...@@ -747,6 +839,8 @@ Lemma except_0_persistently P : ◇ □ P ⊣⊢ □ ◇ P.
Proof. by rewrite /uPred_except_0 persistently_or persistently_later persistently_pure. Qed. Proof. by rewrite /uPred_except_0 persistently_or persistently_later persistently_pure. Qed.
Lemma except_0_persistently_if p P : ?p P ?p P. Lemma except_0_persistently_if p P : ?p P ?p P.
Proof. destruct p; simpl; auto using except_0_persistently. Qed. Proof. destruct p; simpl; auto using except_0_persistently. Qed.
Lemma except_0_plainly P : P P.
Proof. by rewrite /uPred_except_0 plainly_or plainly_later plainly_pure. Qed.
Lemma except_0_frame_l P Q : P Q (P Q). Lemma except_0_frame_l P Q : P Q (P Q).
Proof. by rewrite {1}(except_0_intro P) except_0_sep. Qed. Proof. by rewrite {1}(except_0_intro P) except_0_sep. Qed.
Lemma except_0_frame_r P Q : P Q (P Q). Lemma except_0_frame_r P Q : P Q (P Q).
...@@ -764,11 +858,10 @@ Global Instance ownM_mono : Proper (flip (≼) ==> (⊢)) (@uPred_ownM M). ...@@ -764,11 +858,10 @@ Global Instance ownM_mono : Proper (flip (≼) ==> (⊢)) (@uPred_ownM M).
Proof. intros a b [b' ->]. rewrite ownM_op. eauto. Qed. Proof. intros a b [b' ->]. rewrite ownM_op. eauto. Qed.
Lemma ownM_unit' : uPred_ownM ε True. Lemma ownM_unit' : uPred_ownM ε True.
Proof. apply (anti_symm _); first by auto. apply ownM_unit. Qed. Proof. apply (anti_symm _); first by auto. apply ownM_unit. Qed.
Lemma plainly_cmra_valid {A : cmraT} (a : A) : a a.
Proof. apply (anti_symm _); auto using plainly_elim, plainly_cmra_valid_1. Qed.
Lemma persistently_cmra_valid {A : cmraT} (a : A) : a a. Lemma persistently_cmra_valid {A : cmraT} (a : A) : a a.
Proof. Proof. by rewrite -plainly_cmra_valid persistently_plainly. Qed.
intros; apply (anti_symm _); first by apply:persistently_elim.
apply:persistently_cmra_valid_1.
Qed.
(** * Derived rules *) (** * Derived rules *)
Global Instance bupd_mono' : Proper (() ==> ()) (@uPred_bupd M). Global Instance bupd_mono' : Proper (() ==> ()) (@uPred_bupd M).
...@@ -860,6 +953,25 @@ Global Instance from_option_timeless {A} P (Ψ : A → uPred M) (mx : option A) ...@@ -860,6 +953,25 @@ Global Instance from_option_timeless {A} P (Ψ : A → uPred M) (mx : option A)
( x, Timeless (Ψ x)) Timeless P Timeless (from_option Ψ P mx). ( x, Timeless (Ψ x)) Timeless P Timeless (from_option Ψ P mx).
Proof. destruct mx; apply _. Qed. Proof. destruct mx; apply _. Qed.
(* Derived lemmas for plainness *)
Global Instance Plain_proper : Proper (() ==> iff) (@Plain M).
Proof. solve_proper. Qed.
Global Instance limit_preserving_Plain {A:ofeT} `{Cofe A} (Φ : A uPred M) :
NonExpansive Φ LimitPreserving (λ x, Plain (Φ x)).
Proof. intros. apply limit_preserving_entails; solve_proper. Qed.
(* Not an instance, see the bottom of this file *)
Lemma plain_persistent P : Plain P Persistent P.
Proof. rewrite /Plain /Persistent=> HP. by rewrite {1}HP plainly_elim'. Qed.
Lemma plainly_plainly P `{!Plain P} : P P.
Proof. apply (anti_symm ()); eauto. Qed.
Lemma plainly_intro P Q `{!Plain P} : (P Q) P Q.
Proof. rewrite -(plainly_plainly P); apply plainly_intro'. Qed.
Lemma bupd_plain P `{!Plain P} : (|==> P) P.
Proof. by rewrite -{1}(plainly_plainly P) bupd_plainly. Qed.
(* Derived lemmas for persistence *) (* Derived lemmas for persistence *)
Global Instance Persistent_proper : Proper (() ==> iff) (@Persistent M). Global Instance Persistent_proper : Proper (() ==> iff) (@Persistent M).
Proof. solve_proper. Qed. Proof. solve_proper. Qed.
...@@ -889,20 +1001,71 @@ Proof. ...@@ -889,20 +1001,71 @@ Proof.
apply impl_intro_l. by rewrite and_sep_l wand_elim_r. apply impl_intro_l. by rewrite and_sep_l wand_elim_r.
Qed. Qed.
(* Plain *)
Global Instance pure_plain φ : Plain (⌜φ⌝ : uPred M)%I.
Proof. by rewrite /Plain plainly_pure. Qed.
Global Instance impl_plain P Q : Plain P Plain Q Plain (P Q).
Proof.
rewrite /Plain=> HP HQ.
by rewrite {2}HP -plainly_impl_plainly -HQ plainly_elim.
Qed.
Global Instance wand_plain P Q : Plain P Plain Q Plain (P - Q)%I.
Proof.
rewrite /Plain=> HP HQ.
by rewrite {2}HP -{1}(plainly_elim P) !wand_impl_plainly -plainly_impl_plainly -HQ.
Qed.
Global Instance plainly_plain P : Plain ( P).
Proof. by intros; apply plainly_intro'. Qed.
Global Instance persistently_plain P : Plain P Plain ( P).
Proof. rewrite /Plain=> HP. by rewrite {1}HP persistently_plainly plainly_persistently. Qed.
Global Instance and_plain P Q :
Plain P Plain Q Plain (P Q).
Proof. by intros; rewrite /Plain plainly_and; apply and_mono. Qed.
Global Instance or_plain P Q :
Plain P Plain Q Plain (P Q).
Proof. by intros; rewrite /Plain plainly_or; apply or_mono. Qed.
Global Instance sep_plain P Q :
Plain P Plain Q Plain (P Q).
Proof. by intros; rewrite /Plain plainly_sep; apply sep_mono. Qed.
Global Instance forall_plain {A} (Ψ : A uPred M) :
( x, Plain (Ψ x)) Plain ( x, Ψ x).
Proof. by intros; rewrite /Plain plainly_forall; apply forall_mono. Qed.
Global Instance exist_palin {A} (Ψ : A uPred M) :
( x, Plain (Ψ x)) Plain ( x, Ψ x).
Proof. by intros; rewrite /Plain plainly_exist; apply exist_mono. Qed.
Global Instance internal_eq_plain {A : ofeT} (a b : A) :
Plain (a b : uPred M)%I.
Proof. by intros; rewrite /Plain plainly_internal_eq. Qed.
Global Instance cmra_valid_plain {A : cmraT} (a : A) :
Plain ( a : uPred M)%I.
Proof. by intros; rewrite /Plain; apply plainly_cmra_valid_1. Qed.
Global Instance later_plain P : Plain P Plain ( P).
Proof. by intros; rewrite /Plain plainly_later; apply later_mono. Qed.
Global Instance except_0_plain P : Plain P Plain ( P).
Proof. by intros; rewrite /Plain -except_0_plainly; apply except_0_mono. Qed.
Global Instance laterN_plain n P : Plain P Plain (^n P).
Proof. induction n; apply _. Qed.
Global Instance from_option_palin {A} P (Ψ : A uPred M) (mx : option A) :
( x, Plain (Ψ x)) Plain P Plain (from_option Ψ P mx).
Proof. destruct mx; apply _. Qed.
(* Persistence *) (* Persistence *)
Global Instance pure_persistent φ : Persistent (⌜φ⌝ : uPred M)%I. Global Instance pure_persistent φ : Persistent (⌜φ⌝ : uPred M)%I.
Proof. by rewrite /Persistent persistently_pure. Qed. Proof. by rewrite /Persistent persistently_pure. Qed.
Global Instance pure_impl_persistent φ Q : Global Instance impl_persistent P Q :
Persistent Q Persistent (⌜φ⌝ Q)%I. Plain P Persistent Q Persistent (P Q).
Proof. Proof.
rewrite /Persistent pure_impl_forall persistently_forall. auto using forall_mono. rewrite /Plain /Persistent=> HP HQ.
rewrite {2}HP -persistently_impl_plainly. by rewrite -HQ plainly_elim.
Qed. Qed.
Global Instance pure_wand_persistent φ Q : Global Instance wand_persistent P Q :
Persistent Q Persistent (⌜φ⌝ - Q)%I. Plain P Persistent Q Persistent (P - Q)%I.
Proof. Proof.
rewrite /Persistent -impl_wand pure_impl_forall persistently_forall. rewrite /Plain /Persistent=> HP HQ.
auto using forall_mono. by rewrite {2}HP -{1}(plainly_elim P) !wand_impl_plainly -persistently_impl_plainly -HQ.
Qed. Qed.
Global Instance plainly_persistent P : Persistent ( P).
Proof. by rewrite /Persistent persistently_plainly. Qed.
Global Instance persistently_persistent P : Persistent ( P). Global Instance persistently_persistent P : Persistent ( P).
Proof. by intros; apply persistently_intro'. Qed. Proof. by intros; apply persistently_intro'. Qed.
Global Instance and_persistent P Q : Global Instance and_persistent P Q :
...@@ -930,6 +1093,8 @@ Global Instance later_persistent P : Persistent P → Persistent (▷ P). ...@@ -930,6 +1093,8 @@ Global Instance later_persistent P : Persistent P → Persistent (▷ P).
Proof. by intros; rewrite /Persistent persistently_later; apply later_mono. Qed. Proof. by intros; rewrite /Persistent persistently_later; apply later_mono. Qed.
Global Instance laterN_persistent n P : Persistent P Persistent (^n P). Global Instance laterN_persistent n P : Persistent P Persistent (^n P).
Proof. induction n; apply _. Qed. Proof. induction n; apply _. Qed.
Global Instance except_0_persistent P : Persistent P Persistent ( P).
Proof. by intros; rewrite /Persistent -except_0_persistently; apply except_0_mono. Qed.
Global Instance ownM_persistent : CoreId a Persistent (@uPred_ownM M a). Global Instance ownM_persistent : CoreId a Persistent (@uPred_ownM M a).
Proof. intros. by rewrite /Persistent persistently_ownM. Qed. Proof. intros. by rewrite /Persistent persistently_ownM. Qed.
Global Instance from_option_persistent {A} P (Ψ : A uPred M) (mx : option A) : Global Instance from_option_persistent {A} P (Ψ : A uPred M) (mx : option A) :
...@@ -947,6 +1112,9 @@ Global Instance uPred_sep_monoid : Monoid (@uPred_sep M) := ...@@ -947,6 +1112,9 @@ Global Instance uPred_sep_monoid : Monoid (@uPred_sep M) :=
Global Instance uPred_persistently_and_homomorphism : Global Instance uPred_persistently_and_homomorphism :
MonoidHomomorphism uPred_and uPred_and () (@uPred_persistently M). MonoidHomomorphism uPred_and uPred_and () (@uPred_persistently M).
Proof. split; [split; try apply _|]. apply persistently_and. apply persistently_pure. Qed. Proof. split; [split; try apply _|]. apply persistently_and. apply persistently_pure. Qed.
Global Instance uPred_plainly_and_homomorphism :
MonoidHomomorphism uPred_and uPred_and () (@uPred_plainly M).
Proof. split; [split; try apply _|]. apply plainly_and. apply plainly_pure. Qed.
Global Instance uPred_persistently_if_and_homomorphism b : Global Instance uPred_persistently_if_and_homomorphism b :
MonoidHomomorphism uPred_and uPred_and () (@uPred_persistently_if M b). MonoidHomomorphism uPred_and uPred_and () (@uPred_persistently_if M b).
Proof. split; [split; try apply _|]. apply persistently_if_and. apply persistently_if_pure. Qed. Proof. split; [split; try apply _|]. apply persistently_if_and. apply persistently_if_pure. Qed.
...@@ -963,6 +1131,9 @@ Proof. split; [split; try apply _|]. apply except_0_and. apply except_0_True. Qe ...@@ -963,6 +1131,9 @@ Proof. split; [split; try apply _|]. apply except_0_and. apply except_0_True. Qe
Global Instance uPred_persistently_or_homomorphism : Global Instance uPred_persistently_or_homomorphism :
MonoidHomomorphism uPred_or uPred_or () (@uPred_persistently M). MonoidHomomorphism uPred_or uPred_or () (@uPred_persistently M).
Proof. split; [split; try apply _|]. apply persistently_or. apply persistently_pure. Qed. Proof. split; [split; try apply _|]. apply persistently_or. apply persistently_pure. Qed.
Global Instance uPred_plainly_or_homomorphism :
MonoidHomomorphism uPred_or uPred_or () (@uPred_plainly M).
Proof. split; [split; try apply _|]. apply plainly_or. apply plainly_pure. Qed.
Global Instance uPred_persistently_if_or_homomorphism b : Global Instance uPred_persistently_if_or_homomorphism b :
MonoidHomomorphism uPred_or uPred_or () (@uPred_persistently_if M b). MonoidHomomorphism uPred_or uPred_or () (@uPred_persistently_if M b).
Proof. split; [split; try apply _|]. apply persistently_if_or. apply persistently_if_pure. Qed. Proof. split; [split; try apply _|]. apply persistently_if_or. apply persistently_if_pure. Qed.
...@@ -974,11 +1145,14 @@ Global Instance uPred_laterN_or_homomorphism n : ...@@ -974,11 +1145,14 @@ Global Instance uPred_laterN_or_homomorphism n :
Proof. split; try apply _. apply laterN_or. Qed. Proof. split; try apply _. apply laterN_or. Qed.
Global Instance uPred_except_0_or_homomorphism : Global Instance uPred_except_0_or_homomorphism :
WeakMonoidHomomorphism uPred_or uPred_or () (@uPred_except_0 M).