Zulip Chat Archive
Stream: Is there code for X?
Topic: Map eq cons
Marcus Rossel (Nov 12 2021 at 14:57):
I have a proof that hd :: tl = l.map f
for hd : X
, tl : list X
, l : List Y
, f : Y -> X
.
How can I show that l
must be equal to some a :: b
where f a = hd
and b.map f = tl
?
Yaël Dillies (Nov 12 2021 at 15:08):
You can do cases l
, get rid of the first goal because [].map f = []
and then rw list.map_cons
(or something like that) in your second goal.
Floris van Doorn (Nov 13 2021 at 12:30):
Though feel free to add a lemma to mathlib of the form lemma map_eq_cons : l.map f = hd :: tl \iff \exists x l', l = x :: l' \and f x = hd \and l'.map f = tl
Floris van Doorn (Nov 13 2021 at 12:32):
(and while we're at it map_eq_append
)
Eric Wieser (Nov 13 2021 at 12:38):
Should it be map_eq_cons_iff
? What does #naming have to say about trailing _iff
s?
Last updated: Dec 20 2023 at 11:08 UTC