Commit 8ca249fb authored by Simon Friis Vindum's avatar Simon Friis Vindum

Use fractional pointers with extensional variable

parent 18fe6f53
......@@ -58,9 +58,43 @@ Section common.
iIntros. iApply (own_update with "[$]"). by apply cmra_update_exclusive.
Qed.
Lemma mapsto_full_to_frac l v : l ↦ᵢ v - l ↦ᵢ{-} v.
Proof. iIntros. by iExists _. Qed.
Lemma mapsto_full_to_frac_2 l v : l ↦ᵢ v - l ↦ᵢ{-} v l ↦ᵢ{-} v.
Proof.
iIntros. iDestruct (mapsto_full_to_frac with "[$]") as "H".
iDestruct (mapsto_frac_duplicable with "H") as "[H1 H2]".
iFrame.
Qed.
Lemma mapsto_full_to_frac_3 l v : l ↦ᵢ v - (l ↦ᵢ{-} v l ↦ᵢ{-} v l ↦ᵢ{-} v).
Proof.
iIntros.
iDestruct (mapsto_full_to_frac_2 with "[$]") as "[H1 H2]".
iDestruct (mapsto_frac_duplicable with "H2") as "[H2 H3]".
iFrame.
Qed.
Lemma mapsto_agree_frac l q v1 v2 : l ↦ᵢ{q} v1 - l ↦ᵢ{-} v2 - v1 = v2.
Proof.
iIntros "P1". iDestruct 1 as (q2) "P2". iApply (mapsto_agree with "P1 P2").
Qed.
Lemma mapsto_agree_frac_frac l v1 v2 : l ↦ᵢ{-} v1 - l ↦ᵢ{-} v2 - v1 = v2.
Proof.
iDestruct 1 as (q1) "P1". iDestruct 1 as (q2) "P2".
iApply (mapsto_agree with "P1 P2").
Qed.
(* Maybe commit this upstream. *)
Lemma mapsto_exclusive l v1 v2 q : l ↦ᵢ v1 - l ↦ᵢ{q} v2 - False.
iIntros "Hl1 Hl2". iDestruct (mapsto_valid_2 with "Hl1 Hl2") as %[]%Qp_not_plus_q_ge_1.
Qed.
Lemma mapsto_exclusive_frac l v1 v2 : l ↦ᵢ v1 - l ↦ᵢ{-} v2 - False.
iIntros "Hl1 Hl2". iDestruct "Hl2" as (q) "Hl2".
iDestruct (mapsto_valid_2 with "Hl1 Hl2") as %[]%Qp_not_plus_q_ge_1.
Qed.
End common.
\ No newline at end of file
......@@ -24,6 +24,7 @@ Global Opaque iris_invG.
Notation "l ↦ᵢ{ q } v" := (mapsto (L:=loc) (V:=val) l q v)
(at level 20, q at level 50, format "l ↦ᵢ{ q } v") : bi_scope.
Notation "l ↦ᵢ v" := (mapsto (L:=loc) (V:=val) l 1 v) (at level 20) : bi_scope.
Notation "l ↦ᵢ{-} v" := ( q, l ↦ᵢ{q} v)%I (at level 20, format "l ↦ᵢ{-} v") : bi_scope.
Section lang_rules.
Context `{heapIG Σ}.
......@@ -74,6 +75,14 @@ Section lang_rules.
iModIntro; iSplit=> //. iFrame. by iApply "HΦ".
Qed.
Lemma wp_load_frac E l v :
{{{ l ↦ᵢ{-} v }}} Load (Loc l) @ E {{{ RET v; l ↦ᵢ{-} v }}}.
Proof.
iIntros (Φ) ">Hl HΦ". iDestruct "Hl" as (q) "Hl".
iApply (wp_load with "Hl"). iNext. iIntros "Hl".
iApply "HΦ". by iExists q.
Qed.
Lemma wp_store E l v' e v :
IntoVal e v
{{{ l ↦ᵢ v' }}} Store (Loc l) e @ E
......@@ -100,6 +109,16 @@ Section lang_rules.
iModIntro; iSplit=> //. iFrame. by iApply "HΦ".
Qed.
Lemma wp_cas_fail_frac E l v' e1 v1 e2 v2 :
IntoVal e1 v1 IntoVal e2 v2 v' v1
{{{ l ↦ᵢ{-} v' }}} CAS (Loc l) e1 e2 @ E
{{{ RET (BoolV false); l ↦ᵢ{-} v' }}}.
Proof.
iIntros (<- <- ? Φ) ">Hl HΦ". iDestruct "Hl" as (q) "Hl".
iApply (wp_cas_fail with "Hl"); first done.
iNext. iIntros "Hl". iApply "HΦ". by iExists q.
Qed.
Lemma wp_cas_suc E l e1 v1 e2 v2 :
IntoVal e1 v1 IntoVal e2 v2
{{{ l ↦ᵢ v1 }}} CAS (Loc l) e1 e2 @ E
......@@ -121,6 +140,12 @@ Section lang_rules.
iNext; iIntros (v2 σ2 efs Hstep); inv_head_step. by iFrame.
Qed.
Lemma mapsto_frac_duplicable l v :
l ↦ᵢ{-} v - l ↦ᵢ{-} v l ↦ᵢ{-} v.
Proof.
iIntros "H"; iDestruct "H" as (?) "[Hl Hl']"; iSplitL "Hl"; eauto.
Qed.
Local Ltac solve_exec_safe := intros; subst; do 3 eexists; econstructor; eauto.
Local Ltac solve_exec_puredet := simpl; intros; by inv_head_step.
Local Ltac solve_pure_exec :=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment