Commit a8477867 authored by Robbert's avatar Robbert

Merge branch 'robbert/rel_disambig' into 'master'

Notations for relations with explicit type arguments

See merge request robbertkrebbers/coq-stdpp!30
parents 3bcaaf7e ba69172b
......@@ -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, 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 100 (_ _) => discriminate.
Instance: @PreOrder A (=).
Instance: A, PreOrder (=@{A}).
Proof. split; repeat intro; congruence. Qed.
(** ** Setoid equality *)
......@@ -174,6 +180,9 @@ Class Equiv A := equiv: relation A.
Hint Mode Equiv ! : typeclass_instances. *)
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 "( X ≡)" := (equiv 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.
Notation "( X ≢)" := (λ Y, X Y) (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
with Leibniz equality. We provide the tactic [fold_leibniz] to transform such
setoid equalities into Leibniz equalities, and [unfold_leibniz] for the
......@@ -189,22 +202,22 @@ reverse. *)
Class LeibnizEquiv A `{Equiv A} := leibniz_equiv x y : x y x = y.
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.
Proof. split. apply leibniz_equiv. intros ->; reflexivity. Qed.
Ltac fold_leibniz := repeat
match goal with
| H : context [ @equiv ?A _ _ _ ] |- _ =>
| H : context [ _ @{?A} _ ] |- _ =>
setoid_rewrite (leibniz_equiv_iff (A:=A)) in H
| |- context [ @equiv ?A _ _ _ ] =>
| |- context [ _ @{?A} _ ] =>
setoid_rewrite (leibniz_equiv_iff (A:=A))
end.
Ltac unfold_leibniz := repeat
match goal with
| H : context [ @eq ?A _ _ ] |- _ =>
| H : context [ _ =@{?A} _ ] |- _ =>
setoid_rewrite <-(leibniz_equiv_iff (A:=A)) in H
| |- context [ @eq ?A _ _ ] =>
| |- context [ _ =@{?A} _ ] =>
setoid_rewrite <-(leibniz_equiv_iff (A:=A))
end.
......@@ -249,7 +262,7 @@ Class RelDecision {A B} (R : A → B → Prop) :=
decide_rel x y :> Decision (R x y).
Hint Mode RelDecision ! ! ! : typeclass_instances.
Arguments decide_rel {_ _} _ {_} _ _ : simpl never, assert.
Notation EqDecision A := (RelDecision (@eq A)).
Notation EqDecision A := (RelDecision (=@{A})).
(** ** Inhabited types *)
(** This type class collects types that are inhabited. *)
......@@ -411,9 +424,9 @@ Lemma exist_proper {A} (P Q : A → Prop) :
( x, P x Q x) ( x, P x) ( x, Q x).
Proof. firstorder. Qed.
Instance: Comm () (@eq A).
Instance: Comm () (=@{A}).
Proof. red; intuition. Qed.
Instance: Comm () (λ x y, @eq A y x).
Instance: Comm () (λ x y, y =@{A} x).
Proof. red; intuition. Qed.
Instance: Comm () ().
Proof. red; intuition. Qed.
......@@ -551,7 +564,7 @@ Proof. now intros -> ?. Qed.
(** ** Unit *)
Instance unit_equiv : Equiv unit := λ _ _, True.
Instance unit_equivalence : Equivalence (@equiv unit _).
Instance unit_equivalence : Equivalence (@{unit}).
Proof. repeat split. Qed.
Instance unit_leibniz : LeibnizEquiv unit.
Proof. intros [] []; reflexivity. Qed.
......@@ -799,6 +812,10 @@ Notation "X ⊈ Y" := (¬X ⊆ Y) (at level 70) : 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.
Infix "⊆@{ A }" := (@subseteq A _) (at level 70, only parsing) : stdpp_scope.
Notation "(⊆@{ A } )" := (@subseteq A _) (only parsing) : stdpp_scope.
Infix "⊆*" := (Forall2 ()) (at level 70) : stdpp_scope.
Notation "(⊆*)" := (Forall2 ()) (only parsing) : stdpp_scope.
Infix "⊆**" := (Forall2 (*)) (at level 70) : stdpp_scope.
......@@ -820,6 +837,9 @@ 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.
Infix "⊂@{ A }" := (strict (@{A})) (at level 70, only parsing) : stdpp_scope.
Notation "(⊂@{ A } )" := (strict (@{A})) (only parsing) : stdpp_scope.
Notation "X ⊆ Y ⊆ Z" := (X Y Y Z) (at level 70, Y at next level) : stdpp_scope.
Notation "X ⊆ Y ⊂ Z" := (X Y Y Z) (at level 70, Y at next level) : stdpp_scope.
Notation "X ⊂ Y ⊆ Z" := (X Y Y Z) (at level 70, Y at next level) : stdpp_scope.
......@@ -843,6 +863,9 @@ Notation "(∉)" := (λ x X, x ∉ X) (only parsing) : stdpp_scope.
Notation "( x ∉)" := (λ X, x X) (only parsing) : stdpp_scope.
Notation "(∉ X )" := (λ x, x X) (only parsing) : stdpp_scope.
Infix "∈@{ B }" := (@elem_of _ B _) (at level 70, only parsing) : stdpp_scope.
Notation "(∈@{ B } )" := (@elem_of _ B _) (only parsing) : stdpp_scope.
Class Disjoint A := disjoint : A A Prop.
Hint Mode Disjoint ! : typeclass_instances.
Instance: Params (@disjoint) 2.
......@@ -850,6 +873,10 @@ Infix "##" := disjoint (at level 70) : stdpp_scope.
Notation "(##)" := disjoint (only parsing) : stdpp_scope.
Notation "( X ##.)" := (disjoint X) (only parsing) : stdpp_scope.
Notation "(.## X )" := (λ Y, Y ## X) (only parsing) : stdpp_scope.
Infix "##@{ A }" := (@disjoint A _) (at level 70, only parsing) : stdpp_scope.
Notation "(##@{ A } )" := (@disjoint A _) (only parsing) : stdpp_scope.
Infix "##*" := (Forall2 (##)) (at level 70) : stdpp_scope.
Notation "(##*)" := (Forall2 (##)) (only parsing) : stdpp_scope.
Infix "##**" := (Forall2 (##*)) (at level 70) : stdpp_scope.
......@@ -881,17 +908,19 @@ Class DisjointList A := disjoint_list : list A → Prop.
Hint Mode DisjointList ! : typeclass_instances.
Instance: Params (@disjoint_list) 2.
Notation "## Xs" := (disjoint_list Xs) (at level 20, format "## Xs") : stdpp_scope.
Notation "##@{ A } Xs" :=
(@disjoint_list A _ Xs) (at level 20, only parsing) : stdpp_scope.
Section disjoint_list.
Context `{Disjoint A, Union A, Empty A}.
Implicit Types X : A.
Inductive disjoint_list_default : DisjointList A :=
| disjoint_nil_2 : ## (@nil A)
| disjoint_nil_2 : ##@{A} []
| disjoint_cons_2 (X : A) (Xs : list A) : X ## Xs ## Xs ## (X :: Xs).
Global Existing Instance disjoint_list_default.
Lemma disjoint_list_nil : ## @nil A True.
Lemma disjoint_list_nil : ##@{A} [] True.
Proof. split; constructor. Qed.
Lemma disjoint_list_cons X Xs : ## (X :: Xs) X ## Xs ## Xs.
Proof. split. inversion_clear 1; auto. intros [??]. constructor; auto. Qed.
......@@ -1175,6 +1204,10 @@ Infix "⊑" := sqsubseteq (at level 70) : stdpp_scope.
Notation "(⊑)" := sqsubseteq (only parsing) : stdpp_scope.
Notation "( x ⊑)" := (sqsubseteq x) (only parsing) : stdpp_scope.
Notation "(⊑ y )" := (λ x, sqsubseteq x y) (only parsing) : stdpp_scope.
Infix "⊑@{ A }" := (@sqsubseteq A _) (at level 70, only parsing) : stdpp_scope.
Notation "(⊑@{ A } )" := (@sqsubseteq A _) (only parsing) : stdpp_scope.
Instance sqsubseteq_rewrite `{SqSubsetEq A} : RewriteRelation ().
Hint Extern 0 (_ _) => reflexivity.
......
......@@ -29,7 +29,7 @@ Proof.
- intros X Y x; unfold elem_of, bset_elem_of; simpl.
destruct (bset_car X x), (bset_car Y x); simpl; tauto.
Qed.
Instance bset_elem_of_dec {A} : RelDecision (@elem_of _ (bset A) _).
Instance bset_elem_of_dec {A} : RelDecision (@{bset A}).
Proof. refine (λ x X, cast_if (decide (bset_car X x))); done. Defined.
Typeclasses Opaque bset_elem_of.
......
......@@ -190,16 +190,16 @@ Proof.
intros p; apply eq_bool_prop_intro, (HXY p).
Qed.
Instance coPset_elem_of_dec : RelDecision (@elem_of _ coPset _).
Instance coPset_elem_of_dec : RelDecision (@{coPset}).
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.
Instance mapset_disjoint_dec : RelDecision (@disjoint coPset _).
Instance mapset_disjoint_dec : RelDecision (##@{coPset}).
Proof.
refine (λ X Y, cast_if (decide (X Y = )));
abstract (by rewrite disjoint_intersection_L).
Defined.
Instance mapset_subseteq_dec : RelDecision (@subseteq coPset _).
Instance mapset_subseteq_dec : RelDecision (@{coPset}).
Proof.
refine (λ X Y, cast_if (decide (X Y = Y))); abstract (by rewrite subseteq_union_L).
Defined.
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ Implicit Types X Y : C.
Lemma fin_collection_finite X : set_finite X.
Proof. by exists (elements X); intros; rewrite elem_of_elements. Qed.
Instance elem_of_dec_slow : RelDecision (@elem_of A C _) | 100.
Instance elem_of_dec_slow : RelDecision (@{C}) | 100.
Proof.
refine (λ x X, cast_if (decide_rel () x (elements X)));
by rewrite <-(elem_of_elements _).
......@@ -149,7 +149,7 @@ Proof.
Qed.
(** * Induction principles *)
Lemma collection_wf : wf (strict (@subseteq C _)).
Lemma collection_wf : wf (@{C}).
Proof. apply (wf_projected (<) size); auto using subset_size, lt_wf. Qed.
Lemma collection_ind (P : C Prop) :
Proper (() ==> iff) P
......
This diff is collapsed.
......@@ -98,24 +98,24 @@ Proof.
by split; auto with lia.
- intros X Y x. rewrite !elem_of_multiplicity, multiplicity_union. omega.
Qed.
Global Instance gmultiset_elem_of_dec : RelDecision (@elem_of _ (gmultiset A) _).
Global Instance gmultiset_elem_of_dec : RelDecision (@{gmultiset A}).
Proof. refine (λ x X, cast_if (decide (0 < multiplicity x X))); done. Defined.
(* Algebraic laws *)
Global Instance gmultiset_comm : Comm (@eq (gmultiset A)) ().
Global Instance gmultiset_comm : Comm (=@{gmultiset A}) ().
Proof.
intros X Y. apply gmultiset_eq; intros x. rewrite !multiplicity_union; omega.
Qed.
Global Instance gmultiset_assoc : Assoc (@eq (gmultiset A)) ().
Global Instance gmultiset_assoc : Assoc (=@{gmultiset A}) ().
Proof.
intros X Y Z. apply gmultiset_eq; intros x. rewrite !multiplicity_union; omega.
Qed.
Global Instance gmultiset_left_id : LeftId (@eq (gmultiset A)) ().
Global Instance gmultiset_left_id : LeftId (=@{gmultiset A}) ().
Proof.
intros X. apply gmultiset_eq; intros x.
by rewrite multiplicity_union, multiplicity_empty.
Qed.
Global Instance gmultiset_right_id : RightId (@eq (gmultiset A)) ().
Global Instance gmultiset_right_id : RightId (=@{gmultiset A}) ().
Proof. intros X. by rewrite (comm_L ()), (left_id_L _ _). Qed.
Global Instance gmultiset_union_inj_1 X : Inj (=) (=) (X ).
......@@ -126,7 +126,7 @@ Qed.
Global Instance gmultiset_union_inj_2 X : Inj (=) (=) ( X).
Proof. intros Y1 Y2. rewrite <-!(comm_L _ X). apply (inj _). Qed.
Lemma gmultiset_non_empty_singleton x : {[ x ]} ( : gmultiset A).
Lemma gmultiset_non_empty_singleton x : {[ x ]} @{gmultiset A} .
Proof.
rewrite gmultiset_eq. intros Hx; generalize (Hx x).
by rewrite multiplicity_singleton, multiplicity_empty.
......@@ -231,7 +231,7 @@ Proof.
Qed.
(* Order stuff *)
Global Instance gmultiset_po : PartialOrder (@subseteq (gmultiset A) _).
Global Instance gmultiset_po : PartialOrder (@{gmultiset A}).
Proof.
split; [split|].
- by intros X x.
......@@ -246,7 +246,7 @@ Proof.
apply forall_proper; intros x. unfold multiplicity.
destruct (gmultiset_car X !! x), (gmultiset_car Y !! x); naive_solver omega.
Qed.
Global Instance gmultiset_subseteq_dec : RelDecision (@subseteq (gmultiset A) _).
Global Instance gmultiset_subseteq_dec : RelDecision (@{gmultiset A}).
Proof.
refine (λ X Y, cast_if (decide (map_relation ()
(λ _, False) (λ _, True) (gmultiset_car X) (gmultiset_car Y))));
......@@ -342,7 +342,7 @@ Proof.
Qed.
(* Well-foundedness *)
Lemma gmultiset_wf : wf (strict (@subseteq (gmultiset A) _)).
Lemma gmultiset_wf : wf (@{gmultiset A}).
Proof.
apply (wf_projected (<) size); auto using gmultiset_subset_size, lt_wf.
Qed.
......
......@@ -26,7 +26,7 @@ Qed.
(** * Fresh elements *)
Section Fresh.
Context `{FinCollection A C, Infinite A, !RelDecision (@elem_of A C _)}.
Context `{FinCollection A C, Infinite A, !RelDecision (@{C})}.
Definition fresh_generic_body (s : C) (rec : s', s' s nat A) (n : nat) : A :=
let cand := inject n in
......
......@@ -46,6 +46,10 @@ Notation "x ≢ₚ y":= (¬x ≡ₚ y) (at level 70, no associativity) : stdpp_s
Notation "( x ≢ₚ)" := (λ y, x ≢ₚ y) (only parsing) : stdpp_scope.
Notation "(≢ₚ x )" := (λ y, y ≢ₚ x) (only parsing) : stdpp_scope.
Infix "≡ₚ@{ A }" :=
(@Permutation A) (at level 70, no associativity, only parsing) : stdpp_scope.
Notation "(≡ₚ@{ A } )" := (@Permutation A) (only parsing) : stdpp_scope.
Instance maybe_cons {A} : Maybe2 (@cons A) := λ l,
match l with x :: l => Some (x,l) | _ => None end.
......@@ -311,7 +315,7 @@ Instance list_subseteq {A} : SubsetEq (list A) := λ l1 l2, ∀ x, x ∈ l1 →
Section list_set.
Context `{dec : EqDecision A}.
Global Instance elem_of_list_dec : RelDecision (@elem_of A (list A) _).
Global Instance elem_of_list_dec : RelDecision (@{list A}).
Proof.
refine (
fix go x l :=
......@@ -358,7 +362,7 @@ Tactic Notation "discriminate_list" hyp(H) :=
apply (f_equal length) in H;
repeat (csimpl in H || rewrite app_length in H); exfalso; lia.
Tactic Notation "discriminate_list" :=
match goal with H : @eq (list _) _ _ |- _ => discriminate_list H end.
match goal with H : _ =@{list _} _ |- _ => discriminate_list H end.
(** The tactic [simplify_list_eq] simplifies hypotheses involving
equalities on lists using injectivity of [(::)] and [(++)]. Also, it simplifies
......@@ -830,7 +834,7 @@ Section find.
End find.
(** ** Properties of the [reverse] function *)
Lemma reverse_nil : reverse [] = @nil A.
Lemma reverse_nil : reverse [] =@{list A} [].
Proof. done. Qed.
Lemma reverse_singleton x : reverse [x] = [x].
Proof. done. Qed.
......@@ -883,7 +887,7 @@ Lemma take_drop_middle l i x :
Proof.
revert i x. induction l; intros [|?] ??; simplify_eq/=; f_equal; auto.
Qed.
Lemma take_nil n : take n (@nil A) = [].
Lemma take_nil n : take n [] =@{list A} [].
Proof. by destruct n. Qed.
Lemma take_app l k : take (length l) (l ++ k) = l.
Proof. induction l; f_equal/=; auto. Qed.
......@@ -935,7 +939,7 @@ Qed.
(** ** Properties of the [drop] function *)
Lemma drop_0 l : drop 0 l = l.
Proof. done. Qed.
Lemma drop_nil n : drop n (@nil A) = [].
Lemma drop_nil n : drop n [] =@{list A} [].
Proof. by destruct n. Qed.
Lemma drop_length l n : length (drop n l) = length l - n.
Proof. revert n. by induction l; intros [|i]; f_equal/=. Qed.
......@@ -1323,7 +1327,7 @@ Proof.
Qed.
(** ** Properties of the [mask] function *)
Lemma mask_nil f βs : mask f βs (@nil A) = [].
Lemma mask_nil f βs : mask f βs [] =@{list A} [].
Proof. by destruct βs. Qed.
Lemma mask_length f βs l : length (mask f βs l) = length l.
Proof. revert βs. induction l; intros [|??]; f_equal/=; auto. Qed.
......@@ -2115,7 +2119,7 @@ Section submseteq_dec.
refine (λ l1 l2, cast_if (decide (is_Some (list_remove_list l1 l2))));
abstract (rewrite list_remove_list_submseteq; tauto).
Defined.
Global Instance Permutation_dec : RelDecision (Permutation : relation (list A)).
Global Instance Permutation_dec : RelDecision (≡ₚ@{A}).
Proof.
refine (λ l1 l2, cast_if_and
(decide (length l1 = length l2)) (decide (l1 + l2)));
......@@ -2124,7 +2128,7 @@ Section submseteq_dec.
End submseteq_dec.
(** ** Properties of [included] *)
Global Instance list_subseteq_po : PreOrder (@subseteq (list A) _).
Global Instance list_subseteq_po : PreOrder (@{list A}).
Proof. split; firstorder. Qed.
Lemma list_subseteq_nil l : [] l.
Proof. intros x. by rewrite elem_of_nil. Qed.
......@@ -2826,7 +2830,7 @@ Section setoid.
Qed.
Global Instance list_equivalence :
Equivalence (() : relation A) Equivalence (() : relation (list A)).
Equivalence (@{A}) Equivalence (@{list A}).
Proof.
split.
- intros l. by apply equiv_Forall2.
......@@ -2836,51 +2840,50 @@ Section setoid.
Global Instance list_leibniz `{!LeibnizEquiv A} : LeibnizEquiv (list A).
Proof. induction 1; f_equal; fold_leibniz; auto. Qed.
Global Instance cons_proper : Proper (() ==> () ==> ()) (@cons A).
Global Instance cons_proper : Proper (() ==> () ==> (@{list A})) cons.
Proof. by constructor. Qed.
Global Instance app_proper : Proper (() ==> () ==> ()) (@app A).
Global Instance app_proper : Proper (() ==> () ==> (@{list A})) app.
Proof. induction 1; intros ???; simpl; try constructor; auto. Qed.
Global Instance length_proper : Proper (() ==> (=)) (@length A).
Global Instance length_proper : Proper ((@{list A}) ==> (=)) length.
Proof. induction 1; f_equal/=; auto. Qed.
Global Instance tail_proper : Proper (() ==> ()) (@tail A).
Global Instance tail_proper : Proper ((@{list A}) ==> ()) tail.
Proof. destruct 1; try constructor; auto. Qed.
Global Instance take_proper n : Proper (() ==> ()) (@take A n).
Global Instance take_proper n : Proper ((@{list A}) ==> ()) (take n).
Proof. induction n; destruct 1; constructor; auto. Qed.
Global Instance drop_proper n : Proper (() ==> ()) (@drop A n).
Global Instance drop_proper n : Proper ((@{list A}) ==> ()) (drop n).
Proof. induction n; destruct 1; simpl; try constructor; auto. Qed.
Global Instance list_lookup_proper i :
Proper (() ==> ()) (lookup (M:=list A) i).
Global Instance list_lookup_proper i : Proper ((@{list A}) ==> ()) (lookup i).
Proof. induction i; destruct 1; simpl; try constructor; auto. Qed.
Global Instance list_alter_proper f i :
Proper (() ==> ()) f Proper (() ==> ()) (alter (M:=list A) f i).
Proper (() ==> ()) f Proper (() ==> (@{list A})) (alter f i).
Proof. intros. induction i; destruct 1; constructor; eauto. Qed.
Global Instance list_insert_proper i :
Proper (() ==> () ==> ()) (insert (M:=list A) i).
Proper (() ==> () ==> (@{list A})) (insert i).
Proof. intros ???; induction i; destruct 1; constructor; eauto. Qed.
Global Instance list_inserts_proper i :
Proper (() ==> () ==> ()) (@list_inserts A i).
Proper (() ==> () ==> (@{list A})) (list_inserts i).
Proof.
intros k1 k2 Hk; revert i.
induction Hk; intros ????; simpl; try f_equiv; naive_solver.
Qed.
Global Instance list_delete_proper i :
Proper (() ==> ()) (delete (M:=list A) i).
Proper (() ==> (@{list A})) (delete i).
Proof. induction i; destruct 1; try constructor; eauto. Qed.
Global Instance option_list_proper : Proper (() ==> ()) (@option_list A).
Global Instance option_list_proper : Proper (() ==> (@{list A})) option_list.
Proof. destruct 1; repeat constructor; auto. Qed.
Global Instance list_filter_proper P `{ x, Decision (P x)} :
Proper (() ==> iff) P Proper (() ==> ()) (filter (B:=list A) P).
Proper (() ==> iff) P Proper (() ==> (@{list A})) (filter P).
Proof. intros ???. rewrite !equiv_Forall2. by apply Forall2_filter. Qed.
Global Instance replicate_proper n : Proper (() ==> ()) (@replicate A n).
Global Instance replicate_proper n : Proper ((@{A}) ==> ()) (replicate n).
Proof. induction n; constructor; auto. Qed.
Global Instance reverse_proper : Proper (() ==> ()) (@reverse A).
Global Instance reverse_proper : Proper (() ==> (@{list A})) reverse.
Proof.
induction 1; rewrite ?reverse_cons; simpl; [constructor|].
apply app_proper; repeat constructor; auto.
Qed.
Global Instance last_proper : Proper (() ==> ()) (@last A).
Proof. induction 1 as [|????? []]; simpl; repeat constructor; auto. Qed.
Global Instance resize_proper n : Proper (() ==> () ==> ()) (@resize A n).
Global Instance resize_proper n : Proper (() ==> () ==> (@{list A})) (resize n).
Proof.
induction n; destruct 2; simpl; repeat (constructor || f_equiv); auto.
Qed.
......@@ -3111,8 +3114,7 @@ Section ret_join.
Lemma list_join_bind (ls : list (list A)) : mjoin ls = ls = id.
Proof. by induction ls; f_equal/=. Qed.
Global Instance mjoin_Permutation:
Proper (@Permutation (list A) ==> (≡ₚ)) mjoin.
Global Instance mjoin_Permutation : Proper ((≡ₚ@{list A}) ==> (≡ₚ)) mjoin.
Proof. intros ?? E. by rewrite !list_join_bind, E. Qed.
Lemma elem_of_list_ret (x y : A) : x @mret list _ A y x = y.
Proof. apply elem_of_list_singleton. Qed.
......@@ -3646,7 +3648,7 @@ Ltac solve_length :=
simplify_eq/=;
repeat (rewrite fmap_length || rewrite app_length);
repeat match goal with
| H : @eq (list _) _ _ |- _ => apply (f_equal length) in H
| H : _ =@{list _} _ |- _ => apply (f_equal length) in H
| H : Forall2 _ _ _ |- _ => apply Forall2_length in H
| H : context[length (_ <$> _)] |- _ => rewrite fmap_length in H
end; done || congruence.
......
......@@ -76,16 +76,16 @@ Section deciders.
match X1, X2 with Mapset m1, Mapset m2 => cast_if (decide (m1 = m2)) end);
abstract congruence.
Defined.
Global Instance mapset_equiv_dec : RelDecision (@equiv (mapset M)_) | 1.
Global Instance mapset_equiv_dec : RelDecision (@{mapset M}) | 1.
Proof. refine (λ X1 X2, cast_if (decide (X1 = X2))); abstract (by fold_leibniz). Defined.
Global Instance mapset_elem_of_dec : RelDecision (@elem_of _ (mapset M) _) | 1.
Global Instance mapset_elem_of_dec : RelDecision (@{mapset M}) | 1.
Proof. refine (λ x X, cast_if (decide (mapset_car X !! x = Some ()))); done. Defined.
Global Instance mapset_disjoint_dec : RelDecision (@disjoint (mapset M) _).
Global Instance mapset_disjoint_dec : RelDecision (##@{mapset M}).
Proof.
refine (λ X1 X2, cast_if (decide (X1 X2 = )));
abstract (by rewrite disjoint_intersection_L).
Defined.
Global Instance mapset_subseteq_dec : RelDecision (@subseteq (mapset M) _).
Global Instance mapset_subseteq_dec : RelDecision (@{mapset M}).
Proof.
refine (λ X1 X2, cast_if (decide (X1 X2 = X2)));
abstract (by rewrite subseteq_union_L).
......
......@@ -122,11 +122,11 @@ Section setoids.
Proof. done. Qed.
Global Instance option_equivalence :
Equivalence (() : relation A) Equivalence (() : relation (option A)).
Equivalence (@{A}) Equivalence (@{option A}).
Proof. apply _. Qed.
Global Instance Some_proper : Proper (() ==> ()) (@Some A).
Global Instance Some_proper : Proper (() ==> (@{option A})) Some.
Proof. by constructor. Qed.
Global Instance Some_equiv_inj : Inj () () (@Some A).
Global Instance Some_equiv_inj : Inj () (@{option A}) Some.
Proof. by inversion_clear 1. Qed.
Global Instance option_leibniz `{!LeibnizEquiv A} : LeibnizEquiv (option A).
Proof. intros x y; destruct 1; f_equal; by apply leibniz_equiv. Qed.
......@@ -141,11 +141,11 @@ Section setoids.
Proof. destruct 1; naive_solver. Qed.
Lemma equiv_Some_inv_l' my x : Some x my x', Some x' = my x x'.
Proof. intros ?%(equiv_Some_inv_l _ _ x); naive_solver. Qed.
Lemma equiv_Some_inv_r' `{!Equivalence (() : relation A)} mx y :
Lemma equiv_Some_inv_r' `{!Equivalence (@{A})} mx y :
mx Some y y', mx = Some y' y y'.
Proof. intros ?%(equiv_Some_inv_r _ _ y); naive_solver. Qed.
Global Instance is_Some_proper : Proper (() ==> iff) (@is_Some A).
Global Instance is_Some_proper : Proper ((@{option A}) ==> iff) is_Some.
Proof. inversion_clear 1; split; eauto. Qed.
Global Instance from_option_proper {B} (R : relation B) (f : A B) :
Proper (() ==> R) f Proper (R ==> () ==> R) (from_option f).
......@@ -188,8 +188,7 @@ Lemma fmap_Some_1 {A B} (f : A → B) mx y :
Proof. apply fmap_Some. Qed.
Lemma fmap_Some_2 {A B} (f : A B) mx x : mx = Some x f <$> mx = Some (f x).
Proof. intros. apply fmap_Some; eauto. Qed.
Lemma fmap_Some_equiv {A B} `{Equiv B} `{!Equivalence (() : relation B)}
(f : A B) mx y :
Lemma fmap_Some_equiv {A B} `{Equiv B} `{!Equivalence (@{B})} (f : A B) mx y :
f <$> mx Some y x, mx = Some x y f x.
Proof.
destruct mx; simpl; split.
......@@ -198,8 +197,7 @@ Proof.
- intros ?%symmetry%equiv_None. done.
- intros (? & ? & ?). done.
Qed.
Lemma fmap_Some_equiv_1 {A B} `{Equiv B} `{!Equivalence (() : relation B)}
(f : A B) mx y :
Lemma fmap_Some_equiv_1 {A B} `{Equiv B} `{!Equivalence (@{B})} (f : A B) mx y :
f <$> mx Some y x, mx = Some x y f x.
Proof. by rewrite fmap_Some_equiv. Qed.
Lemma fmap_None {A B} (f : A B) mx : f <$> mx = None mx = None.
......@@ -237,13 +235,13 @@ Lemma bind_with_Some {A} (mx : option A) : mx ≫= Some = mx.
Proof. by destruct mx. Qed.
Instance option_fmap_proper `{Equiv A, Equiv B} :
Proper ((() ==> ()) ==> () ==> ()) (fmap (M:=option) (A:=A) (B:=B)).
Proper ((() ==> ()) ==> (@{option A}) ==> (@{option B})) fmap.
Proof. destruct 2; constructor; auto. Qed.
Instance option_mbind_proper `{Equiv A, Equiv B} :
Proper ((() ==> ()) ==> () ==> ()) (mbind (M:=option) (A:=A) (B:=B)).
Proper ((() ==> ()) ==> (@{option A}) ==> (@{option B})) mbind.
Proof. destruct 2; simpl; try constructor; auto. Qed.
Instance option_mjoin_proper `{Equiv A} :
Proper (() ==> ()) (mjoin (M:=option) (A:=A)).
Proper (() ==> (@{option (option A)})) mjoin.
Proof. destruct 1 as [?? []|]; simpl; by constructor. Qed.
(** ** Inverses of constructors *)
......@@ -312,14 +310,14 @@ Section union_intersection_difference.
Global Instance union_with_right_id : RightId (=) None (union_with f).
Proof. by intros [?|]. Qed.
Global Instance union_with_comm :
Comm (=) f Comm (=) (union_with (M:=option A) f).
Comm (=) f Comm (=@{option A}) (union_with f).
Proof. by intros ? [?|] [?|]; compute; rewrite 1?(comm f). Qed.
Global Instance intersection_with_left_ab : LeftAbsorb (=) None (intersection_with f).
Proof. by intros [?|]. Qed.
Global Instance intersection_with_right_ab : RightAbsorb (=) None (intersection_with f).
Proof. by intros [?|]. Qed.
Global Instance difference_with_comm :
Comm (=) f Comm (=) (intersection_with (M:=option A) f).
Comm (=) f Comm (=@{option A}) (intersection_with f).
Proof. by intros ? [?|] [?|]; compute; rewrite 1?(comm f). Qed.
Global Instance difference_with_right_id : RightId (=) None (difference_with f).
Proof. by intros [?|]. Qed.
......
......@@ -13,8 +13,8 @@ From stdpp Require Export fin_maps.
Set Default Proof Using "Type".
Local Open Scope positive_scope.
Local Hint Extern 0 (@eq positive _ _) => congruence.
Local Hint Extern 0 (¬@eq positive _ _) => congruence.
Local Hint Extern 0 (_ =@{positive} _) => congruence.
Local Hint Extern 0 (_ @{positive} _) => congruence.
(** * The tree data structure *)
(** The data type [Pmap_raw] specifies radix-2 search trees. These trees do
......
......@@ -40,7 +40,7 @@ Qed.
Instance pretty_N : Pretty N := λ x, pretty_N_go x ""%string.
Lemma pretty_N_unfold x : pretty x = pretty_N_go x "".
Proof. done. Qed.
Instance pretty_N_inj : Inj (@eq N) (=) pretty.
Instance pretty_N_inj : Inj (=@{N}) (=) pretty.
Proof.
assert ( x y, x < 10 y < 10
pretty_N_char x = pretty_N_char y x = y)%N.
......@@ -71,6 +71,6 @@ Instance pretty_Z : Pretty Z := λ x,
| Z0 => "" | Zpos x => pretty (Npos x) | Zneg x => "-" +:+ pretty (Npos x)
end%string.
Instance pretty_nat : Pretty nat := λ x, pretty (N.of_nat x).
Instance pretty_nat_inj : Inj (@eq nat) (=) pretty.
Instance pretty_nat_inj : Inj (=@{nat}) (=) pretty.
Proof. apply _. Qed.