Commit 9f47522f by Daniel Gratzer

### Small changes to specs, strengthen CAP spec

parent 4cd40eb2
 ... ... @@ -171,6 +171,6 @@ Section stacks. Qed. End stacks. Program Definition spec {Σ} `{heapG Σ} : concurrent_bag Σ := {| is_bag := is_stack; new_bag := new_stack; bag_push := push; bag_pop := pop |} . Program Definition spec {Σ} N `{heapG Σ} : concurrent_bag Σ := {| is_bag := is_stack N; new_bag := new_stack; bag_push := push; bag_pop := pop |} . Solve Obligations of spec with eauto using pop_spec, push_spec, new_stack_spec.
 ... ... @@ -394,6 +394,6 @@ Section stack_works. Qed. End stack_works. Program Definition spec {Σ} `{heapG Σ, channelG Σ} : concurrent_bag Σ := {| is_bag := is_stack; new_bag := new_stack; bag_push := push; bag_pop := pop |} . Program Definition spec {Σ} N `{heapG Σ, channelG Σ} : concurrent_bag Σ := {| is_bag := is_stack N; new_bag := new_stack; bag_push := push; bag_pop := pop |} . Solve Obligations of spec with eauto using pop_spec, push_spec, new_stack_spec.
 ... ... @@ -133,12 +133,12 @@ Section stack_works. Theorem pop_spec P s Ψ : {{{ is_stack_pred P s ∗ (∀ v xs, P (v :: xs) ={⊤ ∖ ↑ N}=∗ P xs ∗ Ψ (SOMEV v)) ∗ (∀ v xs, P (v :: xs) ={⊤ ∖ ↑ N}=∗ P xs ∗ Ψ (SOMEV v)) ∧ (P [] ={⊤ ∖ ↑ N}=∗ P [] ∗ Ψ NONEV) }}} pop s {{{ v, RET v; Ψ v }}}. Proof. iIntros (Φ) "(Hstack & Hupdcons & Hupdnil) HΦ". iIntros (Φ) "(Hstack & Hupd) HΦ". iDestruct "Hstack" as (l) "[-> #Hinv]". iLöb as "IH". wp_lam. wp_bind (Load _). ... ... @@ -147,6 +147,7 @@ Section stack_works. iDestruct (is_list_disj with "Hlist") as "[Hlist H]". iDestruct "H" as "[-> | HSome]". - iDestruct (is_list_empty with "Hlist") as %->. iDestruct "Hupd" as "[_ Hupdnil]". iMod ("Hupdnil" with "HP") as "[HP HΨ]". iMod ("Hclose" with "[Hlist Hl HP]") as "_". { iNext; iExists _, _; iFrame. } ... ... @@ -170,6 +171,7 @@ Section stack_works. * wp_cas_suc. iDestruct (is_list_cons with "[Hl'] Hlist") as (ys) "%"; first by iExists _. simplify_eq. iDestruct "Hupd" as "[Hupdcons _]". iMod ("Hupdcons" with "HP") as "[HP HΨ]". iDestruct "Hlist" as (l'' t') "(% & Hl'' & Hlist)"; simplify_eq. iDestruct "Hl''" as (q') "Hl''". ... ... @@ -184,7 +186,7 @@ Section stack_works. { iNext; iExists _, _; iFrame. } iModIntro. wp_if. iApply ("IH" with "Hupdcons Hupdnil HΦ"). iApply ("IH" with "Hupd HΦ"). Qed. End stack_works. ... ...
 ... ... @@ -4,27 +4,27 @@ From iris.heap_lang Require Export proofmode notation. (** General (HoCAP-style) spec for a concurrent bag ("per-elemt spec") *) Record concurrent_bag {Σ} `{!heapG Σ} := ConcurrentBag { is_bag (N : namespace) (P : val → iProp Σ) (s : val) : iProp Σ; bag_pers (N : namespace) (P : val → iProp Σ) (s : val) : is_bag N P s -∗ □ is_bag N P s; is_bag (P : val → iProp Σ) (s : val) : iProp Σ; bag_pers (P : val → iProp Σ) (s : val) : Persistent (is_bag P s); new_bag : val; bag_push : val; bag_pop : val; mk_bag_spec (N : namespace) (P : val → iProp Σ) : mk_bag_spec (P : val → iProp Σ) : {{{ True }}} new_bag #() {{{ s, RET s; is_bag N P s }}}; bag_push_spec (N : namespace) (P : val → iProp Σ) s v : {{{ is_bag N P s ∗ P v }}} bag_push s v {{{ RET #(); True }}}; bag_pop_spec (N : namespace) (P : val → iProp Σ) s : {{{ is_bag N P s }}} bag_pop s {{{ ov, RET ov; ⌜ov = NONEV⌝ ∨ ∃ v, ⌜ov = SOMEV v⌝ ∗ P v }}} {{{ s, RET s; is_bag P s }}}; bag_push_spec (P : val → iProp Σ) s v : {{{ is_bag P s ∗ P v }}} bag_push s v {{{ RET #(); True }}}; bag_pop_spec (P : val → iProp Σ) s : {{{ is_bag P s }}} bag_pop s {{{ ov, RET ov; ⌜ov = NONEV⌝ ∨ ∃ v, ⌜ov = SOMEV v⌝ ∗ P v }}} }. Arguments concurrent_bag _ {_}. (** General (HoCAP-style) spec for a concurrent stack *) (** General (CAP-style) spec for a concurrent stack *) Record concurrent_stack {Σ} `{!heapG Σ} := ConcurrentStack { is_stack (N : namespace) (P : list val → iProp Σ) (s : val) : iProp Σ; stack_pers (N : namespace) (P : list val → iProp Σ) (s : val) : is_stack N P s -∗ □ is_stack N P s; stack_pers (N : namespace) (P : list val → iProp Σ) (s : val) : Persistent (is_stack N P s); new_stack : val; stack_push : val; stack_pop : val; ... ... @@ -36,7 +36,7 @@ Record concurrent_stack {Σ} `{!heapG Σ} := ConcurrentStack { {{{ RET #(); Ψ #() }}}; stack_pop_spec (N : namespace) (P : list val → iProp Σ) Ψ s : {{{ is_stack N P s ∗ (∀ v xs, P (v :: xs) ={⊤ ∖ ↑ N}=∗ P xs ∗ Ψ (SOMEV v)) ∗ (∀ v xs, P (v :: xs) ={⊤ ∖ ↑ N}=∗ P xs ∗ Ψ (SOMEV v)) ∧ (P [] ={⊤ ∖ ↑ N}=∗ P [] ∗ Ψ NONEV) }}} stack_pop s {{{ v, RET v; Ψ v }}}; ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!