Skip to content

Conversation

@kim-em
Copy link
Collaborator

@kim-em kim-em commented Dec 3, 2025

This PR enables exact? to find theorems with fvar-headed conclusions like iteInduction : motive (ite c t e) when the goal has a matching structure like p (if h then x else y).

Previously, such theorems were indexed under .star but their argument structure was not preserved, so they couldn't be matched effectively. Now when indexing fvar-headed terms, we also push their arguments to the discrimination tree, enabling matching by argument structure.

Changes:

  • LazyDiscrTree.lean: In pushArgs, when encountering an fvar head with arguments, push those arguments to the todo list (previously they were dropped)
  • LazyDiscrTree.lean: In getMatchCore, when the goal has an fvar head, follow the .star edge with the fvar's arguments to find matching theorems

🤖 Prepared with Claude Code

@kim-em kim-em requested a review from leodemoura as a code owner December 3, 2025 02:07
@kim-em kim-em marked this pull request as draft December 3, 2025 03:30
kim-em and others added 2 commits December 3, 2025 03:53
This PR enables `exact?` to find theorems with fvar-headed conclusions
like `iteInduction : motive (ite c t e)` when the goal has a matching
structure like `p (if h then x else y)`.

Previously, such theorems were indexed under `.star` and dropped because
they matched too many goals. Now we add secondary entries indexed by the
first concrete argument's structure.

Changes:
- LibrarySearch.lean: Add `getFirstArgEntry` to extract secondary index
  entries from fvar-headed conclusions
- LazyDiscrTree.lean: Modify `getMatchCore` to search by first argument's
  key when goal has fvar head

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@kim-em kim-em force-pushed the librarySearch-eliminators branch from b221395 to d0935fc Compare December 3, 2025 11:42
@kim-em kim-em changed the title feat: exact? uses star-indexed lemmas as fallback refactor: replace fullExt with starLemmasExt and add eliminator support Dec 3, 2025
@kim-em kim-em force-pushed the librarySearch-eliminators branch from 2a0af34 to 9249ecc Compare December 3, 2025 12:22
@kim-em kim-em changed the title refactor: replace fullExt with starLemmasExt and add eliminator support feat: exact? finds theorems of the form f (const x y) z, with variable head Dec 3, 2025
@kim-em kim-em changed the title feat: exact? finds theorems of the form f (const x y) z, with variable head feat: exact? finds eliminator-style theorems like iteInduction Dec 3, 2025
@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 Dec 3, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 1377da0c762deb0a42c880e38606018c2ea561cc --onto 5bd331e85d9d110a29fb3367dbb21854010ffcbd. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-03 13:23:39)

@leanprover-bot
Copy link
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 1377da0c762deb0a42c880e38606018c2ea561cc --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-12-03 13:23:41)

@kim-em
Copy link
Collaborator Author

kim-em commented Dec 4, 2025

I am skeptical about this PR, I think just going all the way to #11494 is a better idea. Keeping it around for now in case I run into obstacles there.

@kim-em kim-em closed this Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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