Support Any type, Operations, and Kwargs handling for Python->Laurel#489
Support Any type, Operations, and Kwargs handling for Python->Laurel#489thanhnguyen-aws wants to merge 42 commits intomainfrom
Conversation
|
I asked Thanh to create this branch to replace #457 since I can't push to his fork |
|
Exciting stuff. Is the Any encoding is used for all values now? What happened to using the statically provided Python types to optimize away the Any? |
We plan to improve the partial evaluator to reduce them as much as possible. (Initial experiments suggested a 4% slowdown with this approach, which I think is worth the reduced soundness risk) |
Until you do that, would this change mean you're able to prove less since the verification condition become more complex?
A 4% slowdown of the compilation when the partial evaluator is able to do the optimization? Are there cases where the partial evaluator won't be able to do the optimization and verification results change? |
… Python->Laurel->Core with main
808e334 to
bc2d178
Compare
| } | ||
|
|
||
|
|
||
| inline function PMul (v1: Any, v2: Any) : Any |
There was a problem hiding this comment.
There are a bunch of bugs here from copying PAdd. E.g.,
(Any..isfrom_string(v1) && Any..isfrom_string(v2)) does concat.
from_float(int_to_real(Any..as_int(v1)) + Any..as_float(v2))
uses + instead of *
There was a problem hiding this comment.
I fixed them
| let mut translatedArgs ← finalArgs.mapM (translateExpr ctx) | ||
|
|
||
| -- Check if function has a model | ||
| if !hasModel ctx funcName then |
There was a problem hiding this comment.
We want to keep this.
There was a problem hiding this comment.
I added it back
| | .FloorDiv _ => .ok Operation.Div -- Python // maps to Laurel Div | ||
| | .Mod _ => .ok Operation.Mod | ||
| | .Div _ => .ok Operation.Div -- Python / (true division) | ||
| | .BitAnd _ => .ok Operation.And -- Bitwise & - abstract as logical And |
There was a problem hiding this comment.
We probably want to keep these
There was a problem hiding this comment.
I added it back
| | .LtE _ => .ok Operation.Leq | ||
| | .Gt _ => .ok Operation.Gt | ||
| | .GtE _ => .ok Operation.Geq | ||
| | .In _ => return mkStmtExprMd .Hole -- Abstract: arbitrary bool (sound) |
There was a problem hiding this comment.
We also want to keep these
There was a problem hiding this comment.
I added it back
Yes |
This was timing from Core -> SMT (including solver time). |
StrataTest/Languages/Python/expected_laurel/test_function_def_calls.expected
Show resolved
Hide resolved
There was a problem hiding this comment.
I'd like to request comments (similar to docString style) in the prelude code below, especially since this is hand-written and has to be maintained manually, and as such, should be held to the same high standard as Lean code in this repo.
There was a problem hiding this comment.
Preferably, please link to relevant Python documentation in these comments that justifies the design choices that were made.
There was a problem hiding this comment.
Also, please divide the file into sections, with descriptions of what constructs/operations.. etc. are being handled in each section.
There was a problem hiding this comment.
I added the documents into the prelude.
StrataTest/Languages/Python/expected_laurel/test_precondition_verification.expected
Outdated
Show resolved
Hide resolved
| if (Any..isfrom_string(v)) then !(Any..as_string!(v) == "") else | ||
| if (Any..isfrom_int(v)) then !(Any..as_int!(v) == 0) else | ||
| false | ||
| //WILL BE ADDED |
There was a problem hiding this comment.
Is this another instance of false being a placeholder value?
There was a problem hiding this comment.
This function is guarded by the requires clause, so in case v is not one of the 4 types, it will returns false, but the assertion of this function will fail.
Description of changes:
This PR Any type, Operations, and Kwargs handling for Python->Laurel:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.