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

Constant substitution in CategoricalExprs #10

Open
Legotier opened this issue Jan 22, 2023 · 0 comments
Open

Constant substitution in CategoricalExprs #10

Legotier opened this issue Jan 22, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Legotier
Copy link
Collaborator

Running the program

prog = compile_pgcl("""
    const c := 42
    nat x
    x := c : 1/2 + 2 : 1/2
    x := c
""")
print(prog)

gives the following output:

const c := 42;
nat x;
x := c : 1/2 + 2 : 1/2;
x := 42;

The constant in the categorical expression isn't substituted. This happens because the different subexpressions in a CategoricalExpr aren't stored as top-level attributes (sensible), but in a list of subexpressions with probabilities. This however means that the built-in walk over the expression doesn't yield these subexpressions due to the way children are discovered in mut_expr_children.

I already changed this on the brand-new branch to enable walking over the parameters of a function call. However, the problem with CategoricalExprs persists, as their subexpressions are stored in tuples, which are immutable and thus don't allow for substitution.

@Legotier Legotier added the bug Something isn't working label Jan 22, 2023
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

1 participant