Commit 740e2a90 authored by Amin Timany's avatar Amin Timany

Update to use new version of iris(6cb76aaa)

parent 26128ad3
From iris_logrel.F_mu Require Export logrel.
From iris.proofmode Require Import tactics.
From iris_logrel.F_mu Require Import rules.
From iris.algebra Require Export upred_big_op.
From iris.base_logic Require Export big_op.
Definition log_typed `{irisG lang Σ} (Γ : list type) (e : expr) (τ : type) := Δ vs,
env_PersistentP Δ
......
From iris.proofmode Require Import tactics.
From iris.program_logic Require Export weakestpre.
From iris_logrel.F_mu Require Export lang typing.
From iris.algebra Require Import list upred_big_op.
From iris.algebra Require Import list.
From iris.base_logic Require Import big_op.
Import uPred.
(** interp : is a unary logical relation. *)
......@@ -71,7 +72,7 @@ Section logrel.
Definition interp_env (Γ : list type)
(Δ : listC D) (vs : list val) : iProp Σ :=
(length Γ = length vs [] zip_with (λ τ, τ Δ) Γ vs)%I.
(length Γ = length vs [] zip_with (λ τ, τ Δ) Γ vs)%I.
Notation "⟦ Γ ⟧*" := (interp_env Γ).
Definition interp_expr (τ : type) (Δ : listC D) (e : expr) : iProp Σ :=
......@@ -145,7 +146,7 @@ Section logrel.
iIntros (?) "[Hlen HΓ]"; iDestruct "Hlen" as %Hlen.
destruct (lookup_lt_is_Some_2 vs x) as [v Hv].
{ by rewrite -Hlen; apply lookup_lt_Some with τ. }
iExists v; iSplit. done. iApply (big_and_elem_of with "HΓ").
iExists v; iSplit. done. iApply (big_sep_elem_of with "HΓ").
apply elem_of_list_lookup_2 with x.
rewrite lookup_zip_with; by simplify_option_eq.
Qed.
......@@ -153,18 +154,18 @@ Section logrel.
Lemma interp_env_nil Δ : True [] * Δ [].
Proof. iIntros ""; iSplit; auto. Qed.
Lemma interp_env_cons Δ Γ vs τ v :
τ :: Γ * Δ (v :: vs) ⊣⊢ τ Δ v Γ * Δ vs.
τ :: Γ * Δ (v :: vs) ⊣⊢ τ Δ v Γ * Δ vs.
Proof.
rewrite /interp_env /= (assoc _ ( _ _ _)) -(comm _ (_ = _)%I) -assoc.
by apply and_proper; [apply pure_proper; omega|].
by apply sep_proper; [apply pure_proper; omega|].
Qed.
Lemma interp_env_ren Δ (Γ : list type) (vs : list val) τi :
subst (ren (+1)) <$> Γ * (τi :: Δ) vs ⊣⊢ Γ * Δ vs.
Proof.
apply and_proper; [apply pure_proper; by rewrite fmap_length|].
apply sep_proper; [apply pure_proper; by rewrite fmap_length|].
revert Δ vs τi; induction Γ=> Δ [|v vs] τi; csimpl; auto.
apply and_proper; auto. apply (interp_weaken [] [τi] Δ).
apply sep_proper; auto. apply (interp_weaken [] [τi] Δ).
Qed.
End logrel.
......
......@@ -48,7 +48,7 @@ Section lang_rules.
Proof.
intros <-%of_to_val.
rewrite -(wp_lift_pure_det_head_step' (Unfold _) (of_val v))
-?wp_value_pvs; eauto.
-?wp_value_fupd; eauto.
intros; inv_head_step; eauto.
Qed.
......@@ -57,7 +57,7 @@ Section lang_rules.
(|={E}=> Φ v1) WP Fst (Pair e1 e2) @ E {{ Φ }}.
Proof.
intros ??. rewrite -(wp_lift_pure_det_head_step' (Fst _) e1)
-?wp_value_pvs; eauto.
-?wp_value_fupd; eauto.
intros; inv_head_step; eauto.
Qed.
......@@ -66,7 +66,7 @@ Section lang_rules.
(|={E}=> Φ v2) WP Snd (Pair e1 e2) @ E {{ Φ }}.
Proof.
intros ??. rewrite -(wp_lift_pure_det_head_step' (Snd _) e2)
-?wp_value_pvs; eauto.
-?wp_value_fupd; eauto.
intros; inv_head_step; eauto.
Qed.
......
......@@ -17,6 +17,6 @@ Corollary type_soundness e τ e' thp σ σ' :
rtc step ([e], σ) (thp, σ') e' thp
is_Some (to_val e') reducible e' σ'.
Proof.
intros ??. set (Σ := #[irisΣ lang]).
intros ??. set (Σ := #[irisΣ state]).
eapply (soundness Σ); eauto using fundamental.
Qed.
From iris_logrel.F_mu_ref Require Export logrel.
From iris.proofmode Require Import tactics pviewshifts invariants.
From iris.proofmode Require Import tactics.
From iris_logrel.F_mu_ref Require Import rules.
From iris.algebra Require Export upred_big_op.
From iris.base_logic Require Export big_op.
Definition log_typed `{heapG Σ} (Γ : list type) (e : expr) (τ : type) := Δ vs,
env_PersistentP Δ
......@@ -85,25 +85,27 @@ Section fundamental.
change (fixpoint _) with (interp (TRec τ) Δ); simpl.
iDestruct "Hv" as (w) "#[% Hw]"; subst.
iApply wp_fold; cbn; auto using to_of_val.
iNext; iVsIntro. by rewrite -interp_subst.
iNext; iModIntro. by rewrite -interp_subst.
- (* Alloc *)
smart_wp_bind AllocCtx v "#Hv" IHtyped; cbn. iClear "HΓ".
iApply wp_alloc; auto 1 using to_of_val.
iIntros "{$Hheap} !>"; iIntros (l) "Hl".
iVs (inv_alloc _ with "[Hl]") as "HN";
[| iVsIntro; iExists _; iSplit; trivial]; eauto.
smart_wp_bind AllocCtx v "#Hv" IHtyped; cbn. iClear "HΓ". iApply wp_fupd.
iApply (wp_alloc with "Hheap []"); auto 1 using to_of_val.
iNext; iIntros (l) "Hl".
iMod (inv_alloc _ with "[Hl]") as "HN";
[| iModIntro; iExists _; iSplit; trivial]; eauto.
- (* Load *)
smart_wp_bind LoadCtx v "#Hv" IHtyped; cbn. iClear "HΓ".
iDestruct "Hv" as (l) "[% #Hv]"; subst.
iInv (logN .@ l) as (w) "[Hw1 #Hw2]" "Hclose".
iApply (wp_load _ _ 1); [|iFrame "Hheap"]; trivial. solve_ndisj.
iIntros "{$Hw1} !> Hw1 !==>". iVs ("Hclose" with "[-]"); eauto.
iApply ((wp_load _ _ 1) with "[Hw1] [Hclose]"); [|iFrame "Hheap"|];
trivial. solve_ndisj. iNext.
iIntros "Hw1". iMod ("Hclose" with "[-]"); eauto.
- (* Store *)
smart_wp_bind (StoreLCtx _) v "#Hv" IHtyped1; cbn.
smart_wp_bind (StoreRCtx _) w "#Hw" IHtyped2; cbn. iClear "HΓ".
iDestruct "Hv" as (l) "[% #Hv]"; subst.
iInv (logN .@ l) as (z) "[Hz1 #Hz2]" "Hclose".
iApply wp_store. by rewrite to_of_val. solve_ndisj.
iIntros "{$Hheap $Hz1} !> Hz1 !==>". iVs ("Hclose" with "[-]"); eauto.
iApply (wp_store with "[Hz1] [Hclose]"); [| |iFrame "Hheap Hz1"|].
by rewrite to_of_val. solve_ndisj. iNext.
iIntros "Hz1". iMod ("Hclose" with "[-]"); eauto.
Qed.
End fundamental.
From iris.proofmode Require Import tactics.
From iris.program_logic Require Export weakestpre.
From iris_logrel.F_mu_ref Require Export rules typing.
From iris.algebra Require Import list upred_big_op.
From iris.algebra Require Import list.
From iris.base_logic Require Import big_op.
Import uPred.
Definition logN : namespace := nroot .@ "logN".
......@@ -83,7 +84,7 @@ Section logrel.
Definition interp_env (Γ : list type)
(Δ : listC D) (vs : list val) : iProp Σ :=
(length Γ = length vs [] zip_with (λ τ, τ Δ) Γ vs)%I.
(length Γ = length vs [] zip_with (λ τ, τ Δ) Γ vs)%I.
Notation "⟦ Γ ⟧*" := (interp_env Γ).
Definition interp_expr (τ : type) (Δ : listC D) (e : expr) : iProp Σ :=
......@@ -159,7 +160,7 @@ Section logrel.
iIntros (?) "[Hlen HΓ]"; iDestruct "Hlen" as %Hlen.
destruct (lookup_lt_is_Some_2 vs x) as [v Hv].
{ by rewrite -Hlen; apply lookup_lt_Some with τ. }
iExists v; iSplit. done. iApply (big_and_elem_of with "HΓ").
iExists v; iSplit. done. iApply (big_sep_elem_of with "HΓ").
apply elem_of_list_lookup_2 with x.
rewrite lookup_zip_with; by simplify_option_eq.
Qed.
......@@ -167,18 +168,18 @@ Section logrel.
Lemma interp_env_nil Δ : True [] * Δ [].
Proof. iIntros ""; iSplit; auto. Qed.
Lemma interp_env_cons Δ Γ vs τ v :
τ :: Γ * Δ (v :: vs) ⊣⊢ τ Δ v Γ * Δ vs.
τ :: Γ * Δ (v :: vs) ⊣⊢ τ Δ v Γ * Δ vs.
Proof.
rewrite /interp_env /= (assoc _ ( _ _ _)) -(comm _ (_ = _)%I) -assoc.
by apply and_proper; [apply pure_proper; omega|].
by apply sep_proper; [apply pure_proper; omega|].
Qed.
Lemma interp_env_ren Δ (Γ : list type) (vs : list val) τi :
subst (ren (+1)) <$> Γ * (τi :: Δ) vs ⊣⊢ Γ * Δ vs.
Proof.
apply and_proper; [apply pure_proper; by rewrite fmap_length|].
apply sep_proper; [apply pure_proper; by rewrite fmap_length|].
revert Δ vs τi; induction Γ=> Δ [|v vs] τi; csimpl; auto.
apply and_proper; auto. apply (interp_weaken [] [τi] Δ).
apply sep_proper; auto. apply (interp_weaken [] [τi] Δ).
Qed.
End logrel.
......
This diff is collapsed.
From iris_logrel.F_mu_ref Require Export fundamental.
From iris.proofmode Require Import tactics pviewshifts.
From iris.program_logic Require Import ownership adequacy auth.
From iris.proofmode Require Import tactics.
From iris.program_logic Require Import adequacy.
From iris.base_logic Require Import auth.
Theorem soundness Σ `{irisPreG lang Σ, authG Σ heapUR} e τ e' thp σ σ' :
Theorem soundness Σ `{irisPreG lang Σ, HAG: authG Σ heapUR} e τ e' thp σ σ' :
( `{heapG Σ}, log_typed [] e τ)
rtc step ([e], σ) (thp, σ') e' thp
is_Some (to_val e') reducible e' σ'.
Proof.
intros Hlog ??. cut (adequate e σ (λ _, True)); first (intros [_ ?]; eauto).
eapply (wp_adequacy Σ); iIntros (?) "Hσ". rewrite -(empty_env_subst e).
iVs (auth_alloc (ownP of_heap) heapN _ (to_heap σ) with "[Hσ]") as (γ) "[??]".
iMod (auth_alloc to_heap ownP heapN _ σ with "[Hσ]") as (γ) "[??]".
- auto using to_heap_valid.
- rewrite /= (from_to_heap σ); auto.
- by iNext.
- iApply wp_wand_l; iSplitR; [|iApply (Hlog (HeapG _ _ _ γ))]; eauto.
iSplit. by rewrite /heap_ctx. iApply (@interp_env_nil _ (HeapG _ _ _ γ)).
Qed.
......@@ -21,6 +22,6 @@ Corollary type_soundness e τ e' thp σ σ' :
rtc step ([e], σ) (thp, σ') e' thp
is_Some (to_val e') reducible e' σ'.
Proof.
intros ??. set (Σ := #[irisΣ lang ; authΣ heapUR ]).
intros ??. set (Σ := #[irisΣ state ; authΣ heapUR ]).
eapply (soundness Σ); eauto using fundamental.
Qed.
From iris.proofmode Require Import invariants ghost_ownership tactics.
From iris.proofmode Require Import tactics.
From iris_logrel.F_mu_ref_conc Require Export examples.lock.
From iris_logrel.F_mu_ref_conc Require Import soundness_binary.
From iris.program_logic Require Import adequacy.
Definition CG_increment (x : expr) : expr :=
Rec (Store x.[ren (+ 2)] (BinOp Add (#n 1) (Load x.[ren (+ 2)]))).
......@@ -60,23 +61,23 @@ Section CG_Counter.
Lemma steps_CG_increment E ρ j K x n:
nclose specN E
spec_ctx ρ x ↦ₛ (#nv n) j fill K (App (CG_increment (Loc x)) Unit)
={E}=> j fill K (Unit) x ↦ₛ (#nv (S n)).
|={E}=> j fill K (Unit) x ↦ₛ (#nv (S n)).
Proof.
iIntros (HNE) "[#Hspec [Hx Hj]]". unfold CG_increment.
iVs (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iVs (step_load _ _ j (K ++ [StoreRCtx (LocV _); BinOpRCtx _ (#nv _)])
iMod (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iMod (step_load _ _ j (K ++ [StoreRCtx (LocV _); BinOpRCtx _ (#nv _)])
_ _ _ with "[Hj Hx]") as "[Hj Hx]"; eauto.
rewrite ?fill_app. simpl.
iFrame "Hspec Hj"; trivial.
rewrite ?fill_app. simpl.
iVs (step_nat_binop _ _ j (K ++ [StoreRCtx (LocV _)])
iMod (step_nat_binop _ _ j (K ++ [StoreRCtx (LocV _)])
_ _ _ with "[Hj]") as "Hj"; eauto.
rewrite ?fill_app. simpl.
iFrame "Hspec Hj"; trivial. simpl.
rewrite ?fill_app. simpl.
iVs (step_store _ _ j K _ _ _ _ _ with "[Hj Hx]") as "[Hj Hx]"; eauto.
iMod (step_store _ _ j K _ _ _ _ _ with "[Hj Hx]") as "[Hj Hx]"; eauto.
iFrame "Hspec Hj"; trivial.
iVsIntro.
iModIntro.
iFrame "Hj Hx"; trivial.
Unshelve. all: trivial.
Qed.
......@@ -121,10 +122,10 @@ Section CG_Counter.
nclose specN E
spec_ctx ρ x ↦ₛ (#nv n) l ↦ₛ (#v false)
j fill K (App (CG_locked_increment (Loc x) (Loc l)) Unit)
={E}=> j fill K Unit x ↦ₛ (#nv S n) l ↦ₛ (#v false).
|={E}=> j fill K Unit x ↦ₛ (#nv S n) l ↦ₛ (#v false).
Proof.
iIntros (HNE) "[#Hspec [Hx [Hl Hj]]]".
iVs (steps_with_lock
iMod (steps_with_lock
_ _ j K _ _ _ _ UnitV UnitV _ _ with "[Hj Hx Hl]") as "Hj"; last done.
- iIntros (K') "[#Hspec [Hx Hj]]".
iApply steps_CG_increment; first done. iFrame "Hspec Hj Hx"; trivial.
......@@ -161,14 +162,14 @@ Section CG_Counter.
nclose specN E
spec_ctx ρ x ↦ₛ (#nv n)
j fill K (App (counter_read (Loc x)) Unit)
={E}=> j fill K (#n n) x ↦ₛ (#nv n).
|={E}=> j fill K (#n n) x ↦ₛ (#nv n).
Proof.
intros HNE. iIntros "[#Hspec [Hx Hj]]". unfold counter_read.
iVs (step_rec _ _ j K _ Unit with "[Hj]") as "Hj"; eauto.
iMod (step_rec _ _ j K _ Unit with "[Hj]") as "Hj"; eauto.
asimpl.
iVs (step_load _ _ j K with "[Hj Hx]") as "[Hj Hx]"; eauto.
iMod (step_load _ _ j K with "[Hj Hx]") as "[Hj Hx]"; eauto.
{ by iFrame "Hspec Hj". }
iVsIntro. by iFrame "Hj Hx".
iModIntro. by iFrame "Hj Hx".
Qed.
Opaque counter_read.
......@@ -260,18 +261,18 @@ Section CG_Counter.
{ iDestruct (interp_env_length with "HΓ") as %[=]. }
iClear "HΓ". cbn -[FG_counter CG_counter].
rewrite ?empty_env_subst /CG_counter /FG_counter.
iVs (steps_newlock _ _ j (K ++ [AppRCtx (RecV _)]) _ with "[Hj]")
iMod (steps_newlock _ _ j (K ++ [AppRCtx (RecV _)]) _ with "[Hj]")
as (l) "[Hj Hl]"; eauto.
{ rewrite fill_app /=. by iFrame. }
rewrite fill_app /=.
iVs (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iMod (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
asimpl. rewrite CG_locked_increment_subst /=.
rewrite counter_read_subst /=.
iVs (step_alloc _ _ j (K ++ [AppRCtx (RecV _)]) _ _ _ _ with "[Hj]")
iMod (step_alloc _ _ j (K ++ [AppRCtx (RecV _)]) _ _ _ _ with "[Hj]")
as (cnt') "[Hj Hcnt']"; eauto.
{ rewrite fill_app; simpl. by iFrame. }
rewrite fill_app; simpl.
iVs (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iMod (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
asimpl. rewrite CG_locked_increment_subst /=.
rewrite counter_read_subst /=.
Unshelve.
......@@ -279,13 +280,12 @@ Section CG_Counter.
all: trivial.
iApply (wp_bind [AppRCtx (RecV _)]);
iApply wp_wand_l; iSplitR; [iIntros (v) "Hv"; iExact "Hv"|].
iApply wp_alloc; trivial; iFrame "Hheap"; iNext; iIntros (cnt) "Hcnt /=".
iVsIntro.
iApply (wp_alloc with "[]"); trivial; iFrame "#"; iNext; iIntros (cnt) "Hcnt /=".
(* establishing the invariant *)
iAssert (( n, l ↦ₛ (#v false) cnt ↦ᵢ (#nv n) cnt' ↦ₛ (#nv n) )%I)
with "[Hl Hcnt Hcnt']" as "Hinv".
{ iExists _. by iFrame. }
iVs (inv_alloc counterN with "[Hinv]") as "#Hinv"; trivial.
iMod (inv_alloc counterN with "[Hinv]") as "#Hinv"; trivial.
{ iNext; iExact "Hinv". }
(* splitting increment and read *)
iApply wp_rec; trivial. iNext. asimpl.
......@@ -306,16 +306,16 @@ Section CG_Counter.
iApply (wp_bind [AppRCtx (RecV _)]);
iApply wp_wand_l; iSplitR; [iIntros (v) "Hv"; iExact "Hv"|].
iInv counterN as (n) ">[Hl [Hcnt Hcnt']]" "Hclose".
iApply wp_load; [|iFrame "Hheap"]. solve_ndisj.
iIntros "!> {$Hcnt} Hcnt !==>".
iVs ("Hclose" with "[Hl Hcnt Hcnt']").
iApply (wp_load with "[Hcnt]"); [|iFrame; iFrame "#"|]. solve_ndisj.
iNext. iIntros "Hcnt".
iMod ("Hclose" with "[Hl Hcnt Hcnt']").
{ iNext. iExists _. iFrame "Hl Hcnt Hcnt'"; trivial. }
iApply wp_rec; trivial. asimpl. iNext.
(* fine-grained performs increment *)
iApply (wp_bind [IfCtx _ _; CasRCtx (LocV _) (NatV _)]);
iApply wp_wand_l; iSplitR; [iIntros (v) "Hv"; iExact "Hv"|].
iApply wp_nat_binop; simpl.
iNext. iVsIntro.
iNext. iModIntro.
iApply (wp_bind [IfCtx _ _]);
iApply wp_wand_l; iSplitR; [iIntros (v) "Hv"; iExact "Hv"|].
iInv counterN as (n') ">[Hl [Hcnt Hcnt']]" "Hclose".
......@@ -323,21 +323,21 @@ Section CG_Counter.
destruct (decide (n = n')) as [|Hneq]; subst.
+ (* CAS succeeds *)
(* In this case, we perform increment in the coarse-grained one *)
iVs (steps_CG_locked_increment
iMod (steps_CG_locked_increment
_ _ _ _ _ _ _ _ with "[Hj Hl Hcnt']") as "[Hj [Hcnt' Hl]]".
{ iFrame "Hspec Hcnt' Hl Hj"; trivial. }
iApply wp_cas_suc; simpl; trivial; [|iFrame "Hheap"]. solve_ndisj.
iIntros "{$Hcnt} !> Hcnt !==>".
iVs ("Hclose" with "[Hl Hcnt Hcnt']").
iApply (wp_cas_suc with "[Hcnt]"); trivial; [|iFrame; iFrame "Hheap"|].
solve_ndisj. iNext. iIntros "Hcnt".
iMod ("Hclose" with "[Hl Hcnt Hcnt']").
{ iNext. iExists _. iFrame "Hl Hcnt Hcnt'"; trivial. }
iApply wp_if_true. iNext. iApply wp_value; trivial.
iExists UnitV; iFrame; auto.
+ (* CAS fails *)
(* In this case, we perform a recursive call *)
iApply (wp_cas_fail _ _ _ (#nv n')); simpl; trivial;
[inversion 1; subst; auto | | iFrame "Hheap"]. solve_ndisj.
iIntros "{$Hcnt} !> Hcnt !==>".
iVs ("Hclose" with "[Hl Hcnt Hcnt']").
iApply (wp_cas_fail _ _ _ (#nv n') with "[Hcnt]"); simpl; trivial;
[inversion 1; subst; auto | | iFrame; iFrame "Hheap"|]. solve_ndisj.
iNext. iIntros "Hcnt".
iMod ("Hclose" with "[Hl Hcnt Hcnt']").
{ iNext. iExists _; iFrame "Hl Hcnt Hcnt'"; trivial. }
iApply wp_if_false. iNext. by iApply "Hlat".
- (* refinement of read *)
......@@ -348,12 +348,12 @@ Section CG_Counter.
unfold counter_read at 2.
iApply wp_rec; trivial. simpl.
iNext. iInv counterN as (n) ">[Hl [Hcnt Hcnt']]" "Hclose".
iVs (steps_counter_read with "[Hj Hcnt']") as "[Hj Hcnt']".
iMod (steps_counter_read with "[Hj Hcnt']") as "[Hj Hcnt']".
{ solve_ndisj. }
{ by iFrame "Hspec Hcnt' Hj". }
iApply wp_load; [|iFrame "Hheap"]. solve_ndisj.
iIntros "{$Hcnt} !> Hcnt !==>".
iVs ("Hclose" with "[Hl Hcnt Hcnt']").
iApply (wp_load with "[Hcnt]"); [|iFrame; iFrame "Hheap"|]. solve_ndisj.
iNext. iIntros "Hcnt".
iMod ("Hclose" with "[Hl Hcnt Hcnt']").
{ iNext. iExists _; iFrame "Hl Hcnt Hcnt'"; trivial. }
iExists (#nv _); eauto.
Unshelve. solve_ndisj.
......@@ -364,7 +364,7 @@ Theorem counter_ctx_refinement :
[] FG_counter ctx CG_counter :
TProd (TArrow TUnit TUnit) (TArrow TUnit TNat).
Proof.
set (Σ := #[irisΣ lang; auth.authΣ heapUR; auth.authΣ cfgUR]).
set (Σ := #[irisΣ state; auth.authΣ heapUR; auth.authΣ cfgUR]).
eapply (binary_soundness Σ);
auto using FG_counter_closed, CG_counter_closed, FG_CG_counter_refinement.
Qed.
From iris.proofmode Require Import invariants ghost_ownership tactics.
From iris.proofmode Require Import tactics.
From iris_logrel.F_mu_ref_conc Require Export rules_binary typing.
From iris.base_logic Require Import namespaces.
Definition newlock : expr := Alloc (# false).
Definition acquire : expr :=
......@@ -79,10 +80,10 @@ Section proof.
Lemma steps_newlock E ρ j K :
nclose specN E
spec_ctx ρ j fill K newlock
={E}=> l, j fill K (Loc l) l ↦ₛ (#v false).
|={E}=> l, j fill K (Loc l) l ↦ₛ (#v false).
Proof.
iIntros (HNE) "[#Hspec Hj]".
by iVs (step_alloc _ _ j K with "[Hj]") as "Hj"; eauto.
by iMod (step_alloc _ _ j K with "[Hj]") as "Hj"; eauto.
Qed.
Global Opaque newlock.
......@@ -90,17 +91,17 @@ Section proof.
Lemma steps_acquire E ρ j K l :
nclose specN E
spec_ctx ρ l ↦ₛ (#v false) j fill K (App acquire (Loc l))
={E}=> j fill K Unit l ↦ₛ (#v true).
|={E}=> j fill K Unit l ↦ₛ (#v true).
Proof.
iIntros (HNE) "[#Hspec [Hl Hj]]". unfold acquire.
iVs (step_rec _ _ j K with "[Hj]") as "Hj"; eauto. done.
iVs (step_cas_suc _ _ j (K ++ [IfCtx _ _])
iMod (step_rec _ _ j K with "[Hj]") as "Hj"; eauto. done.
iMod (step_cas_suc _ _ j (K ++ [IfCtx _ _])
_ _ _ _ _ _ _ _ _ with "[Hj Hl]") as "[Hj Hl]"; trivial.
{ rewrite fill_app /=. iFrame "Hspec Hj Hl"; eauto. }
rewrite fill_app /=.
iVs (step_if_true _ _ j K _ _ _ with "[Hj]") as "Hj"; trivial.
iMod (step_if_true _ _ j K _ _ _ with "[Hj]") as "Hj"; trivial.
{ by iFrame. }
by iIntros "!==> {$Hj $Hl}".
by iIntros "!> {$Hj $Hl}".
Unshelve. all:trivial.
Qed.
......@@ -109,13 +110,13 @@ Section proof.
Lemma steps_release E ρ j K l b:
nclose specN E
spec_ctx ρ l ↦ₛ (#v b) j fill K (App release (Loc l))
={E}=> j fill K Unit l ↦ₛ (#v false).
|={E}=> j fill K Unit l ↦ₛ (#v false).
Proof.
iIntros (HNE) "[#Hspec [Hl Hj]]". unfold release.
iVs (step_rec _ _ j K with "[Hj]") as "Hj"; eauto; try done.
iVs (step_store _ _ j K _ _ _ _ _ with "[Hj Hl]") as "[Hj Hl]"; eauto.
iMod (step_rec _ _ j K with "[Hj]") as "Hj"; eauto; try done.
iMod (step_store _ _ j K _ _ _ _ _ with "[Hj Hl]") as "[Hj Hl]"; eauto.
{ by iFrame. }
by iIntros "!==> {$Hj $Hl}".
by iIntros "!> {$Hj $Hl}".
Unshelve. all: trivial.
Qed.
......@@ -125,31 +126,31 @@ Section proof.
nclose specN E
( f, e.[f] = e) (* e is a closed term *)
( K', spec_ctx ρ P j fill K' (App e (of_val w))
={E}=> j fill K' (of_val v) Q)
|={E}=> j fill K' (of_val v) Q)
spec_ctx ρ P l ↦ₛ (#v false)
j fill K (App (with_lock e (Loc l)) (of_val w))
={E}=> j fill K (of_val v) Q l ↦ₛ (#v false).
|={E}=> j fill K (of_val v) Q l ↦ₛ (#v false).
Proof.
iIntros (HNE H1 H2) "[#Hspec [HP [Hl Hj]]]".
iVs (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iMod (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
asimpl. rewrite H1.
iVs (steps_acquire _ _ j (K ++ [AppRCtx (RecV _)])
iMod (steps_acquire _ _ j (K ++ [AppRCtx (RecV _)])
_ _ with "[Hj Hl]") as "[Hj Hl]"; eauto.
{ rewrite fill_app /=. iFrame "Hspec Hj Hl"; eauto. }
rewrite fill_app; simpl.
iVs (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iMod (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
asimpl. rewrite H1.
iVs (H2 (K ++ [AppRCtx (RecV _)]) with "[Hj HP]") as "[Hj HQ]"; eauto.
iMod (H2 (K ++ [AppRCtx (RecV _)]) with "[Hj HP]") as "[Hj HQ]"; eauto.
{ rewrite fill_app /=. iFrame "Hspec Hj HP"; eauto. }
rewrite ?fill_app /=.
iVs (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iMod (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
asimpl.
iVs (steps_release _ _ j (K ++ [AppRCtx (RecV _)]) _ _ with "[Hj Hl]")
iMod (steps_release _ _ j (K ++ [AppRCtx (RecV _)]) _ _ with "[Hj Hl]")
as "[Hj Hl]"; eauto.
{ rewrite fill_app /=. by iFrame. }
rewrite ?fill_app /=.
iVs (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
asimpl. iVsIntro; by iFrame.
iMod (step_rec _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
asimpl. iModIntro; by iFrame.
Unshelve.
all: try match goal with |- to_val _ = _ => auto using to_of_val end.
trivial.
......
This diff is collapsed.
This diff is collapsed.
From iris.proofmode Require Import invariants ghost_ownership tactics.
From iris.proofmode Require Import tactics.
From iris_logrel.F_mu_ref_conc Require Import logrel_binary.
From iris.algebra Require Import gmap dec_agree.
From iris.program_logic Require Import auth.
From iris.base_logic Require Import auth.
Import uPred.
Definition stackUR : ucmraT := gmapUR loc (dec_agreeR val).
......@@ -38,7 +38,7 @@ Section Rules.
Proof.
iIntros "H".
rewrite -own_op.
iDestruct (own_valid _ with "#H") as %Hvalid.
iDestruct (own_valid _ with "H") as %Hvalid.
rewrite own_op. unfold stack_mapsto, auth_own.
iDestruct "H" as "[$ $]".
specialize (Hvalid l). rewrite lookup_op ?lookup_singleton in Hvalid.
......@@ -77,9 +77,9 @@ Section Rules.
Lemma StackLink_dup (Q : D) v `{ vw, PersistentP (Q vw)} :
StackLink Q v StackLink Q v StackLink Q v.
Proof.
iIntros "H". iLöb (v) as "Hlat". rewrite StackLink_unfold.
iIntros "H". iLöb as "Hlat" forall (v). rewrite StackLink_unfold.
iDestruct "H" as (l w) "[% [Hl Hr]]"; subst.
iDestruct (stack_mapsto_dup with "[Hl]") as "[Hl1 Hl2]"; eauto.
iDestruct (stack_mapsto_dup with "[Hl]") as "[Hl1 Hl2]"; first eauto.
iDestruct "Hr" as "[#Hr|Hr]".
{ iSplitL "Hl1".
- iExists _, _; iFrame "Hl1"; eauto.
......@@ -181,10 +181,10 @@ Section Rules.
Lemma stack_owns_alloc E h l v :
stack_owns h l ↦ᵢ v
={E}=> stack_owns (<[l := DecAgree v]> h) l ↦ˢᵗᵏ v.
|={E}=> stack_owns (<[l := DecAgree v]> h) l ↦ˢᵗᵏ v.
Proof.
iIntros "[[Hown Hall] Hl]".
iDestruct (own_valid _ with "#Hown") as "Hvalid".
iDestruct (own_valid _ with "Hown") as "#Hvalid".
iDestruct (auth_validI _ with "Hvalid") as "[Ha' Hb]";
simpl; iClear "Hvalid".
iDestruct "Hb" as %H1.
......@@ -199,10 +199,10 @@ Section Rules.
rewrite big_sepM_insert; [|apply lookup_delete_None; auto].
iDestruct "Hall" as "[Hl' Hall]".
iExFalso. iApply heap_mapsto_dup_invalid; by iFrame "Hl Hl'".
- iVs (own_update with "Hown") as "Hown".
- iMod (own_update with "Hown") as "Hown".
by apply stackR_alloc.
iDestruct "Hown" as "[Hown Hl']".
iVsIntro. iSplitR "Hl'"; [|unfold stack_mapsto, auth_own; trivial].
iModIntro. iSplitR "Hl'"; [|unfold stack_mapsto, auth_own; trivial].
iCombine "Hl" "Hall" as "Hall".
unfold stack_owns. iFrame "Hown".
rewrite big_sepM_insert; trivial.
......@@ -220,7 +220,7 @@ Section Rules.
iIntros "[[Hown Hall] Hl]".
unfold stack_mapsto, auth_own.
iCombine "Hown" "Hl" as "Hown".
iDestruct (own_valid _ with "#Hown") as %Hvalid.
iDestruct (own_valid _ with "Hown") as %Hvalid.
iDestruct "Hown" as "[Hown Hl]".
assert (Heq : h !! l = Some (DecAgree v)).
eapply stackR_auth_is_subheap; eauto using lookup_singleton.
......@@ -241,7 +241,7 @@ Section Rules.
iIntros "[Hown [Hall [Hl Hl']]]".
unfold stack_mapsto, auth_own.
iCombine "Hown" "Hl'" as "Hown".
iDestruct (own_valid _ with "#Hown") as %Hvalid.
iDestruct (own_valid _ with "Hown") as %Hvalid.
iDestruct "Hown" as "[Hown Hl']".
assert (Heq : h !! l = Some (DecAgree v)).
eapply stackR_auth_is_subheap; eauto using lookup_singleton.
......@@ -269,5 +269,5 @@ Section Rules.
Lemma stack_owns_later_open_close h l v :
stack_owns h l ↦ˢᵗᵏ v
(l ↦ᵢ v (l ↦ᵢ v - (stack_owns h l ↦ˢᵗᵏ v))).
Proof. iIntros "H !>". by iApply stack_owns_open_close. Qed.
Proof. iIntros "H". by iNext; iApply stack_owns_open_close. Qed.
End Rules.
From iris_logrel.F_mu_ref_conc Require Export logrel_binary.
From iris.proofmode Require Import tactics pviewshifts invariants.
From iris.proofmode Require Import tactics.
From iris_logrel.F_mu_ref_conc Require Import rules_binary.
From iris.algebra Require Export upred_big_op.
From iris.base_logic Require Export big_op.
Section bin_log_def.
Context `{cfgSG Σ}.
......@@ -94,7 +94,7 @@ Section fundamental.
iIntros (Δ vvs ρ ?) "#(Hh & Hs & HΓ)"; iIntros (j K) "Hj /=".
smart_wp_bind (FstCtx) v v' "[Hv #Hiv]" ('IHHtyped _ _ _ j (K ++ [FstCtx])); cbn.
iDestruct "Hiv" as ([w1 w1'] [w2 w2']) "#[% [Hw1 Hw2]]"; simplify_eq.
iVs (step_fst _ _ j K (of_val w1') w1' (of_val w2') w2' with "* [-]") as "Hw"; eauto.
iMod (step_fst _ _ j K (of_val w1') w1' (of_val w2') w2' with "* [-]") as "Hw"; eauto.
iApply wp_fst; eauto.
Qed.
......@@ -105,7 +105,7 @@ Section fundamental.
iIntros (Δ vvs ρ ?) "#(Hh & Hs & HΓ)"; iIntros (j K) "Hj /=".
smart_wp_bind (SndCtx) v v' "[Hv #Hiv]" ('IHHtyped _ _ _ j (K ++ [SndCtx])); cbn.
iDestruct "Hiv" as ([w1 w1'] [w2 w2']) "#[% [Hw1 Hw2]]"; simplify_eq.
iVs (step_snd _ _ j K (of_val w1') w1' (of_val w2') w2' with "* [-]") as "Hw"; eauto.
iMod (step_snd _ _ j K (of_val w1') w1' (of_val w2') w2' with "* [-]") as "Hw"; eauto.
iApply wp_snd; eauto.
Qed.
......@@ -147,13 +147,13 @@ Section fundamental.
('IHHtyped1 _ _ _ j (K ++ [CaseCtx _ _])); cbn.
iDestruct "Hiv" as "[Hiv|Hiv]".
- iDestruct "Hiv" as ([w w']) "[% Hw]"; simplify_eq.
iVs (step_case_inl _ _ j K (of_val w') w' with "* [-]") as "Hz"; eauto.
iMod (step_case_inl _ _ j K (of_val w') w' with "* [-]") as "Hz"; eauto.
iApply wp_case_inl; auto 1 using to_of_val. iNext.
asimpl. erewrite !n_closed_subst_head_simpl by (rewrite ?fmap_length; eauto).
iApply ('IHHtyped2 _ ((w,w') :: vvs)); repeat iSplit; eauto.
iApply interp_env_cons; auto.
- iDestruct "Hiv" as ([w w']) "[% Hw]"; simplify_eq.
iVs (step_case_inr _ _ j K (of_val w') w' with "* [-]") as "Hz"; eauto.
iMod (step_case_inr _ _ j K (of_val w') w' with "* [-]") as "Hz"; eauto.
iApply wp_case_inr; auto 1 using to_of_val. iNext.
asimpl. erewrite !n_closed_subst_head_simpl by (rewrite ?fmap_length; eauto).
iApply ('IHHtyped3 _ ((w,w') :: vvs)); repeat iSplit; eauto.
......@@ -170,9 +170,9 @@ Section fundamental.
smart_wp_bind (IfCtx _ _) v v' "[Hv #Hiv]"
('IHHtyped1 _ _ _ j (K ++ [IfCtx _ _])); cbn.
iDestruct "Hiv" as ([]) "[% %]"; simplify_eq/=.
- iVs (step_if_true _ _ j K with "* [-]") as "Hz"; eauto.
- iMod (step_if_true _ _ j K with "* [-]") as "Hz"; eauto.
iApply wp_if_true. iNext. iApply 'IHHtyped2; eauto.
- iVs (step_if_false _ _ j K with "* [-]") as "Hz"; eauto.
- iMod (step_if_false _ _ j K with "* [-]") as "Hz"; eauto.
iApply wp_if_false. iNext. iApply 'IHHtyped3; eauto.
Qed.
......@@ -188,8 +188,8 @@ Section fundamental.
('IHHtyped2 _ _ _ j (K ++ [BinOpRCtx _ _])); cbn.
iDestruct "Hiv" as (n) "[% %]"; simplify_eq/=.
iDestruct "Hiw" as (n') "[% %]"; simplify_eq/=.
iVs (step_nat_binop _ _ j K with "* [-]") as "Hz"; eauto.
iApply wp_nat_binop. iNext. iVsIntro. iExists _; iSplitL; eauto.
iMod (step_nat_binop _ _ j K with "* [-]") as "Hz"; eauto.
iApply wp_nat_binop. iNext. iModIntro. iExists _; iSplitL; eauto.
destruct op; simpl; try destruct eq_nat_dec; try destruct le_dec;