aboutsummaryrefslogtreecommitdiff
path: root/theories/Lists
diff options
context:
space:
mode:
authorOlivier Laurent2020-05-03 11:43:18 +0200
committerOlivier Laurent2020-05-04 09:20:23 +0200
commit8ed17d99c6be8c1c5c369c3b6d92deba389b6676 (patch)
treeb838e1f55bf57faac5fddac27d4d03a03d8dc62b /theories/Lists
parente4074cf4e9bc31616ec161541cb35a831573d384 (diff)
add incl_map incl_filter NoDup_filter
Diffstat (limited to 'theories/Lists')
-rw-r--r--theories/Lists/List.v21
1 files changed, 20 insertions, 1 deletions
diff --git a/theories/Lists/List.v b/theories/Lists/List.v
index 5d5f74db44..8798ee4fe5 100644
--- a/theories/Lists/List.v
+++ b/theories/Lists/List.v
@@ -2008,6 +2008,9 @@ Section SetIncl.
now apply incl_cons_inv in Hin.
Qed.
+ Lemma incl_filter f l : incl (filter f l) l.
+ Proof. intros x Hin; now apply filter_In in Hin. Qed.
+
Lemma remove_incl (eq_dec : forall x y : A, {x = y} + {x <> y}) : forall l1 l2 x,
incl l1 l2 -> incl (remove eq_dec x l1) (remove eq_dec x l2).
Proof.
@@ -2018,8 +2021,15 @@ Section SetIncl.
End SetIncl.
+Lemma incl_map A B (f : A -> B) l1 l2 : incl l1 l2 -> incl (map f l1) (map f l2).
+Proof.
+ intros Hincl x Hinx.
+ destruct (proj1 (in_map_iff _ _ _) Hinx) as [y [<- Hiny]].
+ apply in_map; intuition.
+Qed.
+
Hint Resolve incl_refl incl_tl incl_tran incl_appl incl_appr incl_cons
- incl_app: datatypes.
+ incl_app incl_map: datatypes.
(**************************************)
@@ -2412,6 +2422,15 @@ Section ReDun.
now apply Hnin, in_rev.
Qed.
+ Lemma NoDup_filter f l : NoDup l -> NoDup (filter f l).
+ Proof.
+ induction l; simpl; intros Hnd; auto.
+ apply NoDup_cons_iff in Hnd.
+ destruct (f a); [ | intuition ].
+ apply NoDup_cons_iff; split; intuition.
+ apply filter_In in H; intuition.
+ Qed.
+
(** Effective computation of a list without duplicates *)
Hypothesis decA: forall x y : A, {x = y} + {x <> y}.