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

generalize core to all BIs

parent 272d3554
Branches
Tags
No related merge requests found
...@@ -39,6 +39,7 @@ theories/bi/monpred.v ...@@ -39,6 +39,7 @@ theories/bi/monpred.v
theories/bi/embedding.v theories/bi/embedding.v
theories/bi/lib/fractional.v theories/bi/lib/fractional.v
theories/bi/lib/atomic.v theories/bi/lib/atomic.v
theories/bi/lib/core.v
theories/base_logic/upred.v theories/base_logic/upred.v
theories/base_logic/derived.v theories/base_logic/derived.v
theories/base_logic/base_logic.v theories/base_logic/base_logic.v
...@@ -58,7 +59,6 @@ theories/base_logic/lib/boxes.v ...@@ -58,7 +59,6 @@ theories/base_logic/lib/boxes.v
theories/base_logic/lib/na_invariants.v theories/base_logic/lib/na_invariants.v
theories/base_logic/lib/cancelable_invariants.v theories/base_logic/lib/cancelable_invariants.v
theories/base_logic/lib/gen_heap.v theories/base_logic/lib/gen_heap.v
theories/base_logic/lib/core.v
theories/base_logic/lib/fancy_updates_from_vs.v theories/base_logic/lib/fancy_updates_from_vs.v
theories/program_logic/adequacy.v theories/program_logic/adequacy.v
theories/program_logic/lifting.v theories/program_logic/lifting.v
......
From iris.base_logic Require Import base_logic. From iris.bi Require Export bi plainly.
From iris.proofmode Require Import tactics. From iris.proofmode Require Import tactics.
Set Default Proof Using "Type". Set Default Proof Using "Type".
Import uPred. Import bi.
(** The "core" of an assertion is its maximal persistent part, (** The "core" of an assertion is its maximal persistent part,
i.e. the conjunction of all persistent assertions that are weaker i.e. the conjunction of all persistent assertions that are weaker
than P (as in, implied by P). *) than P (as in, implied by P). *)
Definition coreP {M : ucmraT} (P : uPred M) : uPred M := Definition coreP `{!BiPlainly PROP} (P : PROP) : PROP :=
( Q, (P Q) Q)%I. ( Q : PROP, (Q -∗ <pers> Q) (P -∗ Q) Q)%I.
Instance: Params (@coreP) 1. Instance: Params (@coreP) 1.
Typeclasses Opaque coreP. Typeclasses Opaque coreP.
Section core. Section core.
Context {M : ucmraT}. Context `{!BiPlainly PROP}.
Implicit Types P Q : uPred M. Implicit Types P Q : PROP.
Lemma coreP_intro P : P -∗ coreP P. Lemma coreP_intro P : P -∗ coreP P.
Proof. rewrite /coreP. iIntros "HP" (Q) "HPQ". by iApply "HPQ". Qed. Proof.
rewrite /coreP. iIntros "HP" (Q) "_ HPQ".
(* FIXME: Cannot apply HPQ directly. *)
iDestruct (affinely_plainly_elim with "HPQ") as "HPQ".
by iApply "HPQ".
Qed.
Global Instance coreP_persistent P : Persistent (coreP P). Global Instance coreP_persistent P : Persistent (coreP P).
Proof. rewrite /coreP /Persistent. iIntros "#HC" (Q) "!#". iApply "HC". Qed. Proof.
rewrite /coreP /Persistent. iIntros "HC" (Q).
iApply persistently_impl_plainly. iIntros "#HQ".
iApply persistently_impl_plainly. iIntros "#HPQ".
iApply "HQ".
(* FIXME: [iApply "HC"] should work. *)
iSpecialize ("HC" with "HQ"). iSpecialize ("HC" with "HPQ"). done.
Qed.
Global Instance coreP_ne : NonExpansive (@coreP M). Global Instance coreP_ne : NonExpansive (coreP (PROP:=PROP)).
Proof. solve_proper. Qed. Proof. solve_proper. Qed.
Global Instance coreP_proper : Proper ((⊣⊢) ==> (⊣⊢)) (@coreP M). Global Instance coreP_proper : Proper ((⊣⊢) ==> (⊣⊢)) (coreP (PROP:=PROP)).
Proof. solve_proper. Qed. Proof. solve_proper. Qed.
Global Instance coreP_mono : Proper (() ==> ()) (@coreP M). Global Instance coreP_mono : Proper (() ==> ()) (coreP (PROP:=PROP)).
Proof. solve_proper. Qed. Proof. solve_proper. Qed.
Lemma coreP_elim P : Persistent P coreP P -∗ P. Lemma coreP_elim P : Persistent P coreP P -∗ P.
Proof. Proof.
rewrite /coreP. iIntros (?) "HCP". iApply ("HCP" $! P with "[]"). auto. rewrite /coreP. iIntros (?) "HCP". iSpecialize ("HCP" $! P).
(* FIXME: [iApply "HCP"] should work. *)
iAssert ( (P -∗ <pers> P))%I as "#HPpers".
{ iModIntro. iApply persistent. }
iSpecialize ("HCP" with "HPpers").
iAssert ( (P -∗ P))%I as "#HP".
{ iIntros "!> HP". done. }
iSpecialize ("HCP" with "HP").
done.
Qed. Qed.
Lemma coreP_wand P Q : (coreP P Q) (P Q). (* TODO: Can we generalize this to non-affine BIs? *)
Lemma coreP_wand `{!BiAffine PROP} P Q : (coreP P Q) (P <pers> Q).
Proof. Proof.
split. split.
- iIntros (HP) "HP". iDestruct (coreP_intro with "HP") as "#HcP". - iIntros (HP) "HP". iDestruct (coreP_intro with "HP") as "#HcP".
......
From iris.bi Require Export derived_laws. From iris.bi Require Import derived_laws.
From iris.algebra Require Import monoid. From iris.algebra Require Import monoid.
Import interface.bi derived_laws.bi. Import interface.bi derived_laws.bi.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment