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

apply review feedback

parent 01fc1771
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ From iris.algebra Require Import auth excl gmap. ...@@ -2,7 +2,6 @@ From iris.algebra Require Import auth excl gmap.
From iris.base_logic.lib Require Import own invariants gen_heap. From iris.base_logic.lib Require Import own invariants gen_heap.
From iris.proofmode Require Import tactics. From iris.proofmode Require Import tactics.
Set Default Proof Using "Type". Set Default Proof Using "Type".
Import uPred.
(** A "GC" location is a location that can never be deallocated explicitly by (** A "GC" location is a location that can never be deallocated explicitly by
the program. It provides a persistent witness that will always allow reading the program. It provides a persistent witness that will always allow reading
...@@ -29,7 +28,7 @@ Definition gc_mapUR (L V : Type) `{Countable L} : ucmraT := gmapUR L $ prodR ...@@ -29,7 +28,7 @@ Definition gc_mapUR (L V : Type) `{Countable L} : ucmraT := gmapUR L $ prodR
(agreeR $ leibnizO (V Prop)). (agreeR $ leibnizO (V Prop)).
Definition to_gc_map {L V : Type} `{Countable L} (gcm: gmap L (V * (V Prop))) : gc_mapUR L V := Definition to_gc_map {L V : Type} `{Countable L} (gcm: gmap L (V * (V Prop))) : gc_mapUR L V :=
(λ p: V * (V Prop), (Excl' p.1, to_agree p.2)) <$> gcm. prod_map (λ x, Excl' x) to_agree <$> gcm.
Class gcG (L V : Type) (Σ : gFunctors) `{Countable L} := GcG { Class gcG (L V : Type) (Σ : gFunctors) `{Countable L} := GcG {
gc_inG :> inG Σ (authR (gc_mapUR L V)); gc_inG :> inG Σ (authR (gc_mapUR L V));
...@@ -52,18 +51,17 @@ Proof. solve_inG. Qed. ...@@ -52,18 +51,17 @@ Proof. solve_inG. Qed.
Section defs. Section defs.
Context {L V : Type} `{Countable L}. Context {L V : Type} `{Countable L}.
Context `{!invG Σ, !gen_heapG L V Σ, gG: !gcG L V Σ}. Context `{!invG Σ, !gen_heapG L V Σ, gG: !gcG L V Σ}.
Implicit Types (gcm : gmap L (V * (V Prop))) (l : L) (v : V) (I : V Prop).
Definition gc_inv_P : iProp Σ := Definition gc_inv_P : iProp Σ :=
( gcm, ( gcm : gmap L (V * (V Prop)),
own (gc_name gG) ( to_gc_map gcm) ([ map] l p gcm, p.2 p.1 (l p.1) ) )%I. own (gc_name gG) ( to_gc_map gcm) [ map] l p gcm, p.2 p.1 l p.1)%I.
Definition gc_inv : iProp Σ := inv gcN gc_inv_P. Definition gc_inv : iProp Σ := inv gcN gc_inv_P.
Definition gc_mapsto l v I : iProp Σ := Definition gc_mapsto (l : L) (v : V) (I : V Prop) : iProp Σ :=
own (gc_name gG) ( {[l := (Excl' v, to_agree I)]}). own (gc_name gG) ( {[l := (Excl' v, to_agree I)]}).
Definition is_gc_loc l I : iProp Σ := Definition is_gc_loc (l : L) (I : V Prop) : iProp Σ :=
own (gc_name gG) ( {[l := (None, to_agree I)]}). own (gc_name gG) ( {[l := (None, to_agree I)]}).
End defs. End defs.
...@@ -96,9 +94,10 @@ Section to_gc_map. ...@@ -96,9 +94,10 @@ Section to_gc_map.
Proof. by rewrite /to_gc_map lookup_fmap=> ->. Qed. Proof. by rewrite /to_gc_map lookup_fmap=> ->. Qed.
Lemma lookup_to_gc_map_Some_2 gcm l v' I' : Lemma lookup_to_gc_map_Some_2 gcm l v' I' :
to_gc_map gcm !! l Some (v', I') v I, v' Excl' v I' to_agree I /\ gcm !! l = Some (v, I). to_gc_map gcm !! l Some (v', I')
v I, v' Excl' v I' to_agree I gcm !! l = Some (v, I).
Proof. Proof.
rewrite /to_gc_map lookup_fmap. rewrite fmap_Some_equiv. rewrite /to_gc_map /prod_map lookup_fmap. rewrite fmap_Some_equiv.
intros ([] & Hsome & [Heqv HeqI]). eauto. intros ([] & Hsome & [Heqv HeqI]). eauto.
Qed. Qed.
End to_gc_map. End to_gc_map.
...@@ -111,12 +110,8 @@ Proof. ...@@ -111,12 +110,8 @@ Proof.
iModIntro. iModIntro.
iExists (GcG L V γ). iExists (GcG L V γ).
iAssert (gc_inv_P (gG := GcG L V γ)) with "[H●]" as "P". iAssert (gc_inv_P (gG := GcG L V γ)) with "[H●]" as "P".
{ { iExists _. iFrame. done. }
iExists _. iFrame. iApply (inv_alloc gcN E gc_inv_P with "P").
by iApply big_sepM_empty.
}
iMod ((inv_alloc gcN E gc_inv_P) with "P") as "#InvGC".
iModIntro. iFrame "#".
Qed. Qed.
Section gc. Section gc.
...@@ -139,20 +134,18 @@ Section gc. ...@@ -139,20 +134,18 @@ Section gc.
gc_inv L V -∗ l v ={E}=∗ gc_mapsto l v I. gc_inv L V -∗ l v ={E}=∗ gc_mapsto l v I.
Proof. Proof.
iIntros (HN HI) "#Hinv Hl". iIntros (HN HI) "#Hinv Hl".
iMod (inv_acc_timeless _ gcN _ with "Hinv") as "[P Hclose]"=>//. iMod (inv_acc_timeless _ gcN with "Hinv") as "[HP Hclose]"=>//.
iDestruct "P" as (gcm) "[H● HsepM]". iDestruct "HP" as (gcm) "[H● HsepM]".
destruct (gcm !! l) as [v' | ] eqn: Hlookup. destruct (gcm !! l) as [v' | ] eqn: Hlookup.
- (* auth map contains l --> contradiction *) - (* auth map contains l --> contradiction *)
iDestruct (big_sepM_lookup with "HsepM") as "[_ Hl']"=>//. iDestruct (big_sepM_lookup with "HsepM") as "[_ Hl']"=>//.
by iDestruct (mapsto_valid_2 with "Hl Hl'") as %?. by iDestruct (mapsto_valid_2 with "Hl Hl'") as %?.
- iMod (own_update with "H●") as "[H● H◯]". - iMod (own_update with "H●") as "[H● H◯]".
{ { apply lookup_to_gc_map_None in Hlookup.
apply lookup_to_gc_map_None in Hlookup.
apply (auth_update_alloc _ (to_gc_map (<[l := (v, I)]> gcm)) (to_gc_map ({[l := (v, I)]}))). apply (auth_update_alloc _ (to_gc_map (<[l := (v, I)]> gcm)) (to_gc_map ({[l := (v, I)]}))).
rewrite to_gc_map_insert to_gc_map_singleton. rewrite to_gc_map_insert to_gc_map_singleton.
pose proof (to_gc_map_valid gcm). pose proof (to_gc_map_valid gcm).
setoid_rewrite alloc_singleton_local_update=>//. setoid_rewrite alloc_singleton_local_update=>//. }
}
iMod ("Hclose" with "[H● HsepM Hl]"). iMod ("Hclose" with "[H● HsepM Hl]").
+ iExists _. + iExists _.
iDestruct (big_sepM_insert with "[HsepM Hl]") as "HsepM"=>//; iFrame. iDestruct (big_sepM_insert with "[HsepM Hl]") as "HsepM"=>//; iFrame.
...@@ -218,24 +211,22 @@ Section gc. ...@@ -218,24 +211,22 @@ Section gc.
(I v l v ( w, I w -∗ l w ==∗ gc_mapsto l w I |={E gcN, E}=> True)). (I v l v ( w, I w -∗ l w ==∗ gc_mapsto l w I |={E gcN, E}=> True)).
Proof. Proof.
iIntros (HN) "#Hinv". iIntros (HN) "#Hinv".
iMod (inv_acc_timeless _ gcN _ with "Hinv") as "[P Hclose]"=>//. iMod (inv_acc_timeless _ gcN _ with "Hinv") as "[HP Hclose]"=>//.
iIntros "!>" (l v I) "Hgc_l". iIntros "!>" (l v I) "Hgc_l".
iDestruct "P" as (gcm) "[H● HsepM]". iDestruct "HP" as (gcm) "[H● HsepM]".
iDestruct (gc_mapsto_lookup_Some with "Hgc_l H●") as %Hsome. iDestruct (gc_mapsto_lookup_Some with "Hgc_l H●") as %Hsome.
iDestruct (big_sepM_delete with "HsepM") as "[[HI Hl] HsepM]"=>//=. iDestruct (big_sepM_delete with "HsepM") as "[[HI Hl] HsepM]"=>//=.
iFrame. iIntros (w) "% Hl". iFrame. iIntros (w) "% Hl".
iMod (own_update_2 with "H● Hgc_l") as "[H● H◯]". iMod (own_update_2 with "H● Hgc_l") as "[H● H◯]".
{ apply (auth_update _ _ (<[l := (Excl' w, to_agree I)]> (to_gc_map gcm)) {[l := (Excl' w, to_agree I)]}). { apply (auth_update _ _ (<[l := (Excl' w, to_agree I)]> (to_gc_map gcm))
{[l := (Excl' w, to_agree I)]}).
apply: singleton_local_update. apply: singleton_local_update.
{ by apply lookup_to_gc_map_Some in Hsome. } { by apply lookup_to_gc_map_Some in Hsome. }
apply prod_local_update; simpl. apply: prod_local_update_1. apply: option_local_update.
- apply: option_local_update. apply: exclusive_local_update. done. apply: exclusive_local_update. done. }
- done.
}
iDestruct (big_sepM_insert _ _ _ (w, I) with "[Hl HsepM]") as "HsepM"; [ | by iFrame | ]. iDestruct (big_sepM_insert _ _ _ (w, I) with "[Hl HsepM]") as "HsepM"; [ | by iFrame | ].
{ apply lookup_delete. } { apply lookup_delete. }
rewrite insert_delete. rewrite <- to_gc_map_insert. rewrite insert_delete -to_gc_map_insert. iModIntro. iFrame.
iModIntro. iFrame.
iMod ("Hclose" with "[H● HsepM]"); [ iExists _; by iFrame | by iModIntro]. iMod ("Hclose" with "[H● HsepM]"); [ iExists _; by iFrame | by iModIntro].
Qed. Qed.
...@@ -245,17 +236,16 @@ Section gc. ...@@ -245,17 +236,16 @@ Section gc.
v, I v l v (l v ={E gcN, E}=∗ True). v, I v l v (l v ={E gcN, E}=∗ True).
Proof. Proof.
iIntros (HN) "#Hinv Hgc_l". iIntros (HN) "#Hinv Hgc_l".
iMod (inv_acc_timeless _ gcN _ with "Hinv") as "[P Hclose]"=>//. iMod (inv_acc_timeless _ gcN _ with "Hinv") as "[HP Hclose]"=>//.
iModIntro. iModIntro.
iDestruct "P" as (gcm) "[H● HsepM]". iDestruct "HP" as (gcm) "[H● HsepM]".
iDestruct (is_gc_lookup_Some with "Hgc_l H●") as %Hsome. iDestruct (is_gc_lookup_Some with "Hgc_l H●") as %[v Hsome].
destruct Hsome as [v Hsome].
iDestruct (big_sepM_lookup_acc with "HsepM") as "[[#HI Hl] HsepM]"=>//. iDestruct (big_sepM_lookup_acc with "HsepM") as "[[#HI Hl] HsepM]"=>//.
iExists _. iFrame "∗#". iExists _. iFrame "∗#".
iIntros "Hl". iIntros "Hl".
iMod ("Hclose" with "[H● HsepM Hl]"); last done. iMod ("Hclose" with "[H● HsepM Hl]"); last done.
iExists _. iFrame. iExists _. iFrame.
iApply ("HsepM" with "[Hl]"). by iFrame. iApply ("HsepM" with "[$Hl //]").
Qed. Qed.
End gc. End gc.
......
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