Skip to content

feat: infer mutual structural recursion - #4718

Merged
nomeata merged 17 commits into
masterfrom
joachim/mutual-ind-paras
Jul 15, 2024
Merged

nomeata merged 17 commits into
masterfrom
joachim/mutual-ind-paras

Conversation

@nomeata

@nomeata nomeata commented Jul 10, 2024 •

Copy link
Copy Markdown
Collaborator

the support for mutual structural recursion (new since #4575) is extended so that Lean tries to infer it even without annotations.

  • The error message when termination checking fails looks quite different now. Maybe a bit better, maybe with more room for improvements.
  • If there are too many combinations (with an arbitrary cut-off) for a given argument type, it will just give up and ask the user to use termination_by structural.
  • It is now legal to specify termination_by structural on not necessarily all functions of a clique; this simply restricts the combinations of arguments that Lean considers.

@nomeata
nomeata force-pushed the joachim/mutual-ind-paras branch from cf3d547 to ede15f5 Compare July 10, 2024 15:46
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 10, 2024 15:52 Inactive
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 10, 2024 16:14 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 Jul 10, 2024
@ghost

ghost commented Jul 10, 2024 •

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 c01e003b49c4b75da1eec88155430f6ce6310750 --onto 582d6e7f7168e0dc0819099edaace27d913b893e. (2024-07-10 16:31:41)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 5f70c1ca64a2c05a5866c47b9eb80a92034433ec --onto ce8a13072496063ed1b6305ba8dc68d6680eada3. (2024-07-11 08:03:13)
  • ✅ Mathlib branch lean-pr-testing-4718 has successfully built against this PR. (2024-07-12 09:24:00) View Log
  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2024-07-12 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. (2024-07-12 10:03:36)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase a6ae49c3abaade6f2f4420665b4a67d93069fd81 --onto 5f70c1ca64a2c05a5866c47b9eb80a92034433ec. (2024-07-13 06:57:48)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 1118978cbb344e6570729a70c74cd0d3121e8c35 --onto 5f70c1ca64a2c05a5866c47b9eb80a92034433ec. (2024-07-13 09:06:09)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase f99427bd1ac6595f9717796b7fabe6c6e8791e14 --onto 5f70c1ca64a2c05a5866c47b9eb80a92034433ec. (2024-07-15 09:36:11)

@nomeata
nomeata force-pushed the joachim/mutual-ind-paras branch from 152260d to c08f133 Compare July 11, 2024 07:50
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 11, 2024 07:59 Inactive
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 11, 2024 13:01 Inactive
Comment thread tests/lean/run/structuralMutual.lean Resolved
Comment thread src/Lean/Meta/Basic.lean Resolved
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Jul 12, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jul 12, 2024
@ghost ghost added the builds-mathlib CI has verified that Mathlib builds against this PR label Jul 12, 2024
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 12, 2024 10:02 Inactive
nomeata added 2 commits July 13, 2024 08:42
This adds the types
* `IndGroupInfo`, a variant of `InductiveVal` with information that
   applies to a whole group of mutual inductives and
* `IndGroupInst` which extends `IndGroupInfo` with levels and parameters
   to indicate a instantiation of the group.

One purpose of this abstraction is to make it clear when a fuction
operates on a group as a whole, rather than a specific inductive within
the group.

This is extracted from #4718 and #4733 to reduce PR size and improve
bisectability.
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 13, 2024 08:00 Inactive
github-merge-queue Bot pushed a commit that referenced this pull request Jul 13, 2024
This adds the types
* `IndGroupInfo`, a variant of `InductiveVal` with information that
   applies to a whole group of mutual inductives and
* `IndGroupInst` which extends `IndGroupInfo` with levels and parameters
   to indicate a instantiation of the group.

One purpose of this abstraction is to make it clear when a fuction
operates on a group as a whole, rather than a specific inductive within
the group.

This is extracted from #4718 and #4733 to reduce PR size and improve
bisectability.
@nomeata
nomeata marked this pull request as ready for review July 13, 2024 08:55
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 13, 2024 09:07 Inactive
@github-actions
github-actions Bot temporarily deployed to lean-lang.org/lean4/doc July 15, 2024 09:25 Inactive
@nomeata
nomeata enabled auto-merge July 15, 2024 09:27
@nomeata
nomeata added this pull request to the merge queue Jul 15, 2024
Merged via the queue into master with commit 3ab2c71 Jul 15, 2024
github-merge-queue Bot pushed a commit that referenced this pull request Jul 15, 2024
This now works:

```lean
inductive Tree where | node : List Tree → Tree

mutual
def Tree.size : Tree → Nat
  | node ts => list_size ts

def Tree.list_size : List Tree → Nat
  | [] => 0
  | t::ts => t.size + list_size ts
end
```

It is still out of scope to expect to be able to use nested recursion
(e.g. through `List.map` or `List.foldl`) here.

Depends on #4718.

---------

Co-authored-by: Tobias Grosser <[email protected]>

This branch was previously deployed

1 inactive deployment
lean-lang.org/lean4/doc — 3bfcf0e8 Deployed Jul 15, 2024 by github-actions[bot]
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 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.

2 participants