10.07.2015 Views

SIMPLY: a Compiler from a CSP Modeling Language to the SMT-LIB ...

SIMPLY: a Compiler from a CSP Modeling Language to the SMT-LIB ...

SIMPLY: a Compiler from a CSP Modeling Language to the SMT-LIB ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

idea is making <strong>the</strong> DPLL(X) engine and Solver Twork in cooperation: while<strong>the</strong> DPLL(X) engine is in charge of enumerating (partial) propositional models,Solver Tis responsible for checking whe<strong>the</strong>r <strong>the</strong>se models are consistent with <strong>the</strong>given <strong>the</strong>ory T (for example, if T is <strong>the</strong> <strong>the</strong>ory of Linear Integer Arithmetic and<strong>the</strong> current boolean model contains x + 2y ≤ 0, −y − z ≤ 0 and x − 2z > 1, <strong>the</strong>nSolver Thas <strong>to</strong> detect that <strong>the</strong> current boolean assignment is T -inconsistent).Notice that Solver Tonly needs <strong>to</strong> handle conjunctions of literals <strong>from</strong> <strong>the</strong>ory T .In this way, given a formula F and a <strong>the</strong>ory T , we are determining whe<strong>the</strong>r <strong>the</strong>reis a model of T ∪ {F }.Current <strong>SMT</strong> solvers can deal with several <strong>the</strong>ories and logics. For <strong>the</strong> purposesof our <strong>to</strong>ol, as we explain in Section 3, <strong>the</strong>re are two logics which are especiallyrelevant, namely, quantifier free Integer Linear Arithmetic (QF LIA) andits fragment Integer Difference Logic (QF IDL). QF LIA formulas are booleancombinations of inequations between linear polynomials over integer variables.QF IDL formulas are boolean combinations of inequations of <strong>the</strong> form x − y < bwhere x and y are integer variables and b is an integer constant (see [13] fordetails). Such a<strong>to</strong>ms occur in <strong>the</strong> definition of feasible solutions for many problems.For instance, <strong>the</strong>y can be used <strong>to</strong> express constraints on <strong>the</strong> time elapsedbetween pairs of events. Since <strong>the</strong> satisfiability of conjunctions of difference logicliterals can be reduced <strong>to</strong> <strong>the</strong> absence of negative cycles in finite weighted graphs,it can be decided in O(n 3 ) time by <strong>the</strong> Bellman-Ford algorithm. For this reason,many solvers give a special treatment <strong>to</strong> such kind of literals.3 Simply: The <strong>to</strong>olIn this section we describe <strong>the</strong> input language and features of Simply throughan example. Let us consider <strong>the</strong> n-Queens problem: given a number n of queensof <strong>the</strong> chess game, <strong>the</strong> problem is <strong>to</strong> find a position in a board of size n × n,for each queen, such that no queen threatens any o<strong>the</strong>r (i.e., <strong>the</strong>y are not in <strong>the</strong>same column, row or diagonal). A naive model of <strong>the</strong> n-Queens problem (forn = 8) in <strong>the</strong> Simply input language can be found in Fig. 1, with an array q ofn integer variables where q[i], for i in 1..n, denotes <strong>the</strong> row where <strong>the</strong> queenof column i is placed. The problem is solvable iff <strong>the</strong>re exists an assignment forq, according <strong>to</strong> its domain, such that all <strong>the</strong> posted constraints are satisfied, i.e.,all <strong>the</strong> values of q are different (i.e., no two queens are in <strong>the</strong> same row) and <strong>the</strong>distances between <strong>the</strong> indexes (columns) and values (rows) of any two pair ofelements of <strong>the</strong> array are distinct (i.e., no two queens are in <strong>the</strong> same diagonal).In Fig. 2 <strong>the</strong> architecture of Simply is depicted throughout <strong>the</strong> process ofcompiling and solving <strong>the</strong> 8-Queens problem. Let <strong>the</strong> input of <strong>the</strong> compiler be <strong>the</strong>queens 8.y file of Fig. 1. In <strong>the</strong> compilation process all constants are replaced by<strong>the</strong>ir associated value, and all variables are translated in<strong>to</strong> <strong>SMT</strong> integer variables.Constraining a variable <strong>to</strong> its domain results in a disjunction of equalities when<strong>the</strong> domain is an explicit enumeration of values, or in<strong>to</strong> a conjunction of twoinequality predicates when <strong>the</strong> domain is described as a range. The translationof <strong>the</strong> constraints typically results in<strong>to</strong> a conjunction of QF LIA predicates and,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!