From 160cd18c497e357e5c8918807acb1f393e3c4dd5 Mon Sep 17 00:00:00 2001
From: Robbert Krebbers <mail@robbertkrebbers.nl>
Date: Wed, 9 Nov 2016 16:48:15 +0100
Subject: [PATCH] Curried version of wp_wand.

---
 heap_lang/lib/assert.v       |  2 +-
 heap_lang/lib/par.v          |  2 +-
 heap_lang/lib/spawn.v        |  2 +-
 program_logic/hoare.v        |  6 +++---
 program_logic/weakestpre.v   | 11 +++++++----
 tests/barrier_client.v       |  2 +-
 tests/joining_existentials.v |  4 ++--
 tests/one_shot.v             |  2 +-
 8 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/heap_lang/lib/assert.v b/heap_lang/lib/assert.v
index 5b454b0be..b222b908d 100644
--- a/heap_lang/lib/assert.v
+++ b/heap_lang/lib/assert.v
@@ -13,5 +13,5 @@ Lemma wp_assert `{heapG Σ} E (Φ : val → iProp Σ) e `{!Closed [] e} :
   WP e @ E {{ v, v = #true ∧ ▷ Φ #() }} ⊢ WP assert: e @ E {{ Φ }}.
 Proof.
   iIntros "HΦ". rewrite /assert. wp_let. wp_seq.
-  iApply (wp_wand_r with "[- $HΦ]"). iIntros (v) "[% ?]"; subst. by wp_if.
+  iApply (wp_wand with "HΦ"). iIntros (v) "[% ?]"; subst. by wp_if.
 Qed.
diff --git a/heap_lang/lib/par.v b/heap_lang/lib/par.v
index ad5f70a67..52eae597b 100644
--- a/heap_lang/lib/par.v
+++ b/heap_lang/lib/par.v
@@ -30,7 +30,7 @@ Proof.
   rewrite /par. wp_value. wp_let. wp_proj.
   wp_apply (spawn_spec parN with "[$Hh $Hf1]"); try wp_done; try solve_ndisj.
   iIntros (l) "Hl". wp_let. wp_proj. wp_bind (f2 _).
-  iApply (wp_wand_r with "[- $Hf2]"); iIntros (v) "H2". wp_let.
+  iApply (wp_wand with "Hf2"); iIntros (v) "H2". wp_let.
   wp_apply (join_spec with "[$Hl]"). iIntros (w) "H1".
   iSpecialize ("HΦ" with "* [-]"); first by iSplitL "H1". by wp_let.
 Qed.
diff --git a/heap_lang/lib/spawn.v b/heap_lang/lib/spawn.v
index 473667118..8e2e16788 100644
--- a/heap_lang/lib/spawn.v
+++ b/heap_lang/lib/spawn.v
@@ -58,7 +58,7 @@ Proof.
   { iNext. iExists NONEV. iFrame; eauto. }
   wp_apply wp_fork; simpl. iSplitR "Hf".
   - wp_seq. iApply "HΦ". rewrite /join_handle. eauto.
-  - wp_bind (f _). iApply (wp_wand_r with "[ $Hf]"); iIntros (v) "Hv".
+  - wp_bind (f _). iApply (wp_wand with "Hf"); iIntros (v) "Hv".
     iInv N as (v') "[Hl _]" "Hclose".
     wp_store. iApply "Hclose". iNext. iExists (SOMEV v). iFrame. eauto.
 Qed.
diff --git a/program_logic/hoare.v b/program_logic/hoare.v
index 8fcb0ec3c..0f8b104df 100644
--- a/program_logic/hoare.v
+++ b/program_logic/hoare.v
@@ -64,7 +64,7 @@ Lemma ht_vs E P P' Φ Φ' e :
   ⊢ {{ P }} e @ E {{ Φ }}.
 Proof.
   iIntros "(#Hvs & #Hwp & #HΦ) !# HP". iMod ("Hvs" with "HP") as "HP".
-  iApply wp_fupd; iApply wp_wand_r; iSplitL; [by iApply "Hwp"|].
+  iApply wp_fupd. iApply (wp_wand with "[HP]"); [by iApply "Hwp"|].
   iIntros (v) "Hv". by iApply "HΦ".
 Qed.
 
@@ -75,7 +75,7 @@ Lemma ht_atomic E1 E2 P P' Φ Φ' e :
 Proof.
   iIntros (?) "(#Hvs & #Hwp & #HΦ) !# HP". iApply (wp_atomic _ E2); auto.
   iMod ("Hvs" with "HP") as "HP". iModIntro.
-  iApply wp_wand_r; iSplitL; [by iApply "Hwp"|].
+  iApply (wp_wand with "[HP]"); [by iApply "Hwp"|].
   iIntros (v) "Hv". by iApply "HΦ".
 Qed.
 
@@ -84,7 +84,7 @@ Lemma ht_bind `{LanguageCtx Λ K} E P Φ Φ' e :
   ⊢ {{ P }} K e @ E {{ Φ' }}.
 Proof.
   iIntros "[#Hwpe #HwpK] !# HP". iApply wp_bind.
-  iApply wp_wand_r; iSplitL; [by iApply "Hwpe"|].
+  iApply (wp_wand with "[HP]"); [by iApply "Hwpe"|].
   iIntros (v) "Hv". by iApply "HwpK".
 Qed.
 
diff --git a/program_logic/weakestpre.v b/program_logic/weakestpre.v
index 59efd2377..97fee1f57 100644
--- a/program_logic/weakestpre.v
+++ b/program_logic/weakestpre.v
@@ -275,15 +275,18 @@ Lemma wp_frame_step_r' E e Φ R :
   to_val e = None → WP e @ E {{ Φ }} ∗ ▷ R ⊢ WP e @ E {{ v, Φ v ∗ R }}.
 Proof. iIntros (?) "[??]". iApply (wp_frame_step_r E E); try iFrame; eauto. Qed.
 
-Lemma wp_wand_l E e Φ Ψ :
-  (∀ v, Φ v -∗ Ψ v) ∗ WP e @ E {{ Φ }} ⊢ WP e @ E {{ Ψ }}.
+Lemma wp_wand E e Φ Ψ :
+  WP e @ E {{ Φ }} ⊢ (∀ v, Φ v -∗ Ψ v) -∗ WP e @ E {{ Ψ }}.
 Proof.
-  iIntros "[H Hwp]". iApply (wp_strong_mono E); auto.
+  iIntros "Hwp H". iApply (wp_strong_mono E); auto.
   iFrame "Hwp". iIntros (?) "?". by iApply "H".
 Qed.
+Lemma wp_wand_l E e Φ Ψ :
+  (∀ v, Φ v -∗ Ψ v) ∗ WP e @ E {{ Φ }} ⊢ WP e @ E {{ Ψ }}.
+Proof. iIntros "[H Hwp]". iApply (wp_wand with "Hwp H"). Qed.
 Lemma wp_wand_r E e Φ Ψ :
   WP e @ E {{ Φ }} ∗ (∀ v, Φ v -∗ Ψ v) ⊢ WP e @ E {{ Ψ }}.
-Proof. by rewrite comm wp_wand_l. Qed.
+Proof. iIntros "[Hwp H]". iApply (wp_wand with "Hwp H"). Qed.
 End wp.
 
 (** Proofmode class instances *)
diff --git a/tests/barrier_client.v b/tests/barrier_client.v
index 408bb502c..a4b7e564d 100644
--- a/tests/barrier_client.v
+++ b/tests/barrier_client.v
@@ -31,7 +31,7 @@ Section client.
     iIntros "[#Hh Hrecv]". wp_lam. wp_let.
     wp_apply (wait_spec with "[- $Hrecv]"). iDestruct 1 as (f) "[Hy #Hf]".
     wp_seq. wp_load.
-    iApply wp_wand_r. iSplitR; [iApply "Hf"|by iIntros (v) "_"].
+    iApply (wp_wand with "[]"). iApply "Hf". by iIntros (v) "_".
   Qed.
 
   Lemma client_safe : heapN ⊥ N → heap_ctx ⊢ WP client {{ _, True }}.
diff --git a/tests/joining_existentials.v b/tests/joining_existentials.v
index 0652b491f..0c3f3cb3f 100644
--- a/tests/joining_existentials.v
+++ b/tests/joining_existentials.v
@@ -37,7 +37,7 @@ Lemma worker_spec e γ l (Φ Ψ : X → iProp Σ) `{!Closed [] e} :
 Proof.
   iIntros "[Hl #He]". wp_apply (wait_spec with "[- $Hl]"); simpl.
   iDestruct 1 as (x) "[#Hγ Hx]".
-  wp_seq. iApply wp_wand_l. iSplitR; [|by iApply "He"].
+  wp_seq. iApply (wp_wand with "[Hx]"); [by iApply "He"|].
   iIntros (v) "?"; iExists x; by iSplit.
 Qed.
 
@@ -81,7 +81,7 @@ Proof.
   set (workers_post (v : val) := (barrier_res γ Ψ1 ∗ barrier_res γ Ψ2)%I).
   wp_let. wp_apply (wp_par  (λ _, True)%I workers_post with "[- $Hh]").
   iSplitL "HP Hs Hγ"; [|iSplitL "Hr"].
-  - wp_bind eM. iApply wp_wand_l; iSplitR "HP"; [|by iApply "He"].
+  - wp_bind eM. iApply (wp_wand with "[HP]"); [by iApply "He"|].
     iIntros (v) "HP"; iDestruct "HP" as (x) "HP". wp_let.
     iMod (own_update with "Hγ") as "Hx".
     { by apply (cmra_update_exclusive (Shot x)). }
diff --git a/tests/one_shot.v b/tests/one_shot.v
index dea6c813d..aa97d0087 100644
--- a/tests/one_shot.v
+++ b/tests/one_shot.v
@@ -94,6 +94,6 @@ Proof.
   iIntros (f1 f2) "[#Hf1 #Hf2]"; iSplit.
   - iIntros (n) "!# _". wp_proj. iApply "Hf1".
   - iIntros "!# _". wp_proj.
-    iApply (wp_wand_r with "[- $Hf2]"). by iIntros (v) "#? !# _".
+    iApply (wp_wand with "Hf2"). by iIntros (v) "#? !# _".
 Qed.
 End proof.
-- 
GitLab