Conflicting `simp` lemmas `List.push_append_toArray` and `Array.append_singleton`
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
#lean4 > List.push_append_toArray vs Array.push_singleton @ 💬
Simp lemmas docs#List.push_append_toArray and docs#Array.append_singleton are normalizing in opposite directions:
variable (a₁ a₂ : α) (as : Array α) #check_tactic as.push a₁ ++ #[a₂] ~> (as.push a₁).push a₂ by simp only [Array.append_singleton] #check_tactic as.push a₁ ++ #[a₂] ~> as ++ #[a₁, a₂] by simp only [List.push_append_toArray]In particular this makes normalization of arrays sensitive to the context and sensitive to the number of elements of an array in the context, resulting in terms that diverge rather than converge:
variable (a₁ a₂ a₃ : α) (as : Array α) #check_simp (as.push a₁).push a₂ ++ #[a₃] = as.push a₁ ++ #[a₂, a₃] ~> ((as.push a₁).push a₂).push a₃ = as ++ #[a₁, a₂, a₃]I ran into this expecting the following to close by simp:
example (a₁ a₂ : α) (as : Array α) : (as.push a₁).push a₂ = as ++ #[a₁, a₂] := by simpShould List.push_append_toArray normalize in the opposite direction (cons → push)? It would close this goal.
Versions
4.32
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal reproducer and the named simp lemmas List.push_append_toArray and Array.append_singleton; compare their normalization behavior using the shown #check_tactic and #check_simp examples. Done means the conflicting directions are reconciled and the final by simp example behaves consistently without context-sensitive divergence.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100