Author and institution omitted for double-blind review \ccsdesc[100]Theory of computation \CopyrightCopyright: omitted for double-blind review
Efficient Local Search for Nonlinear Real Arithmetic
Abstract
Local search has recently been applied to SMT problems over various arithmetic theories. Among these, nonlinear real arithmetic poses special challenges due to its uncountable solution space and potential need to solve higher-degree polynomials. As a consequence, existing work on local search only considered fragments of the theory. In this work, we analyze the difficulties and propose ways to address them, resulting in an efficient search algorithm that covers the full theory of nonlinear real arithmetic. In particular, we present incremental computation of variable scores, and temporary relaxation of equality constraints. We also discuss choice of candidate moves and a look-ahead mechanism in case when no critical moves are available. The implementation is competitive on satisfiable problem instances against complete methods such as MCSAT implemented in existing SMT solvers.
keywords:
Local search, Nonlinear arithmetic, SMT1 Introduction
Satisfiability Modulo Theories (SMT) is the problem of determining the satisfiability of a formula containing both logical operators and functions interpreted in one or more custom theories [BarrettT18]. Commonly considered theories include equality, arithmetic, bit-vectors, arrays, and strings. After about two decades of development, SMT has gained widespread applications in program verification, model checking, planning, and many other areas.
The arithmetic theories can be divided according to the type of numbers involved into integer and real theories, and according to the operations allowed into difference logic, linear, and nonlinear theories. The case of (quantifier-free) nonlinear real arithmetic (NRA) considers satisfiability of equalities and inequalities involving polynomials of degree greater than one, and where the arithmetic variables take on real values. It has applications in the analysis of nonlinear hybrid automata [CimattiMT12], generating ranking functions for termination analysis [HeizmannHLP13, LeikeH15], constraint answer set programming [SusmanL16, ShenL18], and even analysis of biological networks [AkutsuHT08]. Problem instances from many of these applications are collected in the SMT-LIB benchmarks [BarFT-SMTLIB].
Similar to the SAT case, methods for solving SMT problems can be roughly divided into complete and incomplete methods. Complete methods are usually based on DPLL() or close variants. They are able to both find solutions and prove unsatisfiability. Incomplete methods, such as those based on local search [HoosS2004], explores the solution space heuristically, usually by changing the assignment of one variable at a time, in an attempt to find a satisfying solution. Local search methods are not able to prove unsatisfiability, but can have an advantage over complete methods on some satisfiable instances.
Complete methods for the theory of nonlinear real arithmetic make crucial use of cylindrical algebraic decomposition (CAD) [Caviness2004QuantifierEA], which permits deciding the satisfiability of a conjunction of polynomial (in)equalities over real numbers. This can then serve as the theory solver in DPLL() [NieuwenhuisOT06]. An innovation over DPLL() for arithmetic theories is the MCSAT algorithm [JovanovicM12, MouraJ13], which constructs models involving both boolean and arithmetic variables at the same time. A nice overview of DPLL() and MCSAT for nonlinear real arithmetic can be found in Kremer’s thesis [Kremer20].
Exploration of applying local search to solve SMT problems over arithmetic theories began only recently. The work [CaiLZ22] applied local search to the theory of linear integer arithmetic. It introduced the concept of critical moves, a change in one arithmetic variable that satisfies a previously unsatisfied clause. The algorithm iteratively applies critical moves that most improves the score, a weighted count of unsatisfied clauses. The presence of both boolean and arithmetic variables are dealt with by alternately working in the integer mode and the boolean mode, when assignments to only integer or boolean variables are changed respectively. Switching between modes are performed after the number of non-improving steps reaches a certain threshold.
Compared to linear integer arithmetic, the problem of nonlinear real arithmetic held additional challenges for local search methods. Unlike integer theories, there is an uncountable number of possible assignments to choose from, including infinite number of choices in any finite interval. Unlike the linear case, there is potential need to solve polynomials of degree greater than one, which is both costly in time and may result in variable assignments that are irrational (e.g. algebraic) numbers, causing a slow-down of the ensuing search process. It is also possible that a nonlinear constraint cannot be satisfied by changing the value of one variable alone, resulting in the lack of critical moves, so that other heuristics are needed in such scenarios.
There has already been some work exploring local search for nonlinear real arithmetic. However, largely due to the challenges listed above, none of the existing work covers the entirety of the theory. The work [abs-2303-06676] considers the multilinear case, where each variable appears with degree at most one in each polynomial constraint. The work [LiXZ23] considers problems where all equality constraints contain at least one variable that is linear. In both of these works, the problem of variable assignments to irrational values is avoided by either assuming linearity in each variable, or by limiting higher-degree constraints to strict inequalities only.
1.1 Contributions
In this paper, we propose several improvements to the local search procedure, aimed at addressing the challenges posed by nonlinear real arithmetic. This results in an efficient local search algorithm for the entire NRA theory.
First, we present efficient data structures for caching and updating variable scores used to determine the next critical move. Existing work on local search for arithmetic theories can be thought of as an extension of the GSAT algorithm [SelmanLM92] with adaptive weighting. It is well-known that efficient implementations of GSAT involve caching and updating of variable scores [HoosS2004, Section 6.2]. For arithmetic theories, this is complicated by the fact that each variable is associated not with one score, but with different scores for changing its assignment to values in different intervals. Hence, current implementations of local search for arithmetic theories recompute the score information for each variable at every iteration, resulting in potential repeated computations. This is especially serious for nonlinear arithmetic, where computations may involve costly root-finding for higher-degree polynomials. We describe data structures maintaining boundaries of score changes for each pair of clause and variable appearing in the clause, which only need to be updated on an as-needed basis, and from which the full score information can be quickly recovered.
Second, we address the problem posed by nonlinear equality constraints between variables, which may force assignment to variables that are irrational numbers. Rather than making such assignments, we propose to temporarily relax such equalities into inequalities, e.g. changing the constraint into , and continue the local search process. If an (approximate) solution is found that satisfies the relaxed version of these constraints, we restore the equalities to their original form, and try to find an exact solution near the approximate solution. While it is not guaranteed theoretically (or in practice) that such an exact solution can be found every time, using this method means local search spends most of its time working with rational assignments, significantly improving its efficiency in particular types of problem instances.
Finally, we present alternative ways to deal with situations where no critical move is available to satisfy a certain literal (that is, when the literal is stuck). We first pick heuristically a variable appearing in the literal, and a set of candidate moves for that variable. For each candidate move, we look ahead to see whether that move will lead to the literal having critical moves on the next step. Such moves are then preferred over the others.
The above ideas are implemented as a local search algorithm on top of the Z3 prover [MouraB08]. The implementation relies on the existing library of polynomials and algebraic numbers in Z3, but is otherwise independent from its implementation of MCSAT for nonlinear real arithmetic. We perform thorough experiments on the SMT-LIB benchmarks, showing the effect of incremental computation of variable scores and relaxation of equalities, and that the resulting local search algorithm is competitive with complete algorithms in existing SMT solvers on the satisfiable instances.111Binary file of the program for Linux operating system is available at the anonymized repository https://anonymous.4open.science/r/z3_binary-1038/.
1.2 Related work
Our work builds upon existing work applying local search to SMT over arithmetic theories [CaiLZ22, abs-2303-06676, LiXZ23]. They will be reviewed in more detail in Section 2. Besides arithmetic theories, there have also been earlier work applying local search to the theory of bit-vectors [GriggioPST11, FrohlichBWH15, NiemetzPB16]. In particular, the work [FrohlichBWH15] generalized the scoring function to consider operators on bit-vectors, but the moves remain single-bit flips. Later works [Niemetz2015ImprovingLS, NiemetzPB16] introduced propagation-based move selection and essential inputs to prune the search.
The work of Gao et al. [GaoAC12IJCAR, GaoAC12LICS] introduced the framework of -complete decision procedures, implemented in the dReal tool for solving SMT problems over nonlinear formulas [GaoKC13]. It can handle polynomials as well as trigonometric and exponential functions. The -complete framework allows algorithms to either return - or , where the - case returns a solution for a -weakening of the input formulas. This permits efficient numerical algorithms to be used, as well as showing decidability for a wide range of problems. The concept of relaxation of constraints in our work is similar to -weakening, and we also use it to increase efficiency of our algorithm. However, we still aim to return an exact answer, by restoring the constraints to their original form and try to find an exact solution near any approximate solution that is found.
1.3 Structure of the paper
We begin by defining the SMT problem over nonlinear real arithmetic, and reviewing existing local search algorithms in Section 2. Section 3 presents incremental computation of variable scores. Section 4 presents relaxation and restoring of equality constraints. Section 5 discusses implementation choices, including heuristic move selection and look-ahead mechanism for stuck literals. Section 6 compare with existing SMT solvers, and perform ablation study on each of the improvements. Finally, we conclude in Section 7 with a discussion of potential future directions.
2 Preliminaries
In this section, we formally define SMT problems over nonlinear real arithmetic, followed by a review of existing local search algorithms for arithmetic theories.
The syntax of a general SMT formula over nonlinear real arithmetic is as follows:
(polynomials) | ||||
(atoms) | ||||
(formulas) |
Here is an arithmetic variable, is a (rational) constant, is a boolean variable. A literal is either an atom or its negation. A clause is a disjunction of literals. In practice, we assume that input problem instances are given in conjunctive normal form (CNF), that is as a collection of clauses to be satisfied. Note that strict inequalities , and can be represented as , and , respectively. We allow problem instances to contain boolean and arithmetic variables at the same time. We define boolean literal and arithmetic literal to mean literal whose atom is a boolean variable and a polynomial inequality, respectively.
A polynomial is linear in some variable if all terms of the polynomial have degree at most one in . Alternatively, can be written in the form , where do not contain . A polynomial is multilinear if it is linear in each of its variables.
Given a problem instance containing boolean variables and arithmetic variables , a complete assignment is a mapping from each to and each to . We will only deal with complete assignments in this paper, and hence sometimes call it assignment for short. A formula is satisfied under an assignment if it evaluates to true under the standard interpretation of boolean and arithmetic operators. An assignment is a solution to a problem instance if it satisfies all its clauses. The SMT problem for nonlinear real arithmetic is to determine whether a given problem instance is satisfiable by some assignment.
Local search algorithms attempt to determine satisfiability of a problem instance by searching in the space of complete assignments, usually by changing the value of one variable at a time. In the SAT case, each move in local search flips the assignment of one boolean variable. Which flip to make is determined by factors such as the number of clauses that become satisfied/unsatisfied as result of the flip, weight of the clauses, which variables are flipped recently, and so on. For SMT over arithmetic theories, the analogous move changes the value of one arithmetic variable, usually in order to make some clause become satisfied. Such moves, called critical moves, are introduced in [CaiLZ22] for linear integer arithmetic.
For nonlinear real arithmetic, the basic procedure used to determine possible moves is root isolation for polynomials. Given a polynomial in a single variable (where here we allow the coefficients of to be algebraic numbers), the procedure computes the roots of the equation , together with the sign of the polynomial in each interval separated by the roots. Algebraic numbers in the coefficients of and in the output of root isolation are represented by their minimal polynomials, together with intervals with rational endpoints that bracket a root of that polynomial.
Given a complete assignment, and an arithmetic literal involving variable , we can use root isolation to compute the set of values that assignment of may be moved to in order for to be satisfied. This is done by substituting in assignments to other variables in , resulting in a polynomial containing only variable , then perform root isolation and check the value of in each resulting interval. The answer is given in terms of a set of intervals (which may contain as one of the endpoints, and may be either open or closed at each endpoint). We state the definitions precisely as follows.
Definition 2.1.
Given a complete assignment, a literal and a variable , the feasible set (resp. infeasible set) is the collection of intervals that the value of can be moved to in order for to be satisfied (resp. unsatisfied). Likewise, we define the feasible set (resp. infeasible set) of a clause with respect to a variable. This is computed by taking the union (resp. intersection) of the feasible set (resp. infeasible set) for each literal in the clause.
A critical move is defined to be a change in the assignment of some variable to a value that satisfies some previously unsatisfied clause. The basic local search algorithm then performs critical moves at each iteration, using various scoring metrics to determine which move is chosen next. Such moves can also be interpreted as jumping between CAD cells as in [LiXZ23]. An innovation in [LiXZ23] is that when no critical moves are available for some literal, moves that change multiple variables at once along some straight line are also explored.
Scoring of critical moves is usually based on a weighted count of unsatisfied clauses. Adaptive weighting schemes assign a weight to each clause, reflecting its importance during the current search. Existing work on local search for arithmetic theories mostly use a probabilistic version of the PAWS weighting scheme [ThorntonPBF04]. This scheme is parameterized by a smoothing probability sp. Whenever there is no moves available that improves the score, with probability the weight of each unsatisfied clause is increased by 1, and with probability the weight of each satisfied clause with weight greater than 1 is decreased by 1. Then, the make-break score of each critical move equals the total weight of clauses that become satisfied by the move, minus the total weight of clauses that become unsatisfied by the move. A move is improving if its score is greater than zero.
One key contribution of [abs-2303-06676] is the introduction of make-break intervals. The idea is that instead of considering only the (in)feasible intervals of a variable with respect to some clause, we combine the (in)feasible interval information of with respect to all clauses. This results in a partition of the real line into intervals, with each interval associated to the make-break score for moving the value of into that interval. We illustrate this idea with the following example.
Example 2.2.
Consider the set of clauses , and . The current assignment is , and the current weight of clauses are , respectively. The make-break score for variable with respect to each of the clauses are:
-
•
(unsatisfied): , , .
-
•
(unsatisfied): , .
-
•
(satisfied): , .
Combining the above information, we obtain the following make-break intervals and scores for : , , , . A preferred move would be to change the value of into the interval , satisfying the clause and leaving the status of the other clauses unchanged, with a make-break score of 3.
If boolean variables are present, the make-break score of flipping each boolean variable is defined in a similar way, as the total weight of clauses that become satisfied by the flip, minus the total weight of clauses that become unsatisfied.
Algorithm 1 shows the structure of the basic local search procedure. Begin by initializing the assignments to all variables (line 1). At each iteration, first try to find a move with the largest make-break score. If the score is greater than 0 (the variable necessarily comes from an unsatisfied clause), then perform the corresponding move (line 9). If no move has score greater than 0, it indicates that we reached a local minimum. Update the clause weights according to the PAWS scheme (line 11), and then try to make a move that makes a randomly chosen clause satisfied (line 16). If that is also not possible after several tries, randomly change the assignment of some variable in some unsatisfied clause according to some heuristic (line 19). This continues until all clauses are satisfied (line 4) or the time or step limit is reached (line 6).
There are possible variations in the choice between boolean and arithmetic variables on line 7. In [CaiLZ22, abs-2303-06676], the search is separated into modes where only boolean or arithmetic variables are considered. Alternatively, we can combine the lists of moves and decide between them based purely on make-break scores. We take the latter approach in this paper. There are other aspects of the algorithm that are left unspecified, including how the best move is computed on line 7, and the heuristic choice of moves on line 19. These will be specified in more detail in the next sections.
3 Incremental computation of variable scores
One key step in Algorithm 1 is computing the move with the best make-break score. The computation for boolean variables is standard (and is in any case not the bottleneck here), hence we focus on critical moves for arithmetic variables. The default approach is to loop over all variables in all unsatisfied clauses. For each variable, compute its score with respect to each clause and then combine the results (as demonstrated in Example 2.2). However, it is clear that this may result in repeated computations across iterations. For example, the feasible set of some variable with respect to a clause may be recomputed, even though none of the variables in that clause are changed in the previous step. Following the idea of caching and updating scores in GSAT [SelmanLM92], we propose data structures for caching and updating score information for arithmetic variables.
We define a boundary to be a quadruple , where is a real number, and are boolean values, and is a clause identifier. It indicates that there is a change in make-break score when moving from less than to greater than due to clause . If is , the score is increased by the weight of clause , otherwise it is decreased by the weight. If is , the change is not active at , otherwise it is already active at . There is a natural ordering among boundaries, first order by and then by (with ). The make-break score information of each variable with respect to each clause can be characterized by a starting score (indicating the make-break score of large negative values), together with a set of boundaries. The make-break information of each variable with respect to all clauses is formed by summing the starting score and taking the union of the sets of boundaries. We illustrate the computations in the following example.
Example 3.1.
Continuing from Example 2.2, the starting score and boundary information of variable with respect to each clause is as follows (we identify the three clauses as 1,2,3, respectively).
-
•
: starting score 0, boundary set , indicating no change for large negative values, make at boundary , followed by break at boundary .
-
•
: starting score 3, boundary set , indicating make at large negative values, and break at boundary .
-
•
: starting score , boundary set , indicating break at large negative values, and make at boundary .
The combined make-break score information is: starting score 1, with the following (ordered) set of boundaries: . Make-break score information in terms of intervals can be easily recovered from the above, by traversing the boundaries in order, increasing the score by the weight of the clause when encountering a boundary with , and decreasing the score by the weight otherwise.
During local search, after each move of variable to a new value, only those variables that shares a clause with need to have their make-break score information updated (this is analogous to the concept of dependent variables in the SAT case), and moreover boundary information need to be updated for the shared clauses only. This is summarized in Algorithm 2. The set collects the set of variables sharing a clause with . Line 5 recomputes starting score and boundary information. Line 7 recomputes best critical move and score for each updated variable.
Example 3.2.
Continuing from Example 3.1, suppose the move is made, making the clause satisfied. Then the score information for variable does not need to be updated, as and do not share a clause. The score information for variable need to be updated for the first two clauses. For clause there is no longer any boundaries (no assignment of can make the clause true), and for clause the new starting score and boundary set are 0 and , respectively. So the overall starting score and boundary set are and .
Remark 3.3.
Data structures such as arrays, linked lists, or binary trees can be used to maintain set of boundaries. If the total number of boundaries for each variable is small (as is the case for most of the problem instances in SMT-LIB), arrays or linked lists are sufficient. Otherwise the use of binary trees result in better asymptotic performance for the required operations.
Remark 3.4.
A further optimization can be made: it is not necessary to immediately recompute the boundary information for a variable that does not appear in any unsatisfied clause, as such variables will never be chosen either on line 7 or line 14 of Algorithm 1. Instead, flags can be used to mark that boundary information for certain clauses need to be updated for . When at least one of the clauses containing becomes unsatisfied, information for those flagged clauses (as well as other clauses that need to be updated for that step) are updated.
4 Relaxation of equalities
Equality constraints with degree greater than one pose special difficulty for local search, since it may force assignments of variables to irrational (e.g. algebraic) numbers. For example, for the constraint , with most rational assignments to and , the assignment to would be forced to irrational in order for the constraint to be satisfied. While it is possible to represent and compute with algebraic numbers during local search, the time-cost of such computation is significantly increased. Even without considering algebraic numbers, numbers with increasingly large denominators are also problematic for slowing down the search process.
Both [abs-2303-06676] and [LiXZ23] avoid algebraic numbers by either limiting to the multilinear case, or considering only equality constraints with at least one linear variable (and solving only for those linear variables). The work [abs-2303-06676] further incorporated comparison of size of denominators (as well as absolute value) of potential assignments into the scoring heuristic, in order to keep the complexity of assigned values as low as possible.
We propose a novel approach to address the problem of assignments to irrational values and values with large denominators, that allow the algorithm to be applied efficiently to the full set of nonlinear arithmetic problem instances. The approach still relies on comparing complexity of assigned values, hence we first define it below.
Definition 4.1 (Complexity of values).
We define a preorder on algebraic numbers as follows. if is rational and is irrational, or if both and are rational numbers, and the denominator of is less than that of . We write if neither nor .
The relaxation mechanism can be described simply as follows: whenever some equality (or inequality) constraints force an assignment of some variable to a comparatively complex value, those constraints are relaxed before continuing the local search process, so that such assignments never actually occur. The implementation is parameterized by two thresholds. The parameter (for variable threshold) specifies the complexity of assigned values (according to Definition 4.1) beyond which relaxation of constraints should be applied. The parameter (for polynomial threshold) specifies the amount of relaxation of polynomial constraints. Both and are chosen to be in the implementation.
It should be noted that the constraints and together can also force the assignment of variables to irrational values. These constraints may appear as part of clauses with more than one literal, and hence are not equivalent to . This means in general we consider relaxation of non-strict inequalities, although we will still use the slightly imprecise (but more intuitive) description of relaxing equalities throughout the paper.
The detailed method for determining which constraints to relax is as follows. When computing the best make-break score of a variable , if that score comes from a one-point interval, the set of clause identifiers in the boundaries contributing to that interval are recorded. If the variable is chosen, and the new value of is more complex than both and any other previously assigned value (according to Definition 4.1), all equalities and non-strict inequalities in the recorded clauses that contribute to the boundary are relaxed. The result of relaxation is as follows.
-
•
If the constraint is of the form , it is relaxed into the pair of inequalities and .
-
•
If the constraint is of the form , it is relaxed into . Likewise, if the constraint is of the form , it is relaxed into .
Note that strict inequality constraints cannot force a variable to a particular value. After relaxation, the local search process proceeds as before, but with all evaluation of literals and computation of make-break scores according to the relaxed interpretation of literals.
After local search finds a “solution” under the relaxation of some constraints, it is only an approximate solution. In fact, there is no guarantee that there is an exact solution nearby. Instead, we use local search itself to try to move the approximate solution to an exact solution. First, restore the relaxed constraints to their original forms, and then proceed with local search, until either an exact solution is found, or no improvement is made for a certain number of steps. In the latter case, the search continues with a minor restart (see Section 5.2) and with relaxation of constraints allowed as before.
The above description is summarized as a modification of the overall algorithm, shown in Algorithm 3. The main change is to add a boolean flag called , that specifies whether relaxation of constraints is active. If all clauses are satisfied and , then we may only have an approximate solution, so we restore the relaxed constraints and continue local search (line 4-5). If all clauses are satisfied and , then we obtained an exact solution (line 7). If no improvement is made for steps in the mode, we assume that no exact solution is found nearby, so we assign and continue after minor restart (line 11-12).
5 Implementation
In this section, we describe the implementation in more detail. First, we explain our choice of heuristic move selection when encountering a literal without critical moves. Then, we describe some further details on preprocessing, restart mechanism, and other efficiency improvements.
5.1 Heuristic moves selection and look-ahead
One major difficulty for local search in nonlinear arithmetic is that it is not always possible to find single-variable moves to satisfy a particular constraint. For example, given constraint , and the current assignment , it is not possible to satisfy the constraint by moving only one of and . During local search, this is reflected by the situation that no critical move is available for a clause or literal.
Solving this problem in general would likely require complex algorithms such as CAD or polynomial optimization. Indeed, one category in the SMT-LIB benchmarks, Sturm-MBO, coming from analysis of biological networks [AkutsuHT08], consists exclusively of problems that require a very complex polynomial to evaluate to zero, subject to positivity constraints of the variables. When the problem has many variables (is high-dimensional), any approach based on heuristically searching for assignments would have difficulty finding the exact combination of assigned values required to satisfy the constraint.
One approach is given in [LiXZ23], which involves searching in directions other than those parallel to the coordinate axes to look for solutions. The use of gradient information, as well as scoring based on values of polynomials, increase the chance of finding a solution.
In this paper, we propose another approach that still involves moving only one variable at a time. We say a literal is stuck if it is currently unsatisfied and has no critical moves to make it satisfied. Given a literal that is stuck, we first choose a variable in whose coefficient is nonzero (according to the current assignment of the other variables), then heuristically pick a set of candidate values to move the assignment of to. For each candidate value, we compute whether is still stuck after making that move. We then prefer those moves that result in no longer being stuck.
Given the current assignment and the feasible set of variable (see Section 5.2), the heuristic move selection include the following:
-
1.
rational numbers and integers close to the boundary inside each interval of . The rational numbers are chosen to be within of the boundary.
-
2.
the next integer smaller or larger than .
-
3.
three numbers chosen uniformly in the interval , and three numbers chosen uniformly in the interval .
The first class reflects what we know about the constraints on . The second class attempts basic random walk, and prefers (simple) integer values. The third class is the most general, allowing search over large/small values as well as fractions.
The above ideas are summarized in Algorithm 4. The heuristic choice of candidate values are collected into set (line 2). Then each value in is tested in turn. If has critical move after assigning to any value, that value is returned (line 5). Otherwise a randomly chosen value from is returned (line 7).
5.2 Implementation details
The algorithm is implemented on top of the Z3 prover, and makes use of its library for polynomials and algebraic numbers, as well as data structures for clauses and literals, but otherwise separate from its implementation of the MCSAT algorithm.
Preprocessing. The following preprocessing steps are used. Eliminate clauses with a single boolean variable and propagate assignments. Combine constraints and into equality . Eliminate variable in an equation of the form , where is a constant and is a polynomial with degree at most 1 and containing at most 2 variables. The conditions on are designed so that preprocessing does not significantly increase the complexity of the remaining clauses.
Restart mechanism. We use a two-level restart mechanism with two parameters and (both chosen to be 100 in our implementation). Perform a minor restart after moves without improvements, which randomly changes one of the variables in one of the unsatisfied clauses (this coincides with detection of the end of mode). After such minor restarts, a major restart is performed that resets the value of all variables.
Shortcut for linear equations. Root-isolation is done by calling the existing implementation in Z3, except when the variable to be solved is linear in the polynomial, in which case a direct (and more efficient) solution method is used.
Infeasible sets of variables. For each clause involving a single variable, derive infeasible set for that variable implied by the clause. Experience shows excluding assignments from the infeasible set during local search is beneficial for some problem instances but not others. Hence, we exclude such assignments on alternate turns of minor restarts.
Parameter settings. Values of tunable parameters used in the implementation are summarized in Table 1.
Symbol | Explanation | Value |
---|---|---|
Probability for PAWS scheme | 0.006 | |
Number of non-improving steps before minor restart | 100 | |
Number of minor restarts before major restart | 100 | |
Threshold for relaxing equality | ||
Amount of relaxation |
6 Evaluation
In this section, we compare the implementation with those of complete procedures in existing SMT solvers Z3 [MouraB08], CVC5 [BarbosaBBKLMMMN22] and Yices [Dutertre14], as well as previous work on local search for (fragments of) nonlinear arithmetic. We also perform ablation study on the two improvements described in Section 3 and 4.
The benchmark used in the evaluation comes from SMT-LIB’s QF_NRA theory. The benchmark consists mostly of industrial problems from various applications of constraint solving in nonlinear real arithmetic. Among the benchmarks, we took those problem instances whose status is either satisfiable or unknown. This results in a total of 6604 instances. The experiments are run on a cluster of machines with Intel Xeon Platinum 8153 processor at 2.00GHz. Each experiment is run with a time limit of 20 minutes (as in the SMT competition) and memory limit of 30GB.
6.1 Overall result
Results of our implementation are compared against that of other SMT solvers in Table 2. One major advantage of our algorithm is in the Sturm-MBO category, which involves a single complicated polynomial that tripped up other solvers. However, we also showed good result across other categories, and solved most satisfiable instances overall (the other SMT solvers also decided some of the instances to be unsatisfiable, which is not shown in this table). Scatter plots comparing solution times against Z3 and CVC5 are shown in Figure 1. It shows there is significant amount of complementarity between our algorithm and both Z3 and CVC5. In fact, there are 293 (satisfiable) instances solved by local search but not Z3, and 362 instances solved by local search but not CVC5.
Category | #inst | Z3 | CVC5 | Yices | Ours |
---|---|---|---|---|---|
20161105-Sturm-MBO | 120 | 0 | 0 | 0 | 84 |
20161105-Sturm-MGC | 2 | 2 | 0 | 0 | 0 |
20170501-Heizmann | 69 | 3 | 1 | 0 | 6 |
20180501-Economics-Mulligan | 93 | 93 | 89 | 91 | 87 |
2019-ezsmt | 63 | 54 | 51 | 52 | 18 |
20200911-Pine | 245 | 235 | 201 | 235 | 224 |
20211101-Geogebra | 112 | 109 | 91 | 99 | 100 |
20220314-Uncu | 74 | 73 | 66 | 74 | 73 |
LassoRanker | 684 | 155 | 304 | 122 | 284 |
UltimateAtomizer | 48 | 41 | 34 | 39 | 26 |
hycomp | 525 | 311 | 216 | 227 | 272 |
kissing | 42 | 33 | 17 | 10 | 33 |
meti-tarski | 4391 | 4391 | 4345 | 4369 | 4356 |
zankl | 136 | 70 | 61 | 58 | 99 |
Total | 6604 | 5570 | 5476 | 5376 | 5662 |


We further compare our results against existing work on local search for fragments of nonlinear real arithmetic. Of the 979 instances that are multilinear considered by [abs-2303-06676], our implementation can solve 825 instances, compared to 891 solved instances there. The slightly weaker result is likely due to the more efficient implementation that is possible when only rational numbers need to be considered, and the parameter tuning that is specific to multilinear problems. Of the 2736 instances from SMT-LIB considered by [LiXZ23], our implementation can solve 2596 instances, compared to 2246 solved instances there. In fact, we solve not only more instances than the local search algorithm given in [LiXZ23], but also all other SMT solvers used in the comparison.
6.2 Effect of incremental computation of variable scores
To show the effect of speedup resulting from incremental computation of variable scores in Section 3, we compare three versions of the implementation: with incremental computation (Incremental), without incremental computation (Naive), and without incremental computation, but limiting the number of unsatisfied clauses considered at each turn to 45 (Limit-45). The results are shown in Table 3.
We see that while the difference in total number of problem instance solved is not large, a noticeable effect is still present in the LassoRanker category, whose instances usually require a long time to solve. A closer look at the running time shows that it usually takes 2-10 times longer to solve a particular instance using either (Naive) or (Limit-45) compared to (Incremental), with the exact ration depending strongly on the specific instance. For a time limit of 20 minutes the resulting number of solved problems is not large, but we expect a larger difference with shorter time limits, and especially when local search is incorporated into other methods such as DPLL [CaiZ21, CaiZFB22].
Category | #inst | Incremental | Naive | Limit-45 |
---|---|---|---|---|
20161105-Sturm-MBO | 120 | 84 | 84 | 84 |
20161105-Sturm-MGC | 2 | 0 | 0 | 0 |
20170501-Heizmann | 69 | 6 | 5 | 5 |
20180501-Economics-Mulligan | 93 | 87 | 88 | 88 |
2019-ezsmt | 63 | 18 | 19 | 19 |
20200911-Pine | 245 | 224 | 221 | 221 |
20211101-Geogebra | 112 | 100 | 99 | 99 |
20220314-Uncu | 74 | 73 | 73 | 73 |
LassoRanker | 684 | 284 | 271 | 272 |
UltimateAtomizer | 48 | 26 | 26 | 26 |
hycomp | 525 | 272 | 265 | 267 |
kissing | 42 | 33 | 33 | 33 |
meti-tarski | 4391 | 4356 | 4348 | 4348 |
zankl | 136 | 99 | 99 | 99 |
Total | 6604 | 5662 | 5631 | 5634 |
6.3 Effect of relaxation of equalities
We demonstrate the effect of relaxation of constraints by comparing three possible implementations: with relaxation of constraints (Relaxation), without relaxation of constraints, but preferring variable assignments that are less complex than (Threshold), and without relaxation of constraints, with choosing variable assignments strictly according to complexity order (FullOrder). The results are shown in Table 4.
Category | #inst | Relaxation | Threshold | FullOrder |
---|---|---|---|---|
20161105-Sturm-MBO | 120 | 84 | 85 | 85 |
20161105-Sturm-MGC | 2 | 0 | 0 | 0 |
20170501-Heizmann | 69 | 6 | 9 | 8 |
20180501-Economics-Mulligan | 93 | 87 | 89 | 90 |
2019-ezsmt | 63 | 18 | 18 | 18 |
20200911-Pine | 245 | 224 | 220 | 196 |
20211101-Geogebra | 112 | 100 | 100 | 99 |
20220314-Uncu | 74 | 73 | 73 | 73 |
LassoRanker | 684 | 284 | 283 | 274 |
UltimateAtomizer | 48 | 26 | 24 | 24 |
hycomp | 525 | 272 | 204 | 205 |
kissing | 42 | 33 | 31 | 20 |
meti-tarski | 4391 | 4356 | 4348 | 4334 |
zankl | 136 | 99 | 99 | 98 |
Total | 6604 | 5662 | 5583 | 5524 |
The results indicate that while taking complexity of assigned values into consideration, either using a threshold or according to a strict order, does have an effect in keeping the search efficient for most categories of problem instances (in particular LassoRanker), it is not sufficient for the hycomp category, which involves a large number of nonlinear equalities. In that category using relaxation of constraints have a significant effect, while also performing well in other categories.
6.4 Other techniques
We also tried other techniques commonly used in works on local search, including tabu search, phases for boolean and arithmetic variables, and incorporating random walk. However, none of these methods resulted in improvements on the tested benchmark. However, it remains to investigate whether they will be useful on other types of problems, or in combination with other changes to the algorithm.
7 Conclusion
In this paper, we presented improvements to the local search algorithm for solving SMT problems in nonlinear real arithmetic. Building upon the basic structure of local search, we presented incremental computation of variable scores and temporary relaxation of constraints. We also described heuristic move selection with look-ahead for dealing with literals without critical moves, and implementation details to improve efficiency. The resulting implementation is competitive against complete algorithms based on DPLL() and MCSAT on satisfiable problem instances, as implemented in other SMT solvers. It is the first local search algorithm designed for the entirety of nonlinear real arithmetic, covering a wider range of problems than existing work [abs-2303-06676, LiXZ23].
While the methods proposed in this paper made progress in addressing challenges of local search for nonlinear real arithmetic, there are remaining problems that represent interesting directions of future work.
-
•
Look-ahead for critical moves presents another way to improve upon random search in cases when no critical move is available. On the other hand, methods based on CAD or polynomial optimization would give a more complete way for determining assignments to satisfy a certain literal. A major challenge is how to incorporate such algorithms into local search in an efficient way.
-
•
In the current work, after an approximate solution is found that satisfies the relaxed version of equalities, we use local search itself to attempt to find an exact solution nearby. While there may be more straightforward ways to find exact solutions for limited cases, e.g. when each relaxed clause has a unique variable that can be adjusted, the situations we found in actual benchmarks are usually more complicated. Designing a more general algorithm for finding exact solutions near approximate solutions (or determining that none exist) is an interesting problem that we leave to future work.
-
•
Finally, local search can be incorporated into complete methods such as DPLL, improving its performance even on unsatisfiable instances, as shown by the works [CaiZ21, CaiZFB22]. It is interesting to investigate this possibility for SMT problems over nonlinear real arithmetic. The improvements in efficiency in our work would be very helpful for such combination, as in those cases local search is only given very short running times.