Combining Theory Solvers

TU Wien Guest Lectures October 2025

Nikolaj Bjørner
Microsoft Research

Combination of Theory Solvers

  • Combining Theories in a modular way $\Rightarrow$ scale solvers across theories

Combining Theories

In practice, we need a combination of theories.

\[\begin{mdmathpre}%mdk \mdmathindent{2}\mathid{b}~+~2~=~\mathid{c}~~\mathid{and}~~\mathid{f}(\mathid{read}(\mathid{write}(\mathid{a},\mathid{b},3),~\mathid{c}-2))~\neq \mathid{f}(\mathid{c}-\mathid{b}+1) \end{mdmathpre}%mdk \]

A theory is a set (potentially infinite) of first-order sentences.

Main questions: Is the union of two theories $T_1 \cup T_2$ consistent? Given a solvers for $T_1$ and $T_2$, how can we build a solver for $T_1 \cup T_2$?

Combining Theories In a Nutshell



\[\xymatrix @-0.5em{ & T_1 \cup T_2 \\ T_1 \ar@{.>}[ur] & & T_2 \ar@{.>}[ul] \\ & T_0 \ar[ul] \ar[ur] } \]

Is there an effective $T_0$ over shared signature, that when embeddable into $T_1, T_2$ implies $T_1 \cup T_2$ is consistent?

A Combination History

Foundations Efficiency using rewriting
1979  (Nelson and Oppen1979) - Framework 1984 Shostak Theory
1996 Tinelli et al: N.O Fix 1996 Cyrluk et al: Shostak fix 1
2000 Barrett et al: N.O + Rewriting 1998 B: Shostak + Constraints
2002 Zarba & Manna: “Nice” theories 2001 Rues & Shankar: Shostak fix 2
2004  (Ghilardi2004): N.O. as Amalgamation 2004 Ranise et al: N.O. + Superposition
       (Silva and Sakallah1999,Moskewicz et al. (2001)) efficient backjumping
2006 Bruttomesso et al: Delayed Theory Combination
2007  (Moura and Bjørner2008): Model-based Theory Combination
2011  (Jovanovic and Barrett2011): overlapping, polite, shiny theories
2025  (Toledo et al.2025) super polite shiny polish++

Disjoint Theories

  • Two theories are disjoint if they do not share function/constant and predicate symbols. $=$ is the only exception.

  • Example:

    • The theories of arithmetic and arrays are disjoint.

    • Arithmetic symbols: $\{0, -1, 1, -2, 2, \ldots, +, -, \times, >, <, =, \geq \}$.

    • Array symbols: $\{ read, write \}$

Purification


\[ \color{red}{b + 2 = c},\ \color{blue}{f}(\color{green}{read}(\color{green}{write}\color{red}{(a,b,3), c-2})) \neq \color{blue}{f}(\color{red}{c-b+1}) \]


becomes

\[\begin{array}{l} \color{red}{b + 2 + c}, \color{blue}{f(v_1) \neq f(v_2)} \\ \color{green}{v_1 \equiv read(v_3, v_4)}\\ \color{red}{v_2 \equiv c - b + 1}\\ \color{green}{v_3 \equiv write(a,b,v_5)}\\ \color{red}{v_4 \equiv c-2}\\ \color{red}{v_5 \equiv 2}\\ \end{array} \]

Purification (2)

\[ \color{red}{b + 2 = c},\ \color{blue}{f}(\color{green}{read}(\color{green}{write}\color{red}{(a,b,3), c-2})) \neq \color{blue}{f}(\color{red}{c-b+1}) \]

becomes

\[\begin{array}{ll} \mathrm{Arithmetic:} & \color{red}{b + 2 + c, v_2 \equiv c - b + 1, v_4 \equiv c-2, v_5 \equiv 2}\\[2em] \mathrm{EUF:} & \color{blue}{f(v_1) \neq f(v_2)}\\[2em] \mathrm{Arrays:} & \color{green}{v_1 \equiv read(v_3, v_4), v_3 \equiv write(a,b,v_5)} \end{array} \]

Stably Infinite Theories

  • A theory is stably infinite if every satisfiable QFF is satisfiable in an infinite model.

  • EUF and arithmetic are stably infinite.

  • Bit-vectors are not

