Skip to content

Conversation

@joscoh
Copy link
Contributor

@joscoh joscoh commented Jan 17, 2026

Description of changes:
Adds mutually recursive types to Lambda and its corresponding SMT generation (declare-datatypes). In particular, mutually recursive types generate multiple eliminators, which still have the expected computational behavior. This PR includes tests in TypeFactoryTests.lean for eliminators, other derived functions, and typechecking and in SMTEncoderDatatypeTest.lean and DatatypeVerificationTest.lean for SMT output and verification.
Some key changes:

  1. Core declarations can now have multiple declarations (and likewise multiple names)
  2. The SMT output becomes simpler. We no longer need dependency analysis to rule out mutually recursive types, instead checking type references when a mutual block is created and therefore maintaining a topological order.
  3. Substantial changes to the proofs in ProgramWF.lean, which now have more structure but also more repetition. They can/should be improved in a future PR.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Josh Cohen added 12 commits January 16, 2026 11:58
Generate eliminators for mutual recursive types
Change Boogie TypeDecl to take in List
Leave ProgramWF proofs as sorry for now
Change strict positivity+uniformity checks for mutually recursive types
Remove topological ordering, require TypeContext for order
Adds tests for mutually recursive SMT encoding and for Boogie verif
@joscoh joscoh marked this pull request as ready for review January 21, 2026 00:19
@joscoh joscoh requested a review from a team as a code owner January 21, 2026 00:19
@shigoel shigoel enabled auto-merge January 21, 2026 19:59
@shigoel
Copy link
Contributor

shigoel commented Jan 21, 2026

We no longer need dependency analysis to rule out mutually recursive types, instead checking type references when a mutual block is created and therefore maintaining a topological order.

So, so nice!

Copy link
Contributor

@shigoel shigoel left a comment

Choose a reason for hiding this comment

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

Partial review for now.

Copy link
Contributor

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

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

This PR adds mutually recursive types to Lambda, which is a significant and well-implemented feature. The implementation is thorough with comprehensive tests covering eliminators, testers, destructors, and error cases. The SMT encoding has been simplified by maintaining topological order in the TypeFactory. Overall, this is solid work that extends the type system in a principled way.

Critical issue: There is a bug in validateMutualBlock that prevents duplicate name detection. This should be fixed before merging.

Copy link
Contributor

@shigoel shigoel left a comment

Choose a reason for hiding this comment

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

Left some questions/comments. Looks great, thanks!

@shigoel shigoel added this pull request to the merge queue Jan 23, 2026
Merged via the queue into main with commit 7a02541 Jan 23, 2026
14 checks passed
@shigoel shigoel deleted the josh/mutual branch January 23, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants