leanprover / leanprover/lean4

RFC: `List` lemmas for `tail`/`dropLast` applied to `take`/`drop`

Open
#12,910 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

RFC
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Proposal

I propose adding these lemmas:

theorem tail_take (l : List α) (i : Nat) : (l.take i).tail = l.tail.take (i - 1) := by
  simp [← drop_one, drop_take]

theorem dropLast_take' (l : List α) (i : Nat) :
    (l.take i).dropLast = l.dropLast.take (i - 1) := by
  simp [dropLast_eq_take, take_take, Nat.sub_min_sub_right,
    Nat.le_trans (sub_le ..) (Nat.min_le_left ..)]

theorem tail_drop' (l : List α) (i : Nat) : (l.drop i).tail = l.tail.drop i := by
  simp

theorem dropLast_drop (l : List α) (i : Nat) : (l.drop i).dropLast = l.dropLast.drop i := by
  simp [dropLast_eq_take, Nat.sub_right_comm, drop_take]
Community Feedback

#Is there code for X? > List.tail/List.dropLast + List.take
(Kim supported adding these to core)

Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The proposal specifies four List lemmas: tail_take, dropLast_take', tail_drop', and dropLast_drop. Start by locating the core List API and its existing theorem organization, then check how these statements fit there. Done means the four lemmas are added with the supplied proofs and compile successfully.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.