In the next section, we present a criterion which, given a set of term constraints, indi- cates for which symbols negative constants do not lead to any additional power in combi- nation with the approximations from Definition 3.5. This way, especially transformational approaches to solving SMT-NIA instances such as the SAT encoding of [FGM+07, EWZ08] or the SMT-LIA encoding of [BLO+12] benefit. The reason is that the increased search space does not need to be represented explicitly on symbolic level (i.e., the encodings become smaller), and the actual search starts earlier.
3.3 A Necessary Criterion for Negative Constants
Consider again the term constraint (3.4)
BITS(s(x)) BITS(half(s(x))) (3.4)
from Example 3.1. The reason that we can successfully apply the interpretation [·]A with
a negative constant in [half]A(x1) = max(x1−1, 0) from Example 3.2 is that the argument
of half (i.e., s(x)) is always interpreted as a value which is > 0 (i.e., [s(x)]A = x + 1).
This way, the interpretation of the argument s(x) compensates for the negative constant of [half]A(x1) = max(x1− 1, 0). Therefore, and since moreover the sum of [s(x)]A = x + 1
and the negative constant−1 from [half]A(x1) is non-negative, for the term t = half(s(x))
the approximation [t]rightA = (x + 1) − 1 = x is identical to the actual interpretation [t]A = max(max(x + 1, 0)− 1, 0) = max( (x + 1) − 1, 0) = max(x, 0) = x.
In contrast, consider again the term constraints from Example 2.14:
HALF(s(s(x))) HALF(x) (2.10) BITS(s(s(x))) HALF(x) (2.11) BITS(s(s(x))) BITS(s(half(x))) (2.12) half(0) % 0 (2.13) half(s(0)) % 0 (2.14) half(s(s(x))) % s(half(x)) (2.15)
Note that here we have no right-hand side of a term constraint where half is applied to a term that is always interpreted as a positive value. The only occurrences of half are in (2.12) and (2.15) in the subterm half(x). Since x can also take the value 0, also the approximation [half(x)]rightA = x cannot benefit from the negative constant of [half]A(x1) =
max(x1− 1, 0). In contrast, for the left-hand side of a term constraint, it is beneficial to
use interpretations which map to high values. So we might as well use an interpretation [half](x1) = x1 for the term constraints from Example 2.14 (which is the interpretation
Also for the automation via parametric interpretations of Definition 3.8, it would be good if the search space could be restricted right from the start such that, e.g., for the constraints from Example 2.14, one would not try to search for negative values for the constant addend of [half] in the first place. This way, we can achieve an additional speed-up for the automation by omitting an infeasible part of the search space. This is especially important since the current state of the art of SMT-solving for non-linear integer arithmetic uses encoding-based approaches like bit-blasting to SAT [FGM+07, EWZ08] or
translations to SMT-LIA [BLO+12]. In both cases, each additional value for some variable
that must be considered for the search space leads to an increase of the size of the problem instance and also to an increase in encoding time. So even if the back-end solving engine should recognize early during the exploration of the search space that negative values are infeasible for certain parameters of the interpretation, we would nonetheless unnecessarily lose time while constructing the input for the solver.
Generalizing from these observations, we can now state a general criterion for applica- bility of negative constants. It is based on the notion of potentially negative symbols for a term t, i.e., symbols where an interpretation with a negative constant could be helpful. Definition 3.10 (Potentially Negative Symbols). For a term t we define its potentially negative symbols N (t) as
• N (x) = ∅ for every variable x and
• N (f(t1, . . . , tn)) = S 1≤i≤n N (ti) ∪ {f} if F({t1, . . . , tn}) \ {f} 6= ∅ S 1≤i≤n N (ti) otherwise
For a set of terms T its potentially negative symbols are N (T ) = St∈T N (t).
Note that we do not consider a symbol f to be potentially negative for t only because of a subterm s = f (t1, . . . , tn) of t where only the symbol f itself and variables occur in s. For
example, consider a term t =g(f(f(x))). Here we get N (x) = N (f(x)) = N (f(f(x))) = ∅. Moreover, we get N (t) = {g} since F({f(f(x))}) \ {g} = {f} 6= ∅.
Now consider the subterm s = f(f(x)). If we use a polynomial interpretation [·]A
with a negative constant for the interpretation of f, i.e., [f]A(x1) = max(p0(x1), 0) where
con(p0) < 0, then we also have [f(x)] right
A = ncon(f([x] right
A )) and thus con([f(x)] right
A ) =
con(ncon(f([x]rightA ))) = 0. Together with the negative constant con(p0) for f, we have
con(p0([f(x)]rightA )) < 0, which yields con([s] right
A ) = 0 again. Thus, here we could as well
use an interpretation [·]B where [f]B(x1) = max(ncon(p0(x1)), 0), i.e., an interpretation
where the constant for f is 0. This would yield [s]rightA = [s]rightB = 0.
Based on this notion of potentially negative symbols, we now state a criterion for considering negative constants for certain function symbols, and we prove that it is a necessary criterion. In other words, we do not lose any power if we restrict the search
3.3. A Necessary Criterion for Negative Constants 49
space for the constant of the interpretation for these function symbols to non-negative numbers.
Consider an automation for polynomial interpretations with negative constants where the approximations of Definition 3.5 are used to check if a term constraint `(%)r holds (` % r and ` r can be treated analogously). For term constraints `1(%)r1∧. . .∧`n(%)rn
it then suffices to consider negative constants for symbols f ∈ N ({r1, . . . , rn}). Formally:
Theorem 3.11 (Necessary Criterion for Negative Constants). Let [·]A be a polynomial
interpretation with negative constants where Definition 3.5 is applicable (i.e., for each f ∈ F, we have [f]A(x1, . . . , xn) = max(pf(x1, . . . , xn), 0) where pf(x1, . . . , xn) is weakly
monotonic on Z).
Moreover, let [`1]leftA (≥)[r1] right
A ∧. . .∧[`n]leftA (≥)[rn] right
A hold. Let [·]B be defined as follows:
• [f]B = ncon(pf), if f /∈ N ({r1, . . . , rn}), [f]A = max(pf, 0), and 0 > con(pf),
• [f]B = [f ]A, otherwise.
Here pf(x1, . . . , xn) is a polynomial with a possibly negative constant. Then also the
polynomial constraint [`1]leftB (≥)[r1] right
B ∧ . . . ∧ [`n]leftB (≥)[rn] right
B holds.
Proof. As in the proof of Theorem 3.9, we write “for t we have p1A . . . ” to denote that with the interpretation [·]A, the polynomial p1 of Definition 3.5 or Definition 3.8 for t is
p1A (analogously for p2).
Without loss of generality, assume that [`1]leftA ≥ [r1]rightA ∧ . . . ∧ [`n]leftA ≥ [rn]rightA holds.
This is not a restriction since on N we can express x > y equivalently as x ≥ y + 1. Let [·]A, [·]B be defined as above. To prove the theorem, we now show the following stronger
claims:
(i) For all t∈ T (F, V), we have • [t]left B ≥ [t] left A and • ncon([t]left B ) = 0 iff ncon([t] left A ) = 0.
(ii) For all subterms r of any term in {r1, . . . , rn}, we have [r] right A = [r]
right B
We prove Claim (i) by induction over the structure of t. If t is a variable, we have [t]leftB = t≥ t = [t]leftA . Moreover, we have both ncon([t]leftB ) = t6= 0 and ncon([t]leftA ) = t6= 0.
Now let t = f (t1, . . . , tn). Then by the induction hypothesis we have for 1 ≤ i ≤ n:
[ti]leftB ≥ [ti]leftA and ncon([ti]leftB ) = 0 iff ncon([ti]leftA ) = 0. There are two cases to consider:
(a) [f ]A(x1, . . . , xn) = [f ]B(x1, . . . , xn) = max(p0(x1, . . . , xn), 0)
(b) [f ]A(x1, . . . , xn) = max(p0(x1, . . . , xn), 0), [f ]B(x1, . . . , xn) = ncon(p0(x1, . . . , xn)),
We only give the proof for Case (a); the proof for Case (b) is analogous. So let [f ]A(x1, . . . , xn) = [f ]B(x1, . . . , xn) = max(p0(x1, . . . , xn), 0).
By the induction hypothesis and by monotonicity of p0 on Z, we have:
p1B = p0([t1]leftB , . . . , [tn]leftB )≥ p0([t1]leftA , . . . , [tn]leftA ) = p1A (3.17)
We now show that also the following property of p1 holds:
ncon(p1B) = 0 iff ncon(p1A) = 0 (3.18)
In the following, we call a function p(x1, . . . , xn) independent from its ith argument iff
for all v1, . . . , vn, w we have p(v1, . . . , vi, . . . , vn) = p(v1, . . . , w, . . . , vn). Now to see that
(3.18) holds, note that:
ncon(p1A) = 0
iff ^
1≤i≤n
ncon([ti]leftA ) = 0∨ p0(x1, . . . , xn) is independent from its ith argument
iff ^
1≤i≤n
ncon([ti]leftB ) = 0∨ p0(x1, . . . , xn) is indep. from its ith arg. (by ind. hyp.)
iff ncon(p1B) = 0
By (3.18) it suffices to consider the following two cases: • ncon(p1A)6= 0 and ncon(p1B)6= 0
• ncon(p1A) = 0 and ncon(p1B) = 0
If we have ncon(p1A) 6= 0 and ncon(p1B) 6= 0, then we also have [t]leftB = p1B ≥ p1A =
[t]leftA , ncon([t]leftA )6= 0, and ncon([t]leftB )6= 0.
So now consider ncon(p1A) = 0 and ncon(p1B) = 0. If 0≤ con(p1A), then we have
[t]leftA = p1A
≤ p1B by (3.17)
= [t]leftB (3.17) and con(p1A)≥ 0 imply con(p1B)≥ 0
This also implies ncon([t]leftA ) = 0 and ncon([t]leftB ) = 0.
If however 0 > con(p1A), we have [t]leftA = 0. If also 0 > con(p1B), we get [t]leftB = 0≥ 0 = [t]leftA . If 0≤ con(p1B), we get [t]leftB = p1B = con(p1B)≥ 0 = [t]leftA . Both for 0 > con(p1B)
and for 0≤ con(p1B), we thus also have ncon([t]leftA ) = 0 and ncon([t] left B ) = 0.
We prove Claim (ii) by induction over the structure of the term r. If r is a variable, we have [r]rightA = r = [r]rightB .
3.3. A Necessary Criterion for Negative Constants 51
Now consider r = f (t1, . . . , tn). There are two cases: First, consider [f ]A(x1, . . . , xn) =
[f ]B(x1, . . . , xn) = max(p0(x1, . . . , xn), 0). By the induction hypothesis we have:
p2A = p0([t1]rightA , . . . , [tn]rightA ) = p0([t1]rightB , . . . , [tn]rightB ) = p2B (3.19)
If 0≤ con(p2B), then we have [r]rightB = p2B
= p2A by (3.19) = [r]rightA
Now let 0 > con(p2B). Then we have [r]rightB = ncon(p2B) = ncon(p2A) = [r]rightA .
Thus, let f /∈ N ({r1, . . . , rn}), 0 > con(p0), [f ]A(x1, . . . , xn) = max(p0(x1, . . . , xn), 0),
and [f ]B(x1, . . . , xn) = ncon(p0)(x1, . . . , xn).
Since f /∈ N ({r1, . . . , rn}) and since r is a subterm of a term from {r1, . . . , rn}, we can
conclude that r∈ T ({f}, V), i.e., r only contains variables and the function symbol f. To complete the proof, we will use the following statement:
Let q1, . . . , qn, p be polynomials with con(q1) = . . . = con(qn) = 0.
Then con(p(q1, . . . , qn)) = con(p(x1, . . . , xn)).
(3.20)
To see that (3.20) holds, let q1, . . . , qn, p be polynomials with con(q1) = . . . = con(qn) = 0.
We then have: con(p(q1, . . . , qn)) = p(q1, . . . , qn)(0, . . . , 0) by Corollary 3.6 = p(q1(0, . . . , 0), . . . , qn(0, . . . , 0)) = p(con(q1), . . . , con(qn)) = p(0, . . . , 0) = con(p) by Corollary 3.6
Using (3.20), we now show the following auxiliary statement by induction:
For all u∈ T ({f}, V), we have con([u]rightA ) = 0. (3.21) If u is a variable, we have con([u]rightA ) = con(u) = 0. So let u = f (u1, . . . , un). Then the
induction hypothesis of (3.21) states con([u1]rightA ) = . . . = con([un]rightA ) = 0. Thus, we can
apply the statement (3.20) and get con(p0([u1]rightA , . . . , [un]rightA )) = con(p0(x1, . . . , xn)) <
0. Thus, we have [u]rightA = ncon(p0([u1]rightA , . . . , [un]rightA )) and con([u] right A ) = 0.
Having proved (3.21), we continue with the induction step for Claim (ii). As r ∈ T ({f}, V), by (3.21) we have con([r]right
A ) = 0. Thus: [r]rightA = ncon([r]rightA ) = ncon(p0([t1] right A , . . . , [tn] right A ))
= ncon(p0([t1]rightA , . . . , [tn]rightA )) + con(p0([t1]rightA , . . . , [tn]rightA ))
− con(p0([t1]rightA , . . . , [tn]rightA ))
= p0([t1]rightA , . . . , [tn]rightA )− con(p0([t1]rightA , . . . , [tn]rightA ))
= (p0− con(p0))([t1]rightA , . . . , [tn]rightA ) using (3.20) with:
for all i, ti ∈ T ({f}, V), so by (3.21) con([ti] right A ) = 0
= (ncon(p0))([t1]rightA , . . . , [tn]rightA )
= (ncon(p0))([t1]rightB , . . . , [tn]rightB ) by induction hypothesis
= [r]rightB
Note that as a special case, it is always safe to permit only non-negative constant addends for constant function symbols, even if one does not use the approximations from Definition 3.5. The reason is that a constant symbol has no arguments, and max(c, 0) always takes the value 0 if c is negative.
It is also worth noting that in Theorem 3.11, the restriction to the approximations of Definition 3.5 is necessary for completeness. This is demonstrated by the following example.
Example 3.12 (Completeness of Theorem 3.11 Requires Approximations). Consider again Example 3.1, where we now also add the rulehalf(x) → g(x) to the TRS. Similar to Example 3.1, we then need to solve the following term constraints to prove termination:
BITS(s(x)) BITS(half(s(x))) (3.4)
half(0) % 0 (2.13)
half(s(0)) % 0 (2.14)
half(s(s(x))) % s(half(x)) (2.15) half(x) % g(x) (3.22)
If we extend the interpretation [·]A from Example 3.2 to an interpretation [·]A0 to interpret
g by [g]A0(x1) = max(x1− 1, 0), the term constraint (3.22) yields the constraint max(x −
1, 0) ≥ max(x − 1, 0). Since this constraint obviously holds (≥ is reflexive), we can conclude termination also of this extended TRS.