Commit 1b85d654 authored by Robbert Krebbers's avatar Robbert Krebbers

Rename rvs -> bupd (basic update), pvs -> fupd (fancy update).

And also rename the corresponding proof mode tactics.
parent aec84909
...@@ -5,8 +5,8 @@ Many of the tactics below apply to more goals than described in this document ...@@ -5,8 +5,8 @@ Many of the tactics below apply to more goals than described in this document
since the behavior of these tactics can be tuned via instances of the type since the behavior of these tactics can be tuned via instances of the type
classes in the file [proofmode/classes](proofmode/classes.v). Most notable, many classes in the file [proofmode/classes](proofmode/classes.v). Most notable, many
of the tactics can be applied when the to be introduced or to be eliminated of the tactics can be applied when the to be introduced or to be eliminated
connective appears under a later, a primitive view shift, or in the conclusion connective appears under a later, an update modality, or in the conclusion of a
of a weakest precondition connective. weakest precondition.
Applying hypotheses and lemmas Applying hypotheses and lemmas
------------------------------ ------------------------------
...@@ -124,14 +124,13 @@ Rewriting ...@@ -124,14 +124,13 @@ Rewriting
Iris Iris
---- ----
- `iVsIntro` : introduction of a raw or primitive view shift. - `iUpdIntro` : introduction of an update modality.
- `iVs pm_trm as (x1 ... xn) "ipat"` : run a raw or primitive view shift - `iUpd pm_trm as (x1 ... xn) "ipat"` : run an update modality `pm_trm` (if the
`pm_trm` (if the goal permits, i.e. it is a raw or primitive view shift, or goal permits, i.e. it can be expanded to an update modality.
a weakest precondition).
- `iInv N as (x1 ... xn) "ipat"` : open the invariant `N`. - `iInv N as (x1 ... xn) "ipat"` : open the invariant `N`.
- `iTimeless "H"` : strip a later of a timeless hypothesis `H` (if the goal - `iTimeless "H"` : strip a later of a timeless hypothesis `H` (if the goal
permits, i.e. it is a later, True now, raw or primitive view shift, or a permits, i.e. it is a later, True now, update modality, or a weakest
weakest precondition). precondition).
Miscellaneous Miscellaneous
------------- -------------
...@@ -140,8 +139,8 @@ Miscellaneous ...@@ -140,8 +139,8 @@ Miscellaneous
introduces pure connectives. introduces pure connectives.
- The proof mode adds hints to the core `eauto` database so that `eauto` - The proof mode adds hints to the core `eauto` database so that `eauto`
automatically introduces: conjunctions and disjunctions, universal and automatically introduces: conjunctions and disjunctions, universal and
existential quantifiers, implications and wand, always and later modalities, existential quantifiers, implications and wand, always, later and update
primitive view shifts, and pure connectives. modalities, and pure connectives.
Selection patterns Selection patterns
================== ==================
...@@ -172,7 +171,7 @@ _introduction patterns_: ...@@ -172,7 +171,7 @@ _introduction patterns_:
- `%` : move the hypothesis to the pure Coq context (anonymously). - `%` : move the hypothesis to the pure Coq context (anonymously).
- `# ipat` : move the hypothesis to the persistent context. - `# ipat` : move the hypothesis to the persistent context.
- `> ipat` : remove a later of a timeless hypothesis (if the goal permits). - `> ipat` : remove a later of a timeless hypothesis (if the goal permits).
- `==> ipat` : run a view shift (if the goal permits). - `==> ipat` : run an update modality (if the goal permits).
Apart from this, there are the following introduction patterns that can only Apart from this, there are the following introduction patterns that can only
appear at the top level: appear at the top level:
...@@ -183,7 +182,7 @@ appear at the top level: ...@@ -183,7 +182,7 @@ appear at the top level:
- `!%` : introduce a pure goal (and leave the proof mode). - `!%` : introduce a pure goal (and leave the proof mode).
- `!#` : introduce an always modality (given that the spatial context is empty). - `!#` : introduce an always modality (given that the spatial context is empty).
- `!>` : introduce a later (which strips laters from all hypotheses). - `!>` : introduce a later (which strips laters from all hypotheses).
- `!==>` : introduce a view shift. - `!==>` : introduce an update modality
- `/=` : perform `simpl`. - `/=` : perform `simpl`.
- `*` : introduce all universal quantifiers. - `*` : introduce all universal quantifiers.
- `**` : introduce all universal quantifiers, as well as all arrows and wands. - `**` : introduce all universal quantifiers, as well as all arrows and wands.
...@@ -224,7 +223,7 @@ _specification patterns_ to express splitting of hypotheses: ...@@ -224,7 +223,7 @@ _specification patterns_ to express splitting of hypotheses:
- `[-H1 ... Hn]` : negated form of the above pattern. This pattern does not - `[-H1 ... Hn]` : negated form of the above pattern. This pattern does not
accept hypotheses prefixed with a `$`. accept hypotheses prefixed with a `$`.
- `==>[H1 ... Hn]` : same as the above pattern, but can only be used if the goal - `==>[H1 ... Hn]` : same as the above pattern, but can only be used if the goal
is a primitive view shift, in which case the view shift will be kept in the is an update modality, in which case the update modality will be kept in the
goal of the premise too. goal of the premise too.
- `[#]` : This pattern can be used when eliminating `P -★ Q` with `P` - `[#]` : This pattern can be used when eliminating `P -★ Q` with `P`
persistent. Using this pattern, all hypotheses are available in the goal for persistent. Using this pattern, all hypotheses are available in the goal for
......
...@@ -69,7 +69,7 @@ program_logic/lifting.v ...@@ -69,7 +69,7 @@ program_logic/lifting.v
program_logic/invariants.v program_logic/invariants.v
program_logic/wsat.v program_logic/wsat.v
program_logic/weakestpre.v program_logic/weakestpre.v
program_logic/pviewshifts.v program_logic/fancy_updates.v
program_logic/hoare.v program_logic/hoare.v
program_logic/viewshifts.v program_logic/viewshifts.v
program_logic/language.v program_logic/language.v
......
This diff is collapsed.
...@@ -264,7 +264,7 @@ Definition uPred_cmra_valid {M A} := proj1_sig uPred_cmra_valid_aux M A. ...@@ -264,7 +264,7 @@ Definition uPred_cmra_valid {M A} := proj1_sig uPred_cmra_valid_aux M A.
Definition uPred_cmra_valid_eq : Definition uPred_cmra_valid_eq :
@uPred_cmra_valid = @uPred_cmra_valid_def := proj2_sig uPred_cmra_valid_aux. @uPred_cmra_valid = @uPred_cmra_valid_def := proj2_sig uPred_cmra_valid_aux.
Program Definition uPred_rvs_def {M} (Q : uPred M) : uPred M := Program Definition uPred_bupd_def {M} (Q : uPred M) : uPred M :=
{| uPred_holds n x := k yf, {| uPred_holds n x := k yf,
k n {k} (x yf) x', {k} (x' yf) Q k x' |}. k n {k} (x yf) x', {k} (x' yf) Q k x' |}.
Next Obligation. Next Obligation.
...@@ -275,9 +275,9 @@ Next Obligation. ...@@ -275,9 +275,9 @@ Next Obligation.
apply uPred_mono with x'; eauto using cmra_includedN_l. apply uPred_mono with x'; eauto using cmra_includedN_l.
Qed. Qed.
Next Obligation. naive_solver. Qed. Next Obligation. naive_solver. Qed.
Definition uPred_rvs_aux : { x | x = @uPred_rvs_def }. by eexists. Qed. Definition uPred_bupd_aux : { x | x = @uPred_bupd_def }. by eexists. Qed.
Definition uPred_rvs {M} := proj1_sig uPred_rvs_aux M. Definition uPred_bupd {M} := proj1_sig uPred_bupd_aux M.
Definition uPred_rvs_eq : @uPred_rvs = @uPred_rvs_def := proj2_sig uPred_rvs_aux. Definition uPred_bupd_eq : @uPred_bupd = @uPred_bupd_def := proj2_sig uPred_bupd_aux.
Notation "P ⊢ Q" := (uPred_entails P%I Q%I) Notation "P ⊢ Q" := (uPred_entails P%I Q%I)
(at level 99, Q at level 200, right associativity) : C_scope. (at level 99, Q at level 200, right associativity) : C_scope.
...@@ -310,7 +310,7 @@ Notation "▷ P" := (uPred_later P) ...@@ -310,7 +310,7 @@ Notation "▷ P" := (uPred_later P)
(at level 20, right associativity) : uPred_scope. (at level 20, right associativity) : uPred_scope.
Infix "≡" := uPred_eq : uPred_scope. Infix "≡" := uPred_eq : uPred_scope.
Notation "✓ x" := (uPred_cmra_valid x) (at level 20) : uPred_scope. Notation "✓ x" := (uPred_cmra_valid x) (at level 20) : uPred_scope.
Notation "|=r=> Q" := (uPred_rvs Q) Notation "|=r=> Q" := (uPred_bupd Q)
(at level 99, Q at level 200, format "|=r=> Q") : uPred_scope. (at level 99, Q at level 200, format "|=r=> Q") : uPred_scope.
Notation "P =r=> Q" := (P |=r=> Q) Notation "P =r=> Q" := (P |=r=> Q)
(at level 99, Q at level 200, only parsing) : C_scope. (at level 99, Q at level 200, only parsing) : C_scope.
...@@ -344,7 +344,7 @@ Module uPred. ...@@ -344,7 +344,7 @@ Module uPred.
Definition unseal := Definition unseal :=
(uPred_pure_eq, uPred_and_eq, uPred_or_eq, uPred_impl_eq, uPred_forall_eq, (uPred_pure_eq, uPred_and_eq, uPred_or_eq, uPred_impl_eq, uPred_forall_eq,
uPred_exist_eq, uPred_eq_eq, uPred_sep_eq, uPred_wand_eq, uPred_always_eq, uPred_exist_eq, uPred_eq_eq, uPred_sep_eq, uPred_wand_eq, uPred_always_eq,
uPred_later_eq, uPred_ownM_eq, uPred_cmra_valid_eq, uPred_rvs_eq). uPred_later_eq, uPred_ownM_eq, uPred_cmra_valid_eq, uPred_bupd_eq).
Ltac unseal := rewrite !unseal /=. Ltac unseal := rewrite !unseal /=.
Section uPred_logic. Section uPred_logic.
...@@ -488,14 +488,14 @@ Proof. ...@@ -488,14 +488,14 @@ Proof.
Qed. Qed.
Global Instance cmra_valid_proper {A : cmraT} : Global Instance cmra_valid_proper {A : cmraT} :
Proper (() ==> ()) (@uPred_cmra_valid M A) := ne_proper _. Proper (() ==> ()) (@uPred_cmra_valid M A) := ne_proper _.
Global Instance rvs_ne n : Proper (dist n ==> dist n) (@uPred_rvs M). Global Instance bupd_ne n : Proper (dist n ==> dist n) (@uPred_bupd M).
Proof. Proof.
intros P Q HPQ. intros P Q HPQ.
unseal; split=> n' x; split; intros HP k yf ??; unseal; split=> n' x; split; intros HP k yf ??;
destruct (HP k yf) as (x'&?&?); auto; destruct (HP k yf) as (x'&?&?); auto;
exists x'; split; auto; apply HPQ; eauto using cmra_validN_op_l. exists x'; split; auto; apply HPQ; eauto using cmra_validN_op_l.
Qed. Qed.
Global Instance rvs_proper : Proper (() ==> ()) (@uPred_rvs M) := ne_proper _. Global Instance bupd_proper : Proper (() ==> ()) (@uPred_bupd M) := ne_proper _.
(** Introduction and elimination rules *) (** Introduction and elimination rules *)
Lemma pure_intro φ P : φ P φ. Lemma pure_intro φ P : φ P φ.
...@@ -1282,21 +1282,21 @@ Lemma always_cmra_valid {A : cmraT} (a : A) : □ ✓ a ⊣⊢ ✓ a. ...@@ -1282,21 +1282,21 @@ Lemma always_cmra_valid {A : cmraT} (a : A) : □ ✓ a ⊣⊢ ✓ a.
apply:always_cmra_valid_1. apply:always_cmra_valid_1.
Qed. Qed.
(* Viewshifts *) (* Basic update modality *)
Lemma rvs_intro P : P =r=> P. Lemma bupd_intro P : P =r=> P.
Proof. Proof.
unseal. split=> n x ? HP k yf ?; exists x; split; first done. unseal. split=> n x ? HP k yf ?; exists x; split; first done.
apply uPred_closed with n; eauto using cmra_validN_op_l. apply uPred_closed with n; eauto using cmra_validN_op_l.
Qed. Qed.
Lemma rvs_mono P Q : (P Q) (|=r=> P) =r=> Q. Lemma bupd_mono P Q : (P Q) (|=r=> P) =r=> Q.
Proof. Proof.
unseal. intros HPQ; split=> n x ? HP k yf ??. unseal. intros HPQ; split=> n x ? HP k yf ??.
destruct (HP k yf) as (x'&?&?); eauto. destruct (HP k yf) as (x'&?&?); eauto.
exists x'; split; eauto using uPred_in_entails, cmra_validN_op_l. exists x'; split; eauto using uPred_in_entails, cmra_validN_op_l.
Qed. Qed.
Lemma rvs_trans P : (|=r=> |=r=> P) =r=> P. Lemma bupd_trans P : (|=r=> |=r=> P) =r=> P.
Proof. unseal; split; naive_solver. Qed. Proof. unseal; split; naive_solver. Qed.
Lemma rvs_frame_r P R : (|=r=> P) R =r=> P R. Lemma bupd_frame_r P R : (|=r=> P) R =r=> P R.
Proof. Proof.
unseal; split; intros n x ? (x1&x2&Hx&HP&?) k yf ??. unseal; split; intros n x ? (x1&x2&Hx&HP&?) k yf ??.
destruct (HP k (x2 yf)) as (x'&?&?); eauto. destruct (HP k (x2 yf)) as (x'&?&?); eauto.
...@@ -1305,7 +1305,7 @@ Proof. ...@@ -1305,7 +1305,7 @@ Proof.
exists x', x2; split_and?; auto. exists x', x2; split_and?; auto.
apply uPred_closed with n; eauto 3 using cmra_validN_op_l, cmra_validN_op_r. apply uPred_closed with n; eauto 3 using cmra_validN_op_l, cmra_validN_op_r.
Qed. Qed.
Lemma rvs_ownM_updateP x (Φ : M Prop) : Lemma bupd_ownM_updateP x (Φ : M Prop) :
x ~~>: Φ uPred_ownM x =r=> y, Φ y uPred_ownM y. x ~~>: Φ uPred_ownM x =r=> y, Φ y uPred_ownM y.
Proof. Proof.
unseal=> Hup; split=> n x2 ? [x3 Hx] k yf ??. unseal=> Hup; split=> n x2 ? [x3 Hx] k yf ??.
...@@ -1316,27 +1316,27 @@ Proof. ...@@ -1316,27 +1316,27 @@ Proof.
Qed. Qed.
(** * Derived rules *) (** * Derived rules *)
Global Instance rvs_mono' : Proper (() ==> ()) (@uPred_rvs M). Global Instance bupd_mono' : Proper (() ==> ()) (@uPred_bupd M).
Proof. intros P Q; apply rvs_mono. Qed. Proof. intros P Q; apply bupd_mono. Qed.
Global Instance rvs_flip_mono' : Proper (flip () ==> flip ()) (@uPred_rvs M). Global Instance bupd_flip_mono' : Proper (flip () ==> flip ()) (@uPred_bupd M).
Proof. intros P Q; apply rvs_mono. Qed. Proof. intros P Q; apply bupd_mono. Qed.
Lemma rvs_frame_l R Q : (R |=r=> Q) =r=> R Q. Lemma bupd_frame_l R Q : (R |=r=> Q) =r=> R Q.
Proof. rewrite !(comm _ R); apply rvs_frame_r. Qed. Proof. rewrite !(comm _ R); apply bupd_frame_r. Qed.
Lemma rvs_wand_l P Q : (P - Q) (|=r=> P) =r=> Q. Lemma bupd_wand_l P Q : (P - Q) (|=r=> P) =r=> Q.
Proof. by rewrite rvs_frame_l wand_elim_l. Qed. Proof. by rewrite bupd_frame_l wand_elim_l. Qed.
Lemma rvs_wand_r P Q : (|=r=> P) (P - Q) =r=> Q. Lemma bupd_wand_r P Q : (|=r=> P) (P - Q) =r=> Q.
Proof. by rewrite rvs_frame_r wand_elim_r. Qed. Proof. by rewrite bupd_frame_r wand_elim_r. Qed.
Lemma rvs_sep P Q : (|=r=> P) (|=r=> Q) =r=> P Q. Lemma bupd_sep P Q : (|=r=> P) (|=r=> Q) =r=> P Q.
Proof. by rewrite rvs_frame_r rvs_frame_l rvs_trans. Qed. Proof. by rewrite bupd_frame_r bupd_frame_l bupd_trans. Qed.
Lemma rvs_ownM_update x y : x ~~> y uPred_ownM x |=r=> uPred_ownM y. Lemma bupd_ownM_update x y : x ~~> y uPred_ownM x |=r=> uPred_ownM y.
Proof. Proof.
intros; rewrite (rvs_ownM_updateP _ (y =)); last by apply cmra_update_updateP. intros; rewrite (bupd_ownM_updateP _ (y =)); last by apply cmra_update_updateP.
by apply rvs_mono, exist_elim=> y'; apply pure_elim_l=> ->. by apply bupd_mono, exist_elim=> y'; apply pure_elim_l=> ->.
Qed. Qed.
Lemma except_last_rvs P : (|=r=> P) (|=r=> P). Lemma except_last_bupd P : (|=r=> P) (|=r=> P).
Proof. Proof.
rewrite /uPred_except_last. apply or_elim; auto using rvs_mono. rewrite /uPred_except_last. apply or_elim; auto using bupd_mono.
by rewrite -rvs_intro -or_intro_l. by rewrite -bupd_intro -or_intro_l.
Qed. Qed.
(* Products *) (* Products *)
...@@ -1495,8 +1495,8 @@ Proof. ...@@ -1495,8 +1495,8 @@ Proof.
cut ( x, {n} x Nat.iter n (λ P, |=r=> P)%I ( φ)%I n x φ). cut ( x, {n} x Nat.iter n (λ P, |=r=> P)%I ( φ)%I n x φ).
{ intros help H. eapply (help ); eauto using ucmra_unit_validN. { intros help H. eapply (help ); eauto using ucmra_unit_validN.
eapply H; try unseal; eauto using ucmra_unit_validN. } eapply H; try unseal; eauto using ucmra_unit_validN. }
unseal. induction n as [|n IH]=> x Hx Hvs; auto. unseal. induction n as [|n IH]=> x Hx Hupd; auto.
destruct (Hvs (S n) ) as (x'&?&?); rewrite ?right_id; auto. destruct (Hupd (S n) ) as (x'&?&?); rewrite ?right_id; auto.
eapply IH with x'; eauto using cmra_validN_S, cmra_validN_op_l. eapply IH with x'; eauto using cmra_validN_S, cmra_validN_op_l.
Qed. Qed.
......
...@@ -20,7 +20,7 @@ Definition heap_adequacy Σ `{heapPreG Σ} e σ φ : ...@@ -20,7 +20,7 @@ Definition heap_adequacy Σ `{heapPreG Σ} e σ φ :
adequate e σ φ. adequate e σ φ.
Proof. Proof.
intros Hwp; eapply (wp_adequacy Σ); iIntros (?) "Hσ". intros Hwp; eapply (wp_adequacy Σ); iIntros (?) "Hσ".
iVs (auth_alloc to_heap _ heapN _ σ with "[Hσ]") as (γ) "[Hh _]";[|by iNext|]. iUpd (auth_alloc to_heap _ heapN _ σ with "[Hσ]") as (γ) "[Hh _]";[|by iNext|].
{ exact: to_heap_valid. } { exact: to_heap_valid. }
set (Hheap := HeapG _ _ _ γ). set (Hheap := HeapG _ _ _ γ).
iApply (Hwp _). by rewrite /heap_ctx. iApply (Hwp _). by rewrite /heap_ctx.
......
...@@ -109,10 +109,10 @@ Section heap. ...@@ -109,10 +109,10 @@ Section heap.
heap_ctx ( l, l v ={E}= Φ (LitV (LitLoc l))) WP Alloc e @ E {{ Φ }}. heap_ctx ( l, l v ={E}= Φ (LitV (LitLoc l))) WP Alloc e @ E {{ Φ }}.
Proof. Proof.
iIntros (<-%of_to_val ?) "[#Hinv HΦ]". rewrite /heap_ctx. iIntros (<-%of_to_val ?) "[#Hinv HΦ]". rewrite /heap_ctx.
iVs (auth_empty heap_name) as "Ha". iUpd (auth_empty heap_name) as "Ha".
iVs (auth_open with "[$Hinv $Ha]") as (σ) "(%&Hσ&Hcl)"; first done. iUpd (auth_open with "[$Hinv $Ha]") as (σ) "(%&Hσ&Hcl)"; first done.
iApply wp_alloc_pst. iFrame "Hσ". iNext. iIntros (l) "[% Hσ] !==>". iApply wp_alloc_pst. iFrame "Hσ". iNext. iIntros (l) "[% Hσ] !==>".
iVs ("Hcl" with "* [Hσ]") as "Ha". iUpd ("Hcl" with "* [Hσ]") as "Ha".
{ iFrame. iPureIntro. rewrite to_heap_insert. { iFrame. iPureIntro. rewrite to_heap_insert.
eapply alloc_singleton_local_update; by auto using lookup_to_heap_None. } eapply alloc_singleton_local_update; by auto using lookup_to_heap_None. }
iApply "HΦ". by rewrite heap_mapsto_eq /heap_mapsto_def. iApply "HΦ". by rewrite heap_mapsto_eq /heap_mapsto_def.
...@@ -125,9 +125,9 @@ Section heap. ...@@ -125,9 +125,9 @@ Section heap.
Proof. Proof.
iIntros (?) "[#Hinv [>Hl HΦ]]". iIntros (?) "[#Hinv [>Hl HΦ]]".
rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def. rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def.
iVs (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done. iUpd (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done.
iApply (wp_load_pst _ σ); first eauto using heap_singleton_included. iApply (wp_load_pst _ σ); first eauto using heap_singleton_included.
iIntros "{$Hσ} !> Hσ !==>". iVs ("Hcl" with "* [Hσ]") as "Ha"; first eauto. iIntros "{$Hσ} !> Hσ !==>". iUpd ("Hcl" with "* [Hσ]") as "Ha"; first eauto.
by iApply "HΦ". by iApply "HΦ".
Qed. Qed.
...@@ -138,9 +138,9 @@ Section heap. ...@@ -138,9 +138,9 @@ Section heap.
Proof. Proof.
iIntros (<-%of_to_val ?) "[#Hinv [>Hl HΦ]]". iIntros (<-%of_to_val ?) "[#Hinv [>Hl HΦ]]".
rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def. rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def.
iVs (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done. iUpd (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done.
iApply (wp_store_pst _ σ); first eauto using heap_singleton_included. iApply (wp_store_pst _ σ); first eauto using heap_singleton_included.
iIntros "{$Hσ} !> Hσ !==>". iVs ("Hcl" with "* [Hσ]") as "Ha". iIntros "{$Hσ} !> Hσ !==>". iUpd ("Hcl" with "* [Hσ]") as "Ha".
{ iFrame. iPureIntro. rewrite to_heap_insert. { iFrame. iPureIntro. rewrite to_heap_insert.
eapply singleton_local_update, exclusive_local_update; last done. eapply singleton_local_update, exclusive_local_update; last done.
by eapply heap_singleton_included'. } by eapply heap_singleton_included'. }
...@@ -154,9 +154,9 @@ Section heap. ...@@ -154,9 +154,9 @@ Section heap.
Proof. Proof.
iIntros (<-%of_to_val <-%of_to_val ??) "[#Hinv [>Hl HΦ]]". iIntros (<-%of_to_val <-%of_to_val ??) "[#Hinv [>Hl HΦ]]".
rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def. rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def.
iVs (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done. iUpd (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done.
iApply (wp_cas_fail_pst _ σ); [eauto using heap_singleton_included|done|]. iApply (wp_cas_fail_pst _ σ); [eauto using heap_singleton_included|done|].
iIntros "{$Hσ} !> Hσ !==>". iVs ("Hcl" with "* [Hσ]") as "Ha"; first eauto. iIntros "{$Hσ} !> Hσ !==>". iUpd ("Hcl" with "* [Hσ]") as "Ha"; first eauto.
by iApply "HΦ". by iApply "HΦ".
Qed. Qed.
...@@ -167,9 +167,9 @@ Section heap. ...@@ -167,9 +167,9 @@ Section heap.
Proof. Proof.
iIntros (<-%of_to_val <-%of_to_val ?) "[#Hinv [>Hl HΦ]]". iIntros (<-%of_to_val <-%of_to_val ?) "[#Hinv [>Hl HΦ]]".
rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def. rewrite /heap_ctx heap_mapsto_eq /heap_mapsto_def.
iVs (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done. iUpd (auth_open with "[$Hinv $Hl]") as (σ) "(%&Hσ&Hcl)"; first done.
iApply (wp_cas_suc_pst _ σ); first eauto using heap_singleton_included. iApply (wp_cas_suc_pst _ σ); first eauto using heap_singleton_included.
iIntros "{$Hσ} !> Hσ !==>". iVs ("Hcl" with "* [Hσ]") as "Ha". iIntros "{$Hσ} !> Hσ !==>". iUpd ("Hcl" with "* [Hσ]") as "Ha".
{ iFrame. iPureIntro. rewrite to_heap_insert. { iFrame. iPureIntro. rewrite to_heap_insert.
eapply singleton_local_update, exclusive_local_update; last done. eapply singleton_local_update, exclusive_local_update; last done.
by eapply heap_singleton_included'. } by eapply heap_singleton_included'. }
......
...@@ -98,8 +98,8 @@ Proof. ...@@ -98,8 +98,8 @@ Proof.
iIntros (HN) "[#? HΦ]". iIntros (HN) "[#? HΦ]".
rewrite /newbarrier /=. wp_seq. wp_alloc l as "Hl". rewrite /newbarrier /=. wp_seq. wp_alloc l as "Hl".
iApply ("HΦ" with "==>[-]"). iApply ("HΦ" with "==>[-]").
iVs (saved_prop_alloc (F:=idCF) P) as (γ) "#?". iUpd (saved_prop_alloc (F:=idCF) P) as (γ) "#?".
iVs (sts_alloc (barrier_inv l P) _ N (State Low {[ γ ]}) with "[-]") iUpd (sts_alloc (barrier_inv l P) _ N (State Low {[ γ ]}) with "[-]")
as (γ') "[#? Hγ']"; eauto. as (γ') "[#? Hγ']"; eauto.
{ iNext. rewrite /barrier_inv /=. iFrame. { iNext. rewrite /barrier_inv /=. iFrame.
iExists (const P). rewrite !big_sepS_singleton /=. eauto. } iExists (const P). rewrite !big_sepS_singleton /=. eauto. }
...@@ -112,7 +112,7 @@ Proof. ...@@ -112,7 +112,7 @@ Proof.
- iApply (sts_own_weaken with "Hγ'"); - iApply (sts_own_weaken with "Hγ'");
auto using sts.closed_op, i_states_closed, low_states_closed; auto using sts.closed_op, i_states_closed, low_states_closed;
abstract set_solver. } abstract set_solver. }
iVsIntro. rewrite /recv /send. iSplitL "Hr". iUpdIntro. rewrite /recv /send. iSplitL "Hr".
- iExists γ', P, P, γ. iFrame. auto. - iExists γ', P, P, γ. iFrame. auto.
- auto. - auto.
Qed. Qed.
...@@ -122,10 +122,10 @@ Lemma signal_spec l P (Φ : val → iProp Σ) : ...@@ -122,10 +122,10 @@ Lemma signal_spec l P (Φ : val → iProp Σ) :
Proof. Proof.
rewrite /signal /send /barrier_ctx /=. rewrite /signal /send /barrier_ctx /=.
iIntros "(Hs&HP&HΦ)"; iDestruct "Hs" as (γ) "[#(%&Hh&Hsts) Hγ]". wp_let. iIntros "(Hs&HP&HΦ)"; iDestruct "Hs" as (γ) "[#(%&Hh&Hsts) Hγ]". wp_let.
iVs (sts_openS (barrier_inv l P) _ _ γ with "[Hγ]") iUpd (sts_openS (barrier_inv l P) _ _ γ with "[Hγ]")
as ([p I]) "(% & [Hl Hr] & Hclose)"; eauto. as ([p I]) "(% & [Hl Hr] & Hclose)"; eauto.
destruct p; [|done]. wp_store. iFrame "HΦ". destruct p; [|done]. wp_store. iFrame "HΦ".
iVs ("Hclose" $! (State High I) ( : set token) with "[-]"); last done. iUpd ("Hclose" $! (State High I) ( : set token) with "[-]"); last done.
iSplit; [iPureIntro; by eauto using signal_step|]. iSplit; [iPureIntro; by eauto using signal_step|].
iNext. rewrite {2}/barrier_inv /ress /=; iFrame "Hl". iNext. rewrite {2}/barrier_inv /ress /=; iFrame "Hl".
iDestruct "Hr" as (Ψ) "[Hr Hsp]"; iExists Ψ; iFrame "Hsp". iDestruct "Hr" as (Ψ) "[Hr Hsp]"; iExists Ψ; iFrame "Hsp".
...@@ -138,14 +138,14 @@ Proof. ...@@ -138,14 +138,14 @@ Proof.
rename P into R; rewrite /recv /barrier_ctx. rename P into R; rewrite /recv /barrier_ctx.
iIntros "[Hr HΦ]"; iDestruct "Hr" as (γ P Q i) "(#(%&Hh&Hsts)&Hγ&#HQ&HQR)". iIntros "[Hr HΦ]"; iDestruct "Hr" as (γ P Q i) "(#(%&Hh&Hsts)&Hγ&#HQ&HQR)".
iLöb as "IH". wp_rec. wp_bind (! _)%E. iLöb as "IH". wp_rec. wp_bind (! _)%E.
iVs (sts_openS (barrier_inv l P) _ _ γ with "[Hγ]") iUpd (sts_openS (barrier_inv l P) _ _ γ with "[Hγ]")
as ([p I]) "(% & [Hl Hr] & Hclose)"; eauto. as ([p I]) "(% & [Hl Hr] & Hclose)"; eauto.
wp_load. destruct p. wp_load. destruct p.
- iVs ("Hclose" $! (State Low I) {[ Change i ]} with "[Hl Hr]") as "Hγ". - iUpd ("Hclose" $! (State Low I) {[ Change i ]} with "[Hl Hr]") as "Hγ".
{ iSplit; first done. iNext. rewrite {2}/barrier_inv /=. by iFrame. } { iSplit; first done. iNext. rewrite {2}/barrier_inv /=. by iFrame. }
iAssert (sts_ownS γ (i_states i) {[Change i]})%I with "==>[Hγ]" as "Hγ". iAssert (sts_ownS γ (i_states i) {[Change i]})%I with "==>[Hγ]" as "Hγ".
{ iApply (sts_own_weaken with "Hγ"); eauto using i_states_closed. } { iApply (sts_own_weaken with "Hγ"); eauto using i_states_closed. }
iVsIntro. wp_if. iUpdIntro. wp_if.
iApply ("IH" with "Hγ [HQR] HΦ"). auto. iApply ("IH" with "Hγ [HQR] HΦ"). auto.
- (* a High state: the comparison succeeds, and we perform a transition and - (* a High state: the comparison succeeds, and we perform a transition and
return to the client *) return to the client *)
...@@ -153,12 +153,12 @@ Proof. ...@@ -153,12 +153,12 @@ Proof.
iDestruct (big_sepS_delete _ _ i with "Hsp") as "[#HΨi Hsp]"; first done. iDestruct (big_sepS_delete _ _ i with "Hsp") as "[#HΨi Hsp]"; first done.
iAssert ( Ψ i [ set] j I {[i]}, Ψ j)%I with "[HΨ]" as "[HΨ HΨ']". iAssert ( Ψ i [ set] j I {[i]}, Ψ j)%I with "[HΨ]" as "[HΨ HΨ']".
{ iNext. iApply (big_sepS_delete _ _ i); first done. by iApply "HΨ". } { iNext. iApply (big_sepS_delete _ _ i); first done. by iApply "HΨ". }
iVs ("Hclose" $! (State High (I {[ i ]})) ( : set token) with "[HΨ' Hl Hsp]"). iUpd ("Hclose" $! (State High (I {[ i ]})) ( : set token) with "[HΨ' Hl Hsp]").
{ iSplit; [iPureIntro; by eauto using wait_step|]. { iSplit; [iPureIntro; by eauto using wait_step|].
iNext. rewrite {2}/barrier_inv /=; iFrame "Hl". iExists Ψ; iFrame. auto. } iNext. rewrite {2}/barrier_inv /=; iFrame "Hl". iExists Ψ; iFrame. auto. }
iPoseProof (saved_prop_agree i Q (Ψ i) with "[#]") as "Heq"; first by auto. iPoseProof (saved_prop_agree i Q (Ψ i) with "[#]") as "Heq"; first by auto.
iVsIntro. wp_if. iUpdIntro. wp_if.
iVsIntro. iApply "HΦ". iApply "HQR". by iRewrite "Heq". iUpdIntro. iApply "HΦ". iApply "HQR". by iRewrite "Heq".
Qed. Qed.
Lemma recv_split E l P1 P2 : Lemma recv_split E l P1 P2 :
...@@ -166,13 +166,13 @@ Lemma recv_split E l P1 P2 : ...@@ -166,13 +166,13 @@ Lemma recv_split E l P1 P2 :
Proof. Proof.
rename P1 into R1; rename P2 into R2. rewrite {1}/recv /barrier_ctx. rename P1 into R1; rename P2 into R2. rewrite {1}/recv /barrier_ctx.
iIntros (?). iDestruct 1 as (γ P Q i) "(#(%&Hh&Hsts)&Hγ&#HQ&HQR)". iIntros (?). iDestruct 1 as (γ P Q i) "(#(%&Hh&Hsts)&Hγ&#HQ&HQR)".
iVs (sts_openS (barrier_inv l P) _ _ γ with "[Hγ]") iUpd (sts_openS (barrier_inv l P) _ _ γ with "[Hγ]")
as ([p I]) "(% & [Hl Hr] & Hclose)"; eauto. as ([p I]) "(% & [Hl Hr] & Hclose)"; eauto.
iVs (saved_prop_alloc_strong (R1: %CF (iProp Σ)) I) as (i1) "[% #Hi1]". iUpd (saved_prop_alloc_strong (R1: %CF (iProp Σ)) I) as (i1) "[% #Hi1]".
iVs (saved_prop_alloc_strong (R2: %CF (iProp Σ)) (I {[i1]})) iUpd (saved_prop_alloc_strong (R2: %CF (iProp Σ)) (I {[i1]}))
as (i2) "[Hi2' #Hi2]"; iDestruct "Hi2'" as %Hi2. as (i2) "[Hi2' #Hi2]"; iDestruct "Hi2'" as %Hi2.
rewrite ->not_elem_of_union, elem_of_singleton in Hi2; destruct Hi2. rewrite ->not_elem_of_union, elem_of_singleton in Hi2; destruct Hi2.
iVs ("Hclose" $! (State p ({[i1; i2]} I {[i]})) iUpd ("Hclose" $! (State p ({[i1; i2]} I {[i]}))
{[Change i1; Change i2 ]} with "[-]") as "Hγ". {[Change i1; Change i2 ]} with "[-]") as "Hγ".
{ iSplit; first by eauto using split_step. { iSplit; first by eauto using split_step.
iNext. rewrite {2}/barrier_inv /=. iFrame "Hl". iNext. rewrite {2}/barrier_inv /=. iFrame "Hl".
...@@ -184,7 +184,7 @@ Proof. ...@@ -184,7 +184,7 @@ Proof.
- iApply (sts_own_weaken with "Hγ"); - iApply (sts_own_weaken with "Hγ");
eauto using sts.closed_op, i_states_closed. eauto using sts.closed_op, i_states_closed.
abstract set_solver. } abstract set_solver. }
iVsIntro; iSplitL "Hγ1"; rewrite /recv /barrier_ctx. iUpdIntro; iSplitL "Hγ1"; rewrite /recv /barrier_ctx.
- iExists γ, P, R1, i1. iFrame; auto. - iExists γ, P, R1, i1. iFrame; auto.
- iExists γ, P, R2, i2. iFrame; auto. - iExists γ,