feat(laurel): short-circuit AndThen/OrElse, eager And/Or, forLoop, javaGen improvements#590
Conversation
|
Curious what made you decide to support generating based on the preloaded Laurel grammar - a nice addition btw. |
keyboardDrummer
left a comment
There was a problem hiding this comment.
To prevent accidental unsoundness due to Laurel consumers misinterpreting the meaning of And/Or/Implies, please rename them to make the laziness clear, and please add tests to confirm the laziness. To do the equivalent of an assert false in the assert false branches, you can call a function with requires false as a precondition.
64c1724 to
c39a7af
Compare
|
The preloading of Laurel in |
fa1bf01 to
306194c
Compare
3895a30 to
a95df0a
Compare
- Translate And, Or, Implies to short-circuit ite expressions in LaurelToCoreTranslator instead of non-short-circuit boolean ops - javaGen now accepts a dialect name (e.g. Laurel) in addition to a file path, with a helpful error when neither resolves - Add integration test for javaGen with preloaded dialects, with proper cleanup on all exit paths and failure on missing files - Add comments documenting why Laurel pipeline commands use z3
…, forLoop, tests - Add AndThen/OrElse operations (short-circuit via ite in Core) - Keep And/Or as eager (boolAndOp/boolOrOp), expose with & / | syntax - Grammar: && / || map to AndThen/OrElse, & / | map to And/Or - Add forLoop grammar op, desugars to Block[init, While(cond, inv, Block[body, step])] - Add short-circuit laziness tests (requires false, division by zero) - Add for loop test - Deduplicate solver config (laurelVerifyOptions) - Touch LaurelGrammar.lean to trigger grammar rebuild
On Windows, z3 outputs 'unsat\r\n'. String.extract produces a Substring, and trimAscii returns a Slice that doesn't match string literals in pattern matching. Adding .toString converts it to a String first.
a95df0a to
83169fe
Compare
Add DesugarShortCircuit pass that rewrites AndThen/OrElse/Implies to IfThenElse when the second operand contains imperative calls. Called from the translate pipeline before LiftImperativeExpressions. Pure operands pass through unchanged and are handled by the Core translator. Tests cover both pure and imperative paths for all three operators.
83169fe to
a88f294
Compare
Interesting! Thanks |
keyboardDrummer
left a comment
There was a problem hiding this comment.
Looks great, thanks
Changes
Short-circuit and eager boolean operators
AndThen/OrElseoperations (short-circuit viaitein Core)And/Oras eager (boolAndOp/boolOrOp)&&/||map toAndThen/OrElse,&/|map toAnd/OrImpliesuses short-circuit (ite a b true)AndThen/OrElse/ImpliestoIfThenElsebefore expression lifting when the second operand contains imperative calls, preserving short-circuit semanticsrequires false, division by zero) and imperative path (procedure withrequires false) for all three operatorsFor loop
forLoopgrammar op:for(init; cond; step) invariants bodyBlock[init, While(cond, invariants, Block[body, step])]in ConcreteToAbstractTreeTranslatorjavaGen CLI improvements
Laurel) in addition to a file pathSolver config
laurelVerifyOptionsto deduplicate z3 solver config across Laurel commandsWindows fix
\r\nline endingsparseVerdictnow calls.trimAscii.toString(regression from feat: Implement two-sided verification check with check modes #487 which dropped the.toString)