Draft
Conversation
added 21 commits
February 24, 2026 17:14
Add test for polymorphic function in DDM Add tests for verifier errors (polymorphism, no decreaes, etc) Remove reundant scope with scopeSelf
Add support for more complex triggers in s-expr Remove uses of Visibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes: This PR adds support for recursive functions in Strata Core, including their definition in concrete syntax, partial evaluation, and an axiom-based SMT encoding.
Main changes:
@[scopeSelf]that acts like@[scope]but also adds the function's name to its body's scope. This is structured and handled very similarly to@[declareDatatype], which involves a similar recursive structure. Main changes are inAST.lean,Format.lean,Core.lean.Funcindicating whether a function is recursive and giving an optionaldecreasesclause. This information is used inEnv.leanto calculate the index of the decreasing argument. Here we also rule out recursive functions that are not yet supported: polymorphic functions, functions with more sophisticated termination measures, and functions without an explicitdecreasingclause.RecursiveAxioms.leancontains the generation of axioms asLExprfor a recursive function. Generating the axiom is fairly simple, since we just create term e.g.forall h t, length (List.cons h t) = length (List.cons h t)and then partially evaluate the right-hand side. Since recursive functions are marked asinlineIfConstron their decreasing parameter, this produces the simplified form.Other changes
SMT/DDMTransform/Translatefor trigger patterns complex enough to handle constructors applied to arguments (e.g.List.cons h t).thenandelsebranches and changes the small-step semantics to match.Tests
RecursiveAxiomTests.leantests the generation of recursive axioms as Lambda terms.SMTEncoderDatatypeTests.leanthat demonstrates the SMT encoding of the recursive function axioms.RecursiveFunctionDDMTest.leantests the DDM parsing for recursive function.RecursiveFunctionErrorTest.leandemonstrates not-yet-supported recursive functions.RecursiveFunctionTests.leancontain a variety of programs with recursive functions, some of which contain VCs which can be solved purely by partial evaluation and others which require SMT-based reasoning.BinaryTreeSize.leangives a more complex example that demonstrates inductive reasoning over types and functions.What is not supported (yet): polymorphic and mutually recursive functions, termination checking.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.