Fix early return soundness in Laurel: replace assume false with exit#504
Merged
keyboardDrummer merged 3 commits intomainfrom Mar 5, 2026
Merged
Fix early return soundness in Laurel: replace assume false with exit#504keyboardDrummer merged 3 commits intomainfrom
assume false with exit#504keyboardDrummer merged 3 commits intomainfrom
Conversation
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass that eliminates predicate (constrained) types by: - Inserting assume for values received of predicate type (procedure inputs) - Inserting assert for values provided of predicate type (assignments, returns) - Resolving all predicate type references to their base types New files: - PredicateTypeElim.lean: the pass - T09_PredicateTypes.lean: comprehensive tests - T09_ConstrainedTypes.lean: simple test Also includes: - Grammar: constrained type syntax - Parser: parseConstrainedType, topLevelConstrainedType - Pipeline: pass wired before heapParameterization Depends on #504 (early return soundness fix) for postcondition checking on return paths.
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass that eliminates predicate (constrained) types by: - Inserting assume for values received of predicate type (procedure inputs) - Inserting assert for values provided of predicate type (assignments, returns) - Resolving all predicate type references to their base types New files: - PredicateTypeElim.lean: the pass - T09_PredicateTypes.lean: comprehensive tests - T09_ConstrainedTypes.lean: simple test Also includes: - Grammar: constrained type syntax - Parser: parseConstrainedType, topLevelConstrainedType - Pipeline: pass wired before heapParameterization Depends on #504 (early return soundness fix) for postcondition checking on return paths.
assume false with exit
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (167 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (189 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types in all positions Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (189 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types in all positions Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (189 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types in all positions Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (189 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types in all positions Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (189 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types in all positions Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (189 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types in all positions Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel pass (189 lines) that eliminates predicate types: - assume for inputs and call return values - assert for assignments, variable init, and call arguments - resolve all predicate type references to base types in all positions Grammar: constrained type syntax (6 lines) Parser: parseConstrainedType + topLevelConstrainedType (19 lines) Translator: import + pipeline wiring (2 lines) Test: T09_PredicateTypes — 10 procedures covering all cases Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel elimination pass (ConstrainedTypeElim.lean) that: - Inserts assume for inputs and call return values - Inserts assert for assignments, variable init, and call arguments - Resolves all constrained type references to base types No Core translator changes needed. Grammar: constrained type syntax Parser: parseConstrainedType + topLevelConstrainedType Test: T09_PredicateTypes — 11 test procedures Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel elimination pass (ConstrainedTypeElim.lean) that: - Inserts assume for inputs and call return values - Inserts assert for assignments, variable init, and call arguments - Resolves all constrained type references to base types No Core translator changes needed. Grammar: constrained type syntax Parser: parseConstrainedType + topLevelConstrainedType Test: T09_PredicateTypes — 11 test procedures Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel elimination pass (ConstrainedTypeElim.lean) that: - Inserts assume for inputs and call return values - Inserts assert for assignments, variable init, and call arguments - Resolves all constrained type references to base types No Core translator changes needed. Grammar: constrained type syntax Parser: parseConstrainedType + topLevelConstrainedType Test: T09_PredicateTypes — 11 test procedures Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel elimination pass (ConstrainedTypeElim.lean) that: - Inserts assume for inputs and call return values - Inserts assert for assignments, variable init, and call arguments - Resolves all constrained type references to base types No Core translator changes needed. Grammar: constrained type syntax Parser: parseConstrainedType + topLevelConstrainedType Test: T09_PredicateTypes — 11 test procedures Based on #504 (early return soundness fix).
fabiomadge
added a commit
that referenced
this pull request
Mar 3, 2026
A Laurel-to-Laurel elimination pass (ConstrainedTypeElim.lean) that: - Inserts assume for inputs and call return values - Inserts assert for assignments, variable init, and call arguments - Resolves all constrained type references to base types No Core translator changes needed. Grammar: constrained type syntax Parser: parseConstrainedType + topLevelConstrainedType Test: T09_PredicateTypes — 11 test procedures Based on #504 (early return soundness fix).
9728a16 to
579e349
Compare
Early returns were encoded as 'result := value; assume false'. The assume false made the path vacuously true, so postconditions were never checked on early return paths. Now uses exit statement targeting the labeled body block. The exit skips remaining body statements but postconditions (appended after the block by ProcedureEval) are still checked on all paths. Changes: - LaurelToCoreTranslator: assume false -> exit $body, wrap body in labeled block - TestDiagnostics: support consecutive annotation comments targeting the same code line (needed for duplicate diagnostics from #419) - T8b_EarlyReturnPostconditions: test for the soundness fix - T3_ControlFlow: updated annotations for #419 duplicates
579e349 to
dd1139d
Compare
keyboardDrummer
approved these changes
Mar 4, 2026
Contributor
|
Looks great! Thanks |
MikaelMayer
approved these changes
Mar 5, 2026
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.
Problem
Early returns in Laurel were encoded as
result := value; assume false. Theassume falsemade the return path vacuously true, so Core's VCG never checked postconditions on early return paths. A procedure like:passed verification silently.
Fix
Replace
assume falsewithexit $bodytargeting a labeled body block. Theexitskips remaining body statements, but postconditions — appended after the block byProcedureEval— are still checked on all paths.Changes
assume "return" false→.exit (some "$body") md, wrap procedure body in labeled$bodyblockContext
See PR #385 discussion for the original analysis of this soundness issue. Duplicate diagnostics from
exitinsideifbranches are a known Core VCG issue (#419).By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.