diff --git a/theories/base_logic/lib/fancy_updates.v b/theories/base_logic/lib/fancy_updates.v index 2d910d657eac002a9b8c85e837498dd3b268b9f0..2c4a5818f9907c8b74a56a262742206cc047fa69 100644 --- a/theories/base_logic/lib/fancy_updates.v +++ b/theories/base_logic/lib/fancy_updates.v @@ -50,7 +50,7 @@ Proof. iNext. by iMod ("HP" with "[$]") as "(_ & _ & HP)". Qed. -Lemma fupd_plain_soundness `{invPreG Σ} E (P: iPropSI Σ) `{!Plain P}: +Lemma fupd_plain_soundness `{invPreG Σ} E (P: iProp Σ) `{!Plain P}: (∀ `{Hinv: invG Σ}, (|={⊤, E}=> P)%I) → (â–· P)%I. Proof. iIntros (Hfupd). iMod wsat_alloc as (Hinv) "[Hw HE]". @@ -68,7 +68,7 @@ Proof. eapply (fupd_plain_soundness ⊤); first by apply _. intros Hinv. rewrite -/sbi_laterN. iPoseProof (Hiter Hinv) as "H". - destruct n. + destruct n as [|n]. - rewrite //=. iPoseProof (fupd_plain_strong with "H") as "H'". do 2 iMod "H'"; iModIntro; auto. - iPoseProof (step_fupdN_mono _ _ _ _ (|={⊤}=> â—‡ ⌜φâŒ)%I with "H") as "H'". diff --git a/theories/base_logic/lib/wsat.v b/theories/base_logic/lib/wsat.v index dedced8635211a67e136144d72ad473b6b448f6c..d8f06c6d398e7e3c0196da5b7d5ed19fcf08c3bb 100644 --- a/theories/base_logic/lib/wsat.v +++ b/theories/base_logic/lib/wsat.v @@ -13,23 +13,24 @@ Module invG. enabled_name : gname; disabled_name : gname; }. -End invG. -Import invG. -Definition invΣ : gFunctors := - #[GFunctor (authRF (gmapURF positive (agreeRF (laterCF idCF)))); - GFunctor coPset_disjUR; - GFunctor (gset_disjUR positive)]. + Definition invΣ : gFunctors := + #[GFunctor (authRF (gmapURF positive (agreeRF (laterCF idCF)))); + GFunctor coPset_disjUR; + GFunctor (gset_disjUR positive)]. -Class invPreG (Σ : gFunctors) : Set := WsatPreG { - inv_inPreG :> inG Σ (authR (gmapUR positive (agreeR (laterC (iPreProp Σ))))); - enabled_inPreG :> inG Σ coPset_disjR; - disabled_inPreG :> inG Σ (gset_disjR positive); -}. + Class invPreG (Σ : gFunctors) : Set := WsatPreG { + inv_inPreG :> inG Σ (authR (gmapUR positive (agreeR (laterC (iPreProp Σ))))); + enabled_inPreG :> inG Σ coPset_disjR; + disabled_inPreG :> inG Σ (gset_disjR positive); + }. Instance subG_invΣ {Σ} : subG invΣ Σ → invPreG Σ. Proof. solve_inG. Qed. +End invG. +Import invG. + Definition invariant_unfold {Σ} (P : iProp Σ) : agree (later (iPreProp Σ)) := to_agree (Next (iProp_unfold P)). Definition ownI `{invG Σ} (i : positive) (P : iProp Σ) : iProp Σ := diff --git a/theories/bi/updates.v b/theories/bi/updates.v index 50827b359050d8fcd0b15d7c30ebe6bac0a67a81..33824c502d6e3e937debca5e0c60522effe30423 100644 --- a/theories/bi/updates.v +++ b/theories/bi/updates.v @@ -272,38 +272,6 @@ Section fupd_derived. intros P1 P2 HP Q1 Q2 HQ. by rewrite HP HQ -fupd_sep. Qed. - Lemma fupd_plain_weak `{BiPlainly PROP, !BiFUpdPlainly PROP} E P Q `{!Plain P}: - (Q ={E}=∗ P) -∗ Q ={E}=∗ Q ∗ P. - Proof. by rewrite {1}(plain P) fupd_plainly_weak. Qed. - - Lemma later_fupd_plain `{BiPlainly PROP, !BiFUpdPlainly PROP} p E1 E2 P `{!Plain P} : - (â–·?p |={E1, E2}=> P) ={E1}=∗ â–·?p â—‡ P. - Proof. by rewrite {1}(plain P) later_fupd_plainly. Qed. - - Lemma fupd_plain_strong `{BiPlainly PROP, !BiFUpdPlainly PROP} E1 E2 P `{!Plain P} : - (|={E1, E2}=> P) ={E1}=∗ â—‡ P. - Proof. by apply (later_fupd_plain false). Qed. - - Lemma fupd_plain' `{BiPlainly PROP, !BiFUpdPlainly PROP} E1 E2 E2' P Q `{!Plain P} : - E1 ⊆ E2 → - (Q ={E1, E2'}=∗ P) -∗ (|={E1, E2}=> Q) ={E1}=∗ (|={E1, E2}=> Q) ∗ P. - Proof. - intros (E3&->&HE)%subseteq_disjoint_union_L. - apply wand_intro_l. rewrite fupd_frame_r. - rewrite fupd_plain_strong fupd_except_0 fupd_plain_weak wand_elim_r. - rewrite (fupd_mask_mono E1 (E1 ∪ E3)); last by set_solver+. - rewrite fupd_trans -(fupd_trans E1 (E1 ∪ E3) E1). - apply fupd_mono. rewrite -fupd_frame_r. - apply sep_mono; auto. apply fupd_intro_mask; set_solver+. - Qed. - - Lemma fupd_plain `{BiPlainly PROP, !BiFUpdPlainly PROP} E1 E2 P Q `{!Plain P} : - E1 ⊆ E2 → (Q -∗ P) -∗ (|={E1, E2}=> Q) ={E1}=∗ (|={E1, E2}=> Q) ∗ P. - Proof. - intros HE. rewrite -(fupd_plain' _ _ E1) //. apply wand_intro_l. - by rewrite wand_elim_r -fupd_intro. - Qed. - (** Fancy updates that take a step derived rules. *) Lemma step_fupd_wand E1 E2 E3 P Q : (|={E1,E2,E3}â–·=> P) -∗ (P -∗ Q) -∗ |={E1,E2,E3}â–·=> Q. Proof. @@ -345,13 +313,6 @@ Section fupd_derived. by apply later_mono, fupd_mono. Qed. - Lemma step_fupd_plain `{BiPlainly PROP, !BiFUpdPlainly PROP} E P `{!Plain P} : - (|={E, ∅}â–·=> P) ={E}=∗ â–· â—‡ P. - Proof. - specialize (later_fupd_plain true ∅ E P) => //= ->. - rewrite fupd_trans fupd_plain_strong. apply fupd_mono, except_0_later. - Qed. - Lemma step_fupd_fupd E P: (|={E, ∅}â–·=> P) ⊣⊢ (|={E, ∅}â–·=> |={E}=> P). Proof. @@ -380,15 +341,58 @@ Section fupd_derived. rewrite step_fupd_frame_l IH //=. Qed. - Lemma step_fupdN_plain `{BiPlainly PROP, !BiFUpdPlainly PROP} E n P `{!Plain P}: - (|={E, ∅}â–·=>^n P) ={E}=∗ â–·^n â—‡ P. - Proof. - induction n as [| n]. - - rewrite -fupd_intro. apply except_0_intro. - - rewrite Nat_iter_S step_fupd_fupd IHn ?fupd_trans step_fupd_plain. - apply fupd_mono. destruct n; simpl. - * by rewrite except_0_idemp. - * by rewrite except_0_later. - Qed. + Section fupd_plainly_derived. + Context `{BiPlainly PROP, !BiFUpdPlainly PROP}. + + Lemma fupd_plain_weak E P Q `{!Plain P}: + (Q ={E}=∗ P) -∗ Q ={E}=∗ Q ∗ P. + Proof. by rewrite {1}(plain P) fupd_plainly_weak. Qed. + + Lemma later_fupd_plain p E1 E2 P `{!Plain P} : + (â–·?p |={E1, E2}=> P) ={E1}=∗ â–·?p â—‡ P. + Proof. by rewrite {1}(plain P) later_fupd_plainly. Qed. + + Lemma fupd_plain_strong E1 E2 P `{!Plain P} : + (|={E1, E2}=> P) ={E1}=∗ â—‡ P. + Proof. by apply (later_fupd_plain false). Qed. + + Lemma fupd_plain' E1 E2 E2' P Q `{!Plain P} : + E1 ⊆ E2 → + (Q ={E1, E2'}=∗ P) -∗ (|={E1, E2}=> Q) ={E1}=∗ (|={E1, E2}=> Q) ∗ P. + Proof. + intros (E3&->&HE)%subseteq_disjoint_union_L. + apply wand_intro_l. rewrite fupd_frame_r. + rewrite fupd_plain_strong fupd_except_0 fupd_plain_weak wand_elim_r. + rewrite (fupd_mask_mono E1 (E1 ∪ E3)); last by set_solver+. + rewrite fupd_trans -(fupd_trans E1 (E1 ∪ E3) E1). + apply fupd_mono. rewrite -fupd_frame_r. + apply sep_mono; auto. apply fupd_intro_mask; set_solver+. + Qed. + + Lemma fupd_plain E1 E2 P Q `{!Plain P} : + E1 ⊆ E2 → (Q -∗ P) -∗ (|={E1, E2}=> Q) ={E1}=∗ (|={E1, E2}=> Q) ∗ P. + Proof. + intros HE. rewrite -(fupd_plain' _ _ E1) //. apply wand_intro_l. + by rewrite wand_elim_r -fupd_intro. + Qed. + + Lemma step_fupd_plain E P `{!Plain P} : + (|={E, ∅}â–·=> P) ={E}=∗ â–· â—‡ P. + Proof. + specialize (later_fupd_plain true ∅ E P) => //= ->. + rewrite fupd_trans fupd_plain_strong. apply fupd_mono, except_0_later. + Qed. + + Lemma step_fupdN_plain E n P `{!Plain P}: + (|={E, ∅}â–·=>^n P) ={E}=∗ â–·^n â—‡ P. + Proof. + induction n as [|n IH]. + - rewrite -fupd_intro. apply except_0_intro. + - rewrite Nat_iter_S step_fupd_fupd IH ?fupd_trans step_fupd_plain. + apply fupd_mono. destruct n; simpl. + * by rewrite except_0_idemp. + * by rewrite except_0_later. + Qed. + End fupd_plainly_derived. End fupd_derived. diff --git a/theories/program_logic/adequacy.v b/theories/program_logic/adequacy.v index 4a7030025338eebb81a3bb316ff0223f534e5a8c..4621a3cb0c74cca335c158eb7f5aeba8b5beba8c 100644 --- a/theories/program_logic/adequacy.v +++ b/theories/program_logic/adequacy.v @@ -1,7 +1,7 @@ From stdpp Require Import namespaces. From iris.program_logic Require Export weakestpre. From iris.algebra Require Import gmap auth agree gset coPset. -From iris.base_logic.lib Require Export wsat. +From iris.base_logic.lib Require Import wsat. From iris.proofmode Require Import tactics. Set Default Proof Using "Type". Import uPred.