summaryrefslogtreecommitdiffstats
path: root/theories/basic_queue_spec.v
diff options
context:
space:
mode:
Diffstat (limited to 'theories/basic_queue_spec.v')
-rw-r--r--theories/basic_queue_spec.v30
1 files changed, 30 insertions, 0 deletions
diff --git a/theories/basic_queue_spec.v b/theories/basic_queue_spec.v
new file mode 100644
index 0000000..d7a38e1
--- /dev/null
+++ b/theories/basic_queue_spec.v
@@ -0,0 +1,30 @@
1From iris.program_logic Require Import atomic.
2From iris.heap_lang Require Import notation proofmode.
3
4From lmpmc Require Import util.
5
6Record basic_queue {Σ} `{!heapGS Σ} :=
7 BasicQueue
8 { new : val;
9 enqueue : val;
10 try_dequeue : val;
11
12 queue_repr : loc → list val → iProp Σ;
13 #[global] queue_repr_timeless ℓ vs :: Timeless (queue_repr ℓ vs);
14
15 new_spec :
16 {{{ True }}}
17 new #()
18 {{{ (ℓ_q : loc), RET #ℓ_q; queue_repr ℓ_q [] }}};
19
20 enqueue_spec (ℓ_q : loc) (data : val) :
21 ⊢ <<{ ∀∀ vs, queue_repr ℓ_q vs }>>
22 enqueue #ℓ_q data @ ∅
23 <<{ queue_repr ℓ_q (vs ++ [data]) | RET #() }>>;
24
25 try_dequeue_spec (ℓ_q : loc) :
26 ⊢ <<{ ∀∀ vs, queue_repr ℓ_q vs }>>
27 try_dequeue #ℓ_q @ ∅
28 <<{ queue_repr ℓ_q (tail vs) | RET (val_opt_hl (head vs)) }>>;
29 }.
30#[global] Arguments basic_queue _ {_} : assert.