Add opaque keyword to Laurel grammar#940
Add opaque keyword to Laurel grammar#940keyboardDrummer-bot wants to merge 5 commits intoissue-924-contract-and-proof-passfrom
opaque keyword to Laurel grammar#940Conversation
- Add 'opaque' keyword to the Laurel grammar (.st file) - Ensures and modifies clauses are now syntactically only allowed after 'opaque' - Update ConcreteToAbstractTreeTranslator to parse the new grammar structure - Update AbstractToConcreteTreeTranslator to emit 'opaque' for opaque bodies - Update all Laurel test files to mark procedures as opaque - Update expected test outputs to reflect the new formatting
- Fix opaqueBlock body precedence in grammar (body -> body:0) to prevent the formatter from wrapping the body in parentheses - Add missing opaque keyword to procedures with ensures clauses in PythonRuntimeLaurelPart.lean - Fix error annotation positions in DuplicateNameTests.lean to account for the opaque keyword shifting line positions
|
I investigated the CI failures and pushed a fix in 7701a22. Three issues were found and resolved: 1. Build failure: missing
|
…suffix The proof pass creates both a function copy and a proof copy (with $proof suffix) for every procedure. However, calls inside proof bodies still referenced the original procedure names, causing 'Procedure X not found in program' errors during call elimination — the Core program only has the $proof-suffixed procedures, not the originals. Fix: rename StaticCall callees inside proof copies that refer to non-functional procedures so they point at the $proof copy. Also revert test files that had unnecessary standalone 'opaque' keywords added (procedures without ensures/modifies don't need opaque, and making them opaque hides their implementations from callers, breaking verification).
|
I investigated the CI failures and pushed a fix in 5ef63e4. Root causeThe proof pass ( Fix
Test files: Reverted unnecessary standalone Remaining failures5 Laurel test failures remain, but these are pre-existing on the base branch (they were already failing in CI before this PR):
These are caused by the |
…onsErrors tests These tests had ensures clauses without the opaque keyword, causing parse errors with the new grammar. The tests still have pre-existing failures unrelated to this PR (same as on the base branch).
|
I investigated the CI failure on the Fix pushed: Two test files ( Remaining failures are all pre-existing on the base branch ( The 7 remaining failures (all also failing on the base branch):
None of these failures are introduced by this PR. |
|
I investigated the CI failure in "Build and test Lean (stable)". Here's what I found: Root cause: The
Fix (46c9ae9):
Pre-existing failures (also fail on the base branch
All of these fail identically on the base branch and are unrelated to this PR. |
|
I investigated the CI failure on the All 6 failing tests are pre-existing failures on the base branch ( I verified this by building and running the failing tests on both the base branch and this PR branch locally. The failures are identical:
|
Summary
Introduces an explicit
opaquekeyword in the Laurel grammar. An opaque procedure now looks like:ensuresandmodifiesclauses are syntactically only allowed after theopaquekeyword:Changes
Grammar (
LaurelGrammar.st)OpaqueBlockcategory containingopaquekeyword followed by optionalensures,modifies, andbodyOption OpaqueBlock+Option Bodyinstead of separateensures/modifies/bodyParser (
ConcreteToAbstractTreeTranslator.lean)parseProcedureto handle the new 8-argument grammar structure (was 9)OpaqueBlockto extract ensures, modifies, and opaque bodyFormatter (
AbstractToConcreteTreeTranslator.lean)procedureToOpto emitopaqueBlockforBody.OpaqueandBody.AbstractbodiesopaqueTests
opaqueNotes
lake buildsucceedsRequested by @keyboardDrummer in PR #927.