Skip to content

feat: fine-grained equational lemmas for non-recursive functions#4154

Merged
nomeata merged 45 commits intomasterfrom
joachim/nonrec-eqns2
Aug 22, 2024
Merged

feat: fine-grained equational lemmas for non-recursive functions#4154
nomeata merged 45 commits intomasterfrom
joachim/nonrec-eqns2

Conversation

@nomeata
Copy link
Copy Markdown
Collaborator

@nomeata nomeata commented May 13, 2024

This is part of #3983.

Fine-grained equational lemmas are useful even for non-recursive functions, so this adds them.

The new option eqns.nonrecursive can be set to false to have the old behavior.

Breaking channge

This is a breaking change: Previously, rw [Option.map] would rewrite Option.map f o to match o with … . Now this rewrite will fail because the equational lemmas require constructors here (like they do for, say, List.map).

Remedies:

  • Split on o before rewriting.
  • Use rw [Option.map.eq_def], which rewrites any (saturated) application of Option.map
  • Use set_option eqns.nonrecursive false when defining the function in question.

Interaction with simp

The simp tactic so far had a special provision for non-recursive functions so that simp [f] will try to use the equational lemmas, but will also unfold f else, so less breakage here (but maybe performance improvements with functions with many cases when applied to a constructor, as the simplifier will no longer unfold to a large match-statement and then collapse it right away).

For projection functions and functions marked [reducible], simp [f] won’t use the equational theorems, and will only use its internal unfolding machinery.

Implementation notes

It uses the same mkEqnTypes function as for recursive functions, so we are close to a consistency here. There is still the wrinkle that for recursive functions we don't split matches without an interesting recursive call inside. Unifying that is future work.

@nomeata nomeata force-pushed the joachim/nonrec-eqns2 branch from 142e1a2 to 5b1e503 Compare May 13, 2024 17:08
@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 May 13, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request May 13, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request May 13, 2024
@ghost ghost added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label May 13, 2024
@ghost
Copy link
Copy Markdown

ghost commented May 13, 2024

Mathlib CI status (docs):

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc May 13, 2024 18:09 Inactive
ghost pushed a commit to leanprover-community/batteries that referenced this pull request May 13, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request May 13, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Jun 3, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jun 3, 2024
@ghost ghost added the release-ci Enable all CI checks for a PR, like is done for releases label Jun 3, 2024
nomeata added a commit to nomeata/leansat that referenced this pull request Jun 3, 2024
@nomeata nomeata removed the release-ci Enable all CI checks for a PR, like is done for releases label Aug 15, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Aug 15, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Aug 15, 2024
to avoid `id` checkpoints in the proof, which would make
the lemma ineligible for dsmip
@ghost ghost added the release-ci Enable all CI checks for a PR, like is done for releases label Aug 15, 2024
@nomeata nomeata removed the release-ci Enable all CI checks for a PR, like is done for releases label Aug 15, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Aug 21, 2024
@ghost ghost added breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan and removed builds-mathlib CI has verified that Mathlib builds against this PR labels Aug 21, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc August 21, 2024 09:50 Inactive
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Aug 21, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Aug 21, 2024
@ghost ghost 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 Aug 21, 2024
@nomeata nomeata marked this pull request as ready for review August 21, 2024 11:07
@nomeata nomeata added the release-ci Enable all CI checks for a PR, like is done for releases label Aug 21, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc August 21, 2024 16:43 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc August 21, 2024 17:42 Inactive
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Aug 21, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Aug 21, 2024
@nomeata nomeata added the will-merge-soon …unless someone speaks up label Aug 22, 2024
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 release-ci Enable all CI checks for a PR, like is done for releases toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN will-merge-soon …unless someone speaks up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant