I have a question about the Z3/SMTLib API.
The key SMT subroutine required by the liquid-types tools is the following query:
INPUT: A "background" formula P
, A list of "goal" formulas Qs = [Q1,...,Qn]
OUTPUT: Largest Qs' \subset Qs s.t. forall Q in Qs', P => Q.
Currently, we compute this in the obvious fashion:
def query1(P, Qs):
Qs' := []
ASSERT(P)
for Q in Qs:
PUSH()
ASSERT (not Q)
if CHECKUNSAT():
Qs'.add(Q)
POP()
return Qs'
My question: is there some faster way to do via MaxSAT?
def query2(P, Qs):
F = (Hard P) /\ ((Soft ~Q1) \/ ... \/ (Soft ~QN))
Rs = MaxSat(F)
Qs' = Qs - Rs
return Qs'
That is Hard
means you must satisfy P
and Soft
means that maximize the number of ~Qi
that can also
be satisfied. Specifically,
- Is there an API that would let me do the above?
- Would
query2
be faster than the loop inquery1
above?