Esempio n. 1
0
 def _exit(self):
     self._send_command(SmtLibCommand(smtcmd.EXIT, []))
     self.solver_stdin.close()
     self.solver_stdout.close()
     self.solver.stderr.close()
     self.solver.terminate()
     return
Esempio n. 2
0
 def add_assertion(self, formula, named=None):
     # This is needed because Z3 (and possibly other solvers) incorrectly
     # recognize N * M * x as a non-linear term
     formula = formula.simplify()
     deps = formula.get_free_variables()
     for d in deps:
         if d not in self.declared_vars:
             self._declare_variable(d)
     self._send_silent_command(SmtLibCommand(smtcmd.ASSERT, [formula]))
Esempio n. 3
0
 def solve(self, assumptions=None):
     assert assumptions is None
     self._send_command(SmtLibCommand(smtcmd.CHECK_SAT, []))
     ans = self._get_answer()
     if ans == "sat":
         return True
     elif ans == "unsat":
         return False
     elif ans == "unknown":
         raise SolverReturnedUnknownResultError
     else:
         raise UnknownSolverAnswerError("Solver returned: " + ans)
Esempio n. 4
0
 def get_value(self, item):
     self._send_command(SmtLibCommand(smtcmd.GET_VALUE, [item]))
     lst = self._get_value_answer()
     assert len(lst) == 1
     assert len(lst[0]) == 2
     return lst[0][1]
Esempio n. 5
0
 def pop(self, levels=1):
     self._send_silent_command(SmtLibCommand(smtcmd.POP, [levels]))
Esempio n. 6
0
 def push(self, levels=1):
     self._send_silent_command(SmtLibCommand(smtcmd.PUSH, [levels]))
Esempio n. 7
0
 def reset_assertions(self):
     self._send_silent_command(SmtLibCommand(smtcmd.RESET_ASSERTIONS, []))
     return
Esempio n. 8
0
 def _declare_variable(self, symbol):
     cmd = SmtLibCommand(smtcmd.DECLARE_FUN, [symbol])
     self._send_silent_command(cmd)
     self.declared_vars.add(symbol)
Esempio n. 9
0
 def set_logic(self, logic):
     self._send_silent_command(SmtLibCommand(smtcmd.SET_LOGIC, [logic]))
Esempio n. 10
0
 def set_option(self, name, value):
     self._send_silent_command(
         SmtLibCommand(smtcmd.SET_OPTION, [name, value]))