leanprover / leanprover/lean4

Over eager simplification of Array.drop

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

Nobody has claimed this yet.

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

Description

Prerequisites
Description

Simp simplifies (Array.drop xs n).toList to List.take (xs.size - n) (List.drop n xs.toList). This is self evidently a bad simplification, the List.take is totally superfluous.

The offending simp lemma is, in my view, Array.drop_eq_extract. Neither List.drop_eq_extract nor List.take_eq_extract are simp lemmas, and their array counterparts likely should not be either.

Instead, I believe core should provide Array.toList_take and Array.toList_drop which should be simp lemmas.

Context

This came up in one of my PRs to Batteries.

Zulip

Steps to Reproduce
example : (Array.drop as n).toList = List.take (as.size - n) (List.drop n as.toList) := by
  simp

Expected behavior: Array.drop as n).toList simplifies to List.drop n as.toList

Actual behavior: it instead simplifies to List.take (as.size - n) (List.drop n as.toList)

Versions

Lean 4.29.0-nightly-2026-02-03
Target: x86_64-unknown-linux-gnu

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, 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

Start with the minimal Array.drop reproduction and inspect the named Array.drop_eq_extract simp lemma. Compare its behavior with the stated List.drop and List.take cases, then verify that simplification produces List.drop n as.toList rather than the redundant List.take expression.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.