[wpdm_file id=1]

CryptoMiniSat 4 is now available for download. This version brings a number of substantial improvements and picks up speed to be as good as the best solvers out there. It now has a much improved library interface as well as a simple but powerful python interface.

### SAT Competition 2014

This release is made ahead of the SAT competition 2014 deadlines so anybody can compete and actually have a chance to win. Unfortunately, the way I see it, it’s not possible to use newer versions of lingeling or riss (see license for for details), MiniSat is rather old and glucose doesn’t have new simplification techniques. If you feel the same way, and you rather not write 30K LoC of code, you might enjoy playing with CryptoMiniSat v4 and submitting it to the competition. You can change as much as you like, it’s LGPLv2 — just don’t call it CryptoMiniSat.

### Improvements and techniques

Here is a non-exhaustive list of techniques used in CryptoMiniSat v4:

- Variable elimination and replacement, strengthening, subsumption, vivification
- On-the-fly stamping, literal caching, hyper-binary resolution and transitive reduction during failed literal probing
- Bounded variable addition with hack to allow 2-literal diff
- DRUP-based unsatisfiable proof logging
- Gate-based clause shortening and removal
- XOR recovery and manipulation (NOTE: uses the M4RI library that is GPL, if you want LGPL, compile without it)
- Precise time- and memory tracking. No time or memory-outs on weird CNFs
- Precise usefulness tracking of all clauses
- Clause usefulness-based redundant clause removal. Glues are not used by default, but glues are tracked and can be used (command line option)
- Variable renumbering and variable number hiding. Thanks to this, XOR clauses are cut and the added variables are transparent to the user.
- SQL-based data logging and AJAX-based powerful data display
- And of course many-many more

All of the above are implemented as inprocessing techniques. I do not believe in preprocessing and the solver does not in fact use preprocessing at all — it immediately starts to solve instead. This, as everything else, is configurable and you can change it by passing `’–presimp 1’` as a command-line option. There are a total of 120 command-line options so you can tune the solver as you like.

### Python interface

It’s intuitive and fun to use:

```
>>> from pycryptosat import Solver
>>> s = Solver()
>>> s.add_clause([-1])
>>> s.add_clause([1, 2])
>>> sat, solution = s.solve()
>>> print sat
True
>>> print solution[1]
False
>>> print solution[2]
True
```

You can even have assumptions:

```
>>> from pycryptosat import Solver
>>> s = Solver()
>>> s.add_clause([-1])
>>> sat, solution = s.solve([1])
>>> print sat
False
>>> sat, solution = s.solve()
>>> print sat
True
```

All the power of the SAT solver in a very accessible manner. XOR clauses are trivial, too:

```
>>> from pycryptosat import Solver
>>> s = Solver()
>>> s.add_xor_clause([1, 2], false)
>>> sat, solution = s.solve([1])
>>> print sat
True
>>> print solution[1]
True
>>> print solution[2]
True
```

Where the second argument is the right hand side (RHS) of the equation v1 XOR v2 = False.

### C++ interface

Usage is pretty simple, and the header files have been significantly cleaned up:

`#include `
#include
#include
using std::vector;
using namespace CMSat;
int main()
{
Solver solver;
vector clause;
//adds "1 0"
clause.push_back(Lit(0, false));
solver.add_clause(clause);
//adds "-2 0"
clause.clear();
clause.push_back(Lit(1, true));
solver.add_clause(clause);
//adds "-1 2 3 0"
clause.clear();
clause.push_back(Lit(0, true));
clause.push_back(Lit(1, false));
clause.push_back(Lit(2, false));
solver.add_clause(clause);
lbool ret = solver.solve();
assert(ret == l_True);
assert(solver.get_model()[0] == l_True);
assert(solver.get_model()[1] == l_False);
assert(solver.get_model()[2] == l_True);
return 0;
}

### Some suggestions where you can improve the solver to compete

Here is a non-exhaustive list of things that you can improve to win at the competition:

- Add your own weird idea. You can add new variables if you like, use the occurrence lists already built, and take advantage of all the datastructures (such as stamps, literal cache) already present.
- Tune the parameters. I only have exactly one i7-4770 to tune the parameters. You might have more. All parameters are accessible from command line, so tuning should be trivial.
- Use glues to clean clauses. Or use a combination of glues and usefulness metrics. All the metrics are at your fingertips.
- Make bounded variable addition work for learnt clauses. I could never figure this one out.
- Improve the ordering of variable elimination. Makes a huge difference.
- Try a different approach: I use the ‘heavy’ approach where I don’t remove all clauses that I can as I like strong propagation properties. You might try the ‘light’ approach where everything is removed if possible. Just set variable elimination to 100% and add blocked clause elimination. It might work.

For example, below is the code that calculates which clause should be cleaned or kept. You can clearly see how easily this can be changed using the data elements below:

```
bool Solver::reduceDBStructPropConfl::operator() (const ClOffset xOff, const ClOffset yOff) {
const Clause* x = clAllocator.getPointer(xOff);
const Clause* y = clAllocator.getPointer(yOff);
uint64_t x_useful = x->stats.propagations_made
+ x->stats.conflicts_made;
uint64_t y_useful = y->stats.propagations_made
+ y->stats.conflicts_made;
return x_useful < y_useful;
}
//the data you can use to hack the above calculation:
struct ClauseStats
{
uint32_t glue; ///
```
If you were thinking about submitting your weird hack to the MiniSat hacktrack, think about doing the same to CrytoMiniSat v4. You might actually win the *real* competition. You can change as much as you like.

I will submit a description of CryptoMiniSat v4, your description can simply say that it's the same except for *xyz* that you changed. The point of the descriptions is so that people can read what you did and why and then comprehend the results in that light. Just explain carefully what you did and why, and you should be fine.

### Thanks

Many-many thanks to Martin Maurer who has submitted over 100 bug reports through the GitHub issue system. Kudos to all who have helped me use, debug and improve the solver. To name just a few: Vegard Nossum, Martin Albrecht, Karsten Nohl, Luca Melette, Vijay Ganesh and Robert Aston.