SMT and MILP Solvers for Verification
Complete verification using SMT and MILP solvers, including encoding theory, QCQP/SDP formulations, and the exponential complexity of ReLU activation patterns.
What you will be able to do
- Encode a ReLU exactly with binary variables and prove the encoding is sound and complete
- State what makes the encoding exponential in the worst case
- Read an SMT or MILP verifier result and know whether it is a proof or a timeout
When you need absolute certainty---definitive answers, no “unknown” results---you need complete verification. SMT (Satisfiability Modulo Theories) and MILP (Mixed-Integer Linear Programming) solvers provide exactly this: they always return either “verified” or a counterexample. These are the workhorses of complete neural network verification, encoding the verification problem as logical constraints or optimization problems that mature solvers can handle.
This guide explores how SMT and MILP solvers work for neural network verification, when to use them, and why they provide the strongest guarantees despite computational costs.
Why Complete Verification Matters
Incomplete methods (bound propagation, abstract interpretation) are fast but sometimes return “unknown.” For safety-critical applications---aviation, medical devices, autonomous vehicles---“unknown” isn’t acceptable. You need definitive answers: either the property holds, or here’s a counterexample proving it doesn’t.
Complete verification guarantees exactly this: given enough time and memory, SMT and MILP solvers will find the answer. The tradeoff is computational cost---these methods have exponential worst-case complexity. But when absolute certainty matters more than speed, complete verification is the right tool.
Complete Verification Guarantee
A complete verification method always returns one of two answers:
- VERIFIED: The property provably holds for all inputs in the specified region
- FALSIFIED: A counterexample exists (and is provided)
Unlike incomplete methods, complete verifiers never return “unknown.” Given sufficient computational resources, they always reach a definitive answer.
SMT-Based Verification
SMT solvers determine satisfiability of logical formulas involving theories beyond pure propositional logic. For neural networks, the relevant theory is linear real arithmetic combined with Boolean logic for modeling ReLU activations.
Encoding Neural Networks as SMT Formulas
A neural network can be encoded as a conjunction of constraints:
Linear layers: For weight matrix , bias , and layer computation :
This is a linear equality constraint, directly expressible in SMT.
ReLU activations: For , we need to capture the piecewise behavior:
This is encoded as a disjunction:
Input constraints: For perturbation ball with radius :
Output property: For robustness, require the true class to score highest:
Complete encoding: Combine all constraints:
The SMT solver searches for a satisfying assignment. If one exists, it’s a counterexample. If none exists (unsatisfiable), the property is verified.
SMT Encoding Strategy: Verification reduces to checking: Is there an input in the allowed region where the property fails?
This is a satisfiability problem: find satisfying input constraints and violating the property. If no such exists (unsatisfiable), the property holds.
Encoding Theory: Why Complete Verification is Exponential
Understanding why complete verification has exponential complexity requires analyzing the formal encoding structure. The fundamental issue is that ReLU networks partition input space into exponentially many linear regions.
Formal SAT/LP Encoding Definition:
For a ReLU network with neurons, the complete encoding requires representing all possible activation patterns---assignments of active/inactive states to each ReLU.
Definition (Activation Pattern): For a network with ReLU neurons , an activation pattern assigns:
Each pattern defines a linear region where the network function is piecewise linear.
Theorem (Exponential Number of Activation Patterns): For a ReLU network with neurons, there are at most distinct activation patterns.
Proof:
Each of ReLU neurons can be in one of 2 states (active or inactive). By the multiplication principle, there are possible combinations.
Why this needs formulas — and where the size actually is:
One natural complete encoding enumerates the activation patterns. For a fixed pattern the network is affine, and the question reduces to an LP over a polyhedron; to be complete over all of them, the encoding has to range over every pattern.
Encoding structure:
For each activation pattern :
The complete formula is the disjunction over all patterns:
Two different costs, which are worth not merging. Writing this out as one formula per pattern and then distributing the disjunction into CNF is what produces the exponential formula: the disjunction over branches converts to a product of clauses and grows like in the worst case. That is a property of this encoding, not of the problem and not of every encoding — the MILP below encodes the same ReLU relation with a polynomial number of constraints.
The exponential search is a separate claim. A solver handed the exponential formula must in the worst case consider exponentially many branches; a solver handed the polynomial MILP encoding faces a search over binary assignments without writing them down. Either way the difficulty comes from the number of activation patterns, so this is where completeness gets expensive.
So the honest summary is: the number of activation patterns is , an enumeration-based encoding is exponential in size, and complete verification of a ReLU network has no polynomial-size exact encoding in this family. What does not follow is that the exponential formula has to be written — that is exactly what the next section avoids.
Connection to Operation Decomposition:
ReLU neurons are unary operations that introduce non-linearity (see operation decomposition). Each ReLU creates a binary choice (active/inactive), leading to regions. The binary operations (affine layers) are exact and don’t contribute to exponential complexity---only the unary ReLU operations do.
MILP Big-M Encoding Theory:
MILP avoids explicit enumeration of patterns by using binary integer variables and big-M constraints.
Encoding: For ReLU neuron with pre-activation and post-activation , introduce binary variable :
where are bounds on (from incomplete methods).
When (active):
Since and , this forces (active ReLU).
When (inactive):
This forces (inactive ReLU).
Theorem (MILP Encoding Correctness): The big-M encoding above exactly captures the ReLU function: for all possible values of .
Proof:
Case analysis on :
- If : ReLU should be active (). Setting satisfies all constraints with .
- If : ReLU should be inactive (). Setting forces .
The encoding is complete (covers all cases) and sound (forces correct ReLU behavior).
Why MILP Avoids Explicit Enumeration:
MILP solvers use branch-and-bound to implicitly explore the space of assignments. Instead of enumerating all patterns upfront, the solver:
- Solves LP relaxation (continuous ) → polynomial time
- Branches on fractional → creates two subproblems (0 and 1)
- Bounds each subproblem using LP relaxation → prunes impossible branches
- Implicit enumeration → only explores promising branches, not all
Worst-case complexity: Still (must explore all branches if LP relaxation is weak).
Average-case: Much better---commercial solvers (Gurobi, CPLEX) use sophisticated heuristics to prune branches early.
Soundness and Completeness Proofs:
Theorem (SMT/MILP Soundness): Assume the input region is encoded exactly and the bounds used by the encoding are valid enclosures of . Then, if an SMT/MILP verifier returns “VERIFIED”, the property truly holds for all inputs in the specified region.
Proof Sketch:
- Encoding is sound: Each constraint in the encoding (linear layers, ReLU, input region, property) is a sound over-approximation of the true network behavior (for MILP) or exact logical equivalence (for SMT).
- Solver is sound: SMT/MILP solvers are mathematically proven to return correct results (satisfiable/unsatisfiable for SMT, feasible/infeasible for MILP).
- Composition: Sound encoding + sound solver → sound overall verification.
Theorem (SMT/MILP Completeness): If a property truly holds for all inputs, an SMT/MILP verifier will (given sufficient time and memory) return “VERIFIED”.
Proof Sketch:
- Encoding is complete: The encoding captures all possible behaviors of the network (all activation patterns are representable).
- Solver is complete: SMT/MILP solvers are complete decision procedures---they always terminate with a definitive answer (for decidable theories like linear arithmetic).
- Composition: Complete encoding + complete solver → complete overall verification.
Consequence: SMT/MILP methods are sound and complete, subject to the two assumptions above. The cost is exponential worst-case complexity.
The two assumptions are load-bearing
Completeness is the property that makes these methods attractive and the property most often overstated, because the word does not survive contact with a solver process.
The bounds have to come from somewhere valid. The big-M encoding above is exact for . If a bound is too narrow, the encoding has excluded part of the network, and a “VERIFIED” result is a statement about the truncated network rather than the real one. This is why bound propagation feeds these methods: the completeness is the solver’s, the soundness of the bounds is the previous chapter’s, and a complete method inherits it. An exact encoding over an unsound enclosure is not a complete method — it is an unsound one that is fast.
The solver has to be allowed to finish. A complete decision procedure terminates, and a solver process is not a decision procedure: given a wall-clock limit or a memory limit, Z3 and CPLEX both return an unknown result. So a real run produces three outcomes, not two, and the third is what a competition leaderboard spends most of its columns on. Reading “VERIFIED” off a completed run is sound. Reading it off a run that stopped early is a claim about the harness.
The same applies to the vocabulary. Solvers report SAT, UNSAT, and UNKNOWN, and tools layer their own on top; a SAT result means the encoded formula has a model, which is a counterexample to the property only because the formula was built to encode the negation. The mapping from solver verdict to verification verdict is a property of the encoding, not of the word on the label — two tools can print the same token for different verdicts, and the VNN-COMP reports exist partly to make those conventions comparable.
SMT Solver Mechanics
Modern SMT solvers like Z3 use sophisticated algorithms:
DPLL(T): Combines Boolean satisfiability (SAT) solving with theory-specific reasoning. The solver:
- Abstracts theory constraints to Boolean variables
- Searches for Boolean satisfying assignment
- Checks if assignment is consistent with theory
- Learns conflicts when inconsistent, backtracks
Theory solvers: For linear real arithmetic, use simplex-based solvers. For Boolean structure (ReLU disjunctions), use Boolean reasoning.
Conflict-driven learning: When a branch leads to contradiction, learn a clause preventing similar contradictions. This prunes the search space effectively.
Strengths: SMT solvers are general-purpose, mature, and highly optimized. They handle arbitrary logical combinations of constraints.
Limitations: Exponential worst-case complexity. As network size grows, the number of ReLU disjunctions grows exponentially, making the problem intractable.
MILP-Based Verification
Mixed-Integer Linear Programming formulates verification as optimization with both continuous and integer variables.
Encoding Neural Networks as MILP
Linear layers: Same as SMT---linear equalities are native to MILP:
ReLU activations: Use binary indicator variables and big-M constraints:
When : and (ReLU active, )
When : and (ReLU inactive, )
The big-M constant must be large enough to not constrain the active case but small enough for numerical stability.
Objective: Minimize the margin to find adversarial examples:
If the minimum is negative, a counterexample exists. If non-negative, the property holds.
Tighter encoding: Use bounds from incomplete methods to tighten big-M values, reducing the feasible region and speeding up solving.
MILP Solver Mechanics
MILP solvers like Gurobi use branch-and-bound:
LP relaxation: Relax integer constraints ( instead of ), solve linear program efficiently.
Branching: Select fractional integer variable, create two subproblems (fixing and ).
Bounding: Use LP relaxation to bound optimal value. Prune branches where bound is worse than best-known solution.
Cutting planes: Add linear inequalities (cuts) that tighten the LP relaxation without removing integer solutions.
Strengths: MILP is well-studied with commercial-grade solvers. Supports optimization objectives (find minimum adversarial perturbation).
Limitations: Integer variables (one per ReLU) create exponential branching. Scales poorly to large networks.
| Aspect | SMT | MILP |
|---|---|---|
| Encoding | Logical formulas (disjunctions) | Linear inequalities + binary variables |
| Solver Type | DPLL(T) with theory solvers | Branch-and-bound with LP relaxation |
| Objective Support | Satisfiability only | Optimization (minimize margin) |
| Maturity | General-purpose SMT solvers (Z3) | Commercial MILP solvers (Gurobi) |
| Scalability | Hundreds of neurons | Hundreds of neurons |
| Main Challenge | ReLU disjunctions | Integer variables per ReLU |
QCQP and SDP Encodings: Non-Linear Relaxations
Beyond linear encodings (SMT, MILP), we can use non-linear relaxations that provide tighter bounds at the cost of increased computational complexity. Quadratically Constrained Quadratic Programming (QCQP) and Semidefinite Programming (SDP) offer such relaxations.
QCQP Encoding for ReLU
Quadratic Constraint Encoding:
Instead of linear big-M constraints, QCQP encodes ReLU using quadratic equality constraints:
For with bounds where :
Interpretation:
The quadratic constraint forces either:
- (inactive ReLU), OR
- (active ReLU)
This is exact for unstable ReLUs without requiring integer variables!
Problem: the quadratic equality constraint is non-convex, and that is a property of the set, not of the formula’s appearance.
A subtlety that is easy to miss here. Relaxing the equality to
does not produce a convex relaxation. The linear constraints already present are and , so both factors in the product are non-negative, and their product is therefore . Requiring it to also be forces it to be exactly zero, which means or — the ReLU’s own two branches. The feasible set is the ReLU graph, exactly as before, and it is just as non-convex.
The way to see it in one line: and are both feasible, and their midpoint is not, since . A set containing two points and not their midpoint is not convex.
What would actually give a convex relaxation. The relaxation has to admit points the graph does not contain, which means relaxing in the other direction — replacing the equality by a convex inequality that contains the graph. A convex function lies above its tangents, so a tangent line at any is a valid under-approximation and its maximum with is a convex function that lies below ReLU. That gives an under-approximation, which is the wrong direction for a sound outer bound. The workable alternatives are each a different construction with a different cost: the triangle relaxation, which stays linear and loses the correlation; a lifted PSD formulation, which buys convexity by working over a matrix variable and admits its own spurious points; or an exact MILP encoding, which keeps the region and pays for it in search. What does not work is relaxing a non-convex equality and expecting convexity.
Where this sits against the triangle. The exact quadratic encoding describes a strictly smaller set than the triangle over the same interval, and both contain the graph. Strictness in the first direction is not automatic, though: two sub-regions separated by a branch can together sit inside the triangle without either fitting in a triangle-shaped convex set, which is precisely why the encodings are not interchangeable. And a strictly smaller local region still does not promise a tighter global bound, because what the solver reports depends on the rest of the network’s constraints as well.
SDP Encoding: Semidefinite Programming
Semidefinite Relaxation:
SDP provides an even tighter relaxation by lifting the problem to a higher-dimensional space and enforcing positive semidefiniteness.
Matrix Lifting:
Introduce matrix variable (positive semidefinite) where:
Here is the vector of neuron activations, and represents second-order moments (outer products).
ReLU Constraints in SDP:
For , SDP encoding adds linear matrix inequalities (LMIs):
The key advantage: SDP can encode correlations between multiple neurons through the matrix , capturing multi-neuron dependencies.
Theorem (SDP Tightness Hierarchy):
For single-neuron ReLU relaxation:
where denotes “looser than or equal to.”
Proof:
SDP relaxation includes all linear constraints (triangle relaxation) plus additional semidefinite constraints. By including more constraints, the feasible region is smaller (tighter).
Multi-Neuron SDP:
SDP’s real power is multi-neuron analysis. For neurons, the matrix is , capturing correlations:
This allows SDP to reason about joint distributions of neuron activations, something linear and MILP methods cannot do efficiently.
Complexity Analysis:
| Method | Variables | Constraints | Complexity (per iteration) | Complete? |
|---|---|---|---|---|
| SMT/SAT | Boolean + continuous | disjunctions | Exponential (worst-case) | Yes |
| MILP | binary + continuous | linear | (branch-and-bound) | Yes |
| QCQP | continuous | quadratic | (interior-point) | No (relaxation) |
| SDP | matrix entries | LMI | (interior-point) | No (relaxation) |
Why SDP is Exponentially Slower than LP:
SDP solvers use interior-point methods operating on the matrix space :
- Each iteration: (matrix operations + eigenvalue decomposition)
- Number of iterations: (for -optimal solution)
Compare to LP: per iteration.
Practical Implication:
- LP: Networks with thousands of neurons (tractable)
- SDP: Networks with tens of neurons (already challenging)
SDP is substantially more expensive than LP per query — an interior-point solve on a lifted matrix variable costs far more than a linear solve of the same dimension — which restricts it to small networks or to analysing one layer at a time.
When to Use QCQP/SDP:
Use QCQP/SDP when:
- Need tighter bounds than LP: Triangle relaxation too loose for verification
- Multi-neuron correlations matter: Network has strong neuron dependencies
- Network is tiny: fewer than 100 neurons (SDP tractable)
- Research setting: Exploring tightness frontiers
Don’t use when:
- Network is large: >100 neurons for SDP, >1000 for QCQP
- Need complete verification: QCQP/SDP are incomplete (relaxations)
- Speed matters: an interior-point SDP solve on a lifted formulation costs far more per query than an LP, and these methods are solving a sequence of them
- Standard benchmarks: CROWN/DeepPoly (Singh et al. 2019) already sufficient
Tightness vs Completeness Tradeoff:
Connection to Theoretical Barriers:
Single-neuron linear relaxation (LP triangle) is optimal within the linear constraint class (see theoretical barriers). QCQP/SDP overcome this barrier by using non-linear constraints, achieving tightness beyond the convex barrier at the cost of increased complexity.
Practical Considerations
When to Use Complete Methods
Use SMT/MILP when:
- Network is small (hundreds to low thousands of neurons)
- Absolute certainty is required (safety-critical applications)
- Finding tight counterexamples is valuable (adversarial training)
- Computational budget allows hours or days per property
- Regulatory compliance demands complete verification
Don’t use when:
- Network has millions of parameters (incomplete methods required)
- Rapid iteration is needed (complete methods too slow)
- “Unknown” is acceptable (incomplete methods suffice)
- Only need robustness estimates, not proofs
Improving Performance
Preprocessing with incomplete methods: Use bound propagation to compute bounds on activations. These tighten big-M constants in MILP and prune branches in SMT.
Incremental solving: When verifying multiple similar properties, reuse solver state. Many SMT solvers support incremental mode where learned clauses carry over.
Parallelization: Verify multiple properties in parallel. Each property is independent, allowing trivial parallelization.
Timeout and best-effort: Set timeouts. If complete verification times out, fall back to incomplete methods or partial results.
Hybrid approaches: Use complete methods only on small uncertain regions identified by incomplete methods. Incomplete methods handle bulk verification, complete methods resolve edge cases.
Limitations and Challenges
Scalability barrier: The fundamental NP-completeness means exponential worst-case complexity is unavoidable. No algorithmic breakthrough can make complete verification polynomial-time (unless P=NP).
Network size: Current complete verifiers handle networks with thousands of neurons. Modern production networks have millions to billions of parameters---orders of magnitude beyond current capabilities.
Numerical issues: MILP requires careful tuning of big-M values. Too large causes numerical instability; too small gives incorrect results. Bounds from incomplete methods help but don’t eliminate the issue.
Memory consumption: Branch-and-bound explores exponentially many branches. Each branch requires memory. Large networks exhaust memory before finding answers.
Scalability Reality Check: Complete verification works well for small networks (e.g., ACAS Xu (Julian et al. 2019) with ~300 neurons). For larger networks, expect:
- Networks with thousands of neurons: feasible with good hardware and patience
- Networks with tens of thousands: very challenging, often timeout
- Networks with millions: currently intractable for complete methods
Comparison with Incomplete Methods
Incomplete methods (bound propagation, abstract interpretation) trade completeness for scalability:
Advantages of incomplete methods:
- Polynomial time complexity (scale to large networks)
- Fast verification (seconds to minutes)
- GPU acceleration available
Advantages of complete methods:
- Definitive answers (no “unknown”)
- Find tight counterexamples
- Required for regulatory compliance in some domains
Hybrid is often best: Use incomplete methods for initial screening, complete methods for critical cases. This balances speed and certainty.
Current State and Tools
Available tools:
- Marabou (Katz et al. 2019): SMT-based verifier with specialized ReLU handling (Reluplex (Katz et al. 2017) algorithm)
- Gurobi/CPLEX: Commercial MILP solvers, require encoding network as MILP
- Z3: General-purpose SMT solver, requires manual encoding
Research directions:
- Tighter encodings that reduce solver search space
- Specialized solvers exploiting network structure (convolution, residual connections)
- Better preprocessing with incomplete methods to guide complete solvers
- Parallelization and distributed solving for large instances
Key Takeaways
SMT and MILP solvers provide the gold standard for neural network verification: complete, definitive answers. When you need absolute certainty---for safety-critical systems, regulatory compliance, or finding counterexamples---complete verification is essential.
The cost is computational. Complete methods scale to small networks but struggle with large ones. Understanding this tradeoff helps you choose appropriately: use complete methods where certainty matters and network size permits, use incomplete methods where scale matters more than completeness.
As verification research advances, the boundary between tractable and intractable shifts. Better encodings, faster solvers, and hybrid approaches push complete verification to larger networks. But the fundamental NP-completeness barrier remains---complete verification will always involve exponential worst-case complexity.
Further Reading
This guide provides comprehensive coverage of SMT and MILP approaches to complete neural network verification. For readers interested in diving deeper, we recommend the following resources organized by topic:
SMT-Based Verification:
The foundational work on SMT-based verification established both the approach and its limitations. Reluplex extended the simplex algorithm to handle ReLU constraints directly, providing the first practical SMT-based verifier for neural networks. The same work proved NP-completeness of ReLU network verification, establishing fundamental computational barriers. Z3 provides a general-purpose SMT solver capable of encoding neural network verification problems.
MILP-Based Verification:
MILP formulations encode neural networks as mixed-integer programs, leveraging mature commercial solvers. The key challenge is encoding ReLU activations with binary variables and big-M constraints while maintaining numerical stability and tight bounds. Preprocessing with incomplete methods tightens big-M values, significantly improving MILP solver performance.
Complexity and Limitations:
The NP-completeness result proves that complete verification has worst-case exponential time complexity. This isn’t an engineering limitation---it’s a fundamental mathematical barrier. Understanding this complexity helps set realistic expectations about what complete methods can achieve.
Incomplete Methods for Comparison:
Complete methods are often contrasted with incomplete approaches. Bound propagation and abstract interpretation trade completeness for polynomial-time complexity, scaling to large networks by accepting “unknown” results. These methods are often used to preprocess and guide complete solvers.
Hybrid Approaches:
Many strong verification pipelines combine complete and incomplete methods. alpha-beta-CROWN uses incomplete bound propagation for initial verification, applying branch-and-bound (a complete method) selectively where needed. This hybrid strategy balances the strengths of both approaches. GPU acceleration enables practical implementation of these hybrid strategies.
Specialized Complete Verifiers:
Marabou extends Reluplex with additional features and optimizations, and remains a major SMT-based neural network verifier. It handles networks with thousands of neurons through careful encoding and pruning strategies.
Related Topics:
For understanding the theoretical foundations that SMT and MILP methods are built upon, see verification problem. For the guarantees that complete methods provide, see soundness and completeness. For specialized handling of ReLU constraints, see Marabou and Reluplex. For hybrid approaches combining complete and incomplete methods, see branch and bound.
Primary references:
- Katz, Barrett, Dill, Julian and Kochenderfer, “Reluplex: An Efficient SMT Solver for Verifying Deep Neural Networks”, CAV 2017 https://arxiv.org/abs/1702.01135
- Tjeng, Xiao and Tedrake, “Evaluating Robustness of Neural Networks with Mixed Integer Programming”, ICLR 2019 https://arxiv.org/abs/1711.07356
- Katz et al., “The Marabou Framework for Verification and Analysis of Deep Neural Networks”, CAV 2019 https://doi.org/10.1007/978-3-030-25540-4_26
- Salzer and Lange, “Reachability in Simple Neural Networks”, Fundamenta Informaticae 189(3-4); short version “Reachability is NP-Complete Even for the Simplest Neural Networks”, RP 2021 https://arxiv.org/abs/2203.07941
- Cousot and Cousot, “Abstract Interpretation: A Unified Lattice Model for Static Analysis of Programs”, POPL 1977 https://dl.acm.org/doi/10.1145/512950.512973
- Julian, Kochenderfer and Owen, “Deep Neural Network Compression for Aircraft Collision Avoidance Systems”, AIAA J. Guidance, Control, and Dynamics 2019; Julian et al., “Verifying Aircraft Collision Avoidance Neural Networks Through Linear Approximations of Safe Regions”, AIAA/IEEE DASC 2019 https://arc.aiaa.org/doi/10.2514/1.D0255