Skip to content

Laurel API: precondition → preconditions, postcondition → postconditions#481

Merged
keyboardDrummer merged 8 commits intomainfrom
fabiomadge/laurel-api-changes
Feb 26, 2026
Merged

Laurel API: precondition → preconditions, postcondition → postconditions#481
keyboardDrummer merged 8 commits intomainfrom
fabiomadge/laurel-api-changes

Conversation

@fabiomadge
Copy link
Contributor

@fabiomadge fabiomadge commented Feb 25, 2026

Part of the incremental split of #385. Can be merged independently of #426.

Changes

Converts Laurel's Procedure from a single precondition to a list of preconditions, and Body.Abstract from a single postcondition to a list. This enables multiple requires/ensures clauses per procedure, which is needed by the upcoming constrained types and contract features.

Laurel.lean:

  • precondition : WithMetadata StmtExprpreconditions : List (WithMetadata StmtExpr)
  • Body.Abstract postconditionBody.Abstract (postconditions : List ...)
  • Body.Opaque postconditionBody.Opaque postconditions (name only, already a list)
  • Reorder Parameter struct, add Repr instances

Adapted callers:

  • ConcreteToAbstractTreeTranslator — parse Option OptionalRequires into list
  • LaurelToCoreTranslator — iterate over preconditions list, generate indexed labels for multiple preconditions
  • HeapParameterization — fold over preconditions/postconditions lists
  • LaurelFormat — format preconditions/postconditions lists, relocate formatDeterminism
  • PythonToLaurel, Specs/ToLaurel — adapt to new field names

LiftExpressionAssignments.lean:

  • Process block-in-expression non-last elements left-to-right via transformStmt instead of right-to-left via transformExprDiscarded
  • Remove now-unused transformExprDiscarded

Testing

All existing Laurel, Python, and Core tests pass. No new tests needed — this is a structural refactor with no new features.

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

@fabiomadge fabiomadge requested a review from a team February 25, 2026 03:39
@fabiomadge fabiomadge force-pushed the fabiomadge/laurel-api-changes branch from 22fc213 to f04dd39 Compare February 25, 2026 04:53
Copy link
Contributor

@keyboardDrummer keyboardDrummer left a comment

Choose a reason for hiding this comment

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

Looks good, but I left one blocking comment.

- Laurel.lean: precondition (single) → preconditions (list),
  postcondition → postconditions in Body.Abstract, Parameter struct
  reorder, add Repr instances
- ConcreteToAbstractTreeTranslator: adapt to list preconditions
- LaurelToCoreTranslator: iterate over preconditions list
- HeapParameterization: iterate over preconditions/postconditions lists
- LaurelFormat: format preconditions list, restore formatDeterminism
- LaurelEval: adapt While invariant handling
- LiftExpressionAssignments: simplify block ordering
- LaurelTypes: reorder operator match
- PythonToLaurel, Specs/ToLaurel: adapt to new field names
@fabiomadge fabiomadge force-pushed the fabiomadge/laurel-api-changes branch from c56a53c to f022b9c Compare February 25, 2026 16:29
github-merge-queue bot pushed a commit that referenced this pull request Feb 25, 2026
…ebase (#483)

### Changes
Add additional code owners to the Laurel and Python pieces of the
codebase. Example PR that this change would allow either of us to
review: #481

### Testing
N/A

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
@fabiomadge fabiomadge force-pushed the fabiomadge/laurel-api-changes branch from 5b344ec to 12a52bc Compare February 25, 2026 16:44
@fabiomadge fabiomadge force-pushed the fabiomadge/laurel-api-changes branch from 12a52bc to c08adb2 Compare February 25, 2026 16:56
atomb
atomb previously approved these changes Feb 26, 2026
@keyboardDrummer keyboardDrummer added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit 2341cf8 Feb 26, 2026
15 checks passed
@keyboardDrummer keyboardDrummer deleted the fabiomadge/laurel-api-changes branch February 26, 2026 18:27
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.

4 participants