Maps to: Stanford CS 257 Introduction to Automated Reasoning (Winter 2026), Lecture 18 · Thu 03/05/2026 · SMT: theory combination (Caroline Trippel). Reading: Kroening and Strichman, Decision Procedures, Sections 10.1–10.5. Basis: The Stanford slides are on Canvas. The public Iowa deck Combining Theories and Their Solvers (Tinelli, Spring 2024) credits Barrett, Trippel and Wu at Stanford, and it is the outline of this lecture: its examples, definitions and theorems appear here. Further sources:
- Nelson and Oppen (1979), the method;
- Oppen (1980), convexity;
- Tinelli and Harandi (1996), the non-deterministic version;
- Bozzano et al. (2005), delayed theory combination;
- de Moura and Bjørner (2008), model-based theory combination;
- Ranise, Ringeissen and Zarba (2005) and Jovanović and Barrett (2010), polite combination.
These notes add one module,
combine.py, with:
- purification;
- Nelson–Oppen with an independently checked trace;
- model-based case splits;
- arrangements;
- a finite-sort counterexample;
- CDCL(T1, T2) by interface clauses;
- certificates;
- an Ackermann cross-check.
The experiments were designed for these notes and do not reflect what was said in class. Code:
code/lecture18/(3 scripts + 1 module; Python standard library only; about 2 to 13 seconds of CPU time each) Reading time: 2.5 hours including running the code
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Define the combination of two theories, and purify a mixed formula into two pure parts that share only variables.
- Run the Nelson–Oppen method by hand: check each part, propagate entailed equalities between shared variables, and decide.
- Define convexity, show that the integers are not convex, and explain why non-convex theories need case splits.
- State the non-deterministic method with arrangements and its correctness theorems, and say where stable infiniteness is needed. Build a counterexample when it fails.
- Explain how CDCL(T1, …, Tn) lifts the combination into the SAT search: interface equalities as atoms, local propagation and conflicts.
- Certify a combined answer, and compare the modular method with the eager alternative, Ackermann’s reduction.
0.2 Prerequisites and scope
| Assumed | Introduced here | Developed later |
|---|---|---|
| theories, CDCL(T), EUF and congruence closure, Ackermann (Lecture 10) | , purification, shared variables | — |
| LRA and the simplex method (Lecture 11); LIA, branch and bound (Lecture 12) | convexity; equality propagation; case splits | — |
| arrays and their reduction to EUF (Lecture 13); bit-vectors (Lecture 16) | stable infiniteness, finite sorts | text-to-SQL with mixed theories (Lecture 19) |
| E-graphs (Lecture 17) | interface literals, delayed and model-based combination | — |
0.3 Map
§1 why formulas mix theories
§2 combined theories and purification ← code 01
§3 Nelson–Oppen for convex theories ← code 01
§4 convexity, and case splits for the integers ← code 02
§5 arrangements, correctness, and stable infiniteness ← code 02
§6 CDCL(T1, ..., Tn) ← code 03
§7 certificates, and the eager alternative ← code 01, 03
§8 summary §9 common pitfalls §10 exercises §11 further reading §12 next lecture
0.4 Notation
| Symbol | Meaning |
|---|---|
| the combined theory: interpretations whose restriction to each signature is a model of that theory | |
| , | the pure - and -literals after purification |
| the shared variables, occurring in both and | |
| entails in theory | |
| arrangement | for every pair , either or |
| the number of arrangements (set partitions) of variables |
0.5 The code of this lecture
One module, combine.py:
- purification:
purify,Purifier,owner,literal_owner; - component solvers on conjunctions:
EUFOracle,LRAOracle,LIAOracle,FiniteOracle, each withsat,entailsandcore; - Nelson–Oppen:
nelson_oppen(withsplitandpropagateoptions),Step,check_trace; - arrangements:
set_partitions,bell,combine_by_arrangements,share_terms; - CDCL(T1, T2):
Pair,prepare_combined,solve_combined; - certificates:
combined_model,evaluate_combined,certify_combined; - the eager alternative:
ackermann_arith,solve_ackermann; - benchmarks:
SLIDES_CONVEX,SLIDES_NONCONVEX,MOTIVATING,MOTIVATING_UNSAT,FINITE_SORT_EXAMPLE,ping_pong,random_mixed.
The component solvers are the earlier lectures’ own: congruence closure (Lecture 10), the simplex method (Lecture 11), and branch and bound (Lecture 12). The combination never looks inside them.
1. Why formulas mix theories
The slides open with a formula of the kind program verifiers produce:
It needs integer arithmetic, arrays and an uninterpreted function at once. Every solver of Lectures 10–16 handles one theory. A smaller example shows the problem (script 01, Part 1):
| method | answer |
|---|---|
| EUF alone: , , uninterpreted, a free Boolean | SAT |
| arithmetic alone: every -term an unrelated number | SAT |
| Nelson–Oppen: EUF and LRA exchanging equalities | UNSAT |
| Ackermann’s reduction: eliminated, consistency constraints added | UNSAT |
Why it is unsatisfiable.
- gives by congruence.
- So by arithmetic.
- So by congruence, that is, .
- And by arithmetic: a contradiction.
The argument alternates between the theories. Each solver alone treats the other’s symbols as uninterpreted, so it over-approximates and answers SAT.
Two ways out.
- Eagerly, translate one theory away. Ackermann’s reduction (Lecture 10) removes in exchange for consistency constraints.
- Modularly, keep both solvers and let them exchange facts. Nelson and Oppen (1979) showed that, under conditions on the theories, the facts that need to be exchanged are only equalities between shared variables. This is how all SMT solvers combine theories today.
2. Combined theories and purification
2.1 The combined theory
Theories. Recall from the slides that a theory is a signature with a class of interpretations, the models.
The combination. For two theories with compatible signatures, the combination is
Its models are interpretations of both signatures whose reduct to each signature is a model of that theory. EUF ⊕ LRA has rational numbers with their arithmetic, plus arbitrary functions on them.
The standing assumption. The function symbols are disjoint: . The theories share only sorts, equality and the free constants (our “variables”).
2.2 Purification
A literal is pure if all its symbols come from one signature. Purification names every alien subterm, a term of one theory inside a literal or term of the other, by a fresh variable:
repeat:
find an i-term t (non-variable, top symbol in Σi) that is a subterm of a non-Σi literal or term
replace t by a fresh variable v; add the definition v = t (a Σi-literal)
until every literal is pure; split into L1 (Σ1-literals) and L2 (Σ2-literals)
Script 01, Part 2 (purify works innermost first; the slides number the fresh variables differently):
input: f(f(x) - f(y)) = a ∧ f(0) > a + 2 ∧ x = y
definitions: v1 = f(x) (EUF), v2 = f(y) (EUF), v3 = v1 - v2 (arith), v4 = 0 (arith), v5 = f(v4) (EUF)
L1 (EUF): f(v3) = a, x = y, v1 = f(x), v2 = f(y), v5 = f(v4)
L2 (arith): a + 2 < v5, v3 = v1 - v2, v4 = 0
shared: a, v1, v2, v3, v4, v5
Three remarks.
- Numerals are arithmetic terms. So needs two definitions: for arithmetic, and for EUF.
- Equalities between variables. belongs to both signatures, and is put in EUF, as on the slides. The other theory learns about it only through shared variables, and here are not shared at all.
- Purification preserves satisfiability. A model of the input extends to the fresh variables by their definitions, and a model of satisfies the input because each equals its term.
After purification the halves share only variables. Everything the combination does is about the shared variables : which are equal and which are different.
3. Nelson–Oppen for convex theories
3.1 The method
The deterministic method (the slides’ steps 2 and 4):
purify into L1, L2; E := {}
repeat:
if L1 ∪ E is T1-unsatisfiable or L2 ∪ E is T2-unsatisfiable: return UNSAT
for every pair u, v of shared variables with u = v not in E:
if L1 ∪ E ⊨T1 u = v or L2 ∪ E ⊨T2 u = v: add u = v to E (propagation)
if nothing was added: return SAT
Script 01, Part 3, on the slides’ example (EUF + LRA):
| step | theory | derives | because |
|---|---|---|---|
| 1 | EUF | , , | |
| 2 | LRA | , , | |
| 3 | EUF | , , | |
| 4 | LRA | ⊥ | , |
These are the slides’ four steps: congruence, arithmetic, congruence, arithmetic. The answer is UNSAT after 4 rounds and 112 calls to the component solvers.
3.2 Both directions, and the dialogue
Script 01, Part 4, restricts which theory may send equalities:
| propagation | answer | steps |
|---|---|---|
| both directions | UNSAT | EUF ⊨ v1 = v2, LRA ⊨ v3 = v4, EUF ⊨ a = v5, LRA ⊨ ⊥ |
| EUF → arithmetic only | SAT (wrong) | EUF ⊨ v1 = v2 |
| arithmetic → EUF only | SAT (wrong) | — |
| no exchange | SAT (wrong) | — |
Each half is satisfiable alone. The contradiction exists only in the dialogue, which must go back and forth until a fixpoint.
3.3 Why it is correct (for convex, stably infinite theories)
UNSAT is always right. Every propagated equality is entailed by one half, hence by the whole. A refutation of is therefore a refutation of the input. The slides call this refutation soundness.
Termination. With shared variables there are at most useful equalities: each one merges two classes.
SAT needs an argument. When propagation stops, consider the arrangement
Each half is consistent with :
- Take and the disequalities of .
- If this set were unsatisfiable, would entail the disjunction of the equalities that denies.
- For a convex theory (§4), it would then entail one of them, and that one would have been propagated.
So both and are satisfiable.
Gluing the two models. Take a model of each half with domains of the same cardinality (infinite, for stably infinite theories, §5). Identify the elements named by shared variables according to . Rename the rest bijectively. The result is a model of satisfying the input.
3.4 What it costs
The cost of pairwise tests. Propagation as written tests every pair of shared variables in every round. Script 01, Part 5, uses a family ping_pong(n) whose proof alternates times:
| shared variables | steps | rounds | solver calls | |
|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 1 |
| 2 | 4 | 3 | 3 | 26 |
| 3 | 8 | 5 | 5 | 219 |
| 4 | 12 | 7 | 7 | 772 |
| 5 | 16 | 9 | 9 | 1,877 |
The proof has steps, but the tests cost roughly calls.
How real solvers avoid it. Solvers obtain entailed equalities as a by-product:
- a congruence closure knows its classes;
- the simplex method detects equalities among tight bounds.
They also explain them as theory propagations (Lecture 10’s T-EXPLAIN). Here the explanations are small premise sets found by deletion.
4. Convexity, and case splits for the integers
4.1 Convex theories
A theory is convex if, for every set of literals and every finite disjunction of equalities, implies for some .
Script 02, Part 1, tests the slides’ example :
| theory | entails | entails | entails |
|---|---|---|---|
| LRA | no | no | no |
| LIA | no | no | yes |
Which theories are convex.
- LRA is convex. The solutions of a set of literals form a convex polyhedron. A convex set covered by finitely many hyperplanes lies inside one of them. (Here even refutes the disjunction.)
- EUF is convex too.
- LIA is not. Over the integers , so the disjunction holds but neither equality does.
- Many SMT theories are not convex: arrays, bit-vectors, finite datatypes.
4.2 What goes wrong, and the case split
Script 02, Part 2, uses the slides’ non-convex example:
Over the reals. It is SAT. A certified model is , , , , with and .
Over the integers. It is UNSAT:
- gives ;
- gives .
Propagation alone answers SAT, which is wrong. LIA entails (with , ), but neither disjunct. The two candidate models disagree: arithmetic has , while EUF puts and in different classes.
The fix: case splits. When propagation stalls, the combination must split on an equality between shared variables (the slides’ step 3, “Decision”). Which pair to split on is a design choice:
- The slides guess any non-entailed equality.
- Model-based combination (de Moura and Bjørner 2008) splits only on a pair where the two candidate models disagree, first the way the arithmetic model suggests. When the models agree on every shared pair, they induce the same arrangement and can be glued: SAT.
With model-based splitting, the example needs one split and 259 solver calls:
EUF ⊨ a = v4 because f(v1) = a, v4 = f(v1)
split: v1 = x
EUF ⊨ a = b because f(x) = b, v4 = f(v1), a = v4, v1 = x
EUF ⊨ b = v4 because f(x) = b, v4 = f(v1), v1 = x
LIA ⊨ ⊥ because a = b + 2, a = b
split: v1 ≠ x
LIA ⊨ v2 = x because 1 ≤ x, x ≤ 2, v1 = 1, v2 = 2, v1 ≠ x
EUF ⊨ b = v3 because f(x) = b, v3 = f(v2), v2 = x
LIA ⊨ ⊥ because a = b + 2, v3 = v4 + 3, a = v4, b = v3
These are the two branches of the slides’ CDCL(T1, T2) trace (§6).
5. Arrangements, correctness, and stable infiniteness
5.1 The non-deterministic method
The slides’ bare-bones version:
guess an arrangement A of the shared variables V (for all u, v ∈ V: u = v ∈ A or u ≠ v ∈ A)
if Li ∪ A is Ti-unsatisfiable for i = 1 or 2: this guess fails
SAT if some guess succeeds; UNSAT if every guess fails
The slides state four theorems for it:
- Refutation soundness: if every arrangement fails, the input is unsatisfiable in .
- Solution soundness: if the signatures share no function symbols and both theories are stably infinite, a successful arrangement means the input is satisfiable.
- Termination: there are finitely many arrangements.
- Decidability: under the conditions of theorem 2, if quantifier-free satisfiability is decidable in each , it is decidable in .
The cost is the number of arrangements, the Bell numbers (script 02, Part 3):
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
|---|---|---|---|---|---|---|---|---|---|---|
| Bell() | 1 | 2 | 5 | 15 | 52 | 203 | 877 | 4,140 | 21,147 | 115,975 |
The non-convex example has 7 shared variables. Over LIA all 877 arrangements fail (986 solver calls). Over LRA the 333rd works: together, everything else apart, meaning .
Searching the arrangements cleverly. Propagation is a way of searching the arrangements without listing them. Convexity guarantees that propagation alone finds the right one. Case splits and CDCL search the rest.
5.2 Stable infiniteness
is stably infinite (for a sort ) if every quantifier-free formula satisfiable in is satisfiable in a model where is infinite.
Which theories are stably infinite.
- EUF, LRA and LIA are: an EUF model can be padded with extra elements, and the numbers are infinite anyway.
- Theories with only finite models are not: bit-vectors of a fixed width, arithmetic modulo , finite datatypes, strings of bounded length.
Why the gluing needs it. The halves’ models must have domains of the same size.
The slides’ counterexample. Arrays whose indices and elements are 1-bit vectors, and five arrays that are pairwise different. The array solver accepts the five disequalities, and the bit-vector solver receives nothing. But only such arrays exist.
Script 02, Part 4, has the same phenomenon with EUF. maps into a sort with exactly 2 elements, and the literals are , , :
- Brute force: of the 8 functions from to , none has three different values.
| combination | answer | arrangements tried |
|---|---|---|
| share only variables common to both halves (none) | SAT (wrong) | 1 |
| share every term of sort (, , ) | UNSAT | 5 |
What goes wrong. No variable is shared, so the theory of never hears about the three values.
The repair. Share every term of the finite sort, so that the finite theory must accept the arrangement. EUF accepts only “all different”, and rejects it.
In real solvers. Refinements of this idea are used for bit-vectors and datatypes:
- polite combination (Ranise, Ringeissen and Zarba 2005; Jovanović and Barrett 2010) requires one theory to be “polite” and shares a computed set of terms;
- cvc5 also reasons explicitly about cardinalities.
6. CDCL(T1, …, Tn)
6.1 The rules
Why move the combination into CDCL. Formulas have Boolean structure, and Lecture 10’s CDCL(T) takes one theory solver. The slides lift the combination into the SAT search. Let be the shared constants, the -literals of the trail, and the interface literals: and for shared .
| rule | change from CDCL(T) |
|---|---|
| DECIDE | may decide interface literals too |
| T-PROPAGATE | propagates literals, interface literals included, entailed by in one |
| T-CONFLICT, T-EXPLAIN | reason locally in one |
| I-LEARN (new) | adds over interface literals when it is -valid (the non-convex disjunctions, such as ) |
Theory reasoning stays local, and the SAT solver searches the arrangements.
6.2 Delayed theory combination, as implemented
solve_combined takes a simple route (Bozzano et al.’s delayed theory combination), with no change to Lecture 10’s CDCL(T):
- Purify the whole formula (any Boolean structure). Conjoin the definitions, and turn arithmetic equalities into two (Lecture 11).
- Add interface clauses. For every pair of shared variables , add the interface clause . It states the same fact in each theory’s language: the EUF atom on the left, LRA/LIA atoms on the right.
- Combine the solvers. A
Pairtheory solver dispatches each atom to EUF or to arithmetic. The two solvers never talk to each other.
Script 03, Part 1, runs this on the slides’ example. It has 6 shared variables, hence 15 interface clauses:
T-PROP v1 = v2 because f(x) = v1, f(y) = v2, x = y (EUF)
PROP v1 ≤ v2 (interface clause)
PROP v2 ≤ v1
T-PROP ¬(v5 ≤ a) because a + 2 < v5 (LRA)
PROP ¬(a = v5) (interface clause)
...
UNSAT: 53 decisions, 5 conflicts, 44 theory propagations; certified
Nelson–Oppen as unit propagation. The exchange of equalities is just unit propagation on the interface clauses. Undecided interface atoms are decided like any other atom: those are the case splits.
The non-convex example needs no special code (script 03, Part 2):
| arithmetic | answer | decisions | conflicts | theory propagations | certificate |
|---|---|---|---|---|---|
| LIA | UNSAT | 129 | 14 | 79 | ok |
| LRA | SAT | 126 | 9 | 75 | ok |
The price. One interface atom per pair of shared variables, which is quadratic. The SAT solver also decides many of them.
What Z3 does instead. Its model-based theory combination creates interface equalities only when the theories’ candidate models disagree. That is the splitting rule of §4.2, inside the SAT search.
6.3 Without interface clauses
Script 03, Part 3, drops the interface clauses:
| formula | arithmetic | interface clauses | answer | certificate |
|---|---|---|---|---|
| slides’ convex example | LRA | yes | UNSAT | ok |
| slides’ convex example | LRA | no | SAT | REJECTED: the model falsifies the formula |
| non-convex example | LIA | yes | UNSAT | ok |
| non-convex example | LIA | no | SAT | REJECTED |
The wrong SAT is caught by the certificate (§7). An unchecked solver would have reported it.
6.4 Three theories
The motivating formula of §1 has arrays, and integers. Script 03, Part 4, decides it in two stages:
- Lecture 13’s eager reduction removes the arrays: becomes a function, and the write becomes a fresh array with read-over-write instances. Here: 1 write, index set , 4 instances.
- CDCL(EUF, LIA) decides the result.
The results.
- The motivating formula is SAT, with 6 shared variables and 15 interface clauses. The certified model has , , , , so .
- The variant is UNSAT, certified.
Combining by reduction (arrays into EUF) and by combination (EUF with LIA) is how real solvers stack theories.
7. Certificates, and the eager alternative
7.1 Certifying combined answers
A Nelson–Oppen trace is a proof. Each step is a local entailment in one theory, from input literals and earlier steps. check_trace re-checks each step with code that shares nothing with the solvers:
- EUF steps by a naive congruence closure;
- LRA steps by Fourier–Motzkin, showing that and are both impossible.
On the slides’ example all 4 steps check. A combination proof is a chain of local proofs glued by shared equalities.
CDCL(T1, T2) answers (certify_combined):
-
UNSAT. Every theory lemma is re-checked in its own theory: naive closure, Fourier–Motzkin, or integer box enumeration. A lemma mixing theories would be rejected, and none occurs. The DRUP proof is checked with the interface clauses as input clauses. That is sound because each interface clause is valid in .
-
SAT. A combined model is built:
- each arithmetic variable gets the arithmetic solver’s value;
- each EUF class gets the value of a variable in it, or a fresh number;
- each function symbol gets a table.
The original formula is then evaluated. Different classes receive different values, so the tables are well defined.
7.2 The eager alternative: Ackermann’s reduction
ackermann_arith replaces each application by a fresh variable. For every two applications of the same it adds . What remains is pure arithmetic, for Lecture 11’s or 12’s solver.
A cross-check. It uses no EUF solver and no combination code. Script 03, Part 5:
| formulas × theories | SAT | UNSAT | same answer as Ackermann | certified |
|---|---|---|---|---|
| 200 | 96 | 104 | 200/200 | 200/200 |
Scaling on ping-pong(n), the family of §3.4:
| Nelson–Oppen solver calls | CDCL(T1, T2) interface clauses | conflicts | Ackermann constraints | |
|---|---|---|---|---|
| 2 | 26 | 6 | 5 | 6 |
| 3 | 219 | 28 | 14 | 15 |
| 4 | 772 | 66 | 28 | 28 |
| 5 | 1,877 | 120 | 47 | 45 |
All three methods answer UNSAT. The figure 03_combination_cost.png plots their CPU time.
Ackermann wins here because has only applications. With many applications the eager method’s quadratic constraints dominate, as in Lecture 10’s eager-versus-lazy comparison.
Why modular combination wins in general. It keeps every theory solver’s own strengths (congruence closure, simplex, bit-blasting), and it never blows the formula up.
8. Summary
- Mixed formulas. Formulas mix theories, and each solver alone over-approximates. The combined theory has as models the interpretations whose reducts are models of each theory. Its signatures share no function symbols.
- Purification names alien subterms by fresh variables, so the two halves share only variables.
- Nelson–Oppen checks each half and propagates entailed equalities between shared variables, in both directions, until a contradiction or a fixpoint. On the slides’ example: 4 steps, each independently checkable.
- Convexity makes propagation complete. The integers are not convex, so combination needs case splits. Model-based splitting needed one split on the slides’ example.
- The non-deterministic method tries Bell() arrangements: 877 for 7 shared variables. It is correct when both theories are stably infinite. A finite sort breaks it, and sharing every term of that sort repairs it.
- CDCL(T1, …, Tn) decides interface equalities in the SAT search and keeps theory reasoning local. With interface clauses , Nelson–Oppen’s exchange becomes unit propagation.
- Every answer is certified: per-theory lemma checks plus DRUP, or a combined model evaluated on the original formula. Ackermann’s reduction agrees on all 200 random cases.
9. Common pitfalls
- Checking the halves separately. Two satisfiable halves say nothing; the shared equalities are the whole point.
- Propagating in one direction only. The dialogue must reach a fixpoint on both sides.
- Forgetting non-convexity. Over the integers, bit-vectors or arrays, propagation alone answers SAT wrongly. Split, or let the SAT solver decide interface atoms.
- Combining a finite theory as if it were stably infinite. Cardinality must be shared too: share every term of the finite sort.
- Shared function symbols. The method assumes disjoint signatures. A symbol interpreted by both theories breaks the gluing argument.
- Counting only conflicts. The cost of combination is in the interface: pairs of shared variables, entailment tests, interface atoms.
10. Exercises
1. (purification) Purify . Which variables are shared?
Answer
The definitions. is arithmetic inside : . Then sits inside the arithmetic literal : . In the second literal, the equality is arithmetic (its right side is), and is alien there: . Inside it, is pure EUF and stays.
The halves.
- ;
- .
Shared. ; and occur only in . purify gives exactly this.
2. (Nelson–Oppen by hand) Decide with EUF + LRA. Write the trace.
Answer
The halves. Already pure: , , shared .
The trace.
- LRA ⊨ (because , ).
- EUF ⊨ ⊥ (because , ).
UNSAT, and check_trace verifies both steps.
3. (convexity) Show that LIA is not convex with , , , , . What does LRA entail?
Answer
Over the integers. , so is entailed, but neither nor is.
Over the reals. is possible, so even the disjunction is not entailed.
The oracles report: LRA entails none of the three; LIA entails only the disjunction.
4. (arrangements) For , list the arrangements of the shared variables. Which ones does each theory accept?
Answer
The arrangements. The shared variables are , so there are Bell(3) = 5 arrangements: all equal, , , , all different.
EUF accepts 4. It rejects only : gives , that is, .
LRA accepts 1. and force all three to be different.
Together. Only “all different” works for both: SAT. Nelson–Oppen needs no step at all (nothing is entailed). The certified combined model is , , , , .
5. (stable infiniteness) Is the theory with the single axiom stably infinite? Give literals on which Nelson–Oppen combines it wrongly with EUF.
Answer
Not stably infinite. Every model has exactly one element.
A failure. The EUF literal is satisfiable in EUF. The one-element theory receives no literal and no shared variable, so the combination says SAT. In the combination every two terms are equal, so it is UNSAT.
The repair. Share the terms and . The one-element theory then rejects the only arrangement EUF accepts.
6. (interface size) How many interface clauses does prepare_combined add for shared variables? Check the numbers 15 (slides’ example) and 120 (ping-pong(5)).
Answer
The count. One clause per unordered pair: .
The check. The slides’ example has 6 shared variables: . Ping-pong(5) has 16: .
7. (eager vs lazy) How many consistency constraints does Ackermann’s reduction add for one function symbol applied to distinct argument tuples? Check ping-pong(5).
Answer
The count. One constraint per pair of applications: .
The check. Ping-pong(5) applies to and , so , giving 45 constraints, the number printed by script 03.
8. (I-LEARN) In the slides’ non-convex example, which disjunction of interface equalities does I-LEARN add, and why is it valid in LIA? Why is it not valid in LRA?
Answer
The disjunction. , where and . On the slides it is the I-LEARN clause over the atoms numbered 4 (), 5 (), 11 () and 12 (), with 4 and 5 negated.
Why it holds in LIA. The only integers between 1 and 2 are 1 and 2.
Why not in LRA. falsifies it. The clause is exactly what makes the LIA branch of the trace work.
9. (programming) Replace the pairwise entailment tests of nelson_oppen for EUF by reading the classes of a congruence closure (smt.CongruenceClosure): every two shared variables in one class are entailed equal, with explain as premises. Compare the number of solver calls on ping_pong(n).
Answer sketch
The change. Assert into one CongruenceClosure. For each class, chain its shared variables (, , …). explain(u, v) gives the premises.
What to expect. EUF then costs one call per round instead of one per pair. LRA still tests pairs, unless equalities are read off tight bounds of the simplex tableau, so expect the total to shrink but keep growing with the number of pairs.
10. (programming) Make Pair model-based: drop the interface clauses. In check(final=True), compare the EUF classes with the arithmetic values of shared variables. If they disagree on a pair , return a conflict that forces a decision on .
Answer sketch
The difficulty. Lecture 10’s CDCL(T) cannot add new atoms during search, so the simplest version pre-registers the atoms without the clauses linking them. At the final check:
- if EUF and arithmetic disagree on a pair, return the clause for that pair only, as a lemma (it is valid);
- otherwise the models glue, and the answer is SAT.
What to expect. Only the pairs on which the models actually disagree get a clause, instead of all ; measure how many on the slides’ examples and on ping_pong(n). This is z3’s model-based theory combination.
11. Further reading
- D. Kroening, O. Strichman, Decision Procedures, 2nd ed., Sections 10.1–10.5 (theory combination).
- C. Tinelli, Combining Theories and Their Solvers, CS:4980 slides, University of Iowa, Spring 2024 (with Barrett, Trippel and Wu).
- G. Nelson, D. C. Oppen, “Simplification by Cooperating Decision Procedures”, ACM TOPLAS 1(2), 1979.
- D. C. Oppen, “Complexity, Convexity and Combinations of Theories”, Theoretical Computer Science 12, 1980.
- C. Tinelli, M. Harandi, “A New Correctness Proof of the Nelson–Oppen Combination Procedure”, FroCoS 1996.
- M. Bozzano, R. Bruttomesso, A. Cimatti, T. Junttila, S. Ranise, P. van Rossum, R. Sebastiani, “Efficient Satisfiability Modulo Theories via Delayed Theory Combination”, CAV 2005.
- L. de Moura, N. Bjørner, “Model-based Theory Combination”, ENTCS 198(2), 2008 (SMT 2007).
- S. Ranise, C. Ringeissen, C. G. Zarba, “Combining Data Structures with Nonstably Infinite Theories Using Many-Sorted Logic”, FroCoS 2005.
- D. Jovanović, C. Barrett, “Polite Theories Revisited”, LPAR 2010.
- C. Barrett, C. Tinelli, “Satisfiability Modulo Theories”, in Handbook of Model Checking, Springer 2018 (Section on combination).
12. Next lecture
Lecture 19: using formal verification for text-to-SQL. A guest lecture applies the course’s tools to queries written by language models.
- The question. When is a generated SQL query correct? Its semantics has bags (duplicates), NULLs and aggregation.
- The method. Encode small symbolic tables into a solver. Then ask whether two queries can differ on some database, and produce a tiny counterexample database when they can.
- The theories. The encoding mixes EUF, integers and Booleans, so today’s combination is what decides it.
See Lecture 19.