Commit 1330e552 authored by Dan Frumin's avatar Dan Frumin

Make tp_ more general and rewrite fundamental_binary using tactics

Slightly generalize the way tac_tp_bind works and rewrite the
fundamental property for F_mu_ref_conc using tp_ tactics
parent 94117113
......@@ -94,7 +94,7 @@ Section fundamental.
smart_wp_bind (FstCtx) v v' "[Hv #Hiv]" ('IHHtyped _ _ _ j (K ++ [FstCtx])); cbn.
iDestruct "Hiv" as ([w1 w1'] [w2 w2']) "#[% [Hw1 Hw2]]"; simplify_eq.
iApply wp_fst; eauto. iNext.
tp_fst j; eauto.
tp_fst j; eauto. tp_normalise j. eauto.
Qed.
Lemma bin_log_related_snd Γ e e' τ1 τ2
......@@ -105,7 +105,7 @@ Section fundamental.
smart_wp_bind (SndCtx) v v' "[Hv #Hiv]" ('IHHtyped _ _ _ j (K ++ [SndCtx])); cbn.
iDestruct "Hiv" as ([w1 w1'] [w2 w2']) "#[% [Hw1 Hw2]]"; simplify_eq.
iApply wp_snd; eauto. iNext.
tp_snd j; eauto.
tp_snd j; eauto. tp_normalise j; eauto.
Qed.
Lemma bin_log_related_injl Γ e e' τ1 τ2
......@@ -147,14 +147,14 @@ Section fundamental.
iDestruct "Hiv" as "[Hiv|Hiv]";
iDestruct "Hiv" as ([w w']) "[% Hw]"; simplify_eq.
- iApply fupd_wp.
tp_case_inl j; eauto.
tp_case_inl j; eauto; tp_normalise j.
iApply wp_case_inl; eauto using to_of_val. fold 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.
- iApply fupd_wp.
tp_case_inr j; eauto.
tp_case_inr j; eauto; tp_normalise j.
iApply wp_case_inr; eauto using to_of_val. fold of_val. iNext.
asimpl. erewrite !n_closed_subst_head_simpl by (rewrite ?fmap_length; eauto).
iApply ('IHHtyped3 _ ((w,w') :: vvs)); repeat iSplit; eauto.
......@@ -171,9 +171,9 @@ Section fundamental.
smart_wp_bind (IfCtx _ _) v v' "[Hv #Hiv]"
('IHHtyped1 _ _ _ j (K ++ [IfCtx _ _])); cbn.
iDestruct "Hiv" as ([]) "[% %]"; simplify_eq/=; iApply fupd_wp.
- tp_if_true j; eauto.
- tp_if_true j; eauto; tp_normalise j.
iApply wp_if_true. iNext. iApply 'IHHtyped2; eauto.
- tp_if_false j; eauto.
- tp_if_false j; eauto; tp_normalise j.
iApply wp_if_false. iNext. iApply 'IHHtyped3; eauto.
Qed.
......@@ -190,7 +190,7 @@ Section fundamental.
iDestruct "Hiv" as (n) "[% %]"; simplify_eq/=.
iDestruct "Hiw" as (n') "[% %]"; simplify_eq/=.
iApply fupd_wp.
tp_nat_binop j; eauto.
tp_nat_binop j; eauto; tp_normalise j.
iApply wp_nat_binop. iNext. iModIntro. iExists _; iSplitL; eauto.
destruct op; simpl; try destruct eq_nat_dec; try destruct le_dec;
try destruct lt_dec; eauto.
......@@ -208,7 +208,7 @@ Section fundamental.
iDestruct (interp_env_length with "HΓ") as %?.
iApply wp_rec; auto 1 using to_of_val. iNext.
iApply fupd_wp.
tp_rec j'; eauto.
tp_rec j'; eauto; tp_normalise j'.
asimpl. change (Rec ?e) with (of_val (RecV e)).
erewrite !n_closed_subst_head_simpl_2 by (rewrite ?fmap_length; eauto).
iApply ('IHHtyped _ ((_,_) :: (v,v') :: vvs)); repeat iSplit; eauto.
......@@ -237,7 +237,7 @@ Section fundamental.
iIntros "{$Hj} /= !#"; iIntros (τi ? j' K') "Hv /=".
iApply wp_tlam; iNext.
iApply fupd_wp.
tp_tlam j'; eauto.
tp_tlam j'; eauto; tp_normalise j'.
iApply 'IHHtyped; repeat iSplit; eauto. by iApply interp_env_ren.
Qed.
......@@ -282,7 +282,7 @@ Section fundamental.
change (fixpoint _) with (interp (TRec τ) Δ).
iDestruct "Hiw" as ([w w']) "#[% Hiz]"; simplify_eq/=.
iApply fupd_wp.
tp_fold j; eauto.
tp_fold j; eauto; tp_normalise j.
iApply wp_fold; cbn; auto.
iNext; iModIntro. iExists _; iFrame. by rewrite -interp_subst.
Qed.
......@@ -293,7 +293,7 @@ Section fundamental.
Proof.
iIntros (Δ vvs ρ ?) "#(Hs & HΓ)"; iIntros (j K) "Hj /=".
iApply fupd_wp.
tp_fork j as i "Hi"; eauto.
tp_fork j as i "Hi"; eauto; tp_normalise j.
iApply wp_fork; iNext; iSplitL "Hj".
- iExists UnitV; eauto.
- iApply wp_wand_l; iSplitR; [|iApply ('IHHtyped _ _ _ _ [])]; eauto.
......@@ -306,14 +306,14 @@ Section fundamental.
iIntros (Δ vvs ρ ?) "#(Hs & HΓ)"; iIntros (j K) "Hj /=".
smart_wp_bind (AllocCtx) v v' "[Hv #Hiv]" ('IHHtyped _ _ _ j (K ++ [AllocCtx])).
iApply fupd_wp.
iMod (step_alloc _ _ j K (of_val v') v' with "* [-]") as (l') "[Hj Hl]"; eauto.
tp_alloc j as k "Hk"; eauto. tp_normalise j.
iApply wp_atomic; eauto.
iApply wp_alloc; eauto. iNext.
iIntros (l) "Hl'".
iMod (inv_alloc (logN .@ (l,l')) _ ( w : val * val,
l ↦ᵢ w.1 l' ↦ₛ w.2 interp τ Δ w)%I with "[Hl Hl']") as "HN"; eauto.
{ iNext. iExists (v, v'); iFrame. iFrame "Hiv". }
iModIntro; iExists (LocV l'). iFrame "Hj". iExists (l, l'); eauto.
iIntros (l) "Hl".
iMod (inv_alloc (logN .@ (l,k)) _ ( w : val * val,
l ↦ᵢ w.1 k ↦ₛ w.2 interp τ Δ w)%I with "[Hl Hk]") as "HN"; eauto.
{ iNext. iExists (v, v'); simpl; iFrame. iFrame "Hiv". }
iModIntro; iExists (LocV k). iFrame "Hv". iExists (l, k); eauto.
Qed.
Lemma bin_log_related_load Γ e e' τ
......@@ -329,7 +329,7 @@ Section fundamental.
iModIntro.
iApply (wp_load with "Hw1").
iNext. iIntros "Hw1".
tp_load j.
tp_load j; tp_normalise j.
iMod ("Hclose" with "[Hw1 Hw2]").
{ iNext. iExists (w,w'); by iFrame. }
iModIntro. iExists w'; by iFrame.
......@@ -351,7 +351,7 @@ Section fundamental.
iModIntro.
iApply (wp_store with "Hv1"); auto using to_of_val.
iNext. iIntros "Hw2".
tp_store j; eauto.
tp_store j; eauto; tp_normalise j.
iMod ("Hclose" with "[Hw2 Hv2]").
{ iNext; iExists (w, w'); simpl; iFrame. iFrame "Hiw". }
iExists UnitV; iFrame; auto.
......@@ -384,14 +384,16 @@ Section fundamental.
simpl. iApply (wp_cas_suc with "Hv1"); eauto using to_of_val.
iNext. iIntros "Hv1".
tp_cas_suc j; subst; eauto using to_of_val.
tp_normalise j.
iMod ("Hclose" with "[Hv1 Hv2]").
{ iNext; iExists (_, _); by iFrame. }
iExists (#v true); iFrame; eauto.
iExists (#v true). iFrame "Hu"; eauto.
- iAssert ( v' w'⌝)%I as ">%".
{ rewrite ?interp_EqType_agree; trivial. iSimplifyEq. auto. }
simpl. iApply (wp_cas_fail with "Hv1"); eauto.
iNext. iIntros "Hv1".
tp_cas_fail j; eauto.
tp_normalise j.
iMod ("Hclose" with "[Hv1 Hv2]").
{ iNext; iExists (_, _); by iFrame. }
iExists (#v false); eauto.
......
This diff is collapsed.
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