Skip to content

Remove functions#52

Closed
keyboardDrummer wants to merge 49 commits into
issue-924-contract-and-proof-passfrom
removeFunctions
Closed

Remove functions#52
keyboardDrummer wants to merge 49 commits into
issue-924-contract-and-proof-passfrom
removeFunctions

Conversation

@keyboardDrummer

@keyboardDrummer keyboardDrummer commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Changes

  1. Remove Laurel functions.
  2. Support let expressions in transparent bodies. This is necessary to implement the above change, because the contract pass can produce let expressions when calling procedures with preconditions, and some of the updated tests have transparent bodies that call procedures with preconditions.
  3. Fix several bugs in the lifting pass. Again this is now necessary because with more things being procedures, there were more cases where lifting had to be done correctly.
  4. Improve printing of if-then-else
  5. Fix contract pass so it eliminates all pre and postconditions
  6. Verification performance is worse because calling transparent procedures has a more complicated encoding than calling functions had. Calling transparent procedures should get an encoding optimization but that's out of scope for this PR.
  7. Added #guard_msgs (drop info) in to several tests to prevent getting info output when running lake test. These guards previously already existed but they were accidentally removed in a test refactoring.

Tests

  1. Replaced usages of function in tests with procedure. Tests that had duplicated cases for functions and procedures had the function test-cases removed.
  2. The T3_ControlFlow test was updated to use let expressions in a transparent body
  3. The T2_ImpureExpressions test was updated to check for the new fixed bugs in the lifting pass
  4. Some tests checked against printed if-then-else and they've been updated
  5. No explicit test for this.
  6. Updated tests. Some tests now check for "could not prove" instead of "does not hold"

@github-actions github-actions Bot added the Git conflicts PR has merge conflicts with the base branch label Jun 17, 2026
@github-actions github-actions Bot removed the Git conflicts PR has merge conflicts with the base branch label Jun 17, 2026
keyboardDrummer and others added 16 commits June 17, 2026 14:08
## Functional changes
1. [Debugging] Improve the printing of Laurel if-then-else expressions
1. `EliminateReturnsInExpression` now runs for procedures as well, which
enables more types of transparent bodies for procedures. To make it work
for both functions and procedures, it was also necessary for the body of
functions to be immediately wrapped in a return statement during
parsing.
1. Allow calling procedures from contracts. Combined with the previous
change this makes procedures strictly more powerful than functions
1. Let the transparency pass rewrite the bodies of assume statements so
they don't assert anything.
1. Improve diagnostics related to contracts, using the correct verbiage
"precondition" and "postcondition" instead of "assertion"
1. Generalized the `LaurelPass` concept so it works for all
transformation between Laurel source and Core, not just the
Laurel->Laurel transformation. This helps make the documentation more
complete.

### Why let the transparency pass rewrite the bodies of assume
statements so they don't assert anything?
After the contract pass, a call will look like `assert <preconditions>;
call(..); assume <postconditions>`, where the body of the callee looks
like `assume <preconditions>; <body>; assert <postconditions>`. If we
now do either concrete execution, or we do inlining, then any assertions
that occur inside the pre or postconditions will be asserted twice,
because they occur once in an assert and once in an assume. By ignoring
the assertions inside the assume, we prevent the duplication.

Whether you also want this behavior for assumptions that were created by
users is something I'm not sure about. However, if we want we can let
those behave differently. Right now I think we don't have enough data to
decide what we want for user created assumptions, and they are AFAIK not
yet used, so I think it's OK to change their behavior.

## Implementation
Add these passes:
- [New] EliminateReturnStatements: rewrite `return` to `exit`
statements, needed for the next pass.
- [New] ContractPass: translate away pre and postconditions entirely by
introducing assertion and assumptions at call sites and at procedure
starts and ends
- [Updated] Lift assertions, assumptions and procedure calls when they
occur in expressions. Note: the changes in this pass could have been
extracted to a different PR to reduce the scope of this one, but I think
that keeping them in this PR is most efficient from a developer time
perspective.

## Follow-up work
- Remove the now obsolete functions from Laurel
- Create WF proofs for quantifier bodies
- Lift assumptions in expressions to axioms.
- In the transparency phase, if something has no asserts and only calls
functions, only create a function and no procedure

---------

Co-authored-by: keyboardDrummer-bot <keyboardDrummer-bot@users.noreply.github.com>
Co-authored-by: Fabio Madge <fabio@madge.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant