summaryrefslogtreecommitdiffstats
path: root/theories/lmpmc_blocking_dequeue.v
diff options
context:
space:
mode:
Diffstat (limited to 'theories/lmpmc_blocking_dequeue.v')
-rw-r--r--theories/lmpmc_blocking_dequeue.v40
1 files changed, 40 insertions, 0 deletions
diff --git a/theories/lmpmc_blocking_dequeue.v b/theories/lmpmc_blocking_dequeue.v
new file mode 100644
index 0000000..5051c6a
--- /dev/null
+++ b/theories/lmpmc_blocking_dequeue.v
@@ -0,0 +1,40 @@
1From iris.program_logic Require Import atomic.
2From iris.heap_lang Require Import notation proofmode.
3
4From lmpmc Require Import lmpmc_queue_spec util.
5
6Section lmpmc_blocking.
7 Context (lq : lmpmc_queue_spec.lmpmc_queue_hl).
8
9 (* https://types.pl/@pigworker/115629120124299549 *)
10 Definition dequeue : val := rec: "go" "ℓ_deq" :=
11 match: lq.(try_dequeue) "ℓ_deq" with
12 NONE => "go" "ℓ_deq"
13 | SOME "v" => "v"
14 end.
15
16 Section proofs.
17 Context `{heapGS Σ} (lqp : lmpmc_queue_spec.lmpmc_queue_iris Σ lq).
18
19 Lemma dequeue_spec (ℓ_deq : loc) :
20 ⊢ <<{ ∀∀ ℓ_enq cvs, lqp.(queue_repr lq) ℓ_deq ℓ_enq cvs }>>
21 dequeue #ℓ_deq @ ∅
22 <<{ ∃∃ cv cvs', ⌜cvs = cv :: cvs'⌝ ∗ lqp.(queue_repr lq) ℓ_deq ℓ_enq cvs' | RET cv }>>.
23 Proof.
24 iIntros (Φ) "AU". iLöb as "IH". wp_rec.
25 awp_apply lqp.(try_dequeue_spec lq).
26 rewrite /atomic_acc /=.
27 iMod "AU" as "(%ℓ_enq & %cvs & Hcvs & Hclose)".
28 iFrame. iModIntro. iSplit; iIntros "Hrepr".
29 - by iMod ("Hclose" with "Hrepr") as "AU".
30 - destruct cvs as [|cv cvs']; simplify_list_eq.
31 + iMod ("Hclose" with "Hrepr") as "AU". iModIntro.
32 wp_pures. by iApply "IH".
33 + iDestruct "Hclose" as "[_ Hclose]".
34 iMod ("Hclose" $! cv cvs' with "[$Hrepr //]") as "HΦ".
35 iModIntro. by wp_pures.
36 Qed.
37
38 End proofs.
39
40End lmpmc_blocking.