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

Optimize expr_safe_replace for quantifiers when all source patterns are vars #7481

Merged
merged 3 commits into from
Dec 19, 2024

Conversation

nunoplopes
Copy link
Collaborator

I get > 40% speedups in some benchmarks with this patch.

Alive2 calls var_subst to replace var:0 with something else. But if this falls in the has_quantifier(n) case, it calls expr_safe_replace.
This patch adds a fast path for when all the source exprs are variables by using var_subst, which is much faster than expr_sage_replace (it has multiple fast paths).

@NikolajBjorner could you please check the sanity of this patch? 🙏

@NikolajBjorner
Copy link
Contributor

z3-test var_subst fails. Can you check what is going on?

@nunoplopes
Copy link
Collaborator Author

z3-test var_subst fails. Can you check what is going on?

fixed! (it was using the inverse var order)

@NikolajBjorner NikolajBjorner merged commit e4ab294 into Z3Prover:master Dec 19, 2024
8 checks passed
@nunoplopes nunoplopes deleted the expr_replace_var branch December 19, 2024 23:48
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