monpred.v 45.8 KB
Newer Older
1
From stdpp Require Import coPset.
2
From iris.bi Require Import bi.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
3

4
(** Definitions. *)
5
Structure biIndex :=
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
6
7
  BiIndex
    { bi_index_type :> Type;
8
      bi_index_inhabited : Inhabited bi_index_type;
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
9
      bi_index_rel : SqSubsetEq bi_index_type;
10
      bi_index_rel_preorder : PreOrder (@{bi_index_type}) }.
11
Existing Instances bi_index_inhabited bi_index_rel bi_index_rel_preorder.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
12

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
13
14
15
16
(* We may want to instantiate monPred with the reflexivity relation in
   the case where there is no relevent order. In that case, there is
   no bottom element, so that we do not want to force any BI index to
   have one. *)
17
18
19
Class BiIndexBottom {I : biIndex} (bot : I) :=
  bi_index_bot i : bot  i.

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
20
Section Ofe_Cofe.
21
Context {I : biIndex} {PROP : bi}.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
22
23
24
Implicit Types i : I.

Record monPred :=
25
26
  MonPred { monPred_at :> I  PROP;
            monPred_mono : Proper (() ==> ()) monPred_at }.
27
Local Existing Instance monPred_mono.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
28

29
30
Bind Scope monPred with bi.

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
31
Implicit Types P Q : monPred.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
32

33
(** Ofe + Cofe instances  *)
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
34

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
35
36
Section Ofe_Cofe_def.
  Inductive monPred_equiv' P Q : Prop :=
37
    { monPred_in_equiv i : P i  Q i } .
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
38
39
  Instance monPred_equiv : Equiv monPred := monPred_equiv'.
  Inductive monPred_dist' (n : nat) (P Q : monPred) : Prop :=
40
    { monPred_in_dist i : P i {n} Q i }.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
41
  Instance monPred_dist : Dist monPred := monPred_dist'.
42

43
  Definition monPred_sig P : { f : I -d> PROP | Proper (() ==> ()) f } :=
44
    exist _ (monPred_at P) (monPred_mono P).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
45

