Combinations of Boolean Groebner Bases and SAT Solvers
Combinations of Boolean Groebner Bases and SAT Solvers
D386
To my family
Acknowledgments
I would like to express my deep gratitude to Professor Gerhard Pfister, my supervisor, for his
patient guidance, enthusiastic encouragement of this thesis. I would also like to thank Dr.
Alexander Dreyer and Dr. Michael Brickenstein for their advice and assistance during my
research progress. My grateful thanks are also extended to Dipl.-Ing. Oliver Marx for his help
in hardware description language VHDL. I would like to express my very great appreciation
to Dr. Avi Yadgar for sharing his source code with me.
I would also like to offer my special thanks to the department SYS in ITWM for their
financial support and an excellent research environment.
Finally, I wish to thank my family.
ii
Contents
List of Algorithms v
List of Tables ix
Introduction 1
iii
5.3 Algebraic models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.4 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.4.1 Multiplier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.4.2 FIR Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
iv
List of Algorithms
1.1.1 DPLL algorithm, DPLL(F ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1.2 Typical CDCL algorithm, CDCL(F, ν) . . . . . . . . . . . . . . . . . . . . . . 7
1.2.1 Normal form, N F (f | G) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.2.2 Reduced normal form, redN F (f | G) . . . . . . . . . . . . . . . . . . . . . . . 11
1.2.3 Gröbner basis of S ⊂ K[x], K is field . . . . . . . . . . . . . . . . . . . . . . . 11
1.2.4 Gröbner basis of S ⊂ R[x], R is principal ring . . . . . . . . . . . . . . . . . . 12
v
vi
List of Figures
1.1 Implication graphs with 1-UIP cuts . . . . . . . . . . . . . . . . . . . . . . . . 8
vii
viii
List of Tables
1.1 First decisions of CDCL Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 8
ix
x
Introduction
In this thesis, we will combine Gröbner basis with SAT Solver in different manners. The
Boolean satisfiability (SAT) problem is the problem of finding an assignment of a set of Boolean
variables V such that a Boolean formula F (V ) will have the value true under this assignment.
A tool that can solve a SAT problem is called a SAT Solver. The SAT problem is very
intersting not only in theory but also in practice. Although the complexity of the SAT problem
is NP-complete, many modern SAT solvers can still solve many real world problems efficiently,
including hardware verification, software verification, planning and scheduling.
On the other hand, Gröbner basis is one of the central concepts in computer algebra. It
is a specific generating set of an ideal over a polynomial ring with extremely nice properties.
Gröbner basis techniques have many applications in algebraic geometry, optimization, coding,
robotics, control theory, molecular biology, and many other fields.
Both SAT solvers and Gröbner basis techniques have their own strength and weakness.
Combining them could fix their weakness. Subsequently, several research groups made con-
siderable efforts to combine Gröbner basis techniques with SAT Solvers. Matthew Clegg at
al. [CEI96] introduced a Gröbner proof system combining Buchberger’s algorithm [Buc85] with
the backtracking technique of a SAT Solver. In contrast, Condrat and Kalla used Gröbner
basis to preprocess CNF formulæ [CK07] before giving them to a SAT solver, while Zengler
and Küchlin [ZK10] use Gröbner basis techniques to obtain additional informations for SAT
Solvers.
SAT solvers and Boolean Gröbner basis computations use different inputs. Most of the SAT
solvers use proposition formulæ in conjunctive normal form (CNF) as input. In conjunctive
normal form, only three operators, and (∧), or (∨) and negation (¬) are used to represent
a propositional formula. The input for Boolean Gröbner basis computations is a system of
Boolean polynomials. Boolean polynomial is a polynomial in Z2 [x1 , . . . , xn ], where each term
has degree at most one per variable. Therefore, to combine SAT Solvers and Gröbner basis
techniques, we need an algorithm to convert Boolean polynomials to CNFs and another one to
convert CNFs to Boolean polynomials. In this thesis, we will present some classical conversions
as well as some refinements of these conversions.
The first combination is using Gröbner techniques to learn additional binary clauses for
CDCL SAT solver from a selection of clauses. This combination is first proposed by Zengler
and Küchlin [ZK10]. However, in our experiments, about 80 percent Gröbner basis computa-
tions give no new binary clauses. By selecting smaller and more compact input for Gröbner
basis computations, we can significantly reduce the number of inefficient Gröbner basis com-
putations, learn much more binary clauses. In addition, the new strategy can reduce the
solving time of a SAT Solver in general, especially for large and hard problems.
The second combination is using all-solution SAT solver (find all satisfying assignments for
given formula) and interpolation to compute Boolean Gröbner bases of Boolean elimination
ideals of a given ideal. Computing Boolean Gröbner basis of the given ideal is the classical
method to compute Boolean elimination ideals. However, this method is inefficient in case we
want to eliminate most of the variables from a big system of Boolean polynomials. Therefore,
we propose a more efficient approach to handle such cases. In this approach, we combine
1
all-solutions SAT Solver and interpolation to compute a Boolean Gröbner basis of elimination
ideals. This means that we do not compute a Gröbner basis of the given ideal but only
a Gröbner basis of the ideal corresponding to the projection given by elimination of some
variables. The given ideal is translated to the CNF formula. Then an all-solution SAT Solver
is used to find a finite set of points, the projection of all solutions of the given ideal. Finally, an
algorithm, e.g. Buchberger-Moeller Algorithm, is used to associate the reduced Gröbner basis
to this set of points. We also optimize the Buchberger-Moeller Algorithm for lexicographical
ordering and compare it with the algorithm from [BD13], an alternative to the Buchberger-
Moeller Algorithm for Boolean polynomials.
Finally, we combine Gröbner basis and abstraction techniques to the verification of some
digital designs that contain complicated data paths, such as multiplier and filter. Firstly,
abstraction techniques are used to lift bit operations to word operations whenever possible.
By this way, we can construct an abstract model. Then, we reformulate it as a system of
polynomials in the ring Z2k [x1 , . . . , xn ]. The variables are ordered in a way such that the
system has already been a Gröbner basis w.r.t lexicographical monomial ordering. Finally,
the normal form is employed to prove the desired properties. To evaluate our approach, we
verify the global property of a multiplier and a FIR filter using the computer algebra system
Singular [DGPS12]. The result shows that our approach is much faster than the commercial
verification tool from Onespin [One] on these benchmarks.
We structure the thesis as follows. Basic knowledge about SAT Solvers and Gröbner bases
is given in chapter 1. In chapter 2, we discuss about the relations between Boolean polynomials
(the input for Boolean Gröbner basis computations) and conjunctive normal forms (the input
for SAT Solvers). Chapter 3 shows how to learn additional binary clauses for SAT solvers
using Boolean Gröbner bases efficiently. Using all-solution SAT solver and interpolation to
compute a Boolean Gröbner basis of elimination ideals is presented in chapter 4. In the
final chapter, we combine Gröbner basis and abstraction techniques to verify digital designs
containing complicated data paths.
2
Chapter 1
Boolean Satisfiability and Boolean
Gröbner bases
1.1 Boolean Satisfiability
The Boolean Satisfiability problem is very intersting not only in theory but also in practice.
It is the first problem to be proven NP-complete. However, modern SAT solvers can still solve
many real world problems efficiently, including hardware verification, software verification,
planning and scheduling.
Some classical notions as well as algorithms for state-of-the-art solving of the satisfiability
problem will be given in this section, for more details see – for instance – [BHvMW09].
C1 := ¬x ∨ y and C2 := x ∨ ¬y ∨ z
and 3 variables x, y, z. The clause C1 consists of 2 literals ¬x and y. The CNF can be rewritten
as
F = {{¬x, y}, {x, ¬y, z}}.
3
and the assignment ν = {x, y, ¬z}, e.g x = true, y = true, z = f alse, is a solution for F .
Therefore, F is satisfiable.
Definition 1.1.4. Two literals are said to be complements if one is the negation of the other.
Let C1 and C2 be clauses containing complementary literals. Assume that
where x is a variable, l1 , . . . , lk1 , l10 , . . . , lk0 2 are literals. The the resolvent of C1 and C2 is defined
to be
C := l1 ∨ . . . lk1 ∨ l10 ∨ · · · ∨ lk0 2 .
The rule that replaces C1 and C2 by their resolvent C is called the resolution rule.
The resolution rule in propositional logic is a single valid inference rule that produces a
new clause implied by two clauses containing complementary literals.
The result of conditioning a CNF formula F on a literal l is the CNF formula, denoted by
F | l, which can be obtained from F by
In notation, F | l = {C − {l} | C ∈ F, l ∈ C}
The result of existentially quantifying a variable x from a formula F is denoted by ∃xF
and defined as follows:
∃xF := F | x ∨ F | ¬x.
The most important property of existential quantification is that F is satisfiable if and only
if ∃xF is satisfiable. Notice that ∃xF has one variable less than F (if F involves x).
Whenever there exists a unit clause in the CNF F , we could simplify F by conditioning it
on the only literal of that unit clause. We continue this process until the result CNF contains
no unit clauses. This technique is called unit resolution (or unit propagation).
The Algorithm 1.1.1 represents the DPLL Algorithm in pseudocode. It will call at first the
function unit-resolution. This function will return
4
• G, a new CNF which results from conditioning F on literals in I.
In case the two termination conditions above fail, the algorithm will pick a literal l in G, and
solves two SAT problems with the new CNFs G | l and G | ¬l. If one of them are satisfiable,
it will return a solution for F , otherwise it will return unsatisfiable.
We will use the algorithm 1.1.1 to check the satisfiability of F . Initially, there is no unit clause
in F . In addition, the formula F is neither empty nor containing empty set. Therefore, the
algorithm takes a literal x, and conditions F on x:
Now, DPLL is applied again to check satisfiability of F |x. The formula F |x contains a unit
clause {¬y}. Hence, the function unit-resolution(F | x) is called, and return I = {¬y, ¬z}
and G = { }. The DP LL(F | x) will return {¬y, ¬z} since G is empty. As a result, the
DP LL(F ) will return {x, ¬y, ¬z} which is a solution for F , that means F is satisfiable.
Among all DPLL-based SAT Solvers, the Conflict Driven Clause Learning (CDCL) SAT
solver is the most efficient one. It can solve a lot of practical SAT problems. The power of
the CDCL Solver comes from the ability of learning from conflicts. Some famous CDCL SAT
Solvers are MiniSat [ES04], Glucose [AS09] and CryptoMiniSat [SNC09].
5
1.1.3 Conflict Driven Clause Learning SAT Solver
Algorithm 1.1.2 shows the standard organization of a Conflict Driven Clause Learning SAT
solver. With respect to DPLL, the main differences are the call to function ConflictAnal-
ysis each time a conflict is identified, and the call to Backtrack when backtracking takes
place. Moreover, the Backtrack procedure allows for backtracking non-chronologically. The
following functions are used in algorithm 1.1.2:
1. UnitPropagation consists of the iterated application of the unit clause rule. If all
literals in a clause are f alse except one literal l, the literal l must be true to make the
clause satisfy. This rule is called unit clause rule. If an unsatisfied clause is identified
during unit propagation, then a conflict indication is returned.
3. ConflictAnalysis consists of analyzing the most recent conflict and learning a new
clause from the conflict.
5. AllVariablesAssigned tests whether all variables have been assigned, in which case
the algorithm terminates indicating that the CNF formula is satisfiable.
In the conflict analysis step, there are several learning schemes used to learn new clauses. To
understand these learning schemes, we need the implication graph. This graph reflects the
unit propagation process and conflicts (if they exists).
Definition 1.1.6. The implication graph G at a given state of DPLL is a directed acyclic
graph with edges labeled with sets of clauses. It is constructed as follows:
1. Create a node for each decision literal, labeled with that literal.
2. While there exists a clause C = {l1 , . . . , lk , l} such that all nodes with lables ¬l1 , . . . , ¬lk
are in G, but neither l nor ¬l labels a node in G,
(a) add a node with label l to G, and
(b) add directed edges from li to l with label C, 1 ≤ i ≤ k.
3. While there exists a clause C = {l1 , . . . , lk } such that all nodes with labels ¬l1 , . . . , ¬lk
are in G,
(a) add a node with label K to G, and
(b) add directed edges from li to K with label C, 1 ≤ i ≤ k.
The graph G contains a conflict if it contains a node K. Note that an implication graph
can contain no conflict or one conflict or several conflicts. The Figure 1.1.3 shows 2 examples
of implication graph.
In the rest of this section, we only consider the implication graph at a stage where there is
at least one conflict and fix a conflict if there are several ones. Pick any cut in the implication
graph that has all decision variables on one side, called reason side and the conflict node K
on the other side, called conflict side. All nodes on the reason side that has an edge going to
6
the conflict side form a cause of the conflict. Let C be the clause which contains the negations
of literals labeling nodes in the cause. C is called the learned clause associated to the cut.
The First Unit Implication Point is one of the best learning schemes and commonly used
in most of modern CDCL SAT solvers. A unique implication points (UIP) [MSSSS96] of an
implication graph G is a node of G such that all the paths from latest decision node to the
conflict node K go through it. The first UIP (or 1-UIP ) is the one that is closest to the conflict
node K. The 1-UIP cut is the cut of the implication graph such that all nodes reachable from
the 1-UIP are on conflict side and the rest nodes are on reason side. The learned clause
associated with 1-UIP cut is called 1-UIP clause.
Modern CDCL SAT solvers also often use search restart techniques [GSK98, BMS00] to
avoid getting too deep into spaces with no solutions. Search restart causes the algorithm to
restart itself, all assignments are taken back, but learned clauses are preserved.
The following example will help the reader understand in details how CDCL solve a SAT
problem.
Example 1.1.7. Let F be the CNF consisting of the following clauses r1 = {x1 , x2 }, r2 =
{¬x1 , ¬x4 , ¬x5 }, r3 = {x2 , x5 }, r4 = {¬x3 , x4 }, r5 = {x3 , x4 }, r6 = {x3 , ¬x4 }, r7 = {¬x4 , x5 }.
The Algorithm 1.1.2 solves this SAT problem as follows. At first, it performs unit propagation
on F , but F has no unit clause, hence there is nothing to propagate. It sets decision level to
zero and continues as in Table 1.1. The implied literals are new assignments obtained from
the unit propagation process. The corresponding implication graph is on the left hand side of
Figure 1.1.3. Conflict occurs at this level, hence the graph contains the node K. There are two
UIPs in this graph. The first UIP is x4 and the second UIP is x3 . The 1-UIP cut will generate
the 1-UIP clause r8 = {¬x1 , ¬x4 }. Add r8 to F as learned clause. The backtrack level is the
maximal level of variable in the 1-UIP clause without 1-UIP. In this case, the backtrack level
is 1 which is the level of the variable x1 . The algorithm backtrack to level 1, and clear all
assignments x2 , x3 , x4 and x5 .
7
Table 1.1: First decisions of CDCL Algorithm
Decision literal decision level implied literals conflict
x1 1 none no
x2 2 none no
x3 3 x4 , x5 {¬x1 , ¬x4 , ¬x5 }
r2 x1 ¬x4 ¬x3
x2
K r8 r4
r5
r5
r2 r2
x3 x4 K
x5
r4 r7
Now, the learned clause r8 becomes an unit clause. Unit progation on F leads to another
conflict. The implication graph on the right hand side of Figure 1.1.3 shows the situation of
this conflict. Analyzing this conflict using 1-UIP learning scheme as before, the second learned
clause r9 = {x4 } is added to F . The backtrack level for this conflict is 0. All assignment are
clear. The CNF F has a unit clause r9 = {x4 }. Perform unit propagation on F , the following
assignments (literals) are implied: x4 , x3 , x5 , ¬x1 and x2 . At this point, there is no conflict
and all variable are assigned, hence the algorithm terminates and returns a solution of F :
¬x1 , x2 , x3 , x4 , x5 .
We can see that all clauses in F are satisfied under these variable assignments.
8
1.2.1 Monomial ordering
Let R be any principal ideal ring with 1. Let R[x] := R[x1 , . . . , xn ] be the polynomial ring
over R in variables x1 , . . . , xn . We denote
Definition 1.2.1. We say > is a monomial ordering on a polynomial ring R[x] if it is a total
ordering on the set of monomials M onn = {xα | α ∈ Nn } satisfying
xα > xβ =⇒ xγ xα > xγ xβ
for all α, β, γ in Nn .
We call a monomial ordering > is global if xα > 1 for all α 6= (0, . . . , 0).
In this thesis, we only consider global monomial ordering. Examples for global orderings
are the lexicographical ordering (denoted by lex), the degree lexicographical ordering (denoted
by deglex). They are defined as follows:
Definition 1.2.2. Let > be a fixed monomial ordering on R[x]. Let I ⊂ R[x] be an ideal and
f ∈ R[x] a non-zero polynomial. The polynomial f can be written in a unique way as sum of
non-zero terms
f = aα xα + aβ xβ + · · · + aγ xγ
where aα , aβ , aγ ∈ R and xα > xβ > · · · > xγ . We defined
9
1.2.2 Normal forms and Gröbner bases
Normal forms of a polynomial with respect to a system of polynomials are defined as follows:
Definition 1.2.3. Let T denote the set of all finite subsets of R[x],
N F : R[x] × T −→ R[x], (f, G) 7→ N F (f, G)
is called a normal form on R if
1. N F (0 | G) = 0 for all G ∈ T ,
2. N F (f | G) 6= 0 ⇒ LT (N F (f | G)) ∈
/ L(G) for all f ∈ R and all G ∈ T ,
3. If G = {g1 , . . . , gs }, then, for any f ∈ R, r := f −N F (f |G) has a standard representation
with respect to G, that is,
s
X
r = f − N F (f | G) = ai gi , ai ∈ R, s ≥ 0,
i=1
The polynomial ring R[x] is Noetherian, since R is Noetherian. Hence, every ideal in R[x]
has a finite generating set. A Gröbner basis of an ideal is a particular generating set which
has some extremely nice properties.
Definition 1.2.5. Let I ⊂ R[x] be an ideal. A finite set G ⊂ R[x] is called a Gröbner basis
of I if
G ⊂ I, and L(G) = L(I).
A Gröbner basis G of I is called reduced if LC(f ) = 1 for any f ∈ G, and for any f 6= g ∈ G,
LM (g) does not divides any monomial of f .
10
Algorithm 1.2.2 Reduced normal form, redN F (f | G)
Input: f ∈ R[x], G ⊂ R[x], and a global monomial ordering >.
Output: h ∈ R[x], a reduced normal form of f with respect to G.
if f = 0 then
Return f
end if
f := N F (f | G)
Return LT (f ) + redN F (tail(f ) | G)
A Gröbner basis of an ideal in R[x] always exists, but the reduced Gröbner basic not
necessarily. With a fixed monomial ordering, a Gröbner basis of an ideal I is still not unique,
but the reduced Gröbner basis (if it exists) is unique.
Let I be an ideal in K[x], where K is a field, and let > be a global ordering on K[x].
Assume that I is generated by a finite set S. A Gröbner basis of I can be computed by the
Buchberger Algorithm, the Algorithm 1.2.3.
Consider the case R being a principal ring (i.e every ideal in R can be generated by one
element), e.g. Zm := Z/mZ. Gröbner basis computation over any principal ring is treated in
[BDG+ 09]. Here, we revise some basic notations
Definition 1.2.6. Let R be a principal ring and a ∈ R. The annihilator of a, Ann(a) = {b ∈
R | a · b = 0} is an ideal in R is generated by one element, which we denote by N T (a).
Because of zero divisors, we need to extend the definition of an s-polynomial.
Definition 1.2.7. Let f ∈ R \ {0}. We define the extended s-polynomial of f to be
The Algorithm 1.2.4 will return a Gröbner basis of an ideal in R[x], where R is a principal
ring.
The following theorem ensures the correctness of the Algorithm 1.2.3 and 1.2.4. It is called
Buchberger’s criterion.
11
Algorithm 1.2.4 Gröbner basis of S ⊂ R[x], R is principal ring
Input: S ⊂ R[x], where R a principal ring, and > a global ordering on R[x].
Output: G ⊂ R[x], a Gröbner basis of ideal generated by S in R[x].
G := S
P := {(f, g) | f, g ∈ G, f 6= g} ∪ {(0, f ) | f ∈ G}, the pair-set.
while P 6= ∅ do
Choose (f, g) ∈ P
P := P \ {(f, g)}
h := N F (spoly(f, g) | G)
if h 6= 0 then
P := P ∪ {(h, f ) | f ∈ G} ∪ {(0, h)}
G := G ∪ {h}
end if
end while
Return G
12
Definition 1.3.4. A function F : Zn2 −→ Z2 is called a Boolean function.
Theorem 1.3.5. The map from B to the set of Boolean functions by mapping a polynomial
to its polynomial function is an isomorphism of Z2 -vector spaces.
Corollary 1.3.6. Let p and q be two Boolean polynomials in Z2 [x1 , . . . , xn ]. If p and q have
the same zero-set then p = q.
the Boolean ideal of H. Let G be a finite set of Boolean polynomials in Z2 [x]. We call G a
Boolean Gröbner basis of hHi if G ∪ FP is a Gröbner basis of BI(H). We call G a reduced
Boolean Gröbner basis of hHi, BGB(H) for short, if there exists a subset S ⊂ FP such that
G ∪ S is a reduced Gröbner basis of BI(H).
By definition, the Buchberger algorithm can be used to compute the reduced Boolean
Gröbner basis of an ideal in Z2 [x]. Besides the chain criterion and the product criterion, there
is a new criterion for Boolean Gröbner bases. It is called Linear lead factor criterion which is
stated in the following theorem.
Theorem 1.3.8. Let f ∈ B. If f can be written as f = g.h, where the leading monomial of g
is xi for some i, then the reduced normal form of spoly(f, x2i + xi ) with respect to {f } ∪ FP
is zero.
Boolean polynomials manipulations as well as the reduced Gröbner basis of a Boolean ideal
in Z2 [x] can be computed efficiently in PolyBoRi software developed by Brickenstein and
Dreyer [BD09, Bri10]. See [Bri10] for more details.
13
14
Chapter 2
Relations between Boolean polynomials
and CNFs
Formulæ in CNF are the main input for most SAT solvers, while Boolean Gröbner basis
computation performs on Boolean polynomials. To cooperate the SAT solvers and Boolean
Gröbner bases, we need a good conversion between Boolean polynomials and CNFs as well as
understanding the relation between operations on these two objects.
B = {(a1 , . . . , an ) | ai ∈ Ai }.
15
With the map ψ1 , each prime block B = {(a1 , . . . , an ) | ai ∈ Ai } of O will be associated
with the clause that contains xi if Ai = {0}, and ¬xi if Ai = {1}. With the map ψ0 , each
prime block B = {(a1 , . . . , an ) | ai ∈ Ai } of O will be associated with the clause that contains
xi if Ai = {1}, and ¬xi if Ai = {0}. Conjunction of all clauses associated with all prime blocks
forms a CNF of p.
The original CNF encoder in [Bri10] uses the map ψ1 . However, we prefer the map ψ0 .
In the rest of this thesis, we only use the map ψ0 . The Algorithm 2.1.1 is a variant of the
algorithm given in [Bri10]. It replaces ψ1 by ψ0 .
Example 2.1.2. Let p = x1 + x2 · x3 . To find the CNF of p, the algorithm 2.1.1 will find ones
of p:
T := V := ones(p) = {(0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0)}.
After that, it sets H as a block of V that contains only one point in T , e.g (0, 1, 1), then tries
to extend this block to a prime block of V by adding j − th unit vector to each element of H.
The following prime blocks give a cover of V :
H1 = {(0, 1, 1)},
16
H2 = {(1, 0, 0), (1, 1, 0)},
H3 = {(1, 0, 1), (1, 0, 0)}.
c1 = {¬x1 , x2 , x3 }
c2 = {x1 , ¬x3 }
c3 = {x1 , ¬x2 }
When there are several polynomials in I concerning the same set S of variables, we can
convert them to a CNF at the same time. This conversion can further simplify the CNF of I.
It can be done as follows: when converting a Boolean polynomial p to a CNF, we also looking
for the group SV (p) of Boolean polynomials in I containing the same set of variables as p. In
the Algorithm 2.1.1, instead of setting V := ones(p, Zn2 ), we set
[
V := ones(q, Zn2 ).
q∈SV (p)
Converting polynomials in I one by one will produce the CNF F of I containing following
clauses:
However, polynomials in I having the same set of variables can be converted to a CNF at
the same time. The resulting CNF of I in this case is G = {{x1 }, {x2 }, {x3 }}.
Lemma 2.2.1. The following statements are true for every Boolean polynomials p and q.
2. φ1 (p ∧ q) = φ1 (p) · φ1 (q)
3. φ1 (¬p) = φ1 (p) + 1
17
4. φ0 (p ∨ q) = φ0 (p) · φ0 (q)
6. φ0 (¬p) = φ0 (p) + 1.
Proof. These statements can be proven by truth tables.
With one of the map φ0 or φ1 , we can convert the whole CNF formula to a single Boolean
polynomial, but usually the result is too complicated. For practical reasons, it is recommended
to map each clause in the CNF to a Boolean polynomial and the whole CNF is mapped to a
system of Boolean polynomials.
We prefer the map φ0 since it is more natural to map x1 ∨ x2 to x1 x2 than to x1 x2 + x1 + x2 .
In the rest of this thesis, we only use the map φ0
Example 2.2.2. Let F = C1 ∧ C2 be a CNF formula, where C1 = x1 ¬x2 and C2 = ¬x3 ∨ x4 ,
then
f 3 = x1 x2 x3 x4 + x 1 x2 x3 + x1 x3 x4 + x1 x2 + x 1 x3 + x3 x4 + x1 + x3 .
In practice, we would convert F to the system of Boolean polynomials {f1 , f2 } instead of only
one Boolean polynomials f3 .
Lemma 2.2.3. Let C1 and C2 be clauses satisfying the condition: there exist a literal l in C1
such that ¬l is in C2 , then φ(C1 ) · φ(C2 ) = 0
Proof. By definition,
φ0 (C1 ) = φ0 (C1 \ {l}) · φ0 (l), and φ0 (C2 ) = φ0 (C1 \ {l}) · (φ0 (l) + 1).
Hence, the product of the two Boolean polynomials φ(C1 ) and φ(C2 ) is zero.
Remark 2.2.4. It holds that ψ(φ(C)) = C for any clause C. However, the equality φ(ψ(p)) =
p is not true for any Boolean polynomial p.
In case there exists a CNF sub-formula S containing clauses of the same variable, we propose
converting S to one Boolean polynomial. This method can not only reduce the number of
polynomials, but also reduce the degree of the polynomial. The following lemma allow simplify
the conversion of the and operation in this case.
Lemma 2.2.5. Let S := {C1 , . . . , Cm } ⊂ {(l1 , . . . , lk ) | li ∈ {xi , ¬xi }, i = 1, . . . , k} and assume
that all Ci are pairwise different, then
m
^ m
X
φ0 ( Ci ) = φ0 (Ci ).
i=1 i=1
18
Proof. By definition,
Therefore, by induction,
m
^ m
Y
φ0 ( Ci ) = (φ0 (Ci ) + 1) + 1.
i=1 i=1
However, there always exists a literal l such that l in Ci and ¬l in Cj for any i 6= j. By Lemma
2.2.3, φ0 (Ci ) · φ0 (Cj ) = 0 for any i 6= j. Hence,
m
^ m
X
φ0 ( Ci ) = φ0 (Ci ).
i=1 i=1
Apply the map φ0 to the whole formula F , the Boolean polynomial of F is computed as
follows:
φ0 (C1 ) = x1 x2 x3 + x1 x3 + x2 x3 + x3 ,
φ0 (C2 ) = x1 x2 x3 + x1 x2 + x2 x3 + x2 ,
φ0 (C3 ) = x1 x2 x3 + x1 x2 + x1 x3 + x1 ,
φ0 (C4 ) = x1 x2 x3 ,
φ0 (F ) = φ0 (C1 ) + φ0 (C2 ) + φ0 (C3 ) + φ0 (C4 ) = x1 + x2 + x3 .
Remark 2.2.7. With the new method, every linear polynomial will be recovered after forward
and backward conversions.
Proof. By the identification and the property of conversion using the map φ0 , the clause C
and the Boolean polynomial φ0 (C) have the same set of solutions. Hence
19
Lemma 2.3.2. Let C be the non-trivial resolvent of two clauses, C1 and C2 , then φ(C) is
equal to the reduced normal form of the s-polynomial of φ(C1 ) and φ(C2 ) with respect to φ(C1 )
and φ(C2 ).
Proof. The resolvent C is non-trivial, hence clause C1 has exactly one literal l such that ¬l is
in C2 We may assume that
_ _
C1 = xi ∨ xt ∨ (xj + 1)
i∈I1 j∈J1
_ _
C2 = xi ∨ ¬xt ∨ (xj + 1)
i∈I1 j∈J1
By definition of φ,
Y Y
f1 = xi · xt · (xj + 1)
i∈I1 j∈J1
Y Y
f2 = xi · (xt + 1) · (xj + 1)
i∈I2 j∈J2
Expand the last product in f1 and f2 , and use above notations, we can rewrite f1 and f2 as
follows
X X
f1 = PI1 · xt · PJ1 \K1 = xt PS1 \K1
K1 ⊂J1 K1
X X X
f2 = PI2 · (xt + 1) · PJ2 \K2 = xt PS2 \K2 + PS2 \K2
K2 ⊂J2 K2 K2
20
XX XX XX
= xt PS\(K1 ∪K2 ) + PS\(K1 ∪K2 ) + xt PS\(K1 ∪K2 )
K1 6=∅ K2 K1 6=∅ K2 K1 K2 6=∅
X X XX
= xt PS\K1 + xt PS\K2 + xt PS\(K1 ∪K2 )
K1 6=∅ K2 6=∅ K1 K2 6=∅
=: g
then f1 = h · f10 and f2 = h · f20 . Apply the previous result, the reduced normal form of
spoly(f10 , f20 ) w.r.t f10 and f20 is
Y Y
g0 = xi · (xj + 1).
i∈I10 ∪I20 j∈J10 ∪J20
It follows that
21
= h · RedN F (spoly(f10 , f20 ), {f10 , f20 })
= h · g0
Y Y
= xi (xj + 1)
i∈I j∈J
22
Chapter 3
Extending clause learning of SAT Solvers
We can use Boolean Gröbner bases to learn additional clauses for CDCL SAT Solvers. It is
based on the following lemma.
Lemma 3.0.3. Let F be a CNF and J be the ideal of F . Let C be a clause in the CNF of a
Boolean polynomial f ∈ BGB(J), then F implies C, or C is a valid lemma of F .
Proof. V (C) ⊃ V (φ−1 (f )) = V (f ) ⊃ V (J) = V (F ) where V(K) is standing for the solution
set of K. This shows that the CNF formula F ∧ C has the same set of solutions as F .
BGB(J) = {x1 x4 , x1 x3 + x1 , x1 x2 + x1 , x2 x3 + x2 }
The newly generated Boolean polynomial is x1 x3 . This polynomial corresponds to the clause
x1 ∨ x3 . It is a valid lemma of F .
3. If the number of good inputs is a multiple of 2#restarts , then they compute the BGB of
the last good input.
4. Collect all new polynomials with 2 variables from BGB and add their corresponding
clauses to the set of original clauses at next restart.
All parameters in their approach are chosen heuristically. The above parameters are not
strong enough to control the quality of the selection. For example, it is impossible to deduce
any binary clauses from a set of 6 clauses with length 8, see Lemma 3.1.1.
Lemma 3.1.1. Let m and k be natural numbers and m < k, then there are no clauses of
length k − m which can be deduced from m clauses of length k.
23
Proof. Let F = {C1 , . . . , Cm } be the set of m clauses of length k. Assume that we can deduce
from F a clause of length k − m, say lk−m+1 ∨ lk−m+2 ∨ · · · ∨ lk . Let xi be the variable of the
literal li for i = k − m + 1, · · · , k.
On the other hand, we can always choose a variable xi in Ci such that xi ∈ / Si , where
Si = {x1 , . . . , xi−1 , xk−m+1 , . . . , xk } for i from 1 to m, since Ci has k different variables and
Si has less than k variables. We assign to xi a truth value such that Ci is evaluated to true
for i = 1, . . . , m. Therefore, ν together with {x1 , . . . , xm } is a solution of F , contradictory to
above assumption.
To fix this issue, we propose a completely new strategy. To increase possibilities of getting
new binary clauses, clauses in the selection should be shorter and have more common variables.
Therefore, we select clauses of length at most 4 instead of 8 and introduce a new parameter
to adjust the number of common variables.
Definition 3.1.2. The density of variables in a set of clauses R is defined to be the quotient
of the number of variables in R and the number clauses in R. We denote it by dens(R).
Let m and n be the number of clauses and variables in the selection R, respectively. Let
a and c be the average length of the clauses and the number of occurrences of variables in R,
respectively. Let A be the average occurrences of a variable in R. Then,
c a.m a
A= = = .
n dens(R).m dens(R)
1. If the number of conflicts is a multiple of 2#restarts , then extending binary clause learning
by BGB, or Gröbner-learning for short, is activated.
2. When Gröbner-learning is activated, we collect at most 7 reason clauses such that each
clause has at most 4 literals at conflict analysis and add them to a list R.
3. If R has at least 4 elements and the density of variables in R is at most 1.4, we convert
every element in R to the corresponding polynomial, compute BGB of these polynomials,
and deactivate the Gröbner-learning.
4. Only collect new polynomials with two variables and then add their corresponding clauses
to the set of original clauses at next restart.
24
Table 3.1: Compare two BGB learning schemes.
ZK GB ND GB
name k GBtime BinCls GBs GBzeros GBtime BinCls GBs GBzeros
approve 17 5236 74373 194830 77% 323 80243 18859 6%
bioinfo 20 44517 56632 1346806 98% 444 124706 27355 30%
bitverif 11 17096 629918 1045119 69% 8291 4443896 558542 30%
c32sat 4 7271 11959 171503 96% 114 67474 6241 8%
crypto 11 493 24898 18106 52% 379 210077 23354 3%
palacios/uts 6 4540 67530 138423 72% 781 122631 60696 56%
parity-games 21 49437 378742 1563407 83% 1790 252054 145230 40%
sum 90 128590 1244052 4478194 84% 12122 5301081 840277 32%
25
Table 3.2: Analyze affects of density upper-bounds.
upper-bound GBtime BinCls GBs GBzeros Ratio
1.20 4929 3339453 306172 35% 10.9
1.25 6703 3573694 425067 34% 8.4
1.30 10154 5093819 689707 30% 7.4
1.35 10799 5184031 737096 30% 7.0
1.40 12122 5301081 840277 32% 6.3
1.45 23496 7697614 1483807 28% 5.2
1.50 28409 7972266 1818357 34% 4.4
ZK GB spends for Gröbner basis computations. The reason is that we compute fewer Boolean
Gröbner bases, but each of the Gröbner basis computation usually yields much more binary
clauses. We outperform Zengler’s and Küchlin’s approach on learning new binary clauses by
Boolean Gröbner bases.
In the second test, we want to motivate the density upper-bound setting. Therefore, we
use the same settings as above, but we vary the density upper-bound. Table 3.2 shows that
the larger density upper-bound is, the more binary clauses are learned in total, the more time
we spent in computing Gröbner bases, but the less binary clauses are learned in a Gröbner
computation. From these experiments the value of 1.4 seems to be a well-balanced setting.
To analyze the effect of our new parameter on solving time, we use our original setting,
but vary the density upper bound. Table 3.3 shows that the density upper bound has a very
strong effect on solving time. Again a density upper bound of 1.4 give the best score among
the others.
Finally, we use the original setting of both approaches. The solving time of both approaches
together with pure MiniSat is shown in Table 3.4. Our approach gets the best score among
others in 4of 7 benchmark categories (bioinfo, crypto, palacios/uts and parity-games) and also
in total solving time. The reason is that our solver can solve hard benchmarks faster, see
Fig. 3.1. Table 3.5 shows that our solver can learn more than 15 times the number of binary
clauses that Zenglin’s and Küchlin’s method can learn, but the time spent for computing
Gröbner bases is almost the same.
3.3 Conclusion
By introducing the density of variables as a criterion for the clause selection of the Gröbner
part, we significantly improved the efficiency of the hybrid Gröbner/CDCL-SAT approach.
26
Table 3.4: Compare solving time.
Name Pure ZK GB ND GB
aprove09 2569 736 3060
bioinfo 6361 7088 6057
bitverif 4950 12801 5172
c32sat 798 811 1001
crypto 3210 4587 2702
palacios/uts 1339 1253 1155
parity-games 24794 13655 3922
sum 44021 40931 23069
27
Figure 3.1: SAT solving time in seconds.
Using our heuristic we learn more binary clauses per computed Gröbner basis than the state-
of-the-art approach of Zengler and Küchlin. In particular, the number of Gröbner basis com-
putations yielding no useful information is reduced. This significantly improves the overall
runtime of SAT solving for a crucial set of benchmark examples.
28
Chapter 4
Elimination by all-solutions SAT and
interpolation
Boolean Gröbner bases is the classical tool to compute Boolean elimination ideals. However,
this method is inefficient in case we want to eliminate most of the variables from a big system
of Boolean polynomials. Therefore, we propose a more efficient approach to handle such cases.
In this approach, we combine all-solutions SAT Solver and interpolation to compute a Boolean
Gröbner basis of elimination ideals. This means that we do not compute a Gröbner basis of
the given ideal but only a Gröbner basis of the ideal corresponding to the projection given
by elimination of some variables. The given ideal is translated to the CNF formula. Then an
all-solution SAT Solver is used to find a finite set of points, the projection of all solutions of
the given ideal. Finally, an algorithm, e.g. Buchberger-Möller Algorithm, is used to associate
the reduced Gröbner basis to this set of points. We also optimize the Buchberger-Möller
Algorithm for lexicographical ordering and compare it with the algorithm from [BD13], an
alternative to the Buchberger-Möller Algorithm for Boolean polynomials.
An i-th elimination ideal does not contain the variables x1 , . . . , xi , neither does the basis
generating it. The basis of an elimination ideal can be a Gröbner basis by using the elimination
theorem:
Theorem 4.1.2. Let I ⊆ k [x1 , . . . , xn ] be an ideal and G be a Gröbner basis of I with respect
to a lex ordering where x1 x2 · · · xn . Then for every 0 ≤ i ≤ n, the set
Gi = G ∩ k [xi+1 , . . . , xn ] (4.2)
The proof for elimination theorem can be found in [GP07], page 70.
S = {y + x + xu, v + y + yz)}
29
To eliminate x, y, z, we need to re-order variables such that all eliminated variables are greater
than the remaining variables, e.g
u≺v≺x≺y≺z
There could be millions of solutions, then millions of such a long clauses will be added to the
solver. Therefore, blocking clauses can blow up the memory and slow down the solvers.
Orna Grumberg at el. [GSY04] developed a memory-efficient All-SAT engine that can avoid
adding blocking clauses. Therefore, the speed of the solver as well as the used memory is not
affected by the number of solutions found. Moreover, this engine can find the set of all the
assignments to a subset of variables, namely important variables, which can be extended to
solutions of the formula.
Example 4.2.1. Use the CNF encoder, as explained in the first chapter, to convert the ideal
in Example 4.1.3 to a CNF formula
30
Algorithm 4.3.1 Classical Buchberger-Möller Algorithm
Input: P = {P1 , ..., Pm } a set of points in K n and a monomial ordering on K[x1 , . . . , xn ]
Output: The reduced Gröbner basis G of the vanishing ideal I(P ) and a set of standard
monomials B
1: Initialization: G = ∅, B = ∅, L = {1}, and C a 0 × m matrix
2: while L 6= ∅ do
3: Set t = min (L) and remove t from L
n
4: Compute P the evaluation vector v = (t(P1 ), . . . , t(Pm )) ∈ K
5: if v = j P aj rj , a linear combination of the rows of C then
6: add t − j aj B[j] to G, and remove all multiples of t from L.
7: else
8: add v as a new row to C, append t to B,
9: add to L those elements of {x1 t, . . . , xn t} which are neither multiples of an element
of L nor of lead(G).
10: end if
11: end while
12: Return G, B
Algorithm (BMA, for short) was proposed in [MB82] as a tool to compute these vanishing
ideals. The algorithm below is a formulation of the Classical Buchberger-Möller Algorithm as
given in [ABKR00].
The main idea of the BM Algorithm is that it evaluates monomials one by one in increasing
order (the smallest one is 1) at all points of P . Whenever the set of considered monomials can
build up a polynomial f that vanish at all points of P , adding f to G as an element of the
desired reduced Gröbner basis. Moreover, all multiples of the leading monomial of f will not
be evaluated, this will ensure that G is reduced. In Algorithm 4.3.1, the list L will be updated
m times where m is the number of points in P . Each time, the algorithm needs to check
which monomials in {x1 t, . . . , xn t} are multiples of an element of L or of lead(G). On the
other hand, the algorithm has to find the smallest monomial in a set of monomials L at least
m times. These two tasks are really time consuming. Therefore, we propose a new method
to update L and find the minimal element of L in constant time in case of the lexicographical
ordering.
Our method relates to the algorithm SM − A in [JS06]. The algorithm SM − A gener-
ates first a set of candidate standard monomials, then sorts them in increasing order. The
paper [Lun08] shows that sorting monomials is a time consuming task. Our method gen-
erates a sorted list (w.r.t lex) of candidate standard monomials. Let Bik := {u ∈ B ∩
K[xi , . . . , xn ] | degxi u = k} for k ≥ 1. Let Bi := B ∩ K[xi , . . . , xn ]. Let
L1i = {u · xi | u ∈ Bi+1 }
Lki = {u · xi | u ∈ Bik−1 }
The Algorithm 4.3.3 will return L = Lk+1 i if Bik is not empty. Otherwise, it will return
L = L1i−1 if i > 1 , and return empty list if i = 1.
Proof. Let v be an element of Bik , then v is in B ∩ K[xi , . . . , xn ] and degxi v = k. We can write
v = xi · u. Then, u is also a standard monomial of I(P ) since it is a divisor of a standard
31
monomial. Therefore, v is in Bi+1 if k = 1 or in Bik−1 if k > 1. This fact proves that Bik ⊂ Lki
for all k ≥ 1.
Lemma 4.3.2. The list L generated by the Algorithm 4.3.3 has following properties:
Proof. The first two properties are inherent from B and Bnew in the Algorithm 4.3.3. The
last one is true because of the lexicographical ordering.
Example 4.3.3. Consider P = {(0, 0), (0, 1), (1, 0), (1, 1)} ⊂ Q2 , and the lexicographical
ordering on Q[x, y] with x > y. The Table 4.1 and 4.2 show the steps of BMA and BMAlex
applied to P , respectively. They yield the same result G = {y 2 − y, x2 − x}, B = {1, y, x, xy}
in the same number of steps. However, the BMA needs more work than the BMAlex. The
BMA has to identify the monomials in the column check list which are neither multiples of
monomials in L nor in lead(G), then use these monomials to extend L. In addition, the BMA
has to find the minimal monomial of L while the first monomial of L in the BMAlex is already
the minimal monomial of L.
The update method for Boolean polynomials and lexicographical ordering is presented in
the Algorithm 4.3.4.
32
Algorithm 4.3.3 gen sorted cand stdmonos
Input: B, Bnew, i
Output: A list of candidate standard monomials
if Bnew = ∅ then
i=i−1
if i > 0 then
L = {u · Xi |u ∈ B}
else
L=∅
end if
else
L = {u · Xi |u ∈ Bnew}
end if
Return L, i
33
4.4 Ideal of points by interpolation
In this section we revise the main algorithms in [BD13] which is used to compute the reduced
lexicographical Gröbner basis of a variety. We also add some descriptions as well as examples
to clarify the algorithms. The termination and correctness of the algorithms are proven in
[BD13].
A partial Boolean function f : Zn2 → Z2 can be defined by two disjoint subsets Z and O of
Zn2 where
(bO O2 n
Z1 + bZ2 ) : Z2 −→ Z2
1
x 7−→ bO O2
Z1 (x) + bZ2 (x)
1
By this definition, the sum of two partial functions also a partial function
(Z ∩O )∪(O ∩Z )
bO O2 1 2 1 2
Z1 + bZ2 = b(Z1 ∩Z2 )∪(O1 ∩O2 )
1
Definition 4.4.1. Let > be an arbitrary monomial ordering, then we can extend > lex-
icographically to the set of Boolean polynomials (we make use the fact that all non-zero
coefficients are one) by setting p > q if and only if p 6= 0 and one of the following conditions
holds
• q=0
• p is reduced w.r.t G.
K[x1 , . . . , Xn ]/I(X) −→ K m
34
mapping every f to (f (P1 ), . . . , f (Pm )) is an isomorphism of rings. Therefore, for each i, there
exists a polynomial hi such that hi (Pi ) = 1 and hi (Pj ) = 0 for every j 6= i. The polynomial
n
X
f= φ(Pi )hi ,
i=1
Algorithm 4.4.1, named interpolate smallest lex, can compute the smallest interpolation
polynomial w.r.t lexicographical monomial ordering under all polynomials interpolating the
same function on P
g = bO
Z0
0
Example 4.4.4. Let Z = {(0, 0)} and O = {(0, 1), (1, 0)}. We will apply the algorithm 4.4.1
to find the smallest lex. interpolation Boolean polynomial p of bO
Z.
i=1
Z1 = ∅, Z0 = {0}, O1 = {0}, O0 = {1}
C = {0}
{0} {1} {0}
f = b∅ , g = b{0} , f + g = b∅
{0}
ht = interpolate smallest lex(b∅ ) = 1
35
{1}
F = ∅, w = b{0}
{1}
he = interpolate smallest lex(b{0} )
p = x1 + he
{1}
We apply the Algorithm 4.4.1 again to find the interpolation polynomial q of b{0}
i=2
Z1 = ∅, Z0 = {()}, O1 = {()}, O0 = ∅
C = {()}
{()} {()}
f = b∅ , g = b∅{()} , f + g = b∅
{()}
ht = interpolate smallest lex(b∅ ) = 1
F = ∅, w = b{()}
he = interpolate smallest lex(b{()} ) = 0
q = x2
The result is p = x1 + x2 .
Algorithm 4.4.2 computes the reduced lexicographical normal form of a polynomial w.r.t
vanishing ideal of a variety without Gröbner basis computation. The algorithm calls the
procedure zeros(f, P ) to find the set Z of all zeros of f in P , then the desired normal form is
P \Z
the smallest lexicographical interpolation polynomial of bZ .
Given a monomial ordering > and a set of points P . A monomial is called standard
monomial of ideal I if it is not in the leading ideal of I. The set of standard monomials of
I(P ) has the same cardinality as P . Based on this conclusion, Algorithm 4.4.3 is developed
to compute all standard monomials of I(P ). The algorithm takes a random subset Z of P ,
P \Z
then finds the smallest lex. interpolation polynomial p of bZ . This polynomial is reduced
w.r.t I(P ), hence its terms are not in the leading ideal of I. Therefore, all terms of p as well
as their divisors are standard monomials of I(P ). The process continues until all |P | standard
monomials of I(P ) are found. In this algorithm, the procedure random subset(P ) will return
a random subset of P , the supp(p) is the support of P defined as the set of all terms (with
non-zero coefficients) of p.
36
Algorithm 4.4.3 Standard monomials of I(P): standard monomials variety(P)
Input: P set of points in Zn2 .
Output: S = {t|∃ reduced p ∈ I(P ) : t term of p}
S=∅
while |P | =
6 |S| do
Z = random subset(P )
P \Z
p = interpolate smallest lex(bZ )
S = S ∪ supp(p)
S = {t term | ∃s ∈ S : t divides s}
end while
Return S
Example 4.4.6. Let P = {(0, 0), (0, 1), (1, 0)}, we use Algorithm 4.4.3 to find all standard
monomials of I(P ). Assume a random subset of P is Z = {(0, 0)}, then
{(0,1),(1,0)}
p = interpolate smallest lex(b{(0,0)} ) = x1 + x2 .
The support of p is {x1 , x2 }, hence S = {1, x1 , x2 }. At this point, S has 3 elements, so all the
standard monomials of I(P ) are 1, x1 , x2 .
After finding all standard monomials, we can obtain the leading monomials of the minimal
Gröbner basis by collecting all minimal elements of the remaining Boolean monomials, see
Algorithm 4.4.4
Example 4.4.7. Consider again P = {(0, 0), (0, 1), (1, 0)}. All Boolean terms in Z2 [x1 , . . . , x2 ]
are 1, x1 , x2 and x1 x2 . Using the result from Example 4.4.6, we get R = {x1 x2 } and the leading
monomial of I(P ) is x1 x2 .
The algorithm 4.4.5 constructs the reduced lexicographical Gröbner basis from the set of
leading monomials.
Example 4.4.8. Continuing Example 4.4.7, the vanishing ideal of P has only one leading
monomial, hence the reduced lexicographical Gröbner basis of I(P ) has only one polynomial.
It is
x1 x2 + nf by interpolate(x1 x2 , P ) = x1 x2 .
37
Table 4.3: Compare BDA and BMAlex
nvars npoints BDA BMAlex nvars npoints BDA BMAlex
10 1000 0.1 2.9 100 100 0.7 0.3
20 1000 2.9 8 100 200 1.7 0.5
50 1000 11.1 8.6 100 500 10.8 2.1
100 1000 26 9 100 1000 29 7
200 1000 72 11 100 2000 86 34
500 1000 316 16 100 5000 446 637
1000 1000 929 24 100 10000 1549 9850
For a given set of points P , we presented two algorithms to compute the reduced Boolean
Gröbner basis of vanishing ideal of P . To compare these two algorithms, we generate a random
set of points P and also vary the number points and variables. From the Table 4.3, we can see
that the algorithm from Brickenstein and Dreyer (BDA) is sensitive to the number of variables
while BMAlex is sensitive to the number of points.
To prove the correctness of the Algorithm 4.5.1, we need the following theorem and its
corollary proven in [BDG+ 09].
Theorem 4.5.1. Every ideal I ⊂ Z2 [x1 , . . . , xn ] with I ⊃ hx21 + x1 , . . . , x2n + xn i is radical.
For such an ideal I in Theorem 4.5.1, the algebraic set V (I) in Zn2 and in the algebraic
closure of Zn2 are the same, hence we have
Corollary 4.5.2. For an ideal I ⊂ Z2 [x1 , . . . , xn ] with I ⊃ hx21 + x1 , . . . , x2n + xn i,
I(V (I)) = I.
38
Proof. Algorithm 4.5.1 firstly computes P , the projection of all solutions of I on Z2 [Y ], where
Y = {xi+1 , . . . , xn }, in notation P = πY (V (I)).
The set πY (V (I)) is finite, so Zariski closed (since it is algebraic). Therefore, by the Closure
Theorem,
πY (V (I)) = V (I ∩ Z2 [Y ]). (4.3)
This implies that the vanishing ideal of P is equal to I(V (I ∩ Z2 [Y ])). Applying Corollary
4.5.2 to I ∩ Z2 [Y ], we get
I(V (I ∩ Z2 [Y ])) = I ∩ Z2 [Y ]. (4.4)
This proves that Algorithm 4.5.1 returns the reduced lexicographical Boolean Gröbner basis
of I ∩ Z2 [Y ].
with variables state(0), state(1), state(2), signal(0), . . . , signal(11) and next(0), next(1),
next(2).
To figure out relations between states variables and next variables, we have to eliminate
all signal variables. This can be done by computing a Gröbner basis of an elimination ideal.
The two approaches will be applied to solve this problem.
We limit time to 10 hours and memory to 50 GB. The sign × means error matrix-size
exceed.
4.7 Conclusion
We have presented an alternative approach to compute Boolen Gröbner bases of Boolean
elimination ideals. This approach is really efficient in case we want to eliminate most of
the variables. In such a case, our approach can solve many hard instances that the classical
approach can’t. Our approach is very sensitive to the number of remaining variables. Time
and memory can increase exponentially when this number increases.
39
Table 4.4: Comapre two approaches on some Automata benchmarks.
Problem informations Time (in second) Memory (in Megabyte)
name vars Ivars Gröbner basis SATElim Gröbner basis SATElim
s27 18 6 0.07 0.02 84 83
s208 97 16 5.2 0.08 94 84
s298 140 28 × 21 - 185
s344 143 30 × 363 - 1251
s349 143 30 × 403 - 1267
s382 176 42 × 121 - 337
s386 192 12 25388 0.15 1394 84
s420 205 32 × 26 - 242
s444 201 42 × 158 - 334
s510 244 12 TO 0.16 - 84
s526 252 42 × 19510 - 16866
s641 219 38 × 32775 - 15310
s713 222 38 TO 34217 - 15370
s820 410 10 TO 0.20 - 85
s832 425 10 TO 0.17 - 85
s838 421 64 × - - MO
s953 421 58 TO 1.13 - 104
s1196 528 36 TO 35116 - 20175
s1238 576 36 TO 15481 - 11544
s1423 626 148 TO - - MO
s1488 699 12 TO 0.58 - 87
s1494 709 12 TO 0.58 - 87
40
Table 4.5: Comapre two approaches on some simplified benchmarks.
name Time (in second) Memory (in Megabyte)
Gröbner basis SATElim Gröbner basis SATElim
H.S27 0.03 0.03 83 83
H.S208 0.03 0.07 84 83
H.S298 0.01 0.16 84 84
H.S344 0.12 7.32 85 154
H.S349 0.13 4.6 84 148
H.S382 17.08 2.78 217 124
H.S386 22.19 0.08 127 83
H.S420 4.94 0.12 92 84
H.S444 0.36 0.01 85 84
H.S510 4.4 0.09 109 84
H.S526 0.35 1.24 85 93
H.S641 5415 6.6 864 123
H.S713 3566 6.69 574 128
H.S820 4465 0.153 1331 85
H.S832 8215 0.16 1974 85
H.S838 47544 25 2842 253
H.S953 84 0.27 121 20.5
41
42
Chapter 5
Verification by abstraction and computer
algebra techniques
This is a joint work with Oliver Marx from the department of Electrical and Computer Engi-
neering, TU Kaiserslautern. Oliver Marx builded the abstract models on which I could build
algebraic models and use computer algebra techniques to prove the desired properties.
5.1 Introduction
Verification is very important since it ensures that the design works correctly as expected.
However, the usual methods (for example, using an instance of SAT solver, Binary Decision
Diagram, simulation) can not verify efficiently the components that contain complicated data-
paths, like multiplier and filter. Pavlenko at al [PWS+ 11] has proposed a computer algebra
approach to solve this problem. They extract bit-level informations and transform them to
polynomials in Z2k [X]/hx2 − x : x ∈ Xi. This means that coefficients of polynomials are finite
length integers, but variables are still bit variables. The number of variables and polynomials
will increase very much if the bitwidth is increasing. For instance, to model a signal of type
64 bits integer, we need 64 bit-variables.
Recent developments in abstraction techniques allow us to build abstract models at word
level. For instances, we can reformulate the following bit operation a << 1, i.e. shift a 1 bit
to right, to word operations a · 2.
Our approach is as follows. We use abstraction techniques to lift bit operations to word
operations whenever possible. This way, we can construct an abstract model. Then, we
reformulate it as a system of polynomials in ring Z2k [x1 , . . . , xn ]. We try to order the variables
such that the system has been already a Gröbner basis w.r.t lexicographical monomial ordering.
Finally, the normal form is employed to prove the desired properties.
The description of the abstraction techniques is out of the scope of this thesis. It will
appear in Oliver Marx’s thesis. Here, we focus on how to build the algebraic model from the
abstract design and prove its properties by computer algebra tools.
To evaluate our approach, we verify the global property of a multiplier and a FIR filter
using the computer algebra system Singular [DGPS12]. The result shows that our approach
is much faster than the commercial verification tool from Onespin [One].
In this chapter, digital designs will be described in Very High Speed Integrated Circuit
Hardware Description Language (VHDL) at Register Transfer Level (RTL).
43
Figure 5.1: Clock signal in form of a square wave
raising edge falling edge
a clock cycle
5.2 VHDL
VHDL is a standard language for describing the structure and function of digital electronic
systems. It also allows us to verify the behavior of the design before translating it into real
hardware.
In VHDL, a design consists of at least an entity which describes the interface and at least
an architecture which describes the function. An entity is an object in VHDL containing in-
formation about input ports and output ports. An architecture contains processes, concurrent
signal assignments, etc.
A simple signal assignments in VHDL is of the form
44
only at raising edge of clock signal. In contrast, the concurrent signal assignment c <= a is
asynchronous and is executed whenever the value of a changes.
When all signal assignments as well as the desired properties can be represented as polyno-
mials over Z2k , we can prove the property using Gröbner basis techniques and reduced normal
forms. Let S be the set of all polynomials associated with signal assignments at all states
involved in the proof goals, and I the ideal generated by S. Let p be the polynomial that
represents the proof goal. Compute a Gröbner basis G of the ideal I. Then the property holds
if and only if the normal form of p with respect to G is zero. Moreover, in most cases, we can
order the variables with respect to the so-called topological order, such that S is a Gröbner
basis w.r.t lexicographical monomial ordering.
The topological order of variables is computed as follows
1. Variables corresponding to the signal in the right hand side of a signal assignments are
less than the one in the left hand side.
2. If two variables correspond to the same signal, but at different state, then the variable
corresponding to the signal at higher state is greater.
With topological order of variables above and the lexicographical monomial ordering, the
leading monomials of all polynomials in S are variables. If these variables are pairwise different,
then S is a Gröbner basis of I.
5.4 Applications
We use our approach to verify the global property of a multiplier and a filter.
5.4.1 Multiplier
We consider a design of a multiplier which is used for multiplying two integers of the same
bitwidth. The verification tool Onespin [One] needs 724 seconds to verify the global property
of the original 24 bit multiplier design. Onespin also use symbolic method to verify the
property. Some preprocessing techniques are applied at first, then bit-blasting is used to
convert the problem to CNF and solved by SAT solvers. The paper [PWS+ 11] shows that
the CNF coming from bit-blasting of the design with complicated data path, like multiplier,
is very hard for SAT solver.
45
To make the verification process faster, we first build an abstract design of this multiplier.
Now, Onespin can do the job with the abstract design in 592 seconds. However, this cost is
still not feasible since we want to verify the multiplier of higher bits. Therefore, we do a next
step, building an algebraic model based on the abstract model, then using computer algebra
techniques to verify it.
Consider a multiplier whose original design is written in the VHDL language and given in
Appendix A.1. There are lots of type casting in this design. Moreover, most of the operations
are at the bit level. To have a simple algebraic model, we need to build an abstract design
of this multiplier. The new design will take 2 integers a and b as inputs and return result as
product of a and b. The other inputs (e.g clk, reset, and start) and output (e.g ready) are
used to control the multiplying process.
library i e e e ;
use i e e e . s t d l o g i c 1 1 6 4 . a l l ;
use i e e e . n u m e r i c s t d . a l l ;
use work . c o n s t . a l l ;
ENTITY m u l t i p l i e r IS
port (
clk : IN std logic ;
r e s e t : IN std logic ;
ready : OUT s t d l o g i c ;
r e s u l t : OUT s t d l o g i c v e c t o r ( 2 ∗BIT WIDTH−1 DOWNTO 0 )
);
END m u l t i p l i e r ;
ARCHITECTURE b e h a v i o r OF m u l t i p l i e r IS
type s t a t e t y p e i s ( S CSM IDLE , S CSM CALCULATE ) ;
signal s t a t e : s t a t e t y p e ;
signal ready r : s t d l o g i c ;
s i g n a l r e g a : u n s i g n e d ( 2 ∗BIT WIDTH−1 DOWNTO 0 ) ;
s i g n a l r e g b : u n s i g n e d (BIT WIDTH−1 DOWNTO 0 ) ;
s i g n a l r e s u l t r : u n s i g n e d ( 2 ∗BIT WIDTH−1 DOWNTO 0 ) ;
BEGIN
FSM: PROCESS( c l k , r e s e t )
BEGIN
i f ( r e s e t = ’1 ’) then
s t a t e <= S CSM IDLE ;
r e a d y r <= ’ 0 ’ ;
e l s i f ( r i s i n g e d g e ( c l k ) ) then
i f ( s t a t e=S CSM IDLE ) and ( s t a r t = ’0 ’) then
s t a t e <= S CSM IDLE ;
r e a d y r <= ’ 0 ’ ;
e l s i f ( s t a t e=S CSM IDLE ) and ( s t a r t = ’1 ’) then
s t a t e <= S CSM CALCULATE ;
r e g a <= a ;
r e g b <= b ;
r e s u l t r <= 0 ;
r e a d y r <= ’ 0 ’ ;
e l s i f ( s t a t e = S CSM CALCULATE) and ( r e g b /= 0 ) then
46
s t a t e <= S CSM CALCULATE ;
r e g a <= r e g a ∗ 2 ;
r e g b <= r e g b / 2 ;
r e s u l t r <= r e s u l t r + r e g b ( 0 ) ∗ r e g a ;
r e a d y r <= ’ 0 ’ ;
e l s i f ( s t a t e = S CSM CALCULATE) and ( r e g b = 0 ) then
s t a t e <= S CSM IDLE ;
r e g b <= 0 ;
r e a d y r <= ’ 1 ’ ;
end i f ;
end i f ;
END PROCESS FSM;
ready <= r e a d y r ;
r e s u l t <= r e s u l t r ;
END b e h a v i o r ;
k
X
b= 2j bj .
j=0
b0i + 2 · bi − bi−1 ,
It contains a finite set of polynomials J describing the operations in the design and the
polynomials describing the proof goals. The system J can be partitioned into an initial ideal
Init, state ideals Ji , for i from 0 to bitwidth, where
Init = {a0 − a, b0 − b, r0 },
Ji = {ai − 2 · ai−1 , b0i−1 + 2 · bi − bi−1 , ri − ri−1 − ai−1 · b0i−1 }.
rk > · · · > r0 > ak > · · · > a0 > a > b0k > · · · > b00 > bk > · · · > b0 > b.
With above ordering, the leading terms of all polynomials are variables, and these variables
are pairwise different, hence the ideals I and J are Gröbner bases.
Polynomials for proof goal are pi = ri − a · b. We compute the normal form of all pi with
respect to the ideal I. The desired property is satisfied if and only if all the normal forms are
zero.
47
Example 5.4.1. As an illustration, we would verify the global property of a 2-bit multiplier.
The proof goal is ri = a · b whenever bi = 0 for 0 ≤ i ≤ 2. The proof goal involves 2 clock
cycles. Therefore, the system J is the union of:
Init = {a0 − a, b0 − b, r0 },
J1 = {a1 − 2 · a0 , b00 + 2 · b1 − b0 , r1 − r0 − a0 · b00 }
J2 = {a2 − 2 · a1 , b01 + 2 · b2 − b1 , r2 − r1 − a1 · b01 }.
Polynomials for the proof goal are p1 := r1 − a · b and p2 := r2 − a · b. We also add the
polynomial bi for the assumption bi = 0 to J when checking pi . The variables are ordered as
follows:
r2 > r1 > r0 > a2 > a1 > a0 > a > b01 > b00 > b2 > b1 > b0 > b.
With the lexicographical monomial ordering, the leading terms of all polynomials in J ∪ {bi }
are
a0 , b0 , r0 , a1 , b00 , r1 , a2 , b01 , r2 , and bi .
All of them are variables and pairwise different, hence J ∪ {bi } are Gröbner bases for i = 0, 1, 2
by the product criterion.
Now, we compute the normal form of p2 with respect to I2 := J ∪ {b2 }. The notation
g
f→− h means f is reduced to h by g.
The Table 5.1 presents the verification time (in seconds) of the global property of the
multiplier with different bitwidths using the computer algebra system Singular [DGPS12].
The timing table shows that our approach can verify the global property of the multiplier of
up to 1024 bits while Onespin is unable to verify it from 64 bit.
48
Table 5.1: Verify multiplier by abstraction and computer algebra
bit-width nvars time
32 133 0.05
64 261 0.26
128 517 1.83
256 1029 21
512 2053 283
1024 4101 6138
architecture r t l of c f f i r 3 8 8 i s
s i g n a l mult 0 : s i g n e d ( 1 5 downto 0 ) ;
s i g n a l mult 1 : s i g n e d ( 1 5 downto 0 ) ;
s i g n a l mult 2 : s i g n e d ( 1 5 downto 0 ) ;
s i g n a l mult 3 : s i g n e d ( 1 5 downto 0 ) ;
s i g n a l d a t a r d e l a y e d 1 : s i g n e d ( 7 downto 0 ) ;
s i g n a l d a t a r d e l a y e d 2 : s i g n e d ( 7 downto 0 ) ;
s i g n a l d a t a r d e l a y e d 3 : s i g n e d ( 7 downto 0 ) ;
s i g n a l d a t a r d e l a y e d 4 : s i g n e d ( 7 downto 0 ) ;
s i g n a l d a t a o r d e l a y e d 1 : s i g n e d ( 1 7 downto 0 ) ;
s i g n a l d a t a o r d e l a y e d 2 : s i g n e d ( 1 7 downto 0 ) ;
s i g n a l d a t a o r d e l a y e d 3 : s i g n e d ( 1 7 downto 0 ) ;
begin
mult 0 <= k0 ∗ d a t a r d e l a y e d 1 ;
mult 1 <= k1 ∗ d a t a r d e l a y e d 2 ;
mult 2 <= k2 ∗ d a t a r d e l a y e d 3 ;
mult 3 <= k3 ∗ d a t a r d e l a y e d 4 ;
d a t a o <= d a t a o r d e l a y e d 3 ;
process ( c l o c k c , r e s e t ) i s
begin
i f r e s e t = 1 then
d a t a r d e l a y e d 1 <= 0 ;
49
d a t a r d e l a y e d 2 <= 0 ;
d a t a r d e l a y e d 3 <= 0 ;
d a t a o r d e l a y e d 1 <= 0 ;
d a t a o r d e l a y e d 2 <= 0 ;
d a t a o r d e l a y e d 3 <= 0 ;
e l s i f r i s i n g e d g e ( c l o c k c ) then
d a t a r d e l a y e d 1 <= data ;
d a t a r d e l a y e d 2 <= d a t a r d e l a y e d 1 ;
d a t a r d e l a y e d 3 <= d a t a r d e l a y e d 2 ;
d a t a r d e l a y e d 4 <= d a t a r d e l a y e d 3 ;
d a t a o r d e l a y e d 1 <= mult 0 + mult 1 + mult 2 + mult 3 ;
d a t a o r d e l a y e d 2 <= d a t a o r d e l a y e d 1 ;
d a t a o r d e l a y e d 3 <= d a t a o r d e l a y e d 2 ;
end process ;
end architecture r t l ;
In this design, there are both synchronous assignments and asynchronous assignments. The
names of signals are meanful, but they are too long. Therefore, we assign to each signal a new
variable name. The Table 5.2 shows the signal names and their corresponding variable names.
All asynchronous and synchronous assignments together with their associated polynomials
at state i are presented in Table 5.3 and Table 5.4.
50
a t t : mult 0 = k 0 i ∗ prev ( data , 1 ) ;
a t t : mult 1 = k 1 i ∗ prev ( data , 2 ) ;
a t t : mult 2 = k 2 i ∗ prev ( data , 3 ) ;
a t t : mult 3 = k 3 i ∗ prev ( data , 4 ) ;
a t t : d a t a o = prev ( mult 0 + mult 1 + mult 2 + mult 3 ,3);
end p r o p e r t y ;
We may understand the property above as follows: assume that there is no reset in 5 continue
states (name these state 1, 2, 3, 4, 5), prove that
• mult 0 ( at state 5) = k0 i ( at state 5) ∗ data ( at state 4),
• mult 1 ( at state 5) = k1 i ( at state 5) ∗ data ( at state 3),
• mult 2 ( at state 5) = k2 i ( at state 5) ∗ data ( at state 2),
• mult 3 ( at state 5) = k3 i ( at state 5) ∗ data ( at state 1),
• data o ( at state 5) = mult 0 + mult 1 + mult 2 + mult 3 (at state 2).
The polynomials for these proof goals are
• p0 := m0,5 − k0,5 · a4 ,
• p1 := m1,5 − k1,5 · a3 ,
• p2 := m2,5 − k2,5 · a2 ,
• p3 := m3,5 − k3,5 · a1 ,
• p4 := z5 − m0,2 − m1,2 − m2,2 − m3,2 .
Let G be the set of all polynomials in Table 5.3 and 5.4 at five states 1, 2, 3, 4, 5. There are
total 60 polynomials in G. The topological variable order of G at state i is
zi > y3,i > · · · > y1,i > m3,i > · · · > m0,i > b3,i > · · · > b1,i > ai > k3,i > k0,i .
If some variables correspond to the same signals, but at different states, then the variable
corresponding to the signal at higher state is larger. When the variables are ordered in this
way, the leading terms (w.r.t lex) of all polynomials in G are variables and pairwise different.
Hence, G is a Gröbner basis w.r.t lexicographical ordering. Therefore, to check the proof goals,
we just need to check whether the normal form pi w.r.t G is zero. The normal form of p2 w.r.t
G is computed as follows:
m2,5 −k2,5 ·b3,5
p2 := m2,5 − k2,5 · a2 −−−−−−−−→ k2,5 · b3,5 − k2,5 · a2
b3,5 −b2,4
−−−−−→ k2,5 · b2,4 − k2,5 · a2
b2,4 −b1,3
−−−−−→ k2,5 · b1,3 − k2,5 · a2
b2,4 −a2
−−−−→ 0
51
y3,5 −y2,4
−−−−−→ y2,4 − m3,2 − m2,2 − m1,2 − m0,2
y2,4 −y1,3
−−−−−→ y1,3 − m3,2 − m2,2 − m1,2 − m0,2
y1,3 −m3,2 −m2,2 −m1,2 −m0,2
−−−−−−−−−−−−−−−−→ 0
5.5 Conclusion
Verification by abstraction and computer algebra techniques is a promising approach. We can
verify a digital component containing a complicated data path much faster than the usual
approach. By lifting bit operations to word operations, we can reduce the number of variables
and polynomials by many order of magnitudes. As a result, the verification by algebraic
method is more efficient with the help of abstraction techniques.
52
Appendix A
Designs of a multiplier and a filter
A.1 Multiplier
library ieee ;
use ieee . std_logic_1164 . all ;
use ieee . numeric_std . all ;
use work . const . all ;
ENTITY multiplier IS
port (
clk : IN std_logic ;
reset : IN std_logic ;
53
sum <= ( others = > ’0 ’) ;
elsif ( state = CALCULATING ) then
if ( reg_b = 0) then
state <= IDLE ;
valid_r <= ’1 ’;
else
if reg_b (0) = ’1 ’ then
sum <= sum + reg_a ;
end if ;
reg_a (2* BIT_WIDTH -1 downto 0) <= reg_a (2* BIT_WIDTH -2
downto 0) & ’0 ’;
reg_b ( BIT_WIDTH -1 downto 0) <= ’0 ’ & reg_b ( BIT_WIDTH -1
downto 1) ;
end if ;
end if ;
end if ;
END PROCESS FSM ;
property multiply is
dependencies :
no_reset ;
for timepoints :
tb = t +1.. BIT_WIDTH waits_for ready =1;
freeze :
fa = a@t ,
fb = b@t ;
assume :
at t : CSM_IDLE ;
at t : start = 1;
prove :
at tb : result = fa * fb ;
end property ;
54
signal k_10 : in unsigned (15 downto 0) ;
signal k_11 : in unsigned (15 downto 0) ;
signal k_12 : in unsigned (15 downto 0) ;
signal k_13 : in unsigned (15 downto 0) ;
signal k_14 : in unsigned (15 downto 0) ;
signal k_15 : in unsigned (15 downto 0) ;
signal k_16 : in unsigned (15 downto 0) ;
signal k_17 : in unsigned (15 downto 0) ;
signal k_18 : in unsigned (15 downto 0) ;
signal k_19 : in unsigned (15 downto 0) ;
signal k_20 : in unsigned (15 downto 0) ;
signal k_21 : in unsigned (15 downto 0) ;
signal k_22 : in unsigned (15 downto 0) ;
signal k_23 : in unsigned (15 downto 0) ;
signal k_24 : in unsigned (15 downto 0) ;
signal k_25 : in unsigned (15 downto 0) ;
signal k_26 : in unsigned (15 downto 0) ;
signal k_27 : in unsigned (15 downto 0) ;
signal k_28 : in unsigned (15 downto 0) ;
signal k_29 : in unsigned (15 downto 0) ;
signal k_30 : in unsigned (15 downto 0) ;
signal k_31 : in unsigned (15 downto 0) ;
signal k_32 : in unsigned (15 downto 0) ;
signal k_33 : in unsigned (15 downto 0) ;
signal data_o : out unsigned (37 downto 0) ) ;
end entity cf_fir_33_16_16 ;
55
signal reg_30 : unsigned (31 downto 0) ;
signal reg_31 : unsigned (31 downto 0) ;
signal reg_32 : unsigned (31 downto 0) ;
signal reg_33 : unsigned (31 downto 0) ;
signal data_r_delayed_1 : unsigned (15 downto 0) ;
signal data_r_delayed_2 : unsigned (15 downto 0) ;
signal data_r_delayed_3 : unsigned (15 downto 0) ;
signal data_r_delayed_4 : unsigned (15 downto 0) ;
signal data_r_delayed_5 : unsigned (15 downto 0) ;
signal data_r_delayed_6 : unsigned (15 downto 0) ;
signal data_r_delayed_7 : unsigned (15 downto 0) ;
signal data_r_delayed_8 : unsigned (15 downto 0) ;
signal data_r_delayed_9 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _10 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _11 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _12 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _13 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _14 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _15 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _16 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _17 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _18 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _19 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _20 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _21 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _22 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _23 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _24 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _25 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _26 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _27 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _28 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _29 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _30 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _15 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _32 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _33 : unsigned (15 downto 0) ;
signal da ta_r_d elayed _34 : unsigned (15 downto 0) ;
signal d at a_ o_ r_ de la ye d_ 1 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 2 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 3 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 4 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 5 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 6 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 7 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 8 : unsigned (31 downto 0) ;;
signal d at a_ o_ r_ de la ye d_ 9 : unsigned (31 downto 0) ;;
begin
reg_0 <= k_0 * data_r_delayed_1 ;
reg_1 <= k_1 * data_r_delayed_2 ;
reg_2 <= k_2 * data_r_delayed_3 ;
reg_3 <= k_3 * data_r_delayed_4 ;
reg_4 <= k_4 * data_r_delayed_5 ;
reg_5 <= k_5 * data_r_delayed_6 ;
reg_6 <= k_6 * data_r_delayed_7 ;
reg_7 <= k_7 * data_r_delayed_8 ;
reg_8 <= k_8 * data_r_delayed_9 ;
reg_9 <= k_9 * data_ r_dela yed_10 ;
56
reg_10 <= k_10 * da ta_r_d elayed _11 ;
reg_11 <= k_11 * da ta_r_d elayed _12 ;
reg_12 <= k_12 * da ta_r_d elayed _13 ;
reg_13 <= k_13 * da ta_r_d elayed _14 ;
reg_14 <= k_14 * da ta_r_d elayed _15 ;
reg_15 <= k_15 * da ta_r_d elayed _16 ;
reg_16 <= k_16 * da ta_r_d elayed _17 ;
reg_17 <= k_17 * da ta_r_d elayed _18 ;
reg_18 <= k_18 * da ta_r_d elayed _19 ;
reg_19 <= k_19 * da ta_r_d elayed _20 ;
reg_20 <= k_20 * da ta_r_d elayed _21 ;
reg_21 <= k_21 * da ta_r_d elayed _22 ;
reg_22 <= k_22 * da ta_r_d elayed _23 ;
reg_23 <= k_23 * da ta_r_d elayed _24 ;
reg_24 <= k_24 * da ta_r_d elayed _25 ;
reg_25 <= k_25 * da ta_r_d elayed _26 ;
reg_26 <= k_26 * da ta_r_d elayed _27 ;
reg_27 <= k_27 * da ta_r_d elayed _28 ;
reg_28 <= k_28 * da ta_r_d elayed _29 ;
reg_29 <= k_29 * da ta_r_d elayed _30 ;
reg_30 <= k_30 * da ta_r_d elayed _31 ;
reg_31 <= k_31 * da ta_r_d elayed _32 ;
reg_32 <= k_32 * da ta_r_d elayed _33 ;
reg_33 <= k_33 * da ta_r_d elayed _34 ;
data_o <= d at a_ o_ r_ de la ye d_ 9 ;
process ( clock_c , reset ) is
begin
if reset = 1 then
data_r_delayed_1 <= 0;
data_r_delayed_2 <= 0;
data_r_delayed_3 <= 0;
data_r_delayed_4 <= 0;
data_r_delayed_5 <= 0;
data_r_delayed_6 <= 0;
data_r_delayed_7 <= 0;
data_r_delayed_8 <= 0;
data_r_delayed_9 <= 0;
data _r_del ayed_ 10 <= 0;
data _r_del ayed_ 11 <= 0;
data _r_del ayed_ 12 <= 0;
data _r_del ayed_ 13 <= 0;
data _r_del ayed_ 14 <= 0;
data _r_del ayed_ 15 <= 0;
data _r_del ayed_ 16 <= 0;
data _r_del ayed_ 17 <= 0;
data _r_del ayed_ 18 <= 0;
data _r_del ayed_ 19 <= 0;
data _r_del ayed_ 20 <= 0;
data _r_del ayed_ 21 <= 0;
data _r_del ayed_ 22 <= 0;
data _r_del ayed_ 23 <= 0;
data _r_del ayed_ 24 <= 0;
data _r_del ayed_ 25 <= 0;
data _r_del ayed_ 26 <= 0;
data _r_del ayed_ 27 <= 0;
data _r_del ayed_ 28 <= 0;
data _r_del ayed_ 29 <= 0;
data _r_del ayed_ 30 <= 0;
57
data _r_del ayed_ 31 <= 0;
data _r_del ayed_ 32 <= 0;
data _r_del ayed_ 33 <= 0;
data _r_del ayed_ 34 <= 0;
da ta _o _r _d el ay ed _1 <= 0;
da ta _o _r _d el ay ed _2 <= 0;
da ta _o _r _d el ay ed _3 <= 0;
da ta _o _r _d el ay ed _4 <= 0;
da ta _o _r _d el ay ed _5 <= 0;
da ta _o _r _d el ay ed _6 <= 0;
da ta _o _r _d el ay ed _7 <= 0;
da ta _o _r _d el ay ed _8 <= 0;
da ta _o _r _d el ay ed _9 <= 0;
elsif rising_edge ( clock_c ) then
data_r_delayed_1 <= data ;
data_r_delayed_2 <= data_r_delayed_1 ;
data_r_delayed_3 <= data_r_delayed_2 ;
data_r_delayed_4 <= data_r_delayed_3 ;
data_r_delayed_5 <= data_r_delayed_4 ;
data_r_delayed_6 <= data_r_delayed_5 ;
data_r_delayed_7 <= data_r_delayed_6 ;
data_r_delayed_8 <= data_r_delayed_7 ;
data_r_delayed_9 <= data_r_delayed_8 ;
data _r_del ayed_ 10 <= data_r_delayed_9 ;
data _r_del ayed_ 11 <= dat a_r_de layed_ 10 ;
data _r_del ayed_ 12 <= dat a_r_de layed_ 11 ;
data _r_del ayed_ 13 <= dat a_r_de layed_ 12 ;
data _r_del ayed_ 14 <= dat a_r_de layed_ 13 ;
data _r_del ayed_ 15 <= dat a_r_de layed_ 14 ;
data _r_del ayed_ 16 <= dat a_r_de layed_ 15 ;
data _r_del ayed_ 17 <= dat a_r_de layed_ 16 ;
data _r_del ayed_ 18 <= dat a_r_de layed_ 17 ;
data _r_del ayed_ 19 <= dat a_r_de layed_ 18 ;
data _r_del ayed_ 20 <= dat a_r_de layed_ 19 ;
data _r_del ayed_ 21 <= dat a_r_de layed_ 20 ;
data _r_del ayed_ 22 <= dat a_r_de layed_ 21 ;
data _r_del ayed_ 23 <= dat a_r_de layed_ 22 ;
data _r_del ayed_ 24 <= dat a_r_de layed_ 23 ;
data _r_del ayed_ 25 <= dat a_r_de layed_ 24 ;
data _r_del ayed_ 26 <= dat a_r_de layed_ 25 ;
data _r_del ayed_ 27 <= dat a_r_de layed_ 26 ;
data _r_del ayed_ 28 <= dat a_r_de layed_ 27 ;
data _r_del ayed_ 29 <= dat a_r_de layed_ 28 ;
data _r_del ayed_ 30 <= dat a_r_de layed_ 29 ;
data _r_del ayed_ 31 <= dat a_r_de layed_ 30 ;
data _r_del ayed_ 32 <= dat a_r_de layed_ 31 ;
data _r_del ayed_ 33 <= dat a_r_de layed_ 32 ;
data _r_del ayed_ 34 <= dat a_r_de layed_ 33 ;
da ta _o _r _d el ay ed _1 <= reg_0 + reg_1 + reg_2 + reg_3
+ reg_4 + reg_5 + reg_6 + reg_7 + reg_8 + reg_9
+ reg_10 + reg_11 + reg_12 + reg_13 + reg_14 + reg_15
+ reg_16 + reg_17 + reg_18 + reg_19 + reg_20 + reg_21
+ reg_22 + reg_23 + reg_24 + reg_25 + reg_26 + reg_27
+ reg_28 + reg_29 + reg_30 + reg_31 + reg_32 + reg_33 ;
da ta _o _r _d el ay ed _2 <= d ata _o _r _d el ay ed _1 ;
da ta _o _r _d el ay ed _3 <= d ata _o _r _d el ay ed _2 ;
da ta _o _r _d el ay ed _4 <= d ata _o _r _d el ay ed _3 ;
da ta _o _r _d el ay ed _5 <= d ata _o _r _d el ay ed _4 ;
58
da ta _o _r _d el ay ed _6 <= d ata _o _r _d el ay ed _5 ;
da ta _o _r _d el ay ed _7 <= d ata _o _r _d el ay ed _6 ;
da ta _o _r _d el ay ed _8 <= d ata _o _r _d el ay ed _7 ;
da ta _o _r _d el ay ed _9 <= d ata _o _r _d el ay ed _8 ;
end if ;
end process ;
end architecture rtl ;
59
60
Appendix B
Implementation source codes
B.1 Codes used in Chapter 3
# include < simp / SimpSolver .h >
# include " utils / System . h "
namespace Minisat {}
61
double total_gb_time ;
uint64_t gbs , gbadds , gbzeros , maxdepth ; // GB statistics
std :: set < int > all_levels ; // to store all decision level of a
GB_learnt clause
virtual void e x t e n d e d _ c l a u s e _ l e a r n i n g () {
GBlearning () ;
}
virtual void a d d _ c l a u s e s _ f r o m _ e x t e n d e d _ l e a r n i n g () { addGBlearnt () ; }
virtual void p r e p a r e _ e x t e n d e d _ l e a r n i n g () { setGBparams () ; }
};
// = = = = = = = = = = = = = = = = = = = = = =
// = = = = = = = = = = = = = = = = = = = = = =
// = = = = = = = = = = = = = = = = = = = = = =
62
void GBhelpSolver :: selectGBinput ( std :: vector < Clause * >& GBinput )
{
GBinput . clear () ;
if ( gbhelp == 1) {
select_on = true ;
}
if (( gb_on ) and ( gbhelp == 2) ) {
select_on = true ;
}
for ( int i = 0; i < confl_concern . size () ; i ++) {
Clause & c = *( confl_concern [ i ]) ;
// BGB select input
if ( select_on ) {
if ( gbhelp == 1) {
if ( c . size () <= 8) GBinput . push_back (
confl_concern [ i ]) ;
}
if ( gbhelp == 2) {
Clause * cl = confl_concern [ i ];
if ( c . size () <=4 ) GBinput . push_back ( cl ) ;
}
if ( GBinput . size () > 6) select_on = false ;
}
if (! select_on ) break ;
}
}
// = = = = = = = = = = = = = = = = = = = = = =
bool GBhelpSolver :: GBinput_ok ( const std :: vector < Clause * >& GBinput )
{
if ( GBinput . size () < 4) return false ;
if (( gbhelp ==1) and ( GBinput . size () > 6) ) return false ;
// = = = = = = = = = = = = = = = = = = = = = =
63
void GBhelpSolver :: computeGB ( const std :: vector < Clause * >& GBinput , std ::
vector < std :: vector < int > >& GBoutput )
{
// BGB : Input is ok , compute GB with command " groebner_basis " in
Polybori
END_PBORI_EMBED () ;
}
// = = = = = = = = = = = = = = = = = = = = = =
void GBhelpSolver :: selectGBoutput ( std :: vector < std :: vector < int > > GBoutput
, std :: vector < std :: vector < int > >& selectedGBoutput )
{
for ( unsigned int idx = 0; idx < GBoutput . size () ; ++ idx ) {
std :: vector < int >& cl = GBoutput [ idx ];
bool good_cl = true ;
if ( good_cl ) selectedGBoutput . push_back ( cl ) ;
}
}
// = = = = = = = = = = = = = = = = = = = = = =
void GBhelpSolver :: de cide_a ctivat eGB ()
{
if ( gb_counter % gb_factor == 0) gb_on = true ;
}
64
gb_on = false ;
return ;
}
}
// = = = = = = = = = = = = = = = = = = = = = =
double gb_time = 0;
double init_gb_time = cpuTime () ;
// Check GB input
if (! GBinput_ok ( GBinput ) ) {
return ;
}
// count satisfied GB input for KZ
if (( gbhelp ==1) ) {
gb_counter ++;
if (! gb_on ) return ;
}
// Compute Reduced Boolean Groebner basis
std :: vector < std :: vector < int > > GBoutput ;
GBoutput . clear () ;
computeGB ( GBinput , GBoutput ) ;
// For GB Statistics
gbs ++;
if ( selectedGBoutput . size () == 0) gbzeros ++;
else gbadds += selectedGBoutput . size () ;
gb_time = cpuTime () - init_gb_time ;
total_gb_time = total_gb_time + gb_time + select_time ;
}
65
// = = = = = = = = = = = = = = = = = = = = = =
// Add GB learnt clauses
//
if ( gbhelp == 2) gb_counter = 0;
// = = = = = = = = = = = = = = = = = = = = = =
66
lv = list_var_index ( poly )
lits = list ()
polyset = poly . set ()
for i in lv :
if polyset . subset0 ( i ) . empty () :
lits . append (2* var_map [ i ])
else :
lits . append (2* var_map [ i ]+1)
return lits
res = list ()
for poly in gb :
if ( poly . n_variables () <= max_size ) and ( poly not in
ideal ) :
polys = enc . po ly no mi al _c la us es ( poly )
for p in polys :
lits = tolits (p , var_map )
res . append ( lits )
return res
import resource
67
import sys
import signal
# ----------------------------
def time_expired (n , stack ) :
print ’ EXPIRED : ’ , ctime ()
def e n c o d e _ p o i n t s _ a s _ c o m p _ l i s t ( P ) :
n = len ( P [0])
m = len ( P )
Q = [[ int ( P [ i ][ j ]) for i in xrange ( m ) ] for j in xrange ( n ) ]
return Q
68
G . append ( Polynomial ( f ) )
return G
# ------------------------------
def BM ( P ) :
m = len ( P )
G =[]
if len ( P ) ==0:
G = [1]
else :
nvars = len ( P [0])
ring = declare_ring ([ Block ( " x " , nvars ) ])
zero = ring . zero () . set ()
one = ring . one () . set ()
global x
x = ring . variable
Q= encode_points_as_comp_list (P)
del P
L =[ list () ]
addL =[]
irre = set ()
B =[ one ]
ptr = 0
current_var_idx = nvars -1
# Matrix initialize
x_ks = matrix ( GF (2) ,Q [ current_var_idx ])
I = matrix . identity ( GF (2) ,m )
row =[1 for i in xrange ( m ) ]
M = matrix ( GF (2) , row )
M_for_rank = M . augment ( I [0:1 ,:])
ext = True
nrows =1
while current_var_idx != -1:
if ptr not in irre :
base_mono = list ( L [ ptr ])
current_mono = base_mono +[ current_var_idx ]
if nrows < m :
n_i = I [ nrows : nrows +1 ,:]
v_ex = v . augment ( n_i )
else :
if ext :
69
n_i = matrix ( GF (2) ,1 , m )
ext = False
v_ex = v . augment ( n_i )
N = M_for_rank . stack ( v_ex )
N . echelonize ()
N_last_row = N [ -1]
N1 = N_last_row [: m ]
if N1 . is_zero () :
irre = update_irre ( irre ,L , base_mono , ptr )
G = updateG2 (G ,B , current_mono , one , zero , N_last_row ,m , nrows )
else :
nrows +=1
M = M . stack ( v )
M_for_rank = N
addL . append ( current_mono )
updateB2 (B , current_mono , one , zero )
ptr +=1
if ptr >= len ( L ) :
L = L + addL
current_var_idx -=1
x_ks = matrix ( GF (2) ,Q [ current_var_idx ])
ptr =0
addL =[]
irre = set ()
return G
# ---------------------------------------
def lex_gb_noes ( Sols , nvars , r ) :
offset = 0
S = bset_ from_s trings (r , Sols , offset )
var_as_mono = Monomial ( r )
for i in xrange ( offset , r . n_variables () ) :
var_as_mono *= r . variable ( i )
res = None
res = l e x _ g r o e b n e r _ b a s i s _ p o i n t s (S , var_as_mono )
return res
# --------------------------------------
# ---------------------------------------
def main () :
resource . setrlimit ( resource . RLIMIT_CPU , (36000 ,36001) )
signal . signal ( signal . SIGXCPU , time_expired )
print ’ Starting : ’ , ctime ()
npoints = 1000
# nvars =100
print " npoints = " , npoints
# print " nvars = " , nvars
print " nvars Brickenstein BM "
# print " npoints Brickenstein BM "
nV =[10 ,20 ,50 ,100 ,200 ,500 ,1000]
nV =[10000]
70
# nP =[100 ,200 ,500 ,1000 ,2000 ,5000 ,10000]
for n in nV :
nvars = n
# npoints = n
P = random_example ( nvars , npoints )
# -* - coding : utf -8 -* -
# Author : Hung
# ------------------------
# Find relation between states and next states
# using all - solution SAT and interpolation
# ------------------------
import resource
import sys
import signal
# ################################
# Load test - files
# ################################
def get_data ( number , k ) :
data = load_file ( ’/ u / n / nguyen / polybori - work / sa t_inte rpolat ion /
test_file / S ’+ str ( number ) + ’. py ’)
if k > len ( data . initial_states ) :
raise ValueError , " k must less than or equal to the number of
states "
71
data . ideal = data . ideal + data . initial_states [: k ]
return data
# nvars = 2* data . num_states + data . num_signals
# ################################
# Convert ideal to CNF
# ################################
def toCNF ( ideal ) :
enc = CNFEncoder ( ideal [0]. ring () )
res = enc . dimacs_cnf ( ideal )
res += ’\ n ’
return res
# ################################
# Extract solution info from
# Avi_all_sat output
# ################################
def get_redPLA ( avi_output ) :
res = list ()
counter = 0
for line in avi_output . split ( ’\ n ’) :
if line . startswith ( ’0 ’) or line . startswith ( ’1 ’) :
res . append ( line )
counter +=1
# print ’ number of SAT solutions = ’, counter
return res
# ################################
# Solve all - solution SAT problem
# ################################
def Avi_all_sat ( CNFs , nImportant_vars ) :
# length of a batch
M = str (100)
N = str ( nImportant_vars )
process = Popen ([ " batch_all_sat " ," -" ,N , M ] , bufsize = 4096 , stdin =
PIPE , stdout = PIPE )
all_sat_output = process . communicate ( CNFs ) [0]
res = get_redPLA ( all_sat_output )
return res
# ################################
# Interpolation
# ################################
def lex_gb_noes ( Sols , nvars , r ) :
offset = r . n_variables () - nvars
S = bset_ from_s trings (r , Sols , offset )
var_as_mono = Monomial ( r )
for i in xrange ( offset , r . n_variables () ) :
var_as_mono *= r . variable ( i )
res = None
res = l e x _ g r o e b n e r _ b a s i s _ p o i n t s (S , var_as_mono )
return res
# ################################
# Compute Groebner basis of
# elimination ideal
# by all - solution SAT
72
# and interpolation
# ################################
def SATElim ( data ) :
t = time ()
ideal = data . ideal
ring = data . ring
N = 2* data . num_states
CNFs = toCNF ( ideal )
Sols = Avi_all_sat ( CNFs , N )
gb = lex_gb_noes ( Sols ,N , ring )
return gb
# ################################
# Compute Groebner basis
# ################################
def GBElim ( data ) :
ideal = data . ideal
ring = data . ring
gb = groebner_basis ( ideal2 )
res = [ poly for poly in gb if poly . navigation () . value () >= data .
num_signals ]
return res
# ################################
# Test all benchmarks
# ################################
def main () :
d ={27:3 , 208:8 , 298:14 , 344:15 , 349:15 , 382:21 , 386:6 , 420:16 , 444:21 ,
510:6 , 526:21 , 641:19 , 713:19 , 820:5 , 832:5 , 838:32 , 953:29 ,
1196:18 , 1238:18 , 1423:74 , 1488:6 , 1494:6}
resource . setrlimit ( resource . RLIMIT_CPU , (36000 ,36001) )
signal . signal ( signal . SIGXCPU , time_expired )
print ’ Starting : ’ , ctime ()
# Parse input
method = sys . argv [1]
num = int ( sys . argv [2])
inum = 0
t = time ()
# Get data
data = get_data ( num , inum )
73
if method == " g " :
gb = GBElim ( data )
elif method == " s " :
gb = SATElim ( data )
# Resource statistics
GBtime = time () -t
GBmem = resource . getrusage ( resource . RUSAGE_SELF ) . ru_maxrss / 1000
# Output to screen
print " time = " , GBtime
print " mem = " , GBmem , " M "
print ’ End : ’ , ctime ()
exit ()
return
# indexing
def E (* args ) :
res = args [0]
for i in xrange (1 , len ( args ) ) :
res = res + " _ " + str ( args [ i ])
return res
74
line = line [: -1]+ " ) ," + ordering
lines . append ( line )
# set options
def set_options (* args ) :
for i in xrange ( len ( args ) ) :
line = " option ( " + args [ i ]+ " ) "
lines . append ( line )
# define an ideal
def mk_ideal ( poly_list , start_index , name ) :
res = " ideal " + name + " = ( "
for poly in poly_list :
p = " poly p " + str ( start_index ) + " = " + poly
lines . append ( p )
res = res + " p " + str ( start_index ) + " ,"
start_index +=1
res = res [: -1] + " ) "
lines . append ( res )
return start_index
75
# write to a text file
def write2file ( lines ) :
new = open ( fn , " w " )
for line in lines :
new . write ( line )
new . write ( " ;\ n " )
new . close ()
# ---------------------------------------
# ring data
# ---------------------------------------
r_vars = mk_vars ( " r " , bw )
ready_vars = mk_vars ( " ready " , bw )
a_vars = mk_vars ( " a " , bw )
b_vars = mk_vars ( " b " , bw )
bz_vars = mk_vars ( " bz " , bw )
# all_vars = r_vars + ready_vars + a_vars + [" a " ," b "] + bz_vars + b_vars
all_vars = r_vars + ready_vars + a_vars + [ " a " ] + bz_vars + b_vars +[ " b " ]
ordering = " lp "
# ---------------------------------------
# Poly data
# ---------------------------------------
polys_block =[]
polys =[]
polys . append ( " r_0 - 0 " )
polys . append ( " a_0 - a " )
polys . append ( " b_0 - b " )
polys_block . append ( polys )
for i in xrange ( bw ) :
polys =[]
# Equation for r
poly1 = E ( " r " ,i +1) + E ( " -r " ,i ) + E ( " -a " ,i ) + E ( " * bz " ,i )
polys . append ( poly1 )
# Equation for a
poly2 = E ( " a " ,i +1) + E ( " -2* a " ,i )
polys . append ( poly2 )
# Equations model operator shift b left .
poly3 = E ( " 2* b " ,i +1) + E ( " -b " ,i ) + E ( " + bz " ,i )
polys . append ( poly3 )
polys_block . append ( polys )
# --------------------------------------
# Main
# --------------------------------------
lines =[]
write2file ( lines )
# --------------------------------------
END
76
# !/ bin / bash
# ================================================
# Verify the global property of an filter
# using computer algebra techniques
# ================================================
filename = " filter2 . txt "
textfile = $1
# indexing
def E (* args ) :
res = args [0]
for i in xrange (1 , len ( args ) ) :
res = res + " _ " + str ( args [ i ])
return res
def resolve_bitvar ( s ) :
res = s
if s . find ( " [ " ) == -1:
return res
res = res . replace ( " [ " ," _ " )
res = res . replace ( " ] " ," " )
return res
77
def one_side_eq ( s ) :
res = s
res = res . replace ( " + " ," ++ " )
res = res . replace ( " -" ," + " )
res = res . replace ( " ++ " ," -" )
res = res . replace ( " = " ," -" )
return res
def parse_eq (s , k ) :
s = clean ( s )
s = s . replace ( " <= " ," = " )
s = resolve_bitvar ( s )
if s . find ( " == " ) >=0:
s = s . replace ( " == " ," = " )
instant = True
else :
instant = False
eq_index = s . find ( " = " )
res = " "
v=""
i =0
while i < len ( s ) :
if s [ i ] not in [ " = " ," * " ," + " ," -" ]:
v += s [ i ]
if i == ( len ( s ) -1) :
if instant :
res = add_index (v , k +1 , res )
else :
res = add_index (v ,k , res )
else :
if (i <= eq_index ) or instant :
res = add_index (v , k +1 , res )
else :
res = add_index (v ,k , res )
res += s [ i ]
v=""
i +=1
res = one_side_eq ( res )
return res
78
for i in xrange ( ival ) :
res . append ([])
for s in eqs . split ( " \ n " ) :
s = s . replace ( " ; " ," " )
if s . find ( " = " ) >=0:
for i in xrange ( ival ) :
tmp = parse_eq (s , i )
res [ i ]. append ( tmp )
elif s . find ( " >>" ) >=0:
for i in xrange ( ival ) :
tmp = p arse_s hift_r ight (s ,i , bw )
res [ i ]+= tmp
return res
# ---------------------------------------------
# set options
def set_options (* args ) :
for i in xrange ( len ( args ) ) :
line = " option ( " + args [ i ]+ " ) "
lines . append ( line )
# define an ideal
def mk_ideal ( poly_list , start_index , name ) :
res = " ideal " + name + " = ( "
for poly in poly_list :
p = " poly p " + str ( start_index ) + " = " + poly
lines . append ( p )
res = res + " p " + str ( start_index ) + " ,"
start_index +=1
res = res [: -1] + " ) "
lines . append ( res )
return start_index
79
data_i_18 * k16_i_35 + data_i_17 * k17_i_35 + data_i_16 * k18_i_35 +
data_i_15 * k19_i_35 + data_i_14 * k20_i_35 + data_i_13 * k21_i_35 +
data_i_12 * k22_i_35 + data_i_11 * k23_i_35 + data_i_10 * k24_i_35 +
data_i_9 * k25_i_35 + data_i_8 * k26_i_35 + data_i_7 * k27_i_35 +
data_i_6 * k28_i_35 + data_i_5 * k29_i_35 + data_i_4 * k30_i_35 +
data_i_3 * k31_i_35 + data_i_2 * k32_i_35 + data_i_1 * k33_i_35 ) " )
lines . append ( " reduce ( proofgoal , ide ) " )
lines . append ( " quit " )
d a t a _ o _ r _ d e l a y e d _ v a r s =[]
for i in reversed ( xrange (7) ) :
d a t a _ o _ r _ d e l a y e d _ v a r s += mk_vars ( " dat a_o_r_ delaye d_ " + str ( i +1) , nc )
reg_vars =[]
for i in reversed ( xrange (34) ) :
reg_vars += mk_vars ( " reg " + str ( i ) , nc )
d a t a _ i _ r _ d e l a y e d _ v a r s =[]
for i in reversed ( xrange (34) ) :
d a t a _ i _ r _ d e l a y e d _ v a r s += mk_vars ( " dat a_i_r_ delaye d_ " + str ( i +1) , nc )
k_vars =[]
for i in reversed ( xrange (34) ) :
k_vars += mk_vars ( " k " + str ( i ) + " _i " , nc )
# variable ordering and monomial ordering
all_vars = data_o_vars + d a t a _ o _ r _ d e l a y e d _ v a r s + reg_vars +
d a t a _ i _ r _ d e l a y e d _ v a r s + data_i_vars + k_vars
ordering = " lp "
# Poly data
polys_block = parse ( " $textfile " , nc )
# Main
lines =[]
mk_ring (38 , all_vars , ordering , " r " )
set_options ( " notWarnSB " )
mk_global_ideal ( polys_block )
check_proofgoal ()
# write to file
write2file ( lines )
# -------------------------------------------------------------
END
80
Bibliography
[ABKR00] J. Abbott, A. Bigatti, M. Kreuzer, and L. Robbiano. Computing ideals of points.
Journal of Symbolic Computation, 30(4):341–356, 2000.
[AS09] Gilles Audemard and Laurent Simon. Predicting learnt clauses quality in modern
sat solvers. In Proceedings of the 21st international jont conference on Artifical
intelligence, IJCAI’09, pages 399–404, San Francisco, CA, USA, 2009. Morgan
Kaufmann Publishers Inc.
[BD13] Michael Brickenstein and Alexander Dreyer. Gröbner-free normal forms for
boolean polynomials. Journal of Symbolic Computation, 48(0):37–53, 2013.
[BDG+ 09] Michael Brickenstein, Alexander Dreyer, Gert-Martin Greuel, Markus Wedler,
and Oliver Wienand. New developments in the theory of gröbner bases and appli-
cations to formal verification. Journal of Pure and Applied Algebra, 213(8):1612–
1635, 2009. Theoretical Effectivity and Practical Effectivity of Gröbner Bases.
[BMS00] Luı́s Baptista and João Marques-Silva. Using randomization and learning to
solve hard real-world instances of satisfiability, 2000.
[Bri10] Michael Brickenstein. Boolean Gröbner bases – Theory, Algorithms and Appli-
cations. PhD thesis, University of Kaiserslautern, Germany, 2010.
[CEI96] M. Clegg, J. Edmonds, and R. Impagliazzo. Using the Gröbner basis algorithm
to find proofs of unsatisfiability. Proceedings of the Twenty-eighth Annual ACM
S ymposium on the Theory of Computing, pages 174–183, 1996.
[CK07] Christopher Condrat and Priyank Kalla. A Gröbner basis approach to CNF-
formulae preprocessing. In Tools and Algorithms for the Construction and Anal-
ysis of Systems, volume 4424 of Lecture Notes in Computer Science, pages 618–
631. Springer, 2007.
81
[DGPS12] Wolfram Decker, Gert-Martin Greuel, Gerhard Pfister, and Hans Schönemann.
Singular 3-1-6 — A computer algebra system for polynomial computations.
http://www.singular.uni-kl.de, 2012.
[DLL62] Martin Davis, George Logemann, and Donald Loveland. A machine program for
theorem-proving. Commun. ACM, 5(7):394–397, July 1962.
[DP60] Martin Davis and Hilary Putnam. A computing procedure for quantification
theory. J. ACM, 7(3):201–215, July 1960.
[EB05] Niklas Eén and Armin Biere. Effective preprocessing in SAT through variable
and clause elimination. In Proceedings of the 8th international conference on
Theory and Applications of Satisfiability Testing, SAT’05, pages 61–75, Berlin,
Heidelberg, 2005. Springer-Verlag.
[ES04] Niklas Eén and Niklas Sörensson. An extensible SAT-solver. In Theory and
Applications of Satisfiability Testing, volume 2919 of Lecture Notes in Computer
Science, pages 333–336. Springer Berlin / Heidelberg, 2004.
[GSK98] Carla P. Gomes, Bart Selman, and Henry Kautz. Boosting combinatorial search
through randomization. In Proceedings of the 15th national conference on Artifi-
cial intelligence, pages 431–437. American Association for Artificial Intelligence,
1998.
[GSY04] Orna Grumberg, Assaf Schuster, and Avi Yadgar. Memory efficient all-solutions
sat solver and its application for reachability analysis. In In Proceedings of
the 5th International Conference on Formal Methods in Computer-Aided Design
(FMCAD, pages 275–289. Springer, 2004.
[JS06] Winfried Just and Brandilyn Stigler. Computing gröbner bases of ideals of few
points in high dimensions. ACM Commun. Comput. Algebra, 40(3-4):67–78,
September 2006.
82
[MSSSS96] Joao P. Marques-Silva, Joo P. Marques Silva, Karem A. Sakallah, and Karem A.
Sakallah. Grasp - a new search algorithm for satisfiability. In in Proceedings of
the International Conference on Computer-Aided Design, pages 220–227, 1996.
[RD06] G. Van Rossum and Fred L. Drake. The Python Language Reference Manual.
Network Theory Ltd., Bristol, United Kingdom, November 2006.
[SNC09] Mate Soos, Karsten Nohl, and Claude Castelluccia. Extending sat solvers to
cryptographic problems. In Proceedings of the 12th International Conference
on Theory and Applications of Satisfiability Testing, SAT ’09, pages 244–257,
Berlin, Heidelberg, 2009. Springer-Verlag.
[zGG03] Joachim von zur Gathen and Jürgen Gerhard. Modern Computer Algebra. Cam-
bridge University Press, second edition, 2003.
[ZK10] Christoph Zengler and Wolfgang Küchlin. Extending clause learning of SAT
solvers with Boolean Gröbner bases. In Proceedings of the 12th international
conference on Computer algebra in scientific computing, CASC’10, pages 293–
302, Berlin, Heidelberg, 2010. Springer-Verlag.
83
Wissenschaftlicher Werdegang
1990 – 2002 Besuch der Schule in Vinh Long, Vietnam.
2002 Abschluss an der Pham Hung High School, Vinh Long, Vietnam.
Curriculum Vitae
1990 – 2002 Elementary, secondary, and high school in Vinh Long, Vietnam.
2002 Graduation from Pham Hung High School, Vinh Long, Vietnam.
I hereby declare that this thesis is my own work and effort, and that no other sources than those
listed have been used.
The third chapter of this thesis has been publisched in the Proceeding of 2nd Young Researcher
Symposium 2013 by Fraunhofer Verlag, ISBN 978-3-8396-0628-5.
I am not in a second examination process right now.