From 94a415f64f1c98ad141f88e3cad1ccf99969b95a Mon Sep 17 00:00:00 2001 From: Hei Li Date: Wed, 23 Oct 2024 14:10:30 +0200 Subject: [PATCH] simple parallel_add_spec' --- theories/coneris/examples/two_die.v | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/theories/coneris/examples/two_die.v b/theories/coneris/examples/two_die.v index c3806f6a..15edb4ce 100644 --- a/theories/coneris/examples/two_die.v +++ b/theories/coneris/examples/two_die.v @@ -326,3 +326,79 @@ Qed. End properties. +Section simple'. + Context `{!conerisGS Σ, !spawnG Σ, !inG Σ ra_stateR}. + + Definition simple_parallel_add_inv' l γ := + (∃ (n:nat), l ↦#n ∗ (own γ Start ∨ own γ Final ∗ ⌜(0(%&?&?)" "Hclose". + wp_load. + iMod ("Hclose" with "[$]") as "_". + iModIntro. wp_pures. + iInv "I" as ">(%&Hl&H)" "Hclose". + wp_store. + iDestruct "H" as "[H|H]". + + iMod (ra_state_bupd with "[$]") as "#H". + iMod ("Hclose" with "[Hl]"); last done. + iExists (n+1)%nat. iNext. + rewrite Nat2Z.inj_add. iFrame. + iRight. iSplit; first done. + iPureIntro. lia. + + iDestruct "H" as "[#H %]". iMod ("Hclose" with "[Hl]"); last done. + iExists (n+1)%nat. iNext. + rewrite Nat2Z.inj_add. iFrame. + iRight. iSplit; first done. + iPureIntro. lia. + - wp_apply (wp_rand); first done. + iIntros (??). + wp_pures. + case_bool_decide. + + wp_pures. + wp_bind (! _)%E. + iInv "I" as ">(%&?&?)" "Hclose". + wp_load. + iMod ("Hclose" with "[$]") as "_". + iModIntro. wp_pures. + iInv "I" as ">(%&Hl&H)" "Hclose". + wp_store. + iMod ("Hclose" with "[Hl H]"); last done. + iExists (_+1)%nat. iNext. + rewrite Nat2Z.inj_add. iFrame. + iDestruct "H" as "[H|[H %]]"; iFrame. + iRight. iFrame. iPureIntro. lia. + + by wp_pures. + - iIntros (??) "[H _]". + iNext. + wp_pures. + iInv "I" as ">(%n&Hl&[H'|[H' %]])" "Hclose". + { iCombine "H H'" gives "%H". by cbv in H. } + wp_load. + iMod ("Hclose" with "[H Hl]") as "_". + + iFrame. iRight. iFrame. by iPureIntro. + + iApply "HΦ". by iPureIntro. + Qed. +End simple'.