Skip to content

Fixed UP expression registration #7656

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

Closed
wants to merge 2 commits into from

Conversation

CEisenhofer
Copy link
Collaborator

No description provided.

enode* n = ensure_enode ? this->ensure_enode(e) : ctx.get_enode(e);
ctx.get_rewriter()(term, r);
TRACE("user_propagate", tout << "add " << mk_bounded_pp(term, m) << "\n");
enode* n = ensure_enode ? this->ensure_enode(r) : ctx.get_enode(r);
Copy link
Contributor

@NikolajBjorner NikolajBjorner May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if r is a quantified formula?
It is only possible to create E-nodes with quantifier-free formulas.
The deleted code will take care of this.
Seems you want the deleted code when there are quantifiers.
And for that matter the old code seems also incorrect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a general problem with registering new terms (in addition to the fact that the raw pointer is stored; I just copied some part from my fork):

Asserting "aux-expr = r" for some fresh constant "aux-expr" introduces a problem: if someone registers the same ast multiple times, they get a new constant every time.
So registering, e.g., ast/expr "A & B" several times (as it might have been forgotten upon backtracking), and using that expression as a justification is not possible, as Z3 will internally refer to a different Boolean variable for "A & B" every time. Also, Z3 might eventually forget the "aux-expr = r" lemma on backtracking, such that the relation between "aux-expr" and "r" is forgotten. Registering it again does not work, as Z3 would just introduce a fresh aux-expr in that case.

My (for sure not optimal) solution I used so far in my fork is to return the rewritten ast, rather than introducing an auxiliary term (admittedly, I did not think of quantifiers, in which case this solution does not work) and received callbacks/gave justifications in term of the returned ast, rather than the passed one.
Do you have an idea how to solve this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, this part is fixable by caching, and for ground expressions by using e_internalized.

@CEisenhofer CEisenhofer marked this pull request as draft May 20, 2025 13:46
@CEisenhofer CEisenhofer marked this pull request as ready for review May 20, 2025 13:58
@NikolajBjorner
Copy link
Contributor

with the updates, the new code is equivalent to the old code

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