Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

(a :: l ++ [b]).last' does not simplify to some b #18010

Open
jcpaik opened this issue Dec 24, 2022 · 0 comments
Open

(a :: l ++ [b]).last' does not simplify to some b #18010

jcpaik opened this issue Dec 24, 2022 · 0 comments

Comments

@jcpaik
Copy link

jcpaik commented Dec 24, 2022

For a list with ends a and b, simp does not simplify its last' to some b:

import data.list

variable {α : Type*}
example (a b : α) (l : list α) : (a :: l ++ [b]).last' = some b :=
begin simp, sorry end

A possible workaround is to add the following simp lemma.

import data.list

variable {α : Type*}
@[simp]
theorem list.last'_cons_append_cons (a b : α) (l1 l2 : list α) : 
  (a :: (l1 ++ b :: l2)).last' = (b :: l2).last' := 
by revert a; induction l1 with c l1 ih; simp; intro; exact ih c

-- Now this works
example (a b : α) (l : list α) : (a :: l ++ [b]).last' = some b := by simp

How about we add the lemma above to mathlib?

I think a similar lemma for list.last (without ticks) can be also proved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant