Skip to content
Snippets Groups Projects
Commit 36ea1a45 authored by Ralf Jung's avatar Ralf Jung
Browse files

prove dereferencing borrowed unique pointers

parent ae6b60a0
No related branches found
No related tags found
No related merge requests found
...@@ -68,19 +68,18 @@ Section borrow. ...@@ -68,19 +68,18 @@ Section borrow.
rewrite tctx_interp_singleton tctx_hasty_val' //. iExists _. auto. rewrite tctx_interp_singleton tctx_hasty_val' //. iExists _. auto.
Qed. Qed.
Lemma type_deref_uniq_uniq E L κ κ' p ty :
(* Old Typing *) lctx_lft_alive E L κ lctx_lft_incl E L κ κ'
Lemma typed_deref_uniq_bor_bor ty ν κ κ' κ'' q: typed_instruction_ty E L [TCtx_hasty p (&uniq{κ} &uniq{κ'} ty)] (!p)
typed_step (ν &uniq{κ'} &uniq{κ''} ty κ κ' q.[κ] κ' κ'') (&uniq{κ} ty).
(!ν)
(λ v, v &uniq{κ'} ty κ κ' q.[κ])%P.
Proof. Proof.
iIntros (tid) "!#(#HEAP & #LFT & (H◁ & #H⊑1 & Htok & #H⊑2) & $)". wp_bind ν. iIntros ( Hincl tid eq) "#HEAP #LFT $ HE HL Hp". rewrite tctx_interp_singleton.
iApply (has_type_wp with "H◁"). iIntros (v) "Hνv H◁!>". iDestruct "Hνv" as %Hνv. iPoseProof (Hincl with "[#] [#]") as "Hincl".
rewrite has_type_value. iDestruct "H◁" as (l P) "[[Heq #HPiff] HP]". { by iApply elctx_interp_persist. } { by iApply llctx_interp_persist. }
iDestruct "Heq" as %[=->]. iMod ( with "HE HL") as (q) "[Htok Hclose]"; first set_solver.
wp_bind p. iApply (wp_hasty with "Hp"). iIntros (v) "_ Hown".
iDestruct "Hown" as (l P) "[[Heq #HPiff] HP]". iDestruct "Heq" as %[=->].
iMod (bor_iff with "LFT [] HP") as "H↦". set_solver. by eauto. iMod (bor_iff with "LFT [] HP") as "H↦". set_solver. by eauto.
iMod (lft_incl_acc with "H⊑1 Htok") as (q'') "[Htok Hclose]". done.
iMod (bor_exists with "LFT H↦") as (vl) "Hbor". done. iMod (bor_exists with "LFT H↦") as (vl) "Hbor". done.
iMod (bor_sep with "LFT Hbor") as "[H↦ Hbor]". done. iMod (bor_sep with "LFT Hbor") as "[H↦ Hbor]". done.
iMod (bor_exists with "LFT Hbor") as (l') "Hbor". done. iMod (bor_exists with "LFT Hbor") as (l') "Hbor". done.
...@@ -91,34 +90,38 @@ Section borrow. ...@@ -91,34 +90,38 @@ Section borrow.
rewrite heap_mapsto_vec_singleton. rewrite heap_mapsto_vec_singleton.
iApply (wp_fupd_step _ (⊤∖↑lftN) with "[Hbor]"); try done. iApply (wp_fupd_step _ (⊤∖↑lftN) with "[Hbor]"); try done.
by iApply (bor_unnest with "LFT Hbor"). by iApply (bor_unnest with "LFT Hbor").
wp_read. iIntros "!> Hbor". iFrame "#". iSplitL "Hbor". wp_read. iIntros "!> Hbor". iFrame "#".
- iExists _, _. iSplitR. by auto. iMod ("Hclose'" with "[H↦]") as "[H↦ Htok]"; first by auto.
iApply (bor_shorten with "[] Hbor"). iMod ("Hclose" with "Htok") as "($ & $)".
iApply (lft_incl_glb with "H⊑2"). iApply lft_incl_refl. rewrite tctx_interp_singleton tctx_hasty_val' //.
- iApply ("Hclose" with ">"). by iMod ("Hclose'" with "[$H↦]") as "[_ $]". iExists _, _. iSplitR; first by auto.
iApply (bor_shorten with "[] Hbor").
iApply (lft_incl_glb with "Hincl"). iApply lft_incl_refl.
Qed. Qed.
Lemma typed_deref_shr_bor_bor ty ν κ κ' κ'' q: Lemma type_deref_shr_uniq E L κ κ' p ty :
typed_step (ν &shr{κ'} &uniq{κ''} ty κ κ' q.[κ] κ' κ'') lctx_lft_alive E L κ lctx_lft_incl E L κ κ'
(!ν) typed_instruction_ty E L [TCtx_hasty p (&shr{κ} &uniq{κ'} ty)] (!p)
(λ v, v &shr{κ'} ty κ κ' q.[κ])%P. (&shr{κ} ty).
Proof. Proof.
iIntros (tid) "!#(#HEAP & #LFT & (H◁ & #H⊑1 & [Htok1 Htok2] & #H⊑2) & $)". wp_bind ν. iIntros ( Hincl tid eq) "#HEAP #LFT $ HE HL Hp". rewrite tctx_interp_singleton.
iApply (has_type_wp with "H◁"). iIntros (v) "Hνv H◁!>". iDestruct "Hνv" as %Hνv. iPoseProof (Hincl with "[#] [#]") as "Hincl".
rewrite has_type_value. iDestruct "H◁" as (l) "[Heq Hshr]". { by iApply elctx_interp_persist. } { by iApply llctx_interp_persist. }
iMod ( with "HE HL") as (q) "[[Htok1 Htok2] Hclose]"; first set_solver.
wp_bind p. iApply (wp_hasty with "Hp"). iIntros (v) "_ Hown".
iDestruct "Hown" as (l) "[Heq Hshr]".
iDestruct "Heq" as %[=->]. iDestruct "Hshr" as (l') "[H↦ Hown]". iDestruct "Heq" as %[=->]. iDestruct "Hshr" as (l') "[H↦ Hown]".
iMod (lft_incl_acc with "H⊑1 Htok1") as (q') "[Htok1 Hclose]". done.
iMod (frac_bor_acc with "LFT H↦ Htok1") as (q'') "[>H↦ Hclose']". done. iMod (frac_bor_acc with "LFT H↦ Htok1") as (q'') "[>H↦ Hclose']". done.
iAssert (κ' κ'' κ')%I as "#H⊑3". iAssert (κ κ' κ)%I as "#Hincl'".
{ iApply (lft_incl_glb with "H⊑2 []"). iApply lft_incl_refl. } { iApply (lft_incl_glb with "Hincl []"). iApply lft_incl_refl. }
iMod (lft_incl_acc with "[] Htok2") as (q2) "[Htok2 Hclose'']". solve_ndisj. iMod (lft_incl_acc with "Hincl' Htok2") as (q2) "[Htok2 Hclose'']". solve_ndisj.
{ iApply (lft_incl_trans with "[]"); done. }
iApply (wp_fupd_step _ (_∖_) with "[Hown Htok2]"); try done. iApply (wp_fupd_step _ (_∖_) with "[Hown Htok2]"); try done.
- iApply ("Hown" with "* [%] Htok2"). set_solver+. - iApply ("Hown" with "* [%] Htok2"). set_solver+.
- wp_read. iIntros "!>[#Hshr Htok2]{$H⊑1}". - wp_read. iIntros "!>[#Hshr Htok2]". iMod ("Hclose''" with "Htok2") as "Htok2".
iMod ("Hclose''" with "Htok2") as "$". iSplitR. iMod ("Hclose'" with "[H↦]") as "Htok1"; first by auto.
* iExists _. iSplitR. done. by iApply (ty_shr_mono with "LFT H⊑3 Hshr"). iMod ("Hclose" with "[Htok1 Htok2]") as "($ & $)"; first by iFrame.
* iApply ("Hclose" with ">"). iApply ("Hclose'" with "[$H↦]"). rewrite tctx_interp_singleton tctx_hasty_val' //.
iExists _. iSplitR. done. by iApply (ty_shr_mono with "LFT Hincl' Hshr").
Qed. Qed.
End borrow. End borrow.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment