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

Fix else transformation to use all old variables #26

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

rtjoa
Copy link
Contributor

@rtjoa rtjoa commented Jul 17, 2024

Consider the following program:

x = 0
c = 1
while c == 1:
    if c == 1:
        x = x + 1
        c = Bernoulli(1/2)
    else:
        x = x + 1
    end
end

The else branch should be dead code. However, its inclusion causes the analysis to change from E(x) = 0; 2 - 2/2**n to the incorrect result E(x) = 0; 3 - 3/2**n. This happens because the else transformation does not replace c with the variable storing its old value in the transformed else condition !(c == 1).

This PR makes the appropriate fix and adds the above example as a regression test.

@mmsbrggr
Copy link
Contributor

Hey Ryan. Thanks for your contribution. Great catch!

@mmsbrggr mmsbrggr merged commit a4808e3 into probing-lab:master Jul 18, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants