Skip to content

feat: add iff theorem for List.toArray equality#13840

Closed
raphael-solace wants to merge 1 commit into
leanprover:masterfrom
raphael-solace:rc/list-toarray-iff
Closed

feat: add iff theorem for List.toArray equality#13840
raphael-solace wants to merge 1 commit into
leanprover:masterfrom
raphael-solace:rc/list-toarray-iff

Conversation

@raphael-solace
Copy link
Copy Markdown

@raphael-solace raphael-solace commented May 25, 2026

This PR adds List.toArray_eq_toArray_iff, the iff-shaped theorem for injectivity of List.toArray, while keeping the existing one-way List.toArray_inj theorem for compatibility.

The new theorem follows the usual iff naming shape and is marked [simp], so goals comparing two List.toArray expressions simplify back to list equality.

Addresses #13095.

@raphael-solace raphael-solace requested a review from kim-em as a code owner May 25, 2026 12:20
@raphael-solace
Copy link
Copy Markdown
Author

changelog-library

@github-actions github-actions Bot added changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN labels May 25, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 7f13a8988f0018f404d4bb0954f95122b8855084 --onto 2cd98639c40d2d2a026dd599093b70f55f55ffaf. You can force Mathlib CI using the force-mathlib-ci label. (2026-05-25 13:16:10)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 7f13a8988f0018f404d4bb0954f95122b8855084 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using the force-manual-ci label. (2026-05-25 13:16:12)

@Rob23oba
Copy link
Copy Markdown
Contributor

example (a b : List Nat) : a.toArray = b.toArray ↔ a = b := by simp

actually already works, via Array.mk.injEq. Also if you want to change anything, List.toArray_inj has the wrong name, _inj should be used for the iff theorems, so I'd instead promote List.toArray_inj to an iff theorem like this:

theorem toArray_inj {as bs : List α} : as.toArray = bs.toArray ↔ as = bs := by simp

@Kha Kha closed this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants