<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Proofs and Refutations, and Z3</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Leonardo de Moura</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nikolaj Bjørner Microsoft Research</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Rudnicki P</institution>
          ,
          <addr-line>Sutcliffe G., Konev B., Schmidt R., Schulz S.</addr-line>
          <institution>(eds.); Proceedings of the Combined KEAPPA - IWIL Workshops</institution>
          ,
          <addr-line>pp. 123-132</addr-line>
        </aff>
      </contrib-group>
      <fpage>123</fpage>
      <lpage>132</lpage>
      <abstract>
        <p>Z3 [3] is a state-of-the-art Satisfiability Modulo Theories (SMT) solver freely available from Microsoft Research. It solves the decision problem for quantifier-free formulas with respect to combinations of theories, such as arithmetic, bit-vectors, arrays, and uninterpreted functions. Z3 is used in various software analysis and test-case generation projects at Microsoft Research and elsewhere. The requirements from the user-base range from establishing validity, dually unsatisfiability, of firstorder formulas; to identify invalid, dually satisfiable, formulas. In both cases, there is often a need for more than just a yes/no answer from the prover. A model can exhibit why an invalid formula is not provable, and a proof-object can certify the validity of a formula. This paper describes the proof-producing internals of Z3. We also briefly introduce the model-producing facilities. We emphasize two features that can be of general interest: (1) we introduce a notion of implicit quotation to avoid introducing auxiliary variables, it simplifies the creation of proof objects considerably; (2) we produce natural deduction style proofs to facilitate modular proof re-construction.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        1. We define a notion of implicit quotation that allows us to encode a Tseitsin’ style clausification
without introducing auxiliary symbols. Other proof-producing SMT systems that we are aware of
[
        <xref ref-type="bibr" rid="ref18">18</xref>
        ], [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ], [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ], introduce auxiliary symbols (such as proxy literals) during clausification and
other transformations. Such symbols can impede optimizations in the theory solvers (we provide
an example in Section 3.3.2 where we can avoid introducing extra Simplex Tableaux rows) and
make proof re-construction more involved.
as we adapt a natural deduction style calculus. This contrasts with existing proof-producing SAT
solvers that generate resolution proofs directly [
        <xref ref-type="bibr" rid="ref10 ref21 ref6">10, 6, 21</xref>
        ]. We are obviously not the first to use
