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

Merge branch 'atomic_lft_promotion' into 'master'

Expose atomic lifetimes in the API, end many in a single step

See merge request !37
parents 1a1d47a7 ff921b62
Branches
No related tags found
1 merge request!37Expose atomic lifetimes in the API, end many in a single step
Pipeline #115009 passed
...@@ -29,14 +29,31 @@ Section derived. ...@@ -29,14 +29,31 @@ Section derived.
Context `{!invGS Σ, !lftGS Σ userE}. Context `{!invGS Σ, !lftGS Σ userE}.
Implicit Types κ : lft. Implicit Types κ : lft.
Lemma lft_kill_atomic (Λ : atomic_lft) :
lft_ctx -∗ (1.[@Λ] ={lftN userE}[userE]▷=∗ [@Λ]).
Proof.
iIntros "#LFT".
rewrite -(big_sepS_singleton (λ x, 1.[@x])%I)
-(big_sepS_singleton (λ x, [@x])%I).
by iApply (lft_kill_atomics with "LFT").
Qed.
Lemma lft_create_atomic E :
lftN E
lft_ctx ={E}=∗ Λ, 1.[@Λ].
Proof.
iIntros (?) "#LFT".
iMod (lft_create_strong (λ _, True) with "LFT") as (κ _) "$"=>//.
by apply pred_infinite_True.
Qed.
Lemma lft_create E : Lemma lft_create E :
lftN E lftN E
lft_ctx ={E}=∗ κ, 1.[κ] (1.[κ] ={lftN userE}[userE]▷=∗ [κ]). lft_ctx ={E}=∗ κ, 1.[κ] (1.[κ] ={lftN userE}[userE]▷=∗ [κ]).
Proof. Proof.
iIntros (?) "#LFT". iIntros (?) "#LFT".
iMod (lft_create_strong (λ _, True) with "LFT") as (κ _) "H"=>//; iMod (lft_create_atomic with "LFT") as "[% $]"=>//.
[by apply pred_infinite_True|]. by iApply lft_kill_atomic.
by auto.
Qed. Qed.
(* Deriving this just to prove that it can be derived. (* Deriving this just to prove that it can be derived.
......
...@@ -38,15 +38,22 @@ Module Type lifetime_sig. ...@@ -38,15 +38,22 @@ Module Type lifetime_sig.
Parameter idx_bor_own : `{!lftGS Σ userE} (q : frac) (i : bor_idx), iProp Σ. Parameter idx_bor_own : `{!lftGS Σ userE} (q : frac) (i : bor_idx), iProp Σ.
Parameter idx_bor : `{!invGS Σ, !lftGS Σ userE} (κ : lft) (i : bor_idx) (P : iProp Σ), iProp Σ. Parameter idx_bor : `{!invGS Σ, !lftGS Σ userE} (κ : lft) (i : bor_idx) (P : iProp Σ), iProp Σ.
Parameter atomic_lft : Type.
Parameter atomic_lft_to_lft : atomic_lft lft.
(** Our lifetime creation lemma offers allocating a lifetime that is defined (** Our lifetime creation lemma offers allocating a lifetime that is defined
by a [positive] in some given infinite set. This operation converts the by a [positive] in some given infinite set. This operation converts the
[positive] to a lifetime. *) [positive] to an atomic lifetime. *)
Parameter positive_to_lft : positive lft. Parameter positive_to_atomic_lft : positive atomic_lft.
Notation positive_to_lft p := (atomic_lft_to_lft (positive_to_atomic_lft p)).
(** * Notation *) (** * Notation *)
Notation "q .[ κ ]" := (lft_tok q κ) Notation "q .[ κ ]" := (lft_tok q κ)
(format "q .[ κ ]", at level 2, left associativity) : bi_scope. (format "q .[ κ ]", at level 2, left associativity) : bi_scope.
Notation "q .[@ Λ ]" := (lft_tok q (atomic_lft_to_lft Λ))
(format "q .[@ Λ ]", at level 2, left associativity) : bi_scope.
Notation "[† κ ]" := (lft_dead κ) (format "[† κ ]"): bi_scope. Notation "[† κ ]" := (lft_dead κ) (format "[† κ ]"): bi_scope.
Notation "[†@ Λ ]" := (lft_dead (atomic_lft_to_lft Λ)) (format "[†@ Λ ]"): bi_scope.
Notation "&{ κ }" := (bor κ) (format "&{ κ }") : bi_scope. Notation "&{ κ }" := (bor κ) (format "&{ κ }") : bi_scope.
Notation "&{ κ , i }" := (idx_bor κ i) (format "&{ κ , i }") : bi_scope. Notation "&{ κ , i }" := (idx_bor κ i) (format "&{ κ , i }") : bi_scope.
...@@ -100,7 +107,11 @@ Module Type lifetime_sig. ...@@ -100,7 +107,11 @@ Module Type lifetime_sig.
FrameFractionalQp q1 q2 q FrameFractionalQp q1 q2 q
Frame p (idx_bor_own q1 i) (idx_bor_own q2 i) (idx_bor_own q i) | 5. Frame p (idx_bor_own q1 i) (idx_bor_own q2 i) (idx_bor_own q i) | 5.
Global Declare Instance positive_to_lft_inj : Inj eq eq positive_to_lft. Global Declare Instance atomic_lft_to_lft_inj : Inj eq eq atomic_lft_to_lft.
Global Declare Instance positive_to_atomic_lft_inj : Inj eq eq positive_to_atomic_lft.
Global Declare Instance atomic_lft_eq_dec : EqDecision atomic_lft.
Global Declare Instance atomic_lft_countable : Countable atomic_lft.
(** * Laws *) (** * Laws *)
Parameter lft_tok_sep : q κ1 κ2, q.[κ1] q.[κ2] ⊣⊢ q.[κ1 κ2]. Parameter lft_tok_sep : q κ1 κ2, q.[κ1] q.[κ2] ⊣⊢ q.[κ1 κ2].
...@@ -116,14 +127,15 @@ Module Type lifetime_sig. ...@@ -116,14 +127,15 @@ Module Type lifetime_sig.
[atomic_to_lft] might well not be infinite. *) [atomic_to_lft] might well not be infinite. *)
Parameter lft_create_strong : P E, pred_infinite P lftN E Parameter lft_create_strong : P E, pred_infinite P lftN E
lft_ctx ={E}=∗ lft_ctx ={E}=∗
p : positive, let κ := positive_to_lft p in P p p : positive, let Λ := positive_to_atomic_lft p in P p (1).[@Λ].
(1).[κ] ((1).[κ] ={lftN userE}[userE]▷=∗ [κ]).
(** Given two lifetimes [κ] and [κ'], find a lower bound on atomic lifetimes [m] (** Given two lifetimes [κ] and [κ'], find a lower bound on atomic lifetimes [m]
such that [m ⊓ κ'] is syntactically different from [κ]. such that [m ⊓ κ'] is syntactically different from [κ].
This is useful in conjunction with [lft_create_strong] to generate This is useful in conjunction with [lft_create_strong] to generate
fresh lifetimes when using lifetimes as keys to index into a map. *) fresh lifetimes when using lifetimes as keys to index into a map. *)
Parameter lft_fresh : κ κ', i : positive, Parameter lft_fresh : κ κ', i : positive,
m : positive, (i < m)%positive (positive_to_lft m) κ' κ. m : positive, (i < m)%positive (positive_to_lft m) κ' κ.
Parameter lft_kill_atomics : Λs,
lft_ctx -∗ (([ set] Λ Λs, (1).[@Λ]) ={lftN userE}[userE]▷=∗ [ set] ΛΛs, [@Λ]).
Parameter bor_create : E κ P, Parameter bor_create : E κ P,
lftN E lft_ctx -∗ P ={E}=∗ &{κ} P ([κ] ={E}=∗ P). lftN E lft_ctx -∗ P ={E}=∗ &{κ} P ([κ] ={E}=∗ P).
......
...@@ -44,6 +44,7 @@ Section lft_meta. ...@@ -44,6 +44,7 @@ Section lft_meta.
as (? [Etok [Hinf ->]]) "Hown". as (? [Etok [Hinf ->]]) "Hown".
iMod (lft_create_strong (. Etok) with "LFT") as (p HEtok) "Hκ"; [done..|]. iMod (lft_create_strong (. Etok) with "LFT") as (p HEtok) "Hκ"; [done..|].
iExists (positive_to_lft p). iFrame "Hκ". iExists (positive_to_lft p). iFrame "Hκ".
iDestruct (lft_kill_atomic with "LFT") as "$".
iMod (own_update with "Hown") as "Hown". iMod (own_update with "Hown") as "Hown".
{ eapply (dyn_reservation_map_alloc _ p (to_agree γ)); done. } { eapply (dyn_reservation_map_alloc _ p (to_agree γ)); done. }
iModIntro. iExists p. eauto. iModIntro. iExists p. eauto.
...@@ -55,7 +56,7 @@ Section lft_meta. ...@@ -55,7 +56,7 @@ Section lft_meta.
iIntros "Hidx1 Hidx2". iIntros "Hidx1 Hidx2".
iDestruct "Hidx1" as (p1) "(% & Hidx1)". subst κ. iDestruct "Hidx1" as (p1) "(% & Hidx1)". subst κ.
iDestruct "Hidx2" as (p2) "(Hlft & Hidx2)". iDestruct "Hidx2" as (p2) "(Hlft & Hidx2)".
iDestruct "Hlft" as %<-%(inj positive_to_lft). iDestruct "Hlft" as %<-%(inj atomic_lft_to_lft)%(inj positive_to_atomic_lft).
iCombine "Hidx1 Hidx2" as "Hidx". iCombine "Hidx1 Hidx2" as "Hidx".
iDestruct (own_valid with "Hidx") as %Hval. iDestruct (own_valid with "Hidx") as %Hval.
rewrite ->(dyn_reservation_map_data_valid (A:=agreeR gnameO)) in Hval. rewrite ->(dyn_reservation_map_data_valid (A:=agreeR gnameO)) in Hval.
......
...@@ -107,41 +107,46 @@ Definition kill_set (I : gmap lft lft_names) (Λ : atomic_lft) : gset lft := ...@@ -107,41 +107,46 @@ Definition kill_set (I : gmap lft lft_names) (Λ : atomic_lft) : gset lft :=
Lemma elem_of_kill_set I Λ κ : κ kill_set I Λ Λ κ is_Some (I !! κ). Lemma elem_of_kill_set I Λ κ : κ kill_set I Λ Λ κ is_Some (I !! κ).
Proof. by rewrite /kill_set elem_of_filter elem_of_dom. Qed. Proof. by rewrite /kill_set elem_of_filter elem_of_dom. Qed.
Lemma lft_create_strong P E : Lemma lupd_gmap_mass_insert (Λs : gset atomic_lft) (m : alftUR) (x y : lft_stateR) `{!Exclusive x} : y
pred_infinite P lftN E (m, gset_to_gmap x Λs) ~l~> (gset_to_gmap y Λs m, gset_to_gmap y Λs).
lft_ctx ={E}=∗
p : positive, let κ := positive_to_lft p in P p
(1).[κ] ((1).[κ] ={lftN userE}[userE]▷=∗ [κ]).
Proof. Proof.
assert (userE_lftN_disj:=userE_lftN_disj). iIntros (HP ?) "#LFT". intros ?.
iInv mgmtN as (A I) "(>HA & >HI & Hinv)" "Hclose". apply gmap_local_update.
rewrite ->(pred_infinite_set (C:=gset _)) in HP. intros Λ; destruct (m !! Λ) as [|] eqn:He1, (decide (Λ Λs)) as [|].
destruct (HP (dom A)) as [Λ [HPx %not_elem_of_dom]]. - rewrite lookup_union_l' !lookup_gset_to_gmap !option_guard_True // He1.
iMod (own_update with "HA") as "[HA HΛ]". by apply option_local_update, exclusive_local_update.
{ apply auth_update_alloc, (alloc_singleton_local_update _ Λ (Cinl 1%Qp))=>//. - rewrite lookup_union_r !lookup_gset_to_gmap !option_guard_False //= He1 //.
by rewrite lookup_fmap . } - rewrite lookup_union_l' !lookup_gset_to_gmap !option_guard_True // He1.
iMod ("Hclose" with "[HA HI Hinv]") as "_". by apply alloc_option_local_update.
{ iNext. rewrite /lfts_inv /own_alft_auth. - rewrite lookup_union_r !lookup_gset_to_gmap !option_guard_False //= He1 //.
iExists (<[Λ:=true]>A), I. rewrite /to_alftUR fmap_insert; iFrame. Qed.
iApply (@big_sepS_impl with "[$Hinv]").
iModIntro. rewrite /lft_inv. iIntros (κ ?) "[[Hκ %]|[Hκ %]]". Lemma lft_kill_atomics (Λs : gset atomic_lft) :
- iLeft. iFrame "Hκ". iPureIntro. by apply lft_alive_in_insert. lft_ctx -∗
- iRight. iFrame "Hκ". iPureIntro. by apply lft_dead_in_insert. } (([ set] ΛΛs, 1.[@Λ]) ={lftN userE}[userE]▷=∗
iModIntro; iExists Λ. ([ set] ΛΛs, [@Λ])).
rewrite {1}/lft_tok big_sepMS_singleton. iSplit; first done. iFrame "HΛ". Proof.
clear I A HPx HP. assert (userE_lftN_disj:=userE_lftN_disj). iIntros "#LFT !> HΛs".
(* From here on, we are proving that an atomic lifetime can be ended. *) destruct (decide (Λs = )) as [->|Hne].
iIntros "!> HΛ". { rewrite !big_sepS_empty.
iApply fupd_mask_intro; [set_solver|iIntros "$"].
}
iApply (step_fupd_mask_mono (lftN userE) _ ((lftN userE)∖↑mgmtN)); [solve_ndisj..|]. iApply (step_fupd_mask_mono (lftN userE) _ ((lftN userE)∖↑mgmtN)); [solve_ndisj..|].
iInv mgmtN as (A I) "(>HA & >HI & Hinv)" "Hclose". iInv mgmtN as (A I) "(>HA & >HI & Hinv)" "Hclose".
rewrite /lft_tok big_sepMS_singleton. rewrite /lft_tok.
iDestruct (own_valid_2 with "HA HΛ") iAssert (own alft_name ( gset_to_gmap (Cinl 1%Qp) Λs))%I with "[HΛs]" as "HΛs".
as %[[s [?%leibniz_equiv ?]]%singleton_included_l _]%auth_both_valid_discrete. { setoid_rewrite big_sepMS_singleton.
iMod (own_update_2 with "HA HΛ") as "[HA HΛ]". iDestruct (big_opS_own _ _ _ Hne with "HΛs") as "HΛs".
{ by eapply auth_update, singleton_local_update, rewrite -(big_opS_gset_to_gmap Λs (Cinl 1%Qp)) big_opS_auth_frag //. }
(exclusive_local_update _ (Cinr ())). } iDestruct (own_valid_2 with "HA HΛs")
iDestruct "HΛ" as "#HΛ". iModIntro; iNext. (* This is THE step *) as %[[s Hs] _]%auth_both_valid_discrete.
pose (K := kill_set I Λ). iMod (own_update_2 with "HA HΛs") as "[HA HΛs]".
{ eapply auth_update.
by apply (lupd_gmap_mass_insert Λs _ _ (Cinr ())). }
rewrite -[in own alft_name ( _)]big_opS_gset_to_gmap big_opS_auth_frag big_opS_own //.
iDestruct "HΛs" as "#HΛs".
iModIntro; iNext.
pose (K := set_bind (λ Λ, kill_set I Λ) Λs).
pose (K' := filter (lft_alive_in A) (dom I) K). pose (K' := filter (lft_alive_in A) (dom I) K).
destruct (proj1 (subseteq_disjoint_union_L (K K') (dom I))) as (K''&HI&HK''). destruct (proj1 (subseteq_disjoint_union_L (K K') (dom I))) as (K''&HI&HK'').
{ set_solver+. } { set_solver+. }
...@@ -153,40 +158,70 @@ Proof. ...@@ -153,40 +158,70 @@ Proof.
by iApply lft_inv_alive_in. } by iApply lft_inv_alive_in. }
iAssert ([ set] κ K, lft_inv A κ [ κ])%I with "[HinvK]" as "HinvK". iAssert ([ set] κ K, lft_inv A κ [ κ])%I with "[HinvK]" as "HinvK".
{ iApply (@big_sepS_impl with "[$HinvK]"); iIntros "!>". { iApply (@big_sepS_impl with "[$HinvK]"); iIntros "!>".
iIntros (κ [? _]%elem_of_kill_set) "$". rewrite /lft_dead. eauto. } iIntros (κ [Λ [ [? _]%elem_of_kill_set]]%elem_of_set_bind) "$".
rewrite /lft_dead.
by iDestruct (big_sepS_elem_of with "HΛs") as "$". }
iApply fupd_trans. iApply fupd_trans.
iApply (fupd_mask_mono (userE borN inhN)); first solve_ndisj. iApply (fupd_mask_mono (userE borN inhN)); first solve_ndisj.
iMod (lfts_kill A I K K' with "[$HI $HinvD] HinvK") as "[[HI HinvD] HinvK]". iMod (lfts_kill A I K K' with "[$HI $HinvD] HinvK") as "[[HI HinvD] HinvK]".
{ done. } { done. }
{ intros κ κ' [??]%elem_of_kill_set ??. apply elem_of_kill_set. { intros κ κ' [Λ [? [??]%elem_of_kill_set]]%elem_of_set_bind ??.
apply elem_of_set_bind; exists Λ; split; [assumption|].
apply elem_of_kill_set.
split; last done. by eapply gmultiset_elem_of_subseteq. } split; last done. by eapply gmultiset_elem_of_subseteq. }
{ intros κ ???. rewrite elem_of_difference elem_of_filter elem_of_dom. auto. } { intros κ ???. rewrite elem_of_difference elem_of_filter elem_of_dom. auto. }
iModIntro. iMod ("Hclose" with "[-]") as "_"; last first. iModIntro. iMod ("Hclose" with "[-]") as "_"; last first.
{ iModIntro. rewrite /lft_dead. iExists Λ. { iModIntro.
iApply (big_sepS_impl with "HΛs").
iIntros "!>" (Λ) "??".
rewrite /lft_dead. iExists Λ.
rewrite gmultiset_elem_of_singleton. auto. } rewrite gmultiset_elem_of_singleton. auto. }
iNext. iExists (<[Λ:=false]>A), I. iNext. iExists ((gset_to_gmap false Λs A) : gmap atomic_lft bool), I.
rewrite /own_alft_auth /to_alftUR fmap_insert. iFrame "HA HI". rewrite /own_alft_auth /to_alftUR map_fmap_union fmap_gset_to_gmap.
iFrame "HA HI".
rewrite HI !big_sepS_union //. rewrite HI !big_sepS_union //.
iSplitL "HinvK HinvD"; first iSplitL "HinvK". iSplitL "HinvK HinvD"; first iSplitL "HinvK".
- iApply (@big_sepS_impl with "[$HinvK]"); iIntros "!>". - iApply (@big_sepS_impl with "[$HinvK]"); iIntros "!>".
iIntros (κ [? _]%elem_of_kill_set) "Hdead". rewrite /lft_inv. iIntros (κ [Λ [? [? _]%elem_of_kill_set]]%elem_of_set_bind) "Hdead". rewrite /lft_inv.
iRight. iFrame. iPureIntro. by apply lft_dead_in_insert_false'. iRight. iFrame. iPureIntro. by eapply lft_dead_in_union_false'.
- iApply (@big_sepS_impl with "[$HinvD]"); iIntros "!>". - iApply (@big_sepS_impl with "[$HinvD]"); iIntros "!>".
iIntros (κ [[ HκI]%elem_of_filter HκK]%elem_of_difference) "Halive". iIntros (κ [[ HκI]%elem_of_filter HκK]%elem_of_difference) "Halive".
rewrite /lft_inv. iLeft. iFrame "Halive". iPureIntro. rewrite /lft_inv. iLeft. iFrame "Halive". iPureIntro.
apply lft_alive_in_insert_false; last done. apply lft_alive_in_union_false; [|done].
move: HκK. rewrite elem_of_kill_set -(elem_of_dom (D:=gset lft)). set_solver +HκI. set_solver.
- iApply (@big_sepS_impl with "[$Hinv]"); iIntros "!>". - iApply (@big_sepS_impl with "[$Hinv]"); iIntros "!>".
rewrite /lft_inv. iIntros (κ ) "[[? %]|[? %]]". rewrite /lft_inv. iIntros (κ ) "[[? %]|[? %]]".
+ iLeft. iFrame. iPureIntro. + iLeft. iFrame. iPureIntro.
apply lft_alive_in_insert_false; last done. intros ?. apply lft_alive_in_union_false; last done. intros ??.
assert (κ K) by (rewrite elem_of_kill_set -(elem_of_dom (D:=gset lft)) HI elem_of_union; auto). set_solver.
eapply HK'', . rewrite elem_of_union. auto. + iRight. iFrame. iPureIntro. by apply lft_dead_in_union_false.
+ iRight. iFrame. iPureIntro. by apply lft_dead_in_insert_false. Qed.
Lemma lft_create_strong P E :
pred_infinite P lftN E
lft_ctx ={E}=∗
p : positive, let Λ := positive_to_atomic_lft p in P p (1).[@Λ].
Proof.
assert (userE_lftN_disj:=userE_lftN_disj). iIntros (HP ?) "#LFT".
iInv mgmtN as (A I) "(>HA & >HI & Hinv)" "Hclose".
rewrite ->(pred_infinite_set (C:=gset _)) in HP.
destruct (HP (dom A)) as [Λ [HPx %not_elem_of_dom]].
iMod (own_update with "HA") as "[HA HΛ]".
{ apply auth_update_alloc, (alloc_singleton_local_update _ Λ (Cinl 1%Qp))=>//.
by rewrite lookup_fmap . }
iMod ("Hclose" with "[HA HI Hinv]") as "_".
{ iNext. rewrite /lfts_inv /own_alft_auth.
iExists (<[Λ:=true]>A), I. rewrite /to_alftUR fmap_insert; iFrame.
iApply (@big_sepS_impl with "[$Hinv]").
iModIntro. rewrite /lft_inv. iIntros (κ ?) "[[Hκ %]|[Hκ %]]".
- iLeft. iFrame "Hκ". iPureIntro. by apply lft_alive_in_insert.
- iRight. iFrame "Hκ". iPureIntro. by apply lft_dead_in_insert. }
iModIntro; iExists Λ.
rewrite {1}/lft_tok big_sepMS_singleton. iSplit; first done. iFrame "HΛ".
Qed. Qed.
Lemma lft_fresh κ κ' : Lemma lft_fresh κ κ' :
i : positive, m : positive, (i < m)%positive (positive_to_lft m) κ' κ. i : positive, m : positive, (i < m)%positive (atomic_lft_to_lft (positive_to_atomic_lft m)) κ' κ.
Proof. Proof.
unfold meet, lft_intersect. unfold meet, lft_intersect.
destruct (minimal_exists (flip Pos.le) (dom κ)) as (i & Ha). destruct (minimal_exists (flip Pos.le) (dom κ)) as (i & Ha).
......
...@@ -19,7 +19,8 @@ End lft_notation. ...@@ -19,7 +19,8 @@ End lft_notation.
Definition static : lft := ( : gmultiset _). Definition static : lft := ( : gmultiset _).
Global Instance lft_intersect : Meet lft := λ κ κ', κ κ'. Global Instance lft_intersect : Meet lft := λ κ κ', κ κ'.
Definition positive_to_lft (p : positive) : lft := {[+ p +]}. Definition positive_to_atomic_lft (p : positive) : atomic_lft := p.
Definition atomic_lft_to_lft (Λ : atomic_lft) : lft := {[+ Λ +]}.
Inductive bor_state := Inductive bor_state :=
| Bor_in | Bor_in
...@@ -209,7 +210,10 @@ Global Instance bor_params : Params (@bor) 4 := {}. ...@@ -209,7 +210,10 @@ Global Instance bor_params : Params (@bor) 4 := {}.
Notation "q .[ κ ]" := (lft_tok q κ) Notation "q .[ κ ]" := (lft_tok q κ)
(format "q .[ κ ]", at level 2, left associativity) : bi_scope. (format "q .[ κ ]", at level 2, left associativity) : bi_scope.
Notation "q .[@ Λ ]" := (lft_tok q (atomic_lft_to_lft Λ))
(format "q .[@ Λ ]", at level 2, left associativity) : bi_scope.
Notation "[† κ ]" := (lft_dead κ) (format "[† κ ]"): bi_scope. Notation "[† κ ]" := (lft_dead κ) (format "[† κ ]"): bi_scope.
Notation "[†@ Λ ]" := (lft_dead (atomic_lft_to_lft Λ)) (format "[†@ Λ ]"): bi_scope.
Notation "&{ κ }" := (bor κ) (format "&{ κ }") : bi_scope. Notation "&{ κ }" := (bor κ) (format "&{ κ }") : bi_scope.
Notation "&{ κ , i }" := (idx_bor κ i) (format "&{ κ , i }") : bi_scope. Notation "&{ κ , i }" := (idx_bor κ i) (format "&{ κ , i }") : bi_scope.
...@@ -339,10 +343,17 @@ Proof. rewrite /idx_bor_own. apply _. Qed. ...@@ -339,10 +343,17 @@ Proof. rewrite /idx_bor_own. apply _. Qed.
Global Instance lft_ctx_persistent : Persistent lft_ctx. Global Instance lft_ctx_persistent : Persistent lft_ctx.
Proof. rewrite /lft_ctx. apply _. Qed. Proof. rewrite /lft_ctx. apply _. Qed.
Global Instance positive_to_lft_inj : Inj eq eq positive_to_lft. Global Instance atomic_lft_to_lft_inj : Inj eq eq atomic_lft_to_lft.
Proof. Proof.
unfold positive_to_lft. intros x y Hxy. unfold atomic_lft_to_lft. intros x y Hxy.
apply gmultiset_elem_of_singleton. rewrite -Hxy. apply gmultiset_elem_of_singleton. rewrite -Hxy.
set_solver. set_solver.
Qed. Qed.
Global Instance positive_to_atomic_lft_inj : Inj eq eq positive_to_atomic_lft.
Proof. apply _. Qed.
Global Definition atomic_lft_eq_dec : EqDecision atomic_lft := _.
Global Definition atomic_lft_countable : Countable atomic_lft := _.
End basic_properties. End basic_properties.
...@@ -221,6 +221,14 @@ Proof. ...@@ -221,6 +221,14 @@ Proof.
intros Halive Λ' HΛ'. intros Halive Λ' HΛ'.
rewrite lookup_insert_ne; last (by intros ->); auto. rewrite lookup_insert_ne; last (by intros ->); auto.
Qed. Qed.
Lemma lft_alive_in_union_false A κ Λs b :
( Λ, Λ Λs Λ κ) lft_alive_in A κ lft_alive_in (gset_to_gmap b Λs A) κ.
Proof.
intros Halive Λ' HΛ'.
rewrite lookup_union_r; [by apply Halive|].
apply lookup_gset_to_gmap_None.
by intros ?%.
Qed.
Lemma lft_dead_in_insert A κ Λ b : Lemma lft_dead_in_insert A κ Λ b :
A !! Λ = None lft_dead_in A κ lft_dead_in (<[Λ:=b]> A) κ. A !! Λ = None lft_dead_in A κ lft_dead_in (<[Λ:=b]> A) κ.
...@@ -236,8 +244,28 @@ Proof. ...@@ -236,8 +244,28 @@ Proof.
- exists Λ. by rewrite lookup_insert. - exists Λ. by rewrite lookup_insert.
- exists Λ'. by rewrite lookup_insert_ne. - exists Λ'. by rewrite lookup_insert_ne.
Qed. Qed.
Lemma lft_dead_in_union_false A κ Λs :
lft_dead_in A κ lft_dead_in (gset_to_gmap false Λs A) κ.
Proof.
intros (Λ&?&). destruct (decide (Λ Λs)) as [|].
- exists Λ. rewrite lookup_union_l'.
+ by rewrite lookup_gset_to_gmap_Some.
+ exists false; by rewrite lookup_gset_to_gmap_Some.
- exists Λ. rewrite lookup_union_r.
+ done.
+ by rewrite lookup_gset_to_gmap_None.
Qed.
Lemma lft_dead_in_insert_false' A κ Λ : Λ κ lft_dead_in (<[Λ:=false]> A) κ. Lemma lft_dead_in_insert_false' A κ Λ : Λ κ lft_dead_in (<[Λ:=false]> A) κ.
Proof. exists Λ. by rewrite lookup_insert. Qed. Proof. exists Λ. by rewrite lookup_insert. Qed.
Lemma lft_dead_in_union_false' A κ Λs Λ :
Λ κ Λ Λs lft_dead_in (gset_to_gmap false Λs A) κ.
Proof.
intros HΛκ .
exists Λ; split; [done|].
rewrite lookup_union_l'.
- by apply lookup_gset_to_gmap_Some.
- exists false; by apply lookup_gset_to_gmap_Some.
Qed.
Lemma lft_dead_in_alive_in_union A κ κ' : Lemma lft_dead_in_alive_in_union A κ κ' :
lft_dead_in A (κ κ') lft_alive_in A κ lft_dead_in A κ'. lft_dead_in A (κ κ') lft_alive_in A κ lft_dead_in A κ'.
Proof. Proof.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment