Improving AMulet2 for verifying multiplier circuits using SAT solving and computer algebra

Verifying arithmetic circuits and most prominently multiplier circuits is an important problem which in practice is still considered to be challenging. One of the currently most successful verification techniques relies on algebraic reasoning. In this article, we present AMulet2, a fully automatic tool for verification of integer multipliers combining SAT solving and computer algebra. Our tool models multipliers given as and-inverter graphs as a set of polynomials and applies preprocessing techniques based on elimination theory of Gröbner bases. Finally, it uses a polynomial reduction algorithm to verify the correctness of the given circuit. AMulet2 is a re-factorization and improved re-implementation of our previous verification tool AMulet1 and cannot only be used as a stand-alone tool but also serves as a polynomial reasoning framework. We present a novel XOR-based slicing approach and discuss improvements on the data structures including monomial sharing.


Introduction
Formal verification of arithmetic circuits is important to prevent issues like the infamous Pentium FDIV bug [37]. Up to now, there have been many attempts to verify these circuits, but even today, the problem of fully automatic verification of arithmetic circuits, and especially multipliers, is still considered to be hard.
Methods based on decision diagrams [6] rely on manual structural decomposition of the multiplier. Approaches based on satisfiability checking (SAT) do not scale [3]. Recently, progress has been made using theorem provers [39]. However, the multipliers have to be given as hierarchical SVL netlists, which rely on preservation of information of the circuits. For flattened gate-level multipliers, the currently  Albert-Ludwigs-University, Freiburg, Germany most successful technique is based on algebraic reasoning [8,17,23,34,35]. In this line of work, the circuit is modeled as a set of polynomials that generate a Gröbner basis and the specification is then checked to be implied by the circuit polynomials using a polynomial reduction algorithm.
In our approach [23], we apply a combination of SAT solving and computer algebra. Certain parts of the multiplier, i.e., complex final stage adders that are generate-and-propagate adders [36] are hard to verify using computer algebra, but are easy to verify using SAT solvers [29]. Therefore, we apply adder substitution [23] and replace complex final stage adders by simple ripple-carry adders that can be verified using computer algebra. The equivalence of the adders is verified using SAT solvers. The correctness of the simplified multiplier is shown using computer algebra [23].
This article presents our tool AMulet2, a successor of AMulet1 [23,26]. The version history of AMulet is depicted in Table 1. AMulet2 reads multipliers given as andinverter graphs [30] and fully automatically applies adder substitution and verifies the (simplified) circuit. However, the verification process might not be error-free. In order to validate the verification results algebraic proof certificates that monitor the verification process can be generated in AMulet2, which can be checked using, e.g., Pacheck [19].  [15] improved adder substitution AMulet2.0 [22] modular re-implementation AMulet2. 1 This article reduced memory usage AMulet2 is a modular C++ re-implementation of AMulet1 (while AMulet1 consists of a single C file). AMulet2 is not only a stand-alone tool but also serves as a reasoning framework, i.e., parts can easily be integrated into different workflows. AMulet2 still provides the same functionality as AMulet1, but with improved algorithms, based on the same theory [17,23]. In this article, we focus on the novelties of AMulet2.
This article extends and revises work presented in a tool demonstration paper at TACAS'21 [22]. We extend the preliminaries in Sect. 2 and give a self-contained introduction to bit-level verification using computer algebra following [23]. Additionally, we expand our discussion on design decisions in AMulet2 and present our novel XOR-based slicing approach in Sect. 3 in more detail. Section 4 discusses AMulet2.1, which improves the memory usage of AMulet2.0 [22]. We further extend the experimental evaluation in Sect. 6.

Circuit verification using computer algebra
In this section, we introduce multiplier circuits and their architectural details. We present the algebraic concepts that are needed in the technique of automated circuit verification using computer algebra and discuss adder substitution and proof certificates.

Multiplier circuits
A digital circuit implements a logical function and computes binary digital values, given binary values at the inputs. Multipliers are circuits that compute the product of two-input bit vectors. The computation is typically realized by logic gates, such as NOT, AND, OR, and XOR. The specification of a circuit is the desired relation between its inputs and outputs. A circuit fulfills a specification if for all inputs it produces outputs that match this desired relation. The goal of verification is to formally prove that the circuit fulfills its specification.
In this article, we consider gate-level integer multipliers without latches with 2n input bits a 0 , . . . , a n−1 , b 0 , . . . , b n−1 ∈ {0, 1} and 2n output bits s 0 , . . . , s 2n−1 ∈ {0, 1}. If the circuit represents multiplication of unsigned integers, the multiplier is correct if and only if for all inputs the specification U n = 0 holds, where If the circuit represents signed multiplication, we have to take into account that the integers in the specification S n are represented using two's complement. A signed multiplier is correct if and only if for all inputs the specification S n = 0 holds, where A common representation of digital circuits is the encoding as an and-inverter graph (AIG) [30]. An AIG is a directed acyclic graph, which consists of two-input nodes representing logical conjunction. The edges may contain a marking that indicates logical negation. The AIG usually contains more nodes, than the gate-level representation, but has an unequivocal syntax and semantics, and is very efficient to manipulate. Since an AIG is a directed graph, we are able to determine for each gate g in the circuit its input cone, i.e., the set of gates g i for which there exists a path from g to g i . The space and time complexity of a multiplier depends on its architecture. In general, a multiplier circuit can be divided into three parts [36]. In the first component, partial product generation (PPG), the partial products a i b j for 0 ≤ i < n, 0 ≤ j < n, as contained in the specification, are generated. This can for example be achieved by using simple AND gates or using a more complex Booth encoding [36].
In the second component, partial product accumulation (PPA), the partial products are reduced to two layers by multioperand addition using half adders (HA), full adders (FA), and compressors. The well-known accumulation structures are for example array or diagonal accumulation, Wallace trees, or compressor trees [36].
In the final stage adder (FSA), the output of the circuit is computed using an adder circuit. Generally, adder circuits can be split into two groups: Either the carries are computed alongside the sum bits or they are calculated before the sums. Adders of the first group consist of a sequence of half and full adders, giving them a simple but inefficient structure. Examples are ripple-carry or carry-select adders. In order to decrease the latency of carry computation, the adder circuits of the second group compute the carry bits alongside the sum bits using sequences of OR gates. They are called generate-and-propagate (GP) adders. Examples are carry-lookahead adders, Ladner-Fischer adders, Han-Carlson adders, and Kogge-Stone adders [36].
We call multipliers that can be fully decomposed into half and full adders simple multipliers, all other architectures are called complex multipliers.