natural deduction in the context of SMT, for example, [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], investigates efficient proof checking of
natural deduction style proofs by implementing inference rules as rewrites.
3. We also do not attempt to specify all inference rules from a smaller set of axioms. Instead we rely
on proof checking to be able to carry out a limited set of inferences, or refine proofs in a separate
pass. This choice obviously reflects a trade-off between the requirements on the solver vs. the
proof checker. Our own experience has been that the coarse granularity has in fact been sufficient
in order to catch implementation bugs. Future work includes investigating whether this approach
is practical in the context of proof checkers based on trusted cores [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries</title>
      <sec id="sec-2-1">
        <title>Terms and Formulas</title>
        <p>Z3 uses basic multi-sorted first-order terms. Formulas are just terms of Boolean sort, and terms are built
by function application, quantification, and bound variables. Sorts range over a finite denumerable set of
disjoint primitive sorts. To summarize
s 2 Sorts ::=
t 2 Terms ::=</p>
        <p>Boolean j Int j Proof j : : :
f (t1; : : : ; tn)
x
8x : s : t j 9x : s : t
function application
bound variable
quantification
j
j
There a a few built-in sorts, such as Boolean, Int, Real, BitVec[n] (for each n, an n-bit bit-vector),
and Proof. The Proof sort is used for proof-terms. Terms can be annotated by pragmas. For example,
quantifiers are annotated with patterns that control quantifier instantiation. Function symbols can be both
interpreted and uninterpreted. For example, numerals are encoded using interpreted functions. Function
symbols also have attributes, such as to indicate whether they are associative and/or commutative. Note
that there are no binding operators other than universal and existential quantification. A number of
function symbols are built-in to the base theory. We will introduce the set of proof-constructing terms as
we explain their origination, but here let us summarize the main pre-declared function symbols. We use
the usual infix symbols ^; _; !; $ for Boolean conjunction, disjunction, implication and bi-implication.
For each sort s there is an equality relation ': s s ! Boolean. The relation : Boolean Boolean !
Boolean is used in proof terms. A proof of j y establishes that j is equisatisfiable with y. In
other words, if we close j and y by second-order existential quantification of all Skolem functions and
constants, we obtain equivalent formulas.
2.2</p>
      </sec>
      <sec id="sec-2-2">
        <title>Proof Terms</title>
        <p>Proof objects are also represented as terms. So a proof-tree is just a term where each inference rule is
represented by a function symbol. For example, consider the proof-rule for modus ponens:
.</p>
        <p>.. p
modus ponens y ! jj
.
.
. q
y
In the rule, p is a proof-term for y ! j, and q is a proof for y. The resulting proof-term for j is
then mp(p; q; j). We will later elaborate on the function symbols for building basic proof terms that are
available in Z3.</p>
        <p>Every proof term has a consequent, the formula that the proof establishes. It is always the last
argument in our proof terms. To access the consequent we will use the notation con(p). For example,
con(mp(p; q; j)) = j.
3
3.1</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Proofs</title>
      <sec id="sec-3-1">
        <title>Overview</title>
        <p>Z3 applies multiple stages when attempting to verify a formula. First formulas are simplified using a
repository of simplification rules. The result of simplification is then converted into an internal format
that can be processed by the solver core. We refer to this phase as internalization. The core comprises of
a SAT solver that performs Boolean search and a collection of theory solvers. The solver for equality and
uninterpreted function symbols (congruence closure) features predominantly as a theory solver in Z3 as
it dispatches constraints between the SAT solver and other theories.</p>
        <p>Input formula</p>
        <p>Simplifier (3.2)</p>
        <p>Internalizer (3.3)
SAT solver (3.4.1)</p>
        <p>Theory Core (3.4.2,3.4.3)</p>
        <p>As the figure illustrates, we will describe the various modules in the following sections, as we
introduce the proof terms that are produced as a side effect of the modules.</p>
        <p>
          The figure does not reflect the full extent of Z3. We will not be elaborating on proof objects for
non-ground formulas in this paper. Z3 does produce proof objects for non-ground formulas. The
required machinery introduces judgments stating equi-satisfiability of formulas. Furthermore, Z3 contains
a module that produces and integrates proofs in a superposition calculus [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ]. The proof terms are the
usual superposition inferences [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. That material is beyond the scope of this paper.
3.2
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>Simplification Rewriting</title>
        <p>In a first phase, formulas are simplified using a rewriting simplifier. The simplifier applies standard
simplification rules for the supported theories. For example, terms using the arithmetical operations,
both for integer, real, and bit-vector arithmetic, are normalized into sums of monomials. A single axiom
called rewrite is used to record the simplification steps.
rewrite(t ' s), rewrite(j $ y) A proof for a local rewriting step that converts t to s or j to y. The head
function symbol of t is interpreted. Sample instances of this proof object are: rewrite(x + 0 ' x),
rewrite(x + x ' 2 x), and rewrite((j _ false) $ j).</p>
        <p>Notice that we do not axiomatize the legal rewrites. Instead, to check the rewrite steps, we rely on a
proof checker to be able to apply similar inferences for the set of built-in theories: arithmetic, bit-vectors
and arrays.
3.3</p>
      </sec>
      <sec id="sec-3-3">
        <title>Internalization</title>
        <p>Internalization is the process of translating an arbitrary formula j into a normal form that can be
consumed by efficient proof-search procedures. We will discuss two internalizations: clausification and
conversion of arithmetical constraints into a format that can be processed using a global Simplex tableau.
Internalization often introduces auxiliary variables that are satisfiability preserving definitional
extensions of the original problem. We will introduce a simple, but apparently unrecognized, technique of
implicit quotation to allow us introducing these definitional extensions, but at the same time take
advantage of the fact that the auxiliary variables can be viewed directly as terms they are shorthand for. The
technique of implicit quotation makes the proof extraction process fairly direct.
3.3.1</p>
        <sec id="sec-3-3-1">
          <title>Clausification</title>
          <p>Tseitsin’s clausal form conversion algorithm can be formulated as a procedure that works by recursive
descent on a formula and produces a set of equi-satisfiable set of clauses. A simple conversion algorithm
introduces one fresh name for each sub-formula, and defines the name using the shape of the sub-formula.
We here recall the basic idea by converting and-or formulas into CNF.</p>
          <p>cnf (j) = let (`; F) = cnf 0(j) in ` ^ F
cnf 0(`) = (`; true)
cnf 0(:j) = let (`; F) = cnf 0(j) in (:`; F)
cnf 0(j ^ y) = let (`1; F1) = cnf 0(j); (`2; F2) = cnf 0(y) in</p>
          <p>
            (p; F1 ^ F2 ^ (:`1 _ :`2 _ p) ^ (:p _ `1) ^ (:p _ `2)) p is fresh
cnf 0(j _ y) = let (`1; F1) = cnf 0(j); (`2; F2) = cnf 0(y) in
(p; F1 ^ F2 ^ (`1 _ `2 _ :p) ^ (p _ :`1) ^ (p _ :`2)) p is fresh
` is a literal
More sophisticated CNF conversions that do not introduce fresh names for all sub-formulas exist [
            <xref ref-type="bibr" rid="ref14">14</xref>
            ].
They control the number of auxiliary literals and clauses introduced during clausification.
          </p>
          <p>Z3 does not introduce auxiliary predicates during internalization of quantifier-free formulas. Instead,
it re-uses the terms that are already used for representing the sub-formulas. Thus, instead of introducing
a fresh variable p, in the CNF conversion of j _ y, we treat the term j _ y as a literal. To clarify that a
sub-formula plays the roˆle of a literal below, we quote it. So the literal associated with j _ y is dj _ ye.
So the CNF conversion of j _ y produces the pair:</p>
          <p>(dj _ ye; F1 ^ F2 ^ (`1 _ `2 _ :dj _ ye) ^ (dj _ ye _ :`1) ^ (dj _ ye _ :`2))
It may appear that we need to justify the auxiliary clauses (`1 _ `2 _ :dj _ ye), (dj _ ye _ :`1), and
(dj _ ye _ :`2) by appealing to the equi-satisfiablility, but the justification for these clauses happens in
fact to directly use equivalence. First note that it follows by induction on the clausification algorithm
that `1 is equivalent to j and `2 is equivalent to y. Each of the auxiliary clauses introduced during
clausification is therefore justified as propositional tautologies. Only limited propositional reasoning is
required to justify these. The proof terms corresponding to the auxiliary clauses are tagged as definitional
axioms. For example, the axiom dj _ ye _ :j is represented by the term def axiom((j _ y) _ :j).</p>
          <p>We introduced quotation here to clarify in which context logical connectives were to be used. Our
implementation in Z3 does not use quotation at all.
3.3.2</p>
        </sec>
        <sec id="sec-3-3-2">
          <title>Arithmetic</title>
          <p>
            Implicit quotation is also used when introducing auxiliary variables for theories, such as the theory for
linear arithmetic. Let us recall how the Simplex solver in Z3 works. Following [
            <xref ref-type="bibr" rid="ref5">5</xref>
            ], a theory solver for
linear arithmetic, and integer linear arithmetic can be based on a Simplex Tableau of the form:
where B and N denote the set of basic and nonbasic variables, respectively. The sets B and N are
assumed disjoint, and each basic variable occurs in exactly one row. Thus, the values of basic variables
are determined by the values of the non-basic variables. In addition to this tableau, the solver state stores
upper and lower bounds li and ui for every variable xi and a mapping b that assigns a rational value
b (xi) to every variable xi. The bounds on nonbasic variables are always satisfied by b , so the following
invariant is maintained by the tableau operations
xi '
          </p>
          <p>å
xj2N</p>
          <p>ai jx j xi 2 B;
8x j 2 N ; l j
b (x j)</p>
          <p>u j:
8x j 2 B; l j
b (x j)
u j:
(1)
(2)
(3)
(4)
(5)
(6)
(7)
A tableau is satisfied if the same inequalities hold for the basic variables:
Bounds constraints for basic variables are not necessarily satisfied by b , so for instance, it may be the
case that li &gt; b (xi) for some basic variable xi, but pivoting steps can be used to fix bounds violations, or
detect an unsatisfiable tableau.</p>
          <p>Formally, Simplex-based solvers for linear arithmetic can interface with Boolean combinations of
inequalities by introducing one slack variable and a tableau row for every (maximal) linear arithmetic
sub-term in a formula. For example, it is by now common for SMT solvers to transform problems of the
form:
sup(ar) :=
inf(ar) :=</p>
          <p>å
xj2N +</p>
          <p>å
xj2N +
ar ju j +
ar jl j +</p>
          <p>å
xj2N</p>
          <p>å
xj2N
ar jl j
ar ju j
to the following equi-satisfiable formula:
[(x + y &gt; 2) ^ (2x y &lt; 2)] _ [( f (z + x)</p>
          <p>5) ^ z &lt; 3]
[(s1 &gt; 2) ^ (s2 &lt; 2)] _ [( f (s3)</p>
          <p>
            5) ^ z &lt; 3]
^ s1 ' x + y ^ s2 ' 2x y ^ s3 ' z + x
The definitions for the slack variables translate into rows in a Simplex tableau. If we represent s1 by the
quotation dx + ye, and s2 by d2x ye, and s3 by dz + xe, we observe directly that the additional equalities
are tautologies and therefore have trivial justifications. Furthermore, all Simplex tableau operations,
including pivoting, are equivalence preserving (pivoting replaces equals for equals, and divides rows
by constants), so the justifications for the Simplex rows remains a matter of expanding quotations and
checking equalities using linear arithmetic. The above observation can be used to reconstruct proofs from
unsatisfiable tableaux in a direct manner. In contrast, [
            <xref ref-type="bibr" rid="ref2">2</xref>
            ] proposed an encoding of arithmetical constraints
by introducing slack variables for potentially every arithmetical subterm (including potentially a slack
variable for z in z &lt; 3). The slack variables allowed for tracking explanations and extracting proofs from
infeasible tableaux.
          </p>
          <p>We now explain how proofs are extracted from unsatisfiable tableaux without modifying the
translation phase. With a tableau row of the form (1) associate the suprema and infima of implied by the
coefficients, namely, let ar be the coefficients from the row and l j and u j be the lower and upper bounds
that are asserted by the literals x j u j and l j x j, then:
where N = fx j j ar j &lt; 0g, and N + = fx j j ar j &gt; 0g; and as usual, we set sup(ar) = ¥ if either some
x j 2 N +, u j = ¥, or for some x j 2 N , l j = ¥.</p>
          <p>Then an unsatisfiable tableau can be identified by an infeasible row r, where
ur &lt; inf(ar) and xr
ur is asserted, or lr &gt; sup(ar) and lr
xr is asserted:</p>
          <p>Corresponding to an infeasible row, we can extract a theory conflict by accumulating the bounds that
were used to derive a contradiction. So for example, in case of ur &lt; inf(xr), the conflict clause is of the
form
:(xr
ur) _
:(l j</p>
          <p>x j) _
_
xj2N +</p>
          <p>_
xj2N
:(x j
u j)
(8)
(9)
It is now simple to prove the conflict clause:
xr ' åxj2N ar jx j
lr1</p>
          <p>xr1; xr1 2 N +
xr
(åxj2N ar jx j) ar1xr1 + ar1lr1
xr
(åxj2N ar jx j) ar1xr1 + ar1lr1
xr2</p>
          <p>ur2; xr2 2 N
ar2xr2 + ar2ur2</p>
          <p>: : :
xr</p>
          <p>inf(ar)
lemma
:(xr</p>
          <p>W
ur) _ xj2N + :(l j
?
x j) _ W
xj2N
xr</p>
          <p>ur
:(x j
u j) (9)
The left-most antecedent is a tautology in the theory of linear arithmetic, the other antecedents are
hypotheses. The lemma inference rule collects (see Section 3.4) the disjunction of the negated hypotheses
used for deriving ?. The intermediary inferences correspond to basic inequality propagation. Our
implementation in Z3 only produces the theory lemma directly without listing the equality corresponding
to the infeasible row.
3.4</p>
        </sec>
      </sec>
      <sec id="sec-3-4">
        <title>Modular Proofs</title>
        <p>A basic underlying principle for composing and building proofs in Z3 has been to support a modular
architecture that works well with theory solvers that receive literal assignments from other solvers and
produce contradictions or new literal assignments. The theory solvers should be able to produce
independent and opaque explanations for their decisions.</p>
        <p>Conceptually, each solver acts upon a set of hypotheses and produce a consequent. The basic
proofrules that support such an architecture can be summarized as: hypothesis, that allow introducing an
assumption, lemma, that eliminates hypotheses, and unit resolution that handles basic propagation. We
say that a proof-term is closed when every path that ends with a hypothesis contains an application of
rule lemma. If a term is not closed, it is open. To summarize, these core rules are:
hypothesis(j) Mark j as a hypothesis. The resulting proof term is open.
lemma(p; :j1 _ : : : _ :jn) The proof term has one antecedent p such that con(p) = false, but p is open
with hypotheses j1; : : : ; jn. The resulting proof term is closed.
unit resolution(p0; p1; : : : ; pn; y1 _ : : : _ ym) Where con(p0) = j1 _ : : : _ jn _ y1 _ : : : _ ym, con(p1) =
:j1; : : : con(pn) = :jn.</p>
        <p>We will next describe how these rules integrate within a DPLL(T ) architecture.
3.4.1</p>
        <sec id="sec-3-4-1">
          <title>Proofs from DPLL(T )</title>
          <p>
            The propositional inference engine in Z3 is based on a DPLL(T ) architecture. We refer to [
            <xref ref-type="bibr" rid="ref13">13</xref>
            ] for an
exposition on a basic introduction on DPLL(T ) as a transition system. The main points we will use is
that DPLL(T ) maintains a state of the form M jj F during search, where M is a partial assignment of
the atomic predicates in the formula F. Furthermore, we assume F is in conjunctive normal form. The
search keeps assigning atoms in M based on unit propagation, theory propagation (for example x &gt; 3
implies that x &gt; 0 by the theory of arithmetic), and guesses (also called decisions) until either it reaches
a state where the assignment satisfies all clauses in F, or some clause in F contradicts the assignment in
M.
          </p>
          <p>
            The DPLL(T ) proof search method lends itself naturally to producing resolution style proofs.
Systems, such as zChaff, and a version of MiniSAT [
            <xref ref-type="bibr" rid="ref10 ref21 ref6">10, 6, 21</xref>
            ], produce proof logs based on logging the
unit propagation steps as well as the conflict resolution steps. The resulting log suffices to produce a
propositional resolution proof. This approach works even though the SAT solver can choose to restart or
garbage collect learned conflict clauses that were produced during search.
          </p>
          <p>The approach taken in Z3 bypasses logging, and instead builds proof objects during conflict
resolution. With each clause we attach a proof. Clauses that were produced as part of the input have proofs
that were produced from the previous steps. A clause that is produced during conflict resolution depends
on some state of the partial model M. In particular, the learned clause is contradictory with some
subset of the decision literals in M, either directly because the learned clause contains decision literals, or
because the learned clause contains a literal that was obtained by propagation. Given a conflict clause
C : `1 _ `2 _ : : : _ `n, we build a proof term of the form lemma(p; `1 _ `2 _ : : : _ `n), where p is constructed
by examining the justifications for :`1; : : : ; :`n. If :`i is a decision literal, then the justification for :`i
is a term hypothesis(:`i). If :`i was inferred by unit propagation (so there is a fact :`i in M, with
justification C _ :`i), then it is proved using unit-resolution and the justification for the clause C _ :`i.</p>
          <p>We see that this approach does not require logging resolution steps for every unit-propagation, but
delays the analysis of which unit propagation steps are useful until conflict resolution. The approach also
does not produce a resolution proof directly. It produces a natural deduction style proof with hypotheses.</p>
          <p>Other propositional rules that are used during proof-reconstruction are:
asserted(j) The formula j is a user-supplied assumption.
goal(j) The formula j is a user-supplied goal. A goal is symmetric to asserted, but allows retaining
the distinction between goals and assumptions in proof objects.
mp(p; q; j) Proof of j by modus ponens. Assume that con(p) = y and that con(q) is either y ! j
or y $ j. The latter form is used extensively in the simplifier to apply equivalence-preserving
simplification steps.
3.4.2</p>
        </sec>
        <sec id="sec-3-4-2">
          <title>Congruence Proofs</title>
          <p>
            In Z3, the congruence closure implementation is tightly integrated with the Boolean satisfiability core.
It serves as a main hub for equality propagation. The efficient extraction of minimal justifications for
congruence closure proofs has been studied extensively, [
            <xref ref-type="bibr" rid="ref11">11</xref>
            ]. We here summarize the proof objects that
are extracted from the justifications.
          </p>
          <p>The theory of equality can be captured by axioms for reflexivity, symmetry, transitivity, and
substitutivity of equality. We encode these axioms as inference rules, and furthermore only specify that these
inference rules apply for any binary relation that is reflexive, symmetric, transitive, and/or
reflexivemonotone. We use the terminology, reflexive-monotone, for relations that are reflexive and monotone in
a given function symbol f . In particular, the relation (from Section 2.1) is also an equivalence relation,
and reflexive-monotone over conjunction and disjunction. So the rules are:
refl(R(t;t)) A proof for R(t;t), where R is a reflexive relation.
symm(p; R(t; s)) A proof of R(t; s), where R is a symmetric relation, and con(p) = R(s;t).
trans(p; q; R(t; s)) A proof of R(t; s), where R is transitive, and con(p) = R(t; u) and con(q) = R(u; s).
monotonicity(p1; ::; pn; R( f (t1; ::; tn); f (s1; ::; sn))) A proof of R( f (t1; ::; tn); f (s1; ::; sn)), where
con(p1) = R(t1; s1), : : : ; con(pn) = R(tn; sn), and R is reflexive and monotone in f . The
antecedent pi can be suppressed if ti = si. That is, reflexivity proofs are suppressed to save space.</p>
          <p>Our congruence closure core maintains a congruence table. A congruence table enables propagation
of equalities over function symbols, so that for example if f (s;t) is a term, and s0 is equal to s, then when
creating f (s0;t) it is detected that the potentially new term is in the same congruence class as f (s;t). The
implementation also treats equality as a function, and every equality is also inserted to the congruence
table. This makes detecting implied dis-equalities simple: given two terms s and t, search the congruence
table for an existing entry for s ' t. If the table contains such a literal, then check if the literal is assigned
to false. To make this use of the congruence table effective it understands commutative operations, such
as equality. This implicit use of commutativity gets reflected in the generated proof terms, and we include
a special rule for commutative functions. It can be instantiated for equalities.
comm( f (s;t) ' f (t; s)), comm( f (s;t) $ f (t; s)) where f is a commutative function (relation).
3.4.3</p>
        </sec>
        <sec id="sec-3-4-3">
          <title>Theory lemmas</title>
          <p>In the DPLL(T ) architecture, decision procedures for a theory T identify sets of asserted T -inconsistent
literals. Dually, the disjunction of the negated literals are T -tautologies. Consequently, proof terms
created by theories can be summarized using a single form, here called Theory lemmas.
th lemma(p1; : : : ; pn; j) Generic proof rule for theory lemmas. The formula con(p1) ^ : : : ^ con(pn) !
j should be a T -tautology.
3.5</p>
        </sec>
      </sec>
      <sec id="sec-3-5">
        <title>Applications</title>
        <p>
          Z3 with proofs is still under development and has not been released yet. An obvious current application
is that proofs offer a simple litmus test on the implementation for soundness bugs. We integrate a simple,
but partial (it does not check T -lemmas) proof-checker in Z3 for this purpose. A much more effective
strategy for debugging bugs in theory solvers has been to dump the T -lemmas as they are produced.
Similar to [
          <xref ref-type="bibr" rid="ref20">20</xref>
          ], we can then apply an independent solver (namely, our previous version of Z3) on the
T -lemmas. We found this approach very effective in debugging optimizations that turned out to be
unsound.
        </p>
        <p>We also have a facility for displaying proof-terms, but the proof term visualization very easily
becomes too large to be of any use.</p>
        <p>
          In future applications, we envision applications of proofs in Z3, such as: Proof-mining [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ]; can
proofs be mined for strategies that are helpful for speeding up proofs for a class of problems?
Interpolation. Proof visualization. Finally, in the context of Isabelle/HOL, it has been suggested [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] to translate
HOL formulas (which use polymorphism), into first-order untyped formulas. A potentially unsound
translation is then run through first-order provers, but the produced proofs (currently apparently only
Prover9), can be checked for whether they use inferences that contradict the types.
3.6
        </p>
      </sec>
      <sec id="sec-3-6">
        <title>The overhead of enabling proofs</title>
        <p>We benchmarked proof generation on a few selected, but non-trivial examples from SMT-LIB. The
samples show a memory overhead of between 3x-40x, and corresponding slowdowns of 1.1x to 3x.
Benchmark
NEQ016 size7
PEQ010 size8
fischer6-mutex-14
cache.inv16
xs 20 40</p>
        <p>Without Proofs
26.01 secs 9.1 MB
6.65 secs 9.3 MB
7.01 secs 14 MB
15.99 secs 11 MB
2.2 secs 5.8 MB</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Models</title>
      <p>We will very briefly summarize the model generation features in Z3. More material is available on-line
on http://research.microsoft.com/projects/z3/models.html.</p>
      <p>Z3 has the ability to produce models as part of its output. Models assign values to the constants in
the input and generate finite or partial function graphs for predicates and function symbols.</p>
      <p>A model comprises of a set of partitions, each partition is printed as: *k, where k is a non-negative
number. Each partition is associated with a set of constants from the input, and is associated with a
concrete value. A concrete value can be either a Boolean (true or false), a numeral (with type Int, Real,
or BitVec[n]), an array (represented as a finite map), a tuple (represented by a constructor and sequence
of values for the fields), or an an uninterpreted ur-element. Ur-elements are internally represented as
natural number numerals, but with an uninterpreted type.</p>
      <p>By default Z3, produces a full (and compact) interpretation for free functions. There is an option to
force Z3 to not assign interpretations to functions when their values don’t influence the truth assignment
to the formula.</p>
      <p>
        Z3 version 2 integrates a superposition theorem prover [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. When it is able to finitely saturate the
set of non-ground input clauses, it can also report that the non-ground formula that was provided is
satisfiable, but there are no other mechanisms for extracting additional information from the saturated
set of clauses.
4.1
      </p>
      <sec id="sec-4-1">
        <title>Applications</title>
        <p>
          Models are by now used in a number of Z3 clients. The main clients that use models are the program
exploration and test-case generation tools Pex and SAGE (we refer to [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] for all pointers). They extract
symbolic path conditions by monitoring program executions and use Z3 to find alternate inputs that
can guide the next execution into a different branch. Models are also used for improved debugging
feedback from Spec# and for iterative counter-example guided refinement in the context of bounded
model checking of model programs.
        </p>
        <p>We also believe that the availability of models can in future applications play a useful role in the
context of model-based quantifier instantiation and integrating external decision procedures with Z3.
5</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Conclusions</title>
      <p>We presented the proof and model generation facilities in Z3. Models have already shown particular
usefulness in the context of SMT applications. Proofs will be available in Z3 v2, and we hope, in light
of this introduction, that users will be able to find useful applications of the feature.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Aaron</given-names>
            <surname>Stump</surname>
          </string-name>
          and
          <string-name>
            <given-names>Duckki</given-names>
            <surname>Oe</surname>
          </string-name>
          .
          <article-title>Towards an SMT Proof Format</article-title>
          . In 6'th International Workshop on SMT,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Alessandro</given-names>
            <surname>Cimatti</surname>
          </string-name>
          , Alberto Griggio, and
          <string-name>
            <given-names>Roberto</given-names>
            <surname>Sebastiani</surname>
          </string-name>
          .
          <article-title>Efficient Interpolant Generation in Satisfiability Modulo Theories</article-title>
          .
          <source>In Ramakrishnan and Rehof [15]</source>
          , pages
          <fpage>397</fpage>
          -
          <lpage>412</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3] Leonardo de Moura and Nikolaj Bjørner.
          <article-title>Z3: An Efficient SMT Solver</article-title>
          .
          <source>In Ramakrishnan and Rehof</source>
          [
          <volume>15</volume>
          ].
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4] Leonardo de Moura and
          <string-name>
            <given-names>Nikolaj</given-names>
            <surname>Bjørner</surname>
          </string-name>
          . Engineering DPLL(T) +
          <article-title>Saturation</article-title>
          . In IJCAR'
          <volume>08</volume>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Bruno</given-names>
            <surname>Dutertre</surname>
          </string-name>
          and Leonardo de Moura.
          <article-title>A Fast Linear-Arithmetic Solver for DPLL(T)</article-title>
          .
          <source>In CAV'06, LNCS 4144</source>
          , pages
          <fpage>81</fpage>
          -
          <lpage>94</lpage>
          . Springer-Verlag,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Niklas</given-names>
            <surname>Ee</surname>
          </string-name>
          <article-title>´n and Niklas So¨rensson. An Extensible SAT-solver</article-title>
          .
          <source>In Enrico Giunchiglia and Armando Tacchella</source>
          , editors,
          <source>SAT</source>
          , volume
          <volume>2919</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>502</fpage>
          -
          <lpage>518</lpage>
          . Springer,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Imre</given-names>
            <surname>Lakatos</surname>
          </string-name>
          .
          <source>Proofs and Refutations</source>
          . Cambridge University Press,
          <year>1976</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Jia</given-names>
            <surname>Meng</surname>
          </string-name>
          and Lawrence C.
          <article-title>Paulson. Translating Higher-Order Clauses to First-Order Clauses</article-title>
          .
          <source>J. Autom. Reasoning</source>
          ,
          <volume>40</volume>
          (
          <issue>1</issue>
          ):
          <fpage>35</fpage>
          -
          <lpage>60</lpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>Michal</given-names>
            <surname>Moskal</surname>
          </string-name>
          .
          <article-title>Rocket-Fast Proof Checking for SMT Solvers</article-title>
          .
          <source>In Ramakrishnan and Rehof [15]</source>
          , pages
          <fpage>486</fpage>
          -
          <lpage>500</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Matthew</surname>
            <given-names>W.</given-names>
          </string-name>
          <string-name>
            <surname>Moskewicz</surname>
            , Conor F. Madigan,
            <given-names>Ying</given-names>
          </string-name>
          <string-name>
            <surname>Zhao</surname>
            ,
            <given-names>Lintao</given-names>
          </string-name>
          <string-name>
            <surname>Zhang</surname>
            , and
            <given-names>Sharad</given-names>
          </string-name>
          <string-name>
            <surname>Malik</surname>
          </string-name>
          . Chaff:
          <article-title>Engineering an efficient sat solver</article-title>
          .
          <source>In DAC</source>
          , pages
          <fpage>530</fpage>
          -
          <lpage>535</lpage>
          . ACM,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Robert</surname>
            <given-names>Nieuwenhuis and Albert</given-names>
          </string-name>
          <string-name>
            <surname>Oliveras</surname>
          </string-name>
          .
          <article-title>Proof-Producing Congruence Closure</article-title>
          . In Ju¨rgen Giesl, editor,
          <source>RTA</source>
          , volume
          <volume>3467</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>453</fpage>
          -
          <lpage>468</lpage>
          . Springer,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <surname>Robert</surname>
            <given-names>Nieuwenhuis and Albert</given-names>
          </string-name>
          <string-name>
            <surname>Rubio</surname>
          </string-name>
          .
          <article-title>Paramodulation-Based Theorem Proving</article-title>
          .
          <source>In Robinson and Voronkov [16]</source>
          , pages
          <fpage>371</fpage>
          -
          <lpage>443</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <surname>Roberto</surname>
            <given-names>Niewenhuis</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Albert</given-names>
            <surname>Oliveras</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Cesare</given-names>
            <surname>Tinelli</surname>
          </string-name>
          .
          <article-title>Solving SAT and SAT modulo theories: From an abstract Davis-Putnam-Logemann-Loveland procedure to DPLL(T)</article-title>
          .
          <source>Journal of the ACM</source>
          ,
          <volume>53</volume>
          (
          <issue>6</issue>
          ):
          <fpage>937</fpage>
          -
          <lpage>977</lpage>
          ,
          <year>November 2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>Andreas</given-names>
            <surname>Nonnengart</surname>
          </string-name>
          and
          <string-name>
            <given-names>Christoph</given-names>
            <surname>Weidenbach</surname>
          </string-name>
          .
          <article-title>Computing small clause normal forms</article-title>
          .
          <source>In Robinson and Voronkov [16]</source>
          , pages
          <fpage>335</fpage>
          -
          <lpage>367</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>C. R.</given-names>
            <surname>Ramakrishnan</surname>
          </string-name>
          and Jakob Rehof, editors.
          <source>Tools and Algorithms for the Construction and Analysis of Systems, 14th International Conference, TACAS</source>
          <year>2008</year>
          ,
          <article-title>Held as Part of the Joint European Conferences on Theory and Practice of Software</article-title>
          ,
          <source>ETAPS</source>
          <year>2008</year>
          , Budapest, Hungary, March 29-April 6,
          <year>2008</year>
          . Proceedings, volume
          <volume>4963</volume>
          of Lecture Notes in Computer Science. Springer,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16] John Alan Robinson and Andrei Voronkov, editors.
          <source>Handbook of Automated Reasoning (in 2 volumes)</source>
          .
          <article-title>Elsevier and</article-title>
          MIT Press,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>S.</given-names>
            <surname>Schulz</surname>
          </string-name>
          .
          <article-title>Learning Search Control Knowledge for Equational Theorem Proving</article-title>
          . In F. Baader, G. Brewka, and T. Eiter, editors,
          <source>Proc. of the Joint German/Austrian Conference on Artificial Intelligence (KI-2001)</source>
          , volume
          <volume>2174</volume>
          <source>of LNAI</source>
          , pages
          <fpage>320</fpage>
          -
          <lpage>334</lpage>
          . Springer,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <surname>Aaron</surname>
            <given-names>Stump</given-names>
          </string-name>
          , Clark W. Barrett,
          <string-name>
            <given-names>and David L.</given-names>
            <surname>Dill</surname>
          </string-name>
          .
          <article-title>Producing proofs from an arithmetic decision procedure in elliptical lf</article-title>
          .
          <source>Electr. Notes Theor. Comput. Sci.</source>
          ,
          <volume>70</volume>
          (
          <issue>2</issue>
          ),
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <surname>Aaron</surname>
            <given-names>Stump and David L.</given-names>
          </string-name>
          <string-name>
            <surname>Dill</surname>
          </string-name>
          .
          <article-title>Faster Proof Checking in the Edinburgh Logical Framework</article-title>
          . In Andrei Voronkov, editor,
          <source>CADE</source>
          , volume
          <volume>2392</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>392</fpage>
          -
          <lpage>407</lpage>
          . Springer,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          [20]
          <string-name>
            <given-names>Geoff</given-names>
            <surname>Sutcliffe. Semantic Derivation</surname>
          </string-name>
          <article-title>Verification: Techniques and Implementation</article-title>
          .
          <source>International Journal on Artificial Intelligence Tools</source>
          ,
          <volume>15</volume>
          (
          <issue>6</issue>
          ):
          <fpage>1053</fpage>
          -
          <lpage>1070</lpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          [21]
          <string-name>
            <given-names>Tjark</given-names>
            <surname>Weber</surname>
          </string-name>
          and
          <string-name>
            <given-names>Hasan</given-names>
            <surname>Amjad</surname>
          </string-name>
          .
          <article-title>Efficiently checking propositional refutations in HOL theorem provers</article-title>
          .
          <source>Journal of Applied Logic</source>
          ,
          <year>July 2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          [22]
          <string-name>
            <given-names>Yeting</given-names>
            <surname>Ge</surname>
          </string-name>
          and
          <string-name>
            <given-names>Clark</given-names>
            <surname>Barrett</surname>
          </string-name>
          .
          <article-title>Proof Translation and SMT-LIB Benchmark Certification: A Preliminary Report</article-title>
          . In 6'th International Workshop on SMT,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>