Skip to content
Snippets Groups Projects
Commit 62299a95 authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan
Browse files

Simplify incr_2_safe.

parent e5eacdc3
No related branches found
No related tags found
No related merge requests found
...@@ -95,8 +95,7 @@ Section user. ...@@ -95,8 +95,7 @@ Section user.
rewrite /incr_2. rewrite /incr_2.
wp_let. wp_let.
wp_alloc l as "Hl". wp_alloc l as "Hl".
iVs (inv_alloc N _ (x':Z, l #x')%I with "[Hl]") as "#?". iVs (inv_alloc N _ (x':Z, l #x')%I with "[Hl]") as "#?"; first eauto.
{ iNext. by iExists x. }
wp_let. wp_let.
wp_bind (_ || _)%E. wp_bind (_ || _)%E.
iApply (wp_par (λ _, True%I) (λ _, True%I)). iApply (wp_par (λ _, True%I) (λ _, True%I)).
...@@ -104,11 +103,10 @@ Section user. ...@@ -104,11 +103,10 @@ Section user.
(* prove worker triple *) (* prove worker triple *)
iDestruct (incr_atomic_spec N l with "Hh") as "Hincr"=>//. iDestruct (incr_atomic_spec N l with "Hh") as "Hincr"=>//.
rewrite /incr_triple /atomic_triple. rewrite /incr_triple /atomic_triple.
iSpecialize ("Hincr" $! True%I (fun _ _ => True%I) with "[]"). iSpecialize ("Hincr" $! True%I (fun _ _ => True%I) with "[]").
- iIntros "!# _". - iIntros "!# _".
(* open the invariant *) (* open the invariant *)
iInv N as "Hl" "Hclose". iInv N as (x') ">Hl'" "Hclose".
iTimeless "Hl". iDestruct "Hl" as (x') "Hl'".
(* mask magic *) (* mask magic *)
iApply pvs_intro'. iApply pvs_intro'.
{ apply ndisj_subseteq_difference; auto. } { apply ndisj_subseteq_difference; auto. }
...@@ -118,26 +116,16 @@ Section user. ...@@ -118,26 +116,16 @@ Section user.
iSplit. iSplit.
+ (* provide a way to rollback *) + (* provide a way to rollback *)
iIntros "Hl'". iIntros "Hl'".
iApply pvs_trans. iVs "Hvs". iVs ("Hclose" with "[Hl']"); eauto.
(* close invariant *)
iApply "Hclose".
(* do view shifts *)
iVs "Hvs". iVsIntro. iNext. by iExists x'.
+ (* provide a way to commit *) + (* provide a way to commit *)
iIntros (v) "[Heq Hl']". iIntros (v) "[Heq Hl']".
iApply pvs_trans. iVs "Hvs". iVs ("Hclose" with "[Hl']"); eauto.
(* close the invariant *)
iApply "Hclose".
(* do view shifts *)
iVs "Hvs". iVsIntro. iNext. by iExists (x' + 1).
- iDestruct "Hincr" as "#HIncr". - iDestruct "Hincr" as "#HIncr".
iSplitL; [|iSplitL]; try (iApply wp_wand_r;iSplitL; [by iApply "HIncr"|auto]). iSplitL; [|iSplitL]; try (iApply wp_wand_r;iSplitL; [by iApply "HIncr"|auto]).
iIntros (v1 v2) "_ !>". iIntros (v1 v2) "_ !>".
wp_seq. wp_seq.
iInv N as "Hinv" "Hclose". iInv N as (x') ">Hl" "Hclose".
iTimeless "Hinv". iDestruct "Hinv" as (x') "Hl".
wp_load. wp_load.
iApply "Hclose". iApply "Hclose". eauto.
iNext. by iExists x'.
Qed. Qed.
End user. End user.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment