0

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,

  1. Is there an API that would let me do the above?
  2. Would query2 be faster than the loop in query1 above?
Ranjit Jhala
  • 1,242
  • 8
  • 18

1 Answers1

1

Somewhat confusing: this is not a real max-sat problem. It is computing the largest set of implied literals. It is similar to computing a set of implied equalities, e.g, what are the literals that are equal to "true". We do a little tuning for this in the get-implied-equalities feature and paper with Josh. Generally, there are specialized methods for SAT that use filtering (sat sweeping) to remove candidates before doing full checks.

Your "query2" should really have been something like this:

   def query2(P, Qs):
       while True:
           F = And(P, Or[Not(Q) for Q in Qs])
           if sat == CheckSAT(F):                  
              Qs = [Q for Q in Qs if is_false(model.eval(Q)) ] 
           else:
              return Qs
Nikolaj Bjorner
  • 8,229
  • 14
  • 15