Commit be63cb7e authored by Dan Frumin's avatar Dan Frumin

The `increment` fn in the counter module returns the previous value

parent bf3aca9a
This diff is collapsed.
......@@ -84,7 +84,7 @@ Section namegen_refinement.
iInv N as (n L) "(HB & Hc & HL)" "Hcl".
iModIntro. iNext. iIntros (l') "Hl'".
rel_rec_r.
rel_apply_r (bin_log_FG_increment_r with "Hc").
rel_apply_r (bin_log_related_FG_increment_r with "Hc").
{ solve_ndisj. }
iIntros "Hc".
rel_seq_r.
......
......@@ -374,24 +374,6 @@ Section refinement.
(c1 ↦ᵢ #(S n) c2 ↦ₛ #n shot γ own γ' (Excl ())))%I.
Program Definition TRV : D := λne _, True%I.
Lemma bin_log_related_FG_increment_r Δ Γ K E1 E2 t τ (x : loc) (n : nat) :
nclose specN E1
(x ↦ₛ # n -
(x ↦ₛ # (S n) -
({E1,E2;Δ;Γ} t log fill K #() : τ)) -
{E1,E2;Δ;Γ} t log fill K ((FG_increment $/ (LitV (Loc x))) #()) : τ)%I.
Proof.
iIntros (?) "Hx Hlog".
unlock FG_increment. simpl_subst/=.
rel_rec_r.
rel_load_r.
rel_rec_r. rel_op_r.
rel_cas_suc_r.
rel_if_r.
by iApply "Hlog".
Qed.
Lemma profiled_g `{oneshotG Σ} `{inG Σ (exclR unitR)} γ γ' c1 c2 g1 g2 Δ Γ :
inv shootN (i6 c1 c2 γ γ') -
τg Δ (g1, g2) -
......
......@@ -52,7 +52,7 @@ Section liftings.
Lemma counter_atomic x E1 E2 Δ Γ :
atomic_logrel
(fun (n : nat) => x ↦ᵢ #n)%I
(fun (n : nat) (v : val) => v = #() x ↦ᵢ #(S n))%I
(fun (n : nat) (v : val) => v = #n x ↦ᵢ #(S n))%I
E2 E1
((FG_increment $/ LitV (Loc x)) #())
Δ Γ.
......@@ -65,8 +65,7 @@ Section liftings.
- iDestruct "Hlog" as "[Hlog _]". done.
- iDestruct "Hlog" as "[_ Hlog]".
iIntros (m) "[Hx HR1] HR2".
iSpecialize ("Hlog" $! m #()). simpl.
iApply "Hlog". by iFrame.
iApply ("Hlog" $! m #m). by iFrame.
Qed.
Lemma lift_atomic_ht {A : Type} (α : A iProp Σ) β Ei Eo e Δ
......@@ -122,7 +121,7 @@ Section liftings.
(* Increment refinement using the log atomic triple *)
Lemma FG_CG_increment_refinement2 l cnt cnt' Γ Δ :
inv counterN (counter_inv l cnt cnt') -
{Δ;Γ} FG_increment $/ LitV (Loc cnt) log CG_increment $/ LitV (Loc cnt') $/ LitV (Loc l) : TArrow TUnit TUnit.
{Δ;Γ} FG_increment $/ LitV (Loc cnt) log CG_increment $/ LitV (Loc cnt') $/ LitV (Loc l) : TArrow TUnit TNat.
Proof.
iIntros "#Hinv".
iApply bin_log_related_arrow_val.
......@@ -134,7 +133,7 @@ Section liftings.
iAlways. iIntros (v v') "[% %]"; simplify_eq/=.
pose (F := (fun (n : nat) => (l ↦ₛ #false) cnt' ↦ₛ #n)%I).
iPoseProof (counter_atomic cnt ( counterN) Δ Γ
$! [] _ TUnit True%I F)
$! [] _ _ True%I F)
as "Hrule /=".
iApply "Hrule". iSplitR; first done. iAlways.
iInv counterN as ">Hcnt" "Hcl". iModIntro.
......@@ -152,8 +151,7 @@ Section liftings.
iMod ("Hcl" with "[-]").
{ iNext. iExists _. iFrame. }
simpl.
by rel_vals.
by iApply bin_log_related_nat.
Qed.
End liftings.
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