Commit 6aba4a3f authored by Robbert Krebbers's avatar Robbert Krebbers

Notations `=@{A}` and `≡@{A}` for being explicit about the type of (setoid) equality.

This followed from discussions in https://gitlab.mpi-sws.org/FP/iris-coq/merge_requests/134
parent 3bcaaf7e
...@@ -159,10 +159,16 @@ Notation "(≠)" := (λ x y, x ≠ y) (only parsing) : stdpp_scope. ...@@ -159,10 +159,16 @@ Notation "(≠)" := (λ x y, x ≠ y) (only parsing) : stdpp_scope.
Notation "( x ≠)" := (λ y, x y) (only parsing) : stdpp_scope. Notation "( x ≠)" := (λ y, x y) (only parsing) : stdpp_scope.
Notation "(≠ x )" := (λ y, y x) (only parsing) : stdpp_scope. Notation "(≠ x )" := (λ y, y x) (only parsing) : stdpp_scope.
Infix "=@{ A }" := (@eq A)
(at level 70, only parsing, no associativity) : stdpp_scope.
Notation "(=@{ A } )" := (@eq A) (only parsing) : stdpp_scope.
Notation "(≠@{ A } )" := (λ X Y, ¬X =@{A} Y) (only parsing) : stdpp_scope.
Notation "X ≠@{ A } Y":= (¬X =@{ A } Y) (at level 70, no associativity) : stdpp_scope.
Hint Extern 0 (_ = _) => reflexivity. Hint Extern 0 (_ = _) => reflexivity.
Hint Extern 100 (_ _) => discriminate. Hint Extern 100 (_ _) => discriminate.
Instance: @PreOrder A (=). Instance: A, PreOrder (=@{A}).
Proof. split; repeat intro; congruence. Qed. Proof. split; repeat intro; congruence. Qed.
(** ** Setoid equality *) (** ** Setoid equality *)
...@@ -174,6 +180,9 @@ Class Equiv A := equiv: relation A. ...@@ -174,6 +180,9 @@ Class Equiv A := equiv: relation A.
Hint Mode Equiv ! : typeclass_instances. *) Hint Mode Equiv ! : typeclass_instances. *)
Infix "≡" := equiv (at level 70, no associativity) : stdpp_scope. Infix "≡" := equiv (at level 70, no associativity) : stdpp_scope.
Infix "≡@{ A }" := (@equiv A _)
(at level 70, only parsing, no associativity) : stdpp_scope.
Notation "(≡)" := equiv (only parsing) : stdpp_scope. Notation "(≡)" := equiv (only parsing) : stdpp_scope.
Notation "( X ≡)" := (equiv X) (only parsing) : stdpp_scope. Notation "( X ≡)" := (equiv X) (only parsing) : stdpp_scope.
Notation "(≡ X )" := (λ Y, Y X) (only parsing) : stdpp_scope. Notation "(≡ X )" := (λ Y, Y X) (only parsing) : stdpp_scope.
...@@ -182,6 +191,10 @@ Notation "X ≢ Y":= (¬X ≡ Y) (at level 70, no associativity) : stdpp_scope. ...@@ -182,6 +191,10 @@ Notation "X ≢ Y":= (¬X ≡ Y) (at level 70, no associativity) : stdpp_scope.
Notation "( X ≢)" := (λ Y, X Y) (only parsing) : stdpp_scope. Notation "( X ≢)" := (λ Y, X Y) (only parsing) : stdpp_scope.
Notation "(≢ X )" := (λ Y, Y X) (only parsing) : stdpp_scope. Notation "(≢ X )" := (λ Y, Y X) (only parsing) : stdpp_scope.
Notation "(≡@{ A } )" := (@equiv A _) (only parsing) : stdpp_scope.
Notation "(≢@{ A } )" := (λ X Y, ¬X @{A} Y) (only parsing) : stdpp_scope.
Notation "X ≢@{ A } Y":= (¬X @{ A } Y) (at level 70, no associativity) : stdpp_scope.
(** The type class [LeibnizEquiv] collects setoid equalities that coincide (** The type class [LeibnizEquiv] collects setoid equalities that coincide
with Leibniz equality. We provide the tactic [fold_leibniz] to transform such with Leibniz equality. We provide the tactic [fold_leibniz] to transform such
setoid equalities into Leibniz equalities, and [unfold_leibniz] for the setoid equalities into Leibniz equalities, and [unfold_leibniz] for the
...@@ -189,22 +202,22 @@ reverse. *) ...@@ -189,22 +202,22 @@ reverse. *)
Class LeibnizEquiv A `{Equiv A} := leibniz_equiv x y : x y x = y. Class LeibnizEquiv A `{Equiv A} := leibniz_equiv x y : x y x = y.
Hint Mode LeibnizEquiv ! - : typeclass_instances. Hint Mode LeibnizEquiv ! - : typeclass_instances.
Lemma leibniz_equiv_iff `{LeibnizEquiv A, !Reflexive (@equiv A _)} (x y : A) : Lemma leibniz_equiv_iff `{LeibnizEquiv A, !Reflexive (@{A})} (x y : A) :
x y x = y. x y x = y.
Proof. split. apply leibniz_equiv. intros ->; reflexivity. Qed. Proof. split. apply leibniz_equiv. intros ->; reflexivity. Qed.
Ltac fold_leibniz := repeat Ltac fold_leibniz := repeat
match goal with match goal with
| H : context [ @equiv ?A _ _ _ ] |- _ => | H : context [ _ @{?A} _ ] |- _ =>
setoid_rewrite (leibniz_equiv_iff (A:=A)) in H setoid_rewrite (leibniz_equiv_iff (A:=A)) in H
| |- context [ @equiv ?A _ _ _ ] => | |- context [ _ @{?A} _ ] =>
setoid_rewrite (leibniz_equiv_iff (A:=A)) setoid_rewrite (leibniz_equiv_iff (A:=A))
end. end.
Ltac unfold_leibniz := repeat Ltac unfold_leibniz := repeat
match goal with match goal with
| H : context [ @eq ?A _ _ ] |- _ => | H : context [ _ =@{?A} _ ] |- _ =>
setoid_rewrite <-(leibniz_equiv_iff (A:=A)) in H setoid_rewrite <-(leibniz_equiv_iff (A:=A)) in H
| |- context [ @eq ?A _ _ ] => | |- context [ _ =@{?A} _ ] =>
setoid_rewrite <-(leibniz_equiv_iff (A:=A)) setoid_rewrite <-(leibniz_equiv_iff (A:=A))
end. end.
...@@ -249,7 +262,7 @@ Class RelDecision {A B} (R : A → B → Prop) := ...@@ -249,7 +262,7 @@ Class RelDecision {A B} (R : A → B → Prop) :=
decide_rel x y :> Decision (R x y). decide_rel x y :> Decision (R x y).
Hint Mode RelDecision ! ! ! : typeclass_instances. Hint Mode RelDecision ! ! ! : typeclass_instances.
Arguments decide_rel {_ _} _ {_} _ _ : simpl never, assert. Arguments decide_rel {_ _} _ {_} _ _ : simpl never, assert.
Notation EqDecision A := (RelDecision (@eq A)). Notation EqDecision A := (RelDecision (=@{A})).
(** ** Inhabited types *) (** ** Inhabited types *)
(** This type class collects types that are inhabited. *) (** This type class collects types that are inhabited. *)
...@@ -411,9 +424,9 @@ Lemma exist_proper {A} (P Q : A → Prop) : ...@@ -411,9 +424,9 @@ Lemma exist_proper {A} (P Q : A → Prop) :
( x, P x Q x) ( x, P x) ( x, Q x). ( x, P x Q x) ( x, P x) ( x, Q x).
Proof. firstorder. Qed. Proof. firstorder. Qed.
Instance: Comm () (@eq A). Instance: Comm () (=@{A}).
Proof. red; intuition. Qed. Proof. red; intuition. Qed.
Instance: Comm () (λ x y, @eq A y x). Instance: Comm () (λ x y, y =@{A} x).
Proof. red; intuition. Qed. Proof. red; intuition. Qed.
Instance: Comm () (). Instance: Comm () ().
Proof. red; intuition. Qed. Proof. red; intuition. Qed.
...@@ -551,7 +564,7 @@ Proof. now intros -> ?. Qed. ...@@ -551,7 +564,7 @@ Proof. now intros -> ?. Qed.
(** ** Unit *) (** ** Unit *)
Instance unit_equiv : Equiv unit := λ _ _, True. Instance unit_equiv : Equiv unit := λ _ _, True.
Instance unit_equivalence : Equivalence (@equiv unit _). Instance unit_equivalence : Equivalence (@{unit}).
Proof. repeat split. Qed. Proof. repeat split. Qed.
Instance unit_leibniz : LeibnizEquiv unit. Instance unit_leibniz : LeibnizEquiv unit.
Proof. intros [] []; reflexivity. Qed. Proof. intros [] []; reflexivity. Qed.
......
...@@ -192,7 +192,7 @@ Qed. ...@@ -192,7 +192,7 @@ Qed.
Instance coPset_elem_of_dec : RelDecision (@elem_of _ coPset _). Instance coPset_elem_of_dec : RelDecision (@elem_of _ coPset _).
Proof. solve_decision. Defined. Proof. solve_decision. Defined.
Instance coPset_equiv_dec : RelDecision (@equiv coPset _). Instance coPset_equiv_dec : RelDecision (@{coPset}).
Proof. refine (λ X Y, cast_if (decide (X = Y))); abstract (by fold_leibniz). Defined. Proof. refine (λ X Y, cast_if (decide (X = Y))); abstract (by fold_leibniz). Defined.
Instance mapset_disjoint_dec : RelDecision (@disjoint coPset _). Instance mapset_disjoint_dec : RelDecision (@disjoint coPset _).
Proof. Proof.
......
...@@ -19,14 +19,14 @@ Typeclasses Opaque collection_equiv collection_subseteq collection_disjoint. ...@@ -19,14 +19,14 @@ Typeclasses Opaque collection_equiv collection_subseteq collection_disjoint.
Section setoids_simple. Section setoids_simple.
Context `{SimpleCollection A C}. Context `{SimpleCollection A C}.
Global Instance collection_equivalence: @Equivalence C (). Global Instance collection_equivalence : Equivalence (@{C}).
Proof. Proof.
split. split.
- done. - done.
- intros X Y ? x. by symmetry. - intros X Y ? x. by symmetry.
- intros X Y Z ?? x; by trans (x Y). - intros X Y Z ?? x; by trans (x Y).
Qed. Qed.
Global Instance singleton_proper : Proper ((=) ==> ()) (singleton (B:=C)). Global Instance singleton_proper : Proper ((=) ==> (@{C})) singleton.
Proof. apply _. Qed. Proof. apply _. Qed.
Global Instance elem_of_proper : Global Instance elem_of_proper :
Proper ((=) ==> () ==> iff) (@elem_of A C _) | 5. Proper ((=) ==> () ==> iff) (@elem_of A C _) | 5.
...@@ -35,11 +35,11 @@ Section setoids_simple. ...@@ -35,11 +35,11 @@ Section setoids_simple.
Proof. Proof.
intros X1 X2 HX Y1 Y2 HY; apply forall_proper; intros x. by rewrite HX, HY. intros X1 X2 HX Y1 Y2 HY; apply forall_proper; intros x. by rewrite HX, HY.
Qed. Qed.
Global Instance union_proper : Proper (() ==> () ==> ()) (@union C _). Global Instance union_proper : Proper (() ==> () ==> (@{C})) union.
Proof. intros X1 X2 HX Y1 Y2 HY x. rewrite !elem_of_union. f_equiv; auto. Qed. Proof. intros X1 X2 HX Y1 Y2 HY x. rewrite !elem_of_union. f_equiv; auto. Qed.
Global Instance union_list_proper: Proper (() ==> ()) (union_list (A:=C)). Global Instance union_list_proper: Proper (() ==> (@{C})) union_list.
Proof. by induction 1; simpl; try apply union_proper. Qed. Proof. by induction 1; simpl; try apply union_proper. Qed.
Global Instance subseteq_proper : Proper (() ==> () ==> iff) (() : relation C). Global Instance subseteq_proper : Proper ((@{C}) ==> (@{C}) ==> iff) ().
Proof. Proof.
intros X1 X2 HX Y1 Y2 HY. apply forall_proper; intros x. by rewrite HX, HY. intros X1 X2 HX Y1 Y2 HY. apply forall_proper; intros x. by rewrite HX, HY.
Qed. Qed.
...@@ -50,12 +50,12 @@ Section setoids. ...@@ -50,12 +50,12 @@ Section setoids.
(** * Setoids *) (** * Setoids *)
Global Instance intersection_proper : Global Instance intersection_proper :
Proper (() ==> () ==> ()) (@intersection C _). Proper (() ==> () ==> (@{C})) intersection.
Proof. Proof.
intros X1 X2 HX Y1 Y2 HY x. by rewrite !elem_of_intersection, HX, HY. intros X1 X2 HX Y1 Y2 HY x. by rewrite !elem_of_intersection, HX, HY.
Qed. Qed.
Global Instance difference_proper : Global Instance difference_proper :
Proper (() ==> () ==> ()) (@difference C _). Proper (() ==> () ==> (@{C})) difference.
Proof. Proof.
intros X1 X2 HX Y1 Y2 HY x. by rewrite !elem_of_difference, HX, HY. intros X1 X2 HX Y1 Y2 HY x. by rewrite !elem_of_difference, HX, HY.
Qed. Qed.
...@@ -357,15 +357,15 @@ Section simple_collection. ...@@ -357,15 +357,15 @@ Section simple_collection.
Lemma union_mono X1 X2 Y1 Y2 : X1 X2 Y1 Y2 X1 Y1 X2 Y2. Lemma union_mono X1 X2 Y1 Y2 : X1 X2 Y1 Y2 X1 Y1 X2 Y2.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Global Instance union_idemp : IdemP (() : relation C) (). Global Instance union_idemp : IdemP (@{C}) ().
Proof. intros X. set_solver. Qed. Proof. intros X. set_solver. Qed.
Global Instance union_empty_l : LeftId (() : relation C) (). Global Instance union_empty_l : LeftId (@{C}) ().
Proof. intros X. set_solver. Qed. Proof. intros X. set_solver. Qed.
Global Instance union_empty_r : RightId (() : relation C) (). Global Instance union_empty_r : RightId (@{C}) ().
Proof. intros X. set_solver. Qed. Proof. intros X. set_solver. Qed.
Global Instance union_comm : Comm (() : relation C) (). Global Instance union_comm : Comm (@{C}) ().
Proof. intros X Y. set_solver. Qed. Proof. intros X Y. set_solver. Qed.
Global Instance union_assoc : Assoc (() : relation C) (). Global Instance union_assoc : Assoc (@{C}) ().
Proof. intros X Y Z. set_solver. Qed. Proof. intros X Y Z. set_solver. Qed.
Lemma empty_union X Y : X Y X Y . Lemma empty_union X Y : X Y X Y .
...@@ -480,15 +480,15 @@ Section simple_collection. ...@@ -480,15 +480,15 @@ Section simple_collection.
Proof. unfold_leibniz. apply subseteq_union_2. Qed. Proof. unfold_leibniz. apply subseteq_union_2. Qed.
(** Union *) (** Union *)
Global Instance union_idemp_L : IdemP (@eq C) (). Global Instance union_idemp_L : IdemP (=@{C}) ().
Proof. intros ?. unfold_leibniz. apply (idemp _). Qed. Proof. intros ?. unfold_leibniz. apply (idemp _). Qed.
Global Instance union_empty_l_L : LeftId (@eq C) (). Global Instance union_empty_l_L : LeftId (=@{C}) ().
Proof. intros ?. unfold_leibniz. apply (left_id _ _). Qed. Proof. intros ?. unfold_leibniz. apply (left_id _ _). Qed.
Global Instance union_empty_r_L : RightId (@eq C) (). Global Instance union_empty_r_L : RightId (=@{C}) ().
Proof. intros ?. unfold_leibniz. apply (right_id _ _). Qed. Proof. intros ?. unfold_leibniz. apply (right_id _ _). Qed.
Global Instance union_comm_L : Comm (@eq C) (). Global Instance union_comm_L : Comm (=@{C}) ().
Proof. intros ??. unfold_leibniz. apply (comm _). Qed. Proof. intros ??. unfold_leibniz. apply (comm _). Qed.
Global Instance union_assoc_L : Assoc (@eq C) (). Global Instance union_assoc_L : Assoc (=@{C}) ().
Proof. intros ???. unfold_leibniz. apply (assoc _). Qed. Proof. intros ???. unfold_leibniz. apply (assoc _). Qed.
Lemma empty_union_L X Y : X Y = X = Y = . Lemma empty_union_L X Y : X Y = X = Y = .
...@@ -527,7 +527,7 @@ Section simple_collection. ...@@ -527,7 +527,7 @@ Section simple_collection.
End leibniz. End leibniz.
Section dec. Section dec.
Context `{!RelDecision (@equiv C _)}. Context `{!RelDecision (@{C})}.
Lemma collection_subseteq_inv X Y : X Y X Y X Y. Lemma collection_subseteq_inv X Y : X Y X Y X Y.
Proof. destruct (decide (X Y)); [by right|left;set_solver]. Qed. Proof. destruct (decide (X Y)); [by right|left;set_solver]. Qed.
Lemma collection_not_subset_inv X Y : X Y X Y X Y. Lemma collection_not_subset_inv X Y : X Y X Y X Y.
...@@ -580,15 +580,15 @@ Section collection. ...@@ -580,15 +580,15 @@ Section collection.
X1 X2 Y1 Y2 X1 Y1 X2 Y2. X1 X2 Y1 Y2 X1 Y1 X2 Y2.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Global Instance intersection_idemp : IdemP (() : relation C) (). Global Instance intersection_idemp : IdemP (@{C}) ().
Proof. intros X; set_solver. Qed. Proof. intros X; set_solver. Qed.
Global Instance intersection_comm : Comm (() : relation C) (). Global Instance intersection_comm : Comm (@{C}) ().
Proof. intros X Y; set_solver. Qed. Proof. intros X Y; set_solver. Qed.
Global Instance intersection_assoc : Assoc (() : relation C) (). Global Instance intersection_assoc : Assoc (@{C}) ().
Proof. intros X Y Z; set_solver. Qed. Proof. intros X Y Z; set_solver. Qed.
Global Instance intersection_empty_l : LeftAbsorb (() : relation C) (). Global Instance intersection_empty_l : LeftAbsorb (@{C}) ().
Proof. intros X; set_solver. Qed. Proof. intros X; set_solver. Qed.
Global Instance intersection_empty_r: RightAbsorb (() : relation C) (). Global Instance intersection_empty_r: RightAbsorb (@{C}) ().
Proof. intros X; set_solver. Qed. Proof. intros X; set_solver. Qed.
Lemma intersection_singletons x : ({[x]} : C) {[x]} {[x]}. Lemma intersection_singletons x : ({[x]} : C) {[x]} {[x]}.
...@@ -647,15 +647,15 @@ Section collection. ...@@ -647,15 +647,15 @@ Section collection.
Lemma subseteq_intersection_2_L X Y : X Y = X X Y. Lemma subseteq_intersection_2_L X Y : X Y = X X Y.
Proof. unfold_leibniz. apply subseteq_intersection_2. Qed. Proof. unfold_leibniz. apply subseteq_intersection_2. Qed.
Global Instance intersection_idemp_L : IdemP ((=) : relation C) (). Global Instance intersection_idemp_L : IdemP (=@{C}) ().
Proof. intros ?. unfold_leibniz. apply (idemp _). Qed. Proof. intros ?. unfold_leibniz. apply (idemp _). Qed.
Global Instance intersection_comm_L : Comm ((=) : relation C) (). Global Instance intersection_comm_L : Comm (=@{C}) ().
Proof. intros ??. unfold_leibniz. apply (comm _). Qed. Proof. intros ??. unfold_leibniz. apply (comm _). Qed.
Global Instance intersection_assoc_L : Assoc ((=) : relation C) (). Global Instance intersection_assoc_L : Assoc (=@{C}) ().
Proof. intros ???. unfold_leibniz. apply (assoc _). Qed. Proof. intros ???. unfold_leibniz. apply (assoc _). Qed.
Global Instance intersection_empty_l_L: LeftAbsorb ((=) : relation C) (). Global Instance intersection_empty_l_L: LeftAbsorb (=@{C}) ().
Proof. intros ?. unfold_leibniz. apply (left_absorb _ _). Qed. Proof. intros ?. unfold_leibniz. apply (left_absorb _ _). Qed.
Global Instance intersection_empty_r_L: RightAbsorb ((=) : relation C) (). Global Instance intersection_empty_r_L: RightAbsorb (=@{C}) ().
Proof. intros ?. unfold_leibniz. apply (right_absorb _ _). Qed. Proof. intros ?. unfold_leibniz. apply (right_absorb _ _). Qed.
Lemma intersection_singletons_L x : {[x]} {[x]} = ({[x]} : C). Lemma intersection_singletons_L x : {[x]} {[x]} = ({[x]} : C).
...@@ -776,17 +776,17 @@ Section of_option_list. ...@@ -776,17 +776,17 @@ Section of_option_list.
SetUnfold (x l) P SetUnfold (x of_list (C:=C) l) P. SetUnfold (x l) P SetUnfold (x of_list (C:=C) l) P.
Proof. constructor. by rewrite elem_of_of_list, (set_unfold (x l) P). Qed. Proof. constructor. by rewrite elem_of_of_list, (set_unfold (x l) P). Qed.
Lemma of_list_nil : of_list (C:=C) [] = . Lemma of_list_nil : of_list [] =@{C} .
Proof. done. Qed. Proof. done. Qed.
Lemma of_list_cons x l : of_list (C:=C) (x :: l) = {[ x ]} of_list l. Lemma of_list_cons x l : of_list (x :: l) =@{C} {[ x ]} of_list l.
Proof. done. Qed. Proof. done. Qed.
Lemma of_list_app l1 l2 : of_list (C:=C) (l1 ++ l2) of_list l1 of_list l2. Lemma of_list_app l1 l2 : of_list (l1 ++ l2) @{C} of_list l1 of_list l2.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Global Instance of_list_perm : Proper (() ==> ()) (of_list (C:=C)). Global Instance of_list_perm : Proper (() ==> ()) (of_list (C:=C)).
Proof. induction 1; set_solver. Qed. Proof. induction 1; set_solver. Qed.
Context `{!LeibnizEquiv C}. Context `{!LeibnizEquiv C}.
Lemma of_list_app_L l1 l2 : of_list (C:=C) (l1 ++ l2) = of_list l1 of_list l2. Lemma of_list_app_L l1 l2 : of_list (l1 ++ l2) =@{C} of_list l1 of_list l2.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Global Instance of_list_perm_L : Proper (() ==> (=)) (of_list (C:=C)). Global Instance of_list_perm_L : Proper (() ==> (=)) (of_list (C:=C)).
Proof. induction 1; set_solver. Qed. Proof. induction 1; set_solver. Qed.
...@@ -887,10 +887,9 @@ Section fresh. ...@@ -887,10 +887,9 @@ Section fresh.
Context `{FreshSpec A C}. Context `{FreshSpec A C}.
Implicit Types X Y : C. Implicit Types X Y : C.
Global Instance fresh_proper: Proper (() ==> (=)) (fresh (C:=C)). Global Instance fresh_proper: Proper ((@{C}) ==> (=)) fresh.
Proof. intros ???. by apply fresh_proper_alt, elem_of_equiv. Qed. Proof. intros ???. by apply fresh_proper_alt, elem_of_equiv. Qed.
Global Instance fresh_list_proper n: Global Instance fresh_list_proper n : Proper ((@{C}) ==> (=)) (fresh_list n).
Proper (() ==> (=)) (fresh_list (C:=C) n).
Proof. induction n as [|n IH]; intros ?? E; by setoid_subst. Qed. Proof. induction n as [|n IH]; intros ?? E; by setoid_subst. Qed.
Lemma exist_fresh X : x, x X. Lemma exist_fresh X : x, x X.
...@@ -1058,13 +1057,13 @@ Section seq_set. ...@@ -1058,13 +1057,13 @@ Section seq_set.
Proof. intros x. rewrite elem_of_singleton, elem_of_seq_set. omega. Qed. Proof. intros x. rewrite elem_of_singleton, elem_of_seq_set. omega. Qed.
Lemma seq_set_S_union start len : Lemma seq_set_S_union start len :
seq_set start (C:=C) (S len) {[ start + len ]} seq_set start len. seq_set start (S len) @{C} {[ start + len ]} seq_set start len.
Proof. Proof.
intros x. rewrite elem_of_union, elem_of_singleton, !elem_of_seq_set. omega. intros x. rewrite elem_of_union, elem_of_singleton, !elem_of_seq_set. omega.
Qed. Qed.
Lemma seq_set_S_union_L `{!LeibnizEquiv C} start len : Lemma seq_set_S_union_L `{!LeibnizEquiv C} start len :
seq_set start (C:=C) (S len) = {[ start + len ]} seq_set start len. seq_set start (S len) =@{C} {[ start + len ]} seq_set start len.
Proof. unfold_leibniz. apply seq_set_S_union. Qed. Proof. unfold_leibniz. apply seq_set_S_union. Qed.
End seq_set. End seq_set.
...@@ -1078,7 +1077,7 @@ Section minimal. ...@@ -1078,7 +1077,7 @@ Section minimal.
Context `{SimpleCollection A C} {R : relation A}. Context `{SimpleCollection A C} {R : relation A}.
Implicit Types X Y : C. Implicit Types X Y : C.
Global Instance minimal_proper x : Proper (@equiv C _ ==> iff) (minimal R x). Global Instance minimal_proper x : Proper ((@{C}) ==> iff) (minimal R x).
Proof. intros X X' y; unfold minimal; set_solver. Qed. Proof. intros X X' y; unfold minimal; set_solver. Qed.
Lemma minimal_anti_symm_1 `{!AntiSymm (=) R} X x y : Lemma minimal_anti_symm_1 `{!AntiSymm (=) R} X x y :
......
...@@ -147,38 +147,34 @@ Section setoid. ...@@ -147,38 +147,34 @@ Section setoid.
m1 m2 m1 !! i = Some x y, m2 !! i = Some y x y. m1 m2 m1 !! i = Some x y, m2 !! i = Some y x y.
Proof. generalize (equiv_Some_inv_l (m1 !! i) (m2 !! i) x); naive_solver. Qed. Proof. generalize (equiv_Some_inv_l (m1 !! i) (m2 !! i) x); naive_solver. Qed.
Global Instance map_equivalence : Global Instance map_equivalence : Equivalence (@{A}) Equivalence (@{M A}).
Equivalence (() : relation A) Equivalence (() : relation (M A)).
Proof. Proof.
split. split.
- by intros m i. - by intros m i.
- by intros m1 m2 ? i. - by intros m1 m2 ? i.
- by intros m1 m2 m3 ?? i; trans (m2 !! i). - by intros m1 m2 m3 ?? i; trans (m2 !! i).
Qed. Qed.
Global Instance lookup_proper (i : K) : Global Instance lookup_proper (i : K) : Proper ((@{M A}) ==> ()) (lookup i).
Proper (() ==> ()) (lookup (M:=M A) i).
Proof. by intros m1 m2 Hm. Qed. Proof. by intros m1 m2 Hm. Qed.
Global Instance partial_alter_proper : Global Instance partial_alter_proper :
Proper ((() ==> ()) ==> (=) ==> () ==> ()) (partial_alter (M:=M A)). Proper ((() ==> ()) ==> (=) ==> () ==> (@{M A})) partial_alter.
Proof. Proof.
by intros f1 f2 Hf i ? <- m1 m2 Hm j; destruct (decide (i = j)) as [->|]; by intros f1 f2 Hf i ? <- m1 m2 Hm j; destruct (decide (i = j)) as [->|];
rewrite ?lookup_partial_alter, ?lookup_partial_alter_ne by done; rewrite ?lookup_partial_alter, ?lookup_partial_alter_ne by done;
try apply Hf; apply lookup_proper. try apply Hf; apply lookup_proper.
Qed. Qed.
Global Instance insert_proper (i : K) : Global Instance insert_proper (i : K) :
Proper (() ==> () ==> ()) (insert (M:=M A) i). Proper (() ==> () ==> (@{M A})) (insert i).
Proof. by intros ???; apply partial_alter_proper; [constructor|]. Qed. Proof. by intros ???; apply partial_alter_proper; [constructor|]. Qed.
Global Instance singleton_proper k : Global Instance singleton_proper k : Proper (() ==> (@{M A})) (singletonM k).
Proper (() ==> ()) (singletonM k : A M A).
Proof. Proof.
intros ???; apply insert_proper; [done|]. intros ???; apply insert_proper; [done|].
intros ?. rewrite lookup_empty; constructor. intros ?. rewrite lookup_empty; constructor.
Qed. Qed.
Global Instance delete_proper (i : K) : Global Instance delete_proper (i : K) : Proper (() ==> (@{M A})) (delete i).
Proper (() ==> ()) (delete (M:=M A) i).
Proof. by apply partial_alter_proper; [constructor|]. Qed. Proof. by apply partial_alter_proper; [constructor|]. Qed.
Global Instance alter_proper : Global Instance alter_proper :
Proper ((() ==> ()) ==> (=) ==> () ==> ()) (alter (A:=A) (M:=M A)). Proper ((() ==> ()) ==> (=) ==> () ==> (@{M A})) alter.
Proof. Proof.
intros ?? Hf; apply partial_alter_proper. intros ?? Hf; apply partial_alter_proper.
by destruct 1; constructor; apply Hf. by destruct 1; constructor; apply Hf.
...@@ -186,12 +182,12 @@ Section setoid. ...@@ -186,12 +182,12 @@ Section setoid.
Lemma merge_ext `{Equiv B, Equiv C} (f g : option A option B option C) Lemma merge_ext `{Equiv B, Equiv C} (f g : option A option B option C)
`{!DiagNone f, !DiagNone g} : `{!DiagNone f, !DiagNone g} :
(() ==> () ==> ())%signature f g (() ==> () ==> ())%signature f g
(() ==> () ==> ())%signature (merge (M:=M) f) (merge g). (() ==> () ==> (@{M _}))%signature (merge f) (merge g).
Proof. Proof.
by intros Hf ?? Hm1 ?? Hm2 i; rewrite !lookup_merge by done; apply Hf. by intros Hf ?? Hm1 ?? Hm2 i; rewrite !lookup_merge by done; apply Hf.
Qed. Qed.
Global Instance union_with_proper : Global Instance union_with_proper :
Proper ((() ==> () ==> ()) ==> () ==> () ==>()) (union_with (M:=M A)). Proper ((() ==> () ==> ()) ==> () ==> () ==>(@{M A})) union_with.
Proof. Proof.
intros ?? Hf ?? Hm1 ?? Hm2 i; apply (merge_ext _ _); auto. intros ?? Hf ?? Hm1 ?? Hm2 i; apply (merge_ext _ _); auto.
by do 2 destruct 1; first [apply Hf | constructor]. by do 2 destruct 1; first [apply Hf | constructor].
...@@ -205,7 +201,7 @@ Section setoid. ...@@ -205,7 +201,7 @@ Section setoid.
- intros ?. rewrite lookup_empty; constructor. - intros ?. rewrite lookup_empty; constructor.
Qed. Qed.
Global Instance map_fmap_proper `{Equiv B} (f : A B) : Global Instance map_fmap_proper `{Equiv B} (f : A B) :