Commit 17a84c8d authored by Amin Timany's avatar Amin Timany

Prove refinement of fine/coarse-grained stack

Squashed commit of the following:

commit a8d2dd620df2fe8531b590811b7f08d2bc1289b4
Author: Amin Timany <amintimany@gmail.com>
Date:   Sun May 29 13:54:07 2016 +0200

    Prove refinement of fine/coarse-grained stack

commit 6347ef920581b4f21b5dfa74d288afcf482c9b50
Author: Amin Timany <amintimany@gmail.com>
Date:   Sun May 29 01:37:23 2016 +0200

    Backup

commit 39552d8055f55458c9515e629707d496e26e92b7
Author: Amin Timany <amintimany@gmail.com>
Date:   Sat May 28 22:40:02 2016 +0200

    Backup
parent 9717179a
......@@ -94,7 +94,7 @@ Section CG_Stack.
(CG_locked_push st l).[f] = CG_locked_push st.[f] l.[f].
Proof. by rewrite with_lock_subst CG_push_subst. Qed.
Lemma steps_CG_locked_increment N E ρ j K st w v l :
Lemma steps_CG_locked_push N E ρ j K st w v l :
nclose N E
((Spec_ctx N ρ st ↦ₛ v l ↦ₛ (v false)
j (fill K (App (CG_locked_push (Loc st) (Loc l)) (# w))))%I)
......@@ -389,6 +389,23 @@ Section CG_Stack.
repeat econstructor.
Qed.
Definition CG_iterV (f : expr) : val :=
LamV (Case (Unfold (Var 1))
Unit
(
App (Lam (App (Var 3) (Snd (Var 2))))
(App f.[ren (+3)] (Fst (Var 0)))
)
).
Lemma CG_iter_to_val f : to_val (CG_iter f) = Some (CG_iterV f).
Proof. trivial. Qed.
Lemma CG_iter_of_val f : of_val (CG_iterV f) = CG_iter f.
Proof. trivial. Qed.
Global Opaque CG_iterV.
Lemma CG_iter_closed (f : expr) :
( g, f.[g] = f) g, (CG_iter f).[g] = CG_iter f.
Proof. intros H g. unfold CG_iter. asimpl. rewrite ?H; trivial. Qed.
......
This diff is collapsed.
......@@ -38,6 +38,19 @@ Section Rules.
rewrite -stackR_self_op; trivial.
Qed.
Lemma stack_mapstos_agree l v w:
(l ↦ˢᵗᵏ v l ↦ˢᵗᵏ w)%I (l ↦ˢᵗᵏ v l ↦ˢᵗᵏ w v = w)%I.
Proof.
iIntros "H".
rewrite -own_op.
iDestruct (own_valid _ with "H !") as "Hvalid".
iDestruct "Hvalid" as %Hvalid.
rewrite own_op. unfold stack_mapsto, auth_own.
iDestruct "H" as "[H1 H2]". iFrame "H1 H2".
specialize (Hvalid l). rewrite lookup_op ?lookup_singleton in Hvalid.
cbv -[decide] in Hvalid; destruct decide; trivial.
Qed.
Program Definition StackLink_pre (Q : bivalC -n> iPropG lang Σ)
{HQ : BiVal_to_IProp_Persistent Q} :
(bivalC -n> iPropG lang Σ) -n> bivalC -n> iPropG lang Σ :=
......@@ -47,10 +60,11 @@ Section Rules.
{|
cofe_mor_car :=
λ v, ( l w, v.1 = LocV l l ↦ˢᵗᵏ w
((w = InjLV UnitV v.2 = InjLV UnitV)
((w = InjLV UnitV
v.2 = FoldV (InjLV UnitV))
( y1 z1 y2 z2,
(w = InjRV (PairV y1 z1))
(v.2 = InjRV (PairV y2 z2))
(w = InjRV (PairV y1 (FoldV z1)))
(v.2 = FoldV (InjRV (PairV y2 z2)))
Q (y1, y2) P(z1, z2)
)
)
......@@ -84,16 +98,17 @@ Section Rules.
Lemma StackLink_unfold Q {HQ} v :
@StackLink Q HQ v
( l w, v.1 = LocV l l ↦ˢᵗᵏ w
((w = InjLV UnitV v.2 = InjLV UnitV)
( y1 z1 y2 z2,
(w = InjRV (PairV y1 z1))
(v.2 = InjRV (PairV y2 z2))
Q (y1, y2)
@StackLink Q HQ (z1, z2)
)
)
)%I.
( l w, v.1 = LocV l l ↦ˢᵗᵏ w
((w = InjLV UnitV
v.2 = FoldV (InjLV UnitV))
( y1 z1 y2 z2,
(w = InjRV (PairV y1 (FoldV z1)))
(v.2 = FoldV (InjRV (PairV y2 z2)))
Q (y1, y2)
@StackLink Q HQ (z1, z2)
)
)
)%I.
Proof.
unfold StackLink at 1.
rewrite fixpoint_unfold; trivial.
......@@ -320,4 +335,20 @@ Section Rules.
unfold stack_owns. by iFrame "Hown Hl' Hall".
Qed.
Lemma stack_owns_open_close h l v :
((stack_owns h l ↦ˢᵗᵏ v)%I)
(l ↦ᵢ v (l ↦ᵢ v - (stack_owns h l ↦ˢᵗᵏ v))%I).
Proof.
iIntros "[Howns Hls]".
iDestruct (stack_owns_open with "[Howns Hls]") as "[Hh [Hm [Hl Hls]]]".
{ by iFrame "Howns Hls". }
iFrame "Hl". iIntros "Hl".
iApply stack_owns_close. by iFrame "Hh Hm Hl Hls".
Qed.
Lemma stack_owns_later_open_close h l v :
(( stack_owns h l ↦ˢᵗᵏ v)%I)
( (l ↦ᵢ v (l ↦ᵢ v - (stack_owns h l ↦ˢᵗᵏ v))))%I.
Proof. iIntros "H". iNext. by iApply stack_owns_open_close. Qed.
End Rules.
\ No newline at end of file
......@@ -32,4 +32,5 @@ F_mu_ref_par/examples/lock.v
F_mu_ref_par/examples/counter.v
F_mu_ref_par/examples/stack/stack_rules.v
F_mu_ref_par/examples/stack/CG_stack.v
F_mu_ref_par/examples/stack/FG_stack.v
\ No newline at end of file
F_mu_ref_par/examples/stack/FG_stack.v
F_mu_ref_par/examples/stack/refinement.v
\ No newline at end of file
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