Commit 39967f22 authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan

Renaming : morphism -> embedding.

parent 858d6407
......@@ -2297,106 +2297,106 @@ only be used at the leaves of the proof search tree, i.e. when the
premise of the hint can be derived from just the current context. *)
Hint Immediate bi.plain_persistent : typeclass_instances.
(* BI morphisms *)
Section bi_morphims.
Context `{BiMorphism PROP1 PROP2}.
(* BI embeddings *)
Section bi_embedding.
Context `{BiEmbedding PROP1 PROP2}.
Global Instance bi_mor_proper : Proper (() ==> ()) bi_embedding.
Global Instance bi_embed_proper : Proper (() ==> ()) bi_embed.
Proof. apply (ne_proper _). Qed.
Global Instance bi_mor_mono_flip : Proper (flip () ==> flip ()) bi_embedding.
Global Instance bi_embed_mono_flip : Proper (flip () ==> flip ()) bi_embed.
Proof. solve_proper. Qed.
Global Instance bi_mor_inj : Inj () () bi_embedding.
Global Instance bi_embed_inj : Inj () () bi_embed.
Proof.
intros ?? EQ. apply bi.equiv_spec, conj; apply (inj bi_embedding);
intros ?? EQ. apply bi.equiv_spec, conj; apply (inj bi_embed);
rewrite EQ //.
Qed.
Lemma bi_mor_valid (P : PROP1) : @bi_embedding PROP1 PROP2 _ P P.
Lemma bi_embed_valid (P : PROP1) : @bi_embed PROP1 PROP2 _ P P.
Proof.
by rewrite /bi_valid -bi_mor_emp; split=>?; [apply (inj bi_embedding)|f_equiv].
by rewrite /bi_valid -bi_embed_emp; split=>?; [apply (inj bi_embed)|f_equiv].
Qed.
Lemma bi_mor_forall A (Φ : A PROP1) : x, Φ x x, ⎡Φ x.
Lemma bi_embed_forall A (Φ : A PROP1) : x, Φ x x, ⎡Φ x.
Proof.
apply bi.equiv_spec; split; [|apply bi_mor_forall_2].
apply bi.equiv_spec; split; [|apply bi_embed_forall_2].
apply bi.forall_intro=>?. by rewrite bi.forall_elim.
Qed.
Lemma bi_mor_exist A (Φ : A PROP1) : x, Φ x x, ⎡Φ x.
Lemma bi_embed_exist A (Φ : A PROP1) : x, Φ x x, ⎡Φ x.
Proof.
apply bi.equiv_spec; split; [apply bi_mor_exist_1|].
apply bi.equiv_spec; split; [apply bi_embed_exist_1|].
apply bi.exist_elim=>?. by rewrite -bi.exist_intro.
Qed.
Lemma bi_mor_and P Q : P Q P Q.
Proof. rewrite !bi.and_alt bi_mor_forall. by f_equiv=>-[]. Qed.
Lemma bi_mor_or P Q : P Q P Q.
Proof. rewrite !bi.or_alt bi_mor_exist. by f_equiv=>-[]. Qed.
Lemma bi_mor_impl P Q : P Q (P Q).
Lemma bi_embed_and P Q : P Q P Q.
Proof. rewrite !bi.and_alt bi_embed_forall. by f_equiv=>-[]. Qed.
Lemma bi_embed_or P Q : P Q P Q.
Proof. rewrite !bi.or_alt bi_embed_exist. by f_equiv=>-[]. Qed.
Lemma bi_embed_impl P Q : P Q (P Q).
Proof.
apply bi.equiv_spec; split; [|apply bi_mor_impl_2].
apply bi.impl_intro_l. by rewrite -bi_mor_and bi.impl_elim_r.
apply bi.equiv_spec; split; [|apply bi_embed_impl_2].
apply bi.impl_intro_l. by rewrite -bi_embed_and bi.impl_elim_r.
Qed.
Lemma bi_mor_wand P Q : P - Q (P - Q).
Lemma bi_embed_wand P Q : P - Q (P - Q).
Proof.
apply bi.equiv_spec; split; [|apply bi_mor_wand_2].
apply bi.wand_intro_l. by rewrite -bi_mor_sep bi.wand_elim_r.
apply bi.equiv_spec; split; [|apply bi_embed_wand_2].
apply bi.wand_intro_l. by rewrite -bi_embed_sep bi.wand_elim_r.
Qed.
Lemma bi_mor_pure φ : ⎡⌜φ⌝⎤ ⌜φ⌝.
Lemma bi_embed_pure φ : ⎡⌜φ⌝⎤ ⌜φ⌝.
Proof.
rewrite (@bi.pure_alt PROP1) (@bi.pure_alt PROP2) bi_mor_exist.
rewrite (@bi.pure_alt PROP1) (@bi.pure_alt PROP2) bi_embed_exist.
do 2 f_equiv. apply bi.equiv_spec. split; [apply bi.True_intro|].
rewrite -(_ : (emp emp : PROP1) True) ?bi_mor_impl;
rewrite -(_ : (emp emp : PROP1) True) ?bi_embed_impl;
last apply bi.True_intro.
apply bi.impl_intro_l. by rewrite right_id.
Qed.
Lemma bi_mor_internal_eq (A : ofeT) (x y : A) : x y x y.
Lemma bi_embed_internal_eq (A : ofeT) (x y : A) : x y x y.
Proof.
apply bi.equiv_spec; split; [apply bi_mor_internal_eq_1|].
apply bi.equiv_spec; split; [apply bi_embed_internal_eq_1|].
etrans; [apply (bi.internal_eq_rewrite x y (λ y, x y%I)); solve_proper|].
rewrite -(bi.internal_eq_refl True%I) bi_mor_pure.
rewrite -(bi.internal_eq_refl True%I) bi_embed_pure.
eapply bi.impl_elim; [done|]. apply bi.True_intro.
Qed.
Lemma bi_mor_iff P Q : P Q (P Q).
Proof. by rewrite bi_mor_and !bi_mor_impl. Qed.
Lemma bi_mor_wand_iff P Q : P - Q (P - Q).
Proof. by rewrite bi_mor_and !bi_mor_wand. Qed.
Lemma bi_mor_affinely P : bi_affinely P bi_affinely P.
Proof. by rewrite bi_mor_and bi_mor_emp. Qed.
Lemma bi_mor_absorbingly P : bi_absorbingly P bi_absorbingly P.
Proof. by rewrite bi_mor_sep bi_mor_pure. Qed.
Lemma bi_mor_plainly_if P b : bi_plainly_if b P bi_plainly_if b P.
Proof. destruct b; auto using bi_mor_plainly. Qed.
Lemma bi_mor_persistently_if P b :
Lemma bi_embed_iff P Q : P Q (P Q).
Proof. by rewrite bi_embed_and !bi_embed_impl. Qed.
Lemma bi_embed_wand_iff P Q : P - Q (P - Q).
Proof. by rewrite bi_embed_and !bi_embed_wand. Qed.
Lemma bi_embed_affinely P : bi_affinely P bi_affinely P.
Proof. by rewrite bi_embed_and bi_embed_emp. Qed.
Lemma bi_embed_absorbingly P : bi_absorbingly P bi_absorbingly P.
Proof. by rewrite bi_embed_sep bi_embed_pure. Qed.
Lemma bi_embed_plainly_if P b : bi_plainly_if b P bi_plainly_if b P.
Proof. destruct b; auto using bi_embed_plainly. Qed.
Lemma bi_embed_persistently_if P b :
bi_persistently_if b P bi_persistently_if b P.
Proof. destruct b; auto using bi_mor_persistently. Qed.
Lemma bi_mor_affinely_if P b : bi_affinely_if b P bi_affinely_if b P.
Proof. destruct b; simpl; auto using bi_mor_affinely. Qed.
Lemma bi_mor_hforall {As} (Φ : himpl As PROP1):
bi_hforall Φ⎤ bi_hforall (hcompose bi_embedding Φ).
Proof. induction As=>//. rewrite /= bi_mor_forall. by do 2 f_equiv. Qed.
Lemma bi_mor_hexist {As} (Φ : himpl As PROP1):
bi_hexist Φ⎤ bi_hexist (hcompose bi_embedding Φ).
Proof. induction As=>//. rewrite /= bi_mor_exist. by do 2 f_equiv. Qed.
Global Instance bi_mor_plain P : Plain P Plain P.
Proof. intros ?. by rewrite /Plain -bi_mor_plainly -plain. Qed.
Global Instance bi_mor_persistent P : Persistent P Persistent P.
Proof. intros ?. by rewrite /Persistent -bi_mor_persistently -persistent. Qed.
Global Instance bi_mor_affine P : Affine P Affine P.
Proof. intros ?. by rewrite /Affine (affine P) bi_mor_emp. Qed.
Global Instance bi_mor_absorbing P : Absorbing P Absorbing P.
Proof. intros ?. by rewrite /Absorbing -bi_mor_absorbingly absorbing. Qed.
End bi_morphims.
Section sbi_morphims.
Context `{SbiMorphism PROP1 PROP2}.
Lemma sbi_mor_laterN n P : ⎡▷^n P ^n P.
Proof. induction n=>//=. rewrite sbi_mor_later. by f_equiv. Qed.
Lemma sbi_mor_except_0 P : ⎡◇ P P.
Proof. by rewrite bi_mor_or sbi_mor_later bi_mor_pure. Qed.
Global Instance sbi_mor_timeless P : Timeless P Timeless P.
Proof. destruct b; auto using bi_embed_persistently. Qed.
Lemma bi_embed_affinely_if P b : bi_affinely_if b P bi_affinely_if b P.
Proof. destruct b; simpl; auto using bi_embed_affinely. Qed.
Lemma bi_embed_hforall {As} (Φ : himpl As PROP1):
bi_hforall Φ⎤ bi_hforall (hcompose bi_embed Φ).
Proof. induction As=>//. rewrite /= bi_embed_forall. by do 2 f_equiv. Qed.
Lemma bi_embed_hexist {As} (Φ : himpl As PROP1):
bi_hexist Φ⎤ bi_hexist (hcompose bi_embed Φ).
Proof. induction As=>//. rewrite /= bi_embed_exist. by do 2 f_equiv. Qed.
Global Instance bi_embed_plain P : Plain P Plain P.
Proof. intros ?. by rewrite /Plain -bi_embed_plainly -plain. Qed.
Global Instance bi_embed_persistent P : Persistent P Persistent P.
Proof. intros ?. by rewrite /Persistent -bi_embed_persistently -persistent. Qed.
Global Instance bi_embed_affine P : Affine P Affine P.
Proof. intros ?. by rewrite /Affine (affine P) bi_embed_emp. Qed.
Global Instance bi_embed_absorbing P : Absorbing P Absorbing P.
Proof. intros ?. by rewrite /Absorbing -bi_embed_absorbingly absorbing. Qed.
End bi_embedding.
Section sbi_embedding.
Context `{SbiEmbedding PROP1 PROP2}.
Lemma sbi_embed_laterN n P : ⎡▷^n P ^n P.
Proof. induction n=>//=. rewrite sbi_embed_later. by f_equiv. Qed.
Lemma sbi_embed_except_0 P : ⎡◇ P P.
Proof. by rewrite bi_embed_or sbi_embed_later bi_embed_pure. Qed.
Global Instance sbi_embed_timeless P : Timeless P Timeless P.
Proof.
intros ?. by rewrite /Timeless -sbi_mor_except_0 -sbi_mor_later timeless.
intros ?. by rewrite /Timeless -sbi_embed_except_0 -sbi_embed_later timeless.
Qed.
End sbi_morphims.
\ No newline at end of file
End sbi_embedding.
\ No newline at end of file
......@@ -526,29 +526,29 @@ End sbi_laws.
End bi.
(* Typically, embeddings are used to *define* the destination BI.
Hence we cannot ask it to be a morphism. *)
Class BiEmbedding (A B : Type) := bi_embedding : A B.
Arguments bi_embedding {_ _ _} _%I : simpl never.
Notation "⎡ P ⎤" := (bi_embedding P) : bi_scope.
Instance: Params (@bi_embedding) 3.
Typeclasses Opaque bi_embedding.
Class BiMorphism (PROP1 PROP2 : bi) `{BiEmbedding PROP1 PROP2} := {
bi_mor_ne :> NonExpansive bi_embedding;
bi_mor_mono :> Proper (() ==> ()) bi_embedding;
bi_mor_entails_inj :> Inj () () bi_embedding;
bi_mor_emp : emp emp;
bi_mor_impl_2 P Q : (P Q) P Q;
bi_mor_forall_2 A (Φ : A PROP1) : ( x, ⎡Φ x) x, Φ x;
bi_mor_exist_1 A (Φ : A PROP1) : x, Φ x x, ⎡Φ x;
bi_mor_internal_eq_1 (A : ofeT) (x y : A) : x y x y;
bi_mor_sep P Q : P Q P Q;
bi_mor_wand_2 P Q : (P - Q) P - Q;
bi_mor_plainly P : bi_plainly P bi_plainly P;
bi_mor_persistently P : bi_persistently P bi_persistently P
Hence we cannot ask it to verify the properties of embeddings. *)
Class BiEmbed (A B : Type) := bi_embed : A B.
Arguments bi_embed {_ _ _} _%I : simpl never.
Notation "⎡ P ⎤" := (bi_embed P) : bi_scope.
Instance: Params (@bi_embed) 3.
Typeclasses Opaque bi_embed.
Class BiEmbedding (PROP1 PROP2 : bi) `{BiEmbed PROP1 PROP2} := {
bi_embed_ne :> NonExpansive bi_embed;
bi_embed_mono :> Proper (() ==> ()) bi_embed;
bi_embed_entails_inj :> Inj () () bi_embed;
bi_embed_emp : emp emp;
bi_embed_impl_2 P Q : (P Q) P Q;
bi_embed_forall_2 A (Φ : A PROP1) : ( x, ⎡Φ x) x, Φ x;
bi_embed_exist_1 A (Φ : A PROP1) : x, Φ x x, ⎡Φ x;
bi_embed_internal_eq_1 (A : ofeT) (x y : A) : x y x y;
bi_embed_sep P Q : P Q P Q;
bi_embed_wand_2 P Q : (P - Q) P - Q;
bi_embed_plainly P : bi_plainly P bi_plainly P;
bi_embed_persistently P : bi_persistently P bi_persistently P
}.
Class SbiMorphism (PROP1 PROP2 : sbi) `{BiEmbedding PROP1 PROP2} := {
sbi_mor_bi_mor :> BiMorphism PROP1 PROP2;
sbi_mor_later P : ⎡▷ P P
Class SbiEmbedding (PROP1 PROP2 : sbi) `{BiEmbed PROP1 PROP2} := {
sbi_embed_bi_embed :> BiEmbedding PROP1 PROP2;
sbi_embed_later P : ⎡▷ P P
}.
......@@ -116,10 +116,10 @@ Program Definition monPred_upclosed (Φ : I → PROP) : monPred :=
MonPred (λ i, ( j, i j Φ j)%I) _.
Next Obligation. solve_proper. Qed.
Definition monPred_ipure_def (P : PROP) : monPred := MonPred (λ _, P) _.
Definition monPred_ipure_aux : seal (@monPred_ipure_def). by eexists. Qed.
Global Instance monPred_ipure : BiEmbedding PROP monPred := unseal monPred_ipure_aux.
Definition monPred_ipure_eq : bi_embedding = _ := seal_eq _.
Definition monPred_embed_def (P : PROP) : monPred := MonPred (λ _, P) _.
Definition monPred_embed_aux : seal (@monPred_embed_def). by eexists. Qed.
Global Instance monPred_embed : BiEmbed PROP monPred := unseal monPred_embed_aux.
Definition monPred_embed_eq : bi_embed = _ := seal_eq _.
Definition monPred_pure (φ : Prop) : monPred := ⎡⌜φ⌝⎤%I.
Definition monPred_emp : monPred := emp%I.
......@@ -215,7 +215,7 @@ Definition unseal_eqs :=
@monPred_forall_eq, @monPred_exist_eq, @monPred_internal_eq_eq,
@monPred_sep_eq, @monPred_wand_eq,
@monPred_persistently_eq, @monPred_later_eq,
@monPred_in_eq, @monPred_all_eq, @monPred_ipure_eq).
@monPred_in_eq, @monPred_all_eq, @monPred_embed_eq).
Ltac unseal :=
unfold bi_affinely, bi_absorbingly, sbi_except_0, bi_pure, bi_emp,
monPred_upclosed, bi_and, bi_or, bi_impl, bi_forall, bi_exist,
......@@ -464,8 +464,8 @@ Proof.
by apply affine, bi.forall_affine.
Qed.
Global Instance monPred_ipure_bi_mor :
Inhabited I @BiMorphism PROP (monPredI I PROP) bi_embedding.
Global Instance monPred_bi_embedding :
Inhabited I @BiEmbedding PROP (monPredI I PROP) bi_embed.
Proof.
split; try apply _; unseal; try done.
- move =>?? /= [/(_ inhabitant) ?] //.
......@@ -485,7 +485,7 @@ Implicit Types P Q : monPred I PROP.
Global Instance monPred_car_timeless P i : Timeless P Timeless (P i).
Proof. move => [] /(_ i). unfold Timeless. by unseal. Qed.
Global Instance monPred_ipure_timeless (P : PROP) :
Global Instance monPred_embed_timeless (P : PROP) :
Timeless P @Timeless (monPredSI I PROP) P%I.
Proof. intros. split => ? /=. by unseal. Qed.
Global Instance monPred_in_timeless i0 : Timeless (@monPred_in I PROP i0).
......@@ -497,7 +497,7 @@ Proof.
by apply timeless, bi.forall_timeless.
Qed.
Global Instance monPred_ipure_sbi_mor :
Inhabited I @SbiMorphism PROP (monPredSI I PROP) bi_embedding.
Global Instance monPred_sbi_embedding :
Inhabited I @SbiEmbedding PROP (monPredSI I PROP) bi_embed.
Proof. split; try apply _. by unseal. Qed.
End sbi_facts.
This diff is collapsed.
......@@ -71,9 +71,9 @@ Proof. split. apply bi.entails_wand. apply bi.wand_entails. Qed.
Instance as_valid_equiv {PROP : bi} (P Q : PROP) : AsValid (P Q) (P - Q) | 0.
Proof. split. apply bi.equiv_wand_iff. apply bi.wand_iff_equiv. Qed.
Instance as_valid_morphism `{BiMorphism PROP PROP'} (φ : Prop) (P : PROP) :
Instance as_valid_embed `{BiEmbedding PROP PROP'} (φ : Prop) (P : PROP) :
AsValid φ P AsValid φ P.
Proof. rewrite /AsValid=> ->. rewrite bi_mor_valid //. Qed.
Proof. rewrite /AsValid=> ->. rewrite bi_embed_valid //. Qed.
(** * Start a proof *)
Tactic Notation "iStartProof" uconstr(PROP) :=
......
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