Commit 917d7705 authored by Ralf Jung's avatar Ralf Jung

bump Iris for CmpXchg change, and port everyting

parent 4223390a
...@@ -9,6 +9,6 @@ build: [make "-j%{jobs}%"] ...@@ -9,6 +9,6 @@ build: [make "-j%{jobs}%"]
install: [make "install"] install: [make "install"]
remove: ["rm" "-rf" "%{lib}%/coq/user-contrib/iris_examples"] remove: ["rm" "-rf" "%{lib}%/coq/user-contrib/iris_examples"]
depends: [ depends: [
"coq-iris" { (= "dev.2019-06-20.3.4f0c1046") | (= "dev") } "coq-iris" { (= "dev.2019-06-24.3.5ef58527") | (= "dev") }
"coq-autosubst" { = "dev.coq86" } "coq-autosubst" { = "dev.coq86" }
] ]
...@@ -111,23 +111,23 @@ Section stacks. ...@@ -111,23 +111,23 @@ Section stacks.
wp_load. wp_load.
iMod ("Hclose" with "[Hl Hlist]") as "_". iMod ("Hclose" with "[Hl Hlist]") as "_".
{ iNext; iExists _, _; by iFrame. } { iNext; iExists _, _; by iFrame. }
iModIntro. wp_let. wp_alloc ' as "Hl'". wp_pures. wp_bind (CAS _ _ _). iModIntro. wp_let. wp_alloc ' as "Hl'". wp_pures. wp_bind (CmpXchg _ _ _).
iInv N as ('' v'') "(>% & >Hl & Hlist)" "Hclose"; simplify_eq. iInv N as ('' v'') "(>% & >Hl & Hlist)" "Hclose"; simplify_eq.
destruct (decide (v' = v'')) as [->|Hne]. destruct (decide (v' = v'')) as [->|Hne].
- wp_cas_suc. { destruct v''; left; done. } - wp_cmpxchg_suc. { destruct v''; left; done. }
iMod ("Hclose" with "[HP Hl Hl' Hlist]") as "_". iMod ("Hclose" with "[HP Hl Hl' Hlist]") as "_".
{ iNext; iExists _, (Some '); iFrame; iSplit; first done; { iNext; iExists _, (Some '); iFrame; iSplit; first done;
rewrite (is_list_unfold _ (Some _)). iExists _, _; iFrame; eauto. } rewrite (is_list_unfold _ (Some _)). iExists _, _; iFrame; eauto. }
iModIntro. iModIntro.
wp_if. wp_pures.
by iApply "HΦ". by iApply "HΦ".
- wp_cas_fail. - wp_cmpxchg_fail.
{ destruct v', v''; simpl; congruence. } { destruct v', v''; simpl; congruence. }
{ destruct v''; left; done. } { destruct v''; left; done. }
iMod ("Hclose" with "[Hl Hlist]") as "_". iMod ("Hclose" with "[Hl Hlist]") as "_".
{ iNext; iExists _, _; by iFrame. } { iNext; iExists _, _; by iFrame. }
iModIntro. iModIntro.
wp_if. wp_pures.
iApply ("IH" with "HP HΦ"). iApply ("IH" with "HP HΦ").
Qed. Qed.
...@@ -153,25 +153,25 @@ Section stacks. ...@@ -153,25 +153,25 @@ Section stacks.
iMod ("Hclose" with "[Hl' Hlist]") as "_". iMod ("Hclose" with "[Hl' Hlist]") as "_".
{ iNext; iExists _, _; by iFrame. } { iNext; iExists _, _; by iFrame. }
iModIntro. iModIntro.
wp_pures. wp_bind (CAS _ _ _). wp_pures. wp_bind (CmpXchg _ _ _).
iInv N as ('' v'') "(>% & Hl' & Hlist)" "Hclose". simplify_eq. iInv N as ('' v'') "(>% & Hl' & Hlist)" "Hclose". simplify_eq.
destruct (decide (v'' = (Some l))) as [-> |]. destruct (decide (v'' = (Some l))) as [-> |].
* rewrite is_list_unfold. * rewrite is_list_unfold.
iDestruct "Hlist" as (h' t') "(Hl'' & HP & Hlist)". iDestruct "Hlist" as (h' t') "(Hl'' & HP & Hlist)".
iDestruct "Hl''" as (q') "Hl''". iDestruct "Hl''" as (q') "Hl''".
simpl. simpl.
wp_cas_suc. wp_cmpxchg_suc.
iDestruct (mapsto_agree with "Hl'' Hl") as %[= <- <-%oloc_to_val_inj]. iDestruct (mapsto_agree with "Hl'' Hl") as %[= <- <-%oloc_to_val_inj].
iMod ("Hclose" with "[Hl' Hlist]") as "_". iMod ("Hclose" with "[Hl' Hlist]") as "_".
{ iNext; iExists '', _; by iFrame. } { iNext; iExists '', _; by iFrame. }
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply ("HΦ" with "[HP]"); iRight; iExists _; by iFrame. iApply ("HΦ" with "[HP]"); iRight; iExists _; by iFrame.
* wp_cas_fail. { destruct v''; simpl; congruence. } * wp_cmpxchg_fail. { destruct v''; simpl; congruence. }
iMod ("Hclose" with "[Hl' Hlist]") as "_". iMod ("Hclose" with "[Hl' Hlist]") as "_".
{ iNext; iExists '', _; by iFrame. } { iNext; iExists '', _; by iFrame. }
iModIntro. iModIntro.
wp_if. wp_pures.
iApply ("IH" with "HΦ"). iApply ("IH" with "HΦ").
Qed. Qed.
End stacks. End stacks.
......
...@@ -97,22 +97,22 @@ Section side_channel. ...@@ -97,22 +97,22 @@ Section side_channel.
{{{ v', RET v'; ( v'' : val, v' = InjRV v'' P v'') v' = InjLV #() }}}. {{{ v', RET v'; ( v'' : val, v' = InjRV v'' P v'') v' = InjLV #() }}}.
Proof. Proof.
iIntros (Φ) "[Hinv Hγ] HΦ". iDestruct "Hinv" as (v' l) "[-> #Hinv]". iIntros (Φ) "[Hinv Hγ] HΦ". iDestruct "Hinv" as (v' l) "[-> #Hinv]".
wp_lam. wp_bind (CAS _ _ _). wp_pures. wp_lam. wp_bind (CmpXchg _ _ _). wp_pures.
iInv N as "Hstages" "Hclose". iInv N as "Hstages" "Hclose".
iDestruct "Hstages" as "[[Hl HP] | [H | [Hl H]]]". iDestruct "Hstages" as "[[Hl HP] | [H | [Hl H]]]".
- wp_cas_suc. - wp_cmpxchg_suc.
iMod ("Hclose" with "[Hl Hγ]") as "_". iMod ("Hclose" with "[Hl Hγ]") as "_".
{ iRight; iRight; iFrame. } { iRight; iRight; iFrame. }
iModIntro. iModIntro.
wp_pures. wp_pures.
by iApply "HΦ"; iLeft; iExists _; iSplit. by iApply "HΦ"; iLeft; iExists _; iSplit.
- wp_cas_fail. - wp_cmpxchg_fail.
iMod ("Hclose" with "[H]") as "_". iMod ("Hclose" with "[H]") as "_".
{ iRight; iLeft; auto. } { iRight; iLeft; auto. }
iModIntro. iModIntro.
wp_pures. wp_pures.
by iApply "HΦ"; iRight. by iApply "HΦ"; iRight.
- wp_cas_fail. - wp_cmpxchg_fail.
iDestruct (own_valid_2 with "H Hγ") as %[]. iDestruct (own_valid_2 with "H Hγ") as %[].
Qed. Qed.
...@@ -123,22 +123,22 @@ Section side_channel. ...@@ -123,22 +123,22 @@ Section side_channel.
{{{ v', RET v'; ( v'' : val, v' = InjRV v'' P v'') v' = InjLV #() }}}. {{{ v', RET v'; ( v'' : val, v' = InjRV v'' P v'') v' = InjLV #() }}}.
Proof. Proof.
iIntros (Φ) "H HΦ"; iDestruct "H" as (v l) "[-> #Hinv]". iIntros (Φ) "H HΦ"; iDestruct "H" as (v l) "[-> #Hinv]".
wp_lam. wp_proj. wp_bind (CAS _ _ _). wp_lam. wp_proj. wp_bind (CmpXchg _ _ _).
iInv N as "Hstages" "Hclose". iInv N as "Hstages" "Hclose".
iDestruct "Hstages" as "[[H HP] | [H | [Hl Hγ]]]". iDestruct "Hstages" as "[[H HP] | [H | [Hl Hγ]]]".
- wp_cas_suc. - wp_cmpxchg_suc.
iMod ("Hclose" with "[H]") as "_". iMod ("Hclose" with "[H]") as "_".
{ by iRight; iLeft. } { by iRight; iLeft. }
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply "HΦ"; iLeft; auto. iApply "HΦ"; iLeft; auto.
- wp_cas_fail. - wp_cmpxchg_fail.
iMod ("Hclose" with "[H]") as "_". iMod ("Hclose" with "[H]") as "_".
{ by iRight; iLeft. } { by iRight; iLeft. }
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply "HΦ"; auto. iApply "HΦ"; auto.
- wp_cas_fail. - wp_cmpxchg_fail.
iMod ("Hclose" with "[Hl Hγ]"). iMod ("Hclose" with "[Hl Hγ]").
{ iRight; iRight; iFrame. } { iRight; iRight; iFrame. }
iModIntro. iModIntro.
...@@ -326,23 +326,23 @@ Section stack_works. ...@@ -326,23 +326,23 @@ Section stack_works.
iMod ("Hclose" with "[Hl Hlist]") as "_". iMod ("Hclose" with "[Hl Hlist]") as "_".
{ iNext; iExists _; iFrame. } { iNext; iExists _; iFrame. }
iModIntro. iModIntro.
wp_let. wp_alloc l' as "Hl'". wp_pures. wp_bind (CAS _ _ _). wp_let. wp_alloc l' as "Hl'". wp_pures. wp_bind (CmpXchg _ _ _).
iInv N as (list) "(Hl & Hlist)" "Hclose". iInv N as (list) "(Hl & Hlist)" "Hclose".
destruct (decide (v'' = list)) as [ -> |]. destruct (decide (v'' = list)) as [ -> |].
* wp_cas_suc. { destruct list; left; done. } * wp_cmpxchg_suc. { destruct list; left; done. }
iMod ("Hclose" with "[HP Hl Hl' Hlist]") as "_". iMod ("Hclose" with "[HP Hl Hl' Hlist]") as "_".
{ iNext; iExists (Some _); iFrame. { iNext; iExists (Some _); iFrame.
rewrite (is_list_unfold _ (Some _)). iExists _, _; iFrame; eauto. } rewrite (is_list_unfold _ (Some _)). iExists _, _; iFrame; eauto. }
iModIntro. iModIntro.
wp_if. wp_pures.
by iApply "HΦ". by iApply "HΦ".
* wp_cas_fail. * wp_cmpxchg_fail.
{ destruct list, v''; simpl; congruence. } { destruct list, v''; simpl; congruence. }
{ destruct list; left; done. } { destruct list; left; done. }
iMod ("Hclose" with "[Hl Hlist]") as "_". iMod ("Hclose" with "[Hl Hlist]") as "_".
{ iNext; iExists _; by iFrame. } { iNext; iExists _; by iFrame. }
iModIntro. iModIntro.
wp_if. wp_pures.
iApply ("IH" with "HP HΦ"). iApply ("IH" with "HP HΦ").
- wp_match. - wp_match.
by iApply "HΦ". by iApply "HΦ".
...@@ -373,24 +373,24 @@ Section stack_works. ...@@ -373,24 +373,24 @@ Section stack_works.
iMod ("Hclose" with "[Hl Hlist]") as "_". iMod ("Hclose" with "[Hl Hlist]") as "_".
{ iNext; iExists _; by iFrame. } { iNext; iExists _; by iFrame. }
iModIntro. iModIntro.
wp_let. wp_proj. wp_bind (CAS _ _ _). wp_pures. wp_let. wp_proj. wp_bind (CmpXchg _ _ _). wp_pures.
iInv N as (v'') "[Hl Hlist]" "Hclose". iInv N as (v'') "[Hl Hlist]" "Hclose".
destruct (decide (v'' = Some list)) as [-> |]. destruct (decide (v'' = Some list)) as [-> |].
+ rewrite is_list_unfold. + rewrite is_list_unfold.
iDestruct "Hlist" as (h' t') "(Hl'' & HP & Hlist)". iDestruct "Hlist" as (h' t') "(Hl'' & HP & Hlist)".
iDestruct "Hl''" as (q') "Hl''". iDestruct "Hl''" as (q') "Hl''".
wp_cas_suc. wp_cmpxchg_suc.
iDestruct (mapsto_agree with "Hl'' Hl'") as "%"; simplify_eq. iDestruct (mapsto_agree with "Hl'' Hl'") as "%"; simplify_eq.
iMod ("Hclose" with "[Hl Hlist]") as "_". iMod ("Hclose" with "[Hl Hlist]") as "_".
{ iNext; iExists _; by iFrame. } { iNext; iExists _; by iFrame. }
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply ("HΦ" with "[HP]"); iRight; iExists _; by iFrame. iApply ("HΦ" with "[HP]"); iRight; iExists _; by iFrame.
+ wp_cas_fail. { destruct v''; simpl; congruence. } + wp_cmpxchg_fail. { destruct v''; simpl; congruence. }
iMod ("Hclose" with "[Hl Hlist]") as "_". iMod ("Hclose" with "[Hl Hlist]") as "_".
{ iNext; iExists _; by iFrame. } { iNext; iExists _; by iFrame. }
iModIntro. iModIntro.
wp_if. wp_pures.
iApply ("IH" with "HΦ"). iApply ("IH" with "HΦ").
- iDestruct "HSome" as (v) "[-> HP]". - iDestruct "HSome" as (v) "[-> HP]".
wp_pures. wp_pures.
......
...@@ -118,23 +118,23 @@ Section stack_works. ...@@ -118,23 +118,23 @@ Section stack_works.
{ iNext; iExists _, _; iFrame. } { iNext; iExists _, _; iFrame. }
clear xs. clear xs.
iModIntro. iModIntro.
wp_let. wp_alloc l' as "Hl'". wp_pures. wp_bind (CAS _ _ _). wp_let. wp_alloc l' as "Hl'". wp_pures. wp_bind (CmpXchg _ _ _).
iInv N as (list' xs) "(Hl & Hlist & HP)" "Hclose". iInv N as (list' xs) "(Hl & Hlist & HP)" "Hclose".
destruct (decide (list = list')) as [ -> |]. destruct (decide (list = list')) as [ -> |].
- wp_cas_suc. { destruct list'; left; done. } - wp_cmpxchg_suc. { destruct list'; left; done. }
iMod ("Hupd" with "HP") as "[HP HΨ]". iMod ("Hupd" with "HP") as "[HP HΨ]".
iMod ("Hclose" with "[Hl Hl' HP Hlist]") as "_". iMod ("Hclose" with "[Hl Hl' HP Hlist]") as "_".
{ iNext; iExists (Some _), (v :: xs); iFrame; iExists _; iFrame; auto. } { iNext; iExists (Some _), (v :: xs); iFrame; iExists _; iFrame; auto. }
iModIntro. iModIntro.
wp_if. wp_pures.
by iApply ("HΦ" with "HΨ"). by iApply ("HΦ" with "HΨ").
- wp_cas_fail. - wp_cmpxchg_fail.
{ destruct list, list'; simpl; congruence. } { destruct list, list'; simpl; congruence. }
{ destruct list'; left; done. } { destruct list'; left; done. }
iMod ("Hclose" with "[Hl HP Hlist]"). iMod ("Hclose" with "[Hl HP Hlist]").
{ iExists _, _; iFrame. } { iExists _, _; iFrame. }
iModIntro. iModIntro.
wp_if. wp_pures.
iApply ("IH" with "Hupd HΦ"). iApply ("IH" with "Hupd HΦ").
Qed. Qed.
...@@ -172,10 +172,10 @@ Section stack_works. ...@@ -172,10 +172,10 @@ Section stack_works.
iMod ("Hclose" with "[Hlist Hl HP]") as "_". iMod ("Hclose" with "[Hlist Hl HP]") as "_".
{ iNext; iExists _, _; iFrame. } { iNext; iExists _, _; iFrame. }
iModIntro. iModIntro.
wp_let. wp_proj. wp_bind (CAS _ _ _). wp_pures. wp_let. wp_proj. wp_bind (CmpXchg _ _ _). wp_pures.
iInv N as (v' xs'') "(Hl & Hlist & HP)" "Hclose". iInv N as (v' xs'') "(Hl & Hlist & HP)" "Hclose".
destruct (decide (v' = (Some l'))) as [ -> |]. destruct (decide (v' = (Some l'))) as [ -> |].
* wp_cas_suc. * wp_cmpxchg_suc.
iDestruct (is_list_cons with "[Hl'] Hlist") as (ys) "%"; first by iExists _. iDestruct (is_list_cons with "[Hl'] Hlist") as (ys) "%"; first by iExists _.
simplify_eq. simplify_eq.
iDestruct "Hupd" as "[Hupdcons _]". iDestruct "Hupd" as "[Hupdcons _]".
...@@ -188,11 +188,11 @@ Section stack_works. ...@@ -188,11 +188,11 @@ Section stack_works.
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply ("HΦ" with "HΨ"). iApply ("HΦ" with "HΨ").
* wp_cas_fail. { destruct v'; simpl; congruence. } * wp_cmpxchg_fail. { destruct v'; simpl; congruence. }
iMod ("Hclose" with "[Hlist Hl HP]") as "_". iMod ("Hclose" with "[Hlist Hl HP]") as "_".
{ iNext; iExists _, _; iFrame. } { iNext; iExists _, _; iFrame. }
iModIntro. iModIntro.
wp_if. wp_pures.
iApply ("IH" with "Hupd HΦ"). iApply ("IH" with "Hupd HΦ").
Qed. Qed.
End stack_works. End stack_works.
......
...@@ -119,24 +119,24 @@ Section proofs. ...@@ -119,24 +119,24 @@ Section proofs.
{{{ v', RET v'; ( v'' : val, v' = InjRV v'' can_push P Q v'') (v' = InjLV #() (Q #())) }}}. {{{ v', RET v'; ( v'' : val, v' = InjRV v'' can_push P Q v'') (v' = InjLV #() (Q #())) }}}.
Proof. Proof.
iIntros (Φ) "[Hinv Hγ] HΦ". iDestruct "Hinv" as (v' l) "[-> #Hinv]". iIntros (Φ) "[Hinv Hγ] HΦ". iDestruct "Hinv" as (v' l) "[-> #Hinv]".
wp_lam. wp_pures. wp_bind (CAS _ _ _). wp_lam. wp_pures. wp_bind (CmpXchg _ _ _).
iInv Nside_channel as "Hstages" "Hclose". iInv Nside_channel as "Hstages" "Hclose".
iDestruct "Hstages" as "[[Hl HP] | [[Hl HQ] | [[Hl H] | [Hl H]]]]". iDestruct "Hstages" as "[[Hl HP] | [[Hl HQ] | [[Hl H] | [Hl H]]]]".
- wp_cas_suc. - wp_cmpxchg_suc.
iMod ("Hclose" with "[Hl Hγ]") as "_". iMod ("Hclose" with "[Hl Hγ]") as "_".
{ iNext; iRight; iRight; iFrame. } { iNext; iRight; iRight; iFrame. }
iModIntro. iModIntro.
wp_pures. wp_pures.
by iApply "HΦ"; iLeft; iExists _; iFrame. by iApply "HΦ"; iLeft; iExists _; iFrame.
- wp_cas_fail. - wp_cmpxchg_fail.
iMod ("Hclose" with "[Hl Hγ]") as "_". iMod ("Hclose" with "[Hl Hγ]") as "_".
{ iNext; iRight; iRight; iLeft; iFrame. } { iNext; iRight; iRight; iLeft; iFrame. }
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply ("HΦ" with "[HQ]"); iRight; auto. iApply ("HΦ" with "[HQ]"); iRight; auto.
- wp_cas_fail. - wp_cmpxchg_fail.
iDestruct (own_valid_2 with "H Hγ") as %[]. iDestruct (own_valid_2 with "H Hγ") as %[].
- wp_cas_fail. - wp_cmpxchg_fail.
iDestruct (own_valid_2 with "H Hγ") as %[]. iDestruct (own_valid_2 with "H Hγ") as %[].
Qed. Qed.
...@@ -149,11 +149,11 @@ Section proofs. ...@@ -149,11 +149,11 @@ Section proofs.
( v'' : val, v' = InjRV v'' Ψ v') (v' = InjLV #() (do_pop Q')) }}}. ( v'' : val, v' = InjRV v'' Ψ v') (v' = InjLV #() (do_pop Q')) }}}.
Proof. Proof.
simpl; iIntros (Φ) "[H [Hopener Hupd]] HΦ"; iDestruct "H" as (v l) "[-> #Hinv]". simpl; iIntros (Φ) "[H [Hopener Hupd]] HΦ"; iDestruct "H" as (v l) "[-> #Hinv]".
wp_lam. wp_proj. wp_bind (CAS _ _ _). wp_lam. wp_proj. wp_bind (CmpXchg _ _ _).
iInv Nside_channel as "Hstages" "Hclose". iInv Nside_channel as "Hstages" "Hclose".
iDestruct "Hstages" as "[[Hl Hpush] | [[Hl HQ] | [[Hl Hγ] | [Hl Hγ]]]]". iDestruct "Hstages" as "[[Hl Hpush] | [[Hl HQ] | [[Hl Hγ] | [Hl Hγ]]]]".
- iMod "Hopener" as (xs) "[HP Hcloser]". - iMod "Hopener" as (xs) "[HP Hcloser]".
wp_cas_suc. wp_cmpxchg_suc.
iMod ("Hpush" with "HP") as "[HP HQ]". iMod ("Hpush" with "HP") as "[HP HQ]".
iMod ("Hupd" with "HP") as "[HP HΨ]". iMod ("Hupd" with "HP") as "[HP HΨ]".
iMod ("Hcloser" with "HP") as "_". iMod ("Hcloser" with "HP") as "_".
...@@ -162,19 +162,19 @@ Section proofs. ...@@ -162,19 +162,19 @@ Section proofs.
iApply fupd_intro_mask; first done. iApply fupd_intro_mask; first done.
wp_pures. wp_pures.
iApply "HΦ"; iLeft; auto. iApply "HΦ"; iLeft; auto.
- wp_cas_fail. - wp_cmpxchg_fail.
iMod ("Hclose" with "[Hl HQ]") as "_". iMod ("Hclose" with "[Hl HQ]") as "_".
{ iRight; iLeft; iFrame. } { iRight; iLeft; iFrame. }
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply "HΦ"; auto. iApply "HΦ"; auto.
- wp_cas_fail. - wp_cmpxchg_fail.
iMod ("Hclose" with "[Hl Hγ]"). iMod ("Hclose" with "[Hl Hγ]").
{ iRight; iRight; iFrame. } { iRight; iRight; iFrame. }
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply "HΦ"; auto. iApply "HΦ"; auto.
- wp_cas_fail. - wp_cmpxchg_fail.
iMod ("Hclose" with "[Hl Hγ]"). iMod ("Hclose" with "[Hl Hγ]").
{ iRight; iRight; iFrame. } { iRight; iRight; iFrame. }
iModIntro. iModIntro.
...@@ -350,25 +350,25 @@ Section proofs. ...@@ -350,25 +350,25 @@ Section proofs.
{ iNext; iExists _, _; iFrame. } { iNext; iExists _, _; iFrame. }
clear xs. clear xs.
iModIntro. iModIntro.
wp_let. wp_alloc l' as "Hl'". wp_pures. wp_bind (CAS _ _ _). wp_let. wp_alloc l' as "Hl'". wp_pures. wp_bind (CmpXchg _ _ _).
iInv Nstack as (list' xs) "(Hl & Hlist & HP)" "Hclose". iInv Nstack as (list' xs) "(Hl & Hlist & HP)" "Hclose".
destruct (decide (list = list')) as [ -> |]. destruct (decide (list = list')) as [ -> |].
* wp_cas_suc. { destruct list'; left; done. } * wp_cmpxchg_suc. { destruct list'; left; done. }
iMod (fupd_intro_mask' ( Nstack) inner_mask) as "Hupd'"; first solve_ndisj. iMod (fupd_intro_mask' ( Nstack) inner_mask) as "Hupd'"; first solve_ndisj.
iMod ("Hupd" with "HP") as "[HP HΨ]". iMod ("Hupd" with "HP") as "[HP HΨ]".
iMod "Hupd'" as "_". iMod "Hupd'" as "_".
iMod ("Hclose" with "[Hl Hl' HP Hlist]") as "_". iMod ("Hclose" with "[Hl Hl' HP Hlist]") as "_".
{ iNext; iExists (Some _), (v' :: xs); iFrame; iExists _; iFrame; auto. } { iNext; iExists (Some _), (v' :: xs); iFrame; iExists _; iFrame; auto. }
iModIntro. iModIntro.
wp_if. wp_pures.
by iApply ("HΦ" with "HΨ"). by iApply ("HΦ" with "HΨ").
* wp_cas_fail. * wp_cmpxchg_fail.
{ destruct list, list'; simpl; congruence. } { destruct list, list'; simpl; congruence. }
{ destruct list'; left; done. } { destruct list'; left; done. }
iMod ("Hclose" with "[Hl HP Hlist]"). iMod ("Hclose" with "[Hl HP Hlist]").
{ iExists _, _; iFrame. } { iExists _, _; iFrame. }
iModIntro. iModIntro.
wp_if. wp_pures.
iApply ("IH" with "HΦ Hupd"). iApply ("IH" with "HΦ Hupd").
- wp_match. iApply ("HΦ" with "HΨ"). - wp_match. iApply ("HΦ" with "HΨ").
Qed. Qed.
...@@ -426,10 +426,10 @@ Section proofs. ...@@ -426,10 +426,10 @@ Section proofs.
iMod ("Hclose" with "[Hlist Hl HP]") as "_". iMod ("Hclose" with "[Hlist Hl HP]") as "_".
{ iNext; iExists _, _; iFrame. } { iNext; iExists _, _; iFrame. }
iModIntro. iModIntro.
wp_pures. wp_bind (CAS _ _ _). wp_pures. wp_bind (CmpXchg _ _ _).
iInv Nstack as (v' xs'') "(Hl & Hlist & HP)" "Hclose". iInv Nstack as (v' xs'') "(Hl & Hlist & HP)" "Hclose".
destruct (decide (v' = (Some l'))) as [ -> |]. destruct (decide (v' = (Some l'))) as [ -> |].
+ wp_cas_suc. + wp_cmpxchg_suc.
iDestruct (is_list_cons with "[Hl'] Hlist") as (ys) "%"; first by iExists _. iDestruct (is_list_cons with "[Hl'] Hlist") as (ys) "%"; first by iExists _.
simplify_eq. simplify_eq.
iMod (fupd_intro_mask' ( Nstack) inner_mask) as "Hupd'"; first solve_ndisj. iMod (fupd_intro_mask' ( Nstack) inner_mask) as "Hupd'"; first solve_ndisj.
...@@ -444,7 +444,7 @@ Section proofs. ...@@ -444,7 +444,7 @@ Section proofs.
iModIntro. iModIntro.
wp_pures. wp_pures.
iApply ("HΦ" with "HΨ"). iApply ("HΦ" with "HΨ").
+ wp_cas_fail. { destruct v'; simpl; congruence. } + wp_cmpxchg_fail. { destruct v'; simpl; congruence. }
iMod ("Hclose" with "[Hlist Hl HP]") as "_". iMod ("Hclose" with "[Hlist Hl HP]") as "_".
{ iNext; iExists _, _; iFrame. } { iNext; iExists _, _; iFrame. }
iModIntro. iModIntro.
......
...@@ -162,21 +162,21 @@ Section proof. ...@@ -162,21 +162,21 @@ Section proof.
{ iNext. iExists _,_. iFrame. } clear ls. { iNext. iExists _,_. iFrame. } clear ls.
iModIntro. iModIntro.
wp_alloc n as "Hn". wp_alloc n as "Hn".
wp_pures. wp_bind (CAS _ _ _). wp_pures. wp_bind (CmpXchg _ _ _).
iInv N as (o' ls) "[Ho [Hls >Hb]]" "Hcl". iInv N as (o' ls) "[Ho [Hls >Hb]]" "Hcl".
destruct (decide (o = o')) as [->|?]. destruct (decide (o = o')) as [->|?].
- wp_cas_suc. { destruct o'; left; done. } - wp_cmpxchg_suc. { destruct o'; left; done. }
iMod ("Hvs" with "[$Hb $HP]") as "[Hb HQ]". iMod ("Hvs" with "[$Hb $HP]") as "[Hb HQ]".
iMod ("Hcl" with "[Ho Hn Hls Hb]") as "_". iMod ("Hcl" with "[Ho Hn Hls Hb]") as "_".
{ iNext. iExists (Some _),(v::ls). iFrame "Ho Hb". { iNext. iExists (Some _),(v::ls). iFrame "Ho Hb".
simpl. iExists _. iFrame. by iExists 1%Qp. } simpl. iExists _. iFrame. by iExists 1%Qp. }
iModIntro. wp_if_true. by iApply "HΦ". iModIntro. wp_pures. by iApply "HΦ".
- wp_cas_fail. - wp_cmpxchg_fail.
{ destruct o, o'; simpl; congruence. } { destruct o, o'; simpl; congruence. }
{ destruct o'; left; done. } { destruct o'; left; done. }
iMod ("Hcl" with "[Ho Hls Hb]") as "_". iMod ("Hcl" with "[Ho Hls Hb]") as "_".
{ iNext. iExists _,ls. by iFrame "Ho Hb". } { iNext. iExists _,ls. by iFrame "Ho Hb". }
iModIntro. wp_if_false. iModIntro. wp_proj. wp_if.
by iApply ("IH" with "HP [HΦ]"). by iApply ("IH" with "HP [HΦ]").
Qed. Qed.
...@@ -214,11 +214,11 @@ Section proof. ...@@ -214,11 +214,11 @@ Section proof.
iExists _; eauto. by iFrame. } iExists _; eauto. by iFrame. }
iModIntro. repeat wp_pure _. iModIntro. repeat wp_pure _.
iDestruct "Hhd'" as (q) "Hhd". iDestruct "Hhd'" as (q) "Hhd".
wp_load. repeat wp_pure _. wp_load. wp_pures.
wp_bind (CAS _ _ _). wp_bind (CmpXchg _ _ _).
iInv N as (o' ls') "[Ho [Hls >Hb]]" "Hcl". iInv N as (o' ls') "[Ho [Hls >Hb]]" "Hcl".
destruct (decide (o' = (Some hd))) as [->|?]. destruct (decide (o' = (Some hd))) as [->|?].
+ wp_cas_suc. + wp_cmpxchg_suc.
(* The list is still the same *) (* The list is still the same *)
rewrite (is_list_duplicate tl). iDestruct "Hls'" as "[Hls' Htl]". rewrite (is_list_duplicate tl). iDestruct "Hls'" as "[Hls' Htl]".
iAssert (is_list (Some hd) (x::ls)) with "[Hhd Hls']" as "Hls'". iAssert (is_list (Some hd) (x::ls)) with "[Hhd Hls']" as "Hls'".
...@@ -230,10 +230,10 @@ Section proof. ...@@ -230,10 +230,10 @@ Section proof.
iMod ("Hcl" with "[Ho Htl Hb]") as "_". iMod ("Hcl" with "[Ho Htl Hb]") as "_".
{ iNext. iExists _,ls. by iFrame "Ho Hb". } { iNext. iExists _,ls. by iFrame "Ho Hb". }
iModIntro. wp_pures. by iApply "HΦ". iModIntro. wp_pures. by iApply "HΦ".
+ wp_cas_fail. { destruct o'; simpl; congruence. } + wp_cmpxchg_fail. { destruct o'; simpl; congruence. }
iMod ("Hcl" with "[Ho Hls Hb]") as "_". iMod ("Hcl" with "[Ho Hls Hb]") as "_".
{ iNext. iExists _,ls'. by iFrame "Ho Hb". } { iNext. iExists _,ls'. by iFrame "Ho Hb". }
iModIntro. wp_if_false. iModIntro. wp_proj. wp_if.
by iApply ("IH" with "HP [HΦ]"). by iApply ("IH" with "HP [HΦ]").
Qed. Qed.
End proof. End proof.
......
...@@ -316,10 +316,10 @@ Section monotone_counter. ...@@ -316,10 +316,10 @@ Section monotone_counter.
{ iNext; iExists m; iFrame. } { iNext; iExists m; iFrame. }
iModIntro. iModIntro.
wp_let; wp_op; wp_let. wp_let; wp_op; wp_let.
wp_bind (CAS _ _ _)%E. wp_bind (CmpXchg _ _ _)%E.
iInv N as (k) ">[Hpt HOwnAuth]" "HClose". iInv N as (k) ">[Hpt HOwnAuth]" "HClose".
destruct (decide (k = m)); subst. destruct (decide (k = m)); subst.
+ wp_cas_suc. + wp_cmpxchg_suc.
(* If the CAS succeeds we need to update our ghost state. This is achieved using the own_update rule/lemma. (* If the CAS succeeds we need to update our ghost state. This is achieved using the own_update rule/lemma.
The arguments are the ghost name and the ghost resources x from which and to which we are updating. The arguments are the ghost name and the ghost resources x from which and to which we are updating.