Commit d3814459 authored by Robbert Krebbers's avatar Robbert Krebbers

Remove basic updates from the Iris model, and define them using plainly.

We define basic updates as:

    |==> P  :=  (∀ Q, (P -∗ ■ Q) -∗ ■ Q)

From this definitions, we can prove all laws of basic updates, apart from
those related to frame preserving updates. For that, we need the following
primitive rule:

    x ~~>: Φ →
    uPred_ownM x ∗ (∀ y, ⌜Φ y⌝ -∗ uPred_ownM y -∗ ■ R) ⊢ ■ R.

So, in total, this gets rid of 1 primitive connective (|==>) and 5 primitive
rules (those of `|==>`), which is replaced by one new primitive rule.
parent 1f796221
......@@ -51,7 +51,6 @@ theories/base_logic/bi.v
theories/base_logic/derived.v
theories/base_logic/proofmode.v
theories/base_logic/base_logic.v
theories/base_logic/double_negation.v
theories/base_logic/lib/iprop.v
theories/base_logic/lib/own.v
theories/base_logic/lib/saved_prop.v
......
......@@ -128,20 +128,6 @@ Qed.
Global Instance uPred_plainlyC M : BiPlainly (uPredSI M) :=
{| bi_plainly_mixin := uPred_plainly_mixin M |}.
Lemma uPred_bupd_mixin M : BiBUpdMixin (uPredI M) uPred_bupd.
Proof.
split.
- exact: bupd_ne.
- exact: bupd_intro.
- exact: bupd_mono.
- exact: bupd_trans.
- exact: bupd_frame_r.
Qed.
Global Instance uPred_bi_bupd M : BiBUpd (uPredI M) := {| bi_bupd_mixin := uPred_bupd_mixin M |}.
Global Instance uPred_bi_bupd_plainly M : BiBUpdPlainly (uPredSI M).
Proof. exact: bupd_plainly. Qed.
(** extra BI instances *)
Global Instance uPred_affine M : BiAffine (uPredI M) | 0.
......@@ -181,9 +167,10 @@ Lemma ownM_unit P : P ⊢ (uPred_ownM ε).
Proof. exact: uPred_primitive.ownM_unit. Qed.
Lemma later_ownM a : uPred_ownM a b, uPred_ownM b (a b).
Proof. exact: uPred_primitive.later_ownM. Qed.
Lemma bupd_ownM_updateP x (Φ : M Prop) :
x ~~>: Φ uPred_ownM x |==> y, ⌜Φ y uPred_ownM y.
Proof. exact: uPred_primitive.bupd_ownM_updateP. Qed.
Lemma ownM_updateP x (Φ : M Prop) R :
x ~~>: Φ
uPred_ownM x ( y, ⌜Φ y - uPred_ownM y - R) R.
Proof. exact: uPred_primitive.ownM_updateP. Qed.
Lemma ownM_valid (a : M) : uPred_ownM a a.
Proof. exact: uPred_primitive.ownM_valid. Qed.
......
......@@ -5,6 +5,31 @@ Import bi base_logic.bi.uPred.
(** Derived laws for Iris-specific primitive connectives (own, valid).
This file does NOT unseal! *)
Definition uPred_bupd {M} (P : uPred M) : uPred M :=
( Q, (P - Q) - Q)%I.
Lemma uPred_bupd_mixin M : BiBUpdMixin (uPredI M) uPred_bupd.
Proof.
split; rewrite /bupd /uPred_bupd.
- solve_proper.
- intros P. apply bi.forall_intro=> Q. apply bi.wand_intro_l.
by rewrite bi.wand_elim_l.
- intros P Q H. apply bi.forall_mono=> R. by repeat f_equiv.
- intros P. apply bi.forall_intro=> Q. apply bi.wand_intro_l.
rewrite !(bi.forall_elim Q). etrans; [apply bi.sep_mono_l|apply bi.wand_elim_r].
apply bi.wand_intro_r. by rewrite bi.wand_elim_r.
- intros P R. apply bi.forall_intro=> Q. apply bi.wand_intro_l.
rewrite (bi.forall_elim Q). rewrite !(comm _ _ R) assoc.
by rewrite -bi.wand_curry bi.wand_elim_l bi.wand_elim_r.
Qed.
Global Instance uPred_bi_bupd M : BiBUpd (uPredI M) :=
{| bi_bupd_mixin := uPred_bupd_mixin M |}.
Global Instance uPred_bi_bupd_plainly M : BiBUpdPlainly (uPredSI M).
Proof.
intros P. rewrite /bupd /bi_bupd_bupd /= /uPred_bupd.
rewrite (bi.forall_elim P) -(bi.entails_wand' ( P)%I ( P)%I) // bi.emp_wand.
apply (plainly_elim _).
Qed.
Module uPred.
Section derived.
......@@ -53,6 +78,15 @@ Proof.
first by rewrite persistently_elim.
apply:persistently_cmra_valid_1.
Qed.
Lemma bupd_ownM_updateP x (Φ : M Prop) :
x ~~>: Φ uPred_ownM x |==> y, ⌜Φ y uPred_ownM y.
Proof.
intros Hup. apply bi.forall_intro=> R. apply bi.wand_intro_r.
etrans; [apply bi.sep_mono_r|by eapply ownM_updateP].
apply bi.forall_intro=> y. rewrite -(bi.exist_intro y).
by rewrite bi.persistent_and_sep bi.wand_curry.
Qed.
Lemma bupd_ownM_update x y : x ~~> y uPred_ownM x |==> uPred_ownM y.
Proof.
intros; rewrite (bupd_ownM_updateP _ (y =)); last by apply cmra_update_updateP.
......
This diff is collapsed.
......@@ -322,21 +322,6 @@ Definition uPred_cmra_valid {M A} := uPred_cmra_valid_aux.(unseal) M A.
Definition uPred_cmra_valid_eq :
@uPred_cmra_valid = @uPred_cmra_valid_def := uPred_cmra_valid_aux.(seal_eq).
Program Definition uPred_bupd_def {M} (Q : uPred M) : uPred M :=
{| uPred_holds n x := k yf,
k n {k} (x yf) x', {k} (x' yf) Q k x' |}.
Next Obligation.
intros M Q n1 n2 x1 x2 HQ [x3 Hx] Hn k yf Hk.
rewrite (dist_le _ _ _ _ Hx); last lia. intros Hxy.
destruct (HQ k (x3 yf)) as (x'&?&?); [auto|by rewrite assoc|].
exists (x' x3); split; first by rewrite -assoc.
eauto using uPred_mono, cmra_includedN_l.
Qed.
Definition uPred_bupd_aux : seal (@uPred_bupd_def). by eexists. Qed.
Definition uPred_bupd {M} := uPred_bupd_aux.(unseal) M.
Definition uPred_bupd_eq :
@uPred_bupd = @uPred_bupd_def := uPred_bupd_aux.(seal_eq).
(** Global uPred-specific Notation *)
Notation "✓ x" := (uPred_cmra_valid x) (at level 20) : bi_scope.
......@@ -348,7 +333,7 @@ Definition unseal_eqs :=
(uPred_pure_eq, uPred_and_eq, uPred_or_eq, uPred_impl_eq, uPred_forall_eq,
uPred_exist_eq, uPred_internal_eq_eq, uPred_sep_eq, uPred_wand_eq,
uPred_plainly_eq, uPred_persistently_eq, uPred_later_eq, uPred_ownM_eq,
uPred_cmra_valid_eq, @uPred_bupd_eq).
uPred_cmra_valid_eq).
Ltac unseal :=
rewrite !unseal_eqs /=.
......@@ -381,7 +366,6 @@ Notation "□ P" := (uPred_persistently P) : bi_scope.
Notation "■ P" := (uPred_plainly P) : bi_scope.
Notation "x ≡ y" := (uPred_internal_eq x y) : bi_scope.
Notation "▷ P" := (uPred_later P) : bi_scope.
Notation "|==> P" := (uPred_bupd P) : bi_scope.
(** Entailment *)
Lemma entails_po : PreOrder ().
......@@ -495,14 +479,6 @@ Proof.
by rewrite (dist_le _ _ _ _ Ha); last lia.
Qed.
Lemma bupd_ne : NonExpansive (@uPred_bupd M).
Proof.
intros n P Q HPQ.
unseal; split=> n' x; split; intros HP k yf ??;
destruct (HP k yf) as (x'&?&?); auto;
exists x'; split; auto; apply HPQ; eauto using cmra_validN_op_l.
Qed.
(** Introduction and elimination rules *)
Lemma pure_intro φ P : φ P ⌜φ⌝.
Proof. by intros ?; unseal; split. Qed.
......@@ -710,35 +686,6 @@ Proof.
unseal=> ?. split=> n x ?. by apply (discrete_iff n).
Qed.
(** Basic update modality *)
Lemma bupd_intro P : P |==> P.
Proof.
unseal. split=> n x ? HP k yf ?; exists x; split; first done.
apply uPred_mono with n x; eauto using cmra_validN_op_l.
Qed.
Lemma bupd_mono P Q : (P Q) (|==> P) |==> Q.
Proof.
unseal. intros HPQ; split=> n x ? HP k yf ??.
destruct (HP k yf) as (x'&?&?); eauto.
exists x'; split; eauto using uPred_in_entails, cmra_validN_op_l.
Qed.
Lemma bupd_trans P : (|==> |==> P) |==> P.
Proof. unseal; split; naive_solver. Qed.
Lemma bupd_frame_r P R : (|==> P) R |==> P R.
Proof.
unseal; split; intros n x ? (x1&x2&Hx&HP&?) k yf ??.
destruct (HP k (x2 yf)) as (x'&?&?); eauto.
{ by rewrite assoc -(dist_le _ _ _ _ Hx); last lia. }
exists (x' x2); split; first by rewrite -assoc.
exists x', x2. eauto using uPred_mono, cmra_validN_op_l, cmra_validN_op_r.
Qed.
Lemma bupd_plainly P : (|==> P) P.
Proof.
unseal; split => n x Hnx /= Hng.
destruct (Hng n ε) as [? [_ Hng']]; try rewrite right_id; auto.
eapply uPred_mono; eauto using ucmra_unit_leastN.
Qed.
(** Own *)
Lemma ownM_op (a1 a2 : M) :
uPred_ownM (a1 a2) uPred_ownM a1 uPred_ownM a2.
......@@ -764,14 +711,16 @@ Proof.
exists a'. rewrite Hx. eauto using cmra_includedN_l.
Qed.
Lemma bupd_ownM_updateP x (Φ : M Prop) :
x ~~>: Φ uPred_ownM x |==> y, ⌜Φ y uPred_ownM y.
Lemma ownM_updateP x (Φ : M Prop) R :
x ~~>: Φ
uPred_ownM x ( y, ⌜Φ y - uPred_ownM y - R) R.
Proof.
unseal=> Hup; split=> n x2 ? [x3 Hx] k yf ??.
destruct (Hup k (Some (x3 yf))) as (y&?&?); simpl in *.
{ rewrite /= assoc -(dist_le _ _ _ _ Hx); auto. }
exists (y x3); split; first by rewrite -assoc.
exists y; eauto using cmra_includedN_l.
unseal=> Hup; split; intros n z Hv (?&z2&?&[z1 ?]&HR); ofe_subst.
destruct (Hup n (Some (z1 z2))) as (y&?&?); simpl in *.
{ by rewrite assoc. }
refine (HR y n z1 _ _ _ n y _ _ _); auto.
- rewrite comm. by eapply cmra_validN_op_r.
- by rewrite (comm _ _ y) (comm _ z2).
Qed.
(** Valid *)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment