aboutsummaryrefslogtreecommitdiff
path: root/src/Util/ListUtil.v
diff options
context:
space:
mode:
authorGravatar Jason Gross <jagro@google.com>2018-07-02 15:27:06 -0400
committerGravatar Jason Gross <jagro@google.com>2018-07-02 15:27:06 -0400
commitfe4ad2cd8f0a2f732835e0cd7f25896f63b8478e (patch)
tree92a772cf09f3acfcf42bbcfa1fa87a8add41bb35 /src/Util/ListUtil.v
parent6a8f392badaf7b736651d8349a4eaced47fa2d5e (diff)
Add some list lemmas
Diffstat (limited to 'src/Util/ListUtil.v')
-rw-r--r--src/Util/ListUtil.v11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Util/ListUtil.v b/src/Util/ListUtil.v
index d49db025b..117d02206 100644
--- a/src/Util/ListUtil.v
+++ b/src/Util/ListUtil.v
@@ -1969,3 +1969,14 @@ Proof.
(induction xs as [|x' xs IHxs]; cbn; [ | destruct (f x') eqn:?, (partition f xs) ]; cbn in *; subst; intuition (subst; auto));
congruence.
Qed.
+
+Lemma list_rect_map A B P (f : A -> B) N C ls
+ : @list_rect B P N C (map f ls) = @list_rect A (fun ls => P (map f ls)) N (fun x xs rest => C (f x) (map f xs) rest) ls.
+Proof. induction ls as [|x xs IHxs]; cbn; [ | rewrite IHxs ]; reflexivity. Qed.
+Lemma flat_map_app A B (f : A -> list B) xs ys
+ : flat_map f (xs ++ ys) = flat_map f xs ++ flat_map f ys.
+Proof. induction xs as [|x xs IHxs]; cbn; rewrite ?IHxs, <- ?app_assoc; reflexivity. Qed.
+Hint Rewrite flat_map_app : push_flat_map.
+Lemma map_flat_map A B C (f : A -> list B) (g : B -> C) xs
+ : map g (flat_map f xs) = flat_map (fun x => map g (f x)) xs.
+Proof. induction xs as [|x xs IHxs]; cbn; rewrite ?map_app; congruence. Qed.