Introduction
Satisfiability Modulo Theories (SMT) extends Boolean satisfiability to include reasoning about theories like linear arithmetic, arrays, and uninterpreted functions. While SAT solvers work with Boolean formulas, SMT solvers can reason about mathematical structures, making them powerful for software verification, hardware verification, and automated reasoning. This article explores SMT solving, theories, and applications.
Historical Context
SMT solving emerged in the early 2000s as an extension of SAT solving. Early SMT solvers like Yices and Z3 combined SAT solving with theory-specific reasoning. Modern SMT solvers are highly optimized and handle complex combinations of theories. They have become essential tools for formal verification, program analysis, and automated reasoning.
Core Concepts
SMT Problem
Definition: Given a formula ฯ over variables and theory-specific operations, determine if ฯ is satisfiable in the theory
Example:
(x > 0) โง (y < 10) โง (x + y = 15)
Is this satisfiable in linear integer arithmetic?
Yes: x = 10, y = 5
Theories
Theory: A set of axioms and inference rules for a domain
Common Theories:
- Linear Arithmetic (LA): Linear inequalities over integers/reals
- Uninterpreted Functions (UF): Functions with no interpretation
- Arrays: Array operations (read, write)
- Bit-vectors: Fixed-width binary numbers
- Strings: String operations
Theory Combination
Problem: Combining multiple theories
Solution: Nelson-Oppen method for combining theories
Linear Arithmetic
Linear Integer Arithmetic (LIA)
Formulas: Linear combinations of variables with integer coefficients
Example:
(2x + 3y โค 10) โง (x - y โฅ 5) โง (x, y โ โค)
Decidability: Decidable (Presburger arithmetic)
Complexity: NP-complete
Linear Real Arithmetic (LRA)
Formulas: Linear combinations over real numbers
Example:
(2.5x + 3.7y โค 10.2) โง (x - y โฅ 5.1) โง (x, y โ โ)
Decidability: Decidable
Complexity: PSPACE-complete
Solving: Simplex algorithm
Uninterpreted Functions
Idea: Functions with no specific interpretation
Example:
f(x) = f(y) โง x โ y
Is this satisfiable?
No: If f(x) = f(y), then x = y (by congruence)
Reasoning: Congruence closure algorithm
Arrays
Operations:
- read(a, i): Read element at index i
- write(a, i, v): Write value v at index i
Example:
a' = write(a, i, v)
read(a', i) = v
read(a', j) = read(a, j) for j โ i
Reasoning: Array theory axioms
Bit-Vectors
Representation: Fixed-width binary numbers
Operations: Bitwise AND, OR, XOR, shifts, arithmetic
Example:
(x & 0xFF) = 0x42
(x >> 8) = 0x00
Application: Hardware verification, cryptography
SMT Solver Architecture
DPLL(T) Framework
Idea: Combine DPLL SAT solver with theory solver
Algorithm:
Algorithm DPLL(T)
1. Use DPLL to search for satisfying assignment
2. For each complete assignment:
a. Check if assignment satisfies theory
b. If yes, return SAT
c. If no, learn theory conflict clause
3. If no satisfying assignment, return UNSAT
Theory Solver
Purpose: Check if assignment satisfies theory
Process:
- Extract theory constraints from assignment
- Check satisfiability in theory
- If unsatisfiable, generate conflict clause
Lazy vs Eager Approaches
Lazy: Check theory only for complete assignments
- Advantage: Simpler
- Disadvantage: May explore many invalid assignments
Eager: Check theory constraints during search
- Advantage: Prunes search space
- Disadvantage: More complex
Practical Example: Program Verification
Program:
x = 5
y = 10
assert(x + y = 15)
Verification:
Formula: (x = 5) โง (y = 10) โง (x + y โ 15)
Is this satisfiable?
No: If x = 5 and y = 10, then x + y = 15
Therefore, assertion always holds
SMT Solvers
Z3
Developer: Microsoft Research Strengths: Powerful, handles many theories, good documentation Weaknesses: Complex, large codebase
Yices
Developer: SRI International Strengths: Fast, handles arithmetic well Weaknesses: Fewer theories than Z3
CVC4/CVC5
Developer: Stanford/Iowa Strengths: Handles many theories, good for combinations Weaknesses: Slower than Z3 on some problems
Boolector
Developer: Johannes Kepler University Strengths: Specialized for bit-vectors and arrays Weaknesses: Limited to specific theories
Applications
Software Verification
Application: Verify programs satisfy specifications Process: Encode program and property as SMT formula Benefit: Automated verification
Hardware Verification
Application: Verify circuits satisfy specifications Process: Encode circuit and property as SMT formula Benefit: Catches design errors
Automated Testing
Application: Generate test cases Process: Encode program and test requirements as SMT Benefit: Automated test generation
Cryptanalysis
Application: Analyze cryptographic systems Process: Encode cryptographic equations as SMT Benefit: Automated security analysis
Glossary
Congruence Closure: Algorithm for uninterpreted functions DPLL(T): Framework combining DPLL with theory solver Lazy Approach: Check theory only for complete assignments Nelson-Oppen: Method for combining theories SMT: Satisfiability modulo theories Theory: Set of axioms and inference rules Theory Solver: Component checking theory satisfiability Uninterpreted Function: Function with no specific interpretation
Practice Problems
Problem 1: Determine if (x > 5) โง (x < 3) is satisfiable in linear arithmetic.
Solution: No, this is unsatisfiable. No value of x can be both greater than 5 and less than 3.
Problem 2: Determine if f(x) = f(y) โง g(x) โ g(y) is satisfiable with uninterpreted functions.
Solution: Yes, this is satisfiable. For example, f could be a constant function (f(x) = f(y) for all x, y) while g could be the identity function (g(x) โ g(y) when x โ y).
Problem 3: Verify the program: x := 5; y := x + 3; assert(y = 8).
Solution: Formula: (x = 5) โง (y = x + 3) โง (y โ 8) Substituting: (x = 5) โง (y = 8) โง (y โ 8) is unsatisfiable. Therefore, assertion always holds.
Related Resources
- SMT Solvers: https://en.wikipedia.org/wiki/Satisfiability_modulo_theories
- Z3: https://github.com/Z3Prover/z3
- Yices: https://yices.csl.sri.com/
- CVC5: https://cvc5.github.io/
- Boolector: https://boolector.github.io/
- DPLL(T): https://en.wikipedia.org/wiki/DPLL_algorithm
- Linear Arithmetic: https://en.wikipedia.org/wiki/Presburger_arithmetic
- Uninterpreted Functions: https://en.wikipedia.org/wiki/Uninterpreted_function
- Array Theory: https://en.wikipedia.org/wiki/Array_theory
- Bit-Vectors: https://en.wikipedia.org/wiki/Bit_vector
- Formal Verification: https://en.wikipedia.org/wiki/Formal_verification
- Program Verification: https://en.wikipedia.org/wiki/Program_verification
- Automated Reasoning: https://en.wikipedia.org/wiki/Automated_reasoning
- SAT Solvers: https://en.wikipedia.org/wiki/SAT_solver
- Constraint Solving: https://en.wikipedia.org/wiki/Constraint_satisfaction_problem
Conclusion
Satisfiability modulo theories extends SAT solving to handle reasoning about mathematical structures and theories. By combining SAT solving with theory-specific reasoning, SMT solvers provide powerful tools for automated verification and reasoning.
Understanding SMT is essential for anyone working in formal verification, program analysis, or automated reasoning. As systems become more complex, the ability to reason about theories beyond Boolean logic becomes increasingly important.
Comments