Skip to content
Snippets Groups Projects
Commit 2e5cc41f authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan
Browse files

Merge branch 'jh/bottom_notation' into 'master'

Notation for disjointness: replace ⊥ with ##, so that ⊥ can be used for bottom.

See merge request robbertkrebbers/coq-stdpp!12
parents b99b916f 4b5d254e
No related branches found
No related tags found
No related merge requests found
...@@ -681,7 +681,7 @@ Arguments sig_map _ _ _ _ _ _ !_ / : assert. ...@@ -681,7 +681,7 @@ Arguments sig_map _ _ _ _ _ _ !_ / : assert.
(** We define operational type classes for the traditional operations and (** We define operational type classes for the traditional operations and
relations on collections: the empty collection [∅], the union [(∪)], relations on collections: the empty collection [∅], the union [(∪)],
intersection [(∩)], and difference [(∖)], the singleton [{[_]}], the subset intersection [(∩)], and difference [(∖)], the singleton [{[_]}], the subset
[(⊆)] and element of [(∈)] relation, and disjointess [()]. *) [(⊆)] and element of [(∈)] relation, and disjointess [(##)]. *)
Class Empty A := empty: A. Class Empty A := empty: A.
Hint Mode Empty ! : typeclass_instances. Hint Mode Empty ! : typeclass_instances.
Notation "∅" := empty : C_scope. Notation "∅" := empty : C_scope.
...@@ -800,56 +800,56 @@ Notation "( x ∉)" := (λ X, x ∉ X) (only parsing) : C_scope. ...@@ -800,56 +800,56 @@ Notation "( x ∉)" := (λ X, x ∉ X) (only parsing) : C_scope.
Notation "(∉ X )" := (λ x, x X) (only parsing) : C_scope. Notation "(∉ X )" := (λ x, x X) (only parsing) : C_scope.
Class Disjoint A := disjoint : A A Prop. Class Disjoint A := disjoint : A A Prop.
Hint Mode Disjoint ! : typeclass_instances. Hint Mode Disjoint ! : typeclass_instances.
Instance: Params (@disjoint) 2. Instance: Params (@disjoint) 2.
Infix "" := disjoint (at level 70) : C_scope. Infix "##" := disjoint (at level 70) : C_scope.
Notation "()" := disjoint (only parsing) : C_scope. Notation "(##)" := disjoint (only parsing) : C_scope.
Notation "( X .)" := (disjoint X) (only parsing) : C_scope. Notation "( X ##.)" := (disjoint X) (only parsing) : C_scope.
Notation "(. X )" := (λ Y, Y X) (only parsing) : C_scope. Notation "(.## X )" := (λ Y, Y ## X) (only parsing) : C_scope.
Infix "*" := (Forall2 ()) (at level 70) : C_scope. Infix "##*" := (Forall2 (##)) (at level 70) : C_scope.
Notation "(*)" := (Forall2 ()) (only parsing) : C_scope. Notation "(##*)" := (Forall2 (##)) (only parsing) : C_scope.
Infix "**" := (Forall2 (*)) (at level 70) : C_scope. Infix "##**" := (Forall2 (##*)) (at level 70) : C_scope.
Infix "1*" := (Forall2 (λ p q, p.1 q.1)) (at level 70) : C_scope. Infix "##1*" := (Forall2 (λ p q, p.1 ## q.1)) (at level 70) : C_scope.
Infix "2*" := (Forall2 (λ p q, p.2 q.2)) (at level 70) : C_scope. Infix "##2*" := (Forall2 (λ p q, p.2 ## q.2)) (at level 70) : C_scope.
Infix "1**" := (Forall2 (λ p q, p.1 * q.1)) (at level 70) : C_scope. Infix "##1**" := (Forall2 (λ p q, p.1 ##* q.1)) (at level 70) : C_scope.
Infix "2**" := (Forall2 (λ p q, p.2 * q.2)) (at level 70) : C_scope. Infix "##2**" := (Forall2 (λ p q, p.2 ##* q.2)) (at level 70) : C_scope.
Hint Extern 0 (_ _) => symmetry; eassumption. Hint Extern 0 (_ ## _) => symmetry; eassumption.
Hint Extern 0 (_ * _) => symmetry; eassumption. Hint Extern 0 (_ ##* _) => symmetry; eassumption.
Class DisjointE E A := disjointE : E A A Prop. Class DisjointE E A := disjointE : E A A Prop.
Hint Mode DisjointE - ! : typeclass_instances. Hint Mode DisjointE - ! : typeclass_instances.
Instance: Params (@disjointE) 4. Instance: Params (@disjointE) 4.
Notation "X { Γ } Y" := (disjointE Γ X Y) Notation "X ##{ Γ } Y" := (disjointE Γ X Y)
(at level 70, format "X { Γ } Y") : C_scope. (at level 70, format "X ##{ Γ } Y") : C_scope.
Notation "({ Γ } )" := (disjointE Γ) (only parsing, Γ at level 1) : C_scope. Notation "(##{ Γ } )" := (disjointE Γ) (only parsing, Γ at level 1) : C_scope.
Notation "Xs { Γ }* Ys" := (Forall2 ({Γ}) Xs Ys) Notation "Xs ##{ Γ }* Ys" := (Forall2 (##{Γ}) Xs Ys)
(at level 70, format "Xs { Γ }* Ys") : C_scope. (at level 70, format "Xs ##{ Γ }* Ys") : C_scope.
Notation "({ Γ }* )" := (Forall2 ({Γ})) Notation "(##{ Γ }* )" := (Forall2 (##{Γ}))
(only parsing, Γ at level 1) : C_scope. (only parsing, Γ at level 1) : C_scope.
Notation "X { Γ1 , Γ2 , .. , Γ3 } Y" := (disjoint (pair .. (Γ1, Γ2) .. Γ3) X Y) Notation "X ##{ Γ1 , Γ2 , .. , Γ3 } Y" := (disjoint (pair .. (Γ1, Γ2) .. Γ3) X Y)
(at level 70, format "X { Γ1 , Γ2 , .. , Γ3 } Y") : C_scope. (at level 70, format "X ##{ Γ1 , Γ2 , .. , Γ3 } Y") : C_scope.
Notation "Xs { Γ1 , Γ2 , .. , Γ3 }* Ys" := Notation "Xs ##{ Γ1 , Γ2 , .. , Γ3 }* Ys" :=
(Forall2 (disjoint (pair .. (Γ1, Γ2) .. Γ3)) Xs Ys) (Forall2 (disjoint (pair .. (Γ1, Γ2) .. Γ3)) Xs Ys)
(at level 70, format "Xs { Γ1 , Γ2 , .. , Γ3 }* Ys") : C_scope. (at level 70, format "Xs ##{ Γ1 , Γ2 , .. , Γ3 }* Ys") : C_scope.
Hint Extern 0 (_ {_} _) => symmetry; eassumption. Hint Extern 0 (_ ##{_} _) => symmetry; eassumption.
Class DisjointList A := disjoint_list : list A Prop. Class DisjointList A := disjoint_list : list A Prop.
Hint Mode DisjointList ! : typeclass_instances. Hint Mode DisjointList ! : typeclass_instances.
Instance: Params (@disjoint_list) 2. Instance: Params (@disjoint_list) 2.
Notation " Xs" := (disjoint_list Xs) (at level 20, format " Xs") : C_scope. Notation "## Xs" := (disjoint_list Xs) (at level 20, format "## Xs") : C_scope.
Section disjoint_list. Section disjoint_list.
Context `{Disjoint A, Union A, Empty A}. Context `{Disjoint A, Union A, Empty A}.
Implicit Types X : A. Implicit Types X : A.
Inductive disjoint_list_default : DisjointList A := Inductive disjoint_list_default : DisjointList A :=
| disjoint_nil_2 : (@nil A) | disjoint_nil_2 : ## (@nil A)
| disjoint_cons_2 (X : A) (Xs : list A) : X Xs Xs (X :: Xs). | disjoint_cons_2 (X : A) (Xs : list A) : X ## Xs ## Xs ## (X :: Xs).
Global Existing Instance disjoint_list_default. Global Existing Instance disjoint_list_default.
Lemma disjoint_list_nil : @nil A True. Lemma disjoint_list_nil : ## @nil A True.
Proof. split; constructor. Qed. Proof. split; constructor. Qed.
Lemma disjoint_list_cons X Xs : (X :: Xs) X Xs Xs. Lemma disjoint_list_cons X Xs : ## (X :: Xs) X ## Xs ## Xs.
Proof. split. inversion_clear 1; auto. intros [??]. constructor; auto. Qed. Proof. split. inversion_clear 1; auto. intros [??]. constructor; auto. Qed.
End disjoint_list. End disjoint_list.
......
...@@ -186,7 +186,7 @@ Section set_unfold_simple. ...@@ -186,7 +186,7 @@ Section set_unfold_simple.
Qed. Qed.
Global Instance set_unfold_disjoint (P Q : A Prop) X Y : Global Instance set_unfold_disjoint (P Q : A Prop) X Y :
( x, SetUnfold (x X) (P x)) ( x, SetUnfold (x Y) (Q x)) ( x, SetUnfold (x X) (P x)) ( x, SetUnfold (x Y) (Q x))
SetUnfold (X Y) ( x, P x Q x False). SetUnfold (X ## Y) ( x, P x Q x False).
Proof. constructor. unfold disjoint, collection_disjoint. naive_solver. Qed. Proof. constructor. unfold disjoint, collection_disjoint. naive_solver. Qed.
Context `{!LeibnizEquiv C}. Context `{!LeibnizEquiv C}.
...@@ -371,9 +371,9 @@ Section simple_collection. ...@@ -371,9 +371,9 @@ Section simple_collection.
Lemma empty_union X Y : X Y X Y ∅. Lemma empty_union X Y : X Y X Y ∅.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma union_cancel_l X Y Z : Z X Z Y Z X Z Y X Y. Lemma union_cancel_l X Y Z : Z ## X Z ## Y Z X Z Y X Y.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma union_cancel_r X Y Z : X Z Y Z X Z Y Z X Y. Lemma union_cancel_r X Y Z : X ## Z Y ## Z X Z Y Z X Y.
Proof. set_solver. Qed. Proof. set_solver. Qed.
(** Empty *) (** Empty *)
...@@ -405,22 +405,22 @@ Section simple_collection. ...@@ -405,22 +405,22 @@ Section simple_collection.
Proof. by rewrite elem_of_singleton. Qed. Proof. by rewrite elem_of_singleton. Qed.
(** Disjointness *) (** Disjointness *)
Lemma elem_of_disjoint X Y : X Y x, x X x Y False. Lemma elem_of_disjoint X Y : X ## Y x, x X x Y False.
Proof. done. Qed. Proof. done. Qed.
Global Instance disjoint_sym : Symmetric (@disjoint C _). Global Instance disjoint_sym : Symmetric (@disjoint C _).
Proof. intros X Y. set_solver. Qed. Proof. intros X Y. set_solver. Qed.
Lemma disjoint_empty_l Y : Y. Lemma disjoint_empty_l Y : ## Y.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma disjoint_empty_r X : X ∅. Lemma disjoint_empty_r X : X ## ∅.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma disjoint_singleton_l x Y : {[ x ]} Y x Y. Lemma disjoint_singleton_l x Y : {[ x ]} ## Y x Y.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma disjoint_singleton_r y X : X {[ y ]} y X. Lemma disjoint_singleton_r y X : X ## {[ y ]} y X.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma disjoint_union_l X1 X2 Y : X1 X2 Y X1 Y X2 Y. Lemma disjoint_union_l X1 X2 Y : X1 X2 ## Y X1 ## Y X2 ## Y.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma disjoint_union_r X Y1 Y2 : X Y1 Y2 X Y1 X Y2. Lemma disjoint_union_r X Y1 Y2 : X ## Y1 Y2 X ## Y1 X ## Y2.
Proof. set_solver. Qed. Proof. set_solver. Qed.
(** Big unions *) (** Big unions *)
...@@ -494,9 +494,9 @@ Section simple_collection. ...@@ -494,9 +494,9 @@ Section simple_collection.
Lemma empty_union_L X Y : X Y = X = Y = ∅. Lemma empty_union_L X Y : X Y = X = Y = ∅.
Proof. unfold_leibniz. apply empty_union. Qed. Proof. unfold_leibniz. apply empty_union. Qed.
Lemma union_cancel_l_L X Y Z : Z X Z Y Z X = Z Y X = Y. Lemma union_cancel_l_L X Y Z : Z ## X Z ## Y Z X = Z Y X = Y.
Proof. unfold_leibniz. apply union_cancel_l. Qed. Proof. unfold_leibniz. apply union_cancel_l. Qed.
Lemma union_cancel_r_L X Y Z : X Z Y Z X Z = Y Z X = Y. Lemma union_cancel_r_L X Y Z : X ## Z Y ## Z X Z = Y Z X = Y.
Proof. unfold_leibniz. apply union_cancel_r. Qed. Proof. unfold_leibniz. apply union_cancel_r. Qed.
(** Empty *) (** Empty *)
...@@ -618,7 +618,7 @@ Section collection. ...@@ -618,7 +618,7 @@ Section collection.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma difference_intersection_distr_l X Y Z : (X Y) Z X Z Y Z. Lemma difference_intersection_distr_l X Y Z : (X Y) Z X Z Y Z.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma difference_disjoint X Y : X Y X Y X. Lemma difference_disjoint X Y : X ## Y X Y X.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Lemma difference_mono X1 X2 Y1 Y2 : Lemma difference_mono X1 X2 Y1 Y2 :
...@@ -630,7 +630,7 @@ Section collection. ...@@ -630,7 +630,7 @@ Section collection.
Proof. set_solver. Qed. Proof. set_solver. Qed.
(** Disjointness *) (** Disjointness *)
Lemma disjoint_intersection X Y : X Y X Y ∅. Lemma disjoint_intersection X Y : X ## Y X Y ∅.
Proof. set_solver. Qed. Proof. set_solver. Qed.
Section leibniz. Section leibniz.
...@@ -683,11 +683,11 @@ Section collection. ...@@ -683,11 +683,11 @@ Section collection.
Lemma difference_intersection_distr_l_L X Y Z : Lemma difference_intersection_distr_l_L X Y Z :
(X Y) Z = X Z Y Z. (X Y) Z = X Z Y Z.
Proof. unfold_leibniz. apply difference_intersection_distr_l. Qed. Proof. unfold_leibniz. apply difference_intersection_distr_l. Qed.
Lemma difference_disjoint_L X Y : X Y X Y = X. Lemma difference_disjoint_L X Y : X ## Y X Y = X.
Proof. unfold_leibniz. apply difference_disjoint. Qed. Proof. unfold_leibniz. apply difference_disjoint. Qed.
(** Disjointness *) (** Disjointness *)
Lemma disjoint_intersection_L X Y : X Y X Y = ∅. Lemma disjoint_intersection_L X Y : X ## Y X Y = ∅.
Proof. unfold_leibniz. apply disjoint_intersection. Qed. Proof. unfold_leibniz. apply disjoint_intersection. Qed.
End leibniz. End leibniz.
...@@ -707,7 +707,7 @@ Section collection. ...@@ -707,7 +707,7 @@ Section collection.
intros x. rewrite !elem_of_union; rewrite elem_of_difference. intros x. rewrite !elem_of_union; rewrite elem_of_difference.
split; [ | destruct (decide (x Y)) ]; intuition. split; [ | destruct (decide (x Y)) ]; intuition.
Qed. Qed.
Lemma subseteq_disjoint_union X Y : X Y Z, Y X Z X Z. Lemma subseteq_disjoint_union X Y : X Y Z, Y X Z X ## Z.
Proof. Proof.
split; [|set_solver]. split; [|set_solver].
exists (Y X); split; [auto using union_difference|set_solver]. exists (Y X); split; [auto using union_difference|set_solver].
...@@ -732,7 +732,7 @@ Section collection. ...@@ -732,7 +732,7 @@ Section collection.
Proof. unfold_leibniz. apply non_empty_difference. Qed. Proof. unfold_leibniz. apply non_empty_difference. Qed.
Lemma empty_difference_subseteq_L X Y : X Y = X Y. Lemma empty_difference_subseteq_L X Y : X Y = X Y.
Proof. unfold_leibniz. apply empty_difference_subseteq. Qed. Proof. unfold_leibniz. apply empty_difference_subseteq. Qed.
Lemma subseteq_disjoint_union_L X Y : X Y Z, Y = X Z X Z. Lemma subseteq_disjoint_union_L X Y : X Y Z, Y = X Z X ## Z.
Proof. unfold_leibniz. apply subseteq_disjoint_union. Qed. Proof. unfold_leibniz. apply subseteq_disjoint_union. Qed.
Lemma singleton_union_difference_L X Y x : Lemma singleton_union_difference_L X Y x :
{[x]} (X Y) = ({[x]} X) (Y {[x]}). {[x]} (X Y) = ({[x]} X) (Y {[x]}).
...@@ -1052,7 +1052,7 @@ Section seq_set. ...@@ -1052,7 +1052,7 @@ Section seq_set.
Qed. Qed.
Lemma seq_set_S_disjoint start len : Lemma seq_set_S_disjoint start len :
{[ start + len ]} seq_set (C:=C) start len. {[ start + len ]} ## seq_set (C:=C) start len.
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 :
......
...@@ -122,7 +122,7 @@ Proof. ...@@ -122,7 +122,7 @@ Proof.
- set_solver. - set_solver.
Qed. Qed.
Lemma size_union X Y : X Y size (X Y) = size X + size Y. Lemma size_union X Y : X ## Y size (X Y) = size X + size Y.
Proof. Proof.
intros. unfold size, collection_size. simpl. rewrite <-app_length. intros. unfold size, collection_size. simpl. rewrite <-app_length.
apply Permutation_length, NoDup_Permutation. apply Permutation_length, NoDup_Permutation.
......
...@@ -81,14 +81,14 @@ Proof. rewrite not_elem_of_dom. apply delete_partial_alter. Qed. ...@@ -81,14 +81,14 @@ Proof. rewrite not_elem_of_dom. apply delete_partial_alter. Qed.
Lemma delete_insert_dom {A} (m : M A) i x : Lemma delete_insert_dom {A} (m : M A) i x :
i dom D m delete i (<[i:=x]>m) = m. i dom D m delete i (<[i:=x]>m) = m.
Proof. rewrite not_elem_of_dom. apply delete_insert. Qed. Proof. rewrite not_elem_of_dom. apply delete_insert. Qed.
Lemma map_disjoint_dom {A} (m1 m2 : M A) : m1 m2 dom D m1 dom D m2. Lemma map_disjoint_dom {A} (m1 m2 : M A) : m1 ## m2 dom D m1 ## dom D m2.
Proof. Proof.
rewrite map_disjoint_spec, elem_of_disjoint. rewrite map_disjoint_spec, elem_of_disjoint.
setoid_rewrite elem_of_dom. unfold is_Some. naive_solver. setoid_rewrite elem_of_dom. unfold is_Some. naive_solver.
Qed. Qed.
Lemma map_disjoint_dom_1 {A} (m1 m2 : M A) : m1 m2 dom D m1 dom D m2. Lemma map_disjoint_dom_1 {A} (m1 m2 : M A) : m1 ## m2 dom D m1 ## dom D m2.
Proof. apply map_disjoint_dom. Qed. Proof. apply map_disjoint_dom. Qed.
Lemma map_disjoint_dom_2 {A} (m1 m2 : M A) : dom D m1 dom D m2 m1 m2. Lemma map_disjoint_dom_2 {A} (m1 m2 : M A) : dom D m1 ## dom D m2 m1 ## m2.
Proof. apply map_disjoint_dom. Qed. Proof. apply map_disjoint_dom. Qed.
Lemma dom_union {A} (m1 m2 : M A) : dom D (m1 m2) dom D m1 dom D m2. Lemma dom_union {A} (m1 m2 : M A) : dom D (m1 m2) dom D m1 dom D m2.
Proof. Proof.
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment