Add opaque keyword to Laurel grammar#939
Add opaque keyword to Laurel grammar#939keyboardDrummer-bot wants to merge 25 commits intoissue-924-contract-and-proof-passfrom
opaque keyword to Laurel grammar#939Conversation
- Add 'opaque' keyword to the Laurel grammar (LaurelGrammar.st) that groups ensures and modifies clauses under it - Update ConcreteToAbstractTreeTranslator to parse the new opaqueSpec grammar node (8 args instead of 9) - Update AbstractToConcreteTreeTranslator to emit opaqueSpec when formatting procedures with Opaque bodies - Update all Laurel test files to mark all procedures as opaque - Update .lr.st and .laurel.st test files accordingly
|
The CI failure was caused by Root cause: The previous commit added Fix (3fd4564):
All remaining test failures match the base branch ( |
|
I investigated the CI failure on the Finding: All test failures are pre-existing on the base branch ( I verified this by:
The pre-existing failures are all caused by the Failing tests (identical on both base and PR):
No code changes needed for this PR — the CI failure is not caused by the |
3fd4564 to
6456248
Compare
|
@keyboardDrummer-bot there's currently a bug with postconditions and returns. If the body contains a return the postconditions won't be checked for that return. Add a pass that eliminates returns by replacing them with exits to a procedure block that's added around the procedure. This pass should come after the "EliminateReturns" pass. The new pass should make the test |
Adds a new Laurel-to-Laurel pass that replaces return statements with assignments to output parameters followed by exit to a labelled block wrapping the procedure body. This ensures postcondition assertions (inserted by the contract pass) are checked on all return paths. The pass runs after EliminateReturnsInExpression and before ConstrainedTypeElim/ContractPass in the pipeline.
|
@keyboardDrummer I've implemented the What the pass does:
This ensures that when the contract pass later appends Pipeline placement: The pass runs after Test result: As you noted, other tests may still fail — the pass always wraps procedure bodies in a labelled block, which is semantically equivalent but may interact with other parts of the pipeline. |
…' into opaque-keyword-grammar
|
@keyboardDrummer-bot It should pass after your changes. Other tests can still fail |
…assertions When a requires or ensures clause has a summary annotation, the contract pass now propagates that summary to the generated assert statement. This means verification errors will display the user-provided summary (e.g., 'divisor is non-zero does not hold') instead of the generic 'precondition does not hold' or 'postcondition does not hold'. - Added combinedSummary helper to extract summaries from clause metadata - Added preSummary/postSummary fields to ContractInfo - Updated all assertion generation sites to use clause summaries when available
|
Done — pushed commit e1f1148 to this branch. What changed: In Details:
Verification: |
… into opaque-keyword-grammar
|
@keyboardDrummer-bot to make test StrataTest/Languages/Laurel/Examples/Objects/T2_ModifiesClauses.lean pass, we will need to enable translating functions from FunctionsAndProofs, which have multiple outputs, to Core functions. For this we need to generate datatypes that contain all the return values for a particular function. For now we can support this only for functions in FunctionsAndProofs that don't have a body. Also, calls to functions with multiple outs, like Let's create a separate pass for this transformation that maps FunctionsAndProofs to FunctionsAndProofs. |
|
@keyboardDrummer I've made progress on the What's implementedNew file:
|
|
Just give me the new pass and the integration in the pipeline, without the test updates or any other changes like preserving postconditions in function copy |
|
@keyboardDrummer Done — opened draft PR #949 (targeting this branch) with just the new pass and pipeline integration, no test updates or other changes. What's included:
Full |
Summary
Introduces the
opaquekeyword in the Laurel grammar so that opaque procedures are explicitly marked. Ensures and modifies clauses are now syntactically only allowed after theopaquekeyword.Changes
Grammar (
LaurelGrammar.st)Added a new
OpaqueSpeccategory that groupsensuresandmodifiesclauses:The
procedureandfunctionops now take anOption OpaqueSpecinstead of separateSeq EnsuresClauseandSeq ModifiesClausearguments (8 args instead of 9).New syntax
Parser (
ConcreteToAbstractTreeTranslator.lean)parseProcedureto parse the newopaqueSpecargumentopaquedeterminesBody.OpaquevsBody.Transparentopaque, a procedure with a body isTransparent; withopaque, it'sOpaqueFormatter (
AbstractToConcreteTreeTranslator.lean)procedureToOpto emitopaqueSpecforBody.OpaqueandBody.AbstractproceduresTest updates
All Laurel test files (
.lean,.lr.st,.laurel.st) have been updated to mark all procedures asopaque. This includes ~60 files across:StrataTest/Languages/Laurel/Examples/StrataTest/Languages/Laurel/tests/StrataTest/Languages/Laurel/*.lean(unit tests)StrataTest/Backends/CBMC/contracts/Examples/Notes
#guard_msgsexpected outputs inAbstractToConcreteTreeTranslatorTest.leanwill need updating after the build since the formatter now emitsopaquein the outputissue-924-contract-and-proof-passbranch