Commit 01db92e2 authored by Robbert Krebbers's avatar Robbert Krebbers

Update to new version of Iris.

parent e045456d
......@@ -8,43 +8,10 @@ Import uPred.
Section typed_interp.
Context {Σ : iFunctor}.
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
_ : ?A, _) => let W := fresh "W" in evar (W : A); iExists W; unfold W; clear W
end : itauto.
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
_) => iNext
end : itauto.
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
_) => eapply (@always_intro _ _ _ _)
end : itauto.
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
(_ _)) => iSplit
end : itauto.
Local Tactic Notation "smart_wp_bind" uconstr(ctx) ident(v) constr(Hv) uconstr(Hp) :=
iApply (@wp_bind _ _ _ [ctx]);
iApply wp_impl_l;
iSplit; [| iApply Hp; trivial]; cbn;
eapply (@always_intro _ _ _ _);
iApply wp_wand_l;
iSplitL; [|iApply Hp; trivial]; cbn;
iIntros {v} Hv.
Local Ltac value_case := iApply wp_value; cbn; rewrite ?to_of_val; trivial.
......@@ -53,8 +20,8 @@ Section typed_interp.
(Htyped : typed Γ e τ)
(HΔ : context_interp_Persistent Δ)
: List.length Γ = List.length vs
Π∧ zip_with (λ τ v, interp τ Δ v) Γ vs
WP (e.[env_subst vs]) @ {{ λ v, (@interp Σ) τ Δ v }}.
[] zip_with (λ τ v, interp τ Δ v) Γ vs
WP e.[env_subst vs] {{ λ v, (@interp Σ) τ Δ v }}.
Proof.
revert Δ HΔ vs.
induction Htyped; intros Δ HΔ vs Hlen; iIntros "#HΓ"; cbn.
......@@ -69,75 +36,66 @@ Section typed_interp.
- (* pair *)
smart_wp_bind (PairLCtx e2.[env_subst vs]) v "# Hv" IHHtyped1.
smart_wp_bind (PairRCtx v) v' "# Hv'" IHHtyped2.
value_case; eauto 10 with itauto.
value_case; eauto 10.
- (* fst *)
smart_wp_bind (FstCtx) v "# Hv" IHHtyped; cbn.
iApply double_exists; [|trivial].
intros w w'; cbn; iIntros "#[% [H2 H3]]"; rewrite H; cbn.
iApply wp_fst; try iNext; eauto using to_of_val; cbn.
iDestruct "Hv" as {w1 w2} "#[% [H2 H3]]"; subst.
iApply wp_fst; eauto using to_of_val.
- (* snd *)
smart_wp_bind (SndCtx) v "# Hv" IHHtyped; cbn.
iApply double_exists; [|trivial].
intros w w'; cbn; iIntros "#[% [H2 H3]]"; rewrite H.
iApply wp_snd; try iNext; eauto using to_of_val.
iDestruct "Hv" as {w1 w2} "#[% [H2 H3]]"; subst.
iApply wp_snd; eauto using to_of_val.
- (* injl *)
smart_wp_bind (InjLCtx) v "# Hv" IHHtyped; cbn.
value_case; iLeft; auto with itauto.
value_case; eauto.
- (* injr *)
smart_wp_bind (InjRCtx) v "# Hv" IHHtyped; cbn.
value_case; iRight; auto with itauto.
value_case; eauto.
- (* case *)
smart_wp_bind (CaseCtx _ _) v "#Hv" IHHtyped1; cbn.
iDestruct "Hv" as "[Hv|Hv]";
iDestruct "Hv" as {w} "[% Hw]"; rewrite H;
[iApply wp_case_inl|iApply wp_case_inr];
auto 1 using to_of_val;
asimpl;
[specialize (IHHtyped2 Δ HΔ (w::vs)) |
specialize (IHHtyped3 Δ HΔ (w::vs))];
erewrite <- ?typed_subst_head_simpl in * by (cbn; eauto); iNext;
[iApply IHHtyped2 | iApply IHHtyped3]; cbn; auto with itauto.
iDestruct "Hv" as "[Hv|Hv]"; iDestruct "Hv" as {w} "[% Hw]"; subst.
+ iApply wp_case_inl; auto 1 using to_of_val; asimpl.
specialize (IHHtyped2 Δ HΔ (w::vs)).
erewrite <- ?typed_subst_head_simpl in * by (cbn; eauto).
iNext; iApply IHHtyped2; cbn; auto.
+ iApply wp_case_inr; auto 1 using to_of_val; asimpl.
specialize (IHHtyped3 Δ HΔ (w::vs)).
erewrite <- ?typed_subst_head_simpl in * by (cbn; eauto).
iNext; iApply IHHtyped3; cbn; auto.
- (* lam *)
value_case; apply (always_intro _ _); iIntros {w} "#Hw".
value_case; iAlways; iIntros {w} "#Hw".
iApply wp_lam; auto 1 using to_of_val.
asimpl; erewrite typed_subst_head_simpl; [|eauto|cbn]; eauto.
iNext; iApply (IHHtyped Δ HΔ (w :: vs)); cbn; auto with itauto.
iNext; iApply (IHHtyped Δ HΔ (w :: vs)); cbn; auto.
- (* app *)
smart_wp_bind (AppLCtx (e2.[env_subst vs])) v "#Hv" IHHtyped1.
smart_wp_bind (AppRCtx v) w "#Hw" IHHtyped2.
iApply wp_mono; [|iApply "Hv"]; auto with itauto.
iApply wp_mono; [|iApply "Hv"]; auto.
- (* TLam *)
value_case.
iIntros {τi}; destruct τi as [τi τiPr]. iAlways.
iApply wp_TLam; iNext; simpl in *.
iIntros { [τi τiPr] } "!". iApply wp_TLam; iNext; simpl in *.
iApply IHHtyped; [rewrite map_length|]; trivial.
iRevert "HΓ".
rewrite zip_with_context_interp_subst.
iIntros "#HΓ"; trivial.
rewrite zip_with_context_interp_subst; trivial.
- (* TApp *)
smart_wp_bind TAppCtx v "#Hv" IHHtyped; cbn.
iSpecialize ("Hv" $! ((interp τ' Δ) _)); cbn.
unshelve iSpecialize ("Hv" $! ((interp τ' Δ) _)); try apply _; cbn.
iApply always_elim. iApply always_mono; [|trivial].
apply wp_mono => w. by rewrite interp_subst.
- (* Fold *)
rewrite map_length in IHHtyped.
iApply (@wp_bind _ _ _ [FoldCtx]).
iApply wp_impl_l.
iSplit; [eapply (@always_intro _ _ _ _)|
iApply (IHHtyped (extend_context_interp ((interp (TRec τ)) Δ) Δ));
iApply wp_wand_l.
iSplitL; [|iApply (IHHtyped (extend_context_interp ((interp (TRec τ)) Δ) Δ));
trivial].
+ iIntros {v} "#Hv".
value_case.
change (fixpoint _) with (interp (TRec τ) Δ) at 1; trivial.
rewrite fixpoint_unfold; cbn.
auto with itauto.
iAlways; eauto.
+ iRevert "HΓ"; rewrite zip_with_context_interp_subst; iIntros "#HΓ"; trivial.
- (* Unfold *)
iApply (@wp_bind _ _ _ [UnfoldCtx]);
iApply wp_impl_l;
iSplit; [eapply (@always_intro _ _ _ _)|
iApply IHHtyped;
trivial].
iApply wp_wand_l; iSplitL; [|iApply IHHtyped; trivial].
iIntros {v}.
cbn [interp interp_rec cofe_mor_car].
rewrite fixpoint_unfold.
......@@ -146,9 +104,5 @@ Section typed_interp.
iDestruct "Hv" as {w} "[% #Hw]"; rewrite H.
iApply wp_Fold; cbn; auto using to_of_val.
rewrite -interp_subst; trivial.
(* unshelving *)
Unshelve.
cbn; typeclasses eauto.
Qed.
End typed_interp.
\ No newline at end of file
End typed_interp.
......@@ -221,6 +221,9 @@ other words, [e] also contains the reducible expression *)
eauto using fill_item_no_val_inj, values_head_stuck, fill_not_val.
Qed.
Canonical Structure stateC := leibnizC state.
Canonical Structure valC := leibnizC val.
Canonical Structure exprC := leibnizC expr.
End lang.
(** Language *)
......
This diff is collapsed.
......@@ -2,7 +2,6 @@ Require Import iris.program_logic.lifting.
Require Import iris.algebra.upred_big_op.
Require Import iris_logrel.F_mu.lang.
Section lang_rules.
Context {Σ : iFunctor}.
Implicit Types P : iProp lang Σ.
......
......@@ -12,12 +12,12 @@ Section Soundness.
Definition Σ := #[].
Lemma empty_env_subst e : e.[env_subst []] = e.
Proof.
replace (env_subst []) with (@ids expr _) by reflexivity.
asimpl; trivial.
Qed.
Definition free_type_context :
leibniz_var -n> leibniz_val -n> iProp lang (globalF Σ) :=
Definition free_type_context : varC -n> valC -n> iProp lang (globalF Σ) :=
{|
cofe_mor_car :=
λ x,
......@@ -50,7 +50,7 @@ Section Soundness.
edestruct(@wp_adequacy_reducible lang (globalF Σ)
(interp τ free_type_context)
e e' (e' :: thp) tt ) as [Ha|Ha];
eauto using cmra_unit_valid; try tauto.
eauto using ucmra_unit_valid; try tauto.
- iIntros "H". iApply H1.
- constructor.
Qed.
......
......@@ -58,14 +58,13 @@ Proof.
Qed.
Definition env_subst (vs : list val) (x : var) : expr :=
from_option (Var x) (of_val <$> vs !! x).
from_option id (Var x) (of_val <$> vs !! x).
Notation "# v" := (of_val v) (at level 20).
Lemma typed_subst_head_simpl Δ τ e w ws :
typed Δ e τ -> List.length Δ = S (List.length ws)
e.[# w .: env_subst ws] = e.[env_subst (w :: ws)]
.
e.[# w .: env_subst ws] = e.[env_subst (w :: ws)].
Proof.
intros H1 H2.
rewrite /env_subst. eapply typed_subst_invariant; eauto=> /= -[|x] ? //=.
......@@ -73,11 +72,9 @@ Proof.
by rewrite Hv.
Qed.
Local Opaque eq_nat_dec.
Lemma iter_up_subst_type (m : nat) (τ : type) (x : var)
:
Lemma iter_up_subst_type (m : nat) (τ : type) (x : var) :
(iter m up (τ .: ids) x) =
if lt_dec x m then ids x else
if eq_nat_dec x m then τ.[ren (+m)] else ids (x - 1).
......
......@@ -12,61 +12,23 @@ Import uPred.
Section typed_interp.
Context {Σ : gFunctors} `{i : heapG Σ} `{L : namespace}.
Implicit Types P Q R : iPropG lang Σ.
Notation "# v" := (of_val v) (at level 20).
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
_ : ?A, _) => let W := fresh "W" in evar (W : A); iExists W; unfold W; clear W
end : itauto.
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
_) => iNext
end : itauto.
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
_) => eapply (@always_intro _ _ _ _)
end : itauto.
Local Hint Extern 1 =>
match goal with
|-
(_
--------------------------------------
(_ _)) => iSplit
end : itauto.
Local Tactic Notation "smart_wp_bind" uconstr(ctx) ident(v) constr(Hv) uconstr(Hp) :=
iApply (@wp_bind _ _ _ [ctx]);
iApply wp_impl_l;
iSplit; [| iApply Hp; trivial];
[apply (always_intro _ _); iIntros {v} Hv|iSplit; trivial]; cbn.
iApply wp_wand_l;
iSplitL; [|iApply Hp; trivial]; [iIntros {v} Hv|iSplit; trivial]; cbn.
Local Ltac value_case := iApply wp_value; [cbn; rewrite ?to_of_val; trivial|].
Lemma later_exist_turnstile (M : cmraT) (A : Type) :
Inhabited A Φ : A uPred M, ( ( a : A, Φ a))%I ( a : A, Φ a)%I.
Proof. intros H Φ. rewrite later_exist; trivial. Qed.
Lemma typed_interp N Δ Γ vs e τ
(HNLdisj : l : loc, N L .@ l)
(Htyped : typed Γ e τ)
(HΔ : context_interp_Persistent Δ)
: List.length Γ = List.length vs
(heap_ctx N Π∧ zip_with (λ τ v, (@interp Σ i L) τ Δ v) Γ vs)%I
WP (e.[env_subst vs]) @ {{ λ v, (@interp Σ i L) τ Δ v }}.
heap_ctx N [] zip_with (λ τ v, (@interp Σ i L) τ Δ v) Γ vs
WP e.[env_subst vs] {{ λ v, (@interp Σ i L) τ Δ v }}.
Proof.
revert Δ HΔ vs.
induction Htyped; intros Δ HΔ vs Hlen; iIntros "#[Hheap HΓ]"; cbn.
......@@ -81,87 +43,74 @@ Section typed_interp.
- (* pair *)
smart_wp_bind (PairLCtx e2.[env_subst vs]) v "#Hv" IHHtyped1.
smart_wp_bind (PairRCtx v) v' "# Hv'" IHHtyped2.
value_case; eauto 10 with itauto.
- (* fst *)
value_case; eauto 10.
- (* fst *)
smart_wp_bind (FstCtx) v "# Hv" IHHtyped; cbn.
iApply double_exists; [|trivial].
intros w w'; cbn; iIntros "#[% [H2 H3]]"; rewrite H; cbn.
iApply wp_fst; try iNext; eauto using to_of_val; cbn.
iDestruct "Hv" as {w1 w2} "#[% [H2 H3]]"; subst.
iApply wp_fst; eauto using to_of_val.
- (* snd *)
smart_wp_bind (SndCtx) v "# Hv" IHHtyped; cbn.
iApply double_exists; [|trivial].
intros w w'; cbn; iIntros "#[% [H2 H3]]"; rewrite H; cbn.
iApply wp_snd; try iNext; eauto using to_of_val; cbn.
iDestruct "Hv" as {w1 w2} "#[% [H2 H3]]"; subst.
iApply wp_snd; eauto using to_of_val.
- (* injl *)
smart_wp_bind (InjLCtx) v "# Hv" IHHtyped; cbn.
value_case; iLeft; auto with itauto.
value_case; eauto.
- (* injr *)
smart_wp_bind (InjRCtx) v "# Hv" IHHtyped; cbn.
value_case; iRight; auto with itauto.
value_case; eauto.
- (* case *)
smart_wp_bind (CaseCtx _ _) v "#Hv" IHHtyped1; cbn.
iDestruct "Hv" as "[Hv|Hv]";
iDestruct "Hv" as {w} "[% Hw]"; rewrite H;
[iApply wp_case_inl|iApply wp_case_inr];
auto 1 using to_of_val;
asimpl;
[specialize (IHHtyped2 Δ HΔ (w::vs)) |
specialize (IHHtyped3 Δ HΔ (w::vs))];
erewrite <- ?typed_subst_head_simpl in * by (cbn; eauto); iNext;
[iApply IHHtyped2 | iApply IHHtyped3]; cbn; auto with itauto.
iDestruct "Hv" as "[Hv|Hv]"; iDestruct "Hv" as {w} "[% Hw]"; subst.
+ iApply wp_case_inl; auto 1 using to_of_val; asimpl.
specialize (IHHtyped2 Δ HΔ (w::vs)).
erewrite <- ?typed_subst_head_simpl in * by (cbn; eauto).
iNext; iApply IHHtyped2; cbn; auto.
+ iApply wp_case_inr; auto 1 using to_of_val; asimpl.
specialize (IHHtyped3 Δ HΔ (w::vs)).
erewrite <- ?typed_subst_head_simpl in * by (cbn; eauto).
iNext; iApply IHHtyped3; cbn; auto.
- (* lam *)
value_case; apply (always_intro _ _); iIntros {w} "#Hw".
value_case; iAlways; iIntros {w} "#Hw".
iApply wp_lam; auto 1 using to_of_val.
asimpl; erewrite typed_subst_head_simpl; [|eauto|cbn]; eauto.
iNext; iApply (IHHtyped Δ HΔ (w :: vs)); cbn; auto with itauto.
iNext; iApply (IHHtyped Δ HΔ (w :: vs)); cbn; auto.
- (* app *)
smart_wp_bind (AppLCtx (e2.[env_subst vs])) v "#Hv" IHHtyped1.
smart_wp_bind (AppRCtx v) w "#Hw" IHHtyped2.
iApply wp_mono; [|iApply "Hv"]; auto with itauto.
iApply wp_mono; [|iApply "Hv"]; auto.
- (* TLam *)
value_case.
iIntros {τi}; destruct τi as [τi τiPr].
iRevert "Hheap".
iPoseProof (always_intro with "HΓ") as "HP"; try typeclasses eauto;
try (iApply always_impl; iExact "HP").
iIntros "#HΓ #Hheap".
value_case. iIntros { [τi τiPr] } "!".
iApply wp_TLam; iNext.
iApply IHHtyped; [rewrite map_length|]; trivial.
iSplit; trivial.
iRevert "Hheap HΓ". rewrite zip_with_context_interp_subst.
iIntros "#Hheap #HΓ"; trivial.
rewrite zip_with_context_interp_subst; trivial.
- (* TApp *)
smart_wp_bind TAppCtx v "#Hv" IHHtyped; cbn.
iSpecialize ("Hv" $! ((interp τ' Δ) _)); cbn.
iApply always_elim. iApply always_mono; [|trivial].
apply wp_mono => w. by rewrite -interp_subst; simpl.
unshelve iSpecialize ("Hv" $! ((interp L τ' Δ) _)); try apply _; cbn.
iApply wp_mono; [|done].
intros w; rewrite interp_subst; trivial.
- (* Fold *)
rewrite map_length in IHHtyped.
iApply (@wp_bind _ _ _ [FoldCtx]).
iApply wp_impl_l.
iSplit; [eapply (@always_intro _ _ _ _)|
iApply (IHHtyped (extend_context_interp ((interp (TRec τ)) Δ) Δ));
iApply wp_wand_l.
iSplitL; [|iApply (IHHtyped (extend_context_interp ((interp L (TRec τ)) Δ) Δ));
trivial].
+ iIntros {v} "#Hv".
value_case.
rewrite fixpoint_unfold; cbn.
auto with itauto.
+ iRevert "Hheap HΓ"; rewrite zip_with_context_interp_subst;
iIntros "#Hheap #HΓ"; auto with itauto.
iAlways; eauto.
+ rewrite zip_with_context_interp_subst; auto.
- (* Unfold *)
iApply (@wp_bind _ _ _ [UnfoldCtx]);
iApply wp_impl_l;
iSplit; [eapply (@always_intro _ _ _ _)|
iApply IHHtyped;
auto with itauto].
iApply wp_wand_l; iSplitL; [|iApply IHHtyped; auto].
iIntros {v}.
cbn [interp interp_rec cofe_mor_car].
rewrite fixpoint_unfold.
iIntros "#Hv"; cbn.
change (fixpoint _) with (@interp _ _ L (TRec τ) Δ).
change (fixpoint _) with (interp L (TRec τ) Δ).
iDestruct "Hv" as {w} "[% #Hw]"; rewrite H.
iApply wp_Fold; cbn; auto using to_of_val.
rewrite -interp_subst; auto with itauto.
rewrite -interp_subst; auto.
- (* Alloc *)
smart_wp_bind AllocCtx v "#Hv" IHHtyped; cbn. iClear "HΓ".
iApply wp_atomic; cbn; trivial; [rewrite to_of_val; auto|].
......@@ -175,8 +124,7 @@ Section typed_interp.
iNext; iExists _; iFrame "Hl"; trivial.
- (* Load *)
smart_wp_bind LoadCtx v "#Hv" IHHtyped; cbn. iClear "HΓ".
iRevert "Hheap". iApply exist_elim; [|iExact "Hv"].
iIntros {l} "[% #Hv] #Hheap"; rewrite H.
iDestruct "Hv" as {l} "[% #Hv]"; subst.
iApply wp_atomic; cbn; eauto using to_of_val.
iPvsIntro.
iInv (L .@ l) as {w} "[Hw1 #Hw2]".
......@@ -188,8 +136,7 @@ Section typed_interp.
- (* Store *)
smart_wp_bind (StoreLCtx _) v "#Hv" IHHtyped1; cbn.
smart_wp_bind (StoreRCtx _) w "#Hw" IHHtyped2; cbn. iClear "HΓ".
iRevert "Hheap Hw". iApply exist_elim; [|iExact "Hv"].
iIntros {l} "#[% Hl] #Hheap #Hw"; rewrite H.
iDestruct "Hv" as {l} "[% #Hv]"; subst.
iApply wp_atomic; cbn; [trivial| rewrite ?to_of_val; auto |].
iPvsIntro.
iInv (L .@ l) as {z} "[Hz1 #Hz2]".
......@@ -197,13 +144,8 @@ Section typed_interp.
iApply (wp_store N); auto using to_of_val.
specialize (HNLdisj l); set_solver_ndisj.
iFrame "Hheap Hz1".
iNext.
iIntros "Hz1".
iIntros "> Hz1".
iSplitL; [|iPvsIntro; trivial].
iNext; iExists _. iFrame "Hz1"; trivial.
(* unshelving *)
Unshelve.
cbn; typeclasses eauto.
Qed.
End typed_interp.
\ No newline at end of file
End typed_interp.
......@@ -39,7 +39,6 @@ Module lang.
Instance Subst_expr : Subst expr. derive. Defined.
Instance SubstLemmas_expr : SubstLemmas expr. derive. Qed.
Global Instance expr_dec_eq (e e' : expr) : Decision (e = e').
Proof.
unfold Decision.
......@@ -297,6 +296,9 @@ other words, [e] also contains the reducible expression *)
head_step e1 σ1 e2 σ2 ef to_val e1 = None.
Proof. destruct 1; naive_solver. Qed.
Canonical Structure stateC := leibnizC state.
Canonical Structure valC := leibnizC val.
Canonical Structure exprC := leibnizC expr.
End lang.
(** Language *)
......@@ -326,4 +328,4 @@ Global Instance lang_ctx_item Ki :
LanguageCtx lang (lang.fill_item Ki).
Proof. change (LanguageCtx lang (lang.fill [Ki])). by apply _. Qed.
Export lang.
\ No newline at end of file
Export lang.
This diff is collapsed.
This diff is collapsed.
......@@ -9,14 +9,15 @@ Require Import iris.program_logic.adequacy.
Import uPred.
Section Soundness.
Definition Σ := #[ auth.authGF heapR ].
Definition Σ := #[ auth.authGF heapUR ].
Lemma empty_env_subst e : e.[env_subst []] = e.
Proof.
replace (env_subst []) with (@ids expr _) by reflexivity.
asimpl; trivial.
Qed.
Definition free_type_context: leibniz_var -n> leibniz_val -n> iPropG lang Σ :=
Definition free_type_context: varC -n> valC -n> iPropG lang Σ :=
{|
cofe_mor_car :=
λ x,
......@@ -32,9 +33,8 @@ Section Soundness.
Lemma wp_soundness e τ
: typed [] e τ
(ownership.ownP )
WP e {{v, H, @interp Σ H (nroot .@ "Fμ,ref" .@ 1)
τ free_type_context v}}.
ownership.ownP WP e {{v, H, @interp Σ H (nroot .@ "Fμ,ref" .@ 1)
τ free_type_context v}}.
Proof.
iIntros {H1} "Hemp".
iDestruct (heap_alloc (nroot .@ "Fμ,ref" .@ 2) _ _ _ _ with "Hemp") as "Hp".
......@@ -59,16 +59,15 @@ Section Soundness.
Proof.
intros H1 e' thp h Hstp Hnr.
eapply wp_soundness in H1; eauto.
edestruct(@wp_adequacy_reducible lang (globalF Σ)
edestruct (@wp_adequacy_reducible lang (globalF Σ)
(λ v, ( H : heapG Σ,
@interp Σ H (nroot .@ "Fμ,ref" .@ 1)
τ free_type_context v)%I)
e e' (e' :: thp) h)
as [Ha|Ha]; eauto; try tauto.
- apply cmra_unit_valid.
- apply ucmra_unit_valid.
- iIntros "[Hp Hg]". by iApply H1.
- by rewrite of_empty_heap in Hstp.
- constructor.
Qed.
End Soundness.
\ No newline at end of file
End Soundness.
......@@ -64,14 +64,13 @@ Proof.
Qed.
Definition env_subst (vs : list val) (x : var) : expr :=
from_option (Var x) (of_val <$> vs !! x).
from_option id (Var x) (of_val <$> vs !! x).
Notation "# v" := (of_val v) (at level 20).
Lemma typed_subst_head_simpl Δ τ e w ws :
typed Δ e τ -> List.length Δ = S (List.length ws)
e.[# w .: env_subst ws] = e.[env_subst (w :: ws)]
.
e.[# w .: env_subst ws] = e.[env_subst (w :: ws)].
Proof.
intros H1 H2.
rewrite /env_subst. eapply typed_subst_invariant; eauto=> /= -[|x] ? //=.
......@@ -79,7 +78,6 @@ Proof.
by rewrite Hv.
Qed.
Local Opaque eq_nat_dec.
Lemma iter_up_subst_type (m : nat) (τ : type) (x : var) :
......@@ -97,4 +95,4 @@ Proof.
rewrite IHm.
repeat destruct lt_dec; repeat destruct eq_nat_dec;
asimpl; auto with omega.
Qed.
\ No newline at end of file
Qed.
......@@ -287,5 +287,4 @@ Section bin_log_related_under_typed_context.
+ eapply typed_binary_interp_CAS; eauto using typed_binary_interp.
Unshelve. all: trivial.
Qed.
End bin_log_related_under_typed_context.
\ No newline at end of file
End bin_log_related_under_typed_context.
......@@ -30,13 +30,11 @@ Section CG_Counter.
Lemma steps_CG_increment N E ρ j K x n:
nclose N E
((Spec_ctx N ρ x ↦ₛ (v n)
j (fill K (App (CG_increment (Loc x)) Unit)))%I)
|={E}=>(j (fill K (Unit)) x ↦ₛ (v (S n)))%I.
Spec_ctx N ρ x ↦ₛ (v n) j fill K (App (CG_increment (Loc x)) Unit)
={E}=> j fill K (Unit) x ↦ₛ (v (S n)).
Proof.
intros HNE. iIntros "[#Hspec [Hx Hj]]". unfold CG_increment.
iIntros {HNE} "[#Hspec [Hx Hj]]". unfold CG_increment.
iPvs (step_lam _ _ _ j K _ _ _ _ with "[Hj]") as "Hj"; eauto.
iFrame "Hspec Hj"; trivial. simpl.
iPvs (step_load _ _ _ j (K ++ [StoreRCtx (LocV _); NBOPRCtx _ (v _)])
_ _ _ with "[Hj Hx]") as "[Hj Hx]"; eauto.
rewrite ?fill_app. simpl.
......@@ -98,17 +96,16 @@ Section CG_Counter.
Lemma steps_CG_locked_increment N E ρ j K x n l :
nclose N E
((Spec_ctx N ρ x ↦ₛ (v n) l ↦ₛ (v false)
j (fill K (App
(CG_locked_increment (Loc x) (Loc l)) Unit)))%I)
|={E}=>(j (fill K (Unit)) x ↦ₛ (v S n) l ↦ₛ (v false))%I.
Spec_ctx N ρ x ↦ₛ (v n) l ↦ₛ (v false)
j fill K (App
(CG_locked_increment (Loc x) (Loc l)) Unit)
={E}=> j fill K Unit x ↦ₛ (v S n) l ↦ₛ (v false).
Proof.
intros HNE. iIntros "[#Hspec [Hx [Hl Hj]]]".
iIntros {HNE} "[#Hspec [Hx [Hl Hj]]]".
iPvs (steps_with_lock
_ _ _ j K _ _ _ _ UnitV UnitV _ _ with "[Hj Hx Hl]") as "Hj"; eauto.
- intros K'.
iIntros "[#Hspec [Hx Hj]]".
iApply steps_CG_increment; eauto. iFrame "Hspec Hj Hx"; trivial.
_ _ _ 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.
- iFrame "Hspec Hj Hx"; trivial.
Unshelve. all: trivial.
Qed.
......@@ -145,13 +142,13 @@ Section CG_Counter.
Lemma steps_counter_read N E ρ j K x n :
nclose N E
((Spec_ctx N ρ x ↦ₛ (v n)
j (fill K (App (counter_read (Loc x)) Unit)))%I)
|={E}=>(j (fill K ( n)) x ↦ₛ (v n))%I.
Spec_ctx N ρ x ↦ₛ (v n)