46
  Definition sig_monPred (P' : { f : I -d> PROP | Proper (() ==> ()) f })
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
47
48
    : monPred :=
    MonPred (proj1_sig P') (proj2_sig P').
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
49

50
51
52
53
  (* These two lemma use the wrong Equiv and Dist instance for
    monPred. so we make sure they are not accessible outside of the
    section by using Let. *)
  Let monPred_sig_equiv:
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
54
     P Q, P  Q  monPred_sig P  monPred_sig Q.
55
56
  Proof. by split; [intros []|]. Qed.
  Let monPred_sig_dist:
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
57
     n,  P Q : monPred, P {n} Q  monPred_sig P {n} monPred_sig Q.
58
  Proof. by split; [intros []|]. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
59

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
60
  Definition monPred_ofe_mixin : OfeMixin monPred.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
61
62
  Proof. by apply (iso_ofe_mixin monPred_sig monPred_sig_equiv monPred_sig_dist). Qed.

63
  Canonical Structure monPredO := OfeT monPred monPred_ofe_mixin.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
64

65
  Global Instance monPred_cofe `{Cofe PROP} : Cofe monPredO.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
66
  Proof.
67
    unshelve refine (iso_cofe_subtype (A:=I-d>PROP) _ MonPred monPred_at _ _ _);
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
68
      [apply _|by apply monPred_sig_dist|done|].
69
70
    intros c i j Hij. apply @limit_preserving;
      [by apply bi.limit_preserving_entails; intros ??|]=>n. by rewrite Hij.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
71
  Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
72
73
End Ofe_Cofe_def.

74
Lemma monPred_sig_monPred (P' : { f : I -d> PROP | Proper (() ==> ()) f }) :
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
75
76
77
78
79
80
81
82
83
84
85
86
87
  monPred_sig (sig_monPred P')  P'.
Proof. by change (P'  P'). Qed.
Lemma sig_monPred_sig P : sig_monPred (monPred_sig P)  P.
Proof. done. Qed.

Global Instance monPred_sig_ne : NonExpansive monPred_sig.
Proof. move=> ??? [?] ? //=. Qed.
Global Instance monPred_sig_proper : Proper (() ==> ()) monPred_sig.
Proof. eapply (ne_proper _). Qed.
Global Instance sig_monPred_ne : NonExpansive (@sig_monPred).
Proof. split=>? //=. Qed.
Global Instance sig_monPred_proper : Proper (() ==> ()) sig_monPred.
Proof. eapply (ne_proper _). Qed.
88
89
90
91
92
93

(* We generalize over the relation R which is morally the equivalence
   relation over B. That way, the BI index can use equality as an
   equivalence relation (and Coq is able to infer the Proper and
   Reflexive instances properly), or any other equivalence relation,
   provided it is compatible with (⊑). *)
94
Global Instance monPred_at_ne (R : relation I) :
95
  Proper (R ==> R ==> iff) ()  Reflexive R 
96
   n, Proper (dist n ==> R ==> dist n) monPred_at.
97
98
99
100
Proof.
  intros ????? [Hd] ?? HR. rewrite Hd.
  apply equiv_dist, bi.equiv_spec; split; f_equiv; rewrite ->HR; done.
Qed.
101
Global Instance monPred_at_proper (R : relation I) :
102
  Proper (R ==> R ==> iff) ()  Reflexive R 
103
  Proper (() ==> R ==> ()) monPred_at.
104
Proof. repeat intro. apply equiv_dist=>?. f_equiv=>//. by apply equiv_dist. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
105
106
107
End Ofe_Cofe.

Arguments monPred _ _ : clear implicits.
108
Arguments monPred_at {_ _} _%I _.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
109
Local Existing Instance monPred_mono.
110
Arguments monPredO _ _ : clear implicits.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
111

112
113
(** BI and SBI structures. *)

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
114
Section Bi.
115
Context {I : biIndex} {PROP : bi}.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
116
Implicit Types i : I.
117
Notation monPred := (monPred I PROP).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
118
119
120
Implicit Types P Q : monPred.

Inductive monPred_entails (P1 P2 : monPred) : Prop :=
121
  { monPred_in_entails i : P1 i  P2 i }.
Tej Chajed's avatar
Tej Chajed committed
122
Hint Immediate monPred_in_entails : core.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
123

124
Program Definition monPred_upclosed (Φ : I  PROP) : monPred :=
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
125
  MonPred (λ i, ( j, i  j  Φ j)%I) _.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
126
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
127

128
129
Definition monPred_embed_def (P : PROP) : monPred := MonPred (λ _, P) _.
Definition monPred_embed_aux : seal (@monPred_embed_def). by eexists. Qed.
130
131
Definition monPred_embed : Embed PROP monPred := monPred_embed_aux.(unseal).
Definition monPred_embed_eq : @embed _ _ monPred_embed = _ := monPred_embed_aux.(seal_eq).
132
133
134

Definition monPred_emp_def : monPred := MonPred (λ _, emp)%I _.
Definition monPred_emp_aux : seal (@monPred_emp_def). by eexists. Qed.
135
136
Definition monPred_emp := monPred_emp_aux.(unseal).
Definition monPred_emp_eq : @monPred_emp = _ := monPred_emp_aux.(seal_eq).
137
138
139

Definition monPred_pure_def (φ : Prop) : monPred := MonPred (λ _, ⌜φ⌝)%I _.
Definition monPred_pure_aux : seal (@monPred_pure_def). by eexists. Qed.
140
141
Definition monPred_pure := monPred_pure_aux.(unseal).
Definition monPred_pure_eq : @monPred_pure = _ := monPred_pure_aux.(seal_eq).
142

143
144
Definition monPred_objectively_def P : monPred := MonPred (λ _,  i, P i)%I _.
Definition monPred_objectively_aux : seal (@monPred_objectively_def). by eexists. Qed.
145
146
Definition monPred_objectively := monPred_objectively_aux.(unseal).
Definition monPred_objectively_eq : @monPred_objectively = _ := monPred_objectively_aux.(seal_eq).
147

148
149
Definition monPred_subjectively_def P : monPred := MonPred (λ _,  i, P i)%I _.
Definition monPred_subjectively_aux : seal (@monPred_subjectively_def). by eexists. Qed.
150
151
Definition monPred_subjectively := monPred_subjectively_aux.(unseal).
Definition monPred_subjectively_eq : @monPred_subjectively = _ := monPred_subjectively_aux.(seal_eq).
152

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
153
154
Program Definition monPred_and_def P Q : monPred :=
  MonPred (λ i, P i  Q i)%I _.
155
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
156
Definition monPred_and_aux : seal (@monPred_and_def). by eexists. Qed.
157
158
Definition monPred_and := monPred_and_aux.(unseal).
Definition monPred_and_eq : @monPred_and = _ := monPred_and_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
159

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
160
161
Program Definition monPred_or_def P Q : monPred :=
  MonPred (λ i, P i  Q i)%I _.
162
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
163
Definition monPred_or_aux : seal (@monPred_or_def). by eexists. Qed.
164
165
Definition monPred_or := monPred_or_aux.(unseal).
Definition monPred_or_eq : @monPred_or = _ := monPred_or_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
166

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
167
Definition monPred_impl_def P Q : monPred :=
168
  monPred_upclosed (λ i, P i  Q i)%I.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
169
Definition monPred_impl_aux : seal (@monPred_impl_def). by eexists. Qed.
170
171
Definition monPred_impl := monPred_impl_aux.(unseal).
Definition monPred_impl_eq : @monPred_impl = _ := monPred_impl_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
172

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
173
174
Program Definition monPred_forall_def A (Φ : A  monPred) : monPred :=
  MonPred (λ i,  x : A, Φ x i)%I _.
175
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
176
Definition monPred_forall_aux : seal (@monPred_forall_def). by eexists. Qed.
177
178
Definition monPred_forall := monPred_forall_aux.(unseal).
Definition monPred_forall_eq : @monPred_forall = _ := monPred_forall_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
179

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
180
181
Program Definition monPred_exist_def A (Φ : A  monPred) : monPred :=
  MonPred (λ i,  x : A, Φ x i)%I _.
182
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
183
Definition monPred_exist_aux : seal (@monPred_exist_def). by eexists. Qed.
184
185
Definition monPred_exist := monPred_exist_aux.(unseal).
Definition monPred_exist_eq : @monPred_exist = _ := monPred_exist_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
186

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
187
188
Program Definition monPred_sep_def P Q : monPred :=
  MonPred (λ i, P i  Q i)%I _.
189
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
190
Definition monPred_sep_aux : seal (@monPred_sep_def). by eexists. Qed.
191
192
Definition monPred_sep := monPred_sep_aux.(unseal).
Definition monPred_sep_eq : @monPred_sep = _ := monPred_sep_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
193

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
194
Definition monPred_wand_def P Q : monPred :=
195
  monPred_upclosed (λ i, P i - Q i)%I.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
196
Definition monPred_wand_aux : seal (@monPred_wand_def). by eexists. Qed.
197
198
Definition monPred_wand := monPred_wand_aux.(unseal).
Definition monPred_wand_eq : @monPred_wand = _ := monPred_wand_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
199

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
200
Program Definition monPred_persistently_def P : monPred :=
201
  MonPred (λ i, <pers> (P i))%I _.
202
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
203
Definition monPred_persistently_aux : seal (@monPred_persistently_def). by eexists. Qed.
204
205
Definition monPred_persistently := monPred_persistently_aux.(unseal).
Definition monPred_persistently_eq : @monPred_persistently = _ := monPred_persistently_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
206

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
207
208
Program Definition monPred_in_def (i0 : I) : monPred :=
  MonPred (λ i : I, i0  i%I) _.
209
Next Obligation. solve_proper. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
210
Definition monPred_in_aux : seal (@monPred_in_def). by eexists. Qed.
211
212
Definition monPred_in := monPred_in_aux.(unseal).
Definition monPred_in_eq : @monPred_in = _ := monPred_in_aux.(seal_eq).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
213
214
End Bi.

215
216
Arguments monPred_objectively {_ _} _%I.
Arguments monPred_subjectively {_ _} _%I.
Ralf Jung's avatar
Ralf Jung committed
217
218
Notation "'<obj>' P" := (monPred_objectively P) : bi_scope.
Notation "'<subj>' P" := (monPred_subjectively P) : bi_scope.
219

220
221
222
223
224
225
Section Sbi.
Context {I : biIndex} {PROP : sbi}.
Implicit Types i : I.
Notation monPred := (monPred I PROP).
Implicit Types P Q : monPred.

226
227
Definition monPred_internal_eq_def (A : ofeT) (a b : A) : monPred :=
  MonPred (λ _, a  b)%I _.
228
Definition monPred_internal_eq_aux : seal (@monPred_internal_eq_def). by eexists. Qed.
229
Definition monPred_internal_eq := monPred_internal_eq_aux.(unseal).
230
231
Definition monPred_internal_eq_eq : @monPred_internal_eq = _ :=
  monPred_internal_eq_aux.(seal_eq).
232

233
Program Definition monPred_later_def P : monPred := MonPred (λ i,  (P i))%I _.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
234
Next Obligation. solve_proper. Qed.
235
Definition monPred_later_aux : seal monPred_later_def. by eexists. Qed.
236
237
Definition monPred_later := monPred_later_aux.(unseal).
Definition monPred_later_eq : monPred_later = _ := monPred_later_aux.(seal_eq).
238
End Sbi.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
239

240
Module MonPred.
241
242
Definition unseal_eqs :=
  (@monPred_and_eq, @monPred_or_eq, @monPred_impl_eq,
243
   @monPred_forall_eq, @monPred_exist_eq, @monPred_sep_eq, @monPred_wand_eq,
244
   @monPred_persistently_eq, @monPred_later_eq, @monPred_internal_eq_eq, @monPred_in_eq,
245
246
   @monPred_embed_eq, @monPred_emp_eq, @monPred_pure_eq,
   @monPred_objectively_eq, @monPred_subjectively_eq).
247
248
Ltac unseal :=
  unfold bi_affinely, bi_absorbingly, sbi_except_0, bi_pure, bi_emp,
249
         monPred_upclosed, bi_and, bi_or,
250
         bi_impl, bi_forall, bi_exist, sbi_internal_eq, bi_sep, bi_wand,
Robbert Krebbers's avatar
Robbert Krebbers committed
251
         bi_persistently, bi_affinely, sbi_later;
252
  simpl;
253
  unfold sbi_emp, sbi_pure, sbi_and, sbi_or, sbi_impl, sbi_forall, sbi_exist,
Robbert Krebbers's avatar
Robbert Krebbers committed
254
         sbi_internal_eq, sbi_sep, sbi_wand, sbi_persistently;
Ralf Jung's avatar
Ralf Jung committed
255
  simpl;
256
  rewrite !unseal_eqs /=.
257
258
End MonPred.
Import MonPred.
259

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
260
Section canonical_bi.
261
Context (I : biIndex) (PROP : bi).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
262

263
Lemma monPred_bi_mixin : BiMixin (PROP:=monPred I PROP)
264
  monPred_entails monPred_emp monPred_pure monPred_and monPred_or
265
  monPred_impl monPred_forall monPred_exist monPred_sep monPred_wand
Robbert Krebbers's avatar
Robbert Krebbers committed
266
  monPred_persistently.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
267
Proof.
268
  split; try unseal; try by (split=> ? /=; repeat f_equiv).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
269
  - split.
Robbert Krebbers's avatar
Robbert Krebbers committed
270
271
    + intros P. by split.
    + intros P Q R [H1] [H2]. split => ?. by rewrite H1 H2.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
272
  - split.
273
274
    + intros [HPQ]. split; split => i; move: (HPQ i); by apply bi.equiv_spec.
    + intros [[] []]. split=>i. by apply bi.equiv_spec.
Robbert Krebbers's avatar
Robbert Krebbers committed
275
276
277
278
279
280
281
282
283
284
285
286
287
288
  - intros P φ ?. split=> i. by apply bi.pure_intro.
  - intros φ P HP. split=> i. apply bi.pure_elim'=> ?. by apply HP.
  - intros A φ. split=> i. by apply bi.pure_forall_2.
  - intros P Q. split=> i. by apply bi.and_elim_l.
  - intros P Q. split=> i. by apply bi.and_elim_r.
  - intros P Q R [?] [?]. split=> i. by apply bi.and_intro.
  - intros P Q. split=> i. by apply bi.or_intro_l.
  - intros P Q. split=> i. by apply bi.or_intro_r.
  - intros P Q R [?] [?]. split=> i. by apply bi.or_elim.
  - intros P Q R [HR]. split=> i /=. setoid_rewrite bi.pure_impl_forall.
    apply bi.forall_intro=> j. apply bi.forall_intro=> Hij.
    apply bi.impl_intro_r. by rewrite -HR /= !Hij.
  - intros P Q R [HR]. split=> i /=.
     rewrite HR /= bi.forall_elim bi.pure_impl_forall bi.forall_elim //.
289
    apply bi.impl_elim_l.
Robbert Krebbers's avatar
Robbert Krebbers committed
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
  - intros A P Ψ HΨ. split=> i. apply bi.forall_intro => ?. by apply HΨ.
  - intros A Ψ. split=> i. by apply: bi.forall_elim.
  - intros A Ψ a. split=> i. by rewrite /= -bi.exist_intro.
  - intros A Ψ Q HΨ. split=> i. apply bi.exist_elim => a. by apply HΨ.
  - intros P P' Q Q' [?] [?]. split=> i. by apply bi.sep_mono.
  - intros P. split=> i. by apply bi.emp_sep_1.
  - intros P. split=> i. by apply bi.emp_sep_2.
  - intros P Q. split=> i. by apply bi.sep_comm'.
  - intros P Q R. split=> i. by apply bi.sep_assoc'.
  - intros P Q R [HR]. split=> i /=. setoid_rewrite bi.pure_impl_forall.
    apply bi.forall_intro=> j. apply bi.forall_intro=> Hij.
    apply bi.wand_intro_r. by rewrite -HR /= !Hij.
  - intros P Q R [HP]. split=> i. apply bi.wand_elim_l'.
    rewrite HP /= bi.forall_elim bi.pure_impl_forall bi.forall_elim //.
  - intros P Q [?]. split=> i /=. by f_equiv.
  - intros P. split=> i. by apply bi.persistently_idemp_2.
306
  - split=> i. by apply bi.persistently_emp_intro.
Robbert Krebbers's avatar
Robbert Krebbers committed
307
308
309
310
  - intros A Ψ. split=> i. by apply bi.persistently_forall_2.
  - intros A Ψ. split=> i. by apply bi.persistently_exist_1.
  - intros P Q. split=> i. apply bi.sep_elim_l, _.
  - intros P Q. split=> i. by apply bi.persistently_and_sep_elim.
311
Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
312

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
313
Canonical Structure monPredI : bi :=
Robbert Krebbers's avatar
Robbert Krebbers committed
314
  {| bi_ofe_mixin := monPred_ofe_mixin; bi_bi_mixin := monPred_bi_mixin |}.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
315
316
317
End canonical_bi.

Section canonical_sbi.
318
Context (I : biIndex) (PROP : sbi).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
319

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
320
Lemma monPred_sbi_mixin :
Robbert Krebbers's avatar
Robbert Krebbers committed
321
322
323
  SbiMixin (PROP:=monPred I PROP) monPred_entails monPred_pure
           monPred_or monPred_impl monPred_forall monPred_exist
           monPred_sep monPred_persistently monPred_internal_eq monPred_later.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
324
Proof.
Robbert Krebbers's avatar
Robbert Krebbers committed
325
326
327
  split; unseal.
  - intros n P Q HPQ. split=> i /=.
    apply bi.later_contractive. destruct n as [|n]=> //. by apply HPQ.
328
329
330
331
332
333
334
335
  - by split=> ? /=; repeat f_equiv.
  - intros A P a. split=> i. by apply bi.internal_eq_refl.
  - intros A a b Ψ ?. split=> i /=.
    setoid_rewrite bi.pure_impl_forall. do 2 apply bi.forall_intro => ?.
    erewrite (bi.internal_eq_rewrite _ _ (flip Ψ _)) => //=. solve_proper.
  - intros A1 A2 f g. split=> i. by apply bi.fun_ext.
  - intros A P x y. split=> i. by apply bi.sig_eq.
  - intros A a b ?. split=> i. by apply bi.discrete_eq_1.
Robbert Krebbers's avatar
Robbert Krebbers committed
336
337
338
  - intros A x y. split=> i. by apply bi.later_eq_1.
  - intros A x y. split=> i. by apply bi.later_eq_2.
  - intros P Q [?]. split=> i. by apply bi.later_mono.
339
  - intros P. split=> i /=. by apply bi.later_intro.
Robbert Krebbers's avatar
Robbert Krebbers committed
340
341
342
343
344
345
346
347
  - intros A Ψ. split=> i. by apply bi.later_forall_2.
  - intros A Ψ. split=> i. by apply bi.later_exist_false.
  - intros P Q. split=> i. by apply bi.later_sep_1.
  - intros P Q. split=> i. by apply bi.later_sep_2.
  - intros P. split=> i. by apply bi.later_persistently_1.
  - intros P. split=> i. by apply bi.later_persistently_2.
  - intros P. split=> i /=. rewrite -bi.forall_intro. apply bi.later_false_em.
    intros j. rewrite bi.pure_impl_forall. apply bi.forall_intro=> Hij. by rewrite Hij.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
348
Qed.
349

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
350
Canonical Structure monPredSI : sbi :=
Robbert Krebbers's avatar
Robbert Krebbers committed
351
352
  {| sbi_ofe_mixin := monPred_ofe_mixin; sbi_bi_mixin := monPred_bi_mixin I PROP;
     sbi_sbi_mixin := monPred_sbi_mixin |}.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
353
End canonical_sbi.
354

355
356
357
358
359
Class Objective {I : biIndex} {PROP : bi} (P : monPred I PROP) :=
  objective_at i j : P i - P j.
Arguments Objective {_ _} _%I.
Arguments objective_at {_ _} _%I {_}.
Hint Mode Objective + + ! : typeclass_instances.
360
Instance: Params (@Objective) 2 := {}.
361

362
363
(** Primitive facts that cannot be deduced from the BI structure. *)

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
364
Section bi_facts.
365
Context {I : biIndex} {PROP : bi}.
366
Local Notation monPred := (monPred I PROP).
367
368
Local Notation monPredI := (monPredI I PROP).
Local Notation monPred_at := (@monPred_at I PROP).
369
Local Notation BiIndexBottom := (@BiIndexBottom I).
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
370
Implicit Types i : I.
371
Implicit Types P Q : monPred.
372
373

(** Instances *)
374
Global Instance monPred_at_mono :
375
  Proper (() ==> () ==> ()) monPred_at.
376
Proof. by move=> ?? [?] ?? ->. Qed.
377
Global Instance monPred_at_flip_mono :
378
  Proper (flip () ==> flip () ==> flip ()) monPred_at.
379
380
Proof. solve_proper. Qed.

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
381
Global Instance monPred_in_proper (R : relation I) :
382
  Proper (R ==> R ==> iff) ()  Reflexive R 
383
  Proper (R ==> ()) (@monPred_in I PROP).
384
Proof. unseal. split. solve_proper. Qed.
385
Global Instance monPred_in_mono : Proper (flip () ==> ()) (@monPred_in I PROP).
386
Proof. unseal. split. solve_proper. Qed.
387
Global Instance monPred_in_flip_mono : Proper (() ==> flip ()) (@monPred_in I PROP).
388
389
Proof. solve_proper. Qed.

390
Global Instance monPred_positive : BiPositive PROP  BiPositive monPredI.
391
Proof. split => ?. unseal. apply bi_positive. Qed.
392
Global Instance monPred_affine : BiAffine PROP  BiAffine monPredI.
393
394
Proof. split => ?. unseal. by apply affine. Qed.

395
Global Instance monPred_at_persistent P i : Persistent P  Persistent (P i).
396
Proof. move => [] /(_ i). by unseal. Qed.
397
Global Instance monPred_at_absorbing P i : Absorbing P  Absorbing (P i).
398
Proof. move => [] /(_ i). unfold Absorbing. by unseal. Qed.
399
Global Instance monPred_at_affine P i : Affine P  Affine (P i).
400
Proof. move => [] /(_ i). unfold Affine. by unseal. Qed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
401

402
403
(* Note that monPred_in is *not* Plain, because it does depend on the
   index. *)
404
405
Global Instance monPred_in_persistent i :
  Persistent (@monPred_in I PROP i).
406
Proof. unfold Persistent. unseal; split => ?. by apply bi.pure_persistent. Qed.
407
408
Global Instance monPred_in_absorbing i :
  Absorbing (@monPred_in I PROP i).
409
Proof. unfold Absorbing. unseal. split=> ? /=. apply absorbing, _. Qed.
410

411
Definition monPred_embedding_mixin : BiEmbedMixin PROP monPredI monPred_embed.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
412
Proof.
Robbert Krebbers's avatar
Robbert Krebbers committed
413
414
415
  split; try apply _; rewrite /bi_emp_valid; unseal; try done.
  - move=> P /= [/(_ inhabitant) ?] //.
  - intros P Q. split=> i /=.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
416
    by rewrite bi.forall_elim bi.pure_impl_forall bi.forall_elim.
Robbert Krebbers's avatar
Robbert Krebbers committed
417
  - intros P Q. split=> i /=.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
418
419
    by rewrite bi.forall_elim bi.pure_impl_forall bi.forall_elim.
Qed.
420
421
Global Instance monPred_bi_embed : BiEmbed PROP monPredI :=
  {| bi_embed_mixin := monPred_embedding_mixin |}.
Robbert Krebbers's avatar
Robbert Krebbers committed
422
423
Global Instance monPred_bi_embed_emp : BiEmbedEmp PROP monPredI.
Proof. split. by unseal. Qed.
424
425
426
427
428

Lemma monPred_emp_unfold : emp%I = emp : PROP%I.
Proof. by unseal. Qed.
Lemma monPred_pure_unfold : bi_pure = λ φ,   φ  : PROP%I.
Proof. by unseal. Qed.
429
Lemma monPred_objectively_unfold : monPred_objectively = λ P,  i, P i%I.
430
Proof. by unseal. Qed.
431
Lemma monPred_subjectively_unfold : monPred_subjectively = λ P,  i, P i%I.
432
Proof. by unseal. Qed.
433

434
435
436
Global Instance monPred_objectively_ne : NonExpansive (@monPred_objectively I PROP).
Proof. rewrite monPred_objectively_unfold. solve_proper. Qed.
Global Instance monPred_objectively_proper : Proper (() ==> ()) (@monPred_objectively I PROP).
437
Proof. apply (ne_proper _). Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
438
Lemma monPred_objectively_mono P Q : (P  Q)  (<obj> P  <obj> Q).
439
440
441
442
443
444
445
Proof. rewrite monPred_objectively_unfold. solve_proper. Qed.
Global Instance monPred_objectively_mono' : Proper (() ==> ()) (@monPred_objectively I PROP).
Proof. intros ???. by apply monPred_objectively_mono. Qed.
Global Instance monPred_objectively_flip_mono' :
  Proper (flip () ==> flip ()) (@monPred_objectively I PROP).
Proof. intros ???. by apply monPred_objectively_mono. Qed.

Robbert Krebbers's avatar
Robbert Krebbers committed
446
Global Instance monPred_objectively_persistent P : Persistent P  Persistent (<obj> P).
447
Proof. rewrite monPred_objectively_unfold. apply _. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
448
Global Instance monPred_objectively_absorbing P : Absorbing P  Absorbing (<obj> P).
449
Proof. rewrite monPred_objectively_unfold. apply _. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
450
Global Instance monPred_objectively_affine P : Affine P  Affine (<obj> P).
451
452
453
454
455
Proof. rewrite monPred_objectively_unfold. apply _. Qed.

Global Instance monPred_subjectively_ne : NonExpansive (@monPred_subjectively I PROP).
Proof. rewrite monPred_subjectively_unfold. solve_proper. Qed.
Global Instance monPred_subjectively_proper : Proper (() ==> ()) (@monPred_subjectively I PROP).
456
Proof. apply (ne_proper _). Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
457
Lemma monPred_subjectively_mono P Q : (P  Q)  <subj> P  <subj> Q.
458
459
460
461
462
463
464
Proof. rewrite monPred_subjectively_unfold. solve_proper. Qed.
Global Instance monPred_subjectively_mono' : Proper (() ==> ()) (@monPred_subjectively I PROP).
Proof. intros ???. by apply monPred_subjectively_mono. Qed.
Global Instance monPred_subjectively_flip_mono' :
  Proper (flip () ==> flip ()) (@monPred_subjectively I PROP).
Proof. intros ???. by apply monPred_subjectively_mono. Qed.

Robbert Krebbers's avatar
Robbert Krebbers committed
465
Global Instance monPred_subjectively_persistent P : Persistent P  Persistent (<subj> P).
466
Proof. rewrite monPred_subjectively_unfold. apply _. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
467
Global Instance monPred_subjectively_absorbing P : Absorbing P  Absorbing (<subj> P).
468
Proof. rewrite monPred_subjectively_unfold. apply _. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
469
Global Instance monPred_subjectively_affine P : Affine P  Affine (<subj> P).
470
Proof. rewrite monPred_subjectively_unfold. apply _. Qed.
471

472
473
474
475
(** monPred_at unfolding laws *)
Lemma monPred_at_embed i (P : PROP) : monPred_at P i  P.
Proof. by unseal. Qed.
Lemma monPred_at_pure i (φ : Prop) : monPred_at ⌜φ⌝ i  ⌜φ⌝.
476
Proof. by unseal. Qed.
477
Lemma monPred_at_emp i : monPred_at emp i  emp.
478
Proof. by unseal. Qed.
479
480
481
482
483
484
Lemma monPred_at_and i P Q : (P  Q) i  P i  Q i.
Proof. by unseal. Qed.
Lemma monPred_at_or i P Q : (P  Q) i  P i  Q i.
Proof. by unseal. Qed.
Lemma monPred_at_impl i P Q : (P  Q) i   j, i  j  P j  Q j.
Proof. by unseal. Qed.
485
Lemma monPred_at_forall {A} i (Φ : A  monPred) : ( x, Φ x) i   x, Φ x i.
486
Proof. by unseal. Qed.
487
Lemma monPred_at_exist {A} i (Φ : A  monPred) : ( x, Φ x) i   x, Φ x i.
488
489
490
491
492
Proof. by unseal. Qed.
Lemma monPred_at_sep i P Q : (P  Q) i  P i  Q i.
Proof. by unseal. Qed.
Lemma monPred_at_wand i P Q : (P - Q) i   j, i  j  P j - Q j.
Proof. by unseal. Qed.
493
Lemma monPred_at_persistently i P : (<pers> P) i  <pers> (P i).
494
495
496
Proof. by unseal. Qed.
Lemma monPred_at_in i j : monPred_at (monPred_in j) i  j  i.
Proof. by unseal. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
497
Lemma monPred_at_objectively i P : (<obj> P) i   j, P j.
498
Proof. by unseal. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
499
Lemma monPred_at_subjectively i P : (<subj> P) i   j, P j.
500
Proof. by unseal. Qed.
501
Lemma monPred_at_persistently_if i p P : (<pers>?p P) i  <pers>?p (P i).
502
Proof. destruct p=>//=. apply monPred_at_persistently. Qed.
503
Lemma monPred_at_affinely i P : (<affine> P) i  <affine> (P i).
504
Proof. by rewrite /bi_affinely monPred_at_and monPred_at_emp. Qed.
505
Lemma monPred_at_affinely_if i p P : (<affine>?p P) i  <affine>?p (P i).
506
Proof. destruct p=>//=. apply monPred_at_affinely. Qed.
507
508
509
510
511
Lemma monPred_at_intuitionistically i P : ( P) i   (P i).
Proof. by rewrite /bi_intuitionistically monPred_at_affinely monPred_at_persistently. Qed.
Lemma monPred_at_intuitionistically_if i p P : (?p P) i  ?p (P i).
Proof. destruct p=>//=. apply monPred_at_intuitionistically. Qed.

512
Lemma monPred_at_absorbingly i P : (<absorb> P) i  <absorb> (P i).
513
Proof. by rewrite /bi_absorbingly monPred_at_sep monPred_at_pure. Qed.
514
515
Lemma monPred_at_absorbingly_if i p P : (<absorb>?p P) i  <absorb>?p (P i).
Proof. destruct p=>//=. apply monPred_at_absorbingly. Qed.
516
517
518
519
520
521

Lemma monPred_wand_force i P Q : (P - Q) i - (P i - Q i).
Proof. unseal. rewrite bi.forall_elim bi.pure_impl_forall bi.forall_elim //. Qed.
Lemma monPred_impl_force i P Q : (P  Q) i - (P i  Q i).
Proof. unseal. rewrite bi.forall_elim bi.pure_impl_forall bi.forall_elim //. Qed.

522
(* Laws for monPred_objectively and of Objective. *)
Robbert Krebbers's avatar
Robbert Krebbers committed
523
Lemma monPred_objectively_elim P : <obj> P  P.
524
Proof. rewrite monPred_objectively_unfold. unseal. split=>?. apply bi.forall_elim. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
525
Lemma monPred_objectively_idemp P : <obj> <obj> P  <obj> P.
526
Proof.
527
  apply bi.equiv_spec; split; [by apply monPred_objectively_elim|].
528
529
530
  unseal. split=>i /=. by apply bi.forall_intro=>_.
Qed.

Robbert Krebbers's avatar
Robbert Krebbers committed
531
Lemma monPred_objectively_forall {A} (Φ : A  monPred) : <obj> ( x, Φ x)   x, <obj> (Φ x).
532
533
534
535
Proof.
  unseal. split=>i. apply bi.equiv_spec; split=>/=;
    do 2 apply bi.forall_intro=>?; by do 2 rewrite bi.forall_elim.
Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
536
Lemma monPred_objectively_and P Q : <obj> (P  Q)  <obj> P  <obj> Q.
537
538
539
540
541
Proof.
  unseal. split=>i. apply bi.equiv_spec; split=>/=.
  - apply bi.and_intro; do 2 f_equiv. apply bi.and_elim_l. apply bi.and_elim_r.
  - apply bi.forall_intro=>?. by rewrite !bi.forall_elim.
Qed.
542
Lemma monPred_objectively_exist {A} (Φ : A  monPred) :
Robbert Krebbers's avatar
Robbert Krebbers committed
543
  ( x, <obj> (Φ x))  <obj> ( x, (Φ x)).
544
Proof. apply bi.exist_elim=>?. f_equiv. apply bi.exist_intro. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
545
Lemma monPred_objectively_or P Q : <obj> P  <obj> Q  <obj> (P  Q).
546
547
Proof. apply bi.or_elim; f_equiv. apply bi.or_intro_l. apply bi.or_intro_r. Qed.

Robbert Krebbers's avatar
Robbert Krebbers committed
548
Lemma monPred_objectively_sep_2 P Q : <obj> P  <obj> Q  <obj> (P  Q).
549
Proof. unseal. split=>i /=. apply bi.forall_intro=>?. by rewrite !bi.forall_elim. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
550
Lemma monPred_objectively_sep `{BiIndexBottom bot} P Q : <obj> (P  Q)  <obj> P  <obj> Q.
551
Proof.
552
  apply bi.equiv_spec, conj, monPred_objectively_sep_2. unseal. split=>i /=.
553
554
  rewrite (bi.forall_elim bot). by f_equiv; apply bi.forall_intro=>j; f_equiv.
Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
555
Lemma monPred_objectively_embed (P : PROP) : <obj> P  P.
556
557
558
559
Proof.
  apply bi.equiv_spec; split; unseal; split=>i /=.
  by rewrite (bi.forall_elim inhabitant). by apply bi.forall_intro.
Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
560
Lemma monPred_objectively_emp : <obj> (emp : monPred)  emp.
561
Proof. rewrite monPred_emp_unfold. apply monPred_objectively_embed. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
562
Lemma monPred_objectively_pure φ : <obj> ( φ  : monPred)   φ .
563
Proof. rewrite monPred_pure_unfold. apply monPred_objectively_embed. Qed.
564

Robbert Krebbers's avatar
Robbert Krebbers committed
565
Lemma monPred_subjectively_intro P : P  <subj> P.
566
Proof. unseal. split=>?. apply bi.exist_intro. Qed.
567

568
Lemma monPred_subjectively_forall {A} (Φ : A  monPred) :
Robbert Krebbers's avatar
Robbert Krebbers committed
569
  (<subj> ( x, Φ x))   x, <subj> (Φ x).
570
Proof. apply bi.forall_intro=>?. f_equiv. apply bi.forall_elim. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
571
Lemma monPred_subjectively_and P Q : <subj> (P  Q)  <subj> P  <subj> Q.
572
Proof. apply bi.and_intro; f_equiv. apply bi.and_elim_l. apply bi.and_elim_r. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
573
Lemma monPred_subjectively_exist {A} (Φ : A  monPred) : <subj> ( x, Φ x)   x, <subj> (Φ x).
574
575
576
577
Proof.
  unseal. split=>i. apply bi.equiv_spec; split=>/=;
    do 2 apply bi.exist_elim=>?; by do 2 rewrite -bi.exist_intro.
Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
578
Lemma monPred_subjectively_or P Q : <subj> (P  Q)  <subj> P  <subj> Q.
579
580
581
582
583
584
Proof.
  unseal. split=>i. apply bi.equiv_spec; split=>/=.
  - apply bi.exist_elim=>?. by rewrite -!bi.exist_intro.
  - apply bi.or_elim; do 2 f_equiv. apply bi.or_intro_l. apply bi.or_intro_r.
Qed.

Robbert Krebbers's avatar
Robbert Krebbers committed
585
Lemma monPred_subjectively_sep P Q : <subj> (P  Q)  <subj> P  <subj> Q.
586
587
Proof. unseal. split=>i /=. apply bi.exist_elim=>?. by rewrite -!bi.exist_intro. Qed.

Robbert Krebbers's avatar
Robbert Krebbers committed
588
Lemma monPred_subjectively_idemp P : <subj> <subj> P  <subj> P.
589
Proof.
590
  apply bi.equiv_spec; split; [|by apply monPred_subjectively_intro].
591
592
593
  unseal. split=>i /=. by apply bi.exist_elim=>_.
Qed.

Robbert Krebbers's avatar
Robbert Krebbers committed
594
Lemma objective_objectively P `{!Objective P} : P  <obj> P.
595
Proof.
596
597
  rewrite monPred_objectively_unfold /= embed_forall. apply bi.forall_intro=>?.
  split=>?. unseal. apply objective_at, _.
598
Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
599
Lemma objective_subjectively P `{!Objective P} : <subj> P  P.
600
Proof.
601
602
  rewrite monPred_subjectively_unfold /= embed_exist. apply bi.exist_elim=>?.
  split=>?. unseal. apply objective_at, _.
603
604
Qed.

605
Global Instance embed_objective (P : PROP) : @Objective I PROP P.
606
Proof. intros ??. by unseal. Qed.
607
Global Instance pure_objective φ : @Objective I PROP ⌜φ⌝.
608
Proof. intros ??. by unseal. Qed.
609
Global Instance emp_objective : @Objective I PROP emp.
610
Proof. intros ??. by unseal. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
611
Global Instance objectively_objective P : Objective (<obj> P).
612
Proof. intros ??. by unseal. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
613
Global Instance subjectively_objective P : Objective (<subj> P).
614
Proof. intros ??. by unseal. Qed.
615

616
617
618
619
620
Global Instance and_objective P Q `{!Objective P, !Objective Q} : Objective (P  Q).
Proof. intros i j. unseal. by rewrite !(objective_at _ i j). Qed.
Global Instance or_objective P Q `{!Objective P, !Objective Q} : Objective (P  Q).
Proof. intros i j. by rewrite !monPred_at_or !(objective_at _ i j). Qed.
Global Instance impl_objective P Q `{!Objective P, !Objective Q} : Objective (P  Q).
621
Proof.
622
623
  intros i j. unseal. rewrite (bi.forall_elim i) bi.pure_impl_forall.
  rewrite bi.forall_elim //. apply bi.forall_intro=> k.
624
  rewrite bi.pure_impl_forall. apply bi.forall_intro=>_.
625
  rewrite (objective_at Q i). by rewrite (objective_at P k).
626
Qed.
627
628
629
630
631
632
Global Instance forall_objective {A} Φ {H :  x : A, Objective (Φ x)} :
  @Objective I PROP ( x, Φ x)%I.
Proof. intros i j. unseal. do 2 f_equiv. by apply objective_at. Qed.
Global Instance exists_objective {A} Φ {H :  x : A, Objective (Φ x)} :
  @Objective I PROP ( x, Φ x)%I.
Proof. intros i j. unseal. do 2 f_equiv. by apply objective_at. Qed.
633

634
635
636
Global Instance sep_objective P Q `{!Objective P, !Objective Q} : Objective (P  Q).
Proof. intros i j. unseal. by rewrite !(objective_at _ i j). Qed.
Global Instance wand_objective P Q `{!Objective P, !Objective Q} : Objective (P - Q).
637
Proof.
638
639
  intros i j. unseal. rewrite (bi.forall_elim i) bi.pure_impl_forall.
  rewrite bi.forall_elim //. apply bi.forall_intro=> k.
640
  rewrite bi.pure_impl_forall. apply bi.forall_intro=>_.
641
  rewrite (objective_at Q i). by rewrite (objective_at P k).
642
Qed.
643
Global Instance persistently_objective P `{!Objective P} : Objective (<pers> P).
644
Proof. intros i j. unseal. by rewrite objective_at. Qed.
645