Skip to content

Conversation

@datokrat
Copy link
Contributor

@datokrat datokrat commented Jan 15, 2026

This PR makes several small improvements to the list/array/vector API:

  • It fixes typos in Init.Core.
  • It adds List.isSome_min_iff and List.isSome_max_iff.
  • It adds grind and simp annotations to various previously unannotated lemmas.
  • It adds lemmas for characterizing ∃ x ∈ xs, P x using indices as ∃ (i : Nat), ∃ hi, P (xs[i]), and similar universally quantified lemmas: exists_mem_iff_exists_getElem and forall_mem_iff_forall_getElem.
  • It adds Vector.toList_zip.
  • It adds map_ofFn and ofFn_getElem for lists/arrays/vectors.

@datokrat datokrat changed the title human-eval upstreaming 2 feat: various small list/array/vector API improvements Jan 15, 2026
@datokrat datokrat added the changelog-library Library label Jan 15, 2026
@datokrat
Copy link
Contributor Author

!radar

@leanprover-radar
Copy link

leanprover-radar commented Jan 15, 2026

Benchmark results for 36bde59 against e56351d are in! @datokrat

Warnings (2)

These warnings may indicate that the benchmark results are not directly comparable, for example due to changes in the runner configuration or hardware.

  • Runner for run build has different system configurations between commits.
  • Runner for run other has different system configurations between commits.
Small changes (2✅, 10🟥)
  • 🟥 build/module/Init.Data.Array.Count//instructions: +61.3M (+1.8%)
  • 🟥 build/module/Init.Data.Array.Lemmas//instructions: +246.4M (+0.3%)
  • 🟥 build/module/Init.Data.Array.OfFn//instructions: +189.2M (+7.9%) (reduced significance based on *//lines)
  • 🟥 build/module/Init.Data.List.Count//instructions: +68.1M (+1.8%) (reduced significance based on *//lines)
  • 🟥 build/module/Init.Data.List.Lemmas//instructions: +151.8M (+0.3%)
  • 🟥 build/module/Init.Data.List.MinMax//instructions: +66.2M (+1.6%) (reduced significance based on *//lines)
  • 🟥 build/module/Init.Data.List.OfFn//instructions: +179.8M (+7.7%) (reduced significance based on *//lines)
  • 🟥 build/module/Init.Data.Vector.Count//instructions: +71.3M (+2.3%)
  • 🟥 build/module/Init.Data.Vector.Lemmas//instructions: +347.7M (+0.6%) (reduced significance based on *//lines)
  • 🟥 build/module/Init.Data.Vector.OfFn//instructions: +117.4M (+1.7%) (reduced significance based on *//lines)
  • build/module/Lake.CLI//instructions: -15.6M (-2.0%)
  • build/module/Lean.Elab.Tactic.Congr//instructions: -18.0M (-1.7%)

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jan 15, 2026
@leanprover-bot
Copy link
Collaborator

leanprover-bot commented Jan 15, 2026

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-01-12 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-01-15 17:29:26)
  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-01-14 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-01-17 00:29:41)

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jan 15, 2026
@github-actions github-actions bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Jan 15, 2026
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jan 15, 2026
@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Jan 15, 2026
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Jan 15, 2026

Mathlib CI status (docs):

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jan 16, 2026
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jan 16, 2026
@leanprover-community-bot leanprover-community-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Jan 16, 2026
Comment on lines +97 to +106
@[grind ←=]
theorem Grind.countP_eq_zero_of_forall {xs : Array α} (h : ∀ x ∈ xs, ¬ p x) : xs.countP p = 0 :=
countP_eq_zero.mpr h

/-- This lemma is only relevant for `grind`. -/
theorem Grind.not_of_countP_eq_zero_of_mem {xs : Array α} (h : xs.countP p = 0) (h' : x ∈ xs) : ¬ p x :=
countP_eq_zero.mp h _ h'

grind_pattern Grind.not_of_countP_eq_zero_of_mem => xs.countP p, x ∈ xs where
guard xs.countP p = 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy with this approach of grindifying countP_eq_zero, but I couldn't come up with something better. I tend to think that these grind lemmas are useful, but am not 100% sure that adding them is worth it.

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jan 17, 2026
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-library Library mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

5 participants