derived.v 44.9 KB
 Robbert Krebbers committed Oct 25, 2016 1 ``````From iris.base_logic Require Export primitive. `````` Ralf Jung committed Jan 05, 2017 2 ``````Set Default Proof Using "Type". `````` Robbert Krebbers committed Dec 13, 2016 3 ``````Import upred.uPred primitive.uPred. `````` Robbert Krebbers committed Oct 25, 2016 4 5 6 7 8 `````` Definition uPred_iff {M} (P Q : uPred M) : uPred M := ((P → Q) ∧ (Q → P))%I. Instance: Params (@uPred_iff) 1. Infix "↔" := uPred_iff : uPred_scope. `````` Robbert Krebbers committed Nov 27, 2016 9 10 11 12 13 14 15 16 17 18 ``````Definition uPred_laterN {M} (n : nat) (P : uPred M) : uPred M := Nat.iter n uPred_later P. Instance: Params (@uPred_laterN) 2. Notation "▷^ n P" := (uPred_laterN n P) (at level 20, n at level 9, P at level 20, format "▷^ n P") : uPred_scope. Notation "▷? p P" := (uPred_laterN (Nat.b2n p) P) (at level 20, p at level 9, P at level 20, format "▷? p P") : uPred_scope. `````` Robbert Krebbers committed Oct 25, 2016 19 20 21 22 23 ``````Definition uPred_always_if {M} (p : bool) (P : uPred M) : uPred M := (if p then □ P else P)%I. Instance: Params (@uPred_always_if) 2. Arguments uPred_always_if _ !_ _/. Notation "□? p P" := (uPred_always_if p P) `````` Robbert Krebbers committed Nov 27, 2016 24 `````` (at level 20, p at level 9, P at level 20, format "□? p P"). `````` Robbert Krebbers committed Oct 25, 2016 25 `````` `````` Robbert Krebbers committed Oct 25, 2016 26 27 ``````Definition uPred_except_0 {M} (P : uPred M) : uPred M := ▷ False ∨ P. Notation "◇ P" := (uPred_except_0 P) `````` Robbert Krebbers committed Oct 25, 2016 28 `````` (at level 20, right associativity) : uPred_scope. `````` Robbert Krebbers committed Oct 25, 2016 29 30 ``````Instance: Params (@uPred_except_0) 1. Typeclasses Opaque uPred_except_0. `````` Robbert Krebbers committed Oct 25, 2016 31 32 33 `````` Class TimelessP {M} (P : uPred M) := timelessP : ▷ P ⊢ ◇ P. Arguments timelessP {_} _ {_}. `````` Robbert Krebbers committed Jan 22, 2017 34 ``````Hint Mode TimelessP + ! : typeclass_instances. `````` Robbert Krebbers committed Feb 11, 2017 35 ``````Instance: Params (@TimelessP) 1. `````` Robbert Krebbers committed Oct 25, 2016 36 37 38 `````` Class PersistentP {M} (P : uPred M) := persistentP : P ⊢ □ P. Arguments persistentP {_} _ {_}. `````` Robbert Krebbers committed Jan 22, 2017 39 ``````Hint Mode PersistentP + ! : typeclass_instances. `````` Robbert Krebbers committed Feb 11, 2017 40 ``````Instance: Params (@PersistentP) 1. `````` Robbert Krebbers committed Oct 25, 2016 41 `````` `````` Robbert Krebbers committed Dec 13, 2016 42 ``````Module uPred. `````` Robbert Krebbers committed Oct 25, 2016 43 44 45 46 47 48 49 50 51 52 ``````Section derived. Context {M : ucmraT}. Implicit Types φ : Prop. Implicit Types P Q : uPred M. Implicit Types A : Type. Notation "P ⊢ Q" := (@uPred_entails M P%I Q%I). (* Force implicit argument M *) Notation "P ⊣⊢ Q" := (equiv (A:=uPred M) P%I Q%I). (* Force implicit argument M *) (* Derived logical stuff *) Lemma False_elim P : False ⊢ P. `````` Robbert Krebbers committed Nov 22, 2016 53 ``````Proof. by apply (pure_elim' False). Qed. `````` Robbert Krebbers committed Oct 25, 2016 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 ``````Lemma True_intro P : P ⊢ True. Proof. by apply pure_intro. Qed. Lemma and_elim_l' P Q R : (P ⊢ R) → P ∧ Q ⊢ R. Proof. by rewrite and_elim_l. Qed. Lemma and_elim_r' P Q R : (Q ⊢ R) → P ∧ Q ⊢ R. Proof. by rewrite and_elim_r. Qed. Lemma or_intro_l' P Q R : (P ⊢ Q) → P ⊢ Q ∨ R. Proof. intros ->; apply or_intro_l. Qed. Lemma or_intro_r' P Q R : (P ⊢ R) → P ⊢ Q ∨ R. Proof. intros ->; apply or_intro_r. Qed. Lemma exist_intro' {A} P (Ψ : A → uPred M) a : (P ⊢ Ψ a) → P ⊢ ∃ a, Ψ a. Proof. intros ->; apply exist_intro. Qed. Lemma forall_elim' {A} P (Ψ : A → uPred M) : (P ⊢ ∀ a, Ψ a) → ∀ a, P ⊢ Ψ a. Proof. move=> HP a. by rewrite HP forall_elim. Qed. Hint Resolve pure_intro. Hint Resolve or_elim or_intro_l' or_intro_r'. Hint Resolve and_intro and_elim_l' and_elim_r'. Hint Immediate True_intro False_elim. Lemma impl_intro_l P Q R : (Q ∧ P ⊢ R) → P ⊢ Q → R. Proof. intros HR; apply impl_intro_r; rewrite -HR; auto. Qed. Lemma impl_elim_l P Q : (P → Q) ∧ P ⊢ Q. Proof. apply impl_elim with P; auto. Qed. Lemma impl_elim_r P Q : P ∧ (P → Q) ⊢ Q. Proof. apply impl_elim with P; auto. Qed. Lemma impl_elim_l' P Q R : (P ⊢ Q → R) → P ∧ Q ⊢ R. Proof. intros; apply impl_elim with Q; auto. Qed. Lemma impl_elim_r' P Q R : (Q ⊢ P → R) → P ∧ Q ⊢ R. Proof. intros; apply impl_elim with P; auto. Qed. `````` 85 ``````Lemma impl_entails P Q : (P → Q)%I → P ⊢ Q. `````` Robbert Krebbers committed Oct 25, 2016 86 ``````Proof. intros HPQ; apply impl_elim with P; rewrite -?HPQ; auto. Qed. `````` 87 88 ``````Lemma entails_impl P Q : (P ⊢ Q) → (P → Q)%I. Proof. intro. apply impl_intro_l. auto. Qed. `````` Robbert Krebbers committed Oct 25, 2016 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 `````` Lemma and_mono P P' Q Q' : (P ⊢ Q) → (P' ⊢ Q') → P ∧ P' ⊢ Q ∧ Q'. Proof. auto. Qed. Lemma and_mono_l P P' Q : (P ⊢ Q) → P ∧ P' ⊢ Q ∧ P'. Proof. by intros; apply and_mono. Qed. Lemma and_mono_r P P' Q' : (P' ⊢ Q') → P ∧ P' ⊢ P ∧ Q'. Proof. by apply and_mono. Qed. Lemma or_mono P P' Q Q' : (P ⊢ Q) → (P' ⊢ Q') → P ∨ P' ⊢ Q ∨ Q'. Proof. auto. Qed. Lemma or_mono_l P P' Q : (P ⊢ Q) → P ∨ P' ⊢ Q ∨ P'. Proof. by intros; apply or_mono. Qed. Lemma or_mono_r P P' Q' : (P' ⊢ Q') → P ∨ P' ⊢ P ∨ Q'. Proof. by apply or_mono. Qed. Lemma impl_mono P P' Q Q' : (Q ⊢ P) → (P' ⊢ Q') → (P → P') ⊢ Q → Q'. Proof. intros HP HQ'; apply impl_intro_l; rewrite -HQ'. apply impl_elim with P; eauto. Qed. Lemma forall_mono {A} (Φ Ψ : A → uPred M) : (∀ a, Φ a ⊢ Ψ a) → (∀ a, Φ a) ⊢ ∀ a, Ψ a. Proof. intros HP. apply forall_intro=> a; rewrite -(HP a); apply forall_elim. Qed. Lemma exist_mono {A} (Φ Ψ : A → uPred M) : (∀ a, Φ a ⊢ Ψ a) → (∃ a, Φ a) ⊢ ∃ a, Ψ a. Proof. intros HΦ. apply exist_elim=> a; rewrite (HΦ a); apply exist_intro. Qed. Global Instance and_mono' : Proper ((⊢) ==> (⊢) ==> (⊢)) (@uPred_and M). Proof. by intros P P' HP Q Q' HQ; apply and_mono. Qed. Global Instance and_flip_mono' : Proper (flip (⊢) ==> flip (⊢) ==> flip (⊢)) (@uPred_and M). Proof. by intros P P' HP Q Q' HQ; apply and_mono. Qed. Global Instance or_mono' : Proper ((⊢) ==> (⊢) ==> (⊢)) (@uPred_or M). Proof. by intros P P' HP Q Q' HQ; apply or_mono. Qed. Global Instance or_flip_mono' : Proper (flip (⊢) ==> flip (⊢) ==> flip (⊢)) (@uPred_or M). Proof. by intros P P' HP Q Q' HQ; apply or_mono. Qed. Global Instance impl_mono' : Proper (flip (⊢) ==> (⊢) ==> (⊢)) (@uPred_impl M). Proof. by intros P P' HP Q Q' HQ; apply impl_mono. Qed. `````` Robbert Krebbers committed Oct 28, 2016 131 132 133 ``````Global Instance impl_flip_mono' : Proper ((⊢) ==> flip (⊢) ==> flip (⊢)) (@uPred_impl M). Proof. by intros P P' HP Q Q' HQ; apply impl_mono. Qed. `````` Robbert Krebbers committed Oct 25, 2016 134 135 136 ``````Global Instance forall_mono' A : Proper (pointwise_relation _ (⊢) ==> (⊢)) (@uPred_forall M A). Proof. intros P1 P2; apply forall_mono. Qed. `````` Robbert Krebbers committed Oct 28, 2016 137 138 139 ``````Global Instance forall_flip_mono' A : Proper (pointwise_relation _ (flip (⊢)) ==> flip (⊢)) (@uPred_forall M A). Proof. intros P1 P2; apply forall_mono. Qed. `````` Robbert Krebbers committed Oct 25, 2016 140 ``````Global Instance exist_mono' A : `````` Robbert Krebbers committed Oct 28, 2016 141 142 143 144 `````` Proper (pointwise_relation _ (flip (⊢)) ==> flip (⊢)) (@uPred_exist M A). Proof. intros P1 P2; apply exist_mono. Qed. Global Instance exist_flip_mono' A : Proper (pointwise_relation _ (flip (⊢)) ==> flip (⊢)) (@uPred_exist M A). `````` Robbert Krebbers committed Oct 25, 2016 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 ``````Proof. intros P1 P2; apply exist_mono. Qed. Global Instance and_idem : IdemP (⊣⊢) (@uPred_and M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance or_idem : IdemP (⊣⊢) (@uPred_or M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance and_comm : Comm (⊣⊢) (@uPred_and M). Proof. intros P Q; apply (anti_symm (⊢)); auto. Qed. Global Instance True_and : LeftId (⊣⊢) True%I (@uPred_and M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance and_True : RightId (⊣⊢) True%I (@uPred_and M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance False_and : LeftAbsorb (⊣⊢) False%I (@uPred_and M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance and_False : RightAbsorb (⊣⊢) False%I (@uPred_and M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance True_or : LeftAbsorb (⊣⊢) True%I (@uPred_or M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance or_True : RightAbsorb (⊣⊢) True%I (@uPred_or M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance False_or : LeftId (⊣⊢) False%I (@uPred_or M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance or_False : RightId (⊣⊢) False%I (@uPred_or M). Proof. intros P; apply (anti_symm (⊢)); auto. Qed. Global Instance and_assoc : Assoc (⊣⊢) (@uPred_and M). Proof. intros P Q R; apply (anti_symm (⊢)); auto. Qed. Global Instance or_comm : Comm (⊣⊢) (@uPred_or M). Proof. intros P Q; apply (anti_symm (⊢)); auto. Qed. Global Instance or_assoc : Assoc (⊣⊢) (@uPred_or M). Proof. intros P Q R; apply (anti_symm (⊢)); auto. Qed. Global Instance True_impl : LeftId (⊣⊢) True%I (@uPred_impl M). Proof. intros P; apply (anti_symm (⊢)). - by rewrite -(left_id True%I uPred_and (_ → _)%I) impl_elim_r. - by apply impl_intro_l; rewrite left_id. Qed. `````` Robbert Krebbers committed Nov 21, 2016 181 182 183 184 185 ``````Lemma False_impl P : (False → P) ⊣⊢ True. Proof. apply (anti_symm (⊢)); [by auto|]. apply impl_intro_l. rewrite left_absorb. auto. Qed. `````` Robbert Krebbers committed Oct 25, 2016 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 `````` Lemma exists_impl_forall {A} P (Ψ : A → uPred M) : ((∃ x : A, Ψ x) → P) ⊣⊢ ∀ x : A, Ψ x → P. Proof. apply equiv_spec; split. - apply forall_intro=>x. by rewrite -exist_intro. - apply impl_intro_r, impl_elim_r', exist_elim=>x. apply impl_intro_r. by rewrite (forall_elim x) impl_elim_r. Qed. Lemma or_and_l P Q R : P ∨ Q ∧ R ⊣⊢ (P ∨ Q) ∧ (P ∨ R). Proof. apply (anti_symm (⊢)); first auto. do 2 (apply impl_elim_l', or_elim; apply impl_intro_l); auto. Qed. Lemma or_and_r P Q R : P ∧ Q ∨ R ⊣⊢ (P ∨ R) ∧ (Q ∨ R). Proof. by rewrite -!(comm _ R) or_and_l. Qed. Lemma and_or_l P Q R : P ∧ (Q ∨ R) ⊣⊢ P ∧ Q ∨ P ∧ R. Proof. apply (anti_symm (⊢)); last auto. apply impl_elim_r', or_elim; apply impl_intro_l; auto. Qed. Lemma and_or_r P Q R : (P ∨ Q) ∧ R ⊣⊢ P ∧ R ∨ Q ∧ R. Proof. by rewrite -!(comm _ R) and_or_l. Qed. Lemma and_exist_l {A} P (Ψ : A → uPred M) : P ∧ (∃ a, Ψ a) ⊣⊢ ∃ a, P ∧ Ψ a. Proof. apply (anti_symm (⊢)). - apply impl_elim_r'. apply exist_elim=>a. apply impl_intro_l. by rewrite -(exist_intro a). - apply exist_elim=>a. apply and_intro; first by rewrite and_elim_l. by rewrite -(exist_intro a) and_elim_r. Qed. Lemma and_exist_r {A} P (Φ: A → uPred M) : (∃ a, Φ a) ∧ P ⊣⊢ ∃ a, Φ a ∧ P. Proof. rewrite -(comm _ P) and_exist_l. apply exist_proper=>a. by rewrite comm. Qed. `````` Robbert Krebbers committed Nov 17, 2016 222 223 224 225 226 227 228 ``````Lemma or_exist {A} (Φ Ψ : A → uPred M) : (∃ a, Φ a ∨ Ψ a) ⊣⊢ (∃ a, Φ a) ∨ (∃ a, Ψ a). Proof. apply (anti_symm (⊢)). - apply exist_elim=> a. by rewrite -!(exist_intro a). - apply or_elim; apply exist_elim=> a; rewrite -(exist_intro a); auto. Qed. `````` Robbert Krebbers committed Oct 25, 2016 229 `````` `````` Ralf Jung committed Nov 22, 2016 230 ``````Lemma pure_elim φ Q R : (Q ⊢ ⌜φ⌝) → (φ → Q ⊢ R) → Q ⊢ R. `````` Robbert Krebbers committed Nov 22, 2016 231 232 233 234 ``````Proof. intros HQ HQR. rewrite -(idemp uPred_and Q) {1}HQ. apply impl_elim_l', pure_elim'=> ?. by apply entails_impl, HQR. Qed. `````` Ralf Jung committed Nov 22, 2016 235 ``````Lemma pure_mono φ1 φ2 : (φ1 → φ2) → ⌜φ1⌝ ⊢ ⌜φ2⌝. `````` Robbert Krebbers committed Oct 25, 2016 236 237 238 ``````Proof. intros; apply pure_elim with φ1; eauto. Qed. Global Instance pure_mono' : Proper (impl ==> (⊢)) (@uPred_pure M). Proof. intros φ1 φ2; apply pure_mono. Qed. `````` Ralf Jung committed Nov 22, 2016 239 ``````Lemma pure_iff φ1 φ2 : (φ1 ↔ φ2) → ⌜φ1⌝ ⊣⊢ ⌜φ2⌝. `````` Robbert Krebbers committed Oct 25, 2016 240 ``````Proof. intros [??]; apply (anti_symm _); auto using pure_mono. Qed. `````` Ralf Jung committed Nov 22, 2016 241 ``````Lemma pure_intro_l φ Q R : φ → (⌜φ⌝ ∧ Q ⊢ R) → Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 242 ``````Proof. intros ? <-; auto using pure_intro. Qed. `````` Ralf Jung committed Nov 22, 2016 243 ``````Lemma pure_intro_r φ Q R : φ → (Q ∧ ⌜φ⌝ ⊢ R) → Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 244 ``````Proof. intros ? <-; auto. Qed. `````` Ralf Jung committed Nov 22, 2016 245 ``````Lemma pure_intro_impl φ Q R : φ → (Q ⊢ ⌜φ⌝ → R) → Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 246 ``````Proof. intros ? ->. eauto using pure_intro_l, impl_elim_r. Qed. `````` Ralf Jung committed Nov 22, 2016 247 ``````Lemma pure_elim_l φ Q R : (φ → Q ⊢ R) → ⌜φ⌝ ∧ Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 248 ``````Proof. intros; apply pure_elim with φ; eauto. Qed. `````` Ralf Jung committed Nov 22, 2016 249 ``````Lemma pure_elim_r φ Q R : (φ → Q ⊢ R) → Q ∧ ⌜φ⌝ ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 250 ``````Proof. intros; apply pure_elim with φ; eauto. Qed. `````` Robbert Krebbers committed Nov 21, 2016 251 `````` `````` Ralf Jung committed Nov 22, 2016 252 ``````Lemma pure_True (φ : Prop) : φ → ⌜φ⌝ ⊣⊢ True. `````` Robbert Krebbers committed Oct 25, 2016 253 ``````Proof. intros; apply (anti_symm _); auto. Qed. `````` Ralf Jung committed Nov 22, 2016 254 ``````Lemma pure_False (φ : Prop) : ¬φ → ⌜φ⌝ ⊣⊢ False. `````` Robbert Krebbers committed Nov 21, 2016 255 ``````Proof. intros; apply (anti_symm _); eauto using pure_elim. Qed. `````` Robbert Krebbers committed Oct 25, 2016 256 `````` `````` Ralf Jung committed Nov 22, 2016 257 ``````Lemma pure_and φ1 φ2 : ⌜φ1 ∧ φ2⌝ ⊣⊢ ⌜φ1⌝ ∧ ⌜φ2⌝. `````` Robbert Krebbers committed Oct 25, 2016 258 259 260 261 262 ``````Proof. apply (anti_symm _). - eapply pure_elim=> // -[??]; auto. - eapply (pure_elim φ1); [auto|]=> ?. eapply (pure_elim φ2); auto. Qed. `````` Ralf Jung committed Nov 22, 2016 263 ``````Lemma pure_or φ1 φ2 : ⌜φ1 ∨ φ2⌝ ⊣⊢ ⌜φ1⌝ ∨ ⌜φ2⌝. `````` Robbert Krebbers committed Oct 25, 2016 264 265 266 267 268 ``````Proof. apply (anti_symm _). - eapply pure_elim=> // -[?|?]; auto. - apply or_elim; eapply pure_elim; eauto. Qed. `````` Ralf Jung committed Nov 22, 2016 269 ``````Lemma pure_impl φ1 φ2 : ⌜φ1 → φ2⌝ ⊣⊢ (⌜φ1⌝ → ⌜φ2⌝). `````` Robbert Krebbers committed Oct 25, 2016 270 271 272 273 ``````Proof. apply (anti_symm _). - apply impl_intro_l. rewrite -pure_and. apply pure_mono. naive_solver. - rewrite -pure_forall_2. apply forall_intro=> ?. `````` Robbert Krebbers committed Nov 21, 2016 274 `````` by rewrite -(left_id True uPred_and (_→_))%I (pure_True φ1) // impl_elim_r. `````` Robbert Krebbers committed Oct 25, 2016 275 ``````Qed. `````` Ralf Jung committed Nov 22, 2016 276 ``````Lemma pure_forall {A} (φ : A → Prop) : ⌜∀ x, φ x⌝ ⊣⊢ ∀ x, ⌜φ x⌝. `````` Robbert Krebbers committed Oct 25, 2016 277 278 279 280 ``````Proof. apply (anti_symm _); auto using pure_forall_2. apply forall_intro=> x. eauto using pure_mono. Qed. `````` Ralf Jung committed Nov 22, 2016 281 ``````Lemma pure_exist {A} (φ : A → Prop) : ⌜∃ x, φ x⌝ ⊣⊢ ∃ x, ⌜φ x⌝. `````` Robbert Krebbers committed Oct 25, 2016 282 283 284 285 286 287 ``````Proof. apply (anti_symm _). - eapply pure_elim=> // -[x ?]. rewrite -(exist_intro x); auto. - apply exist_elim=> x. eauto using pure_mono. Qed. `````` Ralf Jung committed Nov 22, 2016 288 ``````Lemma internal_eq_refl' {A : ofeT} (a : A) P : P ⊢ a ≡ a. `````` Robbert Krebbers committed Oct 25, 2016 289 290 ``````Proof. rewrite (True_intro P). apply internal_eq_refl. Qed. Hint Resolve internal_eq_refl'. `````` Ralf Jung committed Nov 22, 2016 291 ``````Lemma equiv_internal_eq {A : ofeT} P (a b : A) : a ≡ b → P ⊢ a ≡ b. `````` Robbert Krebbers committed Oct 25, 2016 292 ``````Proof. by intros ->. Qed. `````` Ralf Jung committed Nov 22, 2016 293 ``````Lemma internal_eq_sym {A : ofeT} (a b : A) : a ≡ b ⊢ b ≡ a. `````` Robbert Krebbers committed Oct 25, 2016 294 ``````Proof. apply (internal_eq_rewrite a b (λ b, b ≡ a)%I); auto. solve_proper. Qed. `````` Ralf Jung committed Dec 05, 2016 295 296 297 ``````Lemma internal_eq_rewrite_contractive {A : ofeT} a b (Ψ : A → uPred M) P {HΨ : Contractive Ψ} : (P ⊢ ▷ (a ≡ b)) → (P ⊢ Ψ a) → P ⊢ Ψ b. Proof. `````` Robbert Krebbers committed Dec 05, 2016 298 299 `````` move: HΨ=> /contractiveI HΨ Heq ?. apply (internal_eq_rewrite (Ψ a) (Ψ b) id _)=>//=. by rewrite -HΨ. `````` Ralf Jung committed Dec 05, 2016 300 ``````Qed. `````` Robbert Krebbers committed Oct 25, 2016 301 `````` `````` Ralf Jung committed Nov 22, 2016 302 ``````Lemma pure_impl_forall φ P : (⌜φ⌝ → P) ⊣⊢ (∀ _ : φ, P). `````` Robbert Krebbers committed Nov 20, 2016 303 304 ``````Proof. apply (anti_symm _). `````` Robbert Krebbers committed Nov 21, 2016 305 `````` - apply forall_intro=> ?. by rewrite pure_True // left_id. `````` Robbert Krebbers committed Nov 20, 2016 306 307 `````` - apply impl_intro_l, pure_elim_l=> Hφ. by rewrite (forall_elim Hφ). Qed. `````` Ralf Jung committed Nov 22, 2016 308 ``````Lemma pure_alt φ : ⌜φ⌝ ⊣⊢ ∃ _ : φ, True. `````` Robbert Krebbers committed Oct 25, 2016 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 ``````Proof. apply (anti_symm _). - eapply pure_elim; eauto=> H. rewrite -(exist_intro H); auto. - by apply exist_elim, pure_intro. Qed. Lemma and_alt P Q : P ∧ Q ⊣⊢ ∀ b : bool, if b then P else Q. Proof. apply (anti_symm _); first apply forall_intro=> -[]; auto. apply and_intro. by rewrite (forall_elim true). by rewrite (forall_elim false). Qed. Lemma or_alt P Q : P ∨ Q ⊣⊢ ∃ b : bool, if b then P else Q. Proof. apply (anti_symm _); last apply exist_elim=> -[]; auto. apply or_elim. by rewrite -(exist_intro true). by rewrite -(exist_intro false). Qed. `````` Ralf Jung committed Jan 27, 2017 325 ``````Global Instance iff_ne : NonExpansive2 (@uPred_iff M). `````` Robbert Krebbers committed Oct 25, 2016 326 327 328 329 330 331 ``````Proof. unfold uPred_iff; solve_proper. Qed. Global Instance iff_proper : Proper ((⊣⊢) ==> (⊣⊢) ==> (⊣⊢)) (@uPred_iff M) := ne_proper_2 _. Lemma iff_refl Q P : Q ⊢ P ↔ P. Proof. rewrite /uPred_iff; apply and_intro; apply impl_intro_l; auto. Qed. `````` 332 ``````Lemma iff_equiv P Q : (P ↔ Q)%I → (P ⊣⊢ Q). `````` Robbert Krebbers committed Oct 25, 2016 333 334 ``````Proof. intros HPQ; apply (anti_symm (⊢)); `````` 335 `````` apply impl_entails; rewrite /uPred_valid HPQ /uPred_iff; auto. `````` Robbert Krebbers committed Oct 25, 2016 336 ``````Qed. `````` 337 ``````Lemma equiv_iff P Q : (P ⊣⊢ Q) → (P ↔ Q)%I. `````` Robbert Krebbers committed Oct 25, 2016 338 ``````Proof. intros ->; apply iff_refl. Qed. `````` Robbert Krebbers committed Oct 25, 2016 339 ``````Lemma internal_eq_iff P Q : P ≡ Q ⊢ P ↔ Q. `````` Robbert Krebbers committed Oct 25, 2016 340 ``````Proof. `````` Robbert Krebbers committed Oct 25, 2016 341 342 `````` apply (internal_eq_rewrite P Q (λ Q, P ↔ Q))%I; first solve_proper; auto using iff_refl. `````` Robbert Krebbers committed Oct 25, 2016 343 344 345 346 ``````Qed. (* Derived BI Stuff *) Hint Resolve sep_mono. `````` Robbert Krebbers committed Nov 03, 2016 347 ``````Lemma sep_mono_l P P' Q : (P ⊢ Q) → P ∗ P' ⊢ Q ∗ P'. `````` Robbert Krebbers committed Oct 25, 2016 348 ``````Proof. by intros; apply sep_mono. Qed. `````` Robbert Krebbers committed Nov 03, 2016 349 ``````Lemma sep_mono_r P P' Q' : (P' ⊢ Q') → P ∗ P' ⊢ P ∗ Q'. `````` Robbert Krebbers committed Oct 25, 2016 350 351 352 353 354 355 ``````Proof. by apply sep_mono. Qed. Global Instance sep_mono' : Proper ((⊢) ==> (⊢) ==> (⊢)) (@uPred_sep M). Proof. by intros P P' HP Q Q' HQ; apply sep_mono. Qed. Global Instance sep_flip_mono' : Proper (flip (⊢) ==> flip (⊢) ==> flip (⊢)) (@uPred_sep M). Proof. by intros P P' HP Q Q' HQ; apply sep_mono. Qed. `````` Robbert Krebbers committed Nov 03, 2016 356 ``````Lemma wand_mono P P' Q Q' : (Q ⊢ P) → (P' ⊢ Q') → (P -∗ P') ⊢ Q -∗ Q'. `````` Robbert Krebbers committed Oct 25, 2016 357 358 359 360 361 ``````Proof. intros HP HQ; apply wand_intro_r. rewrite HP -HQ. by apply wand_elim_l'. Qed. Global Instance wand_mono' : Proper (flip (⊢) ==> (⊢) ==> (⊢)) (@uPred_wand M). Proof. by intros P P' HP Q Q' HQ; apply wand_mono. Qed. `````` Robbert Krebbers committed Oct 28, 2016 362 363 364 ``````Global Instance wand_flip_mono' : Proper ((⊢) ==> flip (⊢) ==> flip (⊢)) (@uPred_wand M). Proof. by intros P P' HP Q Q' HQ; apply wand_mono. Qed. `````` Robbert Krebbers committed Oct 25, 2016 365 366 367 368 369 370 371 372 373 374 375 376 `````` Global Instance sep_comm : Comm (⊣⊢) (@uPred_sep M). Proof. intros P Q; apply (anti_symm _); auto using sep_comm'. Qed. Global Instance sep_assoc : Assoc (⊣⊢) (@uPred_sep M). Proof. intros P Q R; apply (anti_symm _); auto using sep_assoc'. by rewrite !(comm _ P) !(comm _ _ R) sep_assoc'. Qed. Global Instance True_sep : LeftId (⊣⊢) True%I (@uPred_sep M). Proof. intros P; apply (anti_symm _); auto using True_sep_1, True_sep_2. Qed. Global Instance sep_True : RightId (⊣⊢) True%I (@uPred_sep M). Proof. by intros P; rewrite comm left_id. Qed. `````` Robbert Krebbers committed Nov 03, 2016 377 ``````Lemma sep_elim_l P Q : P ∗ Q ⊢ P. `````` Robbert Krebbers committed Oct 25, 2016 378 ``````Proof. by rewrite (True_intro Q) right_id. Qed. `````` Robbert Krebbers committed Nov 03, 2016 379 380 381 ``````Lemma sep_elim_r P Q : P ∗ Q ⊢ Q. Proof. by rewrite (comm (∗))%I; apply sep_elim_l. Qed. Lemma sep_elim_l' P Q R : (P ⊢ R) → P ∗ Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 382 ``````Proof. intros ->; apply sep_elim_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 383 ``````Lemma sep_elim_r' P Q R : (Q ⊢ R) → P ∗ Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 384 385 ``````Proof. intros ->; apply sep_elim_r. Qed. Hint Resolve sep_elim_l' sep_elim_r'. `````` 386 ``````Lemma sep_intro_True_l P Q R : P%I → (R ⊢ Q) → R ⊢ P ∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 387 ``````Proof. by intros; rewrite -(left_id True%I uPred_sep R); apply sep_mono. Qed. `````` 388 ``````Lemma sep_intro_True_r P Q R : (R ⊢ P) → Q%I → R ⊢ P ∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 389 ``````Proof. by intros; rewrite -(right_id True%I uPred_sep R); apply sep_mono. Qed. `````` 390 ``````Lemma sep_elim_True_l P Q R : P → (P ∗ R ⊢ Q) → R ⊢ Q. `````` Robbert Krebbers committed Oct 25, 2016 391 ``````Proof. by intros HP; rewrite -HP left_id. Qed. `````` 392 ``````Lemma sep_elim_True_r P Q R : P → (R ∗ P ⊢ Q) → R ⊢ Q. `````` Robbert Krebbers committed Oct 25, 2016 393 ``````Proof. by intros HP; rewrite -HP right_id. Qed. `````` Robbert Krebbers committed Nov 03, 2016 394 ``````Lemma wand_intro_l P Q R : (Q ∗ P ⊢ R) → P ⊢ Q -∗ R. `````` Robbert Krebbers committed Oct 25, 2016 395 ``````Proof. rewrite comm; apply wand_intro_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 396 ``````Lemma wand_elim_l P Q : (P -∗ Q) ∗ P ⊢ Q. `````` Robbert Krebbers committed Oct 25, 2016 397 ``````Proof. by apply wand_elim_l'. Qed. `````` Robbert Krebbers committed Nov 03, 2016 398 ``````Lemma wand_elim_r P Q : P ∗ (P -∗ Q) ⊢ Q. `````` Robbert Krebbers committed Oct 25, 2016 399 ``````Proof. rewrite (comm _ P); apply wand_elim_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 400 ``````Lemma wand_elim_r' P Q R : (Q ⊢ P -∗ R) → P ∗ Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 401 ``````Proof. intros ->; apply wand_elim_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 402 ``````Lemma wand_apply P Q R S : (P ⊢ Q -∗ R) → (S ⊢ P ∗ Q) → S ⊢ R. `````` Ralf Jung committed Nov 01, 2016 403 ``````Proof. intros HR%wand_elim_l' HQ. by rewrite HQ. Qed. `````` Robbert Krebbers committed Nov 03, 2016 404 ``````Lemma wand_frame_l P Q R : (Q -∗ R) ⊢ P ∗ Q -∗ P ∗ R. `````` Robbert Krebbers committed Oct 25, 2016 405 ``````Proof. apply wand_intro_l. rewrite -assoc. apply sep_mono_r, wand_elim_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 406 ``````Lemma wand_frame_r P Q R : (Q -∗ R) ⊢ Q ∗ P -∗ R ∗ P. `````` Robbert Krebbers committed Oct 25, 2016 407 ``````Proof. `````` Robbert Krebbers committed Nov 03, 2016 408 `````` apply wand_intro_l. rewrite ![(_ ∗ P)%I]comm -assoc. `````` Robbert Krebbers committed Oct 25, 2016 409 410 `````` apply sep_mono_r, wand_elim_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 411 ``````Lemma wand_diag P : (P -∗ P) ⊣⊢ True. `````` Robbert Krebbers committed Oct 25, 2016 412 ``````Proof. apply (anti_symm _); auto. apply wand_intro_l; by rewrite right_id. Qed. `````` Robbert Krebbers committed Nov 03, 2016 413 ``````Lemma wand_True P : (True -∗ P) ⊣⊢ P. `````` Robbert Krebbers committed Oct 25, 2016 414 415 ``````Proof. apply (anti_symm _); last by auto using wand_intro_l. `````` 416 `````` eapply sep_elim_True_l; last by apply wand_elim_r. done. `````` Robbert Krebbers committed Oct 25, 2016 417 ``````Qed. `````` 418 ``````Lemma wand_entails P Q : (P -∗ Q)%I → P ⊢ Q. `````` Robbert Krebbers committed Oct 25, 2016 419 420 421 ``````Proof. intros HPQ. eapply sep_elim_True_r; first exact: HPQ. by rewrite wand_elim_r. Qed. `````` 422 423 ``````Lemma entails_wand P Q : (P ⊢ Q) → (P -∗ Q)%I. Proof. intro. apply wand_intro_l. auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 424 ``````Lemma wand_curry P Q R : (P -∗ Q -∗ R) ⊣⊢ (P ∗ Q -∗ R). `````` Robbert Krebbers committed Oct 25, 2016 425 426 427 428 429 430 ``````Proof. apply (anti_symm _). - apply wand_intro_l. by rewrite (comm _ P) -assoc !wand_elim_r. - do 2 apply wand_intro_l. by rewrite assoc (comm _ Q) wand_elim_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 431 ``````Lemma sep_and P Q : (P ∗ Q) ⊢ (P ∧ Q). `````` Robbert Krebbers committed Oct 25, 2016 432 ``````Proof. auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 433 ``````Lemma impl_wand P Q : (P → Q) ⊢ P -∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 434 ``````Proof. apply wand_intro_r, impl_elim with P; auto. Qed. `````` Ralf Jung committed Nov 22, 2016 435 ``````Lemma pure_elim_sep_l φ Q R : (φ → Q ⊢ R) → ⌜φ⌝ ∗ Q ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 436 ``````Proof. intros; apply pure_elim with φ; eauto. Qed. `````` Ralf Jung committed Nov 22, 2016 437 ``````Lemma pure_elim_sep_r φ Q R : (φ → Q ⊢ R) → Q ∗ ⌜φ⌝ ⊢ R. `````` Robbert Krebbers committed Oct 25, 2016 438 439 440 441 442 443 444 ``````Proof. intros; apply pure_elim with φ; eauto. Qed. Global Instance sep_False : LeftAbsorb (⊣⊢) False%I (@uPred_sep M). Proof. intros P; apply (anti_symm _); auto. Qed. Global Instance False_sep : RightAbsorb (⊣⊢) False%I (@uPred_sep M). Proof. intros P; apply (anti_symm _); auto. Qed. `````` Jacques-Henri Jourdan committed Dec 23, 2016 445 ``````Lemma entails_equiv_and P Q : (P ⊣⊢ Q ∧ P) ↔ (P ⊢ Q). `````` Robbert Krebbers committed Dec 27, 2016 446 ``````Proof. split. by intros ->; auto. intros; apply (anti_symm _); auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 447 ``````Lemma sep_and_l P Q R : P ∗ (Q ∧ R) ⊢ (P ∗ Q) ∧ (P ∗ R). `````` Robbert Krebbers committed Oct 25, 2016 448 ``````Proof. auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 449 ``````Lemma sep_and_r P Q R : (P ∧ Q) ∗ R ⊢ (P ∗ R) ∧ (Q ∗ R). `````` Robbert Krebbers committed Oct 25, 2016 450 ``````Proof. auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 451 ``````Lemma sep_or_l P Q R : P ∗ (Q ∨ R) ⊣⊢ (P ∗ Q) ∨ (P ∗ R). `````` Robbert Krebbers committed Oct 25, 2016 452 453 454 455 ``````Proof. apply (anti_symm (⊢)); last by eauto 8. apply wand_elim_r', or_elim; apply wand_intro_l; auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 456 ``````Lemma sep_or_r P Q R : (P ∨ Q) ∗ R ⊣⊢ (P ∗ R) ∨ (Q ∗ R). `````` Robbert Krebbers committed Oct 25, 2016 457 ``````Proof. by rewrite -!(comm _ R) sep_or_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 458 ``````Lemma sep_exist_l {A} P (Ψ : A → uPred M) : P ∗ (∃ a, Ψ a) ⊣⊢ ∃ a, P ∗ Ψ a. `````` Robbert Krebbers committed Oct 25, 2016 459 460 461 462 463 464 ``````Proof. intros; apply (anti_symm (⊢)). - apply wand_elim_r', exist_elim=>a. apply wand_intro_l. by rewrite -(exist_intro a). - apply exist_elim=> a; apply sep_mono; auto using exist_intro. Qed. `````` Robbert Krebbers committed Nov 03, 2016 465 ``````Lemma sep_exist_r {A} (Φ: A → uPred M) Q: (∃ a, Φ a) ∗ Q ⊣⊢ ∃ a, Φ a ∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 466 ``````Proof. setoid_rewrite (comm _ _ Q); apply sep_exist_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 467 ``````Lemma sep_forall_l {A} P (Ψ : A → uPred M) : P ∗ (∀ a, Ψ a) ⊢ ∀ a, P ∗ Ψ a. `````` Robbert Krebbers committed Oct 25, 2016 468 ``````Proof. by apply forall_intro=> a; rewrite forall_elim. Qed. `````` Robbert Krebbers committed Nov 03, 2016 469 ``````Lemma sep_forall_r {A} (Φ : A → uPred M) Q : (∀ a, Φ a) ∗ Q ⊢ ∀ a, Φ a ∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 470 471 472 473 474 475 476 477 478 479 480 ``````Proof. by apply forall_intro=> a; rewrite forall_elim. Qed. (* Always derived *) Hint Resolve always_mono always_elim. 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_intro' P Q : (□ P ⊢ Q) → □ P ⊢ □ Q. `````` Robbert Krebbers committed Jun 13, 2017 481 ``````Proof. intros <-. apply always_idemp_2. Qed. `````` Robbert Krebbers committed Jun 13, 2017 482 ``````Lemma always_idemp P : □ □ P ⊣⊢ □ P. `````` Robbert Krebbers committed Jun 13, 2017 483 ``````Proof. apply (anti_symm _); auto using always_idemp_2. Qed. `````` Robbert Krebbers committed Oct 25, 2016 484 `````` `````` Ralf Jung committed Nov 22, 2016 485 ``````Lemma always_pure φ : □ ⌜φ⌝ ⊣⊢ ⌜φ⌝. `````` Robbert Krebbers committed Jun 13, 2017 486 487 488 489 490 491 ``````Proof. apply (anti_symm _); auto. apply pure_elim'=> Hφ. trans (∀ x : False, □ True : uPred M)%I; [by apply forall_intro|]. rewrite always_forall_2. auto using always_mono, pure_intro. Qed. `````` Robbert Krebbers committed Oct 25, 2016 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 ``````Lemma always_forall {A} (Ψ : A → uPred M) : (□ ∀ a, Ψ a) ⊣⊢ (∀ a, □ Ψ a). Proof. apply (anti_symm _); auto using always_forall_2. apply forall_intro=> x. by rewrite (forall_elim x). Qed. Lemma always_exist {A} (Ψ : A → uPred M) : (□ ∃ a, Ψ a) ⊣⊢ (∃ a, □ Ψ a). Proof. apply (anti_symm _); auto using always_exist_1. apply exist_elim=> x. by rewrite (exist_intro x). Qed. Lemma always_and P Q : □ (P ∧ Q) ⊣⊢ □ P ∧ □ Q. Proof. rewrite !and_alt always_forall. by apply forall_proper=> -[]. Qed. Lemma always_or P Q : □ (P ∨ Q) ⊣⊢ □ P ∨ □ Q. Proof. rewrite !or_alt always_exist. by apply exist_proper=> -[]. Qed. Lemma always_impl P Q : □ (P → Q) ⊢ □ P → □ Q. Proof. apply impl_intro_l; rewrite -always_and. apply always_mono, impl_elim with P; auto. Qed. `````` Ralf Jung committed Nov 22, 2016 511 ``````Lemma always_internal_eq {A:ofeT} (a b : A) : □ (a ≡ b) ⊣⊢ a ≡ b. `````` Robbert Krebbers committed Oct 25, 2016 512 513 ``````Proof. apply (anti_symm (⊢)); auto using always_elim. `````` Robbert Krebbers committed Oct 25, 2016 514 `````` apply (internal_eq_rewrite a b (λ b, □ (a ≡ b))%I); auto. `````` Robbert Krebbers committed Oct 25, 2016 515 `````` { intros n; solve_proper. } `````` Robbert Krebbers committed Oct 25, 2016 516 `````` rewrite -(internal_eq_refl a) always_pure; auto. `````` Robbert Krebbers committed Oct 25, 2016 517 518 ``````Qed. `````` Robbert Krebbers committed Nov 03, 2016 519 ``````Lemma always_and_sep_l' P Q : □ P ∧ Q ⊣⊢ □ P ∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 520 ``````Proof. apply (anti_symm (⊢)); auto using always_and_sep_l_1. Qed. `````` Robbert Krebbers committed Nov 03, 2016 521 ``````Lemma always_and_sep_r' P Q : P ∧ □ Q ⊣⊢ P ∗ □ Q. `````` Robbert Krebbers committed Oct 25, 2016 522 ``````Proof. by rewrite !(comm _ P) always_and_sep_l'. Qed. `````` Robbert Krebbers committed Jun 13, 2017 523 524 525 526 527 528 529 530 ``````Lemma always_sep_dup' P : □ P ⊣⊢ □ P ∗ □ P. Proof. by rewrite -always_and_sep_l' idemp. Qed. Lemma always_and_sep P Q : □ (P ∧ Q) ⊣⊢ □ (P ∗ Q). Proof. apply (anti_symm (⊢)); auto. rewrite -{1}always_idemp always_and always_and_sep_l'; auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 531 ``````Lemma always_sep P Q : □ (P ∗ Q) ⊣⊢ □ P ∗ □ Q. `````` Robbert Krebbers committed Oct 25, 2016 532 533 ``````Proof. by rewrite -always_and_sep -always_and_sep_l' always_and. Qed. `````` Robbert Krebbers committed Nov 03, 2016 534 ``````Lemma always_wand P Q : □ (P -∗ Q) ⊢ □ P -∗ □ Q. `````` Robbert Krebbers committed Oct 25, 2016 535 ``````Proof. by apply wand_intro_r; rewrite -always_sep wand_elim_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 536 ``````Lemma always_wand_impl P Q : □ (P -∗ Q) ⊣⊢ □ (P → Q). `````` Robbert Krebbers committed Oct 25, 2016 537 538 539 540 541 ``````Proof. apply (anti_symm (⊢)); [|by rewrite -impl_wand]. apply always_intro', impl_intro_r. by rewrite always_and_sep_l' always_elim wand_elim_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 542 ``````Lemma always_entails_l' P Q : (P ⊢ □ Q) → P ⊢ □ Q ∗ P. `````` Robbert Krebbers committed Oct 25, 2016 543 ``````Proof. intros; rewrite -always_and_sep_l'; auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 544 ``````Lemma always_entails_r' P Q : (P ⊢ □ Q) → P ⊢ P ∗ □ Q. `````` Robbert Krebbers committed Oct 25, 2016 545 546 ``````Proof. intros; rewrite -always_and_sep_r'; auto. Qed. `````` Robbert Krebbers committed Nov 27, 2016 547 548 549 ``````Lemma always_laterN n P : □ ▷^n P ⊣⊢ ▷^n □ P. Proof. induction n as [|n IH]; simpl; auto. by rewrite always_later IH. Qed. `````` Robbert Krebbers committed May 12, 2017 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 ``````Lemma wand_alt P Q : (P -∗ Q) ⊣⊢ ∃ R, R ∗ □ (P ∗ R → Q). Proof. apply (anti_symm (⊢)). - rewrite -(right_id True%I uPred_sep (P -∗ Q)%I) -(exist_intro (P -∗ Q)%I). apply sep_mono_r. rewrite -always_pure. apply always_mono, impl_intro_l. by rewrite wand_elim_r right_id. - apply exist_elim=> R. apply wand_intro_l. rewrite assoc -always_and_sep_r'. by rewrite always_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 uPred_and (P → Q)%I) -(exist_intro (P → Q)%I). apply and_mono_r. rewrite -always_pure. apply always_mono, wand_intro_l. by rewrite impl_elim_r right_id. - apply exist_elim=> R. apply impl_intro_l. rewrite assoc always_and_sep_r'. by rewrite always_elim wand_elim_r. Qed. `````` Robbert Krebbers committed Nov 27, 2016 568 `````` `````` Robbert Krebbers committed Oct 25, 2016 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 ``````(* Later derived *) Lemma later_proper P Q : (P ⊣⊢ Q) → ▷ P ⊣⊢ ▷ Q. Proof. by intros ->. Qed. Hint Resolve later_mono later_proper. 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_intro P : P ⊢ ▷ P. Proof. rewrite -(and_elim_l (▷ P) P) -(löb (▷ P ∧ P)). apply impl_intro_l. by rewrite {1}(and_elim_r (▷ P)). Qed. Lemma later_True : ▷ True ⊣⊢ True. Proof. apply (anti_symm (⊢)); auto using later_intro. Qed. Lemma later_forall {A} (Φ : A → uPred M) : (▷ ∀ a, Φ a) ⊣⊢ (∀ a, ▷ Φ a). Proof. apply (anti_symm _); auto using later_forall_2. apply forall_intro=> x. by rewrite (forall_elim x). Qed. Lemma later_exist `{Inhabited A} (Φ : A → uPred M) : ▷ (∃ a, Φ a) ⊣⊢ (∃ a, ▷ Φ a). Proof. apply: anti_symm; [|apply exist_elim; eauto using exist_intro]. rewrite later_exist_false. apply or_elim; last done. rewrite -(exist_intro inhabitant); auto. Qed. Lemma later_and P Q : ▷ (P ∧ Q) ⊣⊢ ▷ P ∧ ▷ Q. Proof. rewrite !and_alt later_forall. by apply forall_proper=> -[]. Qed. Lemma later_or P Q : ▷ (P ∨ Q) ⊣⊢ ▷ P ∨ ▷ Q. Proof. rewrite !or_alt later_exist. by apply exist_proper=> -[]. Qed. Lemma later_impl P Q : ▷ (P → Q) ⊢ ▷ P → ▷ Q. Proof. apply impl_intro_l; rewrite -later_and; eauto using impl_elim. Qed. `````` Robbert Krebbers committed Nov 03, 2016 605 ``````Lemma later_wand P Q : ▷ (P -∗ Q) ⊢ ▷ P -∗ ▷ Q. `````` Robbert Krebbers committed Oct 25, 2016 606 607 608 609 610 ``````Proof. apply wand_intro_r; rewrite -later_sep; eauto using wand_elim_l. Qed. Lemma later_iff P Q : ▷ (P ↔ Q) ⊢ ▷ P ↔ ▷ Q. Proof. by rewrite /uPred_iff later_and !later_impl. Qed. `````` Robbert Krebbers committed Nov 27, 2016 611 ``````(* Iterated later modality *) `````` Ralf Jung committed Jan 27, 2017 612 ``````Global Instance laterN_ne m : NonExpansive (@uPred_laterN M m). `````` Robbert Krebbers committed Nov 27, 2016 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 ``````Proof. induction m; simpl. by intros ???. solve_proper. Qed. Global Instance laterN_proper m : Proper ((⊣⊢) ==> (⊣⊢)) (@uPred_laterN M m) := ne_proper _. Lemma laterN_0 P : ▷^0 P ⊣⊢ P. Proof. done. Qed. Lemma later_laterN n P : ▷^(S n) P ⊣⊢ ▷ ▷^n P. Proof. done. Qed. Lemma laterN_later n P : ▷^(S n) P ⊣⊢ ▷^n ▷ P. Proof. induction n; simpl; auto. Qed. Lemma laterN_plus n1 n2 P : ▷^(n1 + n2) P ⊣⊢ ▷^n1 ▷^n2 P. Proof. induction n1; simpl; auto. Qed. Lemma laterN_le n1 n2 P : n1 ≤ n2 → ▷^n1 P ⊢ ▷^n2 P. Proof. induction 1; simpl; by rewrite -?later_intro. Qed. Lemma laterN_mono n P Q : (P ⊢ Q) → ▷^n P ⊢ ▷^n Q. Proof. induction n; simpl; auto. Qed. Global Instance laterN_mono' n : Proper ((⊢) ==> (⊢)) (@uPred_laterN M n). Proof. intros P Q; apply laterN_mono. Qed. Global Instance laterN_flip_mono' n : Proper (flip (⊢) ==> flip (⊢)) (@uPred_laterN M n). Proof. intros P Q; apply laterN_mono. Qed. Lemma laterN_intro n P : P ⊢ ▷^n P. Proof. induction n as [|n IH]; simpl; by rewrite -?later_intro. Qed. Lemma laterN_True n : ▷^n True ⊣⊢ True. Proof. apply (anti_symm (⊢)); auto using laterN_intro. Qed. Lemma laterN_forall {A} n (Φ : A → uPred M) : (▷^n ∀ a, Φ a) ⊣⊢ (∀ a, ▷^n Φ a). Proof. induction n as [|n IH]; simpl; rewrite -?later_forall; auto. Qed. Lemma laterN_exist `{Inhabited A} n (Φ : A → uPred M) : (▷^n ∃ a, Φ a) ⊣⊢ ∃ a, ▷^n Φ a. Proof. induction n as [|n IH]; simpl; rewrite -?later_exist; auto. Qed. Lemma laterN_and n P Q : ▷^n (P ∧ Q) ⊣⊢ ▷^n P ∧ ▷^n Q. Proof. induction n as [|n IH]; simpl; rewrite -?later_and; auto. Qed. Lemma laterN_or n P Q : ▷^n (P ∨ Q) ⊣⊢ ▷^n P ∨ ▷^n Q. Proof. induction n as [|n IH]; simpl; rewrite -?later_or; auto. Qed. Lemma laterN_impl n P Q : ▷^n (P → Q) ⊢ ▷^n P → ▷^n Q. Proof. apply impl_intro_l; rewrite -laterN_and; eauto using impl_elim, laterN_mono. Qed. Lemma laterN_sep n P Q : ▷^n (P ∗ Q) ⊣⊢ ▷^n P ∗ ▷^n Q. Proof. induction n as [|n IH]; simpl; rewrite -?later_sep; auto. Qed. Lemma laterN_wand n P Q : ▷^n (P -∗ Q) ⊢ ▷^n P -∗ ▷^n Q. Proof. apply wand_intro_r; rewrite -laterN_sep; eauto using wand_elim_l,laterN_mono. Qed. Lemma laterN_iff n P Q : ▷^n (P ↔ Q) ⊢ ▷^n P ↔ ▷^n Q. Proof. by rewrite /uPred_iff laterN_and !laterN_impl. Qed. `````` Robbert Krebbers committed Oct 25, 2016 663 ``````(* Conditional always *) `````` Ralf Jung committed Jan 27, 2017 664 ``````Global Instance always_if_ne p : NonExpansive (@uPred_always_if M p). `````` Robbert Krebbers committed Oct 25, 2016 665 666 667 668 669 670 671 672 673 674 675 ``````Proof. solve_proper. Qed. Global Instance always_if_proper p : Proper ((⊣⊢) ==> (⊣⊢)) (@uPred_always_if M p). Proof. solve_proper. Qed. Global Instance always_if_mono p : Proper ((⊢) ==> (⊢)) (@uPred_always_if M p). Proof. solve_proper. Qed. Lemma always_if_elim p P : □?p P ⊢ P. Proof. destruct p; simpl; auto using always_elim. Qed. Lemma always_elim_if p P : □ P ⊢ □?p P. Proof. destruct p; simpl; auto using always_elim. Qed. `````` Ralf Jung committed Nov 22, 2016 676 ``````Lemma always_if_pure p φ : □?p ⌜φ⌝ ⊣⊢ ⌜φ⌝. `````` Robbert Krebbers committed Oct 25, 2016 677 678 679 680 681 682 683 ``````Proof. destruct p; simpl; auto using always_pure. Qed. Lemma always_if_and p P Q : □?p (P ∧ Q) ⊣⊢ □?p P ∧ □?p Q. Proof. destruct p; simpl; auto using always_and. Qed. Lemma always_if_or p P Q : □?p (P ∨ Q) ⊣⊢ □?p P ∨ □?p Q. Proof. destruct p; simpl; auto using always_or. Qed. Lemma always_if_exist {A} p (Ψ : A → uPred M) : (□?p ∃ a, Ψ a) ⊣⊢ ∃ a, □?p Ψ a. Proof. destruct p; simpl; auto using always_exist. Qed. `````` Robbert Krebbers committed Nov 03, 2016 684 ``````Lemma always_if_sep p P Q : □?p (P ∗ Q) ⊣⊢ □?p P ∗ □?p Q. `````` Robbert Krebbers committed Oct 25, 2016 685 686 687 ``````Proof. destruct p; simpl; auto using always_sep. Qed. Lemma always_if_later p P : □?p ▷ P ⊣⊢ ▷ □?p P. Proof. destruct p; simpl; auto using always_later. Qed. `````` Robbert Krebbers committed Mar 15, 2017 688 689 ``````Lemma always_if_laterN p n P : □?p ▷^n P ⊣⊢ ▷^n □?p P. Proof. destruct p; simpl; auto using always_laterN. Qed. `````` Robbert Krebbers committed Oct 25, 2016 690 691 `````` (* True now *) `````` Ralf Jung committed Jan 27, 2017 692 ``````Global Instance except_0_ne : NonExpansive (@uPred_except_0 M). `````` Robbert Krebbers committed Oct 25, 2016 693 ``````Proof. solve_proper. Qed. `````` Robbert Krebbers committed Oct 25, 2016 694 ``````Global Instance except_0_proper : Proper ((⊣⊢) ==> (⊣⊢)) (@uPred_except_0 M). `````` Robbert Krebbers committed Oct 25, 2016 695 ``````Proof. solve_proper. Qed. `````` Robbert Krebbers committed Oct 25, 2016 696 ``````Global Instance except_0_mono' : Proper ((⊢) ==> (⊢)) (@uPred_except_0 M). `````` Robbert Krebbers committed Oct 25, 2016 697 ``````Proof. solve_proper. Qed. `````` Robbert Krebbers committed Oct 25, 2016 698 699 ``````Global Instance except_0_flip_mono' : Proper (flip (⊢) ==> flip (⊢)) (@uPred_except_0 M). `````` Robbert Krebbers committed Oct 25, 2016 700 701 ``````Proof. solve_proper. Qed. `````` Robbert Krebbers committed Oct 25, 2016 702 703 704 ``````Lemma except_0_intro P : P ⊢ ◇ P. Proof. rewrite /uPred_except_0; auto. Qed. Lemma except_0_mono P Q : (P ⊢ Q) → ◇ P ⊢ ◇ Q. `````` Robbert Krebbers committed Oct 25, 2016 705 ``````Proof. by intros ->. Qed. `````` Robbert Krebbers committed Oct 25, 2016 706 707 708 709 710 711 712 713 714 ``````Lemma except_0_idemp P : ◇ ◇ P ⊢ ◇ P. Proof. rewrite /uPred_except_0; auto. Qed. Lemma except_0_True : ◇ True ⊣⊢ True. Proof. rewrite /uPred_except_0. apply (anti_symm _); auto. Qed. Lemma except_0_or P Q : ◇ (P ∨ Q) ⊣⊢ ◇ P ∨ ◇ Q. Proof. rewrite /uPred_except_0. apply (anti_symm _); auto. Qed. Lemma except_0_and P Q : ◇ (P ∧ Q) ⊣⊢ ◇ P ∧ ◇ Q. Proof. by rewrite /uPred_except_0 or_and_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 715 ``````Lemma except_0_sep P Q : ◇ (P ∗ Q) ⊣⊢ ◇ P ∗ ◇ Q. `````` Robbert Krebbers committed Oct 25, 2016 716 717 ``````Proof. rewrite /uPred_except_0. apply (anti_symm _). `````` Robbert Krebbers committed Oct 25, 2016 718 719 720 721 `````` - apply or_elim; last by auto. by rewrite -!or_intro_l -always_pure -always_later -always_sep_dup'. - rewrite sep_or_r sep_elim_l sep_or_l; auto. Qed. `````` Robbert Krebbers committed Oct 25, 2016 722 ``````Lemma except_0_forall {A} (Φ : A → uPred M) : ◇ (∀ a, Φ a) ⊢ ∀ a, ◇ Φ a. `````` Robbert Krebbers committed Oct 25, 2016 723 ``````Proof. apply forall_intro=> a. by rewrite (forall_elim a). Qed. `````` Robbert Krebbers committed May 12, 2017 724 ``````Lemma except_0_exist_2 {A} (Φ : A → uPred M) : (∃ a, ◇ Φ a) ⊢ ◇ ∃ a, Φ a. `````` Robbert Krebbers committed Oct 25, 2016 725 ``````Proof. apply exist_elim=> a. by rewrite (exist_intro a). Qed. `````` Robbert Krebbers committed May 12, 2017 726 727 728 729 730 731 732 ``````Lemma except_0_exist `{Inhabited A} (Φ : A → uPred M) : ◇ (∃ a, Φ a) ⊣⊢ (∃ a, ◇ Φ a). Proof. apply (anti_symm _); [|by apply except_0_exist_2]. apply or_elim. - rewrite -(exist_intro inhabitant). by apply or_intro_l. - apply exist_mono=> a. apply except_0_intro. Qed. `````` Robbert Krebbers committed Oct 25, 2016 733 734 735 736 737 738 ``````Lemma except_0_later P : ◇ ▷ P ⊢ ▷ P. Proof. by rewrite /uPred_except_0 -later_or False_or. Qed. Lemma except_0_always P : ◇ □ P ⊣⊢ □ ◇ P. Proof. by rewrite /uPred_except_0 always_or always_later always_pure. Qed. Lemma except_0_always_if p P : ◇ □?p P ⊣⊢ □?p ◇ P. Proof. destruct p; simpl; auto using except_0_always. Qed. `````` Robbert Krebbers committed Nov 03, 2016 739 ``````Lemma except_0_frame_l P Q : P ∗ ◇ Q ⊢ ◇ (P ∗ Q). `````` Robbert Krebbers committed Oct 25, 2016 740 ``````Proof. by rewrite {1}(except_0_intro P) except_0_sep. Qed. `````` Robbert Krebbers committed Nov 03, 2016 741 ``````Lemma except_0_frame_r P Q : ◇ P ∗ Q ⊢ ◇ (P ∗ Q). `````` Robbert Krebbers committed Oct 25, 2016 742 ``````Proof. by rewrite {1}(except_0_intro Q) except_0_sep. Qed. `````` Robbert Krebbers committed Oct 25, 2016 743 744 745 746 747 748 749 750 751 752 753 754 `````` (* Own and valid derived *) Lemma always_ownM (a : M) : Persistent a → □ uPred_ownM a ⊣⊢ uPred_ownM a. Proof. intros; apply (anti_symm _); first by apply:always_elim. by rewrite {1}always_ownM_core persistent_core. Qed. Lemma ownM_invalid (a : M) : ¬ ✓{0} a → uPred_ownM a ⊢ False. Proof. by intros; rewrite ownM_valid cmra_valid_elim. Qed. Global Instance ownM_mono : Proper (flip (≼) ==> (⊢)) (@uPred_ownM M). Proof. intros a b [b' ->]. rewrite ownM_op. eauto. Qed. Lemma ownM_empty' : uPred_ownM ∅ ⊣⊢ True. `````` 755 ``````Proof. apply (anti_symm _); first by auto. apply ownM_empty. Qed. `````` Robbert Krebbers committed Oct 25, 2016 756 757 758 759 760 761 762 763 764 765 766 ``````Lemma always_cmra_valid {A : cmraT} (a : A) : □ ✓ a ⊣⊢ ✓ a. Proof. intros; apply (anti_symm _); first by apply:always_elim. apply:always_cmra_valid_1. Qed. (** * Derived rules *) Global Instance bupd_mono' : Proper ((⊢) ==> (⊢)) (@uPred_bupd M). Proof. intros P Q; apply bupd_mono. Qed. Global Instance bupd_flip_mono' : Proper (flip (⊢) ==> flip (⊢)) (@uPred_bupd M). Proof. intros P Q; apply bupd_mono. Qed. `````` Robbert Krebbers committed Nov 03, 2016 767 ``````Lemma bupd_frame_l R Q : (R ∗ |==> Q) ==∗ R ∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 768 ``````Proof. rewrite !(comm _ R); apply bupd_frame_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 769 ``````Lemma bupd_wand_l P Q : (P -∗ Q) ∗ (|==> P) ==∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 770 ``````Proof. by rewrite bupd_frame_l wand_elim_l. Qed. `````` Robbert Krebbers committed Nov 03, 2016 771 ``````Lemma bupd_wand_r P Q : (|==> P) ∗ (P -∗ Q) ==∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 772 ``````Proof. by rewrite bupd_frame_r wand_elim_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 773 ``````Lemma bupd_sep P Q : (|==> P) ∗ (|==> Q) ==∗ P ∗ Q. `````` Robbert Krebbers committed Oct 25, 2016 774 775 776 777 778 779 ``````Proof. by rewrite bupd_frame_r bupd_frame_l bupd_trans. Qed. Lemma bupd_ownM_update x y : x ~~> y → uPred_ownM x ⊢ |==> uPred_ownM y. Proof. intros; rewrite (bupd_ownM_updateP _ (y =)); last by apply cmra_update_updateP. by apply bupd_mono, exist_elim=> y'; apply pure_elim_l=> ->. Qed. `````` Robbert Krebbers committed Oct 25, 2016 780 ``````Lemma except_0_bupd P : ◇ (|==> P) ⊢ (|==> ◇ P). `````` Robbert Krebbers committed Oct 25, 2016 781 ``````Proof. `````` Robbert Krebbers committed Oct 25, 2016 782 `````` rewrite /uPred_except_0. apply or_elim; auto using bupd_mono. `````` Robbert Krebbers committed Oct 25, 2016 783 784 785 786 `````` by rewrite -bupd_intro -or_intro_l. Qed. (* Timeless instances *) `````` Robbert Krebbers committed Feb 11, 2017 787 788 ``````Global Instance TimelessP_proper : Proper ((≡) ==> iff) (@TimelessP M). Proof. solve_proper. Qed. `````` Ralf Jung committed Nov 22, 2016 789 ``````Global Instance pure_timeless φ : TimelessP (⌜φ⌝ : uPred M)%I. `````` Robbert Krebbers committed Oct 25, 2016 790 791 792 793 794 795 796 ``````Proof. rewrite /TimelessP pure_alt later_exist_false. by setoid_rewrite later_True. Qed. Global Instance valid_timeless {A : cmraT} `{CMRADiscrete A} (a : A) : TimelessP (✓ a : uPred M)%I. Proof. rewrite /TimelessP !discrete_valid. apply (timelessP _). Qed. Global Instance and_timeless P Q: TimelessP P → TimelessP Q → TimelessP (P ∧ Q). `````` Robbert Krebbers committed Oct 25, 2016 797 ``````Proof. intros; rewrite /TimelessP except_0_and later_and; auto. Qed. `````` Robbert Krebbers committed Oct 25, 2016 798 ``````Global Instance or_timeless P Q : TimelessP P → TimelessP Q → TimelessP (P ∨ Q). `````` Robbert Krebbers committed Oct 25, 2016 799 ``````Proof. intros; rewrite /TimelessP except_0_or later_or; auto. Qed. `````` Robbert Krebbers committed Oct 25, 2016 800 801 802 803 804 ``````Global Instance impl_timeless P Q : TimelessP Q → TimelessP (P → Q). Proof. rewrite /TimelessP=> HQ. rewrite later_false_excluded_middle. apply or_mono, impl_intro_l; first done. rewrite -{2}(löb Q); apply impl_intro_l. `````` Robbert Krebbers committed Oct 25, 2016 805 `````` rewrite HQ /uPred_except_0 !and_or_r. apply or_elim; last auto. `````` Robbert Krebbers committed Oct 25, 2016 806 807 `````` by rewrite assoc (comm _ _ P) -assoc !impl_elim_r. Qed. `````` Robbert Krebbers committed Nov 03, 2016 808 ``````Global Instance sep_timeless P Q: TimelessP P → TimelessP Q → TimelessP (P ∗ Q). `````` Robbert Krebbers committed Oct 25, 2016 809 ``````Proof. intros; rewrite /TimelessP except_0_sep later_sep; auto. Qed. `````` Robbert Krebbers committed Nov 03, 2016 810 ``````Global Instance wand_timeless P Q : TimelessP Q → TimelessP (P -∗ Q). `````` Robbert Krebbers committed Oct 25, 2016 811 812 813 814 ``````Proof. rewrite /TimelessP=> HQ. rewrite later_false_excluded_middle. apply or_mono, wand_intro_l; first done. rewrite -{2}(löb Q); apply impl_intro_l. `````` Robbert Krebbers committed Oct 25, 2016 815 `````` rewrite HQ /uPred_except_0 !and_or_r. apply or_elim; last auto. `````` Robbert Krebbers committed Oct 25, 2016 816 817 818 819 820 821 822 823 824 `````` rewrite -(always_pure) -always_later always_and_sep_l'. by rewrite assoc (comm _ _ P) -assoc -always_and_sep_l' impl_elim_r wand_elim_r. Qed. Global Instance forall_timeless {A} (Ψ : A → uPred M) : (∀ x, TimelessP (Ψ x)) → TimelessP (∀ x, Ψ x). Proof. rewrite /TimelessP=> HQ. rewrite later_false_excluded_middle. apply or_mono; first done. apply forall_intro=> x. rewrite -(löb (Ψ x)); apply impl_intro_l. `````` Robbert Krebbers committed Oct 25, 2016 825 `````` rewrite HQ /uPred_except_0 !and_or_r. apply or_elim; last auto. `````` Robbert Krebbers committed Oct 25, 2016 826 827 828 829 830 831 `````` by rewrite impl_elim_r (forall_elim x). Qed. Global Instance exist_timeless {A} (Ψ : A → uPred M) : (∀ x, TimelessP (Ψ x)) → TimelessP (∃ x, Ψ x). Proof. rewrite /TimelessP=> ?. rewrite later_exist_false. apply or_elim. `````` Robbert Krebbers committed Oct 25, 2016 832 `````` - rewrite /uPred_except_0; auto. `````` Robbert Krebbers committed Oct 25, 2016 833 834 835 `````` - apply exist_elim=> x. rewrite -(exist_intro x); auto. Qed. Global Instance always_timeless P : TimelessP P → TimelessP (□ P). `````` Robbert Krebbers committed Oct 25, 2016 836 ``````Proof. intros; rewrite /TimelessP except_0_always -always_later; auto. Qed. `````` Robbert Krebbers committed Oct 25, 2016 837 838 ``````Global Instance always_if_timeless p P : TimelessP P → TimelessP (□?p P). Proof. destruct p; apply _. Qed. `````` Ralf Jung committed Nov 22, 2016 839 ``````Global Instance eq_timeless {A : ofeT} (a b : A) : `````` Robbert Krebbers committed Oct 25, 2016 840 841 842 843 844 `````` Timeless a → TimelessP (a ≡ b : uPred M)%I. Proof. intros. rewrite /TimelessP !timeless_eq. apply (timelessP _). Qed. Global Instance ownM_timeless (a : M) : Timeless a → TimelessP (uPred_ownM a). Proof. intros ?. rewrite /TimelessP later_ownM. apply exist_elim=> b. `````` Robbert Krebbers committed Oct 25, 2016 845 `````` rewrite (timelessP (a≡b)) (except_0_intro (uPred_ownM b)) -except_0_and. `````` Robbert Krebbers committed Oct 25, 2016 846 847 `````` apply except_0_mono. rewrite internal_eq_sym. apply (internal_eq_rewrite b a (uPred_ownM)); first apply _; auto. `````` Robbert Krebbers committed Oct 25, 2016 848 ``````Qed. `````` Robbert Krebbers committed Nov 29, 2016 849 850 851 ``````Global Instance from_option_timeless {A} P (Ψ : A → uPred M) (mx : option A) : (∀ x, TimelessP (Ψ x)) → TimelessP P → TimelessP (from_option Ψ P mx). Proof. destruct mx; apply _. Qed. `````` Robbert Krebbers committed Oct 25, 2016 852 `````` `````` Robbert Krebbers committed Jan 22, 2017 853 ``````(* Derived lemmas for persistence *) `````` Robbert Krebbers committed Feb 11, 2017 854 855 ``````Global Instance PersistentP_proper : Proper ((≡) ==> iff) (@PersistentP M). Proof. solve_proper. Qed. `````` Robbert Krebbers committed Mar 09, 2017 856 857 858 ``````Global Instance limit_preserving_PersistentP {A:ofeT} `{Cofe A} (Φ : A → uPred M) : NonExpansive Φ → LimitPreserving (λ x, PersistentP (Φ x)). Proof. intros. apply limit_preserving_entails; solve_proper. Qed. `````` Robbert Krebbers committed Feb 11, 2017 859 `````` `````` Robbert Krebbers committed Jan 22, 2017 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 ``````Lemma always_always P `{!PersistentP P} : □ P ⊣⊢ P. Proof. apply (anti_symm (⊢)); auto using always_elim. Qed. Lemma always_if_always p P `{!PersistentP P} : □?p P ⊣⊢ P. Proof. destruct p; simpl; auto using always_always. Qed. Lemma always_intro P Q `{!PersistentP P} : (P ⊢ Q) → P ⊢ □ Q. Proof. rewrite -(always_always P); apply always_intro'. Qed. Lemma always_and_sep_l P Q `{!PersistentP P} : P ∧ Q ⊣⊢ P ∗ Q. Proof. by rewrite -(always_always P) always_and_sep_l'. Qed. Lemma always_and_sep_r P Q `{!PersistentP Q} : P ∧ Q ⊣⊢ P ∗ Q. Proof. by rewrite -(always_always Q) always_and_sep_r'. Qed. Lemma always_sep_dup P `{!PersistentP P} : P ⊣⊢ P ∗ P. Proof. by rewrite -(always_always P) -always_sep_dup'. Qed. Lemma always_entails_l P Q `{!PersistentP Q} : (P ⊢ Q) → P ⊢ Q ∗ P. Proof. by rewrite -(always_always Q); apply always_entails_l'. Qed. Lemma always_entails_r P Q `{!PersistentP Q} : (P ⊢ Q) → P ⊢ P ∗ Q. Proof. by rewrite -(always_always Q); apply always_entails_r'. Qed. Lemma always_impl_wand P `{!PersistentP P} Q : (P → Q) ⊣⊢ (P -∗ Q). Proof. apply (anti_symm _); auto using impl_wand. apply impl_intro_l. by rewrite always_and_sep_l wand_elim_r. Qed. `````` Robbert Krebbers committed Oct 25, 2016 882 ``````(* Persistence *) `````` Ralf Jung committed Nov 22, 2016 883 ``````Global Instance pure_persistent φ : PersistentP (⌜φ⌝ : uPred M)%I. `````` Robbert Krebbers committed Oct 25, 2016 884 ``````Proof. by rewrite /PersistentP always_pure. Qed. `````` Robbert Krebbers committed Jan 22, 2017 885 886 887 888 889 890 891 892 893 894 895 ``````Global Instance pure_impl_persistent φ Q : PersistentP Q → PersistentP (⌜φ⌝ → Q)%I. Proof. rewrite /PersistentP pure_impl_forall always_forall. auto using forall_mono. Qed. Global Instance pure_wand_persistent φ Q : PersistentP Q → PersistentP (⌜φ⌝ -∗ Q)%I. Proof. rewrite /PersistentP -always_impl_wand pure_impl_forall always_forall. auto using forall_mono. Qed. `````` Robbert Krebbers committed Oct 25, 2016 896 897 898 899 900 901 902 903 904 ``````Global Instance always_persistent P : PersistentP (□ P). Proof. by intros; apply always_intro'. Qed. Global Instance and_persistent P Q : PersistentP P → PersistentP Q → PersistentP (P ∧ Q). Proof. by intros; rewrite /PersistentP always_and; apply and_mono. Qed. Global Instance or_persistent P Q : PersistentP P → PersistentP Q → PersistentP (P ∨ Q). Proof. by intros; rewrite /PersistentP always_or; apply or_mono. Qed. Global Instance sep_persistent P Q : `````` Robbert Krebbers committed Nov 03, 2016 905 `````` PersistentP P → PersistentP Q → PersistentP (P ∗ Q). `````` Robbert Krebbers committed Oct 25, 2016 906 907 908 909 910 911 912 ``````Proof. by intros; rewrite /PersistentP always_sep; apply sep_mono. Qed. Global Instance forall_persistent {A} (Ψ : A → uPred M) : (∀ x, PersistentP (Ψ x)) → PersistentP (∀ x, Ψ x). Proof. by intros; rewrite /PersistentP always_forall; apply forall_mono. Qed. Global Instance exist_persistent {A} (Ψ : A → uPred M) : (∀ x, PersistentP (Ψ x)) → PersistentP (∃ x, Ψ x). Proof. by intros; rewrite /PersistentP always_exist; apply exist_mono. Qed. `````` Ralf Jung committed Nov 22, 2016 913 ``````Global Instance internal_eq_persistent {A : ofeT} (a b : A) : `````` Robbert Krebbers committed Oct 25, 2016 914 `````` PersistentP (a ≡ b : uPred M)%I. `````` Robbert Krebbers committed Oct 25, 2016 915 ``````Proof. by intros; rewrite /PersistentP always_internal_eq. Qed. `````` Robbert Krebbers committed Oct 25, 2016 916 917 918 919 920 ``````Global Instance cmra_valid_persistent {A : cmraT} (a : A) : PersistentP (✓ a : uPred M)%I. Proof. by intros; rewrite /PersistentP always_cmra_valid. Qed. Global Instance later_persistent P : PersistentP P → PersistentP (▷ P). Proof. by intros; rewrite /PersistentP always_later; apply later_mono. Qed. `````` Robbert Krebbers committed Nov 27, 2016 921 922 ``````Global Instance laterN_persistent n P : PersistentP P → PersistentP (▷^n P). Proof. induction n; apply _. Qed. `````` Robbert Krebbers committed Oct 25, 2016 923 924 925 926 927 ``````Global Instance ownM_persistent : Persistent a → PersistentP (@uPred_ownM M a). Proof. intros. by rewrite /PersistentP always_ownM. Qed. Global Instance from_option_persistent {A} P (Ψ : A → uPred M) (mx : option A) : (∀ x, PersistentP (Ψ x)) → PersistentP P → PersistentP (from_option Ψ P mx). Proof. destruct mx; apply _. Qed. `````` Robbert Krebbers committed Mar 24, 2017 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 `````` (* For big ops *) Global Instance uPred_and_monoid : Monoid (@uPred_and M) := {| monoid_unit := True%I |}. Global Instance uPred_or_monoid : Monoid (@uPred_or M) := {| monoid_unit := False%I |}. Global Instance uPred_sep_monoid : Monoid (@uPred_sep M) := {| monoid_unit := True%I |}. Global Instance uPred_always_and_homomorphism : MonoidHomomorphism uPred_and uPred_and (@uPred_always M). Proof. split; [split|]. apply _. apply always_and. apply always_pure. Qed. Global Instance uPred_always_if_and_homomorphism b : MonoidHomomorphism uPred_and uPred_and (@uPred_always_if M b). Proof. split; [split|]. apply _. apply always_if_and. apply always_if_pure. Qed. Global Instance uPred_later_monoid_and_homomorphism : MonoidHomomorphism uPred_and uPred_and (@uPred_later M). Proof. split; [split|]. apply _. apply later_and. apply later_True. Qed. Global Instance uPred_laterN_and_homomorphism n : MonoidHomomorphism uPred_and uPred_and (@uPred_laterN M n). Proof. split; [split|]. apply _. apply laterN_and. apply laterN_True. Qed. Global Instance uPred_except_0_and_homomorphism : MonoidHomomorphism uPred_and uPred_and (@uPred_except_0 M). Proof. split; [split|]. apply _. apply except_0_and. apply except_0_True. Qed. Global Instance uPred_always_or_homomorphism : MonoidHomomorphism uPred_or uPred_or (@uPred_always M). Proof. split; [split|]. apply _. apply always_or. apply always_pure. Qed. Global Instance uPred_always_if_or_homomorphism b : MonoidHomomorphism uPred_or uPred_or (@uPred_always_if M b). Proof. split; [split|]. apply _. apply always_if_or. apply always_if_pure. Qed. Global Instance uPred_later_monoid_or_homomorphism : WeakMonoidHomomorphism uPred_or uPred_or (@uPred_later M). Proof. split. apply _. apply later_or. Qed. Global Instance uPred_laterN_or_homomorphism n : WeakMonoidHomomorphism uPred_or uPred_or (@uPred_laterN M n). Proof. split. apply _. apply laterN_or. Qed. Global Instance uPred_except_0_or_homomorphism : WeakMonoidHomomorphism uPred_or uPred_or (@uPred_except_0 M). Proof. split. apply _. apply except_0_or. Qed. Global Instance uPred_always_sep_homomorphism : MonoidHomomorphism uPred_sep uPred_sep (@uPred_always M). Proof. split; [split|]. apply _. apply always_sep. apply always_pure. Qed. Global Instance uPred_always_if_sep_homomorphism b : MonoidHomomorphism uPred_sep uPred_sep (@uPred_always_if M b). Proof. split; [split|]. apply _. apply always_if_sep. apply always_if_pure. Qed. Global Instance uPred_later_monoid_sep_homomorphism : MonoidHomomorphism uPred_sep uPred_sep (@uPred_later M). Proof. split; [split|]. apply _. apply later_sep. apply later_True. Qed. Global Instance uPred_laterN_sep_homomorphism n : MonoidHomomorphism uPred_sep uPred_sep (@uPred_laterN M n). Proof. split; [split|]. apply _. apply laterN_sep. apply laterN_True. Qed. Global Instance uPred_except_0_sep_homomorphism : MonoidHomomorphism uPred_sep uPred_sep (@uPred_except_0 M). Proof. split; [split|]. apply _. apply except_0_sep. apply except_0_True. Qed. Global Instance uPred_ownM_sep_homomorphism : MonoidHomomorphism op uPred_sep (@uPred_ownM M). Proof. split; [split|]. apply _. apply ownM_op. apply ownM_empty'. Qed. `````` Robbert Krebbers committed Oct 25, 2016 987 ``````End derived. `````` Robbert Krebbers committed Dec 13, 2016 988 ``End uPred.``