Stably Infinite Theories - Result

The union of two consistent, disjoint, stably infinite theories is consistent.

Beyond Disjointness - Amalgamation (Ghilardi2004)

\[\xymatrix @-0.5em{ & T_1 \cup T_2 \\ T_1 \cup T_0^* \ar@{.>}[ur] & & T_2 \cup T_0^* \ar@{.>}[ul] \\ & T_0^* \ar[ul] \ar[ur] \\ T_1 \ar[uu] & & T_2 \ar[uu] \\ & T_0 \ar[uu] } \]

Amalgamation (Ghilardi2004)

  1. there is a universal theory $T_0$ in the shared signature $\Sigma_0$ that is contained in both $T_1$ and $T_2$
    • $T_0$ is universal = axioms of $T_0$ use only $\forall$.
  2. $T_0$ admits model-completion $T^*_0$
    • Every model of $T_0$ embeds into $T^*_0$.
    • $T^*_0$ admits quantifier elimination.
  3. every model of $T_i$ embeds into a model of $T_i \cup T^*_0$
    • $M \models T_i$ iff $\mu(M) \models T_i \cup T^*_0$
  4. $T_0$ is effectively locally finite.
    • For every set of constants $\overline{a}$, there is a finite, computable, set $t_1, \ldots, t_k$ over $\Sigma_0^{\overline{a}}$ s.t. $T_0 \models \forall u \ . \bigvee_i \ . \ t_i = u$.

Signature non-disjoint theories


Ingredient: establish homomorphism from theory $\mathcal{T}$ to $\mathcal{T}_A$, such that consistency of $\mathcal{T}$ is reduced to consistency of $\mathcal{T}_{A} \cup Arith$.



Local Theory Extensions, Bridge Functions, Surjective Homomorphisms (Sofronie-Stokkermans2005), (Fontaine and Gribomont2005), (Zhang et al.2006), (Suter et al.2010), (Chocron et al.2015), (Berthon and Ringeissen2016)

\[\begin{mdmathpre}%mdk \mdmathindent{4}\mathid{type}~\mathid{tree}~=~\mathid{node}_{2}(\mathid{tree},~\mathid{tree})~|~\mathid{leaf}\\ \mdmathindent{4}\mathid{x},~\mathid{y}~:~\mathid{tree}\\ \mdmathindent{4}\mathid{length}(\mathid{node}(\mathid{x},\mathid{y}))~=~1~+~\mathid{length}(\mathid{x})~+~\mathid{length}(\mathid{y})\\ \mdmathindent{4}\mathid{length}(\mathid{leaf})~=~1\\ \\ \mdmathindent{4}\mathid{length}(\mathid{x})~=~2\cdot \mathid{length}(\mathid{y})~~ \end{mdmathpre}%mdk \]

Nelson-Oppen combination

Let $\mathcal{T}_1$ and $\mathcal{T}_2$ be consistent, stably infinite theories over disjoint (countable) signatures. Assume satisfiability of conjunction of literals can be decided in $O(\mathcal{T}_1(n))$ and $O(\mathcal{T}_2(n))$ time respectively. Then

  1. The combined theory $\mathcal{T}$ is consistent and stably infinite.

  2. Satisfiability of quantifier free conjunction of literals can be decided in $O(2^{n^2} \times (\mathcal{T}_1(n) + \mathcal{T}_2(n)))$.

  3. If $\mathcal{T}_1$ and $\mathcal{T}_2$ are convex, then so is $\mathcal{T}$ and satisfiability in $\mathcal{T}$ is in $O(n^3 \times (\mathcal{T}_1(n) + \mathcal{T}_2(n)))$.

Convexity

A theory $T$ is convex iff:

  • For all finite sets $S$ of literals
  • For every disjunction $a_1 = b_1 \vee \ldots \vee a_n = b_n$
    • $S \models a_1 = b_1 \vee \ldots \vee a_n = b_n$
    • iff
    • $S \models a_i = b_i$ for some $1 \leq i \leq n$.

Convexity: Positive Results

  • Every convex theory with non trivial models is stably infinite.

  • Horn equational theories are convex.

    • Horn equations are formulas of the form $a_1 \neq b_1 \vee \ldots a_n \neq b_n \vee a = b$.

Convexity: Negative Results

  • Integer arithmetic is not convex.

    • $1 \leq a \leq 2, b = 1, c = 2$ implies $a = b \vee a = c$.
  • Real non-linear arithmetic

    • $a^2 = 1, b = 1, c = -1$ implies $a = b \vee a = c$.

Combination of non-convex theories

  • EUF is convex $O(n \log n)$

  • IDL is non-convex $O(n\cdot m)$

  • $EUF \cup IDL$ is NP-complete

    • Reduce 3-CNF to EUF+ IDL:
      • $0 \leq a_i \leq 1$ for each Boolean variable.
      • For each clause $a_i \vee \neg a_j \vee a_k$: $f(a_i,a_j,a_k) \neq f(0,1,0)$.

A Reduction Approach to Combination (Kapur and Zarba2006; Moura and Bjørner2009)

Theory Combination in Z3:

  • Core Theories = Arithmetic + EUF + SAT

  • Bit-vectors, Finite domains = SAT

  • Other theories reduced to Core Theories

    • Arrays, Datatypes, ..: Instantiate Theory Axioms
      • each index $j$, each occurrence $\color{green}{write(a,i,v)}$.
      • add $\color{green}{read(write(a,i,v),i) = v}$
      • add $\color{green}{read(write(a,i,v),j) = read(a,j) \lor i = j}$

Gentle, smooth, polite theory combinations (Jovanovic and Barrett2011)

  • Filtering rules on when shared variables matter.

  • $x, y$ are shared, but

    • $x$ occurs only in $f(x), g(x,z)$

    • $y$ occurs only in $h(y), g(z,y)$

  • We don't care if $x = y$ or $x \neq y$.

Combining Theories in Practice

Propagate all implied equalities.

  • Deterministic Nelson-Oppen.

  • Complete only for convex theories.

  • It may be expensive for some theories.

Delayed Theory Combination.

  • Deterministic Nelson-Oppen.

  • Create set of interface equalities $(x = y)$ between shared variables.

  • Use SAT solver to guess the partition.

  • Disadvantage: the number of additional equalities is quadratic in the number of shared variables.

Combining Theories in Practice (2)

Common to these methods is that they are pessimistic about which equalities are propagated.

Model-based Theory Combination:

  • Optimistic approach.

  • Use a candidate model $M_i$ for one of the theories $\mathcal{T}_i$ and propagate all equalities implied by the candidate model hedging that other theories will agree.

    \[ \mathrm{if}\ M_i \models \mathcal{T}_i \cup \Gamma_i \cup \{ u = v \}\ \mathrm{then\ propagate}\ u = v \]
  • If not, use backtracking on choices $\Gamma$ to fix the model.

  • It is cheaper to enumerate equalities that are implied in a particular model than of all models.

Model-Based Theory Combination - Example

\[\begin{mdmathpre}%mdk \mdmathindent{2}\mathid{x}~=~\mathid{f}(\mathid{y}-1),~\mathid{f}(\mathid{x})~\neq \mathid{f}(\mathid{y}),~0~\leq \mathid{x}~\leq 1,~0~\leq \mathid{y}~\leq 1 \end{mdmathpre}%mdk \]

purify

\[ {\color{blue}{x = f(z), f(x) \neq f(y)}}, {\color{red}{0 \leq x \leq 1, 0 \leq y \leq 1, z = y - 1}} \]

Model-Based Theory Combination (1)

MBTCombination1

Model-Based Theory Combination (2)

MBTCombination2

Model-Based Theory Combination (3)

MBTCombination3

Model-Based Theory Combination (4)

MBTCombination4

Model-Based Theory Combination (5)

MBTCombination5

Model-Based Theory Combination (6)

MBTCombination6

Model-Based Theory Combination (7)

MBTCombination7

Relaxing conditions, arrays

Diversifying Arithmetic

Polite, etc

Yoni Zohar's ontology

Canonization and Equality Saturation

  • Bit-vectors

  • Arithmetic

References

