Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing deepcopy in wp.py #8

Open
bensturgis opened this issue Jul 30, 2022 · 2 comments
Open

Missing deepcopy in wp.py #8

bensturgis opened this issue Jul 30, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@bensturgis
Copy link

In the method apply of the class ExpectationTransformer of the module wp, a deepcopy is missing in line 276 around expectation. Without this deepcopy, in the subsequent substitution, changes to one occurrence of this expectation are also applied to the other occurrences.
For example, the following code produces the output (5 + 2) + (5 + 2) instead of (5 + 2) + (4 + 2).

v = VarExpr('v')
a = SubstExpr({'x': NatLitExpr(5)}, v)
b = SubstExpr({'x': NatLitExpr(4)}, v)
e = BinopExpr(Binop.PLUS, a, b)
wt = WeightingTransformer('v', e)
print(wt.apply(BinopExpr(Binop.PLUS, VarExpr('x'), NatLitExpr(2))))
@Philipp15b
Copy link
Owner

WeightingTransformer is not a part of probably. Could you provide a minimal working example that works only with probably APIs? Thanks!

@bensturgis
Copy link
Author

Sorry, I meant ExpectationTransformer. A working example is given by

v = VarExpr('v')
a = SubstExpr({'x': NatLitExpr(5)}, v)
b = SubstExpr({'x': NatLitExpr(4)}, v)
e = BinopExpr(Binop.PLUS, a, b)
wt = ExpectationTransformer('v', e)
print(wt.apply(BinopExpr(Binop.PLUS, VarExpr('x'), NatLitExpr(2))))

which produces the output (5 + 2) + (5 + 2) instead of (5 + 2) + (4 + 2).

@Philipp15b Philipp15b added the bug Something isn't working label Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants