Notes: Satisfiability Modulo Theories (SMT)

SAT: Satisfiability for Propositional Logic

Input: For boolean variables x1,x2,,xnx_1, x_2,\cdots, x_n, the Clasual Normal Form(CNF) of a clause:

(x1¬x2)(x2x3)¬x4(x_1 \vee \neg x_2)\wedge (x_2 \vee x_3) \wedge \neg x_4

Terms

Assignment:

lν={ν(xi)if l=xi1ν(xi)if l=¬xiων=max{lν  lω}ϕν=min{ων  ωϕ}\begin{align}
l^\nu &= \begin{cases}\nu(x_i) & \textrm{if } l = x_i\\ 1 - \nu(x_i) & \textrm{if } l = \neg x_i\end{cases} \\
\omega^\nu &= \max\{l^\nu\ |\ l\in\omega\} \\
\phi^\nu &= \min\{\omega^\nu\ |\ \omega \in \phi\}
\end{align}

Output: if the clause is satisfiable.

DPLL algorithm

Alternate between propagations (assign values to atoms whose value is forced) and decisions (choose an arbitrary value for an unassigned atom)

Example

for clause

(x1x2)(x3x4)¬x2(x_1 \vee x_2)\wedge (x_3 \vee x_4) \wedge \neg x_2
  1. Propagate: x2x_2 has to be 00
  2. Propagate: x11x_1\gets 1
  3. Decide: x31x_3\gets 1

Clause is SAT

Satisfiability Modulo Theories

"Reasoning about theories"

Replace boolean variable with propositions within theories, e.g. linear integer arithmetics(LIA), string theory

(a+1>0a+b>0)(a<0a+b>4)¬(a+b>0)(a + 1 > 0 \vee a + b > 0) \wedge (a < 0 \vee a + b > 4) \wedge \neg (a + b > 0)

DPLL(T)

Incorporate theory solver with SAT solver.

  1. Map variables to clauses:

    ϕ=(x1x2)(x3x4)¬x2, where{x1a+1>0x2a+b>0x3a<0x4a+b>4\phi = (x_1\vee x_2)\wedge(x_3 \vee x_4)\wedge\neg x_2, \\
    \textrm{ where}
    \begin{cases}
    x_1 \Lrarr a + 1 > 0\\x_2\Lrarr a + b > 0\\x_3\Lrarr a < 0\\x_4\Lrarr a + b > 4
    \end{cases}
    
  2. Invoke SAT solver

    1. Propagate: x20x_2 \gets 0
    2. Propagate: x11x_1\gets 1
    3. Decide: x31x_3\gets 1
  3. Invoke theory (LIA) solver on:

    {a+1>0¬(a+b>0)a<0\begin{cases}
    a + 1 > 0\\
    \neg(a + b > 0)\\
    a < 0
    \end{cases}
    

    x1x_1 and x3x_3 are LIA-unsatisfiable

  4. add (¬x1¬x3)(\neg x_1 \vee \neg x_3) to clauses, Backtrack to last decision

    1. Propagate: x30x_3\gets 0
    2. Propagate: x41x_4\gets 1
  5. Invoke LIA solver on:

    {a+1>0¬(a+b>0)¬(a<0)a+b>4\begin{cases}
    a + 1 > 0\\
    \neg(a + b > 0)\\
    \neg(a < 0)\\
    a + b > 4
    \end{cases}
    

    ¬x2\neg x_2 and x4x_4 are LIA-unsatisfiable

  6. add (x2¬x4)(x_2 \vee \neg x_4) to clauses, no decision to backtrack, SMT is UNSAT.

Conflict Driven Clause Learning (CDCL)

Unit Propagation: If a clause is unit, then its sole unassigned literal must be assigned value 1 for the clause to be satisfied.

Terms

Each variable is characterized by a number of properties:

Example

ϕ=ω1ω2ω3=(x1¬x4)(x1x3)(¬x3x2x4)\begin{align*}
\phi &= \omega_1\wedge \omega_2 \wedge \omega_3\\
&= (x_1 \vee \neg x_4)\wedge (x_1\vee x_3)\wedge (\neg x_3 \vee x_2 \vee x_4)
\end{align*}
  1. Decide: x40x_4 \larr 0, decision level δ(x4)=1\delta(x_4) = 1, Noted as x4=0@1x_4 = 0 @ 1.
  2. Decide: x1=0@2x_1 = 0@2.
    1. Propagate: x3=1@2x_3 = 1@2, α(x3)=ω2\alpha(x_3) = \omega_2
    2. Propagate: x2=1@2x_2 = 1@2, α(x2)=ω3\alpha(x_2) = \omega_3

Implication Graph[1]

I=(VI,EI)I = (V_I, E_I)

Algorithm

Algorithm CDCL(φ, ν):
    if (UnitPropagation(φ, ν) = CONFLICT):
        return UNSAT
    dl ← 0                                      # Decision level

    while (¬AllVariablesAssigned(φ, ν)):
        (x, v) = PickBranchingVariable(φ, ν)    # Decide stage
        dl ← dl + 1                             # Increment decision level
                                                # due to new decision
        ν ← ν ∪ {(x, v)}
        if (UnitPropagation(φ, ν) = CONFLICT):  # Deduce stage
            β ← ConflictAnalysis(φ, ν)          # Diagnose stage
            if (β < 0)
                return UNSAT
            else
                Backtrack(φ, ν, β)
                dl ← β                          # Decrement due to backtracking
    return SAT

Learning clauses from conflicts

Notations

ωLd,i={α(κ)if i=0ωLd,i1α(l)if i0ξ(ωLd,i1,l,d)=1ωLd,i1if i0lξ(ωLd,i1,l,d)=0\omega_L^{d, i} = \begin{cases}
\alpha(\kappa) & \textrm{if } i = 0\\
\omega_L^{d, i - 1} \odot \alpha(l) & \textrm{if } i \neq 0 \wedge \xi (\omega_L^{d, i - 1}, l, d) = 1\\
\omega_L^{d, i - 1} & \textrm{if } i \neq 0 \wedge \forall_l \xi (\omega_L^{d, i - 1}, l, d) = 0\\
\end{cases}
ϕ1=ω1ω2ω3ω4ω5ω6=(x1¬x3)(x1¬x3)(x2x3x4)(¬x4¬x5)(x21¬x4¬x6)(x5x6)\begin{align*}
\phi_1 &= \omega_1 \wedge \omega_2 \wedge \omega_3 \wedge \omega_4  \wedge \omega_5 \wedge \omega_6\\
&= (x_1 \vee \neg x_3) \wedge (x_1 \vee  \neg x_3) \wedge (x_2 \vee x_3 \vee x_4) \wedge (\neg x_4 \vee \neg x_5) \wedge (x_{21} \vee \neg x_4 \vee \neg x_6) \wedge (x_5 \vee x_6)
\end{align*}
Screenshot 2024-07-18 at 23.50.06

Resolution Steps

  1. ωL5,0=α(κ)=ω6={x5,x6}\omega_L^{5, 0} = \alpha(\kappa) = \omega_6 = \{x_5, x_6\}

  2. ωL5,1=ωL5,0α(x5)=ωL5,0ω4={¬x4,x6}\omega_L^{5, 1} = \omega_L^{5, 0} \odot \alpha(x_5) = \omega_L^{5, 0}\odot \omega_4 = \{\neg x_4, x_6\}

  3. ωL5,2=ωL5,1α(x6)=ωL5,1ω5={¬x4,x21}\omega_L^{5, 2} = \omega_L^{5, 1} \odot \alpha(x_6) = \omega_L^{5, 1}\odot \omega_5 = \{\neg x_4, x_{21}\}

  4. ωL5,3=ωL5,2α(x4)=ωL5,2ω3={x2,x3,x21}\omega_L^{5, 3} = \omega_L^{5, 2} \odot \alpha(x_4) = \omega_L^{5, 2}\odot \omega_3 = \{x_2, x_3, x_{21}\}

  5. repeat until a fixed point occurs: ωL5,6={x1,x31,x21}\omega_L^{5, 6} = \{x_1, x_{31}, x_{21}\}

  6. the learned clause is ωL5=(x1x31x21)\omega_L^5 = (x_1\vee x_{31} \vee x_{21})

Unit Implication Points [1]

A vertex uu dominates another vertex xx in a directed graph if every path from xx to another vertex κ\kappa contains uu[2]. In the implication graph, a UIP uu dominates the decision vertex xx with respect to the conflict vertex κ\kappa.

ωLd,i={α(κ)if i=0ωLd,i1α(l)if i0ξ(ωLd,i1,l,d)=1ωLd,i1if i0σ(ωLd,i1,d)=1\omega_L^{d, i} = \begin{cases}
\alpha(\kappa) & \textrm{if } i = 0\\
\omega_L^{d, i - 1} \odot \alpha(l) & \textrm{if } i \neq 0 \wedge \xi (\omega_L^{d, i - 1}, l, d) = 1\\
\omega_L^{d, i - 1} & \textrm{if } i \neq 0 \wedge \sigma (\omega_L^{d, i - 1}, d) = 1\\
\end{cases}

Other Clause Learning Algorithms

GRASP[1]

Apart from conflict analysis, these solvers include lazy data structures, search restarts, conflict-driven branching heuristics and clause deletion strategies.

Nelson-Oppen Theory Combination

SMT with multiple theories

f(f(x)f(y))=af(0)>a+2x=yf(f(x) - f(y)) = a\\
f(0) > a + 2\\
x = y

belongs to Linear Real Arithmetics(LRA) and Uninterpreted Functions(UF)

  1. purify literals, each literal should belong to a single theory

    1. f(f(x)f(y))=af(f(x) - f(y)) = a
      • f(e1)=a,e1=f(x)f(y)f(e_1) = a, e_1 = f(x) - f(y)
      • f(e1)=a,e1=e2e3,e2=f(x),e3=f(y)f(e_1) = a, e_1 = e_2 - e_3, e_2 = f(x), e_3 = f(y)
    2. f(0)>a+2f(0) > a + 2
      • f(e4)=e5,e4=0,e5>a+2f(e_4) = e_5, e_4 = 0, e_5 > a + 2
    3. x=yx = y
    UF LRA
    f(e1)=af(e_1) = a e1=e2e3e_1 = e_2 - e_3
    f(x)=e2f(x) = e_2 e4=0e_4 = 0
    f(y)=e3f(y) = e_3 e5>a+2e_5 > a + 2
    f(e4)=e5f(e_4) = e_5
    x=yx = y
  2. Exchange entailed interface equalities, equalities over shared constants e1,e2,e3,e4,e5,ae_1, e_2, e_3, e_4, e_5, a

    x=y,f(x)=f(y)e2=e3x = y, f(x) = f(y)\Rarr e_2 = e_3

    e2=e3,e1=e2e3,e4=0e1=e4e_2 = e_3, e_1 = e_2 - e_3, e_4 = 0 \Rarr e_1 = e_4

    e1=e4,f(e1)=f(e4)a=e5e_1 = e_4, f(e_1) = f(e_4)\Rarr a = e_5

    UF LRA
    f(e1)=af(e_1) = a e1=e2e3e_1 = e_2 - e_3
    f(x)=e2f(x) = e_2 e4=0e_4 = 0
    f(y)=e3f(y) = e_3 e5>a+2e_5 > a + 2
    f(e4)=e5f(e_4) = e_5 e2=e3e_2 = e_3
    x=yx = y a=e5a = e_5
    e1=e4e_1 = e_4

Nelson-Oppen (non-deterministic, non-incremental)

Notations:

Input: L1L2L_1 \cup L_2

Output: SAT or UNSAT

  1. Guess an arrangement AA, i.e., a set of equalities and disequalities over CC such that:
c,dC(c=dAcdA)\forall c, d\in C (c = d\in A \vee c\neq d \in A)
  1. If LiAL_i\cup A is TiT_i-UNSAT for i{1,2}i \in \{1, 2\}, return UNSAT
  2. return SAT

The algorithm is terminating, sound and complete under certain conditions(Σ1Σ2=T1,T2\Sigma_1\cap \Sigma_2 = \varnothing\wedge T_1, T_2 are stably infinite)

References

[1] J. P. Marques-Silva and K. A. Sakallah. GRASP: A new search algorithm for satisfiability. In International Conference on Computer-Aided Design, pages 220–227, November 1996.

[2] R. E. Tarjan. Finding dominators in directed graphs. SIAM Journal on Computing, 1974.


×