Algebra
Let us now briefly summarize algebraic concepts. Our algebraic setting follows [9] and we assume 0 ∈ N.
• Let X denote the set of variables {x 1 , . . . , we denote the ring of polynomials in variables X with coefficients in Z. 1 1 · · · x d l l is a product of powers of variables for d i ∈ N. A monomial is a multiple of a term cτ with c ∈ Z\{0} and a polynomial is a finite sum of monomials with pairwise distinct terms.
• On the set of terms, an order ≤ is fixed such that for all terms τ, σ 1 , σ 2 , it holds that 1 ≤ τ and further σ 1 ≤ σ 2 ⇒ τ σ 1 ≤ τ σ 2 . One such order is the so-called lexicographic term order, defined as follows. If the variables of a polynomial are ordered x 1 > x 2 > . . . x l , then given two distinct terms σ 1 = x d 1 1 · · · x d l l , σ 2 = x e 1 1 · · · x e l l it holds σ 1 < σ 2 if and only if there exists an index i with d j = e j for all j < i, and d i < e i .
• For a polynomial p = cτ + · · · , the largest term τ (w.r.t. ≤) is called the leading term lt( p) = τ . The leading coefficient lc( p) = c and leading monomial lm( p) = cτ are defined accordingly. The theory of D-Gröbner bases [2] offers a unique decision procedure for the so-called ideal membership problem over Z[X ], i.e., given q ∈ Z[X ] and a basis P = {p 1 , . . . , p m } ⊆ Z[X ], decide whether q belongs to the ideal generated by P. We discuss in Sect. 2.3 why we choose the ring Z[X ], instead of a polynomial ring where the coefficient domain is a field, which would involve the standard theory of Gröbner bases [7].
Let p, q, r ∈ Z[X ] and P ⊆ Z[X ]. Some facts about the theory of D-Gröbner bases over Euclidean domains, such as Z, are • A basis P of an ideal I ⊆ Z[X ] is called a D-Gröbner basis of I if and only if ∀q ∈ I ∃ p ∈ P : lm( p) | lm(q). • Every ideal of Z[X ] has a D-Gröbner basis, and there is an algorithm [2, Thm 10.14] that, given an arbitrary basis of an ideal, computes a D-Gröbner basis of it in finitely many steps. It is based on repeated computation of so-called S-polynomials spol and G-polynomials gpol. The precise definition of spol and gpol is not important for our application and thus is not included in this article. • We say q D-reduces to r w.r.t. p if there exists a monomial m in q with m = m lm( p) and r = q − mp. If m = lm(q), we say top-D-reduction. • The remainder r of the D-reduction of q by P is such that q − r ∈ P and r is D-reduced w.r.t. P. If r is calculated using only top-D-reductions, then we say r is top-D-reduced w.r.t. P. • (Cor. 10.12 in [2]) A set P ⊆ D[X ] is a D-Gröbner basis of P if and only if for all pairs ( p 1 , p 2 ) ∈ P × P, the remainder of D-reducing spol( p 1 , p 2 ) w.r.t. P is zero and gpol( p 1 , p 2 ) top-D-reduces to zero w.r.t. P. • (Thm. 10.23 in [2]) Let P be a D-Gröbner basis. Then, q ∈ P ⇔ q D-reduces to 0 w.r.t. P.
In general, the construction of D-Gröbner basis is very expensive. However, there exist some results which state when the computation of spol and gpol is superfluous when computing a D-Gröbner basis. We will heavily use the following lemma in our application.
The semantics of each AIG node, cf. Fig. 1, implies a polynomial relation among the input and output variables, such as the following ones: The polynomials are chosen such that the Boolean roots of the polynomials are the solutions of the node constraints and vice versa. Let G(C) ⊆ Z[X ] be the set of polynomials that contains for each AIG node its corresponding polynomial relation. All variables x ∈ X are Boolean and we enforce this property by the set of Boolean value con- . As the right side of all polynomial equations is always zero, we write f instead of f = 0.
The polynomials in G(C) are ordered according to a lexicographic order, based on a variable ordering such that the output variable of a node is always greater than the inputs of the gate [32]. This ordering is also called reverse topological term ordering.
If for a certain term order, all leading terms of P only consist of at most a single variable with exponent 1 and are unique and further lc( p) ∈ {−1, 1} for all p ∈ P, then we say P has unique monic leading terms (UMLT). Let X 0 (P) ⊆ X be the set of all variables that do not occur as leading terms in P. We further define B 0 (P) = B(X 0 (P)).

Example 1 The set
In the following, these X 0 (P) will represent inputs of a circuit, and accordingly, B 0 (P) are the Boolean value constraints only on its inputs. Let Additionally, we add the constant 2 n to the ideal generators of J (C), because this admits modular reasoning and allows us to eliminate monomials with too large coefficients from polynomials [23]. Adding constants is only possible in Z[X ]. If we would choose the ring Q[X ] as our polynomial domain, we are able to deduce from 2 n ∈ J (C), that 1 2 n 2 n = 1 ∈ J (C), thus making any verification attempt obsolete. In the ring Z[X ], this deduction is not possible, because 1 2 n / ∈ Z[X ]. The circuit fulfills its specification if and only if we can derive that L ∈ J (C) [23]. The following theorem shows that we do not have to compute a D-Gröbner basis for J (C).
UMLT and thus it holds by Lemma 1, top-D-reduction of spol( p, q) and gpol( p, q) by { p, q} gives the remainder zero for any choice p, q ∈ G(C) Hence, the correctness of the circuit can be established by D-reducing L by the polynomials G(C) ∪ B 0 (X ) ∪ {2 n } and checking whether the result is zero. Because of the UMLT property, D-reduction actually boils down to simple substitutions of the leading terms.
Hence, after each D-reduction step of L by a polynomial g ∈ G(C), we reduce the result by B(X )∪{2 n }, i.e., reduce all exponents greater than one to one and reduce all monomials with coefficients that are greater than 2 n − 1. This step helps to reduce the size of the intermediate reduction results.
If the final remainder r of D-reducing L by G(C)∪ B(X )∪ {2 n } is not zero, we know that the circuit contains an error and we are able to derive at least one concrete counter example for which the circuit computes wrong results. By the choice of the term order, r only contains input variables a 0 , . . . , a n−1 , b 0 , . . . , b n−1 , and none of them appears with degree greater than one. Let m be a monomial of r with a minimal number of variables, which includes the case where m is constant. Since exponents are at most one, the set of variables of monomials in r differ by at least one variable. Now choose a i (b j ) to evaluate to 1 if and only if a i ∈ m (b j ∈ m). By this choice, all monomials of r except m vanish (evaluate to zero). Thus, r evaluates to the (nonzero) coefficient of m, contradicting the specification.

Variable Elimination
Several experiments have shown that simply reducing the specification by G(C) ∪ B(X ) ∪ {2 n } leads to large intermediate results [17,33]. Hence, we eliminate variables in G(C) prior to reduction to yield a more compact D-Gröbner basis [23]. In the preprocessing step, we repeatedly select and remove variables v ∈ X \ X 0 from , we can safely remove p v from G(C) without violating the D-Gröbner basis property [23].

Adder Substitution
Certain parts of the multiplier, i.e., when the FSA is a GP adder, are hard to verify using computer algebra, even with prior variable elimination. In a GP adder with inputs x 0 , . . . , x m , y 0 , . . . , y m , c in and outputs s 0 , . . . , s m , c out the output bits s i are calculated as s i = p i ⊕c i , with p i = x i ⊕ y i . The carries c i are recursively generated using the equation The precise derivation of the carries c i (recursively, unrolled or mixed) depends on the architecture of the adders, but is generally computed using sequences of OR gates. These sequences of OR gates make the GP adders hard to verify using the algebraic approach as the following example shows.
In AMulet, we identify whether the FSA is a GP adder, using the equations s i = p i ⊕ c i and p i = x i ⊕ y i . If we detect that the FSA is a GP adder, we substitute the FSA by a simple RC adder, which has the same inputs as the original FSA. The first two stages, PPG and PPA, are not changed. We generate a bit-level miter in conjunctive normal form (CNF) to prove that the ripple-carry adder is equivalent to the GP adder. The miter is verified by a SAT solver. However, if the FSA is not a GP adder, we do not apply adder substitution. After substitution, we verify the rewritten AIG in AMulet using computer algebra.

Proof certificates
The verification process itself might not be error-free. A common technique to guarantee the correctness of the result is to generate simple proof certificates, which monitor the steps of the verification process and enable reproducing the proof. These certificates can be checked by stand-alone proof checkers.
Algebraic proof systems reason about polynomial equations. Given a set of polynomials G, the aim is to show that an equation f = 0 is implied by G, i.e., f ∈ G , using a sequence of proof steps. In our application, f is the specification L of a multiplier, and the polynomials g i are the gate constraints G(C) and Boolean value constraints B(X ). AMulet2 supports the practical algebraic calculus (PAC) [27], like AMulet1, but now also Nullstellensatz proofs [1,21]. Examples for both formats are depicted in Example 4.
PAC proofs consist of a sequence of steps that either encode polynomial addition or multiplication. During proof checking in, e.g., Pacheck [27], each proof step is checked for correctness. Thus, PAC proofs allow the user to localize possible errors. The Boolean value constraints are handled implicitly, i.e., the proof checker internally calculates x · x = x.
In the Nullstellensatz proof format, co-factors α i ∈ Z[X ] are provided such that there exist β j ∈ Z[X ] with L = g i ∈G(C) α i g i + h j ∈B(X ) β j h j + γ 2 n . This proof format is very concise, as only the ordered list of co-factors α i , γ is printed as a proof certificate. The Boolean value constraints are treated implicitly during proof checking, thus it is not necessary to provide co-factors β j . However, proof checking consists of calculating one huge linear combination, making it nearly impossible to locate a possible error in the certificate.

Example 4
Let z = x ∧ y, x = a ∧ b, and y = a ⊕ b, with the specification z = 0. The algebraic encoding of the gates is 1 -z+xy; 2 -x+ab; 3 -y+a+b-2ab; A proof in PAC is as follows, using labels: A proof in Nullstellensatz is -1, -y, -ab. Because after reducing all exponents.

AMULET2
We present the architecture of AMulet2 and discuss novel optimizations. The published version of our tool AMulet2 including its artifact is available at [16]. The maintained version is available at [18] and is published as open source under the MIT license. The architecture of AMulet2 is shown in Fig. 2. The blue arrows outside the box reflect inputs and outputs of AMulet2. The gray arrows inside the box depict the dependencies of the individual modules within AMulet2.
In contrast to AMulet1, which consists of a single C file, AMulet2 is split into components, which allows integrating only parts in different workflows. For example, the artifact [16] contains two demos, where (i) the Polynomial Library is used for simple polynomial calculations and (ii) the Polynomial Solver is used for verification of multipliers that are not given as AIGs.
AMulet2 is implemented in C++11 and consists of around 3 800 lines of code. It relies on the AIGER library [5] to process the given AIG and the GMP library [11] to represent large integers.
AMulet2 supports three modes, substitute, verify, and certify. The mode of AMulet2 is triggered by the command line input, see also the usage demo in Sect. 5. In substitution mode, AMulet2 parses the AIG, allocates the internal gate structure, and invokes the substitution engine for adder substitution. In verification mode, AMulet2 reads the AIG and initializes the gate structure. Afterward, the circuit is verified In the following, we present the individual components of AMulet2 and summarize the improvements over AMulet1.

Parser module
AMulet2 checks whether the given AIG circuit fulfills the requirements described in Sect. 2, i.e., the AIG circuit has an even number of inputs and an equal number of outputs and does not contain any latches. The AIG module wraps functions of the external AIGER library that are needed to process the input file.

Gate library
After parsing, AMulet2 allocates a gate for each AIG node, which includes structural information of the node, such as dependencies, or whether the gate represents an input/output or an XOR gate. Each gate is linked to a unique variable. If the given AIG is verified or certified, AMulet2 also initializes the gate constraints and creates the specification polynomial L ∈ Z[X ].

Substitution engine
In substitution mode, AMulet2 applies heuristic pattern matching to identify GP adders [23]. The algorithms in the substitution engine are almost the same as in AMulet1 [26] and highly relate on the structure of GP adders, cf. Sect. 2.4. In particular, we use the fact that the outputs of GP adders are always outputs of XOR gates, but the carries are never outputs of XOR gates. This allows us within one iteration over the output bits to mark the carries c i (including the carry output c out ) and propagate bits p i of the GP adder and we are further able to identify and mark all inputs x i , y i of the GP adder using the relation p i = x i ⊕ y i .
In a second step, we mark all gates that belong to the FSA. We start at the carry output c out resp. sum outputs and follow all paths in the input cones until we either reach a marked input x i , y i , or c in . We mark the visited variables. If at some point we reach one of the input variables a i , b j of the multiplier, the FSA is not a GP adder, i.e., we were not able to clearly identify the boundaries of the FSA. Consequently, adder substitution was not successful and the initially given AIG is returned without generating a bit-level miter. If on the other hand all paths stop at the marked inputs or at c in , we have successfully identified and marked all gates belonging to a GP adder and apply adder substitution.
In AMulet2, we enhanced the identification heuristics and cover special cases, e.g., in some architectures, we have x i = x i+1 , that are not considered in AMulet1. Thus, AMulet2 is able to detect more GP adders. After a positive GP pattern match, AMulet2 replaces the GP adder by an equivalent RC adder. A bit-level miter is generated in CNF to verify the equivalence of the adders. The rewritten multiplier and the CNF miter are printed to the provided output files.

Polynomial solver
The polynomial solver is a modernized version of the solving engine of AMulet1 [26] and is used to verify or certify the given multiplier. In a nutshell, the polynomial solver first applies preprocessing by eliminating selected variables. Afterward, the remaining variables are ordered into column-wise slices, such that we can apply our incremental verification algorithm [25], where we split the specification L into multiple polynomials and verify the multiplier by deriving the correctness of each slice using polynomial reduction. The necessary polynomial operations are implemented in our Polynomial Library described below.
In AMulet2, we eliminate variables before ordering them, whereas in AMulet1, it is the other way around. In a first step, we eliminate all internal gates of the XOR structures and all single-parent nodes in the AIG. Thus, fewer variables are considered for ordering, which improves computation time of AMulet2.
Furthermore, we include a novel XOR-based slicing approach in AMulet2, which relies on the fact that many multiplier architectures use XOR-skeletons to compute the output bits. We identify these skeletons as follows. We start from the output bits of the given multiplier and follow all paths as long as the gates are identified as (internal) XOR gates or encode partial products, i.e., both children are inputs of the AIG. All nodes of a skeleton are assigned to the same slice. Figure 3 shows the AIG of a simple 4-bit multiplier. We uniquely colored for each output bit the corresponding XOR-skeleton. Gates occurring between XOR-skeletons are assigned to the smaller (less significant) slice. Hence, after two iterations, all slices are fixed, which improves slicing compared to AMulet1. All variables that are not assigned to slices, e.g., gates used to compute the partial products in Booth encoding [36], are eliminated from the gate structure.
In few cases, we cannot identify XOR-skeletons, e.g., in multipliers containing a carry-select adder, and we fall back on the slicing approach of AMulet1 [26]: We slice based on input cones and eagerly move gates between slices to reduce the number of carries, by iterating multiple times over the variables.
After assigning gates to slices, AMulet2 reduces the slice-wise specifications incrementally by the sliced gate constraints and checks whether the final result is zero, similar to the implementation of AMulet1. If the final remainder is not zero, AMulet2 detects counter examples, i.e., input assignments for which the multiplier circuit computes an incorrect result.
In certification mode, AMulet2 tracks polynomial operations in the selected proof format and prints gate constraints, the generated proof, and the specification L to the provided files.

Polynomial library
The polynomial library implements the arithmetic operations for addition and multiplication of polynomials (by constants), and division by terms. Since all variables represent Boolean values, we always reduce exponents greater than one automatically to one, i.e., we assume x · x = x. All algorithms for polynomial operations are optimized accordingly.
Polynomials are represented as sorted linked lists of monomials. Each monomial consists of a coefficient, represented using the GMP library, and a term. Terms are linked lists of variables, which are internally shared using a hash table.
In AMulet1, we do not share monomials and make hard copies in the few occasions when a monomial needs to be copied. This has the benefit that we can simply modify coefficients of the monomials, e.g., during addition. In our experiments, we observed that allocating new GMP objects is actually quite time consuming, and therefore, we now share monomials in AMulet2, using reference counting, which decreases verification time by a factor of two.

Improvements over AMULET1
AMulet2 contains some major improvements over AMulet1, which can be clearly seen in the experimental evaluation. At this point, we summarize the major improvements of AMulet2 over AMulet1 that are scattered in this section in one place: • Modular re-implementation in C++, which allows reusing single components. • Consideration of corner cases during adder substitution has the effect that more GP adders are detected. • Restructuring the order of variable elimination and slicing to reduce the amount of gates that have to be ordered. • Novel XOR-based slicing approach, which leads to faster verification time. • Sharing of monomials in the data structure, which speeds up verification time. • Invoking multiple proof formats.

AMULET2.1
Our experimental evaluation, cf. Sect. 6 shows that AMulet2.0 needs more memory than AMulet1 for 64-bit multipliers. We have addressed this issue and enhanced the algorithms and used data structures to reduce the memory usage. The improvements are published in AMulet2.1 [18], which further contains some bug-fixes on the slicing approach.
First of all, AMulet2.0 generates all gate constraints during the initialization phase. These polynomials are kept in memory through the whole verification process, although they might only be used in the final reduction steps. In AMulet2.1, we now generate the gate constraints on the fly. Whenever an original gate constraint is required during variable elimination or during reduction, we generate the corresponding polynomial encoding that is implied by the AIG. These polynomials will be deleted again after the elimination or the reduction step and we only keep the rewritten polynomials that are generated during variable elimination in memory, which reduces the size of the hash table used for sharing the terms/monomials significantly.
Although the deletion of gate constraints means that we sometimes have to generate the same polynomial equation multiple times, our experimental evaluation shows that this is less costly than maintaining a large hash table.
Second, we optimized the data structure of the polynomials in AMulet2.1. In AMulet2.0, we store the polynomials as a linked list of monomials using std::deque. Using deques proved to be faster than std::vector, but they have a higher minimal memory cost. Using an array for storing the monomials in AMulet2.1 decreased the memory usage by around 10% without affecting the verification time.
As a third modification, we changed the format of the proof certificates in AMulet2.1. In AMulet2.0, certificates can be generated in the Nullstellensatz proof format [21] or in PAC [27] to validate the verification results. For proof checking, two different proof checkers are necessary, depending on which proof calculus is selected. Recently, we developed LPAC (PAC + linear combinations) that unifies both proof formats [28]. LPAC proofs consist of a sequence of linear combination rules, cf., Example 5. It is possible to simulate Nullstellensatz by writing down only a single linear combination step, as well a PAC proofs by simulating single addition and multiplication steps. Furthermore, it is possible to generate certificates on an intermediate density level, i.e., a sequence of linear combinations. These proofs are more concise than pure PAC proofs, but still allow to localize errors. AMulet2.1 supports LPAC proofs on three density levels, which is demonstrated in the following Sect. 5.

Usage
In this section, we demonstrate the usage of our tool AMulet2.1. The usage for AMulet2.0 is almost identical, only the options in the certification mode differ, cf. Sect. 5.3, due to the change in the proof formats. AMulet2.1 relies on the AIGER library [5] and the GMP library [11]. The AIGER library is provided together with the source code of AMulet2.1, the GMP library needs to be preinstalled by the user. AMulet2.1 is compiled executing "./configure.sh && make." In a complete workflow, one should first apply adder substitution, using the substitution mode, to make sure that a potential complex FSA is replaced by a simple RC adder. Afterward, one of the two modes, the verification mode or certification mode, can be applied to verify the (simplified) multiplier, which we will call in the following rewritten multiplier. If it is known that the final stage adder is not a complex GP adder, the substitution step can be omitted. Figure 4 shows our tool chain used for verifying (left side) and certifying (right side) multiplier circuits. We present a complete demonstration for the unsigned 64-bit multiplier <bpwtcl.aig>, which is included in the complementary material [16]. The output of AMulet2.1 can be seen in the corresponding log-files that are also included in the artifact [16].
cnf rewritten.aig [options] If the multiplier computes multiplication of signed integers, the option "-signed" has to be involved, because the signedness is part of the circuit specification. If adder substitution can be applied successfully, the generated miter is written to <miter.cnf> and the rewritten multiplier to <rewritten.aig>. Otherwise, a trivial unsatisfiable CNF is written to <miter.cnf> and the given multiplier will be written to <rewritten.aig>. The file <miter.cnf> has to be given to a SAT solver, e.g., Kissat [4], which is then expected to return unsatisfiable. The rewritten multiplier can be verified or certified using AMulet2.1.

Verification
Verification is executed by ./amulet -verify rewritten.aig [options] As for adder substitution, one has to invoke the option "-signed" for verification of signed multipliers. Furthermore, the option "-no-counter-examples" is available, which turns off generation and saving of counter examples, in the case when the circuit in <rewritten.aig> is incorrect.

Certification
Certification is applied using ./amulet -certify rewritten.aig out.pol out.prf out.

spc [-pN] [options]
In this mode, AMulet2.1 verifies the multiplier and automatically generates proof certificates, which can be checked by corresponding proof checkers. AMulet2.1 supports the LPAC proof format on three different density levels, which can be selected using options "-p1", "-p2" or "-p3". The option "-p1" selects the most expanded proof, which generates a proof step for every single polynomial operation. Typically, for each D-reduction step, a multiplication and addition are applied, thus two proof steps are generated for each reduction step. These proof certificates are close to PAC proofs. The option "-p2" combines the multiplication and addition steps of each D-reduction, into a single proof step. Thus, the proof files typically have only 50% of the size of "-p1"proofs, but we are still able to associate errors in the proofs to single D-reduction steps. The option "-p2" is the default proof format in AMulet2.1.
The option "-p3" is the most concise proof format and only generates a single proof rule, i.e., a single linear combination. Proofs with option "-p3" simulate Nullstellensatz proofs. All options of the verification mode are available too.
The proof is stored in the provided files <out.pol>, <out.prf>, and <out.spc>. The file <out.pol> contains the gate constraints, the second file <out.prf> the core proof in the selected proof format and the third file <out.spc> the specification of the multiplier. The generated proofs can be given to the proof checkers Pacheck 2.0 [19], or Pastèque 2.0 [10].
The involved SAT solver for checking adder equivalence produces a proof certificate in the DRUP format [12]. Since two different proof formats are involved, the generated certificates can only be trusted up to compositional reasoning. Thus, we generated a method to translate DRUP proofs into PAC [24], which can be applied on top to generate a combined proof certificate in a single proof format, see for example the experimental evaluation in [28].

Evaluation
In our experiments, we use an Intel Xeon E5-2620 v4 CPU at 2.10 GHz (with turbo-mode disabled) with a memory limit of 128 GB. The time is listed in seconds (wall-clock time). We compare AMulet2 to our previous tool AMulet1 and to the most recent related work RevSCA-2.0, RevSCA [34], DyPoSub [35], and ABC-based work [8] on multiplier verification using computer algebra, where circuits are given as AIGs.
The tool RevSCA and its successor RevSCA-2.0 [34] use a preprocessing technique that aims to detect converging gate cones and atomic blocks, such as half and full adders, in the given AIG. For each converging gate cone and atomic block, a vanishing-free specification polynomial is generated, i.e., a polynomial where all monomials are removed that will reduce to zero later in the reduction process. This helps to compress the Gröbner basis before reduction is applied. DyPoSub is a follow-up work of [34] and explicitly tries to tackle the problem of verifying multiplier circuits, where logic synthesis and technology mapping is applied. The main idea in DyPoSub is to use a dynamic substitution order that allows to keep the size of the intermediate reduction results on a moderate level. The preprocessing steps in DyPoSub are the same as in its predecessor RevSCA-2.0. In ABC-based work of [8], a method called function extraction is used to verify circuits. Function extraction is a similar algebraic approach to Gröbner basis reduction as presented in Sect. 2. The difference to Gröbner basis reduction is that it is not required to provide the complete specification polynomial of the circuit for reduction. Instead the word-level output of the circuit, i.e., the bit vector 2n−1 i=0 2 i s i for unsigned numbers resp. −2 2n−1 s 2n−1 + 2n−2 i=0 2 i s i for signed number representation is reduced by the gate constraints of the given circuit. This method returns a unique polynomial representation of the functionality of the circuit in terms of the circuit inputs. In order to verify correctness of a circuit, the remainder polynomial needs to be compared to the desired circuit functionality.
In our experiments, we consider two versions of our tool AMulet1: (i) AMulet1.0 as published in [23], (ii) AMulet1.5 a slightly improved version [15] with new heuristics for detecting GP adders. For AMulet2, we consider the version AMulet2.0 as published in [22] as well as its derivative AMulet2.1, which we discussed in Sect. 4.
For all AMulet versions, we measure and sum up the time of adder substitution, verification and the time the SAT solver Kissat needs, i.e., all steps that are included in the rectangle on the left side of Fig. 4. All experimental data, benchmarks and the source code of AMulet2.1 are available at [20].
In our first experiment, we consider the comprehensive AOKI benchmark set [14] that provides 384 signed and unsigned integer multiplier architectures up to input bitwidth 64. The AOKI benchmark set combines a wide range of PPGs, PPAs, and FSAs, including Booth encoding, Wallace tree accumulation, and carry-lookahead adders. We consider all 384 possible architectures of bit-width 64. The time limit in our experiments is set to 300 seconds. The results are shown in Figs. 5 and 6, where it can be seen that AMulet2 is the only tool that is able to verify the complete benchmark set within the given time limit. ABC-based work of [8] uses an optimization, which only works for simple multiplier architectures. Enabling this optimization on the more involved AOKI benchmarks leads to incompleteness. Without enabling it [8] either produces a segmentation fault or exceeds the time limit. Thus, there are no results for [8] in Figs. 5 and 6. It can be seen in Fig. 5 that AMulet2.0 and its derivatives are faster than the predecessor AMulet1.0 and clearly outperforms related work. Figure 6 shows the memory usage of the tools and it can be seen that all versions of AMulet use less memory than tools of related work. However, AMulet2.0 is less memory efficient than AMulet1.0, and AMulet1.5. This flaw has been fixed in AMulet2.1, which needs significantly less memory than AMulet2.0.
In our second experiment, we generate benchmarks of simple multipliers up to input size 2 048, using scripts by Arist Kojevnikov [13]. The time limit is set to 86 400 seconds (24 h) and the results are shown in Figs. 7 and 8. Since we are considering simple multiplier architectures, we can make use of the optimization in ABC-based work of [8]. It can be seen that AMulet2 outperforms all competitor tools and is an order of magnitude faster on large multiplier circuits. The memory usage is shown in Fig. 8, where it can be seen that ABC-based work of [8] is the most memory efficient.
In our third experiment, we generate large benchmarks of complex multipliers up to input size 1 024 using Mult-Gen [38]. We choose the architecture "bp-wt-lf" that uses a Booth encoding to generate the partial products, which are then accumulated using a Wallace tree. The final stage adder is a Ladner-Fischer adder. The time limit is again set to 86 400 seconds (24 h), and the results are shown in Fig. 9 and 10. Since "bp-wt-lf" is a complex architecture, we had to disable the optimization in the ABC-based work, which leads to segmentation faults. The tool RevSCA exceeded the time limit  It can be seen in Fig. 9 that AMulet2.1 is more than an order of magnitude faster than related tools, however, AMulet2.1 requires twice as much memory than AMulet1.0 resp. AMulet1.5, cf. Fig. 10. The cause is currently unclear and investigating why AMulet2 is more memory hungry than AMulet1 on large complex multipliers is an interesting future work.

Conclusion
We presented AMulet2, a fully automatic tool for verifying multiplier circuits given as AIGs. AMulet2 is a re-factorization and re-implementation of our previous verification tool AMulet1 [23,26] and successfully verifies a large set of multiplier architectures. We further discussed novelties in the maintained version AMulet2.1, which help to reduce the memory usage of AMulet2.0 significantly. In the future, we want to directly integrate a SAT solver into AMulet2 and provide language bindings, e.g., for Python.
Funding Open access funding provided by TU Wien (TUW).  Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/.