Skip to content

Conversation

@joscoh
Copy link
Contributor

@joscoh joscoh commented Oct 6, 2025

Adds bounded integer type to LMonoTy and parameterizes LExprT with this type to produce Lambda expressions with bounded ints. File DL/Bounded/BExpr.lean contains an algorithm (with explanation) to translate these terms to ordinary Lambda expressions (with bound assumptions added) and to produce well-formedness conditions. The rest of the changes are simply a result of adding another parameter to LMonoTy.

This PR allows the definitions of types like nat = {x : int | 0 <= x} and expressions like forall (x: nat), x + 1 > 0. This gets translated to the semantically equivalent forall (x: int), 0 <= x -> x + 1 > 0. For more examples which show the variety of features supported (e.g. external operators with bounded types), see the test cases in StrataTest/DL/Bounded/BExprTest.lean.

Currently, this omits the necessary changes to the typing and type inference of Lambda; these will need to be made polymorphic in the newly added ExtraRestrict parameter. Once this piece is complete, the default parameter of LMonoTy will be Empty rather than BoundTyRestrict, resulting in no overall change to Lambda.

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 18 commits September 16, 2025 16:58
Instantiate with unit as default for compatibiity
Bitvectors are no longer a special case in LTy but rather an
instance of a type restriction/metadata
Test cases for wf generation
Fix a few bugs, refactor and improve comments in code
Some AI-generated tests for more bound cases
Change List -> Set to avoid duplicates
Remove quantifiers from output wf conditions when possible
Add guard_msgs for tests
Split tests into separate file
Fix bug in abstraction case
Better description of overall algorithm
Mark definitions private
Comments for most functions
Other minor code quality improvements
@joscoh joscoh requested review from a team, atomb and shigoel as code owners October 6, 2025 21:47
@joscoh joscoh changed the title Add bounded integer types to Lambda Add bounded integer types and expressions to Lambda Oct 6, 2025
Josh Cohen added 3 commits October 7, 2025 11:33
Still special case but need this way so that we can have polymorphic
non-restricted type applications
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.

1 participant