Skip to content
Snippets Groups Projects
Commit 3b6db97b authored by Zhen Zhang's avatar Zhen Zhang
Browse files

doOp tentative

parent 637f31c7
No related branches found
No related tags found
No related merge requests found
...@@ -185,42 +185,52 @@ Section proof. ...@@ -185,42 +185,52 @@ Section proof.
iApply ("HΦ" with "Ho2 Ho3 Hfrag Hx2"). iApply ("HΦ" with "Ho2 Ho3 Hfrag Hx2").
Admitted. Admitted.
Definition doOp_triple (f: val) p γx γ1 γ2 γ3 γ4 Q: iProp Σ := Definition pinv_sub RI γx γ1 γ2 γ3 γ4 p Q := (RI ⊣⊢ Rf, Rf p_inv γx γ1 γ2 γ3 γ4 p Q)%I.
atomic_triple (fun _:() => p_inv γx γ1 γ2 γ3 γ4 p Q (own γ2 (Excl ()) own γ1 (Excl ()))
( x:val, WP f x {{ v, Q x v }}))%I Lemma doOp_spec Φ (f: val) (RI: iProp Σ) γx γ1 γ2 γ3 γ4 p Q `{TimelessP _ RI}:
(fun _ ret => (own γ2 (Excl ()) own γ1 (Excl ())) ret = #() p_inv γx γ1 γ2 γ3 γ4 p Q)%I heapN N pinv_sub RI γx γ1 γ2 γ3 γ4 p Q
(nclose heapN) heap_ctx inv N RI own γ2 (Excl ())
( x:val, WP f x {{ v, Q x v }})%I (own γ2 (Excl ()) - Φ #())
(doOp f #p). WP doOp f #p {{ Φ }}.
Lemma doOp_spec (f: val) p γx γ1 γ2 γ3 γ4 R:
heapN N heap_ctx doOp_triple f p γx γ1 γ2 γ3 γ4 R.
Proof. Proof.
iIntros (HN) "#Hh". rewrite /doOp_triple /atomic_triple. iIntros (HN Hsub) "(#Hh & #HRI & Ho2 & #Hf & HΦ)".
iIntros (P Q) "#Hvs". wp_seq. wp_let. wp_bind (! _)%E.
iIntros "!# HP". wp_rec. iInv N as ">H" "Hclose".
wp_let. wp_bind (! _)%E. iDestruct (Hsub with "H") as (Rf) "[HRf [Hp | [Hp | [Hp | Hp]]]]".
iVs ("Hvs" with "HP") as (xs) "[[Hp [[Ho2 | Ho1] #Hf]] Hvs']". - iDestruct "Hp" as (y) "(Hp & Ho1 & Ho3)".
- rewrite /p_inv. wp_load. iVs ("Hclose" with "[HRf Hp Ho1 Ho3]").
iDestruct "Hp" as "[Hp | [Hp | [Hp | Hp]]]". { iNext. iApply Hsub. iExists Rf. iFrame "HRf".
+ iDestruct "Hp" as (y) "(Hp & Ho1 & Ho3)". iLeft. iExists y. by iFrame. }
wp_load. iDestruct "Hvs'" as "[_ Hvs']". iVsIntro. wp_match. by iApply "HΦ".
iVs ("Hvs'" $! #() with "[-]") as "HQ". - iDestruct "Hp" as (x) "(Hp & Hx & Ho1 & Ho4)".
{ iSplitL "Ho2"; first by iLeft. iSplitR; first auto. iLeft. iExists y. by iFrame. } wp_load.
iVsIntro. wp_match. eauto. iAssert (|=r=> own γx (((1 / 4)%Qp, DecAgree x) ((1 / 4)%Qp, DecAgree x)))%I with "[Hx]" as "==>[Hx1 Hx2]".
+ iDestruct "Hp" as (x) "(Hp & Hx & Ho1 & Ho4)". { iDestruct (own_update with "Hx") as "Hx"; last by iAssumption.
wp_load. replace ((1 / 2)%Qp) with (1/4 + 1/4)%Qp; last by apply Qp_div_S.
iAssert (|=r=> own γx (((1 / 4)%Qp, DecAgree x) ((1 / 4)%Qp, DecAgree x)))%I with "[Hx]" as "==>[Hx1 Hx2]". by apply pair_l_frac_op'. }
{ iDestruct (own_update with "Hx") as "Hx"; last by iAssumption. iVs ("Hclose" with "[HRf Hp Hx1 Ho2 Ho4]").
replace ((1 / 2)%Qp) with (1/4 + 1/4)%Qp; last by apply Qp_div_S. { iNext. iApply Hsub. iExists Rf. iFrame "HRf".
by apply pair_l_frac_op'. } iRight. iRight. iLeft. iExists x. by iFrame. }
iDestruct "Hvs'" as "[Hvs' _]". iVsIntro. wp_match.
iVs ("Hvs'" with "[-]") as "HP". wp_bind (f _). iApply wp_wand_r.
{ iSplitR "Ho1"; last auto. iRight. iRight. iLeft. iExists x. by iFrame. } iSplitR; first by iApply "Hf".
iVsIntro. wp_match. iIntros (y) "%".
iInv N as ">H" "Hclose".
iDestruct (Hsub with "H") as (Rf') "[HRf [Hp | [Hp | [Hp | Hp]]]]".
+ admit.
+ admit.
+ iDestruct "Hp" as (x') "(Hp & Hx & Ho2 & Ho4)".
destruct (decide (x = x')) as [->|Hneq]; last by admit.
\ No newline at end of file iCombine "Hx2" "Hx" as "Hx".
iDestruct (own_update with "Hx") as "==>Hx"; first by apply pair_l_frac_op.
rewrite Qp_div_S.
wp_store. iVs ("Hclose" with "[HRf Hp Hx Ho1 Ho4]").
{ iNext. iApply Hsub. iExists Rf'. iFrame "HRf".
iRight. iRight. iRight. iExists x', y.
by iFrame. }
iVsIntro. by iApply "HΦ".
+ admit.
- admit.
- admit.
Admitted.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment