Commit e0a45a07 authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan
Browse files

Merge branch 'master' of gitlab.mpi-sws.org:FP/iris-coq

parents 5ffa64f9 626a2258
Pipeline #3753 passed with stage
in 4 minutes and 22 seconds
...@@ -130,10 +130,12 @@ Infix "⋅?" := opM (at level 50, left associativity) : C_scope. ...@@ -130,10 +130,12 @@ Infix "⋅?" := opM (at level 50, left associativity) : C_scope.
(** * Persistent elements *) (** * Persistent elements *)
Class Persistent {A : cmraT} (x : A) := persistent : pcore x Some x. Class Persistent {A : cmraT} (x : A) := persistent : pcore x Some x.
Arguments persistent {_} _ {_}. Arguments persistent {_} _ {_}.
Hint Mode Persistent + ! : typeclass_instances.
(** * Exclusive elements (i.e., elements that cannot have a frame). *) (** * Exclusive elements (i.e., elements that cannot have a frame). *)
Class Exclusive {A : cmraT} (x : A) := exclusive0_l y : {0} (x y) False. Class Exclusive {A : cmraT} (x : A) := exclusive0_l y : {0} (x y) False.
Arguments exclusive0_l {_} _ {_} _ _. Arguments exclusive0_l {_} _ {_} _ _.
Hint Mode Exclusive + ! : typeclass_instances.
(** * CMRAs whose core is total *) (** * CMRAs whose core is total *)
(** The function [core] may return a dummy when used on CMRAs without total (** The function [core] may return a dummy when used on CMRAs without total
...@@ -545,7 +547,7 @@ Section ucmra. ...@@ -545,7 +547,7 @@ Section ucmra.
Global Instance cmra_unit_total : CMRATotal A. Global Instance cmra_unit_total : CMRATotal A.
Proof. Proof.
intros x. destruct (cmra_pcore_mono' x ) as (cx&->&?); intros x. destruct (cmra_pcore_mono' x ) as (cx&->&?);
eauto using ucmra_unit_least, (persistent ). eauto using ucmra_unit_least, (persistent (:A)).
Qed. Qed.
End ucmra. End ucmra.
Hint Immediate cmra_unit_total. Hint Immediate cmra_unit_total.
......
...@@ -72,8 +72,10 @@ Hint Extern 1 (_ ≡{_}≡ _) => apply equiv_dist; assumption. ...@@ -72,8 +72,10 @@ Hint Extern 1 (_ ≡{_}≡ _) => apply equiv_dist; assumption.
(** Discrete OFEs and Timeless elements *) (** Discrete OFEs and Timeless elements *)
(* TODO: On paper, We called these "discrete elements". I think that makes (* TODO: On paper, We called these "discrete elements". I think that makes
more sense. *) more sense. *)
Class Timeless `{Equiv A, Dist A} (x : A) := timeless y : x {0} y x y. Class Timeless {A : ofeT} (x : A) := timeless y : x {0} y x y.
Arguments timeless {_ _ _} _ {_} _ _. Arguments timeless {_} _ {_} _ _.
Hint Mode Timeless + ! : typeclass_instances.
Class Discrete (A : ofeT) := discrete_timeless (x : A) :> Timeless x. Class Discrete (A : ofeT) := discrete_timeless (x : A) :> Timeless x.
(** OFEs with a completion *) (** OFEs with a completion *)
...@@ -1029,12 +1031,13 @@ Section sigma. ...@@ -1029,12 +1031,13 @@ Section sigma.
Global Instance sig_timeless (x : sig P) : Global Instance sig_timeless (x : sig P) :
Timeless (proj1_sig x) Timeless x. Timeless (proj1_sig x) Timeless x.
Proof. intros ? y. destruct x, y. unfold dist, sig_dist, equiv, sig_equiv. apply (timeless _). Qed.
Global Instance sig_discrete_cofe : Discrete A Discrete sigC.
Proof. Proof.
intros ? [??] [??]. rewrite /dist /equiv /ofe_dist /ofe_equiv /=. intros ? [b ?]; destruct x as [a ?].
rewrite /sig_dist /sig_equiv /=. apply discrete_timeless. rewrite /dist /ofe_dist /= /sig_dist /equiv /ofe_equiv /= /sig_equiv /=.
Qed. apply (timeless _).
Qed.
Global Instance sig_discrete_cofe : Discrete A Discrete sigC.
Proof. intros ??. apply _. Qed.
End sigma. End sigma.
Arguments sigC {_} _. Arguments sigC {_} _.
...@@ -12,10 +12,10 @@ Section ofe. ...@@ -12,10 +12,10 @@ Section ofe.
Definition vec_ofe_mixin m : OfeMixin (vec A m). Definition vec_ofe_mixin m : OfeMixin (vec A m).
Proof. Proof.
split. split.
- intros x y. apply (equiv_dist (A:=listC A)). - intros v w. apply (equiv_dist (A:=listC A)).
- unfold dist, vec_dist. split. - unfold dist, vec_dist. split.
by intros ?. by intros ??. by intros ?????; etrans. by intros ?. by intros ??. by intros ?????; etrans.
- intros. by apply (dist_S (A:=listC A)). - intros n v w. by apply (dist_S (A:=listC A)).
Qed. Qed.
Canonical Structure vecC m : ofeT := OfeT (vec A m) (vec_ofe_mixin m). Canonical Structure vecC m : ofeT := OfeT (vec A m) (vec_ofe_mixin m).
...@@ -48,22 +48,21 @@ Section proper. ...@@ -48,22 +48,21 @@ Section proper.
Proper (dist n ==> eq ==> dist n) (@Vector.nth A m). Proper (dist n ==> eq ==> dist n) (@Vector.nth A m).
Proof. Proof.
intros v. induction v as [|x m v IH]; intros v'; inv_vec v'. intros v. induction v as [|x m v IH]; intros v'; inv_vec v'.
- intros _ x. inversion x. - intros _ x. inv_fin x.
- intros x' v' EQ i ? <-. inversion_clear EQ. inv_fin i; first done. - intros x' v' EQ i ? <-. inversion_clear EQ. inv_fin i=> // i. by apply IH.
intros i. by apply IH.
Qed. Qed.
Global Instance vlookup_proper m : Global Instance vlookup_proper m :
Proper (equiv ==> eq ==> equiv) (@Vector.nth A m). Proper (equiv ==> eq ==> equiv) (@Vector.nth A m).
Proof. Proof.
intros ??????. apply equiv_dist=>?. subst. f_equiv. by apply equiv_dist. intros v v' ? x x' ->. apply equiv_dist=> n. f_equiv. by apply equiv_dist.
Qed. Qed.
Global Instance vec_to_list_ne n m : Global Instance vec_to_list_ne n m :
Proper (dist n ==> dist n) (@vec_to_list A m). Proper (dist n ==> dist n) (@vec_to_list A m).
Proof. intros ?? H. apply H. Qed. Proof. by intros v v'. Qed.
Global Instance vec_to_list_proper m : Global Instance vec_to_list_proper m :
Proper (equiv ==> equiv) (@vec_to_list A m). Proper (equiv ==> equiv) (@vec_to_list A m).
Proof. intros ?? H. apply H. Qed. Proof. by intros v v'. Qed.
End proper. End proper.
Section cofe. Section cofe.
...@@ -95,7 +94,7 @@ Instance vec_map_ne {A B : ofeT} m f n : ...@@ -95,7 +94,7 @@ Instance vec_map_ne {A B : ofeT} m f n :
Proper (dist n ==> dist n) f Proper (dist n ==> dist n) f
Proper (dist n ==> dist n) (@vec_map A B m f). Proper (dist n ==> dist n) (@vec_map A B m f).
Proof. Proof.
intros ??? H. eapply list_fmap_ne in H; last done. intros ? v v' H. eapply list_fmap_ne in H; last done.
by rewrite -!vec_to_list_map in H. by rewrite -!vec_to_list_map in H.
Qed. Qed.
Definition vecC_map {A B : ofeT} m (f : A -n> B) : vecC A m -n> vecC B m := Definition vecC_map {A B : ofeT} m (f : A -n> B) : vecC A m -n> vecC B m :=
......
...@@ -115,10 +115,12 @@ Notation "'[∗' 'mset' ] x ∈ X , P" := (big_opMS (M:=uPredUR _) X (λ x, P)) ...@@ -115,10 +115,12 @@ Notation "'[∗' 'mset' ] x ∈ X , P" := (big_opMS (M:=uPredUR _) X (λ x, P))
Class PersistentL {M} (Ps : list (uPred M)) := Class PersistentL {M} (Ps : list (uPred M)) :=
persistentL : Forall PersistentP Ps. persistentL : Forall PersistentP Ps.
Arguments persistentL {_} _ {_}. Arguments persistentL {_} _ {_}.
Hint Mode PersistentL + ! : typeclass_instances.
Class TimelessL {M} (Ps : list (uPred M)) := Class TimelessL {M} (Ps : list (uPred M)) :=
timelessL : Forall TimelessP Ps. timelessL : Forall TimelessP Ps.
Arguments timelessL {_} _ {_}. Arguments timelessL {_} _ {_}.
Hint Mode TimelessP + ! : typeclass_instances.
(** * Properties *) (** * Properties *)
Section big_op. Section big_op.
......
...@@ -31,10 +31,12 @@ Typeclasses Opaque uPred_except_0. ...@@ -31,10 +31,12 @@ Typeclasses Opaque uPred_except_0.
Class TimelessP {M} (P : uPred M) := timelessP : P P. Class TimelessP {M} (P : uPred M) := timelessP : P P.
Arguments timelessP {_} _ {_}. Arguments timelessP {_} _ {_}.
Hint Mode TimelessP + ! : typeclass_instances.
Class PersistentP {M} (P : uPred M) := persistentP : P P. Class PersistentP {M} (P : uPred M) := persistentP : P P.
Hint Mode PersistentP - ! : typeclass_instances. Hint Mode PersistentP - ! : typeclass_instances.
Arguments persistentP {_} _ {_}. Arguments persistentP {_} _ {_}.
Hint Mode PersistentP + ! : typeclass_instances.
Module uPred. Module uPred.
Section derived. Section derived.
...@@ -808,9 +810,43 @@ Global Instance from_option_timeless {A} P (Ψ : A → uPred M) (mx : option A) ...@@ -808,9 +810,43 @@ Global Instance from_option_timeless {A} P (Ψ : A → uPred M) (mx : option A)
( x, TimelessP (Ψ x)) TimelessP P TimelessP (from_option Ψ P mx). ( x, TimelessP (Ψ x)) TimelessP P TimelessP (from_option Ψ P mx).
Proof. destruct mx; apply _. Qed. Proof. destruct mx; apply _. Qed.
(* Derived lemmas for persistence *)
Lemma always_always P `{!PersistentP P} : P P.
Proof. apply (anti_symm ()); auto using always_elim. Qed.
Lemma always_if_always p P `{!PersistentP P} : ?p P P.
Proof. destruct p; simpl; auto using always_always. Qed.
Lemma always_intro P Q `{!PersistentP P} : (P Q) P Q.
Proof. rewrite -(always_always P); apply always_intro'. Qed.
Lemma always_and_sep_l P Q `{!PersistentP P} : P Q P Q.
Proof. by rewrite -(always_always P) always_and_sep_l'. Qed.
Lemma always_and_sep_r P Q `{!PersistentP Q} : P Q P Q.
Proof. by rewrite -(always_always Q) always_and_sep_r'. Qed.
Lemma always_sep_dup P `{!PersistentP P} : P P P.
Proof. by rewrite -(always_always P) -always_sep_dup'. Qed.
Lemma always_entails_l P Q `{!PersistentP Q} : (P Q) P Q P.
Proof. by rewrite -(always_always Q); apply always_entails_l'. Qed.
Lemma always_entails_r P Q `{!PersistentP Q} : (P Q) P P Q.
Proof. by rewrite -(always_always Q); apply always_entails_r'. Qed.
Lemma always_impl_wand P `{!PersistentP P} Q : (P Q) (P - Q).
Proof.
apply (anti_symm _); auto using impl_wand.
apply impl_intro_l. by rewrite always_and_sep_l wand_elim_r.
Qed.
(* Persistence *) (* Persistence *)
Global Instance pure_persistent φ : PersistentP (⌜φ⌝ : uPred M)%I. Global Instance pure_persistent φ : PersistentP (⌜φ⌝ : uPred M)%I.
Proof. by rewrite /PersistentP always_pure. Qed. Proof. by rewrite /PersistentP always_pure. Qed.
Global Instance pure_impl_persistent φ Q :
PersistentP Q PersistentP (⌜φ⌝ Q)%I.
Proof.
rewrite /PersistentP pure_impl_forall always_forall. auto using forall_mono.
Qed.
Global Instance pure_wand_persistent φ Q :
PersistentP Q PersistentP (⌜φ⌝ - Q)%I.
Proof.
rewrite /PersistentP -always_impl_wand pure_impl_forall always_forall.
auto using forall_mono.
Qed.
Global Instance always_persistent P : PersistentP ( P). Global Instance always_persistent P : PersistentP ( P).
Proof. by intros; apply always_intro'. Qed. Proof. by intros; apply always_intro'. Qed.
Global Instance and_persistent P Q : Global Instance and_persistent P Q :
...@@ -843,23 +879,5 @@ Proof. intros. by rewrite /PersistentP always_ownM. Qed. ...@@ -843,23 +879,5 @@ Proof. intros. by rewrite /PersistentP always_ownM. Qed.
Global Instance from_option_persistent {A} P (Ψ : A uPred M) (mx : option A) : Global Instance from_option_persistent {A} P (Ψ : A uPred M) (mx : option A) :
( x, PersistentP (Ψ x)) PersistentP P PersistentP (from_option Ψ P mx). ( x, PersistentP (Ψ x)) PersistentP P PersistentP (from_option Ψ P mx).
Proof. destruct mx; apply _. Qed. Proof. destruct mx; apply _. Qed.
(* Derived lemmas for persistence *)
Lemma always_always P `{!PersistentP P} : P P.
Proof. apply (anti_symm ()); auto using always_elim. Qed.
Lemma always_if_always p P `{!PersistentP P} : ?p P P.
Proof. destruct p; simpl; auto using always_always. Qed.
Lemma always_intro P Q `{!PersistentP P} : (P Q) P Q.
Proof. rewrite -(always_always P); apply always_intro'. Qed.
Lemma always_and_sep_l P Q `{!PersistentP P} : P Q P Q.
Proof. by rewrite -(always_always P) always_and_sep_l'. Qed.
Lemma always_and_sep_r P Q `{!PersistentP Q} : P Q P Q.
Proof. by rewrite -(always_always Q) always_and_sep_r'. Qed.
Lemma always_sep_dup P `{!PersistentP P} : P P P.
Proof. by rewrite -(always_always P) -always_sep_dup'. Qed.
Lemma always_entails_l P Q `{!PersistentP Q} : (P Q) P Q P.
Proof. by rewrite -(always_always Q); apply always_entails_l'. Qed.
Lemma always_entails_r P Q `{!PersistentP Q} : (P Q) P P Q.
Proof. by rewrite -(always_always Q); apply always_entails_r'. Qed.
End derived. End derived.
End uPred. End uPred.
...@@ -8,7 +8,7 @@ Import uPred. ...@@ -8,7 +8,7 @@ Import uPred.
in the shallow embedding. *) in the shallow embedding. *)
Definition coreP {M : ucmraT} (P : uPred M) : uPred M := Definition coreP {M : ucmraT} (P : uPred M) : uPred M :=
( `(!PersistentP Q, P Q), Q)%I. ( `(!PersistentP Q), P Q Q)%I.
Instance: Params (@coreP) 1. Instance: Params (@coreP) 1.
Typeclasses Opaque coreP. Typeclasses Opaque coreP.
...@@ -25,7 +25,7 @@ Section core. ...@@ -25,7 +25,7 @@ Section core.
Global Instance coreP_mono : Proper (() ==> ()) (@coreP M). Global Instance coreP_mono : Proper (() ==> ()) (@coreP M).
Proof. Proof.
rewrite /coreP. iIntros (P P' ?) "H"; iIntros (Q ??). rewrite /coreP. iIntros (P P' ?) "H"; iIntros (Q ??).
unshelve iApply ("H" $! Q). by etrans. iApply ("H" $! Q with "[%]"). by etrans.
Qed. Qed.
Global Instance coreP_proper : Proper (() ==> ()) (@coreP M). Global Instance coreP_proper : Proper (() ==> ()) (@coreP M).
......
...@@ -155,8 +155,10 @@ Section proofmode_classes. ...@@ -155,8 +155,10 @@ Section proofmode_classes.
Proof. rewrite /FromAssumption=>->. apply bupd_fupd. Qed. Proof. rewrite /FromAssumption=>->. apply bupd_fupd. Qed.
Global Instance into_wand_fupd E1 E2 R P Q : Global Instance into_wand_fupd E1 E2 R P Q :
IntoWand R P Q IntoWand R (|={E1,E2}=> P) (|={E1,E2}=> Q) | 100. IntoWand R P Q IntoWand' R (|={E1,E2}=> P) (|={E1,E2}=> Q) | 100.
Proof. rewrite /IntoWand=>->. apply wand_intro_l. by rewrite fupd_wand_r. Qed. Proof.
rewrite /IntoWand' /IntoWand=>->. apply wand_intro_l. by rewrite fupd_wand_r.
Qed.
Global Instance from_sep_fupd E P Q1 Q2 : Global Instance from_sep_fupd E P Q1 Q2 :
FromSep P Q1 Q2 FromSep (|={E}=> P) (|={E}=> Q1) (|={E}=> Q2). FromSep P Q1 Q2 FromSep (|={E}=> P) (|={E}=> Q1) (|={E}=> Q2).
...@@ -179,8 +181,8 @@ Section proofmode_classes. ...@@ -179,8 +181,8 @@ Section proofmode_classes.
Global Instance is_except_0_fupd E1 E2 P : IsExcept0 (|={E1,E2}=> P). Global Instance is_except_0_fupd E1 E2 P : IsExcept0 (|={E1,E2}=> P).
Proof. by rewrite /IsExcept0 except_0_fupd. Qed. Proof. by rewrite /IsExcept0 except_0_fupd. Qed.
Global Instance into_modal_fupd E P : IntoModal P (|={E}=> P). Global Instance from_modal_fupd E P : FromModal (|={E}=> P) P.
Proof. rewrite /IntoModal. apply fupd_intro. Qed. Proof. rewrite /FromModal. apply fupd_intro. Qed.
(* Put a lower priority compared to [elim_modal_fupd_fupd], so that (* Put a lower priority compared to [elim_modal_fupd_fupd], so that
it is not taken when the first parameter is not specified (in it is not taken when the first parameter is not specified (in
......
...@@ -101,13 +101,13 @@ Section sts. ...@@ -101,13 +101,13 @@ Section sts.
Proof. Proof.
iIntros "[Hinv Hγf]". rewrite /sts_ownS /sts_inv /sts_own. iIntros "[Hinv Hγf]". rewrite /sts_ownS /sts_inv /sts_own.
iDestruct "Hinv" as (s) "[>Hγ Hφ]". iDestruct "Hinv" as (s) "[>Hγ Hφ]".
iCombine "Hγ" "Hγf" as "Hγ"; iDestruct (own_valid with "Hγ") as %Hvalid. iDestruct (own_valid_2 with "Hγ Hγf") as %Hvalid.
assert (s S) by eauto using sts_auth_frag_valid_inv. assert (s S) by eauto using sts_auth_frag_valid_inv.
assert ( sts_frag S T) as [??] by eauto using cmra_valid_op_r. assert ( sts_frag S T) as [??] by eauto using cmra_valid_op_r.
rewrite sts_op_auth_frag //.
iModIntro; iExists s; iSplit; [done|]; iFrame "Hφ". iModIntro; iExists s; iSplit; [done|]; iFrame "Hφ".
iIntros (s' T') "[% Hφ]". iIntros (s' T') "[% Hφ]".
iMod (own_update with "Hγ") as "Hγ"; first eauto using sts_update_auth. iMod (own_update_2 with "Hγ Hγf") as "Hγ".
{ rewrite sts_op_auth_frag; [|done..]. by apply sts_update_auth. }
iRevert "Hγ"; rewrite -sts_op_auth_frag_up; iIntros "[Hγ $]". iRevert "Hγ"; rewrite -sts_op_auth_frag_up; iIntros "[Hγ $]".
iModIntro. iNext. iExists s'; by iFrame. iModIntro. iNext. iExists s'; by iFrame.
Qed. Qed.
......
...@@ -187,7 +187,8 @@ Proof. ...@@ -187,7 +187,8 @@ Proof.
Defined. Defined.
Ltac inv_vec v := Ltac inv_vec v :=
match type of v with let T := type of v in
match eval hnf in T with
| vec _ 0 => | vec _ 0 =>
revert dependent v; match goal with |- v, @?P v => apply (vec_0_inv P) end revert dependent v; match goal with |- v, @?P v => apply (vec_0_inv P) end
| vec _ (S ?n) => | vec _ (S ?n) =>
......
...@@ -219,15 +219,22 @@ Proof. apply and_elim_r', impl_wand. Qed. ...@@ -219,15 +219,22 @@ Proof. apply and_elim_r', impl_wand. Qed.
Global Instance into_wand_always R P Q : IntoWand R P Q IntoWand ( R) P Q. Global Instance into_wand_always R P Q : IntoWand R P Q IntoWand ( R) P Q.
Proof. rewrite /IntoWand=> ->. apply always_elim. Qed. Proof. rewrite /IntoWand=> ->. apply always_elim. Qed.
Global Instance into_wand_later (R1 R2 P Q : uPred M) : Global Instance into_wand_later (R1 R2 P Q : uPred M) :
IntoLaterN 1 R1 R2 IntoWand R2 P Q IntoWand R1 ( P) ( Q) | 99. IntoLaterN 1 R1 R2 IntoWand R2 P Q IntoWand' R1 ( P) ( Q) | 99.
Proof. rewrite /IntoLaterN /IntoWand=> -> ->. by rewrite -later_wand. Qed. Proof.
rewrite /IntoLaterN /IntoWand' /IntoWand=> -> ->. by rewrite -later_wand.
Qed.
Global Instance into_wand_laterN n (R1 R2 P Q : uPred M) : Global Instance into_wand_laterN n (R1 R2 P Q : uPred M) :
IntoLaterN n R1 R2 IntoWand R2 P Q IntoWand R1 (^n P) (^n Q) | 100. IntoLaterN n R1 R2 IntoWand R2 P Q IntoWand' R1 (^n P) (^n Q) | 100.
Proof. rewrite /IntoLaterN /IntoWand=> -> ->. by rewrite -laterN_wand. Qed. Proof.
rewrite /IntoLaterN /IntoWand' /IntoWand=> -> ->. by rewrite -laterN_wand.
Qed.
Global Instance into_wand_bupd R P Q : Global Instance into_wand_bupd R P Q :
IntoWand R P Q IntoWand R (|==> P) (|==> Q) | 98. IntoWand R P Q IntoWand' R (|==> P) (|==> Q) | 98.
Proof. rewrite /IntoWand=>->. apply wand_intro_l. by rewrite bupd_wand_r. Qed. Proof.
rewrite /IntoWand' /IntoWand=> ->. apply wand_intro_l. by rewrite bupd_wand_r.
Qed.
(* FromAnd *) (* FromAnd *)
Global Instance from_and_and P1 P2 : FromAnd (P1 P2) P1 P2. Global Instance from_and_and P1 P2 : FromAnd (P1 P2) P1 P2.
...@@ -564,12 +571,12 @@ Global Instance into_exist_laterN {A} n P (Φ : A → uPred M) : ...@@ -564,12 +571,12 @@ Global Instance into_exist_laterN {A} n P (Φ : A → uPred M) :
IntoExist P Φ Inhabited A IntoExist (^n P) (λ a, ^n (Φ a))%I. IntoExist P Φ Inhabited A IntoExist (^n P) (λ a, ^n (Φ a))%I.
Proof. rewrite /IntoExist=> HP ?. by rewrite HP laterN_exist. Qed. Proof. rewrite /IntoExist=> HP ?. by rewrite HP laterN_exist. Qed.
(* IntoModal *) (* FromModal *)
Global Instance into_modal_later P : IntoModal P ( P). Global Instance from_modal_later P : FromModal ( P) P.
Proof. apply later_intro. Qed. Proof. apply later_intro. Qed.
Global Instance into_modal_bupd P : IntoModal P (|==> P). Global Instance from_modal_bupd P : FromModal (|==> P) P.
Proof. apply bupd_intro. Qed. Proof. apply bupd_intro. Qed.
Global Instance into_modal_except_0 P : IntoModal P ( P). Global Instance from_modal_except_0 P : FromModal ( P) P.
Proof. apply except_0_intro. Qed. Proof. apply except_0_intro. Qed.
(* ElimModal *) (* ElimModal *)
......
...@@ -2,77 +2,102 @@ From iris.base_logic Require Export base_logic. ...@@ -2,77 +2,102 @@ From iris.base_logic Require Export base_logic.
Set Default Proof Using "Type". Set Default Proof Using "Type".
Import uPred. Import uPred.
Section classes. Class FromAssumption {M} (p : bool) (P Q : uPred M) :=
Context {M : ucmraT}. from_assumption : ?p P Q.
Implicit Types P Q : uPred M. Arguments from_assumption {_} _ _ _ {_}.
Hint Mode FromAssumption + + ! - : typeclass_instances.
Class FromAssumption (p : bool) (P Q : uPred M) := from_assumption : ?p P Q.
Global Arguments from_assumption _ _ _ {_}. Class IntoPure {M} (P : uPred M) (φ : Prop) := into_pure : P ⌜φ⌝.
Arguments into_pure {_} _ _ {_}.
Class IntoPure (P : uPred M) (φ : Prop) := into_pure : P ⌜φ⌝. Hint Mode IntoPure + ! - : typeclass_instances.
Global Arguments into_pure : clear implicits.
Class FromPure {M} (P : uPred M) (φ : Prop) := from_pure : ⌜φ⌝ P.
Class FromPure (P : uPred M) (φ : Prop) := from_pure : ⌜φ⌝ P. Arguments from_pure {_} _ _ {_}.
Global Arguments from_pure : clear implicits. Hint Mode FromPure + ! - : typeclass_instances.
Class IntoPersistentP (P Q : uPred M) := into_persistentP : P Q. Class IntoPersistentP {M} (P Q : uPred M) := into_persistentP : P Q.
Global Arguments into_persistentP : clear implicits. Arguments into_persistentP {_} _ _ {_}.
Hint Mode IntoPersistentP + ! - : typeclass_instances.
Class IntoLaterN (n : nat) (P Q : uPred M) := into_laterN : P ^n Q.
Global Arguments into_laterN _ _ _ {_}. Class IntoLaterN {M} (n : nat) (P Q : uPred M) := into_laterN : P ^n Q.
Arguments into_laterN {_} _ _ _ {_}.
Class FromLaterN (n : nat) (P Q : uPred M) := from_laterN : ^n Q P. Hint Mode IntoLaterN + - ! - : typeclass_instances.
Global Arguments from_laterN _ _ _ {_}.
Class FromLaterN {M} (n : nat) (P Q : uPred M) := from_laterN : ^n Q P.
Class IntoWand (R P Q : uPred M) := into_wand : R P - Q. Arguments from_laterN {_} _ _ _ {_}.
Global Arguments into_wand : clear implicits. Hint Mode FromLaterN + - ! - : typeclass_instances.
Class FromAnd (P Q1 Q2 : uPred M) := from_and : Q1 Q2 P. Class IntoWand {M} (R P Q : uPred M) := into_wand : R P - Q.
Global Arguments from_and : clear implicits. Arguments into_wand {_} _ _ _ {_}.
Hint Mode IntoWand + ! - - : typeclass_instances.
Class FromSep (P Q1 Q2 : uPred M) := from_sep : Q1 Q2 P.
Global Arguments from_sep : clear implicits. Class IntoWand' {M} (R P Q : uPred M) := into_wand' :> IntoWand R P Q.
Arguments into_wand' {_} _ _ _ {_}.
Class IntoAnd (p : bool) (P Q1 Q2 : uPred M) := Hint Mode IntoWand' + ! ! - : typeclass_instances.
Hint Mode IntoWand' + ! - ! : typeclass_instances.
Class FromAnd {M} (P Q1 Q2 : uPred M) := from_and : Q1 Q2 P.
Arguments from_and {_} _ _ _ {_}.
Hint Mode FromAnd + ! - - : typeclass_instances.
Class FromSep {M} (P Q1 Q2 : uPred M) := from_sep : Q1 Q2 P.
Arguments from_sep {_} _ _ _ {_}.
Hint Mode FromSep + ! - - : typeclass_instances.
Hint Mode FromSep + - ! ! : typeclass_instances. (* For iCombine *)
Class IntoAnd {M} (p : bool) (P Q1 Q2 : uPred M) :=
into_and : P if p then Q1 Q2 else Q1 Q2. into_and : P if p then Q1 Q2 else Q1 Q2.
Global Arguments into_and : clear implicits. Arguments into_and {_} _ _ _ _ {_}.
Hint Mode IntoAnd + + ! - - : typeclass_instances.
Lemma mk_into_and_sep p P Q1 Q2 : (P Q1 Q2) IntoAnd p P Q1 Q2. Lemma mk_into_and_sep {M} p (P Q1 Q2 : uPred M) :
(P Q1 Q2) IntoAnd p P Q1 Q2.
Proof. rewrite /IntoAnd=>->. destruct p; auto using sep_and. Qed. Proof. rewrite /IntoAnd=>->. destruct p; auto using sep_and. Qed.
Class FromOp {A : cmraT} (a b1 b2 : A) := from_op : b1 b2 a. Class FromOp {A : cmraT} (a b1 b2 : A) :