Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: termination arguments as Expr, not Syntax #3658

Merged
merged 30 commits into from
Mar 15, 2024

Conversation

nomeata
Copy link
Contributor

@nomeata nomeata commented Mar 12, 2024

Before, the termination argument as inferred by GuessLex was passed further
on as Syntax, to be elaborated later in WF.Rel.

This didn’t feel quite right anymore. In particular if we want to teach
GuessLex about guessing more complex termination arguments like xs.size - i, using Expr here is more natural.

So this introduces TerminationArgument based on an Expr to be used here.

A side-effect of how the termination arguments are elaborated is that the unused
variables linter will now look at termination_by variables, and that parameters
past the colon are not even invisibly in scope, so ‹_› will not find them
See https://github.com/leanprover-community/mathlib4/pull/11370/files for examples
of fixing these changes.

This introduces the `ArgsPacker` module and abstraction, to replace the
exising `PackDomain`/`PackMutual` code. The motivation was that we now
have more uses besides `Fix.lean` (`GuessLex` and `FunInd`), and the
code was spread in various places.

The goals are

 * consistent function naming withing the the `PSigma` handling, the
   `PSum` handling, and the combined interface
 * avoid taking a type apart just based on the `PSigma`/`PSum` nesting,
   to be robust in case the user happens to be using `PSigma`/`PSum`
   somewhere. Therefore, always pass an `arity` or `numFuncs` or
   `varNames` around.
 *  keep all the `PSigma`/`PSum` encoding logic contained within one
    module (`ArgsPacker`), and keep that module independent of its users
    (so no `EqnInfos` visible here).
 * pick good variable names when matching on a packed argument
 * the unary function now is either called `fun1._unary` or
   `fun1._mutual`, never `fun1._unary._mutual`.

This file has less heavy dependencies than `PackMutual` had, so build
parallelism is improved as well.
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 12, 2024 14:39 Inactive
@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 Mar 12, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Mar 12, 2024

Mathlib CI status (docs):

  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 1388f6bc83b5ea085fe14faa1db213e745c3e398 --onto 32dcc6eb895b58df3d3241a2521963e64995b621. (2024-03-12 14:43:12)
  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 995726f75fd7eed223c2189a54f6df3293185327 --onto 317adf42e92a4dbe07295bc1f0429b61bb8079fe. (2024-03-14 14:08:25)
  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 795e332fb37729f013c9a66b211fd45e5c90a1f9 --onto 317adf42e92a4dbe07295bc1f0429b61bb8079fe. (2024-03-14 17:01:16)

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 12, 2024 15:08 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 12, 2024 18:24 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 12, 2024 18:38 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 13, 2024 11:08 Inactive
@nomeata nomeata changed the base branch from master to joachim/argspacker March 13, 2024 13:48
@nomeata nomeata changed the base branch from joachim/argspacker to master March 13, 2024 13:48
nomeata added a commit to leanprover-community/mathlib4 that referenced this pull request Mar 14, 2024
this will break once leanprover/lean4#3658
lands, so let's fix this now.
@nomeata nomeata added the will-merge-soon …unless someone speaks up label Mar 14, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 14, 2024 13:47 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 14, 2024 13:53 Inactive
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Mar 14, 2024
this will break once leanprover/lean4#3658
lands, so let's fix this now.

Also avoids binding unused variables in `termination_by`.
@nomeata nomeata changed the base branch from joachim/argspacker to master March 14, 2024 16:44
@nomeata nomeata enabled auto-merge March 14, 2024 16:47
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 14, 2024 17:04 Inactive
@nomeata nomeata added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 14, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 14, 2024 19:46 Inactive
@nomeata nomeata enabled auto-merge March 14, 2024 23:13
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc March 14, 2024 23:21 Inactive
@nomeata nomeata added this pull request to the merge queue Mar 14, 2024
Merged via the queue into master with commit 022b2e4 Mar 15, 2024
20 checks passed
dagurtomas pushed a commit to leanprover-community/mathlib4 that referenced this pull request Mar 22, 2024
this will break once leanprover/lean4#3658
lands, so let's fix this now.

Also avoids binding unused variables in `termination_by`.
utensil pushed a commit to leanprover-community/mathlib4 that referenced this pull request Mar 26, 2024
this will break once leanprover/lean4#3658
lands, so let's fix this now.

Also avoids binding unused variables in `termination_by`.
Louddy pushed a commit to leanprover-community/mathlib4 that referenced this pull request Apr 15, 2024
this will break once leanprover/lean4#3658
lands, so let's fix this now.

Also avoids binding unused variables in `termination_by`.
uniwuni pushed a commit to leanprover-community/mathlib4 that referenced this pull request Apr 19, 2024
this will break once leanprover/lean4#3658
lands, so let's fix this now.

Also avoids binding unused variables in `termination_by`.
callesonne pushed a commit to leanprover-community/mathlib4 that referenced this pull request Apr 22, 2024
this will break once leanprover/lean4#3658
lands, so let's fix this now.

Also avoids binding unused variables in `termination_by`.
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 will-merge-soon …unless someone speaks up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants