Zulip Chat Archive

Stream: new members

Topic: vector_map_id missing?


Vaibhav Karve (Oct 27 2020 at 00:41):

Is this missing from mathlib? I wanted to use this in one of my proofs but had to prove it by hand because library_search and suggest told me it is not already in mathlib. Is that correct? Does it need to be added in?

lemma vec_map_id {α : Type} {n : } (v : vector α n) : vector.map id v = v :=
begin
  induction n,
    {simp only [eq_iff_true_of_subsingleton]},
  cases v with vl vn,
  unfold vector.map,
  norm_num,
end

Scott Morrison (Oct 27 2020 at 01:54):

I'm not seeing it either. I suspect there's a nicer proof in terms of .to_list.

Yakov Pechersky (Oct 27 2020 at 02:00):

import data.vector2

lemma vector.map_id {α : Type} {n : } (v : vector α n) : vector.map id v = v :=
begin
  apply vector.eq,
  simp only [list.map_id, vector.to_list_map]
end

Filippo A. E. Nuccio (Oct 27 2020 at 09:20):

Isn't it linear_map.id in linear_algebra.basic?

Anne Baanen (Oct 27 2020 at 09:21):

This is a computer science vector, i.e. a list with fixed length :)

Eric Wieser (Oct 27 2020 at 12:24):

This is worth a quick PR, right?

Anne Baanen (Oct 27 2020 at 12:27):

Quick PRs are always worth the effort!

Eric Wieser (Oct 27 2020 at 12:27):

Presumably the proof golfs to vector.eq (by simp)?

Vaibhav Karve (Oct 27 2020 at 14:04):

Almost. I think it's vector.eq _ _ (by simp).

Vaibhav Karve (Oct 27 2020 at 14:12):

@Eric Wieser if you don't mind, can I create the PR? I have never contributed to mathlib before and I would like to learn :-)

Vaibhav Karve (Oct 27 2020 at 14:45):

@maintainers Can I get write access for the non-master branches of mathlib? Github username: vaibhavkarve. Thank you for your time!

Mario Carneiro (Oct 27 2020 at 14:49):

invitation sent

Vaibhav Karve (Oct 27 2020 at 14:56):

I opened a PR here: https://github.com/leanprover-community/mathlib/pull/4799

Yury G. Kudryashov (Oct 27 2020 at 14:59):

#4799 works too


Last updated: Dec 20 2023 at 11:08 UTC