28
$\begingroup$

Scott Aaronson's blog post today gave a list of interesting open problems/tasks in complexity. One in particular caught my attention:

Build a public library of 3SAT instances, with as few variables and clauses as possible, that would have noteworthy consequences if solved. (For example, instances encoding the RSA factoring challenges.) Investigate the performance of the best current SAT-solvers on this library.

This triggered my question: What's the standard technique for reducing RSA/factoring problems to SAT, and how fast is it? Is there such a standard reduction?

Just to be clear, by "fast" I don't mean polynomial time. I'm wondering whether we have tighter upper bounds on the reduction's complexity. For example, is there a known cubic reduction?

$\endgroup$
26
$\begingroup$

One approach to encode Factoring (RSA) to SAT is to use multiplicator circuits (Every circuit can be encoded as CNF).

Let's assume we are given an integer $C$ with $2n$ bits, $C=(c_1,c_2,\cdots,c_{2n})_2$. We are interested in finding two $n$-bit integers $A=(a_1,\cdots,a_n)$ and $A=(b_1,\cdots,b_n)$ whose product is $C=A*B$.

The most naive encoding can be something like this: We know that

$$c_{2n}= a_n \land b_n$$ $$c_{2n-1}= (a_n\land b_{n-1}) xor (a_{n-1}\land b_n)$$ $$Carry:d_{2n-1}= (a_n\land b_{n-1}) \land (a_{n-1}\land b_n)$$ $$c_{2n-2}= (a_n\land b_{n-2}) xor (a_{n-1}\land b_{n-1}) xor (a_{n-2}\land b_{n}) xor d_{2n-1}$$ ...

Then using Tseitin transformation, the above encoding can be translated into CNF.

This approach produces a relatively small CNF. But this encoding does not support "Unit Propagation" and so, the performance of SAT Solvers are really bad.

There are other circuit for multiplication which can be used for this purpose, but they produce a larger CNF.

$\endgroup$
  • 10
    $\begingroup$ In section 6.1 of "Finding Hard Instances of the Satisfiability problem: A survey", by Cook and Mitchell, they use this problem as a challenge. $\endgroup$ – Amir May 27 '11 at 6:29
  • $\begingroup$ How do you know that A and B must be n bits length, couldn't it be n - 1 and and n bits. For sure it can be 2n bits and 1 bit. $\endgroup$ – Ilya Gazman Oct 17 '13 at 13:14
  • 1
    $\begingroup$ @Babibu: If we are talking about general factorization, you are right. But for case of RSA, we know that each of the two primes has $n$ bits. $\endgroup$ – Amir Oct 17 '13 at 19:40
  • $\begingroup$ I understand you answer but I don't know how to continue it. Can you please show $c_{2n−2}$. $\endgroup$ – Ilya Gazman Nov 11 '13 at 8:06
  • $\begingroup$ What about RSA-129 $\endgroup$ – Ilya Gazman Nov 28 '13 at 23:41
18
$\begingroup$

Extending what @Amir wrote, I came across the following nice web page which hosts a CNF generator for factoring circuits that one could e.g. run on some of the (now inactive) RSA Factoring Challenge numbers. The generated instances are in DIMACS format that can directly be fed to any one of the current competitors in the annual SAT solver competition. Regarding hard SAT instances in general, the benchmark problems given at the SAT competition site appear to be quite useful, also the classification into random/crafted/industrial is nice.

$\endgroup$
  • 1
    $\begingroup$ That link is very cool! $\endgroup$ – Huck Bennett May 28 '11 at 16:23
  • $\begingroup$ If you actually try inputting one of those numbers you'll find their source code uses the int datatype and therefore can only hold 32-bit numbers, while the unfactored RSA numbers start at hundreds of bits. $\endgroup$ – Elliot Gorokhovsky Dec 9 '14 at 3:10
11
$\begingroup$

Here's a paper on generating SAT instances from factoring:

Horie, S. & Watanabe, O. [1997] "Hard instance generation for SAT" Algorithms and Computation 1350:22-31 (pdf)

It's worse than linear, but better than $n^2$. A 512-bit RSA challenge type number generates an instance with 63,652 variables and 406,860 clauses.

$\endgroup$
9
$\begingroup$

ToughSat by Henry Yuen and Joseph Bebel is another tool similar to the one linked by @Martin, which generates CNF formulas that encode instances of factoring and other hard problems.

$\endgroup$
0
$\begingroup$

See satfactor:


Convert Integer Factorization into a boolean SATISFIABILITY problem

Shane Neph

Overview

Determining factors of a large integer number has been of interest to Man since at least Euclid's time. There is no known general algorithm for this problem that scales in less than exponential time with respect to the number of bits needed to represent the integer.

What this code does

Converts an integer factorization problem into a boolean SATISFIABILITY problem. If the problem is solved by a SAT solver, it then extracts the integer factors.

Boolen satisfiability solvers improve every year. Every 2 years, an international competition between solvers takes place (see http://www.satcompetition.org/ and http://www.satlive.org/). How well can these state-of-the-art solvers do against one of the oldest open math problems in existence?

This project has 2 main purposes:
1) Convert the problem and factor an integer of interest!
2) Quickly create either a solvable or an unsolvable SATISFIABILITY problem, whose difficulty is easily controlled by the creater.
- To create an unsolvable SATISFIABILITY problem, simply encode a prime number.
- To create more difficult but solvable problems, choose larger composite numbers with fewer factors.

The number of interest may be any size!

There are some open-source SATISFIABILITY solvers. See http://www.satlive.org/ for some of these.

Build

make -C src/

How-To

Input a number of interest in its binary form:

bin/iencode 10101 > composite.21
// solve with your favorite solver and put results in solution.txt
bin/extract-sat composite.21 solution.txt

The output would be:
00011
00111

which are binary representations for decimal integers 3 and 7, the factors of 21.

If an input integer has more than 2 factors, and the SAT problem is solved, the output will be two of the factors only. These may not be prime numbers (you could test for that easily in Maxima, Maple, or Mathematica).

Not all SAT solvers output results in the same format. You may need to doctor those results slightly. extract-sat requires a solution file containing a list of integers (on any number of lines). For example,

1 -2 3 4 -5 ...

$\endgroup$
  • 1
    $\begingroup$ Can you summarize the techniques used by this software? On this site we are more interested in algorithms and techniques, rather than an advertisement of a software tool. For example, the questions for the complexity of the reduction. I don't see how you've addressed the question; on Stack Exchange sites, you should only answer if you can answer the specific question that was asked. Also, do you have any relationship with the tool or its authors? $\endgroup$ – D.W. Sep 15 '18 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.