diff --git a/theories/encodings/branching.v b/theories/encodings/branching.v index d94b438f7f0efb73b1924878a170ea9920a2ed03..101b6b27c33eeb443a7921b684f1a55641b5d97f 100644 --- a/theories/encodings/branching.v +++ b/theories/encodings/branching.v @@ -51,12 +51,6 @@ Section branching_specs. λ: "c" "s" "b", send "c" "s" "b". - Definition branch : val := - λ: "c" "s" "b1" "b2", - if: recv "c" "s" - then "b1" - else "b2". - Lemma select_st_spec st1 st2 γ c s (b : side) : {{{ ⟦ c @ s : st1 <+> st2 ⟧{N,γ} }}} select c #s #b @@ -70,20 +64,28 @@ Section branching_specs. iApply "HΦ". by destruct b. Qed. + + Definition branch : val := + λ: "c" "s" "b1" "b2", + if: recv "c" "s" + then "b1" + else "b2". - Lemma branch_st_spec st1 st2 γ c s (b1 b2 : val) Φ : - ⟦ c @ s : st1 <&> st2 ⟧{N,γ} -∗ - (⟦ c @ s : st1 ⟧{N,γ} -∗ (Φ b1)) -∗ - (⟦ c @ s : st2 ⟧{N,γ} -∗ (Φ b2)) -∗ - WP branch c #s b1 b2 {{ v, Φ v }}. + Lemma branch_st_spec st1 st2 γ c s (b1 b2 : val) : + {{{ ⟦ c @ s : st1 <&> st2 ⟧{N,γ} }}} + branch c #s b1 b2 + {{{ v, RET v; (⌜v = b1%V⌠∧ ⟦ c @ s : st1 ⟧{N,γ}) ∨ + (⌜v = b2%V⌠∧ ⟦ c @ s : st2 ⟧{N,γ})}}}. Proof. - iIntros "Hst Hb1 Hb2". - wp_lam. rewrite /TSB. + iIntros (Φ'). + iIntros "Hst HΦ'". + wp_pures. + wp_lam. rewrite /TSB. simpl. wp_apply (recv_st_spec N bool with "[$Hst //]"). iIntros (v) "[Hstl _]". - destruct v; wp_pures. - - by iApply "Hb1". - - by iApply "Hb2". + destruct v. + - wp_pures. iApply ("HΦ'"). eauto with iFrame. + - wp_pures. iApply ("HΦ'"). eauto with iFrame. Qed. End branching_specs. \ No newline at end of file diff --git a/theories/examples/branching_proofs.v b/theories/examples/branching_proofs.v index 21fb687f599debf7a40312dc8c882e038112a672..a7cadc1c51158bbf47b14be8857790f404a87128 100644 --- a/theories/examples/branching_proofs.v +++ b/theories/examples/branching_proofs.v @@ -28,9 +28,11 @@ Section BranchingExampleProofs. wp_pures. wp_apply (wp_fork with "[Hstr]"). - iNext. - wp_apply (branch_st_spec N with "Hstr"); - iIntros "Hstr". - + wp_apply (send_st_spec N Z with "[$Hstr //]"); + simpl. + wp_apply (branch_st_spec with "Hstr")=> //; + iIntros (v) "[Hstr | Hstr]"; iDestruct "Hstr" as (->) "Hstr". + + wp_pures. + wp_apply (send_st_spec N Z with "[$Hstr //]"). iIntros "Hstr". done. + wp_pures. done. - destruct b.