Raphaël Berthon, and Christophe Ringeissen. “Satisfiability Modulo Free Data Structures Combined with Bridging   Functions.” In Proceedings of the 14th International Workshop on Satisfiability Modulo   Theories Affiliated with the International Joint Conference on Automated Reasoning, SMT@IJCAR 2016, Coimbra, Portugal, July 1-2, 2016., 71–80. 2016. http://​ceur-​ws.​org/​Vol-​1617/​paper7.​pdf🔎
Paula Chocron, Pascal Fontaine, and Christophe Ringeissen. “A Polite Non-Disjoint Combination Method: Theories with Bridging Functions   Revisited,” in @DBLP:conf/cade/2015, 9195:419–433. 2015. doi:10.1007/978-3-319-21401-6_29🔎
Pascal Fontaine, and E. Pascal Gribomont. “Combining Non-Stably Infinite, Non-First Order Theories.” Electr. Notes Theor. Comput. Sci. 125 (3): 37–51. 2005. doi:10.1016/j.entcs.2004.06.066🔎
Silvio Ghilardi. “Model-Theoretic Methods in Combined Constraint Satisfiability.” J. Autom. Reasoning 33 (3-4): 221–249. 2004. doi:10.1007/s10817-004-6241-5🔎
Dejan Jovanovic, and Clark Barrett. “Sharing Is Caring: Combination of Theories.” In Frontiers of Combining Systems, 8th International Symposium, FroCoS   2011, Saarbrücken, Germany, October 5-7, 2011. Proceedings, 195–210. 2011. doi:10.1007/978-3-642-24364-6_14🔎
Deepak Kapur, and Calogero Zarba. A Reduction Approach to Decision Procedures. University of New Mexico. 2006. https://​www.​cs.​unm.​edu/​~kapur/​mypapers/​reduction.​pdf🔎
Matthew W. Moskewicz, Conor F. Madigan, Ying Zhao, Lintao Zhang, and Sharad Malik. “Chaff: Engineering an Efficient SAT Solver.” In Proceedings of the 38th Design Automation Conference, DAC 2001,   Las Vegas, NV, USA, June 18-22, 2001, 530–535. ACM. 2001. doi:10.1145/378239.379017🔎
Leonardo Mendonça de Moura, and Nikolaj Bjørner. “Model-Based Theory Combination.” Electron. Notes Theor. Comput. Sci. 198 (2): 37–49. 2008. doi:10.1016/j.entcs.2008.04.079🔎
Leonardo Mendonça de Moura, and Nikolaj Bjørner. “Generalized, Efficient Array Decision Procedures.” In Proceedings of 9th International Conference on Formal Methods in Computer-Aided   Design, FMCAD 2009, 15-18 November 2009, Austin, Texas, USA, 45–52. 2009. doi:10.1109/FMCAD.2009.5351142🔎
Greg Nelson, and Derek C. Oppen. “Simplification by Cooperating Decision Procedures.” ACM Trans. Program. Lang. Syst. 1 (2): 245–257. 1979. doi:10.1145/357073.357079🔎
João P. Marques Silva, and Karem A. Sakallah. “GRASP: A Search Algorithm for Propositional Satisfiability.” IEEE Trans. Computers 48 (5): 506–521. 1999. 🔎
Viorica Sofronie-Stokkermans. “Hierarchic Reasoning in Local Theory Extensions.” In Automated Deduction - CADE-20, 20th International Conference on Automated   Deduction, Tallinn, Estonia, July 22-27, 2005, Proceedings, 219–234. 2005. doi:10.1007/11532231_16🔎
Philippe Suter, Mirco Dotta, and Viktor Kuncak. “Decision Procedures for Algebraic Data Types with Abstractions,” in @DBLP:conf/popl/2010, 199–210. 2010. doi:10.1145/1706299.1706325🔎
Guilherme Vicentin de Toledo, Benjamin Przybocki, and Yoni Zohar. “Being Polite Is Not Enough (and Other Limits of Theory Combination).” In Automated Deduction - CADE 30 - 30th International Conference on   Automated Deduction, Stuttgart, Germany, July 28-31, 2025, Proceedings, edited by Clark W. Barrett and Uwe Waldmann, 15943:17–34. Lecture Notes in Computer Science. Springer. 2025. doi:10.1007/978-3-031-99984-0_2🔎
Ting Zhang, Henny B. Sipma, and Zohar Manna. “Decision Procedures for Term Algebras with Integer Constraints.” Inf. Comput. 204 (10): 1526–1574. 2006. doi:10.1016/j.ic.2006.03.004🔎