Skip to content
Snippets Groups Projects
Commit a9465820 authored by Simon Friis Vindum's avatar Simon Friis Vindum
Browse files

Minor tweaks to bag example

parent 80c70aff
No related branches found
No related tags found
1 merge request!36Add bag and tweak lock
...@@ -15,7 +15,7 @@ Definition newbag : val := ...@@ -15,7 +15,7 @@ Definition newbag : val :=
let: "v" := newlock #() in ("ℓ", "v"). let: "v" := newlock #() in ("ℓ", "v").
Definition insert : val := Definition insert : val :=
λ: "x", λ: "e", let: "ℓ" := Fst "x" in λ: "x" "e", let: "ℓ" := Fst "x" in
let: "lock" := Snd "x" in let: "lock" := Snd "x" in
acquire "lock" ;; acquire "lock" ;;
"ℓ" <- SOME ("e", !"ℓ") ;; "ℓ" <- SOME ("e", !"ℓ") ;;
...@@ -44,7 +44,7 @@ Section spec. ...@@ -44,7 +44,7 @@ Section spec.
end. end.
Definition is_bag (v : val) (Ψ : val iProp) := Definition is_bag (v : val) (Ψ : val iProp) :=
( ( : loc) (v₂ : val) γ, v = PairV (#) v₂ is_lock γ v₂ ( u, u isBag Ψ u))%I. ( ( : loc) (v₂ : val) γ, v = (#, v₂)%V is_lock γ v₂ ( u, u isBag Ψ u))%I.
Global Instance bag_persistent v Ψ: Persistent (is_bag v Ψ). Global Instance bag_persistent v Ψ: Persistent (is_bag v Ψ).
Proof. apply _. Qed. Proof. apply _. Qed.
...@@ -65,7 +65,7 @@ Section spec. ...@@ -65,7 +65,7 @@ Section spec.
{{{ is_bag v Ψ Ψ e }}} insert v e {{{ RET #(); True }}}. {{{ is_bag v Ψ Ψ e }}} insert v e {{{ RET #(); True }}}.
Proof. Proof.
iIntros (ϕ) "[Hb Hψ] Hcont". iIntros (ϕ) "[Hb Hψ] Hcont".
iDestruct "Hb" as ( u γ) "[% #IL]" ; subst. iDestruct "Hb" as ( u γ) "[% #IL]"; subst.
wp_lam. wp_pures. wp_lam. wp_pures.
wp_apply (acquire_spec with "IL"); first done. wp_apply (acquire_spec with "IL"); first done.
iIntros (v) "[P HLocked]". iIntros (v) "[P HLocked]".
...@@ -77,7 +77,7 @@ Section spec. ...@@ -77,7 +77,7 @@ Section spec.
Qed. Qed.
Lemma bag_remove_triple_spec v Ψ: Lemma bag_remove_triple_spec v Ψ:
{{{ is_bag v Ψ }}} remove v {{{ u, RET u; u = NONEV x, u = SOMEV x Ψ x}}}. {{{ is_bag v Ψ }}} remove v {{{ u, RET u; u = NONEV x, u = SOMEV x Ψ x }}}.
Proof. Proof.
iIntros (ϕ) "Hb Hcont". iIntros (ϕ) "Hb Hcont".
iDestruct "Hb" as ( u γ) "[% #IL]"; subst. iDestruct "Hb" as ( u γ) "[% #IL]"; subst.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment