Optimizing an smt query about partial orders #6173
-
I asked this question on Stace Overflow, but then I realized this venue existed and so I am cross posting it here because I'm not sure if everyone here would see it there. I am working on trying to do type inference in Z3 for a compiler and the compiler generates a Z3 query over a fully defined partial order, and then attempts to find the maximal type for all the variables such that a fixed set of constraints is satisfied. The query looks something like this:
This is a smaller query and runs fine. The problem is, when the number of sorts and variables and disjunctions in the constraints increases, z3 starts to take a significant amount of time to solve the constraints. Part of this is because the size of the relations is quadratic, and part of this is due to the existential quantifier being used to assert that the solution is maximal. What I am wondering is, are there any specific tactics I could use or ways I could refactor the way the query is generated so queries of this type are faster on complex examples? I can provide a larger query if it would be useful, but it's several hundred kilobytes. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
You are likely better of writing a user-propagator plugin to z3 that encodes the partial order. https://github.com/Z3Prover/z3/tree/master/examples/userPropagator |
Beta Was this translation helpful? Give feedback.
-
I added a tutorial example |
Beta Was this translation helpful? Give feedback.
I added a tutorial example
https://microsoft.github.io/z3guide/docs/Programming%20Z3/Using%20Z3%20from%20Python/User%20Propagator