viewshifts.v 2.72 KB
Newer Older
1
From iris.base_logic.lib Require Export invariants.
2
From iris.proofmode Require Import tactics.
3

4
Definition vs `{invG Σ} (E1 E2 : coPset) (P Q : iProp Σ) : iProp Σ :=
5
  ( (P - |={E1,E2}=> Q))%I.
6
Arguments vs {_ _} _ _ _%I _%I.
7

8
Instance: Params (@vs) 4.
9
Notation "P ={ E1 , E2 }=> Q" := (vs E1 E2 P Q)
10
11
12
13
14
15
  (at level 99, E1,E2 at level 50, Q at level 200,
   format "P  ={ E1 , E2 }=>  Q") : uPred_scope.
Notation "P ={ E }=> Q" := (P ={E,E}=> Q)%I
  (at level 99, E at level 50, Q at level 200,
   format "P  ={ E }=>  Q") : uPred_scope.

16
Notation "P ={ E1 , E2 }=> Q" := (P ={E1,E2}=> Q)%I
17
18
  (at level 99, E1,E2 at level 50, Q at level 200,
   format "P  ={ E1 , E2 }=>  Q") : C_scope.
19
Notation "P ={ E }=> Q" := (P ={E}=> Q)%I
20
21
22
  (at level 99, E at level 50, Q at level 200,
   format "P  ={ E }=>  Q") : C_scope.

23
Section vs.
24
Context `{invG Σ}.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Implicit Types P Q R : iProp Σ.
Implicit Types N : namespace.

Global Instance vs_ne E1 E2 n: Proper (dist n ==> dist n ==> dist n) (vs E1 E2).
Proof. solve_proper. Qed.

Global Instance vs_proper E1 E2 : Proper (() ==> () ==> ()) (vs E1 E2).
Proof. apply ne_proper_2, _. Qed.

Lemma vs_mono E1 E2 P P' Q Q' :
  (P  P')  (Q'  Q)  (P' ={E1,E2}=> Q')  P ={E1,E2}=> Q.
Proof. by intros HP HQ; rewrite /vs -HP HQ. Qed.

Global Instance vs_mono' E1 E2 : Proper (flip () ==> () ==> ()) (vs E1 E2).
Proof. solve_proper. Qed.

Lemma vs_false_elim E1 E2 P : False ={E1,E2}=> P.
42
Proof. iIntros "!# []". Qed.
43
Lemma vs_timeless E P : TimelessP P   P ={E}=> P.
44
Proof. by iIntros (?) "!# > ?". Qed.
45
46
47
48
49

Lemma vs_transitive E1 E2 E3 P Q R :
  (P ={E1,E2}=> Q)  (Q ={E2,E3}=> R)  P ={E1,E3}=> R.
Proof.
  iIntros "#[HvsP HvsQ] !# HP".
50
  iMod ("HvsP" with "HP") as "HQ". by iApply "HvsQ".
51
52
53
Qed.

Lemma vs_reflexive E P : P ={E}=> P.
54
Proof. by iIntros "!# HP". Qed.
55
56
57
58

Lemma vs_impl E P Q :  (P  Q)  P ={E}=> Q.
Proof. iIntros "#HPQ !# HP". by iApply "HPQ". Qed.

59
Lemma vs_frame_l E1 E2 P Q R : (P ={E1,E2}=> Q)  R  P ={E1,E2}=> R  Q.
60
61
Proof. iIntros "#Hvs !# [$ HP]". by iApply "Hvs". Qed.

62
Lemma vs_frame_r E1 E2 P Q R : (P ={E1,E2}=> Q)  P  R ={E1,E2}=> Q  R.
63
64
65
66
67
Proof. iIntros "#Hvs !# [HP $]". by iApply "Hvs". Qed.

Lemma vs_mask_frame_r E1 E2 Ef P Q :
  E1  Ef  (P ={E1,E2}=> Q)  P ={E1  Ef,E2  Ef}=> Q.
Proof.
68
  iIntros (?) "#Hvs !# HP". iApply fupd_mask_frame_r; auto. by iApply "Hvs".
69
70
71
Qed.

Lemma vs_inv N E P Q R :
72
  N  E  inv N R  ( R  P ={E∖↑N}=>  R  Q)  P ={E}=> Q.
73
74
Proof.
  iIntros (?) "#[? Hvs] !# HP". iInv N as "HR" "Hclose".
75
  iMod ("Hvs" with "[HR HP]") as "[? $]"; first by iFrame.
76
77
78
  by iApply "Hclose".
Qed.

79
Lemma vs_alloc N P :  P ={N}=> inv N P.
80
Proof. iIntros "!# HP". by iApply inv_alloc. Qed.
81
End vs.