[{"content":" Andrei Tarkovsky\u0026rsquo;s Stalker (1979)\nCharlie Munger said: \u0026ldquo;Show me the incentive and I will show you the outcome\u0026rdquo;. The issue with Academic Research, in my opinion, is that the outcomes have drifted very far away from the original goal, which I believe to be the advancement of scientific understanding, and training of the new generation of researchers. Academic research was meant to be about breaking new ground, keeping to honesty and good scientific conduct, being clear and upfront about uncertainties, errors, and mistakes, and improving our common understanding of science, all the while training the new generation to follow these goals and principles.\nRecently, I have bumped into multiple cases where I believe the correctness of the results, the honesty of the people writing them, or the lack of curiosity once they are told that their results are wrong, incorrect, faulty, or misleading, has been unsatisfying. Simply put, researchers are not too interested in learning that their papers or reports are wrong, and/or misleading others who don\u0026rsquo;t happen to know that the results are \u0026ndash; known to the authors, and a few select others to be partially \u0026ndash; incorrect.\nThe issue is, once you published the paper, and got the promotions and fame, it doesn\u0026rsquo;t matter that the results are wrong, and known to be wrong or misleading, and potentially doing harm to the advancement of science. It\u0026rsquo;s not your problem. It\u0026rsquo;s someone else\u0026rsquo;s problem. In fact, when I challenged the authors of one such paper, considered state-of-the-art, and known to the authors to have incorrect evaluation, one of the author\u0026rsquo;s response was along the lines of acknowledging the issues, but refusing to retract the paper, and instead asking if it\u0026rsquo;s bothering me in publishing my paper.\nThe incentives are wrong. In my opinion, it\u0026rsquo;s not all about the papers \u0026ndash; mine or others\u0026rsquo;. It\u0026rsquo;s about scientific integrity, about being honest with each other, it\u0026rsquo;s about caring about the results, it\u0026rsquo;s about advancement of our common scientific understanding through seeking of truth and correctness. It\u0026rsquo;s about communicating when something is wildly wrong, and either retracting the relevant incorrect claims, or notifying the community of the known serious issues. It\u0026rsquo;s about caring for what we all consider to be the common understanding of what is the truth, and cultivating an environment where the new generation grows up to learn what the proper scientific conduct is, and that it is notacceptable to seriously deviate from it.\nUnfortunately, I am seeing more and more PhD students who are less and less interested in correctness, precision, and what I\u0026rsquo;d consider proper scientific conduct. They have learned from those successful in the field what does and does not matter. I remember when someone once told me that my approach for a particular algorithm was wrong (about strongly connected components discovery), and how upset I was that I had no idea. I went home that day and I immediately fixed my tool to use the right approach (i.e. to use Tarjan\u0026rsquo;s algorithm). I felt deep shame that I had no clue what I was doing, and that I messed up. In contrast, recently talked with a PhD student who wrote a tool that was meant to perform well in certain contexts. When I explained the student that the approach to the evaluation was incorrect, they didn\u0026rsquo;t follow up at all. I think they were surprised that I later followed up, demonstrating that indeed the evaluation was not careful enough, and the tool is less useful than it seems from the paper\u0026rsquo;s evaluation. It was a strange experience \u0026ndash; when I was a PhD student and someone sat down and showed me that what I was doing was potentially sloppy, I was super worried and very curious to find out what\u0026rsquo;s going on. I still remember this moment when a reviewer of my dissertation challenged a graph and I was stressed for a week before I figured out they misread the graph, because I didn\u0026rsquo;t label it clearly. Or when in a presentation I accidentally left out performing so-called \u0026lsquo;restarts\u0026rsquo; as a major advancement in the history of SAT solvers, and someone in the audience rightfully pointed it out. I felt embarrassed for having made such a mistake.\nI am not sure how to fix this problem. Seemingly, researchers are less and less keen on correctness, precision, and scientific curiosity. They don\u0026rsquo;t seem to be incentivised to do so. I sometimes wonder if the system has become so damaged, so many PhD students have grown up to be professors in this environment, that much of what I wrote here seems alien, even repulsive, to many. It makes me sad.\n","permalink":"https://www.msoos.org/2026/10/incentives-in-academic-research/","summary":"\u003cfigure class=\"alignright\"\u003e\n    \u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2026/10/stalker.jpg\"\n         alt=\"Andrei Tarkovsky\u0026rsquo;s Stalker (1979)\" width=\"392\"/\u003e \u003cfigcaption\u003e\n            \u003cp\u003eAndrei Tarkovsky\u0026rsquo;s Stalker (1979)\u003c/p\u003e\n        \u003c/figcaption\u003e\n\u003c/figure\u003e\n\n\u003cp\u003eCharlie Munger said: \u0026ldquo;Show me the incentive and I will show you the outcome\u0026rdquo;. The issue with Academic Research, in my opinion, is that the outcomes have drifted very far away from the original goal, which I believe to be the advancement of scientific understanding, and training of the new generation of researchers. Academic research was meant to be about breaking new ground, keeping to honesty and good scientific conduct, being clear and upfront about uncertainties, errors, and mistakes, and improving our common understanding of science, all the while training the new generation to follow these goals and principles.\u003c/p\u003e","title":"Incentives in Academic Research"},{"content":"I was quite hopeful when I first saw the XNF solver 2-Xornado, and then Xorricane, which solve so-called XOR-OR-AND (XNF) problems, i.e. problems written in the format \u0026ldquo;(a XOR b XOR c) or (f XOR NOT g)\u0026rdquo;. The two papers about this family of solvers were [ PDF1][ PDF2], and the results looked impressive. They could outdo CryptoMiniSat, my CNF-XOR solver, on a bunch of instance families. To be honest, I suspected a cutoff being fired, but I was also hopeful and didn\u0026rsquo;t want to be the annoying person in the way of new research. Then the Xorcle paper dropped [ PDF] and my collaborator asked me to take a look. This led me down a rabbit hole of figuring out that in fact, all these years, XNF solvers have been comparing against CryptoMiniSat in a somewhat unflattering way.\nCryptoMiniSat has to function as a regular SAT solver as well as perform XOR reasoning, while the XNF solvers only really work well for XNF inputs, and are not so competitive on CNF inputs. In order to balance the requirement of needing to also work on plain CNF input, CryptoMiniSat has a number of cutoffs. For example, it didn\u0026rsquo;t use more than 3-5 matrices at most by default, and the number of rows and columns in matrices was also limited. However, the instances that the XNF authors were using sometimes had extremely large matrices, and/or very many of them (e.g. over 1000 matrices). Furthermore, some of them contained blasted XOR constraints that are quite long, and would normally be cut up \u0026ndash; so CryptoMiniSat\u0026rsquo;s default recovery limit didn\u0026rsquo;t check for them. This meant that CryptoMiniSat was often not running XOR reasoning (Gauss-Jordan Elimination, GJE) on many of these instances. Essentially, the defaults made it easy to run benchmarks incorrectly with CryptoMiniSat.\nPerformance of CryptoMiniSat vs XNF Solvers I had a go at checking the performance of CryptoMiniSat once these limits were lifted. Unfortunately, it turns out that CryptoMiniSat had a few annoying performance bugs. Firstly, each propagation of GJE ran an algorithm linear in the number of matrices, which didn\u0026rsquo;t quite work with over 500 matrices. Oops. Secondly, there was a silly limit in the maximum discoverable XOR size, which had to be lifted. Finally, I never thought there\u0026rsquo;d be more than 1000 matrices, so 1000 was a reserved number, and caused an assertion failure. These had to be fixed.\nOnce fixed, running CryptoMiniSat with \u0026quot; --autodisablegauss 0 --presimp 1 --maxmatrixrows 100000 --maxmatrixcols 100000 --maxnummatrices 1000000 --minmatrixrows 1 --maxxorsize 12\u0026quot; to lift all the minimum/maximum limits, led to it outperforming all the XNF solvers by a healthy margin. The results are available here. Main graph:\nAs you can see, CryptoMiniSat (\u0026ldquo;cms\u0026rdquo;) with those minor performance changes (changes only needed for \u0026ldquo;lifted pebbling\u0026rdquo; and \u0026ldquo;tseitin\u0026rdquo; families) and the correct options solves many more instances than the XNF solvers. Moreover, as per the report, it solves almost every family as fast or faster than these solvers, individually, as well.\nThen I thought maybe I should spend some time with an AI to fix up CryptoMiniSat, and take ideas from CaDiCaL in the process. So I pointed the AI to CaDiCaL by Armin Biere et al. (a paper on one of its best techniques is here) and let it find all the things that I missed over the past 5-6 years. The result is the \u0026ldquo;cms-improved\u0026rdquo; line in the graph above. It took two evenings with AI, and now it\u0026rsquo;s quite performant, outperforming both Xorcle and Xorricane on every benchmark family except \u0026ldquo;lifted pebbling\u0026rdquo; where both Xorcle and CMS finish all benchmarks under 4 seconds or less. The new version of CryptoMiniSat has a better \u0026ldquo;too slow GJE\u0026rdquo; detection, so all limits have been lifted by default. So in the future, it should be easier to correctly run such benchmarks with CryptoMiniSat. While this version of CMS is of course better than the old version, it was not really tuned for these benchmarks. I need CMS to perform relatively well on all the things I use it for, and that\u0026rsquo;s mostly ApproxMC solving and Ganak preprocessing.\nBugs and Fuzzing I was curious whether these tools were outputting correct solutions. So I took the 20 minutes to ask an AI to write an XNF fuzzer (should be about 2-3h by hand) and test the tools. Unfortunately, the tools seem not to have been tested with a fuzzer. Both had a wrong-answer bug on edge-case inputs, and both had crashes and inconsistencies. Xorricane seems to be faring worse: Xorcle had 4 bugs [ here] and Xorricane had 9 [ here].\nCryptoMiniSat is fuzzed extensively, and has been for a long while. Also it emits a proof for GJE reasoning thanks to the work of Jiong Yang, Yong Kiam Tan et al. [ paper]. Actually, I asked an AI to fix up the proof generation, and now it emits a pure XLRUP proof, without needing any refinement via frat-rs (by Mario Carneiro [ paper]), which was previously required.\nXNF Solving Report The full XNF solving report is available here, the code, logs, data etc. to generate it are all available here, and the fuzzer is part of that codebase, here. It only took about a weekend to put this together, using AI. I think it\u0026rsquo;s a rather interesting set of benchmarks, gathered by the authors of Xorcle and Xorricane. All the benchmarks are of course directly sourced via git submodules, so I give credit where credit is due. I also ran Bosphorus [ code][ paper], our ANF solver, on the relevant problems just for fun. I keep maintaining it as well, and with the new CryptoMiniSat it was performing quite well.\nThe Future of Research I have to admit that I feel disappointed by this line of XNF research. I was hoping that something really interesting would come out of it. But seeing that the tools don\u0026rsquo;t seem to have been fuzz-tested, and overall they are not well-performing on the benchmark sets used by the papers, I am somewhat less optimistic. I still hope that someone will do something really-really cool with CNF-XOR, though. I think it\u0026rsquo;s more possible than ever before, now that we have AI. In fact, I pointed the AI at the Gauss-Jordan Elimination in CryptoMiniSat, and it found a really cool way of making it several times faster, depending on the matrix size. Thanks to this, ApproxMC, our approximate model counter, is almost twice as fast as before.\nHowever, the question is \u0026ndash; what\u0026rsquo;s the point of research if we can just ask the AI to do a lot of things for us? Tools that are correct? Tools that people want to use and re-use for years, maybe even decades to come? CryptoMiniSat was originally published in 2009, nearly two decades ago. Will today\u0026rsquo;s CNF-XOR/XNF solvers still be around in 20 years? Would it be rightfully called research or just engineering at that point? Would it be the right use of research time? None of these questions have easy or clear answers. Maybe it\u0026rsquo;s a waste of time for researchers to write and maintain tools \u0026ndash; maybe their job is to come up with cool ideas, and let the industry implement them well/bug-free. Sometimes, it\u0026rsquo;s best to do fire-and-forget: write the paper, and not deal with it any more, instead let others pick it up and run with it. I personally keep maintaining CryptoMiniSat nearly 2 decades later, along with Arjun, Ganak, Bosphorus, and pepin -- but of course, I never really made it in research, either.\n","permalink":"https://www.msoos.org/2026/09/cryptominisat-on-xnf-benchmarks-revisited/","summary":"\u003cp\u003eI was quite hopeful when I first saw the XNF solver \u003ca href=\"https://github.com/j-danner/2-Xornado\"\u003e2-Xornado\u003c/a\u003e, and then \u003ca href=\"https://github.com/j-danner/Xorricane/\"\u003eXorricane\u003c/a\u003e, which solve so-called XOR-OR-AND (XNF) problems, i.e. problems written in the format \u0026ldquo;(a XOR b XOR c) or (f XOR NOT g)\u0026rdquo;. The two papers about this family of solvers were [ \u003ca href=\"https://arxiv.org/pdf/2311.00733\"\u003ePDF1\u003c/a\u003e][ \u003ca href=\"https://dl.acm.org/doi/epdf/10.1613/jair.1.20298\"\u003ePDF2\u003c/a\u003e], and the results looked impressive. They could outdo \u003ca href=\"https://github.com/msoos/cryptominisat\"\u003eCryptoMiniSat\u003c/a\u003e, my CNF-XOR solver, on a bunch of instance families. To be honest, I suspected a cutoff being fired, but I was also hopeful and didn\u0026rsquo;t want to be the annoying person in the way of new research. Then the Xorcle paper dropped [ \u003ca href=\"https://arxiv.org/pdf/2605.15002\"\u003ePDF\u003c/a\u003e] and my collaborator asked me to take a look. This led me down a rabbit hole of figuring out that in fact, all these years, XNF solvers have been comparing against CryptoMiniSat in a somewhat unflattering way.\u003c/p\u003e","title":"CryptoMiniSat on XNF Benchmarks, Revisited"},{"content":"Ganak (github), our propositional model counter, has won every single model counting competition track for the past two years. Perhaps it\u0026rsquo;s time to explain how that came about, and what are the ingredients of such a tool. Firstly, a propositional model counter is a tool that counts how many solutions there are to a set of boolean constraints of the form:\na V b b V -c This set of constraints has the following possible solutions:\nabc --- 000 001 010 011 100 101 110 111 But the ones highlighted in bold are not solutions, because the constraints make them incorrect. So we are left with 8-3=5 solutions. There is one more twist. Sometimes, we are only interested in the solutions over a set of variables, which we will call the sampling set, say \u0026ldquo;a\u0026rdquo; and \u0026ldquo;b\u0026rdquo;. Then we are only left with the solutions \u0026ldquo;01x\u0026rdquo;, \u0026ldquo;10x\u0026rdquo;, and \u0026ldquo;11x\u0026rdquo;, a total of 3 solutions, where \u0026ldquo;x\u0026rdquo; means we don\u0026rsquo;t care about the value , since it\u0026rsquo;s not in the sampling set.\nThe History of the Preprocessor: Arjun Arjun (github) came about because we saw the B+E tool doing minimisation of the sampling set. Minimising the sampling set is important, because if the sampling set is e.g. only of size 10, then there are at most 2^10 things to count, but if it\u0026rsquo;s 20, then there are 2^20. It\u0026rsquo;s possible to minimise the sampling set sometimes: for example when we can prove that e.g. a=b, there is no need to have both \u0026ldquo;a\u0026rdquo; and \u0026ldquo;b\u0026rdquo; in the sampling set. Tricks like this can significantly lower the complexity of counting solutions. We enhanced B+E, and published this as a paper here.\nIn the end, it turned out that minimising the sampling set was really only the beginning: we also needed to make the input smaller. The fewer the constraints, and the fewer the number of variables, the easier it is to deal with the formula. This was not new to anyone, but it turns out that this minimisation was hard. Others have tried, too, but my advantage was that I came from the SAT world, with the CryptoMiniSat SAT solver under my belt, so I wrote an entire API (blogpost) for my SAT solver to be used as an input minimiser. This allowed me to try out many heuristics and write code easily, taking advantage of all the datastructures already inside CryptoMiniSat for constraint handling.\nThe History of the Counter: Ganak The actual counter, Ganak (github), was something of another story. It started with a hack that my long-time collaborator Kuldeep Meel and I did in 2018, for a long evening and night in Singapore. This lead to the [original Ganak paper](http://title={GANAK: A Scalable Probabilistic Exact Model Counter},) which essentially added hashing to the system, thereby making it probabilistic, but also use a lot less memory, and thereby faster. I personally haven\u0026rsquo;t touched that project much, and instead focussed all my energies on the preprocessor, Arjun. I was pretty convinced that if I could make the preprocessor good enough, no matter what Ganak looked like, it would be good enough.\nThis strategy of focussing on Arjun mostly paid out, we did well in model counting competitions. The counter d4 was the main competitor at the time. Then SharpSAT-TD (paper) by Korhonen and Jarvisalo and came and it blew everything out of the water. That made me look at the Ganak source code first time in about 5 years, and I was appalled. We were putting a donkey, Ganak, on the rocket, Arjun, that I built, and we were doing OK, but looking at SharpSAT-TD, we were clearly racing a donkey against a cheetah. So In the spring of 2023 I sat down one morning and started replacing things I hated about Ganak, which was mostly everything.\nThus, the Ganak we know today was born. This gradual rewriting took about 2-3 years, continued during the summer and then the next spring. The most significant parts of this rewrite were that we cleaned up the code, added extensive fuzzing and debugging capabilities to it, added/adapted a lot of well-known SAT tricks for counting, integrated the tree decomposition (\u0026ldquo;TD\u0026rdquo;) system and parts of the preprocessor from SharpSAT-TD, and came up with a way to not only minimise the sampling set, but also the extend it, which can help in certain cases.\nIdeas in Ganak and Arjun We wrote a paper about Ganak (paper here) but to be honest, it only covers a very small ground of what we did. The change to Ganak between the original paper in 2019 to today is about 30'000 lines of code. Obviously, that cannot be explained in detail in just a few pages. Furthermore, the way academic publishing works, it\u0026rsquo;s not possible to simply list a bunch of ideas that were implemented \u0026ndash; you need to explain everything in detail, which cannot be done with 30'000 lines of code. So, below is a bit of an \u0026ldquo;idea dump\u0026rdquo; that I have implemented in Ganak, but never published.\nI might attempt at publishing some of them some day. Currently, I see little reward for doing so besides citations, and citations are not a great indicator in my view: lcamtuf is one of the best IT security professionals, ever, and has basically no citations. Besides, due to the \u0026ldquo;publish or perish\u0026rdquo; system in academia, there is a sea of research papers that most work gets lost in. I believe what matters most is performance and usability. Ganak does pretty well in this regard. It compiles to many platforms: Linux, Mac, both ARM and x86, and even emscripten in your browser. It supports more weight systems than other counters: integers, floats, exact rationals, complex numbers, primes, and multivariate polynomials over the rationals and floats. Ganak also uses less memory than other competing counters, while running faster. Besides, it\u0026rsquo;s regularly fuzzed and leaks no memory, so its output is rather trustworthy.\nWithout further ado, here are some ideas never published in Ganak, but which help the system run faster:\nUsing and improving the Oracle SAT Solver Korhonen and Jarvisalo (PDF by the authors). Oracle is a specialised SAT solver that allows one to query with many so-called \u0026ldquo;assumptions\u0026rdquo; in the SAT query, i.e. checking if something is satisfiable under conditions such as \u0026ldquo;a=true, b=false\u0026rdquo; \u0026ndash; but many-many of them. This kind of query is very slow if you use a normal SAT solver, but with Oracle, it\u0026rsquo;s super-fast. This allows us to remove unneeded constraints, and make the constraints smaller. I improved this tool in a few ways, mostly by integrating a local search solver into it, that can drastically speed it up, by finding a satisfying solution much faster. I have also improved its heuristics, e.g. by using a better LBD heuristic (PDF by authors). I have also improved its solution cache, by employing cache performance tracking, pre-filtering, and cache size limitation. Besides, I added a step-tracking to it so it can be deterministically limited in time. Improved version of tree decomposition originally by Korhonen and Jarvisalo (PDF here). This system computes the tree decomposition of a CNF via Flow-Cutter by Ben Strasser (PDF, code), however, the original system had a few issues. Firstly, it did a clock-limited run of the executable, which was unacceptable to me, as it makes the system non-deterministic: depending on the CPU it will run faster/slower thereby computing different values (it\u0026rsquo;s a local search algorithm, with many restarts). Also, running separate executables is very fragile. Secondly, and more importantly, it computed the tree decomposition of a CNF and then tried to find its centroid. But\u0026hellip; what if the CNF was disjoint? What\u0026rsquo;s the single centroid of a forest? Slight issue. I fixed this by computing the top-level disjoint components and counting them separately. Although disjoint components sound really like an input issue, and not a counter issue, the problem is that our preprocessing is so strong that it can make a non-disjoint input into a disjoint input, thereby confusing the TD/centroid finding. Ooops. Special-casing some inputs. Because we detect disjoint top-level components, sometimes we end up with CNFs that are very weird, for example, with a sampling set size of 2. These CNFs can only have at most 4 solutions, so counting them via the incredibly complicated d-DNNF system is an overkill, likely to waste a lot of time via the start-up and tear-down. Hence, these CNFs are counted one-by-one via the trivial use of a standard SAT solver. Using CCNR by Shaowei Cai (PDF by authors) for speeding up the Oracle query. It\u0026rsquo;s a cool local search system, and it works really well. I wish I had fixed up its code because it\u0026rsquo;s a bit clunky and my colleagues gave me a hard time for it. Not research colleagues, of course. In research, quality of code is irrelevant \u0026ndash; remember, only the number of citations matters. Adapting Vivification by Li et al. (PDF paper) to the model counting setting. The original system stops the SAT solver once when the solver restarts, rewrites all the clauses to be shorter when possible, and continues happily every after. This happily ever after is impossible in a model counting setting, because we never restart. Slight issue. What I wrote was basically a nightmare-fuelled 2-week, probably about ~2000 line craziness that rewrites the propagation tree and/or avoids the clause improvement, so that all the invariants of the propagation remain intact while the clauses get shorter. This is kind of like changing the wheels on a car while it\u0026rsquo;s running. I don\u0026rsquo;t recommend doing this without extremely thorough fuzzing and debug tooling in place, or you\u0026rsquo;ll run into a lot of trouble. (By the way, this system not only contracts clauses, but also performs subsumption \u0026ndash; if I have built the system, I might as well use it all the way) Using an virtual interface for the Field we are counting over. With this system, the Field we are counting over becomes irrelevant for the counter. Instead, the counter can focus on counting, and the implementation of the interface can focus on the Field-specific operations. This has allowed me to add many-many Fields with very little overhead. The Field parses, prints, and handles the 0, and 1 points, and the + and * operators. This separation of concerns is I think the right way to go. Also, it allows someone to implement their own Field and use it without having to recompile anything. Zero-suppressed Field counting. When counting over a field, there are two special elements one needs to take care of: zero and one. Of this, the zero is quite special, because a+0=a, and a*0=0. So, in Ganak, we don\u0026rsquo;t initialise the zero field element. Instead, we keep it as a null pointer. When manipulating this pointer, like adding or multiplying, we can simply replace it with a copy of what we add to it, or, when multiplying, keep it a null pointer. This saves space and also reduces the number of pointer dereferences we need to perform. Extensive fuzzing infrastructure by Latour et al (code), with ideas taken from Niemetz at al (PDF here). Ganak and Arjun both have many options that allow the fuzzer to turn off certain parts of the system, or push them to the extreme, thereby exercising parts of them that would otherwise be impossible to reach. The paper I linked to explains how adding the options to the fuzzer, and setting them to all sorts of values, can help the fuzzer reach very hard-to-reach parts of the code, thereby exposing bugs in them easier. Extensive debug infrastructure. Finding issues via fuzzing is only part of the deal, one must also be able to debug them. For this, Ganak has a 4-level debug system where progressively slower self-checking can be turned on so as to find the first place where the bug manifests itself as precisely as possible. The last level of debug checks every single node in the d-DNNF that Ganak builds, and exits out on the first node that the count is incorrect. The debug infrastructure also comes with a verbosity option that prints out full, human readable, structured, coloured logs for each major decision point in the d-DNNF. Overall, just the debug code of Ganak is likely 2-3 thousand lines of code. This may sound excessive, but Ganak can self-check its state at every node, and ensure that there is at least a path forward to counting the correct count, at almost all nodes. Apparently some have attempted to do what we did in our paper on Ganak, but bumped into issues they couldn\u0026rsquo;t resolve. I can confirm that without the appropriate fuzz and debug infrastructure, it would have been impossible for us to figure the things out we published in that paper. Cache-optimised, lazy component finding. When a decision and propagation happens in the CNF, we must check whether the system has fallen into disjoint components. If so, we can count the components separately, and then multiply their counts \u0026ndash; a property of a Field. This greatly helps in doing a lot less work. However, this means we must examine every single variable in the system, and see if it\u0026rsquo;s connected to the others through clauses at every node \u0026ndash; often millions, or even 100s of millions of times during counting. Normally, d-DNNF counters do this by going through all the so-called occurrence list of all variables, recursively, and see if they encounter all variables. The issue with this is that it is extremely expensive, up to 50% of the total runtime, and furthermore, it re-examines parts of the clauses that were not touched by the newly set variables. However, it\u0026rsquo;s not easy to fix this: doing something very smart to a system that is very fast but dumb can slow down the system, since the smart thing can often take more time to compute than doing the dumb thing fast. So I pulled an old trick out of a hat, one that I learned from a paper by Heule et al.: time stamping. Basically, you keep a time stamp for each data element you touched, and as long as you can decide cheaply that you don\u0026rsquo;t need to recompute something based on the timestamp, you are good. We keep stamping each variable when its value is changed, and then we know what parts of the clauses need to be re-examined, based on the stamp on the clause and the stamp on the variable. I implemented this in a cache-optimized way, similarly how SharpSAT does it, laying it all out flat in the memory, putting clauses next to each other that will be dereferenced after one another \u0026ndash; a trick I learned form MiniSat. Prefetching of watchlists, and using blocked literals. Prefetching of watchlists is one of the very few things in SAT solving that was my idea. Basically, whenever a literal is set, its watchlist will be examined shortly. Hence, we can prefetch the watchslit the moment the literal is assigned, so as to prevent the CPU from stalling when the literal\u0026rsquo;s watchlist is invariably examined. This prefetching can be extended to the component finding, except there it\u0026rsquo;s occurrence lists and not watchlists. Secondly, I added blocked literals, another cache-optimising trick, by Chu et al (paper). Blocked literals are widely used by modern SAT solvers. SharpSAT missed it because it was written before this trick was known, so I added it in. Recursive Conflict Clause Minimisation by Sörensson and Biere (paper). This was a trivial lift-and-shift from the MiniSat source code. There\u0026rsquo;s nothing much to say here other than it\u0026rsquo;s pretty well-known thing, but was not known at the time of SharpSAT. I believe there is nowadays a much better system by Fleury and Biere that does efficient all-UIP minimisation (paper). If you wanna lift-and-shit that code into Ganak and win the model counting competition, be my guest \u0026ndash; all Ganak is always open source and online at all points in time, I have no energy to hide code. Tight monitoring and management of memory usage. One of the first things you will notice with some model counters is that they eat all the RAM you have and then get killed by the kernel for lack of memory. This is unfortunately encouraged by the model counting competition guidelines which give massive amounts of memory, up to 64GB, to use by the counters. However, when you are testing your counter, almost all cluster systems have approx 4GB of memory per core (or less) in their nodes. The cluster I use has 160 cores per node and each node has 768GB of RAM, giving 4.8GB/core. Hence, if I want to test my counter without wasting resources, it should use at most 4.8GB of memory. Since I wanted to win the model counting competition, and for that I needed to test my system a lot, I optimised the system to use about 4.5GB memory at most. This is approx 10x less than what many other counters use. The way I did this is by (1) making sure no memory is leaked, ever, (2) precisely accounting for all memory usage and (3) deleting cache items that are occupying too much memory, ruthlessly. This required a using the valgrind memory leak detector, and a lot of use of valgrind\u0026rsquo;s massif heap profiler for many different types of inputs. This ensured that Ganak uses only the required amount of memory, and can safely and efficiently run in memory-constrained environments. In fact, Ganak would have won all tracks in both previous model counting competitions with only 1/10th of the allowed memory use (i.e. 6.4GB instead of 64GB). A few more things that I can barely remember. For example, watchlists or clauses(?) were reverse-visited. Binary clauses were in the same watchlists as the normal clauses, but they can use a specialised watchlist and be visited faster. Clauses were removed from the watchlist using the \u0026ldquo;switch-to-the-end\u0026rdquo; trick which has been shown to be less efficient than simply overwriting. The original Ganak allocated memory for the component, hashed it, then deallocated the memory, but it could have called the hash in-situ, without the allocation, copy, and de-allocation. The original Ganak also used a hash function that was optimised to hash very large inputs, which made it impossible to compile to emscripten due to the CPU intrinsics used, and besides, it was unnecessary because it only had to hash a few KB at most. So I switched to chibihash64 by nrk. The above took about 3-4 years of work, on-and-off, since I don\u0026rsquo;t normally get paid to do research. The total time I worked on Ganak being paid to do it was about 4-5 months. So it was mostly just passion and having some fun. The code at least is not absolutely unreadable, and there are a lot of seatbelts around, about 5-10% of the code is asserts, and there are entire sets of functions written solely to do self-checking, debug reporting, etc.\nI will likely not publish any of the above ideas/improvements. Some are, I think, publishable, for example the the vivification, but especially that code is nightmare-inducing to me. The fuzzing and debugging while important to me, as I am interested in tools that work, is hard to publish and not too novel. Memory management again falls into this weird place where it\u0026rsquo;s not very novel but necessary for usable tools. Supporting many fields is just a basic requirement for a well-functioning system, besides, it\u0026rsquo;s super-easy to do, if set up right. The rest is just basic copy-paste with minor adjustment. I think the use of CCNR is actually quite fun, but I hardly think it\u0026rsquo;s worth a paper. It\u0026rsquo;s shaving 30-40% time off of a very slow-running (but necessary) part of the preprocessor, and I was very happy when I discovered it.\nI hope you appreciated this somewhat long list. The code can of course be examined for all of them, and you can lift-and-shift some/all the ideas into other tools and other systems. I left quite a lot of comments, and if you turn on VERBOSE_DEBUG and set verbosity very high (say, \u0026ldquo;\u0026ndash;verb 100\u0026rdquo;) you should be able to see how all of them work in tandem.\n","permalink":"https://www.msoos.org/2026/03/ganak-the-making-of-a-versatile-high-performance-model-counter/","summary":"\u003cp\u003eGanak (\u003ca href=\"https://github.com/meelgroup/ganak\"\u003egithub\u003c/a\u003e), our propositional model counter, has won every single model counting competition track for the past two years. Perhaps it\u0026rsquo;s time to explain how that came about, and what are the ingredients of such a tool. Firstly, a propositional model counter is a tool that counts how many solutions there are to a set of boolean constraints of the form:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ea V b\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eb V -c\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eThis set of constraints has the following possible solutions:\u003c/p\u003e","title":"Ganak: The Making of a Versatile, High Performance Model Counter"},{"content":"Finally, after many months of waiting for our paper to be accepted (preliminary PDF here), Ganak2 is finally released (GitHub code, released binaries) and easily accessible and modifiable. I wish this release had come earlier, but double-blind requirements didn\u0026rsquo;t allow us to release the code any sooner.\nBasically, Ganakv2 has been re-written in many ways. Some of the original ideas by Thurley for SharpSAT has been kept alive, but many-many things are completely different and completely re-written \u0026ndash; well over 10'000 lines of change in total. This set of changes has allowed Ganak2 to win every available track at the Model Counting Competition of 2024. In other words, Ganak2 is incredibly fast, making it a state-of-the-art tool.\nChonological Backtracking, Enhanced SAT solving, S- and D-sets The new Ganak has a pretty powerful SAT solver engine with its own restart strategy, polarity and variable branching strategy. This SAT solver is tightly integrated into Ganak, and reuses the same datastructures a Ganak, hence the counter/SAT transitions are smooth. This relies on the observation that once every variable in the (minimal) independent set has been assigned, there is at most one solution, so we can just run a SAT solver, there is no need to a full-blown model counter. This idea has existed at least since GPMC, but we improved on it in important ways.\nA very complicated but very important aspect of Ganak2 is our integration of Chronological Backtracking which we adopted to the model counting setting. This required a lot of attention to detail, and in order to debug this, we took full advantage of the fuzzer written and maintained by Anna Latour. We further added very serious and thorough checking into Ganak2, with varying levels of internal checking and per-node checking of counts. This allows to perform effective debugging: the first node that the count is incorrect will immediately stop and error-out, along with a full human-readable debug log of what had happened. This was necessary to do, as some of the issues that Chonological Backtracking leads to are highly non-trivial, as mentioned in the paper.\nGanak2 now understands something we call a D-set, which is a set of variables that\u0026rsquo;s potentially much larger than the projection set but when branched on, the count is the same. This allows Ganak to branch on far more variables than any other current model counter. We run an algorithm that takes advantage of Padoa\u0026rsquo;s theorem to make this D-set as large as possible. Further, Ganak2 takes advantage of projection set minimization, calling he minimal set an S-set, and running a SAT solver as soon as all variables from the S-set have been decided. This allows us to run a SAT solver much earlier than any other model counter.\nComponent Discovery, Subsumption and Strengthening, and Counting over any Field Since the paper, I have also added a number of pretty interesting improvements, especially related to component generation, which is now a highly cache-optimized datastructure, using time stamping, a trick I learned from Heule et al\u0026rsquo;s brilliant tree-based lookahead paper (worth a read). I also changed the hash function used to chibihash, it\u0026rsquo;s not only faster (on the small inputs we run it on) but also doesn\u0026rsquo;t rely on any specific instruction set, so it can be compiled to emscripten, and so Ganak2 can run in your browser.\nThere is also a pretty experimental on-the-fly subsumption and strengthening that I do. It actually rewrites the whole search tree in order to achieve this, which is a lot harder to do than I imagined. It\u0026rsquo;s the most trivial subsumption \u0026amp; strengthening code you can imagine, but then the rewriting is hell on earth. However, the rewriting is necessary in case we want to be able to continue counting without restarting the whole counting process.\nGanak, unlike many of its counterparts, also manages memory very tightly and tries not to die due to memory-out. The target memory usage of the cache can be given via \u0026ndash;maxcache in MB. A cache size of 2500MB is default, which should cap out at about 4GB total memory usage. More cache should lead to better performance, but we actually won (every available track of) the Model Counting Competition 2024 with rather low memory usage, I think I restricted it to 8-12GB \u0026ndash; other competitors ran with ~2x that.\nFurthermore, Arjun, our CNF minimizer has also been tuned. While this is not specifically Ganak, it gives a nice improvement, and has some cool ideas that I am pretty happy about. In particular, it runs the whole preprocessing twice, and it incorporates Armin Biere\u0026rsquo;s CadiBack for backbone detection. I wish I could improve this system a bit, because sometimes CadiBack takes \u0026gt;1000s to run, but without it, it\u0026rsquo;s even slower to count in most cases. But not always, and sometimes backbone is just a waste of time.\nThe system also now allows to use any field, all you need to do is implement the +/-/*/div operators and the 0 and 1 constants. I have implemented integers, rationals, modulo prime counting, and counting over a the field of polynomials with rational coefficients. All you need to do is override the Field and FieldGen interfaces. I made it work for modulo prime counting in under 20 minutes, it\u0026rsquo;s like 30 lines of code.\nFloating Point Numbers Notice that floating point numbers don\u0026rsquo;t form a field, because 0.3+(0.2+0.1) is not equal to (0.3+0.2)+0.1, i.e. it\u0026rsquo;s not associative (\u0026ndash; thanks to Martin Hořeňovský for this correction, previously I said \u0026ldquo;commutative\u0026rdquo;). Actually, Ganak2\u0026rsquo;s weighted model counting doesn\u0026rsquo;t currently support floating point numbers, because it doesn\u0026rsquo;t need to \u0026ndash; we won literally every available track with infinite rational numbers: 0.3 is simply interpreted as 3/10. This sounds minor, but it also means that it\u0026rsquo;s actually trivial to check if Ganak runs correctly \u0026ndash; it simply needs to be run with a different configuration and it should produce the same solution. Notice that this is not at all true for any other weighted model counter. Literally all of them, except for Ganak, will give different solutions if ran with different seeds. Which is hilarious, since there is obviously only one correct solution. But since 0.3+(0.2+0.1) is not equal to (0.3+0.2)+0.1 in floating point, they can\u0026rsquo;t do anything\u0026hellip; rational.\nThis whole floating point saga is actually quite annoying, as it also means we can\u0026rsquo;t check Ganak against any other counter \u0026ndash; at least not easily. All other counters give wrong answers, given that floating point is incorrect, and so we can only compare Ganak2 to other counters if we allow a certain deviation. Which is pretty hilarious, given that counters all claim to use \u0026ldquo;infinite precision\u0026rdquo;. In fact, the only thing infinite about their results is likely the error. Since (0.3+(0.2+0.1)) - ((0.3+0.2)+0.1) is not 0, it is actually possible to have theoretically infinite error in case of negative weights.\nApproximate Counting and Ganak Ganak2 incorporates ApproxMC, and can seamlessly transition into counting via approximate model counting methods. To do this, simply pass the \u0026ldquo;\u0026ndash;appmct T\u0026rdquo; flag, where T is the number of seconds after which Ganak will start counting in approximate mode. This can only be done for unweighted counting, as ApproxMC can only do unweighted counting. However, this seamless transition is very interesting to watch, and demonstrates that using a multi-modal counting framework, i.e. exact+approximate is a very viable strategy.\nWhat happens under the hood is currently unpublished, but basically, we stop the exact counting, check how much we have counted so far, subtract that from the formula, and pass it to ApproxMC. We then get the result from ApproxMC and add the partial count that Ganak counted, and display the result to the user. So the final count is partially approximate, and partially exact, so we actually give better approximation (epsilon and delta) guarantees than what we promise.\nCompiling Ganak The new Ganak incorporates 8 libraries: GNU MP, CryptoMiniSat, Arjun, ApproxMC, SBVA, CadiCal, CadiBack, and BreakID. Furthermore, it and compiles in (optinally) BuDDy, Oracle (from Korhonen and Jarvisalo) and Flowcutter. These are all individually mentioned and printed to the console when running. However, this means that building Ganak is not trivial. Hence, with the very generous help of Noa Aarts, Ganak has a flake nix, so you can simply:\ngit clone https://github.com/meelgroup/ganak cd ganak nix-shell And it will reproducibly build Ganak and make it available in the path. All this needs is for one to have installed Nix, which is a single-liner and works incredibly reliably. Otherwise, the Ganak repository can be cloned together with its GitHub Actions, and then each push to the repository will build Ganak2 for 4 different architectures: Linux x86\u0026amp;ARM, Mac x86\u0026amp;ARM.\nSubmit your Version of Ganak to the 2025 Competition Ganak2 is highly extensible/modifiable. I strongly encourage you to extend/change/improve it and submit your improvement to the Model Counting Competition of 2025. Deadline is in 3 weeks, it\u0026rsquo;s time to get your idea into Ganak and win. I promise I will have all my changes publicly available until then, and you can literally submit the same thing I will, if you like. I\u0026rsquo;d prefer if you put in some cool change, though.\n","permalink":"https://www.msoos.org/2025/05/ganakv2-released/","summary":"\u003cp\u003eFinally, after many months of waiting for our paper to be accepted (preliminary \u003ca href=\"/wordpress/wp-content/uploads/2025/05/ganak2.pdf\"\u003ePDF here\u003c/a\u003e), Ganak2 is finally released (\u003ca href=\"https://github.com/meelgroup/ganak/\"\u003eGitHub code,\u003c/a\u003e released \u003ca href=\"https://github.com/meelgroup/ganak/releases/latest\"\u003ebinaries\u003c/a\u003e) and easily accessible and modifiable. I wish this release had come earlier, but double-blind requirements didn\u0026rsquo;t allow us to release the code any sooner.\u003c/p\u003e\n\u003cp\u003eBasically, Ganakv2 has been re-written in many ways. Some of the original ideas by Thurley for SharpSAT has been kept alive, but many-many things are completely different and completely re-written \u0026ndash; well over 10'000 lines of change in total. This set of changes has allowed Ganak2 to \u003ca href=\"https://mccompetition.org/assets/files/2024/MC2024_awards.pdf\"\u003ewin every available track\u003c/a\u003e at the Model Counting Competition of 2024. In other words, Ganak2 is incredibly fast, making it a state-of-the-art tool.\u003c/p\u003e","title":"Ganakv2 Released"},{"content":"Imagine you are super-excited about some new technology that\u0026rsquo;s enabled by the internet, say, Google, and instead of investing in Google, i.e. buying Google stock, you start buying AT\u0026amp;T stock. Or let\u0026rsquo;s say Facebook just came out, and it\u0026rsquo;s the hottest thing. Everyone wants Facebook. So instead of investing in Facebook stock, you start buying AT\u0026amp;T stock. It\u0026rsquo;d be just weird, right? But that\u0026rsquo;s what seems to be happening in the crypto space.\nThe more I spend in this space, the more I\u0026rsquo;m baffled by people buying and holding ETH, the native currency of Ethereum, hoping that if the next Facebook comes around, the value of ETH will go up. And to be fair, AT\u0026amp;T and Cisco stock probably did go up when Netflix became popular. But ultimately, AT\u0026amp;T, Cisco, T-mobile \u0026ndash; they are just the underlying pipes. Sure enough, Cisco should go up somewhat when Netflix is becoming popular, because you definitely need routers to watch Netflix. But we all understand that the Internet is just the piping.\nThis is reminiscent of AOL. Back in the dark ages of the Internet, AOL was \u0026ldquo;the\u0026rdquo; internet, it provided all the services in one place. From directory to mail services. If you wanted to invest in the internet, you bought AOL stock. But that\u0026rsquo;s no longer the case, and for a good reason.\nElectricity, the Internet, and Infrastructure Electricity plug designed to fit into a socket for light bulbs\nI think most people would find it rather insane to buy electricity suppliers\u0026rsquo; stocks when a new type of home appliance, say robot vacuums come around. However, electricity stocks were a big deal back in the day. The original use-case for electricity at home was light bulbs. Light bulbs were huge \u0026ndash; lighting was expensive (you had to get candles or oil) and was painful to light up, and sometimes it burned down buildings. In fact, the original washing machines\u0026rsquo; electric plugs actually plugged into a socket for light bulbs! You had to screw it in \u0026ndash; and unscrew it in case there was an accident. Which was very-very dangerous, hence the new sockets that are very easy to unplug. But it\u0026rsquo;s interesting to observe that there was an original use-case, and it was so popular that \u0026ldquo;electricity\u0026quot;just straight up meant light bulbs, and nothing else.\nThe original use-case of cryptocurrencies was liquid, fast transfer of fungible value over the network without a central system. But we moved way beyond that now. We have currencies and banks operating over Ethereum. We have casinos and online games and betting platforms. We have exchanges and brokers. However, somehow people still hope that the infrastructure value will go up.\nHoping your AT\u0026amp;T bill goes up Imagine buying a monthly internet subscription from AT\u0026amp;T and hoping that the subscription costs go up. That\u0026rsquo;s what\u0026rsquo;s happening in crypto. The native currency of Ethereum is used to regulate the transactions on the chain, so that the competition of which transaction makes it into the chain can be decided. When you hold ETH, you are effectively hoping that transaction costs go up. It\u0026rsquo;s like hoping that your AT\u0026amp;T bill gets higher. Who the hell would want that? It\u0026rsquo;s infrastructure cost, it\u0026rsquo;s not supposed to go up over time. It\u0026rsquo;s supposed to go down.\nThe secondary use-case of ETH is the consensus protocol, making sure the things that do make it into the transaction block are what one would more or less expect. So it\u0026rsquo;s used to also secure the chain in a manner that\u0026rsquo;s called Proof-of-Stake. Here, the value of ETH is used to make sure it\u0026rsquo;s not economically viable to cheat. However, it wouldn\u0026rsquo;t be too difficult to move staking to stablecoins such as Dai, or other value-holders, e.g. a combination of the most used systems on the chain. After all, it\u0026rsquo;s in everyone\u0026rsquo;s best interest for the most value-generating systems to survive.\nBetting on success In my view, if you want to bet on the crypto system to be successful, you need to start betting on not only ETH, but much more importantly all the systems that make Ethereum useful. Looking at e.g. a DeFi token list is a good start. Ultimately, the internet is not useful because of AT\u0026amp;T. It\u0026rsquo;s useful because of email, websites, and online systems such as Ethereum itself, which wouldn\u0026rsquo;t exist without the Internet. Yet I\u0026rsquo;m pretty sure ETH holders are not in a rush to buy AT\u0026amp;T stock. In the same vain, they should not be in a rush to buy ETH. Rather, they should be investing in all the systems and tools built on top of Ethereum. Ethereum is \u0026ldquo;just\u0026rdquo; the infrastructure, similarly how the internet on which Ethereum runs, is \u0026ldquo;just\u0026rdquo; the infrastructure, which itself is built on electricity, which is \u0026ldquo;just\u0026rdquo; the infrastructure. Sure, we need the infrastructure. And we need to invest in the infrastructure (I have a separate rant on how little is actually being invested by anyone other than the Ethereum Foundation). But only investing in the infrastructure, and not on the systems built on top of it, is weird.\nPost Scriptum: Bitcoin Bitcoin is forever stuck at being electricity for light bulbs only. Make of that what you will. Light bulbs are useful, of course. But I\u0026rsquo;m typing this on a computer, that\u0026rsquo;s connected to the internet, and my light bulbs are not even on. If electricity was only capable of lighting the light bulb, and not powering my computer, my router, and the system of routers that route my packets to you, we would still be writing\u0026amp;reading articles in physical newspapers, and sending mail via physical post.\nReferences You may be interested in this article and this tweet thread for ideas and thoughts that others had independently, but well before me. Thanks to M. at the EF for these references, they are actually really relevant. I\u0026rsquo;m glad others are seeing things similarly to me.\n","permalink":"https://www.msoos.org/2025/03/ethereum-in-the-age-of-aol/","summary":"\u003cp\u003eImagine you are super-excited about some new technology that\u0026rsquo;s enabled by the internet, say, Google, and instead of investing in Google, i.e. buying Google stock, you start buying AT\u0026amp;T stock. Or let\u0026rsquo;s say Facebook just came out, and it\u0026rsquo;s the hottest thing. Everyone wants Facebook. So instead of investing in Facebook stock, you start buying AT\u0026amp;T stock. It\u0026rsquo;d be just weird, right? But that\u0026rsquo;s what seems to be happening in the crypto space.\u003c/p\u003e","title":"Ethereum in the age of AOL"},{"content":"Probabilities of certain events are really hard to estimate sometimes. Often, it\u0026rsquo;s because we lack information of the underlying causal chains, but sometimes, it\u0026rsquo;s because the causes are so intertwined that even if we know the underlying probabilities of certain events happening along with the causal chains, it\u0026rsquo;s still impossible for us to untangle the web.\nLet\u0026rsquo;s say there\u0026rsquo;s an event X has a probability of 0.4, Y has a probability of 0.6, and Z happens if either X or Y happens, but X and Y can\u0026rsquo;t happen at the same time, with a probability of 0.8. What\u0026rsquo;s the probability of Z happening?\n0.4 0.6 ┌───────┐ ┌───────┐ │ │ 0.8 │ │ │ X │◄────!─────►│ Y │ │ │ │ │ └──┬────┘ └────┬──┘ │ │ │ ┌───────┐ │ │ │ │ │ └─────►│ Z │◄──────┘ │ │ └───────┘ Translating to a Model Counting Problem The solution is easy to compute if you know how to use propositional model counters. They allow you to create a set of rules, such as:\nX = 0.4 Y = 0.6 X or Y = True 0.8 -\u0026gt; NOT (X \u0026amp; Y) The above perfectly describes the probability landscape, by using \u0026ldquo;-\u0026gt;\u0026rdquo;, i.e. implication (if the left side is true, the right side must also be true), and using \u0026ldquo;\u0026amp;\u0026rdquo; (i.e. logical AND). Basically, for Z to happen, X or Y has to happen. And with probability 0.8, they must not happen at the same time. To solve the above, we add a helper variable H1, that will allow us to translate the last equation into an implication:\nX = 0.4 Y = 0.6 X or Y = True H1 = 0.8 H1 -\u0026gt; NOT (X \u0026amp; Y) To translate this to propositional model counting, we can do the following, where \u0026ldquo;-\u0026rdquo; is negation:\nweight X = 0.4 weight Y = 0.6 weight H1 = 0.8 X or Y = True -H1 or -X or -Y = True The highlighted lines are what\u0026rsquo;s call the Tseitin transformation, which basically means that when H1 is TRUE, (NOT X or NOT y) must be TRUE, i.e. at least one of them has to be FALSE, i.e. they can\u0026rsquo;t happen at the same time (but it\u0026rsquo;s possible that neither of them happens). The above is what\u0026rsquo;s called a conjunctive normal form, or CNF for short.\nThe model counting DIMACS representation (formal description here) of the above is:\nc t pwmc p cnf 3 2 c comment X = 1, Y = 2, H1 = 3 c p weight 1 0.4 0 c p weight 2 0.6 0 c p weight 3 0.8 0 1 2 0 -3 -1 -2 0 c p show 1 2 3 0 Which is a straightforward 1-to-1 translation of the above, except we have to tell the counter that this is a projected weighted model counting problem (\u0026ldquo;pwmc\u0026rdquo;) and that it has 3 variables, and 2 constraints (\u0026ldquo;p cnf 3 2\u0026rdquo;).\nSolving with a Model Counter Once you have a CNF representation, you can run a modern propositional weighted model counter to count the number of weighted solutions, i.e. the probability of Z. I recommend the one I develop, ganak (linux binary here, open source code will be available soon, ask me if you need it):\n./ganak problem.cnf c s type pwmc s SATISFIABLE c s exact arb float 5.68E-01 So Z has a probability of 0.568. This can easily be verified to be correct:\nPython 3.13.1 \u0026gt;\u0026gt;\u0026gt; 0.6*(1-.4)+0.4*(1-0.6)+0.4*0.6*(1-0.8) 0.568 Which adds up the probabilities that the left fires (but not the right), the right fires (but not the left), and that both fire, but the conflict does not happen (with 1-0.8 probability).\nOf course, the above is a rather simple problem. However, with the above steps, one can create arbitrarily complicated causal chains, with complex constraints between partial, or intermediate elements of the chain, conditional probabilities, etc. Although there are limits to scalability, it\u0026rsquo;s many-many orders of magnitude faster than anything by hand, or by some form of brute-force checking/estimation.\nUse-cases In certain scenarios, it\u0026rsquo;s really important to know what the probability of some event is. For example, if you want to run a hazardous process such as a nuclear reactor or a chemical plant, or you want to provide insurance for some complicated (financial) product, accurately computing the probabilities of bad events happening is extremely important. I think it\u0026rsquo;s rather obvious that nuclear plants have very complicated causal chains for bad events happening \u0026ndash; and they tend to be intertwined. If the external power lines are damaged, then likely it\u0026rsquo;s a major event (e.g. earthquake) and you likely also lost the majority of your transport capabilities, and along them, much of potential external help.\nSimilarly, if you want to bet for/against market moves, where you know or have a good idea of the underlying causal chains and associated probabilities, you can build quant trading, or expert advice systems based on the above. In other words, weighted model counting is not only useful for party tricks. Complex probability chains with thousands of interdependent random variables can easily be analyzed using the above system.\n","permalink":"https://www.msoos.org/2025/02/computing-tricky-probabilities/","summary":"\u003cp\u003eProbabilities of certain events are really hard to estimate sometimes. Often, it\u0026rsquo;s because we lack information of the underlying causal chains, but sometimes, it\u0026rsquo;s because the causes are so intertwined that even if we know the underlying probabilities of certain events happening along with the causal chains, it\u0026rsquo;s still impossible for us to untangle the web.\u003c/p\u003e\n\u003cp\u003eLet\u0026rsquo;s say there\u0026rsquo;s an event X has a probability of 0.4, Y has a probability of 0.6, and Z happens if either X or Y happens, but X and Y can\u0026rsquo;t happen at the same time, with a probability of 0.8. What\u0026rsquo;s the probability of Z happening?\u003c/p\u003e","title":"Computing Tricky Probabilities"},{"content":"The Internet is a pretty vast place. So I decided to curate a few links for you all for this special end-of-year period:\nhttps://vimeo.com/41786246 A film about\u0026hellip; a couch. That balances on a single leg. And sometimes falls, and falls apart, but with some care, and compassion, can be pieced back together. https://www.theparisreview.org/blog/2017/02/15/rhythmical-lines/ An article on unbroken lines, drawn by Wacław Szpakowski, who did it as a form of doodling. http://astronaut.io/ This website is an art piece about the world, I think, made of small, randomly selected videos. https://interfacecritique.net/book/olia-lialina-from-my-to-me/ An article about the old internet, and why we should have and cultivate our own space on the interwebs. By one of my favourite aritsts, Olia Lialina https://www.theparisreview.org/blog/2014/07/28/working-on-my-novel/ About a book that is made of a set of tweets that contains the phrase \u0026ldquo;working on my novel.\u0026rdquo; A surreal experience. https://www.marxists.org/archive/brecht/works/1935/questions.htm A short poem by Bertold Brecht about who did what, questioning why we only remember those in power. https://www.newyorker.com/magazine/2016/08/29/michael-heizers-city About a land art piece by Michael Heizer, who is both a genius and is also rather crazy. His other work, Double Negative is truly beautiful (it\u0026rsquo;s literally a hole in the desert, but a beautiful hole, the best hole, and I mean it) https://publicdelivery.org/agnes-denes-wheatfield/ About a large wheat field, in the middle of Manhattan, that Ágnes Dénes sowed and then harvested, right in the view of the World Trade Center. https://www.africavernaculararchitecture.com/ A classic 90s website about vernacular architecture in Africa. Some amazingly beautiful houses, built for the people, by the people, to live in. Click on a country and enjoy. https://vimeo.com/58444378 A mockumentary about a guy making music, caring for his father, trying to enjoy life, and remembering the things that didn\u0026rsquo;t work out, which he likens to Mount Everest, his Whateverest. https://www.vincentmoon.com/map/ The map of places where Vincent Moon recorded traditional music preformed by locals. Here is one for a taster. If you listen patiently, with intent, you might find that there\u0026rsquo;s a lot of beautiful music out there. https://www.ryojiikeda.com/project/testpattern/ A set of test patterns, projected over a large space, that allows people to lay down, walk around, and explore. To be coupled with his strange but fascinating noise music. I went to his concert, it\u0026rsquo;s exactly as weird as you\u0026rsquo;d imagine. He never said hello, goodbye, or left any space to clap. https://whatever.scalzi.com/2005/09/03/being-poor/ What it means to be poor by Scalzi. Watch out for the comment by her own sister. Back in the days of the interwebs when comments added value. The Marion Stokes Project, with its transcript in a more accessible form. https://www.tate.org.uk/tate-etc/issue-10-summer-2007/excremental-value An article about my favourite artwork, Manzoni\u0026rsquo;s Merda d\u0026rsquo;Artista. In 1961 he put his own excrement into 90 small cans and sold them at the price of gold ($37/ounce). Over the years, it has outperformed gold by a factor of 70x. The guy with the banana stuck to the wall is a mere imitator by comparison (and 60 years late) Ágnes Dénes – Wheatfield – A Confrontation, 1982, Battery Park Landfill, Downtown Manhattan, photo: John McGrall\n","permalink":"https://www.msoos.org/2024/12/some-food-for-thought-great-content-on-the-internet/","summary":"\u003cp\u003eThe Internet is a pretty vast place. So I decided to curate a few links for you all for this special end-of-year period:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://vimeo.com/41786246\"\u003ehttps://vimeo.com/41786246\u003c/a\u003e A film about\u0026hellip; a couch. That balances on a single leg. And sometimes falls, and falls apart, but with some care, and compassion, can be pieced back together.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.theparisreview.org/blog/2017/02/15/rhythmical-lines/\"\u003ehttps://www.theparisreview.org/blog/2017/02/15/rhythmical-lines/\u003c/a\u003e An article on unbroken lines, drawn by Wacław Szpakowski, who did it as a form of doodling.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://astronaut.io/\"\u003ehttp://astronaut.io/\u003c/a\u003e This website is an art piece about the world, I think, made of small, randomly selected videos.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://interfacecritique.net/book/olia-lialina-from-my-to-me/\"\u003ehttps://interfacecritique.net/book/olia-lialina-from-my-to-me/\u003c/a\u003e An article about the old internet, and why we should have and cultivate our own space on the interwebs. By one of my favourite aritsts, Olia Lialina\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.theparisreview.org/blog/2014/07/28/working-on-my-novel/\"\u003ehttps://www.theparisreview.org/blog/2014/07/28/working-on-my-novel/\u003c/a\u003e About a book that is made of a set of tweets that contains the phrase \u0026ldquo;working on my novel.\u0026rdquo; A surreal experience.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.marxists.org/archive/brecht/works/1935/questions.htm\"\u003ehttps://www.marxists.org/archive/brecht/works/1935/questions.htm\u003c/a\u003e A short poem by Bertold Brecht about who did what, questioning why we only remember those in power.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.newyorker.com/magazine/2016/08/29/michael-heizers-city\"\u003ehttps://www.newyorker.com/magazine/2016/08/29/michael-heizers-city\u003c/a\u003e About a land art piece by Michael Heizer, who is both a genius and is also rather crazy. His other work, Double Negative is truly beautiful (it\u0026rsquo;s literally a hole in the desert, but a beautiful hole, the best hole, and I mean it)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://publicdelivery.org/agnes-denes-wheatfield/\"\u003ehttps://publicdelivery.org/agnes-denes-wheatfield/\u003c/a\u003e About a large wheat field, in the middle of Manhattan, that Ágnes Dénes sowed and then harvested, right in the view of the World Trade Center.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.africavernaculararchitecture.com/\"\u003ehttps://www.africavernaculararchitecture.com/\u003c/a\u003e A classic 90s website about vernacular architecture in Africa. Some amazingly beautiful houses, built for the people, by the people, to live in. Click on a country and enjoy.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://vimeo.com/58444378\"\u003ehttps://vimeo.com/58444378\u003c/a\u003e A mockumentary about a guy making music, caring for his father, trying to enjoy life, and remembering the things that didn\u0026rsquo;t work out, which he likens to Mount Everest, his Whateverest.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.vincentmoon.com/map/\"\u003ehttps://www.vincentmoon.com/map/\u003c/a\u003e The map of places where Vincent Moon recorded traditional music preformed by locals. \u003ca href=\"https://www.vincentmoon.com/filmography/fydalty-namys-polyphonic-voices-from-north-ossetia/\"\u003eHere\u003c/a\u003e is one for a taster. If you listen patiently, with intent, you might find that there\u0026rsquo;s a lot of beautiful music out there.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.ryojiikeda.com/project/testpattern/\"\u003ehttps://www.ryojiikeda.com/project/testpattern/\u003c/a\u003e A set of test patterns, projected over a large space, that allows people to lay down, walk around, and explore. To be coupled with his strange but \u003ca href=\"https://open.spotify.com/track/3Spgnf1lO6QFGlWLO2aECt?si=4dbe4ba9a7aa4f1a\"\u003efascinating noise music\u003c/a\u003e. I went to his concert, it\u0026rsquo;s exactly as weird as you\u0026rsquo;d imagine. He never said hello, goodbye, or left any space to clap.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://whatever.scalzi.com/2005/09/03/being-poor/\"\u003ehttps://whatever.scalzi.com/2005/09/03/being-poor/\u003c/a\u003e What it means to be poor by Scalzi. Watch out for the comment by her own sister. Back in the days of the interwebs when comments added value.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://recorderfilm.com/\"\u003eThe Marion Stokes Project\u003c/a\u003e, with its transcript in a \u003ca href=\"/wordpress/wp-content/uploads/2026/07/recorder-the-marion-stokes-project.txt\"\u003emore accessible form\u003c/a\u003e.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.tate.org.uk/tate-etc/issue-10-summer-2007/excremental-value\"\u003ehttps://www.tate.org.uk/tate-etc/issue-10-summer-2007/excremental-value\u003c/a\u003e An article about my favourite artwork, Manzoni\u0026rsquo;s Merda d\u0026rsquo;Artista. In 1961 he put his own excrement into 90 small cans and sold them at the price of gold ($37/ounce). Over the years, it has outperformed gold by a factor of 70x. The guy with the banana stuck to the wall is a mere imitator by comparison (and 60 years late)\u003c/li\u003e\n\u003c/ul\u003e\n\u003cfigure\u003e\n    \u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2024/12/Agnes-Denes-Wheatfield-A-Confrontation-1982-Battery-Park-Landfill-Downtown-Manhattan-1-2-scaled-749723663.jpg\"/\u003e \n\u003c/figure\u003e\n\n\u003cp\u003eÁgnes Dénes – \u003cem\u003eWheatfield – A Confrontation\u003c/em\u003e, 1982, Battery Park Landfill, Downtown Manhattan, photo: John McGrall\u003c/p\u003e","title":"Some food for thought: great content on the Internet"},{"content":"I have recently had a few discussions with people who wanted to do some form of model counting, and I decided to put my thoughts about this problem into a single blog post, hopefully bringing some light to this area. Firstly, when talking about model counting, it\u0026rsquo;s very important to think through what one actually needs to achieve. When people talk about a model, they often mean a solution to a problem, described as a set of constraints over either purely boolean variables (so-called propositional model counting) expressed in so-called CNF, or over higher-level constraints, often expressed in SMT-LIB format.\nLet\u0026rsquo;s look at a CNF example:\nc this is a comment c below line means there are 5 boolean variables and 2 constraints p cnf 5 2 1 -2 0 1 -2 3 0 The above CNF has 5 boolean variables and 2 constraints: \u0026ldquo;v1 or (not v2) = true\u0026rdquo;, and \u0026ldquo;v1 or (not v2) or v3 = true\u0026rdquo;. In this case, if \u0026ldquo;v1 or (not v2) = true\u0026rdquo; is satisfied, the other constraint is also satisfied. So we effectively only have to satisfy the \u0026ldquo;v1 or -v2\u0026rdquo; constraint. There are 3 solutions over the variables v1 and v2 to this constraint: (1, 0), (1, 1), and (0,0). For variables v3, v4, and v5 we can choose anything. So there are a total of 3*2^3 = 24 solutions to this CNF.\nLet\u0026rsquo;s look at an SMT problem:\n(set-logic QF_BV) ; Set the logic to Quantifier-Free BitVectors (declare-fun bv () (_ BitVec 8)) ; Declare an 8-bit value (assert (not (= bv #x00))) ; Assert that \u0026#39;bv\u0026#39; is not equal to zero In this SMT-LIB problem, we declared that the logic we will be using is the so-called quantifier-free bitvector logic, which basically gives you access to fixed-width variables such as uint8_t, and of course all the logical and fixed-bit bitwector operators such as modulo addition, division, subtraction, etc. In this particular case, we declared an 8-bit variable and banned it from being 0, so this problem has 2^8-1 solutions, i.e. 255.\nWhichever format is being used, \u0026ldquo;counting\u0026rdquo; of solutions is something that may sound trivial (it\u0026rsquo;s just a number!), but once we get a bit more fiddly, it turns out that we can do many things that are actually easier, or even harder, than just counting, even though they sound very close to, or are even synonymous with, counting :\nFiguring out if there is at least one solution. This is more appropriately called satisfiability checking. This is significantly easier than any notion of counting listed below. However, even this can be challenging. Typically, in the SMT/SAT competition, this is the so-called SMT single query track or the SAT competition Main Track. All SAT and SMT solvers such as kissat or cvc5 can run this kind of task. Next up in complexity is to figure out if there is exactly one solution. This is actually very close to satisfiability checking, and requires only two so-called \u0026ldquo;incremental calls\u0026rdquo; to the SMT/SAT solver. I have seen this question pop up a lot in zero-knowledge (ZK) circuit correctness. What is needed is to run the query as per the above, but then add a constraint that bans the solution that is output by the solver, and ask the system to be solved again. If the solver outputs UNSAT, i.e. unsatisfiable, then we know there are no more solutions, and we are happy with the result. If not, it gives us another solution, which is a witness that there are at least two solutions. These queries are answered by so-called incremental SMT solvers (SMT competition track here), or incremental SAT solvers (incremental SAT competition track here). Almost all SAT and SMT solvers can work incrementally, for example cvc5 or z3. Most SAT solvers work incrementally, too, but e.g. kissat does not, and you need to use CaDiCaL instead. Next up in complexity is to approximately count the solutions. Here, we are not interested that there are exactly, say, 87231214 solutions, instead, we are happy to know that there are approx 2^26 solutions. This is often good enough, in case one wants to e.g. figure out probabilities. There are very few such systems available, for SMT there is csb, and for SAT there is ApproxMC. For the special case of approximate DNF counting, I\u0026rsquo;d recommend pepin. Next up in the complexity is exactly counting the solutions. Here, we want to know how many solutions there are, exactly, and we really-really need the exact number. There are few solutions to doing this over SMT, but doing this over SAT is quite developed. For SMT, I would recommend following the csb approach, and running Ganak on the blasted SAT formula instead of ApproxMC, and for SAT, there is the annual model counting competition, where Ganak won every single category this year, so I\u0026rsquo;d recommend Ganak. Next up is model enumeration where it\u0026rsquo;s not enough to count the solutions, but we need a way to compactly represent and store them all. This of course requires quite a bit of disk space, as there could be e.g. 2^100 solutions, and representing them all, even in a very compact format with lots of smart ideas can take a lot of space \u0026ndash; but not necessarily exponential amount. Currently, there is no such system for SMT, and my understanding is that only the d4 model counter can do this on SAT/CNF problems, thanks to its proof checking system, in part thanks to Randal Byrant. Once Ganak can output a proof, it will also be able to do this. All in all, there is a very large gap between \u0026ldquo;find if there is exactly one solution\u0026rdquo; and \u0026ldquo;enumerate all solutions\u0026rdquo; \u0026ndash; even though I have seen these two notions being mixed up a few times. The first might take only a few seconds to solve, while the other might not even be feasible, because compactly representing all solutions may be too expensive in terms of space (and that\u0026rsquo;s not even discussing time).\nOne aspect to keep in mind is that often, one does not need all solutions. For example, if one only wants to find a good set of example solutions, then it is possible to use uniform-like samplers, that give a \u0026ldquo;somewhat uniform\u0026rdquo; set of example solutions from the solution space (without guarantees of uniformity). A good tool for this is cmsgen for CNF/SAT problems. If one needs a guaranteed uniform set of samples (to be exact, a probabilistically approximately uniform sample), then unigen is the way to go. Obviously, it\u0026rsquo;s quite easy to find a uniform sample once we have an enumeration of all solutions \u0026ndash; simply pick a random one from the whole set \u0026ndash; but that\u0026rsquo;s way more expensive than running unigen.\nWhile all of the above is about counting, it\u0026rsquo;s often the case that one wants to optimize for something within the solution space. Basically, we have some kind of objective function that we want to optimize for (e.g. maximize profit, minimize loss) , and so we are looking for a solution that maximizes/minimizes some property. Of course, once we have done model enumeration, it\u0026rsquo;s quite easy to do this \u0026ndash; simply run the objective function on all solutions, and pick the best! But that\u0026rsquo;s really hard. Instead, one can formulate the problem as a so-called MaxSAT or an SMT problem with an objective function. These systems run some really smart algorithms to significantly cut down search time, and even often keep a \u0026ldquo;best so far\u0026rdquo; solution around, so we can early-abort them and still get some kind of \u0026ldquo;best so far\u0026rdquo; solution.\nAll in all, it\u0026rsquo;s extremely important to figure out what one actually needs, because there are vast gaps in complexity between the problems (and corresponding algorithms) above. Even between something like approximate and exact counting, the gap is gigantic, as there are huge swaths of problems that are almost trivial to count approximately, but essentially impossible to exactly count with current technology:\nHere, the green line is a tool that changes its behaviour from exact to approximate model counting after 1800 seconds of solving, and the number of solved instances jumps significantly. Notice that the red line, the original system it runs for 1800s, is the best in class here, by a wide margin, and still the approximate counting that Ganak+ApprocMC switches into shows a massive difference.\n","permalink":"https://www.msoos.org/2024/10/on-sat-smt-model-counting/","summary":"\u003cp\u003eI have recently had a few discussions with people who wanted to do some form of model counting, and I decided to put my thoughts about this problem into a single blog post, hopefully bringing some light to this area. Firstly, when talking about model counting, it\u0026rsquo;s very important to think through what one actually needs to achieve. When people talk about a model, they often mean a solution to a problem, described as a set of constraints over either purely boolean variables (so-called propositional model counting) expressed in so-called \u003ca href=\"https://en.wikipedia.org/wiki/Conjunctive_normal_form\"\u003eCNF\u003c/a\u003e, or over higher-level constraints, often expressed in \u003ca href=\"https://smt-lib.org/examples.shtml\"\u003eSMT-LIB\u003c/a\u003e format.\u003c/p\u003e","title":"On SAT/SMT Model Counting"},{"content":"This post is just a bit of a recap of what we have developed over the years as part of our toolset of SAT solvers, counters, and samplers. Many of these tools depend on each other, and have taken greatly from other tools, papers, and ideas. These dependencies are too long to list here, but the list is long, probably starting somewhere around the Greek period, and goes all the way to recent work such as SharpSAT-td or B+E. My personal work stretches back to the beginning of CryptoMiniSat in 2009, and the last addition to our list is Pepin.\nOverview Firstly when I say \u0026ldquo;we\u0026rdquo; I loosely refer to the work of my colleagues and myself, often but not always part of the research group lead by Prof Kuldeep Meel. Secondly, almost all these tools depend on CryptoMiniSat, a SAT solver that I have been writing since around 2009. This is because most of these tools use DIMACS CNF as the input format and/or make use of a SAT solver, and CryptoMiniSat is excellent at reading, transforming , and solving CNFs. Thirdly, many of these tools have python interface, some connected to PySAT. Finally, all these tools are maintained by me personally, and all have a static Linux executable as part of their release, but many have a MacOS binary, and some even a Windows binary. All of them build with open source toolchains using open source libraries, and all of them are either MIT licensed or GPL licensed. There are no stale issues in their respective GitHub repositories, and most of them are fuzzed.\nCryptoMiniSat CryptoMiniSat (research paper) our SAT solver that can solve and pre- and inprocess CNFs. It is currently approx 30k+ lines of code, with a large amount of codebase dedicated to CNF transformations, which are also called \u0026ldquo;inprocessing\u0026rdquo; steps. These transformations are accessible to the outside via an API that many of the other tools take advantage of. CryptoMiniSat used to be a state-of-the-art SAT solver, and while it\u0026rsquo;s not too shabby even now, it hasn\u0026rsquo;t had the chance to shine at a SAT competition since 2020, when it came 3rd place. It\u0026rsquo;s hard to keep SAT solver competitive, there are many aspects to such an endeavor, but mostly it\u0026rsquo;s energy and time, some of which I have lately redirected into other projects, see below. Nevertheless, it\u0026rsquo;s a cornerstone of many of our tools, and e.g. large portions of ApproxMC and Arjun are in fact implemented in CryptoMiniSat, so that improvement in one tool can benefit all other tools.\nArjun Arjun (research paper) is our tool to make CNFs easier to count with ApproxMC, our approximate counter. Arjun takes a CNF with or without a projection set, and computes a small projection set for it. What this means is that if say the question was: \u0026ldquo;How many solutions does this CNF has if we only count solutions to be distinct over variables v4, v5, and v6?\u0026rdquo;, Arjun can compute that in fact it\u0026rsquo;s sufficient to e.g. compute the solutions over variables v4 and v5, and that will be the same as the solutions over v4, v5, and v6. This can make a huge difference for large CNFs where e.g. the original projection set can be 100k variables, but Arjun can compute a projection set sometimes as small as a few hundred. Hence, Arjun is used as a preprocessor for our model counters ApproxMC and GANAK.\nApproxMC ApproxMC (research paper) is our probabilistically approximate model counter for CNFs. This means that when e.g. ApproxMC gives a result, it gives it in a form of \u0026ldquo;The model count is between 0.9*M and 1.1*M, with a probability of 99%, and with a probability of 1%, it can be any value\u0026rdquo;. Which is very often enough for most cases of counting, and is much easier to compute than an exact count. It counts by basically halfing the solution space K times and then counts the remaining number of solutions. Then, the count is estimated to be 2^(how many times we halved)*(how many solutions remained). This halfing is done using XOR constraints, which CryptoMiniSat is very efficient at. In fact, no other state-of-the-art SAT solver can currently perform XOR reasoning other than CryptoMiniSat.\nUniGen UniGen (research paper) is an approximate probabilistic uniform sample generator for CNFs. Basically, it generates samples that are probabilistically approximately uniform. This can be hepful for example if you want to generate test cases for a problem, and you need the samples to be almost uniform. It uses ApproxMC to first count and then the same idea as ApproxMC to sample: add as many XORs as needed to half the solution space, and then take K random elements from the remaining (small) set of solutions. These will be the samples returned. Notice that UniGen depends on ApproxMC for counting, Arjun for projection minimization, and CryptoMiniSat for the heavy-lifting of solution/UNSAT finding.\nGANAK GANAK (research paper, binary) is our probabilistic exact model counter. In other words, it returns a solution such as \u0026ldquo;This CNF has 847365 solutions, with a probability of 99.99%, and with 0.01% probability, any other value\u0026rdquo;. GANAK is based on SharpSAT and some parts of SharpSAT-td and GPMC. In its currently released form, it is in its infancy, and while usable, it needs e.g. Arjun to be ran on the CNF before, and while competitive, its ease-of-use could be improved. Vast improvements are in the works, though, and hopefully things will be better for the next Model Counting Competition.\nCMSGen CMSGen (research paper) is our fast, weighted, uniform-like sampler, which means it tries to give uniform samples the best it can, but it provides no guarantees for its correctness. While it provides no guarantees, it is surprisingly good at generating uniform samples. While these samples cannot be trusted in scenarios where the samples must be uniform, they are very effective in scenarios where a less-than-uniform sample will only degrade the performance of a system. For example, they are great at refining machine learning models, where the samples are taken uniformly at random from the area of input where the ML model performs poorly, to further train (i.e. refine) the model on inputs where it is performing poorly. Here, if the sample is not uniform, it will only slow down the learning, but not make it incorrect. However, generating provably uniform samples in such scenarios may be prohibitively expensive. CMSGen is derived from CryptoMiniSat, but does not import it as a library.\nBosphorus Bosphorus (research paper) is our ANF solver, where ANF stands for Algebraic Normal Form. It\u0026rsquo;s a format used widely in cryptography to describe constraints over a finite field via multivariate polynomials over a the field of GF(2). Essentially, it\u0026rsquo;s equations such as \u0026ldquo;a XOR b XOR (b AND c) XOR true = false\u0026rdquo; where a,b,c are booleans. These allow some problems to be expressed in a very compact way and solving them can often be tantamount to breaking a cryptographic primitive such as a symmetric cipher. Bosphorus takes such a set of polynomials as input and either tries to simplify them via a set of inprocessing steps and SAT solving, and/or tries to solve them via translation to a SAT problem. It can output an equivalent CNF, too, that can e.g. be counted via GANAK, which will give the count of solutions to the original ANF. In this sense, Bosphorus is a bridge from ANF into our set of CNF tools above, allowing cryptographers to make use of the wide array of tools we have developed for solving, counting, and sampling CNFs.\nPepin Pepin (research paper) is our probabilistically approximate DNF counter. DNF is basically the reverse of CNF \u0026ndash; it\u0026rsquo;s trivial to ascertain if there is a solution, but it\u0026rsquo;s very hard to know if all solutions are present. However, it is actually extremely fast to probabilistically approximate how many solutions a DNF has. Pepin does exactly that. It\u0026rsquo;s one of the very few tools we have that doesn\u0026rsquo;t depend on CryptoMiniSat, as it deals with DNFs, and not CNFs. It basically blows all other such approximate counters out of the water, and of course its speed is basically incomparable to that of exact counters. If you need to count a DNF formula, and you don\u0026rsquo;t need an exact result, Pepin is a great tool of choice.\nConclusions My personal philosophy has been that if a tool is not easily accessible (e.g. having to email the authors) and has no support, it essentially doesn\u0026rsquo;t exist. Hence, I try my best to keep the tools I feel responsible for accessible and well-supported. In fact, this runs so deep, that e.g. CryptoMiniSat uses the symmetry breaking tool BreakID, and so I made that tool into a robust library, which is now being packaged by Fedora, because it\u0026rsquo;s needed by CryptoMiniSat. In other words, I am pulling other people\u0026rsquo;s tools into the \u0026ldquo;maintained and supported\u0026rdquo; list of projects that I work with, because I want to make use of them (e.g. BreakID now builds on Linux, MacOS, and Windows). I did the same with e.g. the Louvain Community library, which had a few oddities/issues I wanted to fix.\nAnother oddity of mine is that I try my best to make our tools make sense to the user, work as intended, give meaningful (error) messages, and good help pages. For example, none of the tools I develop call subprocesses that make it hard to stop a computation, and none use a random number seed that can lead to reproducibility issues. While I am aware that working tools are sometimes less respected than a highly cited research paper, and so in some sense I am investing my time in a slightly suboptimal way, I still feel obliged to make sure the tax money spent on my academic salary gives something tangible back to the people who pay for it.\n","permalink":"https://www.msoos.org/2024/02/our-tools-for-solving-counting-and-sampling/","summary":"\u003cp\u003eThis post is just a bit of a recap of what we have developed over the years as part of our toolset of SAT solvers, counters, and samplers. Many of these tools depend on each other, and have taken greatly from other tools, papers, and ideas. These dependencies are too long to list here, but the list is long, probably starting somewhere around the \u003ca href=\"https://en.wikipedia.org/wiki/Thales_of_Miletus#Mathematics\"\u003eGreek period\u003c/a\u003e, and goes all the way to recent work such as \u003ca href=\"https://github.com/Laakeri/sharpsat-td\"\u003eSharpSAT-td\u003c/a\u003e or \u003ca href=\"http://www.cril.univ-artois.fr/KC/bpe2.html\"\u003eB+E\u003c/a\u003e. My personal work stretches back to the beginning of \u003ca href=\"https://github.com/msoos/cryptominisat\"\u003eCryptoMiniSat\u003c/a\u003e in 2009, and the last addition to our list is \u003ca href=\"https://github.com/meelgroup/pepin\"\u003ePepin\u003c/a\u003e.\u003c/p\u003e","title":"Our tools for solving, counting and sampling"},{"content":"Many modern SAT solvers do a lot of what\u0026rsquo;s called inprocessing. These steps simplify the CNF into something that is easier to solve. In the compiler world, these are called rewritngs since the effectively rewrite (parts of) the formula to something else that retain certain properties, such as satisfiability. One of the most successful such rewrite rules for CNF is Bounded Variable Elimination (BVE, classic paper here), but there are many others. These rewrites are usually done by modern SAT solvers in a particular order that was found to be working well for their particular use-case, but they are not normally accessible from the outside.\nSometimes one wants to use these rewrite rules for something other than just solving the instance via the SAT solver. One such use-case is to use these rewrite rules to simplify the CNF in order to count the solution to it. In this scenario, the user wants to rewrite the CNF in a very particular way, and then extract the simplified CNF. Other use-cases are easy to imagine, such as e.g. MaxSAT, core counting, etc. Over the years, CryptoMiniSat has evolved such a rewrite capability. It is possible to tell CryptoMiniSat to simplify the formula exactly how the user wants the solver to be satisfied and then extract the simplified formula.\nExample Use-Case Let\u0026rsquo;s say we have a CNF that we want to simplify:\np cnf 4 2 1 2 3 4 0 1 2 3 0 In this CNF, 1 2 3 4 0 is not needed, because it is subsumed by the clause 1 2 3 0. You can run subsumption using CryptoMiniSat this way:\n#include \u0026#34;cryptominsat5/cryptominisat.h\u0026#34; #include \u0026lt;vector\u0026gt; #include \u0026lt;cmath\u0026gt; #include \u0026lt;iostream\u0026gt; using namespace CMSat; using namespace std; #define lit(a) Lit(std::abs(a)-1, a\u0026lt;0) int main() { Solver s; vector\u0026lt;Lit\u0026gt; cl; s.add_new_vars(4); cl = vector\u0026lt;Lit\u0026gt;{lit(1), lit(2), lit(3), lit(4)}; s.add_clause(cl); cl = vector\u0026lt;Lit\u0026gt;{lit(1), lit(2), lit(3)}; s.add_clause(cl); s.simplify(NULL, \u0026#34;occ-backw-sub\u0026#34;); s.start_getting_clauses(); while(s.get_next_clause(cl) { for(const auto l: cl) cout \u0026lt;\u0026lt; l \u0026lt;\u0026lt; \u0026#34; \u0026#34;; cout \u0026lt;\u0026lt; endl; } s.end_getting_clauses() return 0; } This code runs the inprocessing system occ-backw-sub, which stands for backwards subsumption using occurrence lists. The input CNF can be anything, and the output CNF is the simplified CNF. This sounds like quite a lot of code for simple subsumption, but this does a lot of things under the hood for things to be fast, and it is a lot more capable than just doing subsumption.\nNotice that the first argument we passed to simplify() is NULL. This means we don\u0026rsquo;t care about any variables being preserved \u0026ndash; any variable can (and will) be eliminated if occ-bve is called. In case some variables are important to you not to be eliminated, you can create a vector of them and pass the pointer here. If you have called the renumber API, then you can get the set of variables you had via clean_sampl_and_get_empties(). The numbering will not be preserved, but their set will be the same, though not necessarily the same size. This is because some variables may have been set, or some variables may be equivalent to other variables in the same set. You can get the variables that have been set via get_zero_assigned_lits().\nSupported Inprocessing Steps Currently, the following set of inprocessing steps are supported:\nAPI name Inprocessing performed occ-backw-sub Backwards subsumption using occurence lists occ-backw-sub-str Backwards subsumption and strengthening using occurence lists occ-bce Blocked clause elimination (paper) occ-ternary-res Ternary resolution (paper) occ-lit-rem Literal removal via strengthening occ-cl-rem-with-orgates OR-gate based clause removal (unpublished work, re-discovered by others) occ-rem-with-orgates OR-gate based literal removal occ-bve Bounded variable elimination (paper) occ-bve-empty Bounded variable elimination of empty resolvents only intree-probe Probe using in-tree probing, also do hyper-binary resolution and transitive reduction (paper). Also does hyper-binary resoution \u0026amp; transitive reduction full-probe Probe each literal individually (slow compared to intree-probe) backbone Backbone simplification (cadiback paper) sub-impl Subsume with binary clauses with binary clauses (fast) sub-str-cls-with-bin Subsume and strengthen long clauses with binary clauses (fast) sub-cls-with-bin Subsume long clauses with binary clauses (fast) distill-bins Distill binary clauses distill-cls Distill long clauses (distillation paper) distill-cls-onlyrem Distill long clauses, but only remove clauses, don\u0026rsquo;t shorten them. Useful if you want to make sure BVE can run at full blast after this step. clean-cls Clean clauses of set literals, and delete satisfied clauses must-renumber Renumber variables to start from 0, in case some have been set to TRUE/FALSE or removed due to equivalent literal replacement. must-scc-vrepl Perform strongly connected component analysis and perform equivalent literal replacement. oracle-vivify Vivify clauses using the Oracle tool by Korhonen and Jarvisalo (paper). Slow but very effective. oracle-vivif-sparsify Vivify \u0026amp; sparsify clauses using the Oracle tool by Korhonen and Jarvisalo. Slow but very effective. Convenience Features Under the Hood The steps above do more than what they say on the label. For example, the ones that start with occ build an occurrence list and use it for the next simplification stop if it also starts with occ. They also all make sure that memory limits and time limits are adhered to. The timeout multiplier can be changed via set_timeout_all_calls(double multiplier). The time limits are entirely reproducible, there is no actual seconds, it\u0026rsquo;s all about an abstract \u0026ldquo;tick\u0026rdquo; that is ticking. This means that all bugs in your code are always reproducible. This helps immensely with debugging \u0026ndash; no more frustrating Heisenbugs. You can check the cryptominisat.h file for all the different individual timeouts and memouts you can set.\nUnder the hood you also get a lot of tricks implemented by default. You don\u0026rsquo;t have to worry about e.g. strengthening running out of control, it will terminate in reasonable amount of ticks, even if that means it will not run to completion. And the next time you run it, it will start at a different point. This makes a big difference in case you actually want your tool to be usable, rather than just \u0026ldquo;publish and forget\u0026rdquo;. In many cases, simplification only makes things somewhat faster, and you want to stop performing the simplification after some time, but you also want your users to be able to report bugs and anomalies. If the system didn\u0026rsquo;t have timeouts, you\u0026rsquo;d run the risk of the simplifier running way too long, even though the actual solving would have taken very little time. And if the timeout was measured in seconds, you\u0026rsquo;d run the risk of a bug being reported but being irreproducible, because the exact moment the timeout hit for the bug to occur would be irreproducible.\nMaking the Best of it All This system is just an API \u0026ndash; it doesn\u0026rsquo;t do much on its own. You need to play with it, and creatively compose simplifications. If you take a look at cryptominisat.h, it already has a cool trick, where it moves the simplified CNF from an existing solver to a new, clean solver through the API, called copy_simp_solver_to_solver(). It is also used extensively in Arjun, our CNF simplifier for counting. There, you can find the function that controls CryptoMiniSat from the outside to simplify the CNF in the exact way needed. It may be worthwhile reading through that function if you want to control CryptoMiniSat via this API.\nThe simplify() API can give you the redundant clauses, too (useful if you e.g. did ternary or hyper-binary resolution), and can give you the non-renumbered CNF as well \u0026ndash; check out the full API in cryptominisat.h, or the Arjun code. Basically, there is a red and a simplified parameter you can pass to this function.\nPerhaps I\u0026rsquo;ll expose some of this API via the Python interface, if there is some interest for it. I think it\u0026rsquo;s quite powerful and could help people who use CNFs in other scenarios, such as MaxSAT solving, core counting, core minimization, etc.\nClosing Thoughts I think there is currently a lack of tooling to perform the already well-known and well-documented pre- and inprocessing steps that many SAT solvers implement internally, but don\u0026rsquo;t expose externally. This API is supposed to fill that gap. Although it\u0026rsquo;s a bit rough on the edges sometimes, hopefully it\u0026rsquo;s something that will inspire others to either use this API to build cool stuff, or to improve the API so others can build even cooler stuff. While it may sound trivial to re-implement e.g. BVE, once you start going into the weeds of it (e.g. dealing with the special case of detecting ITE, OR \u0026amp; AND gates\u0026rsquo; and their lower resolvent counts, or doing it incrementally with some leeway to allow clause number increase), it gets pretty complicated. This API is meant to alleviate this stress, so researchers and enthusiasts can build their own simplifier given a set of working and tested \u0026ldquo;LEGO bricks\u0026rdquo;.\n","permalink":"https://www.msoos.org/2023/10/the-inprocessing-api-of-cryptominisat/","summary":"\u003cp\u003eMany modern SAT solvers do a lot of what\u0026rsquo;s called inprocessing. These steps simplify the CNF into something that is easier to solve. In the compiler world, these are called \u003ca href=\"https://en.wikipedia.org/wiki/Rewriting\"\u003erewritngs\u003c/a\u003e since the effectively rewrite (parts of) the formula to something else that retain certain properties, such as satisfiability. One of the most successful such rewrite rules for CNF is Bounded Variable Elimination (BVE, \u003ca href=\"https://fmv.jku.at/papers/EenBiere-SAT05.pdf\"\u003eclassic paper here\u003c/a\u003e), but there are many others. These rewrites are usually done by modern SAT solvers in a particular order that was found to be working well for their particular use-case, but they are not normally accessible from the outside.\u003c/p\u003e","title":"The Inprocessing API of CryptoMiniSat"},{"content":"Let\u0026rsquo;s say you are allowed to have cubes in a 3-dimensional space that happens to be binary. In this space, x1, x2, and x3 are the axis, and for example the cube x1=0 is a cube that happens to have 4 points in it: 000, 001, 010, and 011. So far, so good. Now, let\u0026rsquo;s say we need to calculate the total volume of two cubes in this space. If they don\u0026rsquo;t intersect, it\u0026rsquo;s quite easy, we simply add their volumes. But what if they intersect? Now we need to compute their overlap, and subtract it from their sum of volumes. But there is a better way.\nProbabilistic Approximate Volume Counting Our new tool Pepin (code, paper) is based on the probabilistic approximate model counting algorithm by Meel, Vinodchandran, and Chakraborty (paper) that is so simple in principle yet so ingenious that even Donald Knuth got excited about it, recently writing a 15-page note and spending considerable amount of time on the algorithm.\nSo, what is this algorithm? Well, it\u0026rsquo;s so simple it\u0026rsquo;s almost funny. Basically, we keep randomly sampled points from the volume that we currently hold. At every moment we have a representative, evenly sampled set of points from the volume we currently have, and we know the sampling rate. You can think of the \u0026ldquo;sampling rate\u0026rdquo; as the approximate volume that each sample represents. So, if at any point we want to know the volume, we calculate number_of_points*(1/sampling_rate) and have the approximate volume. Kinda neat, no? So all we need is a randomly sampled set of points and a corresponding sampling rate. But how do we go about that?\nLet\u0026rsquo;s say we are about to process the first cube (i.e. volume, could be any shape, actually, but cubes are simple). Our sampling rate is 1.0, we have 10 dimensions, and we have a limit of 10 samples in our bag. Let\u0026rsquo;s say the first cube is:\nx1=0 Notice that this cube has 2^9 elements: 0000000000, 0000000001, \u0026hellip; 0111111111. But that\u0026rsquo;s too many elements to hold, we only have space for 10 samples in the bag! We have to drop our sampling rate. The algorithm throws coins for each element in the volume (at first, a coin that has 1.0 probability of heads\u0026hellip; funny coin!), and realizes that it won\u0026rsquo;t fit the sample bag. So it halves the sample rate (to 0.5) and throws the coins again. Realizes it doesn\u0026rsquo;t fit\u0026hellip; halves the sample rate\u0026hellip; and eventually will likely end up with a sampling rate of 1/2^6. That sample rate makes sense: it means 2^9/2^6 = 9 samples on average, which fits. Let\u0026rsquo;s say the algorithm flipped the coins, halved the sampling rate every time, and settled on a sampling rate of 1/2^6, and 9 samples.\nLet\u0026rsquo;s see these samples. For readability, I\u0026rsquo;ll write the samples as 0110\u0026hellip; which means x1=0, x2=1, x3=1, x4=0, etc.\n0001011110 0010110110 0010000101 0001101001 0101001011 0011110101 0101101001 0110101100 0000011111 Think of each of these points representing a volume of 2^6. The current estimate of the volume is 9*2^6 = 2^9.17 (instead of 2^9). So far so good. Now a new cube comes in. Let\u0026rsquo;s say this cube is:\nx1=0, x1=1 This is the tricky part. What do we do? The algorithm is extremely simple: we throw away every sample that matches this cube, and then we sample the cube. Let\u0026rsquo;s throw away everything that matches, i.e. everything that starts with \u0026ldquo;01\u0026rdquo;:\n0001011110 0010110110 0010000101 0001101001 0011110101 0000011111 Good. Now we sample the cube \u0026ldquo;x1=0, x1=1\u0026rdquo; with 1/2^6 probability. Time to take out our weird coin that has a 1/2^6 chance of winning! We toss this coin on every element in the cube, i.e. all 2^8 (since x0=1, x1=1 has 2^8 elements). We should get about 4 heads, but let\u0026rsquo;s say we got 3. Happens. Now, append these 3 to our neat little sample bag:\n0001011110 0010110110 0010000101 0001101001 0011110101 0000011111 0101001011 0101111101 0110000010 Nice. What just happened? Well, we got rid of the elements from the volume we were holding that were contained in the cube that we are processing. Then, we randomly sampled elements from the cube at our given sampling rate. If you think about it, this means that as long as we did everything uniformly at random, we are basically back to where we started. In fact, the 2nd cube could have been anything. It could have been completely outside of our current volume, or it could have partially intersected it. The game is the same. Running out of space? Just throw away each sample with probability half, and half your sampling rate! Here\u0026rsquo;s a visual representation what we would do in case the two cubes partially intersected:\nAs the number of samples goes over the limit in our bag, we simply throw away each sample with 0.5 probability, and halve our sampling rate. This allows us to keep a fixed maximum number of samples, regardless of the size of the volume we are holding. For our example, we decided to limit ourselves to 10 samples, and got a pretty good estimate of the volume: 9*2^6 (=~2^9.17) instead of 2^9. One thing of note. This algorithm is not only approximate in the sense that we get something close to the actual solution, like 2^9.17. It\u0026rsquo;s also probabilistic in the sense that with a low probability, we get a complete garbage value. You can reduce the probability of getting a garbage value in a number of ways, though.\nThis algorithm is really powerful, because you could approximately count a 100-dimensional volume with thousands of cubes using less than 1MB of memory, and actually be pretty damn accurate, with a very low probability of getting a wrong value. Unsurprisingly, this is exactly what we do in our tool, Pepin.\nThe Tricks of Pepin If you think about it, Pepin does nothing but: (1) holds a bunch of samples (2) deals with some large \u0026amp; small numbers (2^10000 is large, and 1/2^100000 is small), and (3) deals with probabilities. For dealing with small \u0026amp; large numbers, we used the GNU MP Bignum library, with all the standard tricks (pre-allocating memory \u0026amp; constants, etc), and for probabilities we use a number of tricks \u0026ndash; sampling the binomial distribution is easy until you have to do it with t=2^100 and p=1/2^95. While dealing with probabilities was hard from a mathematical perspective, the really fun part for me was dealing with the sampling bag.\nIt turns out I wasn\u0026rsquo;t the only one who got sidetracked with the sampling bag: if you take a look at Knuth\u0026rsquo;s implementation, he goes into great detail about his datastructure, the Treap (honestly, that whole note by Knuth is quite a trip, you can see how his mind is racing). Anyway, back to the sampling bag. Firstly, the bag is just a matrix (with some rows sometimes empty) so we can store it either column or row-major. This is probably the first thing that comes to everyone\u0026rsquo;s mind as a computer science 101 trick. More interestingly, if one looks at the performance bottlenecks of the algorithm, it quickly becomes apparent that: (1) generating millions of bits of randomness for all the samples is expensive, and (2) writing all those samples to memory is expensive. So, what can we do?\nThe cool trick we came up with is what Knuth would call \u0026ldquo;late binding\u0026rdquo;, or we can call it lazy evaluation. Let\u0026rsquo;s keep to our original example: we first had the cube \u0026ldquo;x1=1\u0026rdquo;. We ran our coin-flip technique and found that we needed 9 samples (setting the sampling rate to 1/2^6), fine. But why do we really need all the bits of the samples? We don\u0026rsquo;t need them now! We may need them later \u0026ndash; but since it\u0026rsquo;s all random anyway, we can generate them anytime, now or later! So, let\u0026rsquo;s generate 9 samples like this:\n1********* 1********* 1********* 1********* 1********* 1********* 1********* 1********* 1********* The \u0026ldquo;*\u0026rdquo; simply means this bit needs to be selected randomly. Now the cube \u0026ldquo;x1=1, x2=0\u0026rdquo; comes, which forces our hands, we have to know what the 2nd bit is: if it\u0026rsquo;s a \u0026ldquo;1\u0026rdquo; we have to throw the sample away, if it\u0026rsquo;s a \u0026ldquo;0\u0026rdquo;, we can keep it in. So we decide this bit now (not in the past, but now, when we need it), randomly:\n00******** 00******** 00******** 00******** 01******** 00******** 01******** 01******** 00******** And now we can throw away the samples that match \u0026ldquo;x1=0, x2=1\u0026rdquo;, just like before. The sample bag is now:\n00******** 00******** 00******** 00******** 00******** 00******** We can now sample from the cube \u0026ldquo;x1=0, x2=1\u0026rdquo; randomly \u0026ndash; again, notice we don\u0026rsquo;t need to know what the 3rd or 4th, etc. bits are. They can be decided later, when they are needed:\n00******** 00******** 00******** 00******** 00******** 00******** 01******** 01******** 01******** Nice. Notice that this leads to exactly where we would have arrived anyway from a conceptual point of view. Except we (1) don\u0026rsquo;t need to generate as many random numbers and (2) if we can fill memory with \u0026ldquo;*\u0026rdquo; faster, then we can sample much faster.\nIn our implementation, we store values mem-packed, with 2 bits representing 0/1/*: for us, 00=0, 01=1, 11=*. This way, we can simply memset() with 1-s and fill it all up with \u0026ldquo;*\u0026rdquo;, a common occurrence. It probably won\u0026rsquo;t surprise anyone that of course we tried using a sparse matrix representation as well. It works very well for some problems. However, it depends what the exact problem is, and the performance degrades drastically for many problems. So the system uses dense representation by default. I\u0026rsquo;d be happy to merge a pull request that flips between sparse and dense depending on some density metric.\nObviously, I could not have done any of this alone. Pepin, the tool \u0026amp; paper, is by Divesh Aggarwal, Sourav Chakraborty, Kuldeep S. Meel, Maciej Obremski, and myself. Honestly speaking, it was wonderful to work together with all these amazing people.\nPerformance At this stage, it should be obvious that it doesn\u0026rsquo;t even make sense to compare this tool to exact methods. The difference is mind-boggling. It\u0026rsquo;d be like racing a fighter jet against a rabbit. It\u0026rsquo;s a lot more fun to compare against other, existing approximate volume counting tools.\nAbove is a set of graphs of how Pepin performs against other approximate volume counting tools. Basically, it\u0026rsquo;s either way faster (easy 1000x speedup), or it\u0026rsquo;s a lot faster. Graph (c) is a bit misleading: for completeness, we included DNFApproxMC (PDF), which performs very poorly on these problems, and so Pepin seems to perform \u0026ldquo;as well as the others\u0026rdquo;. But, on closer examination, it\u0026rsquo;s about 3x faster than any other.\nPotential Future Work As mentioned above, a pretty straightforward (but not trivial) improvement would be to automatically switch to a sparse matrix representation. This would be akin to \u0026ldquo;making the horse run faster\u0026rdquo;, rather than inventing the steam engine, but hey, if it works, it works. Building a steam engine would be more like putting the whole algorithm into GPGPU and/or parallelizing it. It should be possible to rewrite this algorithm in a dynamic programming way, as it should be possible to combine sample bags and sampling probabilities (maybe not, I\u0026rsquo;m just an engineer). Then you can do divide-and-conquer. If you do that over a GPGPU that has 1000+ streaming cores, it could be possible to make this whole thing run 100x+ faster.\nAs engineers we like to over-engineer for performance, so it\u0026rsquo;s important to keep in mind that we are already hundreds of times faster than exact algorithms. Hence, perhaps it\u0026rsquo;d be more interesting to come up with interesting use-cases, rather than focusing on further improving speed. To keep with the horse analogy, it may be useful not to put the cart in front of the horse.\nClosing Thoughts Approximate volume counting is actually really cool. It takes the power of randomization and uses it to its own advantage to make something really difficult into something that one could explain a child. I have a feeling we could make a few beautiful graphics and teach this algorithm to 12 year olds. The sample-in-a-bag idea is so simple, yet so powerful. Actually, it\u0026rsquo;s also incredibly weird if you start going into the weeds of it. Like, what happens when the size of your bag is 1? It\u0026rsquo;s the kind of question that only Knuth would ask, and then answer with clarity and prowess that only one with deep mathematical insight can. I won\u0026rsquo;t even entertain the thought, but you can, if you read his notes and then work on his questions.\nPS: Pepin was named after the rather eccentric character of the same name from Bohumil Hrabal\u0026rsquo;s book Cutting It Short, also released as a film. Pepin in the book was inspired by Hrabal\u0026rsquo;s own uncle who came to visit his hometown for two weeks but stayed for 40 years. I think we have all been there.\n","permalink":"https://www.msoos.org/2023/09/pepin-our-probabilistic-approximate-volume-counter/","summary":"\u003cp\u003eLet\u0026rsquo;s say you are allowed to have cubes in a 3-dimensional space that happens to be binary. In this space, x1, x2, and x3 are the axis, and for example the cube x1=0 is a cube that happens to have 4 points in it: 000, 001, 010, and 011. So far, so good. Now, let\u0026rsquo;s say we need to calculate the total volume of two cubes in this space. If they don\u0026rsquo;t intersect, it\u0026rsquo;s quite easy, we simply add their volumes. But what if they intersect? Now we need to compute their overlap, and subtract it from their sum of volumes. But there is a better way.\u003c/p\u003e","title":"Pepin, our Probabilistic Approximate Volume Counter"},{"content":"After many years of work, I am very happy to present our new CNF model counting preprocessor, Arjun [ PDF][ static binary]. It improves upon our approximate model counter ApproxMC [ static binary], and can be used as a stand-alone binary to preprocess CNFs for (projected) model counting . Usage is simple:\n./arjun blasted_case110.cnf c Arjun Version: 43b17ef5899c461b8e947b0f3ca286efcf71464c c CMS SHA revision 9bf1d82a7b9fa5492cf4f0437cf7110b77ad7230 [..] c [arjun] original sampling set size: 284 c [arjun] final set size: 15 percent of original: 5.2817 % Here, Arjun took a CNF that had a projection set of 284 variables, and reduced it to an independent support of only 15 variables. Arjun is now part of ApproxMC by default. Let\u0026rsquo;s solve a problem with ApproxMC without Arjun:\n./approxmc --arjun 0 blasted_squaring42.cnf.gz.no_w.cnf.gz c ApproxMC SHA revision 9fb4fdd01b40cc0526c4933e2f2dca402f0ab91f c CMS SHA revision 9bf1d82a7b9fa5492cf4f0437cf7110b77ad7230 c [appmc] Orig sampling vars size: 349 [after waiting 5000 seconds, it times out] Now let\u0026rsquo;s do the same with Arjun (this does not use code from SharpSAT-td):\n./approxmc blasted_squaring42.cnf.gz.no_w.cnf.gz c ApproxMC SHA revision 9fb4fdd01b40cc0526c4933e2f2dca402f0ab91f c CMS SHA revision 9bf1d82a7b9fa5492cf4f0437cf7110b77ad7230 c Arjun SHA revision 43b17ef5899c461b8e947b0f3ca286efcf71464c c [appmc] Orig sampling vars size: 349 c [arjun] final set size: 155 percent of original: 44.4126 % c [appmc+arjun] Total time: 12.80 c [appmc] Number of solutions is: 80*2**127 s SATISFIABLE s mc 13611294676837538538534984297270728458240 Done in 12.8 seconds, NICE. Wanna try it out? Arjun+ApproxMC static Linux binary HERE, Arjun static Linux binary HERE. Research paper HERE. Arjun code HERE. Now that the demo is out of the way, let\u0026rsquo;s get into the nitty-gritty details!\nProjected Model Counting CNF model counting is the problem where you want to count the number of solutions to a set of equations written in the CNF form. This form is quite restrictive, but also very powerful, here is an example:\nx1 OR x2 OR -x3 = True x1 OR -x2 = True x1 OR -x3 = True x1 OR -x4 = True -x1 OR x4 = True The above set of constraints clearly have a solution, e.g. setting x1=True and x4=False will satisfy all constraints. The question in model counting is how many solutions a system has. The above problem has 5 solutions in total:\n[Where \u0026#34;1\u0026#34; means TRUE and \u0026#34;-1\u0026#34; means FALSE] x1 x2 x3 x4 ----------------- -1 -2 -3 4 0 1 2 3 -4 0 1 2 -3 -4 0 1 -2 3 -4 0 1 -2 -3 -4 0 This was kinda easy. However, there are two complications. One complication tends to be is that there are a massive number of solutions. For example, there are 2^200 solutions. Enumerating them one-by-one is just not going to work. Hence, we need some smart systems to do the counting for us, that don\u0026rsquo;t count one-by-one. Secondly, often we are interested only in the distinct number of solutions over a certain set of variables. Let\u0026rsquo;s take the above example, and say we want the distinct number of solutions over variables x1, x2 and x4 only. So, let\u0026rsquo;s delete column for x3 from above table:\nx1 x2 x4 Same? ------------------- -1 -2 4 0 1 2 -4 0 * 1 2 -4 0 * 1 -2 -4 0 + 1 -2 -4 0 + Notice there are only 3 distinct solutions: the rows marked with * are both the same, and the rows marked with + are also the same. This is called projected counting because we are projecting the solution space over a specific set of variables \u0026ndash; in this case, x1, x2, and x4.\nComputing the Independent set of a Projection Set In the above example, our projection set was x1, x2, and x4. However, notice that x1=-x4, due to the constraints:\nx1 OR -x4 = True -x1 OR x4 = True Hence, it is good enough to count over x1 and x2, since x4 is determined by x1 and so x4 cannot possibly make the distinct number of solutions smaller or larger. This realization is at the heart of calculating an independent support \u0026ndash; we basically want to minimize the set of variables that we project over. The independent support is simply a subset of the projection set, that\u0026rsquo;s hopefully a lot smaller than the projection set.\nAn early work on independent support calculation is the B+E preprocessor [ PDF], which aims to do two things: \u0026ldquo;B\u0026rdquo; which finds a small independent support, and \u0026ldquo;E\u0026rdquo;, which eliminates variables from the problem. Let\u0026rsquo;s concentrate on \u0026ldquo;B\u0026rdquo; here. In the B+E paper, the authors talk about independent support over all variables of the formula, not over a projection set. In other words, their code and paper originally was conceived to minimize a projection set that had all variables inside. In our case, their work would minimize x1..x4, finding that x1,x2,x3 is an independent support of x1..x4.\nImplicit Definability The trick of B+E is to use the idea of so-called implicit definability. Implicit deniability is really simple. If I take x1, x2 and x3, does that define the value of x4? Yep. In fact, x1 on its own would define the value of x4, because x1=-x4. However, sometimes you have equations that define a variable through a (large) number of other variables. For example:\nx30 OR -x10 OR -x20 = True -x30 OR x10 = True -x30 OR x20 = True This set of constraints describe x10 AND x20=x30. In this case, x10 and x20 together define x30. So if you have the above set of constraints in a CNF, and you have x10, x20, and x30 all in your projection set, you can confidently take out x30 from the set \u0026ndash; and the number of distinct solutions projected will not change.\nImplicit definability states that we can find these definitions in an implicit way, using a relatively straightforward system. We make two copies of the CNF, let\u0026rsquo;s call these CNF1 and CNF2. Then, we have variables v1\u0026hellip;vN in the first CNF and w1..wN in the second CNF. Now, we create new variables called indicator variables, i1\u0026hellip;iN that indicate whether v1=w1, v2=w2\u0026hellip; etc. After this setup, the query is simple. Given i1=TRUE (i.e. given v1=w2), is it possible that v2 is different from w2? If it is, then our new independent set must contain both i1 and i2 (If not, we can get rid of i2). Now we move to i3. Let\u0026rsquo;s set i1=TRUE and i2=TRUE, and ask if it is possible that v3 is different from w3? Otherwise, our independent set remains i1, and we ask, is it possible that i1=TRUE and i2=TRUE, but v3 is different from w3? etc. This way, we test all the variables from v/w1\u0026hellip;v/wN, and eventually end up with a set of indicator variables that tell us a minimal independent support.\nExplicit Definability As an external observer, without knowing nothing about implicit definability, CNF copying and renumbering and the like, it is quite easy to figure out that x1=-x4 just by looking at the CNF, since it contains:\nx1 OR -x4 = True -x1 OR x4 = True Such set of constraints can be trivially found using Tarjan\u0026rsquo;s algorithm. This is actually linear in the number of binary (i.e. 2-long) constraints, so this is super-quick to run. Similarly, we can very easily find the AND gate x10 AND x20=x30:\nx30 OR -x10 OR -x20 = True -x30 OR x10 = True -x30 OR x20 = True It\u0026rsquo;s a quick check on all the constraints that are 3-long and have the corresponding 2-long constraints. Such syntactic checks are well-known parts of SAT solvers. For example, the extremely successful kissat solver has the following lines of code in gates.c:\nif (kissat_find_equivalence_gate (solver, lit)) res = true; else if (kissat_find_and_gate (solver, lit, 0)) res = true; else if (kissat_find_and_gate (solver, not_lit, 1)) res = true; else if (kissat_find_if_then_else_gate (solver, lit, 0)) res = true; else if (kissat_find_if_then_else_gate (solver, not_lit, 1)) res = true; else if (kissat_find_definition (solver, lit)) res = true; So, kissat finds equivalence gates (i.e. x1=x2), AND gates (like x10 AND x20=x30), IF-THEN-ELSE gates, and curiously\u0026hellip; \u0026ldquo;definition\u0026rdquo; gates. What could these be? Well, it turns out kissat uses a very cool trick to find definitions. It takes all constraints that contain a variable, say x30/-x30, and cuts off the x30/-x30:\n-x10 OR -x20 = True \u0026lt;-- we cut of \u0026#34;x30 OR\u0026#34; x10 = True \u0026lt;-- we cut of \u0026#34;-x30 OR\u0026#34; x20 = True \u0026lt;-- we cut of \u0026#34;-x30 OR\u0026#34; Notice that this set of constraints is now unsatisfiable. In fact, for all gates that define a variable, if you take all the constraints that the variable is in, and you chop off the variable, the constraints will together be unsatisfiable. To find such gates, kissat uses a SAT solver called kitten. Kitten solves these problems really fast and allows for UNSAT core extraction (not present in kissat) to find the defining variables.\nArjun So what did we do with Arjun? We basically do the following set of improvements over B+E \u0026ndash; while not even once looking at B+E\u0026rsquo;s code, since it was close-sourced, and by the time the authors open-sourced it, we already had our paper in the review queue:\nWe allow taking in a projection set, rather than the full set of variables like B+E does. This allows us to compute and independent support of a projection set, which is extremely important for our model counter ApproxMC. With a small independent support, ApproxMC uses a smaller matrix, so Gauss-Jordan elimination, which is an O(n^3) algorithm in our implementation, is significantly faster. We use CryptoMiniSat to our advantage to simplify the CNF formula before running explicit or implicit definability detection. CryptoMiniSat is a powerful system that allows fine-tuned set of heuristics to be run, completely controlled from the API, e.g. \u0026ldquo;auto str = string(\u0026ldquo;intree-probe, occ-backw-sub-str, distill-bins, \u0026ldquo;); solver.simplify(NULL, \u0026amp;str);\u0026rdquo; We use all the different ways to syntactically recover gates: and/or gates, if-then-else gates, and parity (XOR) constraints. We also recover gates semi-syntactically using picosat (instead of kitten) \u0026ndash; this is semi-syntactic, because we use syntactic methods to get the occurrence list of a variable and to construct the SAT query, but then use a SAT solver (i.e. a semantic method) to recover the definition, if any. We then construct a directed graph from the gates and greedily find a minimum cover. This is needed because there could be loops, and we don\u0026rsquo;t want x1 to be defined by x2, and x2 being defined by x1, and accidentally remove both, which would be silly. We repeat steps 2 \u0026amp; 3 at least 2x to make sure it\u0026rsquo;s done to a good enough level. This allows us to save time on the expensive next step, implicit definability detection. At this stage, we also do empty occurrence detection \u0026ndash; if a variable is in the projection set, but doesn\u0026rsquo;t even occur in the formula, then obviously the variable can be removed and the count increased by a factor of 2. We change the SAT solver\u0026rsquo;s assumptions method to improve implicit definability detection. From the standpoint of a SAT solver, the queries mentioned in the implicit definability section are so-called assumption queries: assuming i1=TRUE, v2=TRUE, v3=FALSE, is there a solution? The list of assumptions tends to be very long here, so SAT solvers can struggle. Our insight here is to change the traditional way of how assumptions are handled in the SAT solver, and effectively make the SAT solver not backtrack to the beginning every time a query is made. This makes quite a bit of difference in performance.(Note: it turns out this improvement idea has been invented, and re-invented, a few times already, e.g. by SharpSAT-td, and by IntelSAT \u0026ndash; see Alexander Nadel\u0026rsquo;s presentation at SAT 2022). That\u0026rsquo;s all folks! These improvements add up to about 5k LoC of code. All in all, they make Arjun more than an order of magnitude faster than B+E, and it can compute an independent support over a projection set, rather than all variables in the formula.\nPerformance of Arjun Here\u0026rsquo;s an example performance graph for B+E vs Arjun, using the set of benchmark instances we have been measuring the performance of ApproxMC on for ~5 years now \u0026ndash; perhaps outdated, but at least it\u0026rsquo;s easy to compare all the values in all of our papers. The performance difference is quite big:\nBasically, in B+E took 4932 seconds to compute the independent set of 1752 instances, while Arjun did the same in 117 seconds. Quite nice, about 40x improvement. Notice that due to the way our implicit definability works, it\u0026rsquo;s possible to e.g. order the variables in such a way as to make querying faster, but end up with a larger independent set. So, here is the comparison of independent sets computed by the same system as per the graph above:\nEssentially, the same, modulo some noise. There is some advantage to using B+E in a few cases, and there is some advantage using Arjun in other cases, from the perspective of the calculated independent set. However, notice that Arjun is so much faster, that we could actually run it 2x with different variable ordering, thereby getting a (much) smaller independent set, and often still be a lot faster than B+E. However, there is always a trade-off, so we decided to be approximately as good in the minimization as B+E, while being significantly faster.\nPerformance Impact on ApproxMC So, Arjun is fast but what does that mean for ApproxMC? It turns out, it means a lot. ApproxMC adds XOR constraints over the projection set, and the smaller the projection set, the smaller the XORs . Hence, the matrix that the Gauss-Jordan elimination algorithm has to run on inside ApproxMC is much smaller \u0026ndash; which is an O(n^3) algorithm in our implementation. Hence, the performance of ApproxMC4 vs Arjun+ApproxMC4 is remarkable:\nBasically, we can count in 2.24 seconds with Arjun+ApproxMC4 as many instances as we could count in 5000s with ApproxMC4 alone: more than 3 orders of magnitude improvement. In fact, it\u0026rsquo;s so fast we\u0026rsquo;ll need to switch away from our set of benchmark instances, because we are getting close to the limit of 1896, the number of instances in total. Notice that over the years, ApproxMC has improved dramatically in speed. In fact, the earliest ApproxMC could only count ~400 instances within 5000 seconds. We can now count 400 instances within a time limit of only 0.09 seconds.\nConclusions As it may be evident from winning a number of tracks at the Model Counting Competition, Arjun is not only making ApproxMC faster \u0026ndash; we also won the non-projected exact(!) model counting track with an entry called Arjun+ SharpSAT-td, where SharpSAT-td [ PDF] is an exact model counter by Tuukka Korhonen and Matti Jarvisalo. We hope to improve Arjun further in the future, and we hope Arjun will be become a standard preprocessor for model counters in the Model Counting Competition in the coming years, exploiting its CNF reduction capabilities that are currently available as: \u0026ldquo;./arjun input.cnf minimized.cnf\u0026rdquo;, using code and ideas from SharpSAT-td.\n","permalink":"https://www.msoos.org/2022/08/arjun-our-new-cnf-model-counting-preprocessor/","summary":"\u003cp\u003eAfter many years of work, I am very happy to present our new CNF model counting preprocessor, \u003ca href=\"https://github.com/meelgroup/arjun\"\u003eArjun\u003c/a\u003e [ \u003ca href=\"/wordpress/wp-content/uploads/2022/08/arjun.pdf\"\u003ePDF\u003c/a\u003e][ \u003ca href=\"/largefiles/arjun-43b17ef58-9bf1d82a7-64blinux-static.gz\"\u003estatic binary\u003c/a\u003e]. It improves upon our approximate model counter ApproxMC [ \u003ca href=\"/largefiles/approxmc-9fb4fdd-9bf1d82a7-43b17ef58-64blinux-static.gz\"\u003estatic binary\u003c/a\u003e], and can be used as a stand-alone binary to preprocess CNFs for (projected) model counting . Usage is simple:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e./arjun blasted_case110.cnf\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ec Arjun Version: 43b17ef5899c461b8e947b0f3ca286efcf71464c\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ec CMS SHA revision 9bf1d82a7b9fa5492cf4f0437cf7110b77ad7230\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[..]\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ec [arjun] original sampling set size: 284\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ec [arjun] final set size:   15 percent of original: 5.2817 %\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eHere, Arjun took a CNF that had a projection set of 284 variables, and reduced it to an independent support of only 15 variables. Arjun is now part of ApproxMC by default. Let\u0026rsquo;s solve a problem with ApproxMC without Arjun:\u003c/p\u003e","title":"Arjun, our New CNF Model Counting Preprocessor"},{"content":"Uniform sampling is pretty simple: there are a set of solutions to a set of equations, and I want you to give me N solutions uniformly at random. Say, I have a set of equations that only has the solutions x=1\u0026hellip;6, and I ask you to give me solutions uniformly at random. In this case, if the system is not cheating, it should give me solutions exactly like a random dice would give: 1..6, each with the same probability of 1/6. Now, if you give me nothing but 1\u0026rsquo;s I\u0026rsquo;d be slightly confused, and eventually would think you may be trying to cheat.\nUniformity is useful not only in gambling, but also e.g. if you want to make sure to cover a good chunk of the potential states in a system. Say, your equations describe how a program can run. Now, uniform solutions to these equations will be examples of the state space of your program. If you want to check that your system is in most cases doing the right thing, you can ask for uniform solutions at random and check the states for inconsistencies or unexpected behaviors.\nUniform Sampling of CNFs One type of equations that is quite popular is to have all variables boolean (i.e. True/False), and equations being nothing but an \u0026ldquo;AND of ORs\u0026rdquo;, i.e. something like: \u0026ldquo;(a OR b) AND (b OR c OR d) AND (-f OR -g)\u0026rdquo;. These types of equations, also known as CNF, can express quite complicate things, e.g. (parts of) computer programs, logical circuits (e.g. parts of CPUs), and more. What\u0026rsquo;s nice about CNF is that there are many different tools to convert your problem language into CNF.\nGiven CNF as the intermediate language, all you need to do is run a uniform sampler on the CNF, and interpret the samples given your transformation. For example, you could translate your Ethereum cryptocurrency contract into QF_BV logic and blast that to CNF using e.g. the STP solver. Then you can get uniform random examples of the execution of your cryptocurrency contract using e.g. UniGen.\nThere are many different samplers for CNFs, and they mostly fall into two categories: ones that give guarantees and are hence truly uniform, and ones that don\u0026rsquo;t give guarantees and therefore fall into what we\u0026rsquo;ll call uniform-like samplers. These latter samplers tend to be significantly faster than truly uniform samplers, however, they can, and sometimes do, give non-uniform samples. I personally help maintain one truly uniform sampler, UniGen (PDF), and one uniform-like sampler, CMSGen (PDF). Other popular truly uniform samplers include KUS (PDF) and SPUR (PDF).\nCatching Uniform-Like Samplers: Barbarik If I give you a sampler and ask you to tell me if it\u0026rsquo;s truly uniform or simply uniform-like, what should you do? How should we distinguish one from the other, without looking into the internals of the system? It turns out that this is not a simple question to answer. It is very reasonable to assume that there are e.g. 2^200 solutions, so e.g. trying to prove that a sampler is uniform by saying that it should only output the same sample twice rarely is not really meaningful. In this latter case, you\u0026rsquo;d need to get approx 2^100 samples from a truly uniform sampler before it will likely give two colliding samples. While a uniform-like sampler may collide at e.g. only 2^60 (i.e. a trillion times earlier), that\u0026rsquo;s still a lot of computation, and only a single data point.\nDoing this efficiently is the question that was on the minds of the authors of Barbarik. Basically, their idea was the following: take a CNF, remove all solutions but two, and blow up these two solutions into equally many solutions each. Say, you find two solutions to a CNF, one BLUE and one RED. Barbarik will take BLUE, make 100 blue balls out of it, and take RED, and make 100 red balls out of it. Then, it will give the CNF with the 200 solutions, half blue, half red, to the sampler under test. Then it asks the sampler to give it a bunch of balls. We of course expect approx 50%-50% red-blue distribution of balls from a truly uniform sampler.\nBarbarik fails a solver if it is gives a distribution too far away from the 50%-50% we\u0026rsquo;d expect. Barbarik runs this check many times, with different example blue/red solutions that are \u0026ldquo;blown up\u0026rdquo; to multiple solutions. Given different base CNFs, and many tries, it is possible to differentiate the good from the bad\u0026hellip; most of the time:\nIf you take a look at the table above, QuickSampler and STS, both uniform-like samplers, are rejected by Barbarik given 50 different CNFs. In contrast, UniGen survives all 50 tests with flying colors. Notice, however, that CMGen also survived all tests.\nThe Birth of CMSGen When Barbarik was being created, I was fortunate enough to be present, and so I decided to tweak my SAT solver, CryptoMiniSat purely using command-line parameters, until Barbarik could not distinguish it from a truly uniform sampler. This, in my view, showcased how extremely important a test system was: I actually had a bug in CryptoMiniSat\u0026rsquo;s randomization that Barbarik clearly showed and I had to fix to get higher quality samples. We called the resulting uniform-like sampler CMSGen, and it was used in the function synthesis tool Manthan (PDF), that blew all other function synthesis system out of the water, thanks to its innovative design and access to high quality, fast samples from CMSGen:\nNotice that within 200 seconds Manthan outperformed all other function synthesis systems, even if we give the other system 7000 seconds to work with. If you are interested in the details of this crazy improvement over previous state-of-the-art, check out the slides here or the video here (these are all work of my coworkers, I am not an author).\nWhile CMSGen was clearly fast and powerful, it bothered me endlessly that Barbarik couldn\u0026rsquo;t demonstrate that it wasn\u0026rsquo;t a truly uniform sampler. This eventually lead to the development of ScalBarbarik.\nThe Birth of ScalBarbarik Since CMSGen passed all the tests of Barbarik, we had to come up with a new trick to distinguish it from truly uniform samplers. ScalBarbarik\u0026rsquo;s (PDF) underlying system is still the same as Barbarik: we take a CNF, take 2 samples from it, and blow both of these samples up to a certain number. However, how we blow them up is where the trick lies. Before, they were both blown up the same way into solutions that are equally easy/hard to find. However, this time around, we\u0026rsquo;ll make one of the solution types much harder to find than the other. For this, we\u0026rsquo;ll use Vegard Nossum\u0026rsquo;s SHA-1 CNF generator (PDF) to force the system to reverse a partial, reduced-round SHA-1 hash, with some fixed inputs \u0026amp; outputs. This allows us to both change the complexity of the problem and the number of solutions to it rather easily.\nWhile one set of solutions will be hard to find, the other ones will be trivial to find \u0026ndash; if one special variable is set to TRUE, the finding a set of solutions is trivial But when it\u0026rsquo;s set to FALSE, the system has to reverse a reduce-round SHA-1. The logic behind this is that the uniform-like systems will likely be finding the easy solutions with much higher probability than the hard solutions, so they will sample much more unevenly. Indeed that\u0026rsquo;s the case:\nNote that as the hardness parameter is increased, CMSGen is rejected more and more often, and eventually it\u0026rsquo;s rejected for all CNFs. Also interesting to note is that QuickSampler and STS get both rejected, as before, but this time around, STS gets rejected for all 50 CNFs, rather than for only 36 out of 50. In other words, ScalBarbarik is overall a stronger/better distinguisher.\nConclusions With the birth of Barbarik, a set of uniform-like testers were shown to be less than ideal, and a new, more robust near-uniform sampler was born, CMSGen. But as a the gauntlet has been throw down by CMSGen, a new tool emerged, ScalBarbarik, to help find the non-truly uniform samplers. With this cycle in mind, I hope that new, more elaborate, and higher-quality uniform-like samplers will emerge that will be able to beat ScalBarbarik at its own game, improving the quality of the sampling while maintaining the speed advantage that uniform-like samplers enjoy over truly uniform samplers. With better uniform-like sampling tools, hopefully we\u0026rsquo;ll be able to make headway in automated test case generation (imagine having it as part of all development IDEs), higher performance function synthesis, and hopefully even more diverse areas of interest for the general public.\n","permalink":"https://www.msoos.org/2022/06/checking-uniform-like-samplers/","summary":"\u003cp\u003eUniform sampling is pretty simple: there are a set of solutions to a set of equations, and I want you to give me N solutions uniformly at random. Say, I have a set of equations that only has the solutions x=1\u0026hellip;6, and I ask you to give me solutions uniformly at random. In this case, if the system is not cheating, it should give me solutions exactly like a random dice would give: 1..6, each with the same probability of 1/6. Now, if you give me nothing but 1\u0026rsquo;s I\u0026rsquo;d be slightly confused, and eventually would think you may be trying to cheat.\u003c/p\u003e","title":"Checking Uniform-Like Samplers"},{"content":"The NIST Cybersecurity Framework\u0026rsquo;s five Functions are: Identify, Protect, Detect, Respond, and Recover. Within this framework \u0026ldquo;shift left\u0026rdquo; means that we shift our focus towards Identify and Protect, i.e. towards fixing issues before our system is deployed into production. Say, if you have a bug in your Apple Store/Google Play app, you\u0026rsquo;d prefer fixing it before you deploy it to the internet, or, similarly you prefer fixing the bug in your cryptocurrency contract before you deploy it in the wild (i.e. \u0026ldquo;on the mainnet\u0026rdquo;). While shift left makes lots of sense (let\u0026rsquo;s prevent the issue in the first place!), in many cases, preventing all issues is likely impossible.\nShifting Left Firstly, it is important to state that preventing all issues is often impossible because of what safety practitioners call the \u0026ldquo;blunt end\u0026rdquo;. When writing code, practitioners, i.e. developers, are at what safety literature would call the \u0026ldquo;sharp end\u0026rdquo;: they are like airplane pilots, directly at the control of their craft. While it\u0026rsquo;s easy to imagine that pilots are in \u0026ldquo;full control\u0026rdquo;, in reality, airplane pilots depend on and are affected by many things: accurate weather reports, quality and amount of training, certification bodies, proper aircraft maintenance, production pressure from corporate, etc. These are what safety literature calls the \u0026ldquo;blunt end\u0026rdquo; \u0026ndash; things that contribute to both success and failure, but are not directly visible/obvious. When the 10th plane drops out of the sky this same year, and Boeing keeps blaming the (now dead) pilots, you know it\u0026rsquo;s the blunt end you ought to be looking at.\nWhat this boils down to in terms of shift left is that while developers are in \u0026ldquo;full control\u0026rdquo;, in reality, there is a large blunt end that they have little to no control over, and which may set up the conditions such that failure is sometimes inevitable, even with the most careful of developers. An easy example of this is previously unknown vulnerability classes: for example unknown issues with CPU cache timing side-channels in classical IT security, or flash loan attacks for cryptocurrency contracts, which are a relatively new phenomenon, allowing anyone to instantly obtain a large capital for a fraction of time to break assumptions about a contract, which can help attackers. Another slightly less obvious example is production pressure, where competing entities are known to be working on the same idea/system and releasing first is critical for business success. It is one thing to \u0026ldquo;ask for time\u0026rdquo;, it\u0026rsquo;s another thing when you gotta release or it was all for nothing. While techniques like fuzzing, formal verification, coding best practices, etc. can help, they are neither bulletproof, nor are they reasonable to expect to be done fully for all contracts.\nNotice that given the nature of cryptocurrencies where \u0026ldquo;code is the law\u0026rdquo;, it seems counter-intuitive to think that there are factors at play other than the code itself. On the surface, the rules of the game seem set and all mistakes seem to happen to/with code, hence the culprit is always clear. In other words, it seems as if there is no \u0026ldquo;blunt end\u0026rdquo;. However, as with all interesting endeavors, in my view, blunt ends are abound, even if they only manifest themselves in code in subtle ways. For example, before overflow protection was enabled by default on the most used Ethereum compiler, Solidity, overflow issues were possible (e.g. issues where 255+1=0, oops!), and could have lead to attacks. In other words, changing the compiler defaults can prevent a type of attack. Similarly, the SMT Checker, shipped as part of Solidity and Remix, can also warn developers of potential mistakes. These systems change the landscape, preventing the \u0026ldquo;sharp end\u0026rdquo;, i.e. developers, from making mistakes.\nShifting Right The IT security sector has realized for some time now that spending all their effort on shift left, i.e. identifying issues and preventing them pre-deployment, is not adequate. With some effort, time, and money being spent on detection, adequate response, and recovery, i.e. post-deployment and hence on the \u0026ldquo;right\u0026rdquo; side, the impact of attacks or unforeseen events can be minimized. This is incredibly important, because as per above, it is often impossible to prevent all attacks. From phishing attacks, novel attack classes, persistent attackers, to production pressures, some attacks will go through, and be successful \u0026ndash; at which point the only question is how successful will they be, i.e. will they reach all (or any) of their intended goals, or will they be stopped early, minimizing the damage caused.\nThere are some interesting properties of spending proper time dealing with post-production incidents. Firstly, it allows the system designers and developers to understand what attack patterns are typical against systems. In classical IT security, e.g. honeypots are often used to understand attacker behavior. These are (often under-protected) systems deployed either on the public internet, or more interestingly, on the intranet(s) of organizations, to see if (and how) attackers try to attack it. These systems can help spot (novel) attack patterns, and attackers in general. Other information-sharing systems are also in-place in the traditional IT security world: in Germany the BSI is responsible to warn large enterprises of (novel/successful) attack patterns in the wild. Within the space of cryptocurrencies, attacks tend to be on the public chain, and can be observed directly both as they happen (unless they are in a so-called private mempool, more on this later), and retrospectively, thanks to the public ledger. There is plenty to learn from how others succeed, or fail.\nMEV, and On-Chain Security-as-a-Service With all the above out of the way, let\u0026rsquo;s get to the meat of this article: how behavior patterns in the cryptocurrency world that are often cited as undesirable are actually doing a form of shift right. This inadvertent shift right is something I believe we could exploit to improve the safety of the chain overall.\nGeneralized frontrunning is a technique that consists of people listening to the set of sent, but unconfirmed transactions on the chain, and seeing if copying the same transaction themselves would make them money. They then submit the same transaction with a higher fee, giving more fee to the miners who confirm transactions. This leads to both transactions being executed, but theirs being executed first (and the 2nd likely failing), thereby giving them the money. Clearly, miners (who confirm transactions) could always do such frontrunning, and could do it much easier, since they decide who is going to be first, so they can make themselves first without paying a higher (or any) fee. Transaction frontrunning is slightly more complicated: it tries to both front- and back-run a transaction (also called sandwiching), manipulating the price before the transaction is executed (the \u0026ldquo;front\u0026rdquo; part) and then selling the excess (the \u0026ldquo;back\u0026rdquo; part). Generalized and transaction frontrunning attacks all fit under the umbrella of transaction reordering attacks and are also called Miner Extractable Value, or MEV for short. MEV is big business, with 8 million USD extracted in the past 30 days on the Ethereum chain, as of writing.\nWhen you perform generalized frontrunning, you do two things: (1) you constantly check for potential value to be extracted, such an attack would do, and (2) you make sure your transaction runs first (hence the name \u0026ldquo;front-run\u0026rdquo;) that extracts the value to get the value for yourself. This clearly maps to the post-deployment part of the Cybersecurity Framework of NIST: detect \u0026amp; respond. In other words, it would actually make sense to constantly run a bot on-chain to detect and front run attacks against your own contracts. In a sense, the frontrunners are operating what in the traditional IT security world would be called a SOC \u0026ndash; a Security Operations Center that is constantly on the lookout for attacks.\nIn this sense, MEV is not undesired, but a price to pay to have a non-stop security system. Of course, it is not a given that MEV bot operators extracting MEV will give back your money for the attack they front-ran. However, I posit that it\u0026rsquo;s much more likely that you\u0026rsquo;ll get your money back from them than the attackers. For example, at the MEV day for Devconnect, there was a discussion I participated in where a large MEV bot operator mentioned that they were willing to give back the funds of attacks they front-ran for a 10% fee. I expect that large organizations will in the future run their own MEV bots, and medium-sized ones will either simply pay the fee (10% or whatever it will be) when an attack happens, or perhaps pay a monthly fee for the protection service provided.\n(Footnote: there is not only bad MEV. For example, backrunning (i.e. running after) liquidation events are incentivized to happen, and are considered normal for the system to run as designed.)\nCurrent Solutions to MEV, and their Impact There are two obvious ways to deal with the MEV issue: creating economic incentives to reduce their impact, and hiding pending transactions. Let\u0026rsquo;s to to get into both.\nOne way to deal with MEV is by not making pending transaction visible. So-called private mempools are operated by some miners (i.e. confirmers of transactions) that don\u0026rsquo;t allow the public to see the not-yet confirmed transactions. This is advantageous because it means that attackers cannot run clients to frontrun/sandwich/etc. pending transactions sent to these private mempools. In a way, private mempools are kind of a trusted environment, where you can be safe from people trying to extract MEV. However, it also means that malicious behavior submitted to these private pools cannot be front-run. Since these private pools are trust-based, it would be possible to allow some trusted parties to observe these private pools and frontrun attacks. Rather than being purely trust-based, it is possible that some sort of incentives-based system could also be set up, which seems like an open question/potential for improvement. This would be similar to what Flashbots does. Flashbots tries to use economic incentives through an open marketplace to make MEV extraction less disruptive to the ecosystem (among other benefits). However, it does not work for private mempools, since, well, they are private, and Flashbots requires publicly visible unconfirmed transactions to be able to work, due to its open marketplace concept.\nMEV is not only big business, it\u0026rsquo;s also wasteful: often, the original transaction will fail, but still execute, consuming computational resources and burning money. MEV systems trying to outbid one another for the prize are effectively participating in an all-pay auction, i.e. everyone pays for the good but only one gets it. Thankfully Flashbots solves this by running an off-chain auction that is not all-pay. However, once we move from proof-of-work to proof-of-stake (i.e. to ETH 2.0), the attack transaction can be directly proposed to the next validator, skipping the public pool entirely. Essentially, the attacker can choose be in the private mempool by default (with some caveats, see Proposer-Builder Separation, and MEV-Boost), rather than by exception.\nConclusions While Miner Extractable Value (MEV) seems on the surface to be an undesirable side-effect of the combination of current cryptocurrency protocols and the public nature of digital ledgers, it can also be seen as a feature. This feature could allow one to perform detection \u0026amp; response to attacks, allowing legitimate entities to mitigate the impact of attacks on contracts post-deployment. There is some evidence that some people running MEV extraction bots are already effectively providing a form of post-deployment attack-mitigation-as-a-service for a fee. However, as usual, preventative measures are both more reliable and cheaper, and should be the focus of most efforts against attacks.\n","permalink":"https://www.msoos.org/2022/05/a-tale-of-shift-left-shift-right-and-mev/","summary":"\u003cp\u003eThe NIST \u003ca href=\"https://www.nist.gov/cyberframework/online-learning/five-functions\"\u003eCybersecurity Framework\u0026rsquo;s five Functions\u003c/a\u003e are: Identify, Protect, Detect, Respond, and Recover. Within this framework \u0026ldquo;shift left\u0026rdquo; means that we shift our focus towards Identify and Protect, i.e. towards fixing issues before our system is deployed into production. Say, if you have a bug in your Apple Store/Google Play app, you\u0026rsquo;d prefer fixing it before you deploy it to the internet, or, similarly you prefer fixing the bug in your cryptocurrency contract before you deploy it in the wild (i.e. \u0026ldquo;on the mainnet\u0026rdquo;). While shift left makes lots of sense (let\u0026rsquo;s prevent the issue in the first place!), in many cases, preventing all issues is likely impossible.\u003c/p\u003e","title":"A Tale of Shift Left, Shift Right, and MEV"},{"content":"If you have a look at a modern SAT solver, say kissat or CryptoMiniSat, you\u0026rsquo;ll see that they have well over 20k lines of code. Reviewing that for bugs is basically impossible. So how can you trust that the solver is giving a correct result? Well, if the result is that the input formula is satisfiable, it\u0026rsquo;s quite easy \u0026ndash; we can simply substitute the solution (all modern SAT solvers provide a satisfying assignment) to the formula, and it should satisfy each constraint. This is really fast to do, linear in the size of the formula.\nHowever, if the solver gives a result that the formula is unsatisfiable (UNSAT), what do we do? Well, we need some form of assurance. One would be to check the code, but again, that\u0026rsquo;s just too much work. We could run it with another SAT solver, but there have been cases of the same bug being in more than one solver. Actually, this bug seems to have been a conceptual mistake copy-pasted, quite weird. In fact, there is a well-known GCC version that will miscompile most MiniSat-based SAT solvers such that they report wrong results(!). We could also do some fuzzing, but do you want to sit on an airplane knowing its flight control software was fuzz-tested for a full 10 minutes to \u0026ldquo;meet\u0026rdquo; compliance requirements? No. We need strong assurances. So, let\u0026rsquo;s ask the SAT solver to produce a proof for the UNSAT result! This is what proof traces are all about.\nThe Binary Resolution Operator At its core, a proof trace essentially records the set of operations that must be performed by a system to arrive at the 0=1 equation (i.e. at obvious nonsense), starting with the input equations. Let\u0026rsquo;s see a simple example. Let\u0026rsquo;s have our input formula (so-called CNF) be:\nx1 V x2 = TRUE x1 V -x2 = TRUE -x1 V x2 = TRUE -x1 V -x2 = TRUE Where x1 and x2 are boolean variables. Actually, let\u0026rsquo;s make this a bit easier to read by a computer:\n1 2 0 1 -2 0 -1 2 0 -1 -2 0 This the same as the above, but closer to the standard DIMACS format. Each line is called a clause, each line is made up of literals like 1, -1, 2, and -2, and each clause is terminated by a \u0026ldquo;0\u0026rdquo;, marking the end of the clause.\nThe above CNF has no solution to its set of clauses: no matter what we set x1 and x2, at least one of the clauses is not satisfied. OK, so how do I prove that there is no solution? Well, the easiest way to do it is through the binary resolution operator. The binary resolution basically says that if two clauses have one literal that\u0026rsquo;s inverted, such as \u0026ldquo;x1\u0026rdquo; and \u0026ldquo;-x1\u0026rdquo;, then we can do this: (A OR x1) RESOLVE (B OR -x1) =\u0026gt; A OR B, where \u0026ldquo;A\u0026rdquo; and \u0026ldquo;B\u0026rdquo; are any set of literals. So, e.g. \u0026ldquo;x1 V x2 V -x3\u0026rdquo; resolved with \u0026ldquo;x3 V x4\u0026rdquo; becomes \u0026ldquo;x1 V x2 V x4\u0026rdquo;. Nice, so let\u0026rsquo;s try to prove that the above problem is unsatisfiable:\n1 2 0 RESOLVE 1 -2 0 =\u0026gt; 1 0 -1 2 0 RESOLVE -1 -2 0 =\u0026gt; -1 0 1 0 RESOLVE -1 0 =\u0026gt; 0 In essence, we resolved 2 clauses to prove that x1 is TRUE, then resolved another two to prove that x1 is FALSE, and then we resolved \u0026ldquo;x1\u0026rdquo; with \u0026ldquo;-x1\u0026rdquo; to arrive at EMPTY=TRUE, i.e. 0=1, which is obviously nonsense.\nThe RUP notation In the so-called RUP notation (\u0026ldquo;Reverse Unit Propagation\u0026rdquo;), the above is simply written as:\na 1 0 a -1 0 a 0 Basically, we simply write down each derived clause one after the other as \u0026ldquo;added\u0026rdquo; (=\u0026ldquo;a\u0026rdquo;). It\u0026rsquo;s called Reverse Unit Propagation, because it\u0026rsquo;s possible to prove each of these clauses to be correct, by starting from the top, and performing simple propagation [where propagation is substitution of the values into the equations, and checking if any variable is forced to a value] . Let me explain. Say we want to prove \u0026ldquo;1 0\u0026rdquo; is correct. Then, we set all the literals\u0026rsquo; inverted values, here, \u0026ldquo;x1=FALSE\u0026rdquo;, and propagate on the original clauses plus any clause that\u0026rsquo;s above \u0026ldquo;1 0\u0026rdquo; (and hence has been proven to be correct). If we set x1=FALSE, then the original formula\u0026rsquo;s clause \u0026ldquo;1 2 0\u0026rdquo; will propagate x2=TRUE and then the original formula\u0026rsquo;s \u0026ldquo;1 -2 0\u0026rdquo; conflicts immediately (all its literals are now FALSE). Hence, propagation lead to a conflict! This means that indeed, \u0026ldquo;1 0\u0026rdquo; must hold.\nWhat\u0026rsquo;s important to realize here is that each of the lines of the proof must be checkable by simple propagation. Let\u0026rsquo;s say we have this set of constraints:\n8 9 2 3 0 8 9 -2 3 0 8 9 4 -3 0 8 9 -4 -3 0 Given these constraints, it is fairly easy to check that \u0026ldquo;8 9 0\u0026rdquo; holds. However, we can\u0026rsquo;t just write into the proof that \u0026ldquo;a 8 9 0\u0026rdquo;. Because for that, the propagation check as explained above should succeed: when I set both x8=FALSE and x9=FALSE, I should get the a conflict. But I don\u0026rsquo;t! Instead when I substitute x8=FALSE and x9=FALSE in to the equations, I get this reduced formula:\n2 3 0 -2 3 0 4 -3 0 -4 -3 0 Which does not force any variable to any value (i.e. they don\u0026rsquo;t propagate anything) and none of them are the empty clause, so I\u0026rsquo;m stuck. The proof verifiers literally will say they are \u0026ldquo;stuck\u0026rdquo;. So, how I can prove \u0026ldquo;x8 OR x9\u0026rdquo;? Let\u0026rsquo;s do it like this:\na 8 9 -3 0 a 8 9 3 0 a 8 9 0 Let\u0026rsquo;s see how this works. First, let\u0026rsquo;s try to validate \u0026ldquo;8 9 -3\u0026rdquo; by setting v8=FALSE, v9=FALSE, v3=TRUE. Then the original constraint \u0026ldquo;8 9 4 -3 0\u0026rdquo; will propagate v4=TRUE, and the original constraint \u0026ldquo;8 9 -4 -3 0\u0026rdquo; will be immediately conflicting (all its literals are now FALSE). So simple propagation fails, hence the clause \u0026ldquo;8 9 -3\u0026rdquo; must be correct. While this is not the goal (that\u0026rsquo;s \u0026ldquo;8 9 0\u0026rdquo;), we are getting there. We now prove \u0026ldquo;8 9 3\u0026rdquo; in a similar fashion, and then we prove \u0026ldquo;8 9 0\u0026rdquo; in the same fashion. Easy!\nFaster Proof Verification: DRUP While RUP is indeed a good format, we don\u0026rsquo;t always need all the constraints to be in the active set in order to prove UNSAT. Let\u0026rsquo;s quickly re-visit this CNF, and try to prove \u0026ldquo;8 9 0\u0026rdquo;:\n8 9 2 3 0 8 9 -2 3 0 8 9 4 -3 0 8 9 -4 -3 0 In order to reduce memory load, let\u0026rsquo;s delete all the clauses we don\u0026rsquo;t need after we used them! These steps are going to be noted with \u0026ldquo;d\u0026rdquo; (=\u0026ldquo;delete\u0026rdquo;) instead of \u0026ldquo;a\u0026rdquo; (\u0026ldquo;add\u0026rdquo;):\na 8 9 -3 0 d 8 9 4 -3 0 d 8 9 -4 -3 0 a 8 9 3 0 d 8 9 -2 3 0 d 8 9 2 3 0 a 8 9 0 d 8 9 -3 0 d 8 9 3 0 NICE! So we first derived \u0026ldquo;8 9 -3 0\u0026rdquo; and then removed both of the clauses we used to create it, they are not needed anymore! Begone \u0026ldquo;8 9 4 -3 0\u0026rdquo; and \u0026ldquo;8 9 -4 -3 0\u0026rdquo; ! Same thing with \u0026ldquo;8 9 3 0\u0026rdquo;. Then, once we derived \u0026ldquo;8 9 0\u0026rdquo;, we even deleted the intermediary constraints \u0026ldquo;8 9 -3 0\u0026rdquo; and \u0026ldquo;8 9 3 0\u0026rdquo; we previously derived. Begone! Not needed anymore, all we need is \u0026ldquo;8 9 0 \u0026ldquo;.\nExtended resolution for proofs Okay, I\u0026rsquo;m gonna cut this part short, mostly because I am terrible at this, but we have talk about the elephant in the room: RAT, or, more beautifully, Resolution Asymmetric Tautologies. So, what is it? Essentially, it allows you to declare new variables in your proof and use them later. This is absolutely amazing, because with this, you can provide so-called extended resolution proofs (warning: 1968 research paper), which allows us to express certain proofs more compactly, in fact, exponentially more compactly!\nHere\u0026rsquo;s how to do it. Let\u0026rsquo;s say you want to use the definition \u0026ldquo;x1 OR v2 = x99\u0026rdquo; in your proof, because it would make your proof smaller. This can happen, for example, because your constraints often have \u0026ldquo;x1 OR x2\u0026rdquo; in them, and now you can replace all of those parts with simply \u0026ldquo;x99\u0026rdquo;. Well then, you write this into your proof file:\na -99 2 1 0 a 99 -1 0 a 99 -2 0 Notice that this is just a simple OR gate definition. The only thing RAT requires is that (1) the first variable is the one that\u0026rsquo;s being defined and (2) the introduced variable must not be part of our input formula \u0026ndash; so our input formula here should have at most 98 variables. That\u0026rsquo;s it. Now you can use x99 anywhere you like, as long as it makes sense. For example, you could take a clause \u0026ldquo;1 2 3 4 0\u0026rdquo; and convert it to \u0026ldquo;99 3 4 0\u0026rdquo;:\na 99 3 4 0 d 1 2 3 4 0 Notice that \u0026ldquo;99 3 4 0\u0026rdquo; is simply a RUP proof at this point: setting 99=FALSE, 3=FALSE, 4=FALSE will immediately propagate x1=FALSE, x2=FALSE (due to the clauses \u0026ldquo;99 -1 0\u0026rdquo; and \u0026ldquo;99 -2 0\u0026rdquo;), and x1,x2,x3, and x4 all being FALSE will immediately trigger a conflict for clause \u0026ldquo;1 2 3 4 0\u0026rdquo;, so we have the RUP property and we are fine. Then we can delete \u0026ldquo;1 2 3 4 0\u0026rdquo;, we don\u0026rsquo;t need it no more. Notice that I can\u0026rsquo;t write the reverse:\nd 1 2 3 4 0 a 99 3 4 0 If I wrote that, \u0026ldquo;a 99 3 4 0\u0026rdquo; will not work, since it relies on \u0026ldquo;1 2 3 4 0\u0026rdquo; but we already deleted that, oops!\nBesides the above trivial example with the OR gate, extended resolution can simulate, in polynomial time, some algorithms that are extremely hard (read: exponentially hard) for normal resolution to express. This means that using RAT, we can express even complicated mathematical concepts in this extremely simple system, for example in this case, pseudo-boolean reasoning.\nWhat the solver does vs. what the proof checker does So let\u0026rsquo;s say you implement DRAT proof trace into your SAT solver and your proofs are always verified. All good! Not so fast. One day you decide to check the proof that DRAT recovered, and to your absolute horror, you realize that DRAT thinks your proof to be substantially different than what the SAT solver thought it was! How can that be?\nWell, the DRAT checker recovered a proof. It\u0026rsquo;s a valid proof, and it can be recovered given the set of clauses that haven\u0026rsquo;t been deleted using the \u0026ldquo;d\u0026rdquo; operator, as above. But notice that we never told the proof checker which set of clauses we resolved on to get to a clause! It just kind of figured it out by itself. Now, we can look at this and say, this is great because (1) I don\u0026rsquo;t have to do hand-holding of the proof checker, and really interestingly, (2) the proof checker could actually recover different proofs from the same proof trace(!). Ambiguity can be useful. Well, that\u0026rsquo;s great, but what if I really-really want to know what the SAT solver actually did?\nEnter FRAT. This proof format is super-close to DRAT, with the following changes. Firstly, FRAT numbers each clause with a unique clause ID. This is needed because the same clause can be in the solver\u0026rsquo;s memory more than once, and we need to be able to distinguish them from each other \u0026ndash; they may have been derived in completely different ways! Secondly, FRAT allows an optional hint at how the clause was derived. Let me give a hands-on example, it should be quite clear. As a reminder, here is the input formula we had before:\n1 2 0 1 -2 0 -1 -2 0 -1 2 0 And here is the DRAT proof:\na 1 0 a -1 0 a 0 Now, for the FRAT proof:\no 10 1 2 0 -- input clause, let\u0026#39;s set its ID to 10 o 11 1 -2 0 -- input clause, let\u0026#39;s set its ID to 11 o 12 -1 2 0 o 13 -1 -2 0 -- last input clause a 14 1 0 l 10 11 0 -- first resolvent d 10 1 2 0 d 11 1 -2 0 a 15 -1 0 l 12 13 0 -- second resolvent d 12 -1 2 0 d 13 -1 -2 0 a 16 0 l 14 15 0 -- empty clause! It\u0026#39;s UNSAT! f 14 1 0 -- finishup from down here f 15 -1 0 f 16 0 Okkkay. So\u0026hellip; the original clauses are part of the proof trace now, they start with \u0026ldquo;o\u0026rdquo;. And each clause has an ID, after o/a/d/f. This can be any number, but they must be non-clashing (obviously). Furthermore, we are allowed to have an \u0026ldquo;l\u0026rdquo; after the closing \u0026ldquo;0\u0026rdquo; when adding a clause \u0026ndash; these are the clause IDs we had to resolve to arrive at the new clause. So, e.g. IDs 10 and 11, i.e. \u0026ldquo;1 2 0\u0026rdquo; and \u0026ldquo;1 -2 0\u0026rdquo; must resolve to \u0026ldquo;1 0\u0026rdquo; (clause ID 14). And finally, we must \u0026ldquo;finalize\u0026rdquo; all our clauses, i.e. we must account for all clauses remaining in memory, with the \u0026ldquo;f\u0026rdquo; command.\nFirstly, finalization means that in case your SAT solver forgot to delete a clause in the proof trace, but deleted it from memory, finalization will fail, because the solver will not finalize that clause, and so the checker will complain. In essence, finalization forces the hand of the SAT solver writer to make sure that the \u0026ldquo;view of the world\u0026rdquo; from the perspective of the SAT solver and that of the proof verifier match when it comes to clauses in memory. This is not the case for DRAT \u0026ndash; the proof verifier there could have millions of clauses more in memory than the SAT solver :S\nSecondly, the \u0026ldquo;l\u0026rdquo; notation means that we can now be precise about what clauses were actually resolved by the SAT solver to arrive at a new clause. However, this is only a \u0026ldquo;can\u0026rdquo; \u0026ndash; adding the \u0026ldquo;l\u0026rdquo; is not necessary, and of course can be stripped. This means that if we want to, we can have ambiguity, or if we want to, we can have precision. The best of both worlds!\nTrusting trust Proofs are cool, and are very important so we can be sure our results are correct. But\u0026hellip; are we sure they are correct? Well, not so much. You see, the proof verifiers themselves are not verified. Say, frat-rs will say \u0026ldquo;VERIFIED\u0026rdquo; on a FRAT proof, but\u0026hellip; frat-rs itself is over 5000 lines of Rust. And before you think I\u0026rsquo;m really stretching things here, let me just remind you that I personally found a segmentation fault in drat-trim, the official DRAT proof verifier, used at the SAT competition. (I actually found the bug accidentally while fuzzing my own SAT solver.)\nSo, what can we do? Well, we need another verifier. I\u0026rsquo;m not kidding. Basically, frat-rs can take a proof that the SAT solver provides, and translate it to a fully annotated, clean proof with all the deletions at their earliest possible points (see this hack). We can then write a slow, but verified proof checker, that can do the trivial checking that the resolutions are indeed correct, reaching the empty clause (i.e. 0=1). The pipeline would then be:\nAirplane software code + compliance requirements -\u0026gt;SAT_query solution, proof = SAT_solver(SAT_query) solution, clean_proof = frat-rs(SAT_query, solution, proof) solution = verified_proof_checker(SAT_query, solution, clean_proof) What this allows us to do is that we don\u0026rsquo;t need to trust the SAT_solver or frat-rs. We can treat them as black boxes. All we need to trust is that the verified_proof_checker is correct: given the SAT_query, the solution can be trusted. In this sense, clean_proof is simply a hint for the verified_proof_checker to do its job. Notice that I completely skipped how SAT_query can be trusted \u0026ndash; that\u0026rsquo;s an entirely different can of worms :D\nIn case you want to use such a verified proof checker, there is one in lean4, available here, and one for acl2, available here. The non-verified tool to \u0026ldquo;elaborate\u0026rdquo; simpler (e.g. DRAT) proofs into annotated (LRAT) proofs, you can use frat-rs.\nConclusions So, we talked a lot about proof traces, proof formats, and how to trust the solution. In some cases, this is extremely important \u0026ndash; some software and hardware is verified in this way that controls trains and airplanes, and industrial systems (think: nuclear reactors, rockets\u0026hellip; Ariane 5 crash anyone?). We certainly don\u0026rsquo;t want any bugs in there.\nWhat I didn\u0026rsquo;t talk about, is that proof traces do something else, as well: they allow us to understand how SAT solvers work. You see, while the proof is written in the forward fashion \u0026ndash; the same direction that SAT solvers work, \u0026ndash; the proof actually only makes sense in the reverse direction. We always start at the empty clause, at the end of the proof, and walk backwards to see how the empty clause got proven! So, if you think about it, proofs can be used to look at SAT solvers in the reverse direction. And that\u0026rsquo;s super-exciting. For example, how much work did the SAT solver really have to do to reach the empty clause? How much complete nonsense did it do that was utterly useless to prove unsatsifiability? How many times did it forget proof fragmets that it later had to re-learn? Or, what is the minimum memory footprint that its produced proof could fit in? And if we take advantage of DRAT\u0026rsquo;s and FRAT\u0026rsquo;s ambiguity: is there a proof with fewer steps it could have produced given the total same set of resolvents? In my opinion, there is a whole wealth of data in proof traces that we should do research on to learn more about SAT solvers.\n(PS: Tracecheck is one of the earliest proof trace systems. I didn\u0026rsquo;t want to mention it because it\u0026rsquo;s not as relevant anymore as the above, and it would have made the story a tad more confusing)\n","permalink":"https://www.msoos.org/2022/04/proof-traces-for-sat-solvers/","summary":"\u003cp\u003eIf you have a look at a modern SAT solver, say \u003ca href=\"https://github.com/arminbiere/kissat\"\u003ekissat\u003c/a\u003e or \u003ca href=\"https://github.com/msoos/cryptominisat\"\u003eCryptoMiniSat\u003c/a\u003e, you\u0026rsquo;ll see that they have well over 20k lines of code. Reviewing that for bugs is basically impossible. So how can you trust that the solver is giving a correct result? Well, if the result is that the input formula is satisfiable, it\u0026rsquo;s quite easy \u0026ndash; we can simply substitute the solution (all modern SAT solvers provide a satisfying assignment) to the formula, and it should satisfy each constraint. This is really fast to do, linear in the size of the formula.\u003c/p\u003e","title":"Proof Traces for SAT solvers"},{"content":"Uniform sampling is a problem where you are given a solution space and you have to present solutions uniformly, at random. In some cases, this is quite simple, say, for the lotto. Just pick 5 random numbers from a box and we are done! For the lotto the solution space is very easy to generate. However, when there are constraints on the solution space, it starts to get tricky.\nLet\u0026rsquo;s say that I have a function I want to test, but the input to the function has some real-world constraints like e.g. the 1st parameter must be larger than the second, the 2nd parameter must be divisible by the 3rd etc. If I want to test that this function operates correctly, one way to do it is to generate 100 uniformly random inputs that don\u0026rsquo;t violate any of the constraints, run the function, and see if all is OK. For this, I need a fast way of generating uniform samples given the constraints on the solution space.\nSampler speed vs. accuracy There have been many samplers proposed in the literature. I personally have worked on one called UniGen, a guaranteed approximate probabilistic sampler, meaning that it\u0026rsquo;ll give approximately uniform samples most of the time, and we have a proof to back this up. It\u0026rsquo;s a great sampler and will work very fast on many instances. However, for really complex solution spaces, it can have trouble. Say, you want to generate interesting test inputs for your deep learning algorithm. Deep neural networks tend to be extremely complex when translated to binary constraints, so UniGen will likely not be fast enough. It would give very good quality samples (i.e. properly uniform samples), but if it\u0026rsquo;s too slow, we may want to exchange quality of samples for speed of generation.\nThere are two well-known samplers that are supposed to generate uniform samples on complex solution spaces, QuickSampler (code), and STS (code), but give no guarantees, let\u0026rsquo;s call these \u0026ldquo;uniform-like\u0026rdquo; samplers. Unfortunately, the paper by Chakraborty et al and its resulting code Barbarik showed that these uniform-like samplers are highly non-uniform. Barbarik is a pretty neat idea that basically constructs solution spaces with known solution distributions and then asks the sampler to generate uniform samples. Knowing the solution space, Barbarik can then verify how non-uniform the sampler is. Imagine having a box with 1000 balls, half of them blue and the other half green. Now if I ask the sampler to give me 50 balls at random, and all of them are green, I\u0026rsquo;d be a bit surprised to say the least. It\u0026rsquo;d be like the 5-lottery having the same numbers 3 times in a row. Possible, but\u0026hellip; not very likely. If I do this experiment 100 times, and I always get 50 green balls, it\u0026rsquo;s fair to conclude that the sampler is not uniform.\nOur new uniform-like sampler, CMSGen Given an effective tester, Barbarik, we (Priyanka Golia, Sourav Chakraborty, Kuldeep S. Meel, and myself) thought perhaps we can follow the nowadays very successful test-driven development (TDD) methodology. All we have to do is to make our sampler pass the test of Barbarik, while being at least as fast as STS/QuickSampler, and we\u0026rsquo;ll be good to go. In fact, given Barbarik, it only took about a week of playing around with CryptoMiniSat\u0026rsquo;s options to beat both STS and QuickSampler in both accuracy and speed. This speaks volumes to how important it is to have a robust, reliable, and fast testing framework that can give immediate feedback about the quality of samples generated.\nOur new uniform-like sampler, based on CryptoMiniSat, is called CMSGen (research paper here), and effectively takes CyrptoMiniSat and applies the following set of changes, through pre-set command line options:\nPick polarities at random. Normally, SAT solvers use polarity caching scheme, but of course we want uniform samples over all the search space, so we need to pick polarities at random. Branch on variables at random. Normally, SAT solver branch on variables that will most likely lead to a conflict to maximize search efficiency (the VSIDS heuristic). However, we want to explore the solution space as evenly as possible, and so we want to approach the solution space from as many angles as possible. If you think about the search space as an N-dimensional binary cube, then we are trying to approach this cube as any ways as possible. Turn off all pre- and inprocessing. Pre and inprocessing in SAT solvers are used to minimize the instance, transforming it into something easier to solve, e.g. through Bounded Variable Elimination. We later reconstruct a viable solution based on the solution to the transformed instance. However, the transformed instance may (and often will!) have a very different solution space. We cannot have that, so we must turn this off. To be fair, some pre- and inprocessing could be left intact, e.g. subsumption and self-subsuming elimination, perhaps a future paper :) Restart at static intervals. Restarts are nowadays often dynamic in modern SAT solvers, or even if not dynamic, then follow a non-regular pattern. However, that could disturb how we find solution. Imagine, let\u0026rsquo;s say that solutions with variable A set to TRUE are very easy to find, but solutions with FALSE are very hard to find. What will happen? Well, in restarts where A was randomly set to TRUE, we\u0026rsquo;ll always quickly find a solution and output it. But for restarts when A was randomly set to FALSE, the system would struggle to find a solution, and after some conflicts, it will simply restart into a status where hopefully A is set to TRUE, and it can find a solution again. It is quite clear to see that this will lead to serious issues with sampling quality. Hence, we set an adjustable but static restart interval of 100 conflicts, with higher values typically leading to more uniform samples. Performance of CMSGen Performance of the system is on the ridiculous scale in comparison with other samplers:\nWhen it comes to 2-wise coverage, i.e. the quality of samples, the data speaks for itself (note, UniGen is missing here because it was too slow):\nNote that between STS and QuickSampler, STS is both the more uniform sampler, but also the slower one. CMSGen overcomes this limitation: it\u0026rsquo;s both faster than QuickSampler, and more uniform than STS.\nAnd of course, the Barbarik tester gives \u0026ldquo;Accept\u0026rdquo; on CMSGen much more often than on STS or QuickSampler:\nConclusion If you need non-guaranteed uniform but fast sampling, I\u0026rsquo;d go and try out CMSGen. It\u0026rsquo;s really a completely different beast. It\u0026rsquo;s not a guaranteed uniform sampler, but it\u0026rsquo;s incredibly effective. In fact, it\u0026rsquo;s so effective and works so well, it took me a full year to figure out how best to generate problems for it where it wouldn\u0026rsquo;t be uniform. But that\u0026rsquo;s another paper, and another blog post! In the meantime, the sampler is here, go check it out!\n","permalink":"https://www.msoos.org/2021/09/cmsgen-a-fast-uniform-like-sampler/","summary":"\u003cp\u003eUniform sampling is a problem where you are given a solution space and you have to present solutions uniformly, at random. In some cases, this is quite simple, say, for the lotto. Just pick 5 random numbers from a box and we are done! For the lotto the solution space is very easy to generate. However, when there are constraints on the solution space, it starts to get tricky.\u003c/p\u003e\n\u003cp\u003eLet\u0026rsquo;s say that I have a function I want to test, but the input to the function has some real-world constraints like e.g. the 1st parameter must be larger than the second, the 2nd parameter must be divisible by the 3rd etc. If I want to test that this function operates correctly, one way to do it is to generate 100 uniformly random inputs that don\u0026rsquo;t violate any of the constraints, run the function, and see if all is OK. For this, I need a fast way of generating uniform samples given the constraints on the solution space.\u003c/p\u003e","title":"CMSGen, a Fast Uniform-Like Sampler"},{"content":"After many months of work, CryptoMiniSat 5.8.0 has been released. In this post I\u0026rsquo;ll go through the most important changes, and how they helped the solver to be faster and win a few awards, among them 1st place at the SAT incremental track, 3rd place SAT Main track, and 2nd\u0026amp;3d place in the SMT BitVector tracks together with the STP and MinkeyRink solvers.\nGauss-Jordan Elimination First and foremost, Gauss-Jordan elimination at all levels of the search is now enabled by default. This is thanks to the work detailed in the CAV 2020 paper (video here). The gist of the paper is that we take advantage of the bit-packed matrix and some clever bit field filters to quickly check whether an XOR constraint is propagating, conflicting, or neither. This, and a variety of other improvements lead to about 3-10x speedup for the Gauss-Jordan elimination procedure.\nWith this speedup, the overhead is quite small, and we enable G-J elimination at all times now. However, there are still limits on the size of the matrix, the number of matrices, and we disable it if it doesn\u0026rsquo;t seem to improve performance.\nAs a bit of reflection: our original paper with Nohl and Castelluccia on CryptoMiniSat, featuring Gauss-Jordan elimination at all levels of the search tree was published at SAT 2009. It took about 11 years of work, and in particular the work of Han and Jiang to get to this point, but we finally arrived. The difference is day and night.\nTarget Phases This one is really cool, and it\u0026rsquo;s in CaDiCaL (direct code link here) by Armin Biere, description here (on page 8). If you look at the SAT Race of 2019, you will see that CaDiCaL solved a lot more satisfiable problems than any other solver. If you dig deep enough, you\u0026rsquo;ll see it\u0026rsquo;s because of target phases.\nBasically, target phases are a variation of phase saving, but instead of saving the phase all the time when backtracking, it only saves it when backtracking from a depth that\u0026rsquo;s longer than anything seen before. Furthermore, it is doing more than just this: sometimes, it picks only TRUE, and sometimes it picks only FALSE phase. To spice it up, you can keep \u0026ldquo;local deepest\u0026rdquo; and \u0026ldquo;global deepest\u0026rdquo; if you like, and even pick inverted phases.\nIt\u0026rsquo;s pretty self-explanatory if you read this code (basically, just switching between normal, target, inverted, fixed FALSE, fixed TRUE phases) and it helps tremendously. If you look at the graphs of the SAT 2020 competition results (side no. 19 here) you will see a bunch of solvers being way ahead of the competition. That\u0026rsquo;s target phases right there.\nCCAnr Local Search Solver CryptoMiniSat gained a new local search solver, CCAnr (paper here) and it\u0026rsquo;s now the default. This is a local search solver by Shaowei Cai who very kindly let me add his solver to CryptoMiniSat and allowed me to add him as an author to the version of CryptoMiniSat that participated in the SAT competition. It\u0026rsquo;s a local search solver, so it can only solve satisfiable instances, and does so by always working on a full solution candidate that it tries to \u0026ldquo;massage\u0026rdquo; into a full solution.\nWithin CryptoMiniSat, CCAnr takes the starting candidate solution from the phases inside the CDCL solver, and tries to extend it to fit all the clauses. If it finds a satisfying assignment, this is emitted as a result. If it doesn\u0026rsquo;t, the best candidate solution (the one that satisfies the most clauses) is saved into the CDCL phase and is later used in the CDCL solver. Furthermore, some statistics during the local search phase are saved and then injected into the variable branching heuristics of the CDCL solver, see code here.\nHybrid Variable Branching Variable branching in CryptoMiniSat has always been a mix of VSIDS (Variable State Independent Decaying Sum, paper here) and Maple (multi-arm bandit based, paper here) heuristics. However, both Maple and VSIDS have a bunch of internal parameters that work best for one, or for another type of SAT problem.\nTo go around the issue of trying to find a single optimal value for all, CryptoMiniSat now uses a combination of different configurations that is parsed from the command line, such as: \u0026ldquo;maple1 + maple2 + vsids2 + maple1 + maple2 + vsids1\u0026rdquo; that allows different configurations for both Maple and VSIDS (v1 and v2 for both) to be configured and used, right from the command line. This configuration system allows for a wider variety of problems to be efficiently solved.\nFinal Remarks CryptoMiniSat is now used in many systems. It is the default SAT solver in:\nQBF solver Caqe, which regularly wins QBF competitions SMT solvers STP and MinkeyRink , SMT competition results here and here, regularly placing 2nd and 3rd in the QF_BV track Model counting system ApproxMC, which seems to have won 2 of the 3 Model Counting Competition 2020 awards Uniform sampling system Unigen ANF solving system Bosphorus I think the above, especially given their track record of achieving high performance in their respective fields, show that CryptoMiniSat is indeed a well-performing and reliable workhorse. This is thanks to many people, including, but not limited to, Kuldeep Meel, Kian Ming A. Chai, Trevor Hansen, Arijit Shaw, Dan Liew, Andrew V. Jones, Daniel Fremont, Martin Hořeňovský, and others who have all contributed pull requests and valuable feedback. Thanks!\nAs always, let me know if you have any feedback regarding the solver. You can create a GitHub issue here, and pull request here. I am always interested in new use-cases and I am happy to help integrate it into new systems.\n","permalink":"https://www.msoos.org/2020/07/cryptominisat-5-8-0-released/","summary":"\u003cp\u003eAfter many months of work, CryptoMiniSat 5.8.0 has been \u003ca href=\"https://github.com/msoos/cryptominisat/releases/tag/5.8.0\"\u003ereleased\u003c/a\u003e. In this post I\u0026rsquo;ll go through the most important changes, and how they helped the solver to be faster and \u003ca href=\"https://satcompetition.github.io/2020/results.html\"\u003ewin a few awards\u003c/a\u003e, among them 1st place at the SAT incremental track, 3rd place SAT Main track, and 2nd\u0026amp;3d place in the SMT BitVector tracks together with the STP and MinkeyRink solvers.\u003c/p\u003e\n\u003ch2 id=\"gauss-jordan-elimination\"\u003eGauss-Jordan Elimination\u003c/h2\u003e\n\u003cp\u003eFirst and foremost, Gauss-Jordan elimination at all levels of the search is now enabled by default. This is thanks to the work detailed in the CAV 2020 \u003ca href=\"https://www.comp.nus.edu.sg/~meel/Papers/cav20-sgm.pdf\"\u003epaper\u003c/a\u003e (video \u003ca href=\"https://youtu.be/C3YCFnNPD4Y?t=3068\"\u003ehere\u003c/a\u003e). The gist of the paper is that we take advantage of the bit-packed matrix and some clever bit field filters to quickly check whether an XOR constraint is propagating, conflicting, or neither. This, and a variety of other improvements lead to about 3-10x speedup for the Gauss-Jordan elimination procedure.\u003c/p\u003e","title":"CryptoMiniSat 5.8.0 Released"},{"content":"This blog post is to promote the tool here (paper here) that converts weighted counting and sampling to their unweighted counterparts. It turns out that weighted counting and sampling is a thing. It\u0026rsquo;s basically a conjunctive normal form formula, a CNF, with weights attached to each variable. One must count the number of solutions to the CNF, where the weight of each solution is not necessarily 1, but weighted according to the polarity of each variable in the solution. One such formula could look like:\np cnf 2 1 c ind 1 2 0 1 2 0 w 1 0.9 This basically says that we have 2 variables, a single constraint (\u0026ldquo;v1 or v2\u0026rdquo;) where a solution with v1=True is worth 0.9 points, but a solution with v1=False is only worth 0.1 points. Or, if we are sampling, we want to bias our samples 9-to-1 for solutions that have v1=True.\nLet\u0026rsquo;s go through this CNF. It has has 3 solutions, with its associated points:\nsolution points 1 2 0.9 1 -2 0.9 -1 2 0.1 Total points: 1.9 The issue is that we have great tools for doing unweighted counting and sampling but few tools for doing weighted counting and sampling.\nConverting Weighted CNFs to Unweighted CNFs The solution is to use a converter to make an unweighted formula from a weighted formula, and then either divide the number of solutions of the unweighted formula (for counting) or simply cut off variables from the samples (for sampling). This work was done by Chakraborty et al. and presented at IJCAI'15. The basic idea is that we can approximate the weight with a binary representation and encode that in CNF. For example, 0.26 can be approximated with 1/4. If this weight is attached to v1, and there are 10 variables in the original CNF, we generate the extra set of clauses:\n12 -1 0 11 -1 0 12 -11 1 0 This CNF has exactly 1 solution when v1=True and 3 solutions when v1=False. So the number of positive solutions is 1/4 of all solutions, i.e. 0.25, close to the requested 0.26.\nThe above set of clauses is generated from chain formulas that can be easily generated, and are only polynomal in size of the binary precision required. For k-bit precision (above: 2 bit precision), we need only k extra variables and k+1 clauses. See the paper for details, but it\u0026rsquo;s sufficient to say that it\u0026rsquo;s easy to generate and, looking through a few examples, quite easy to understand.\nExample: Weighted Counting Let\u0026rsquo;s do the full run, using our favorite counter, approxmc:\n$ cat my.cnf p cnf 2 1 c ind 1 2 0 1 2 0 w 1 0.9 $ ./weighted_to_unweighted.py my.cnf my-unweighted.cnf Orig vars: 2 Added vars: 7 The resulting count you have to divide by: 2**7 $ ./approxmc my-unweighted.cnf […] [appmc] FINISHED AppMC T: 0.01 s [appmc] Number of solutions is: 62*2**2 $ python \u0026gt;\u0026gt;\u0026gt; 62*2**2/2**7 1.9375 So, we got pretty close to the correct weighted count of 1.9. The reason for the discrepancy is because we approximated 0.9 with a 7-bit value, namely 115/2**7, i.e. 0.8984375, and we used an approximate counter. With an exact counter such as sharpSAT, we would have got:\n$ ./sharpSAT my-unweighted.cnf [...] # solutions 243 # END $ python \u0026gt;\u0026gt;\u0026gt; 243/2**7 1.8984375 Which is pretty close to the correct weighted count and in fact corresponds to the expected error of 0.9-0.8984375=0.0015625:\n$ python \u0026gt;\u0026gt;\u0026gt; from decimal import Decimal \u0026gt;\u0026gt;\u0026gt; Decimal(\u0026#34;1.8984375\u0026#34;)+\\ Decimal(\u0026#34;0.9\u0026#34;)-Decimal(\u0026#34;115\u0026#34;)/Decimal(2**7) Decimal(\u0026#39;1.9000000\u0026#39;) Example: Weighted Sampling Weighted-to-unweighted sampling mimics counting. First, we transform our formula:\n$ ./weighted_to_unweighted.py my.cnf my-unweighted.cnf Orig vars: 2 Added vars: 7 The resulting count you have to divide by: 2**7 Then we sample it, e.g. using our favorite sampler, UniGen (research paper):\n$ ./unigen my-unweighted.cnf --sampleout samples --samples 1000 \u0026gt; /dev/null The samples now contain extra variables that were used for the translation, so we simply cut them off to the original sampling set size, here, 2:\n$ cut -d \u0026#34; \u0026#34; -f 1-2 samples | sort | uniq -c 55 -1 2 478 1 -2 490 1 2 And we are done! The sampling worked as expected: we get proportionally more samples where v1 is True than when it\u0026rsquo;s False.\nConclusions Weighted counting is non-trivial but can be approximated using chain formulas, blowing up the original equation in only a minor way. This allows us to use well-optimized unweighted systems to perform the counting and sampling, and then trivially transform the output of these tools to match our original weighted problem.\n","permalink":"https://www.msoos.org/2019/12/weighted-to-unweighted-counting-and-sampling/","summary":"\u003cp\u003eThis blog post is to promote the tool \u003ca href=\"https://github.com/meelgroup/weighted-to-unweighted\"\u003ehere\u003c/a\u003e (paper \u003ca href=\"https://www.comp.nus.edu.sg/~meel/Papers/ijcai15.pdf\"\u003ehere\u003c/a\u003e) that converts weighted counting and sampling to their unweighted counterparts. It turns out that weighted counting and sampling is a thing. It\u0026rsquo;s basically a \u003ca href=\"https://en.wikipedia.org/wiki/Conjunctive_normal_form\"\u003econjunctive normal form formula\u003c/a\u003e, a CNF, with weights attached to each variable. One must count the number of solutions to the CNF, where the weight of each solution is not necessarily 1, but weighted according to the polarity of each variable in the solution. One such formula could look like:\u003c/p\u003e","title":"Weighted to Unweighted Counting and Sampling"},{"content":"This is going to be a long post, collecting many years of work, some of which was done by my colleagues Kuldeep Meel and Raghav Kulkarni. They have both significantly contributed to this work and I owe a lot to both. The research paper is available here (accepted to SAT'2019) and the code is available here. Build instructions are at the bottom of the post. Part 2 will deal with exploring the data in more detail.\nI always had a fascination with data when it comes to SAT solving. My SAT solver, CryptoMiniSat always had very detailed stats printed to the console. At one point, this fascination with data got to the point where tallying up data from the console (with AWK, like a true hacker) didn\u0026rsquo;t cut it, and I started dumping data to SQL.\nAn Early Attempt: Visualization Out of the SQL data dumped, this website was born, back in 2012. This site displays pretty graphs like:\nThese graphs can show quite a bit of data, the above must be a few hundred data points. The data gathered is pumped to an SQL database, and then visualized. I felt like I am on to something. Finally, I was going to be able to explain things.\nBut I was able to explain very little. Some things were quite obvious, like how industrial and cryptographic instances\u0026rsquo; variable polarity distributions were so different. Above, the black/green graph shows a cryptographic instance, and the distribution is 47% vs. 53%. On a typical industrial instance, the same graph looks like:\nHere, the polarity distribution is 6% vs 94%. This is easy to see with the human eye. But I was gathering tons more data, many megabytes per instance. What was I going to do with all this data? How was I going to know what is good and bad behavior? And how would I make the solver work towards good?\nSATZilla: Solver Selection Using Machine Learning I wasn\u0026rsquo;t the only one trying to make sense of SAT-related data and improve solving based on it. SATZilla has done this before. There, the idea was to gather information \u0026ndash; called features -- about the input CNF problem, run multiple SAT solvers, save how much time it took for the solver to run, then create code that matches the CNF features to the preferred SAT solver. This creates a lines like:\nnum-vars num-clauses Best Solver 132 16730 Lingeling 375 46741 CryptoMiniSat 834 41690 CryptoMiniSat Where the first N columns are the features and the last column is the label that we calculated to be correct. SATZilla uses many features, such as the number of horn clauses, the ratio of variables and clauses, etc. Once such a table has been built, with lines called labeled training examples, it uses a machine learning system, for example Decision Trees, to classify (i.e. guess) which SAT solver would be best for any CNF instance. So it generalizes, and can guess which SAT solver is best for a CNF it has never seen.\nThis system is interesting but has some drawbacks. First, for each data line one must run 5-10 SAT solvers on a CNF, potentially using up to 20-30'000 CPU seconds. Hence, each labeled training example is extremely expensive. If you know about the Big Data hype, you know that spending $2 on a single data point is not viable. Modern systems use millions of labeled training examples to learn a classifier. Secondly, this system was not designed to work in an industrial setting, where the CNF is not presented in a single file but piece-by-piece through a library interface.\nEnter DRAT DRAT is a system used to verify the resolution proof that modern SAT solvers generate. Basically, every unsatifiable problem that SAT solvers solve can be shown to be unsatisfiable through a set of operations called resolutions, that eventually lead to the equation 0=1, which is trivially false. A DRAT verifier can know exactly which clause was used by the SAT solver at exactly which time during the creation of the proof. Hence, DRAT knows a lot. It can actually tell, after the solving has finished, which parts of the SAT solving were absolutely useless, and which ones useful. A resolution proof with thousands of resolutions can be computed in seconds, which means cheap data.\nWhen I first really understood DRAT, I realized, what if I could get all this data out of DRAT, and use it as a label for the millions of data points I already have? I have finally found a label, available at a huge scale, to train on.\nThe Beginnings of CrystalBall What to train for was still a question that needed answering. Since DRAT is so intimately connected with learnt clauses, I decided to train for throwing away as many unneeded learnt clauses as possible. This would definitely make solving faster, by throwing away everything that is useless weight and making sure everything that is useful stays.\nI must thank Marijn Heule who helped me with the first hack of DRAT-trim in early 2016 to get data out from from it. I hacked CryptoMiniSat to add Clause IDs to DRAT, so the verifier, DRAT-trim, could read and track these IDs. I now knew which clause was used in the proof and which wasn\u0026rsquo;t. This sounds really useful \u0026ndash; you could now know which learnt clauses should have been thrown away the moment they were generated, since they were useless. Let\u0026rsquo;s see some data from modern CrystalBall (see at the bottom of the post how to download, compile and run):\nsqlite\u0026gt; select count() from sum_cl_use where num_used\u0026gt;0; 51675 sqlite\u0026gt; select count() from sum_cl_use where num_used=0; 42832 The data says that about 50% of clauses were useful. Let\u0026rsquo;s see what is the average LBD value of the useful and useless clauses:\nsqlite\u0026gt; select avg(glue) from sum_cl_use, clauseStats where sum_cl_use.clauseID = clauseStats.clauseID and num_used \u0026gt; 0; 6.71436865021771 sqlite\u0026gt; select avg(glue) from sum_cl_use, clauseStats where sum_cl_use.clauseID = clauseStats.clauseID and num_used = 0; 9.80162028389989 Nice. Let\u0026rsquo;s get the sizes, too, by replacing \u0026ldquo;glue\u0026rdquo; with \u0026ldquo;size\u0026rdquo;:\nsqlite\u0026gt; select avg(size)... 12.2770198355104 sqlite\u0026gt; select avg(size)... 23.5734497571909 Cool. Size is a better discriminator? Let\u0026rsquo;s see another feature. Let\u0026rsquo;s get the average LBD of the redundant non-binary antecedents of the clause:\nsqlite\u0026gt; select avg(antecedents_glue_long_reds_avg)... 4.88254061122689 sqlite\u0026gt; select avg(antecedents_glue_long_reds_avg)... 5.68082216847043 There are plenty more, well over a hundred, that is being measured, so I won\u0026rsquo;t bore you. I have a feeling you could write a few research papers just by running queries on this data.\nI don\u0026rsquo;t know if you noticed, but something is odd here. SAT solvers only keep about 5-10% of all clauses. Just run a modern SAT solvers to completion and check how many clauses remain in the clause database. How is this compatible with 50% of clauses being useful? Well, we can use clauses for a while, then throw them away. But for that, we need much more than just whether a clause is useful or not. We need to know exactly when it was useful. Clauses can be used many-many times in a single proof.\nWe Need More Refined Labels It turns out that having only whether a clause is being used is not good enough to compute useful labels. We need to know when, exactly, was the clause useful. So CryptoMiniSat and DRAT-trim was hacked to output into the DRAT proof exact conflict numbers when a clause was created. This, with some minor magic, would tell us exactly when each learnt clauses was used:\nsqlite\u0026gt; select sum(num_used) from sum_cl_use, clauseStats where sum_cl_use.clauseID = clauseStats.clauseID and glue\u0026lt;=3; 332689 sqlite\u0026gt; select count() from clauseStats where glue\u0026lt;=3; 11221 For this problem, a clause that had LBD 3 or lower was used on average 332689/11221.0=29.65 times in the proof. Okay, how about clauses with LBD 4 or larger? It\u0026rsquo;s a trivial change in the above code, and gives us 5.95. Cool, the lower glue, the more it\u0026rsquo;s used in the proof.\nNow that we know how to walk, let\u0026rsquo;s run. When was clauseID 59465 created and at what conflict points was it used in the proof?\nsqlite\u0026gt; select conflicts from clauseStats where clauseID=59465; 101869 sqlite\u0026gt; select used_at from usedClauses where clauseID = 59465 order by used_at asc; 101870 123974 152375 This is an interesting clause. It was generated at conflict no. 101869, was used in the proof right after it was generated, at conflict no. 101870, and then it was used in the proof more than 20'000 conflicts later, twice.\nThe Data Pipeline The idea is this: we are going examine every learnt clause at every 10'000 conflicts, and guess whether it\u0026rsquo;s going to be used in the future enough for it to be kept. If it\u0026rsquo;s going to be used enough in the future, we keep it. If not, we\u0026rsquo;ll throw it away. What do we need for this?\nWell, we need a ton of labeled training examples. And for that, we need a truckload of data, one that generates so much that we have to throw away 96% and still end up with hundreds of MBs in under an hour. Also, we need this from a wide variety of problems, and we need to be able to debug the hell out of this data, because where there is tons of data, there are tons of NaNs, and negative clause sizes and the whatnot. So we need a data pipeline.\nThe first part of the pipeline we only run once, because it\u0026rsquo;s a bit expensive, about 3-10x slower than a normal CNF run, and looks like this:\nRun CryptoMiniSat without any clause cleaning, and write an SQLite database with all dynamic data gathered. The data written is about: the CNF (such as number of claues, etc.), the restarts (e.g. avg. LBD, restart length), the learnt clauses (e.g. LBD, size), and at every 10'000 conflicts the dynamic characteristics of the learnt clauses (e.g. activity, number of times used in a conflict the past 10'000 conflicts) Run DRAT, and dump all usage data to a file. Augment the SQLite data with the DRAT data Sample the data because otherwise it\u0026rsquo;s going to be too much. We need to sample smartly, though, because without biased sampling, the really weird cases will not be represented in the final data at all, and our machine learning system will not see some really interesting data. If we could store and process 1TB of data (you can generate that rather easily), we wouldn\u0026rsquo;t have this issue. But we can\u0026rsquo;t. So now we have a ton of cool data that is very raw. This is going to be our baseline. We\u0026rsquo;ll keep this data in our stash and never modify it.\nThe second part of our data pipeline will use this stash of data to do all the cool things we want. This 2nd part is much-much cheaper to run (few seconds to a few minutes per CNF), so we will be able to run it as many times as we like, playing with all the cool parameters. This second part of the pipeline will:\nThe data is stored normalized in SQLite for speed and space. For machine learning, we must denormalize it, to have everything related to decision on a single line. Create the labeled training data using Python Pandas for easy data manipulation and visualization Create a classifier using Python\u0026rsquo;s scikit-learn Spit out a C++ code we can compile into our solver Getting Labeled Training Examples In order to train a classifier, we need labeled training examples. These are lines like:\nglue size used_last_10k_conflicts activity rank label 10 15 3 top half KEEP 7 10 1 bottom half THROW_AWAY 3 7 0 bottom half THROW_AWAY Notice that this table has essentially two parts. The left part, i.e. everything apart from \u0026ldquo;keep\u0026rdquo;, called features, must be available to the solver during running. And the right part, \u0026ldquo;keep\u0026rdquo;, the label, which is computed using data from DRAT-trim. This latter the solver has no access to during running, this is our crystal ball, looking into the future. What we want is to predict the label given the features.\nThe left hand side, i.e. the features are not so difficult to do. Adding a new feature is now about 3-4 lines change in CryptoMiniSat and it\u0026rsquo;s essentially free in terms of speed. The data gathering only needs to run once (the 1st part of our data pipeline) and it is not running during solving. So, you can add as many features as you like. If they are useful, then you also need to add some lines to the solver so they will be available during running \u0026ndash; of the 200+ only a few are really useful.\nThe right hand side, i.e. the labels are a completely different story, though. We know what is the future, kinda (yes, the future is a function of the past\u0026amp;present, but let\u0026rsquo;s not go there for the moment). So given the future, how do I label things? We need to use a heuristic. The good part is that we have a ton of information about the future, such as the distribution of all clause\u0026rsquo;s usage in the proof, and the number of times a particular clause is used in the future. But we still need to come up with something to decide KEEP/THROW_AWAY. A simple such heuristic is: if in the next 10'000 conflicts this clause will be used at least 6 times, keep it. Otherwise, into the bin it goes:\nCASE WHEN -- useful in the next round used_later10k.used_later10k \u0026gt; 5 THEN \u0026#34;keep\u0026#34; ELSE \u0026#34;throw_away\u0026#34; END AS `x.class` Nice! Remember that clauseID 59465 that I talked about above? Yeah, that would be labeled THROW_AWAY \u0026ndash; it was only used 20'000 conflicts later. We have labeled our data, now we need to train a classifier, make it output C++ code and we are good to go. But before that, let\u0026rsquo;s play with Weka.\nData Analysis And Machine Learning with Weka Weka is a cool tool for exploring data and building simple classifiers. You can get a free Weka course on Futurelearn, and I highly recommend it. The person who wrote it is the one who is giving the course and he is really cool. The denormalized, labeled data can be output to CSV (see at the bottom), which Weka can read:\nHere, you have Weka showing the denormalized set of features on the left, and showing the LBD distribution on the right. Blue color is for for lines labeled KEEP and red color is for lines labeled THROW_AWAY. As you can see, the distribution of blue vs red is not the same at all as the LBD value increases (hence LBD being a good discriminator, see glucose).\nYou can also visualize correlations:\nYou can also build classifiers based on this labeled data. Just don\u0026rsquo;t forget to delete the \u0026ldquo;sum_cl_use.*\u0026rdquo; features, as they are not really features, they are data from the proof verification. If you don\u0026rsquo;t delete them, Weka will cheat and use them in the classifier, which is like using the solution key during the exam :) Let\u0026rsquo;s create a classifier using Weka:\nThis shows a confusion matrix at the bottom. Nice. Total misclassification was 18% using the J48 decision tree algorithm with some minor tuning. Here is such an example decision tree (PDF here):\nWeka is great in many ways, and I will forever be indebted to it. However, it\u0026rsquo;s just not gonna cut it for us. We need something a lot faster, and we need to be able to automate it and we need to be able to get C++ code out. Weka could do some of these, but I\u0026rsquo;m not a Java programmer, and Weka\u0026rsquo;s speed is nowhere near that of scikit-learn. However, if it\u0026rsquo;s your first time doing machine learning, Weka is an amazing tool.\nTraining a Classifier Using scikit-learn Now that we have labeled training data, we need to create a classifier so that the solver, during running, can take the features it knows and guess the label KEEP or THROW_AWAY. There are many-many different classifiers that can be trained, and I have tried the most important ones, such as logistic regression, SVM, decision trees and random forests.\nLet me pause here for a moment. If you haven\u0026rsquo;t done machine learning before, you might think \u0026ndash; this is where the magic is. The classifier is where it\u0026rsquo;s at! And if you have done machine learning before, you know full well, it\u0026rsquo;s not here at all. It turns out that the quality and quantity of your data is way more important than the classifier you choose. It\u0026rsquo;s relatively easy to see why. If your data is messy, incorrect, or missing elements, no matter what classifier you use, no matter how amazing it is, it will give you bad results. Bad data, bad results. Every. Single. Time. Keep this in mind.\nSo, we have chosen our classifier, say, decision trees. Decision trees are easy to visualize, and you will need to debug the hell out of this, so it comes handy. After all, nobody wrote 1000 lines of python and it came out perfect the first time.\nNow, there are still some things to deal with. First, we cannot possibly use all 200+ features in our prediction. We can generate the tables, but we need to be reasonable, and cut down the features to something much smaller, say, 20, during the running of the solver. To do that, we create a large random forest and then check which features were picked by the most trees. That gives us feature ranking (thanks to Raghav Kulkarni for this trick):\n../predict.py \u0026#34;mydata-min.db-short-conf-0.dat\u0026#34; --name short [...] Feature ranking: 1 rdb0.used_for_uip_creation 0.1070 2 rdb0.last_touched_diff 0.0723 3 rdb0.act_ranking 0.0694 4 rdb0.activity_rel 0.0644 5 rdb0.sum_uip1_used 0.0641 So the top 5 features for this particular run are these. For different instances or different configurations, the top features may differ, and you probably want to sample X number of labeled training example from each problem, put it in a large data file and then run the feature ranking.\nThere are still some minor obstacles to overcome. Since about 95% of the clauses need to be thrown away, our labels will be very unbalanced. So we need to balance that. Also, how aggressive do we want to be with throwing clauses away? Should we err on the side of caution? Note that this is not about labeling anymore. The label has already been chosen. It\u0026rsquo;s about guessing the label. We are now tuning what\u0026rsquo;s called the confusion matrix:\nX label label KEEP THROW_AWAY guessed 0.80 0.20 KEEP guessed 0.05 0.95 THROW_AWAY Here, we have 80% of things that we labeled as KEEP actually being guessed to be kept, while 20% of them are wrongly guessed as THROW_AWAY. So it\u0026rsquo;s kinda okay. We are better at guessing if something needs to be thrown away, though, there we only guess 5% of them wrongly. Maybe this a good balance, but if not, it can be changed as a weight parameter.\nThe system can also classify clauses into different types, using K-means clustering. Then it can train a different classifier for each clause type. The K-means clustering uses the already denormalized features, so it\u0026rsquo;s really trivial to do, though which features should be used for the clustering is a good question. I currently use the CNF features only (e.g. number of clauses, variables, ratio of vars/clauses, etc.), thereby clustering problems rather than clauses. One could could use any set of features though, it\u0026rsquo;s all automatic, including C++ code generation.\nActually, the C++ code generation. The system produces C++ code for decision trees, random forests and K-means clustering, ready for it to be compiled into the final executable. We have now created our clustering and classifier, and it\u0026rsquo;s all in C++ code. Let\u0026rsquo;s run it!\nThe Final Solver This is the most fun part. And the cumulative effort of a lot of work. It\u0026rsquo;s really interesting to see all those thousands of lines of C++ and python churning out gigabytes of data, being boiled down to juts a few hundred lines of automatically generated if-then-else statements, running during solving. But there it is.\nLet me talk about the good parts first. It\u0026rsquo;s very fast at evaluating whether to keep or throw away a clause. You don\u0026rsquo;t even notice it running. It doesn\u0026rsquo;t use much more memory than normal CryptoMiniSat (i.e. a few features were enough), and it correctly guesses the cluster where a clause belongs. It also guesses the labels correctly with very high probability. The final solver beats every solver from 2018 on the SAT competition 2014-17 instances.\nAnother great thing is that this system can be used to automatically train for specific problem types. This can be very significant in industry, where the instances are similar and training for a particular type of instance would make a lot of sense. Since this system tunes to the data it\u0026rsquo;s given, if it\u0026rsquo;s given data only about a particular type of instances, it will tune to them only, making the solver particularly good at them.\nThere is a bad part too, though: the built-in, rather sophisticated heuristic of keeping or throwing away clauses beats the system built. This makes me very sad, but some things make me hopeful. Firstly, the data is probably still messy. There are probably some bugs here and there, where some of the data gathered is not reliable. Secondly, the labeling is very-very rudimentary. If you have a look at that CASE statement above, it\u0026rsquo;s laughingly simple. Finally, the normal heuristic is quite smart, keeping some (simple) information about clauses, i.e. keeping some state over time, which the current machine learning system cannot do \u0026ndash; the classifier has no memory.\nConclusions This project, going back over 6 years, has been a tough one. All in all, it must have costed about 2 full years of work. A sane researcher would have abandoned it after about 2 weeks. In fact, we had a reviewer rejecting the paper, claiming that this work could be done in 2 weeks by her/his PhD student (I love such reviews). I sometimes wonder how much that PhD student charges for their time, because I might just pay it if they are that good.\nMaybe we did the wrong thing, keeping going for so many years, but I think this could be a foundation of something much more interesting. It could be used not only to create machine learning models, but also to understand SAT solvers. With so much data at hand, we could finally understand some of the behavior of solvers, perhaps leading to some interesting ideas. And the data could be used for many other machine learning systems, too: guessing when to restart, guessing which variable to branch on, etc.\nBuild and Use Instructions # Prerequisites on a modern Debian/Ubuntu installation sudo apt-get install build-essential cmake git sudo apt-get install zlib1g-dev libsqlite3-dev sudo apt-get install libboost-program-options-dev sudo apt-get install python3-pip sudo pip3 install sklearn pandas numpy lit matplotlib # Getting the code git clone https://github.com/msoos/cryptominisat cd cryptominisat git checkout crystalball git submodule update --init mkdir build \u0026amp;\u0026amp; cd build ln -s ../scripts/crystal/* . ln -s ../scripts/build_scripts/* . # Let\u0026#39;s get an unsatisfiable CNF wget http://www.msoos.org/largefiles/goldb-heqc-i10mul.cnf.gz gunzip goldb-heqc-i10mul.cnf.gz # Gather the data, denormalize, label, output CSV, # create the classifier, generate C++, # and build the final SAT solver ./ballofcrystal.sh --csv goldb-heqc-i10mul.cnf [...compilations and the full data pipeline...] # Let\u0026#39;s use our newly built tool # we are using configuration number short:3 long:3 ./cryptominisat5 --predshort 3 --predlong 3 goldb-heqc-i10mul.cnf [ ... ] s UNSATISFIABLE # Let\u0026#39;s look at the data cd goldb-heqc-i10mul.cnf-dir sqlite3 mydata.db sqlite\u0026gt; select count() from sum_cl_use; 94507 ","permalink":"https://www.msoos.org/2019/06/crystalball-sat-solving-data-gathering-and-machine-learning/","summary":"\u003cp\u003eThis is going to be a long post, collecting many years of work, some of which was done by my colleagues \u003ca href=\"https://www.comp.nus.edu.sg/~meel/\"\u003eKuldeep Meel\u003c/a\u003e and \u003ca href=\"https://dblp.uni-trier.de/pers/hd/k/Kulkarni:Raghav\"\u003eRaghav Kulkarni\u003c/a\u003e. They have both significantly contributed to this work and I owe a lot to both. The research paper is available \u003ca href=\"/wordpress/wp-content/uploads/2019/06/sat19-skm.pdf\"\u003ehere\u003c/a\u003e (accepted to \u003ca href=\"https://10times.com/sat-lisbon\"\u003eSAT'2019\u003c/a\u003e) and the code is available \u003ca href=\"https://github.com/msoos/cryptominisat/tree/crystalball\"\u003ehere\u003c/a\u003e. Build instructions are at the bottom of the post. Part 2 will deal with exploring the data in more detail.\u003c/p\u003e","title":"CrystalBall: SAT solving, Data Gathering, and Machine Learning"},{"content":"About this cookie policy This Cookie Policy explains what cookies are and how we use them. You should read this policy to understand what cookies are, how we use them, the types of cookies we use i.e, the information we collect using cookies and how that information is used and how to control the cookie preferences. For further information on how we use, store and keep your personal data secure, see our Privacy Policy.\nYou can at any time change or withdraw your consent from the Cookie Declaration on our website.\nLearn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.\nYour consent applies to the following domains: www.msoos.org\n[user_consent_state]\nWhat are cookies ? Cookies are small text files that are used to store small pieces of information. The cookies are stored on your device when the website is loaded on your browser. These cookies help us make the website function properly, make the website more secure, provide better user experience, and understand how the website performs and to analyze what works and where it needs improvement.\nHow do we use cookies ? As most of the online services, our website uses cookies first-party and third-party cookies for a number of purposes. The first-party cookies are mostly necessary for the website to function the right way, and they do not collect any of your personally identifiable data.\nThe third-party cookies used on our websites are used mainly for understanding how the website performs, how you interact with our website, keeping our services secure, providing advertisements that are relevant to you, and all in all providing you with a better and improved user experience and help speed up your future interactions with our website.\nWhat types of cookies do we use ? Essential: Some cookies are essential for you to be able to experience the full functionality of our site. They allow us to maintain user sessions and prevent any security threats. They do not collect or store any personal information. For example, these cookies allow you to log-in to your account and add products to your basket and checkout securely.\nStatistics: These cookies store information like the number of visitors to the website, the number of unique visitors, which pages of the website have been visited, the source of the visit etc. These data help us understand and analyze how well the website performs and where it needs improvement.\nMarketing: Our website displays advertisements. These cookies are used to personalize the advertisements that we show to you so that they are meaningful to you. These cookies also help us keep track of the efficiency of these ad campaigns.\nThe information stored in these cookies may also be used by the third-party ad providers to show you ads on other websites on the browser as well.\nFunctional: These are the cookies that help certain non-essential functionalities on our website. These functionalities include embedding content like videos or sharing contents on the website on social media platforms.\nPreferences: These cookies help us store your settings and browsing preferences like language preferences so that you have a better and efficient experience on future visits to the website.\n[cookie_audit columns=\u0026ldquo;cookie,description\u0026rdquo; heading=\u0026ldquo;The below list details the cookies used in our website.\u0026rdquo;]\nHow can I control the cookie preferences ? Should you decide to change your preferences later through your browsing session, you can click on the \u0026ldquo;Privacy \u0026amp; Cookie Policy\u0026rdquo; tab on your screen. This will display the consent notice again enabling you to change your preferences or withdraw your consent entirely.\nIn addition to this, different browsers provide different methods to block and delete cookies used by websites. You can change the settings of your browser to block/delete the cookies. To find out more out more on how to manage and delete cookies, visit wikipedia.org, www.allaboutcookies.org.\n","permalink":"https://www.msoos.org/cookie-policy/","summary":"\u003ch3 id=\"about-this-cookie-policy\"\u003eAbout this cookie policy\u003c/h3\u003e\n\u003cp\u003eThis Cookie Policy explains what cookies are and how we use them. You should read this policy to understand what cookies are, how we use them, the types of cookies we use i.e, the information we collect using cookies and how that information is used and how to control the cookie preferences. For further information on how we use, store and keep your personal data secure, see our Privacy Policy.\u003c/p\u003e","title":"Cookie Policy"},{"content":"Satisfiability problem solvers, or SAT solvers for short, try to find a solution to decidable, finite problems such as cryptography, planning, scheduling, and the like. They are very finely tuned engines that can be looked at in two main ways . One is to see them as proof generators, where the SAT solver is building a proof of unsatisfiability as it runs, i.e. it tries to prove that there is no solution to the problem. Another way is to see SAT solvers as smart search engines. In this blog post, I\u0026rsquo;ll take this latter view and try to explain why I think intermediary variables are important. So, for the sake of argument, let\u0026rsquo;s forget that SAT solvers sometimes restart the search (forgetting where they were before) and learn clauses (cutting down the search space and remembering where not go again). Let\u0026rsquo;s just pretend all they do is search.\nSearching The CryptoMiniSat SAT solver used to be able to generate graphs that show how a search through the search space went. Search spaces in these domains are exponential in size, say, 2^n in case there are n variables involved. I don\u0026rsquo;t have the search visualization code anymore but below is an example of such a search tree. The search starts at the very top not far from the middle, it descends towards the bottom left, then iteratively backtracks all the way to the top, and then descends towards the bottom right. Every pentagon at the bottom of a line is a place where the SAT solver backtracked. Observe that it never goes all the way back to the top \u0026ndash; except once, when the top assignment needs to be flipped. Instead, it only goes back some way, partially unassigning variables. The bottom right corner is where the solution is found after many-many partial backtracks and associated partial unassignements:\nWhat I want you to take away from this graph is the following: the solver iteratively tries to set a variable a value, calculates forward, and if it doesn\u0026rsquo;t work, it will partially backtrack, flip its value to its opposite, then descend again.\nBrute force search vs. SAT solving Trying one value and then trying the other sounds suspiciously like brute force search. Brute force search does exactly that, in a systematic and incredibly efficient way. We can build highly specialized executables and even hardware, to perform this task. If you look at e.g. Bitcoin mining, you will see a lot of specialized hardware, ASIC s, doing brute-force search. And if you look at rainbow tables, you\u0026rsquo;ll see a lot of bit slicing.\nSo why waste our time doing all this fancy value propagation and backtracking when we could use a much more effective, systematic search system? The answer is, if you generated your problem description wrongly, then basically, for no good reason, and you are probably better off doing brute-force search. But if you did well, then a SAT solver can perform a significantly better search than brute-force. The trick lies in intermediary variables, and partial value assignments.\nPartial value assignments So let\u0026rsquo;s say that your brute force engine is about to check one input variable setting. It sets the input variables, runs the whole algorithm, and computes the output. The output is wrong though. Here is where things go weird. The brute force engine now completely erases its state, takes another input and runs the whole algorithm again.\nSo, brute force does the whole calculation again, starting from a clean state, every time. What we have to recognize is that this is actually a design choice . Another design choice is to calculate what variables were affected by one of the input bits, unset these variables, flip the input bit value, and continue running the calculation. This has the following requirements:\nA way to quickly determine which intermediate values depend on which other ones so we can unset variables and know which intermediate, already calculated, dependent variables also need to be unset. A way to quickly unset variables A good set of intermediary values so we can keep as much state of the calculation as possible If you think about it, the above is what SAT solvers do, well mostly. In fact, they do (1) only partially: they allow variables only to be unset in reverse chronological order. Calculating and maintaining a complete dependency graph seems too expensive. So we unset more variables than we need to. But we can unset them quickly and correctly and we compensate for the lack of correct dependency check in (1) by caching polarities. This caches the independent-but-nevertheless-unset variables\u0026rsquo; values and then hopes to reassign them later to the correct value. Not perfect, but not too shabby either.\nModeling and intermediary variables To satisfy requirement (3) one must have a good set of intermediary variables in the input problem (described in DIMACS format), so the SAT solver can both backtrack and evaluate partially. Unfortunately, this is not really in the hands of the SAT solver. It is in the hands of the person describing the problem. Modeling is the art of transforming a problem that is usually expressed in natural language (such as \u0026ldquo;A person cannot be scheduled to be on a night shift twice in a row\u0026rdquo;) into a problem that can be given to a SAT solver.\nModeling has lots of interesting constraints, one of which I often hear and I am confused by: that it should minimize the number of variables. Given the above, that SAT solvers can be seen at as partial evaluation engines that thrive on the fact that they can partially evaluate and partially backtrack, why would anyone try to minimize the number of variables? If the solver has no intermediary variables to backtrack to, the solver will simply backtrack all the way to the beginning every time, thus becoming a really bad brute-force engine that incidentally tracks a dependency graph and is definitely non-optimized for the task at hand.\nSome final thoughts In the above I tried to take a premise, i.e. that SAT solvers are just search engines, and ran with it. I don\u0026rsquo;t think the results are that surprising. Of course, nothing is black-and-white. Having hundreds of millions of variables in your input is not exactly optimal. But minimizing the number of variables given to a SAT solver at the expense of expressive intermediate variables is a huge no-no.\n","permalink":"https://www.msoos.org/2019/02/sat-solvers-as-smart-search-engines/","summary":"\u003cp\u003e\u003ca href=\"https://en.wikipedia.org/wiki/Boolean_satisfiability_problem\"\u003eSatisfiability problem solvers,\u003c/a\u003e or SAT solvers for short, try to find a solution to decidable, finite problems such as cryptography, planning, scheduling, and the like. They are very finely tuned engines that can be looked at in two main ways . One is to see them as proof generators, where the SAT solver is building a proof of unsatisfiability as it runs, i.e. it tries to prove that there is no solution to the problem. Another way is to see SAT solvers as smart search engines. In this blog post, I\u0026rsquo;ll take this latter view and try to explain why I think intermediary variables are important. So, for the sake of argument, let\u0026rsquo;s forget that SAT solvers sometimes restart the search (forgetting where they were before) and learn clauses (cutting down the search space and remembering where not go again). Let\u0026rsquo;s just pretend all they do is search.\u003c/p\u003e","title":"SAT Solvers as Smart Search Engines"},{"content":"I am happy to finally release a piece of work that I have started many years ago at Security Research Labs (many thanks to Karsten Nohl there). Back in the days, it helped us to break multiple real-world ciphers. The released system is called Bosphorus and has been released with major, game-changing work by Davin Choo and Kian Ming A. Chai from DSO National Laboratories Singapore and great help by Kuldeep Meel from NUS. The paper will be published at the DATE 2019 conference.\nANFs and CNFs Algebraic Normal Form is a form that is used by most cryptographers to describe symmetric ciphers, hash algorithms, and lately a lot of post-quantum asymmetric ciphers. It\u0026rsquo;s a very simple notation that basically looks like this:\nx1 ⊕ x2 ⊕ x3 = 0 x1 * x2 ⊕ x2 * x3 + 1 = 0 Where \u0026ldquo;⊕\u0026rdquo; represents XOR and \u0026ldquo;*\u0026rdquo; represents the AND operator. So the first line here is an XOR of binary variables x1, x2 and x3 and their XOR must be equal to 0. The second line means that \u0026ldquo;(x1 AND x2) XOR (x2 AND x3)\u0026rdquo; must be equal to 1. This normal form allows to see a bunch of interesting things. For example, it allows us to see the so-called \u0026ldquo;maximum degree\u0026rdquo; of the set of equations, where the degree is the maximum number of variables AND-ed together in one line. The above set of equations has a maximum degree of 2, as (x1*x2) is of degree 2. Degrees can often be a good indicator for the complexity of a problem.\nWhat\u0026rsquo;s good about ANFs is that there are a number of well-known algorithms to break problems described in them. For example, one can do (re)linearization and Gauss-Jordan elimination, or one could run Grobner-basis algorithms such as F4/F5 on it. Sometimes, the ANFs can also be solved by converting them to another normal form, Conjunctive Normal Form (CNF), used by SAT solvers. The CNF normal form looks like:\nx1 V x2 V x3 -x1 V x3 Where x1, x2 and x3 are binary variables, \u0026ldquo;V\u0026rdquo; is the logical OR, and each line must be equal to TRUE. Using CNF is interesting, because the solvers used to solve them, SAT solvers, typically provide a different set of trade-offs for solving than ANF problem solvers. SAT solvers tend to use more CPU time but a lot less memory, sometimes making problems viable to solve in the \u0026ldquo;real world\u0026rdquo;. Whereas sometimes breaking of a cipher is enough to be demonstrated on paper, it also happens that one wants to break a cipher in the real world.\nBridging and Simplifying Bosphorus is I believe a first of its kind system that allows ANFs to be simplified using both CNF- and ANF-based systems. It can also convert between the two normal forms and can act both as an ANF and a CNF preprocessor, like SatELite (by Een and Biere) was for CNF. I believe this makes Bosphorus unique and also uniquely useful, especially if you are working on ANFs.\nBosphorus uses an iterative architecture that performs the following set of steps, either until it runs out of time or until fixedpoint:\nReplace variables and propagate constants in the ANF Run limited Extended Linarization (XL) and inject back unit and binary XORs Run limited ElimLin and inject back unit and binary XORs Convert to CNF, run a SAT solver for a limited number of conflicts and inject back unit and binary (and potentially longer) XORs In other words, the system is an iterative simplifier/preprocessor that invokes multiple reasoning systems to try to simplify the problem as much as possible. It can outright solve the system, as most of these reasoning systems are complete, but the point is to run them only to a certain limit and inject back into the ANF the easily \u0026ldquo;digestible\u0026rdquo; information. The simplified ANF can then either be output as an ANF or a CNF.\nBosphorus can also take a CNF as input, perform the trivial transformation of it to ANF and then treat it as an ANF. This allows the CNF to be simplified using techniques previously unavailable to CNF systems, such as XL.\nANF to CNF Conversion I personally think that ANF-to-CNF conversion is actually not that hard, and that\u0026rsquo;s why there hasn\u0026rsquo;t been too much academic effort devoted to it. However, it\u0026rsquo;s an important step without which a lot of opportunities would be missed.\nThe implemented system contains a pretty advanced ANF-to-CNF converter, using Karnaugh tables through Espresso, XOR cutting, monomial reuse, etc. It should give you a pretty optimal CNF for all ANFs. So you can use Bosphorus also just as an ANF-to-CNF converter, though it\u0026rsquo;s so much more.\nFinal Thoughts What I find coolest about Bosphorus is that it can simplify/preprocess ANF systems so more heavyweight ANF solvers can have a go at them. Its ANF simplification is so powerful, it can even help to solve some CNFs by lifting them to ANF, running the ANF simplifiers, converting it back to CNF, and solving that(!). I believe our initial results, published in the paper, are very encouraging. Further, the system is in a ready-to-use state: there is a Docker image, the source should build without a hitch, and there is even a precompiled Linux binary. Good luck using it, and let me know how it went!\n","permalink":"https://www.msoos.org/2019/01/bosphorus-an-anf-and-cnf-simplifier-and-converter/","summary":"\u003cp\u003eI am happy to finally release a piece of work that I have started many years ago at \u003ca href=\"https://srlabs.de/\"\u003eSecurity Research Labs\u003c/a\u003e (many thanks to Karsten Nohl there). Back in the days, it helped us to break multiple real-world ciphers. The released system is called \u003ca href=\"https://github.com/meelgroup/bosphorus\"\u003eBosphorus\u003c/a\u003e and has been released with major, game-changing work by Davin Choo and Kian Ming A. Chai from \u003ca href=\"https://www.dso.org.sg/\"\u003eDSO National Laboratories\u003c/a\u003e Singapore and great help by \u003ca href=\"https://www.comp.nus.edu.sg/~meel/\"\u003eKuldeep Meel\u003c/a\u003e from NUS. The \u003ca href=\"https://www.comp.nus.edu.sg/~meel/Papers/date-cscm19.pdf\"\u003epaper\u003c/a\u003e will be published at the \u003ca href=\"https://www.date-conference.com/\"\u003eDATE 2019\u003c/a\u003e conference.\u003c/p\u003e","title":"Bosphorus, an ANF and CNF simplifier and converter"},{"content":"Approximate model counting allows to count the number of solutions (or \u0026ldquo;models\u0026rdquo;) to propositional satisfiability problems. This problem seems trivial at first given a propositional solver that can find a single solution: find one solution, ban it, ask for another one, ban it, etc. until all solutions are counted. The issue is that sometimes, the number of solutions is 2^50 and so counting this way is too slow. There are about 2^266 atoms in the universe, so counting anywhere near that is impossible using this method.\nExact Counting Since we cannot count 1-by-1, we are then left with trying to count in some smarter way. There are a bunch of methods to count exactly, the simplest is to cut the problem on a variable, count when the variable is True, count when the variable is False, recursively, and add them all up. Given caching of components that recur while \u0026ldquo;cutting\u0026rdquo; away, this can be quite successful, as implemented by sharpSAT (see Marc Thurley\u0026rsquo;s paper).\nThese counters can scale quite well, but have some downsides. In particular, when the memory runs out, the cache needs to be groomed, sometimes resorting back to 1-by-1 counting, which we know will fail as there is no way 2^200 can be counted 1-by-1 in any reasonable amount of time. The caching systems used are smart, though, retaining last-used entries when the cache needs to be groomed. However, sometimes this grooming algorithm can lead to cyclic behaviour that effectively simulates 1-by-1 counting.\nApproximate Counting What Chakraborty, Meel and Vardi did in their paper, was to create a counter that counts not exactly, but \u0026ldquo;probably approximately correctly\u0026rdquo;. This jumble of terms basically means: there is a certain probability that the counting is correct, within a given threshold. We can both improve the probability and the threshold given more CPU time spent. In practical terms, the probability can be set to be over 99.99% and the threshold can be set to be under 20%, still beating exact counters. Note that 20% is not so much, as e.g. 2^60*1.2 = 2^(60.3).\nSo what\u0026rsquo;s the trick? How can we approximately count and give guarantees about the count? The trick is in fact quite simple. Let\u0026rsquo;s say you have to count balls, and there are thousands of them. One way to do it is to count 1-by-1. But, if you have a machine that can approximately half the number of balls you have, it can be done a lot faster: you half the balls, then check if you have at least 5 doing 1-by-1 counting. If you do, you half them again, and check if you have at least 5, etc. Eventually, let\u0026rsquo;s say you halved it 11 times and now you are left with 3 balls. So approximately, you must have had 3*2^11 = 6144 balls to begin with. In the end you had to execute the 1-by-1 count only 11*5+3+1 =59 times \u0026ndash; a lot less than 6144! This is the idea used by ApproxMC.\nApproximately Halving Using XORs The \u0026ldquo;approximate halving\u0026rdquo; function used by ApproxMC is the plain XOR function, populated with variables picked with 50% probability. So for example if we have variables v1\u0026hellip;v10, we pick each variable with 50% probability and add them into the same XOR. Let\u0026rsquo;s say we picked v1,v2,v5 and v8. The XOR would then be: v1⊕v2⊕v5⊕v8=1. This XOR is satisfied if an odd number of variables from the set {v1,v2,v5,v8} are 1. This intuitively forbids about half the solutions. The \u0026ldquo;intuitively\u0026rdquo; part of course is not enough, and if you read the original paper you will find the rigorous mathematical proof for the approximate halving of solutions this XOR function provides.\nOK, so all we need to do is add these XORs to our original problem and we are done! This sounds easy, but there is a small hurdle and there is a big hurdle associated with this.\nThe small hurdle is that the original problem is a CNF, i.e. a conjunction of disjunctions, looking like \u0026ldquo;(v1 OR v2) AND (v2 OR not v3 OR not v4) AND\u0026hellip;\u0026rdquo;. The XOR obviously does not look like this. The straightforward translation of XOR into CNF is exponential, so we need to add some variables to cut them smaller. It\u0026rsquo;s not that hard to figure this out and eventually add all the XORs into the CNF.\nXORs, CDCL, and Gauss-Jordan Elimination The larger hurdle is that once the XORs are in the CNF using the translation, the CNF becomes exponentially hard to solve using standard CDCL as used in most SAT solvers. This is because Gauss-Jordan elimination is exponentially hard for the standard CDCL to perform \u0026ndash; but we need Gauss-Jordan elimination because the XORs will interact with each other, as we expect there to be many of them. Without being able to resolve the XORs with each other efficiently and derive information from them, it will be practically impossible to solve the CNF.\nThe solution is to tightly integrate Gauss-Jordan elimination into the solving process. CryptoMiniSat was the first solver to do this tight integration (albeit only for Gaussian elimination, which is sufficient). Other solvers have followed, in particular the work by Tero Laitinen and work by Cheng-Shen Han and Jie-Hong Roland Jiang. CryptoMiniSat currently uses the code by Han and Jiang after some cleanup and updates.\nThe latest work on ApproxMC and CryptoMiniSat has added one more thing besides the tight integration of the CDCL cycle: it now allows in- and pre-processing to occur while the XORs are inside the system. This brought some serious speedups as pre- and inprocessing are important factors in SAT solving. In fact, all modern SAT solvers strongly depend on them being active and working.\nConcluding Remarks We have gone from what model counting is, through how approximate counting works from a high-level perspective, all the way to the detail of running such a system inside a modern SAT solver. In case you want to try it out, you can do it by downloading the pre-built binaries or building it from source.\n","permalink":"https://www.msoos.org/2018/12/how-approximate-model-counting-works/","summary":"\u003cp\u003eApproximate model counting allows to count the number of solutions (or \u0026ldquo;models\u0026rdquo;) to propositional satisfiability problems. This problem seems trivial at first given a propositional solver that can find a single solution: find one solution, ban it, ask for another one, ban it, etc. until all solutions are counted. The issue is that sometimes, the number of solutions is 2^50 and so counting this way is too slow. There are about 2^266 atoms in the universe, so counting anywhere near that is impossible using this method.\u003c/p\u003e","title":"How Approximate Model Counting Works"},{"content":"This blogpost and its underlying work has been brewing for many years, and I\u0026rsquo;m extremely happy to be able to share it with you now. Kuldeep Meel and myself have been working very hard on speeding up approximate model counting for SAT and I think we have made real progress. The research paper, accepted at AAAI-19 is available here. The code is available here (release with static binary here). The main result is that we can solve a lot more problems than before. The speed of solving is orders(!) of magnitude faster than the previous best system:\nBackground The idea of approximate model counting, originally by Chakraborty, Meel and Vardi was a huge hit back in 2013, and many papers have followed it, trying to improve its results. All of them were basically tied to CryptoMiniSat, the SAT solver that I maintain, as all of them relied on XOR constraints being added to the regular CNF of a typical SAT problem.\nSo it made sense to examine what CryptoMiniSat could do to improve the speed of approximate counting. This time interestingly coincided with me giving up on XORs in CryptoMiniSat. The problem was the following. A lot of new in- and preprocessing systems were being invented, mostly by Armin Biere et al, and I quickly realised that I simply couldn\u0026rsquo;t keep adding them, because they didn\u0026rsquo;t take into account XOR constraints. They handled CNF just fine, but not XORs. So XORs became a burden, and I removed them in versions 3 and 4 of CryptoMiniSat. But there was need, and Kuldeep made it very clear to me that this is an exciting area. So, they had to come back.\nBlast-Inprocess-Recover-Destroy But how to both have and not have XOR constraints? Re-inventing all the algorithms for XORs was not a viable option. The solution I came up with was a rather trivial one: forget the XORs during inprocessing and recover them after. The CNF would always remain the source of truth. Extracting all the XORs after in- and preprocessing would allow me to run the Gauss-Jordan elimination on the XORs post-recovery. So I can have the cake and eat it too.\nThe process is conceptually quite easy:\nBlast all XORs into clauses that are in the input using intermediate variables. I had all the setup for this, as I was doing Bounded Variable Addition (also by Biere et al.) so I didn\u0026rsquo;t have to write code to \u0026ldquo;hide\u0026rdquo; these additional variables. Perform pre- or inprocessing. I actually only do inprocessing nowadays (as it has faster startup time). But preprocessing is just inprocessing at the start ;) Recover the XORs from the CNF. There were some trivial methods around. They didn\u0026rsquo;t work as well as one would have hoped, but more on that later Run the CDCL and Gauss-Jordan code at the same time. Destroy the XORs and goto 2. This system allows for everything to be in CNF form, lifting the XORs out when necessary and then forgetting them when it\u0026rsquo;s convenient. All of these steps are rather trivial, except, as I later found out, recovery.\nXOR recovery Recovering XORs sounds like a trivial task. Let\u0026rsquo;s say we have the following clauses\nx1 V x2 V x3 -x1 V -x2 V x3 x1 V -x2 V -x3 -x1 V x2 V -x3 This is conceptually equivalent to the XOR v1+v2+v3=1. So recovering this is trivial, and has been done before, by Heule in particular, in his PhD thesis. The issue with the above is the following: a stronger system than the above still implies the XOR, but doesn\u0026rsquo;t look the same. Let me give an example:\nx1 V x2 V x3 -x1 V -x2 V x3 x1 V -x2 V -x3 -x1 V x2 This is almost equivalent to the previous set of clauses, but misses a literal from one of the clauses. It still implies the XOR of course. Now what? And what to do when missing literals mean that an entire clause can be missing? The algorithm to recover XORs in such cases is non-trivial. It\u0026rsquo;s non-trivial not only because of the complexity of how many combinations of missing literals and clauses there can be (it\u0026rsquo;s exponential) but because one must do this work extremely fast because SAT solvers are sensitive to time.\nThe algorithm that is in the paper explains all the bit-fiddling and cache-friendly data layout used along with some fun algorithms that I\u0026rsquo;m sure some people will like. We even managed to use compiler intrinsics to use target-specific assembly instructions for hamming weight calculation. It\u0026rsquo;s a blast. Take a look.\nThe results The results, as shown above, speak for themselves. Problems that took thousands of seconds to solve can now be solved under 20. The reason for such incredible speedup is basically the following. CryptoMiniSatv2 was way too clunky and didn\u0026rsquo;t have all the fun stuff that CryptoMiniSatv5 has, plus the XOR handling was incorrect, loosing XORs and the like. The published algorithm solves the underlying issue and allows CNF pre- and inprocessing to happen independent of XORs, thus enabling CryptoMiniSatv5 to be used in all its glory. And CryptoMiniSatv5 is fast, as per the this year\u0026rsquo;s SAT Competition results.\nSome closing words Finally, I want to say thank you to Kuldeep Meel who got me into the National University of Singapore to do the work above and lots of other cool work, that we will hopefully publish soon. I would also like to thank the National Supercomputing Center Singapore that allowed us to run a ton of benchmarks on their machines, using at least 200 thousand CPU hours to make this paper. This gave us the chance to debug all the weird edge-cases and get this system up to speed where it beats the best exact counters by a wide margin. Finally, thanks to all the great people I had the chance to meet and sometimes work with at NUS, it was a really nice time.\n","permalink":"https://www.msoos.org/2018/11/approxmcv3-a-modern-approximate-model-counter/","summary":"\u003cp\u003eThis blogpost and its underlying work has been brewing for many years, and I\u0026rsquo;m extremely happy to be able to share it with you now. Kuldeep Meel and myself have been working very hard on speeding up approximate model counting for SAT and I think we have made real progress. The research paper, accepted at AAAI-19 is available \u003ca href=\"https://www.comp.nus.edu.sg/~meel/Papers/aaai19-sm.pdf\"\u003ehere\u003c/a\u003e. The code is available \u003ca href=\"https://github.com/meelgroup/ApproxMC\"\u003ehere\u003c/a\u003e (release with static binary \u003ca href=\"https://github.com/meelgroup/ApproxMC/releases\"\u003ehere\u003c/a\u003e). The main result is that we can solve a \u003cstrong\u003elot\u003c/strong\u003e more problems than before. The speed of solving is orders(!) of magnitude faster than the previous best system:\u003c/p\u003e","title":"ApproxMCv3, a modern approximate model counter"},{"content":"I have been reading a lot of privacy literature lately and the more I read, the more I got frustrated with the \u0026ldquo;Privacy by Design\u0026rdquo; motto. It somehow was not right, and made me realise that \u0026ldquo;Security by Design\u0026rdquo; motto is similarly hyped and is just as misguided. Let me explain.\nWhy security/privacy wasn\u0026rsquo;t baked in at the start First of all, the basics: \u0026ldquo;X by Design\u0026rdquo; means that security/privacy is baked into the product from the inception and design through to implementation, and all the way to operation. This of course sounds great, and one can easily see that trying to retroactively implement security or privacy features/requirements into an already existing product is a lot harder than baking it in all from the start. Where I think this starts to fall apart is that often, the reason for something being only \u0026ldquo;an afterthought\u0026rdquo; is not that it wasn\u0026rsquo;t actually considered while e.g. conceptualizing the product. It\u0026rsquo;s because it was considered but either:\nThere weren\u0026rsquo;t any people available who could help i.e. the security/privacy personnel were busy, expensive or too complicated to acquire/hire/consult or It wasn\u0026rsquo;t considered important to involve the right people/team because the project/product was supposed to be small/unimportant and security/privacy-irrelevant but over time it grew to be important/large In other words, it was either resource constraints or legitimate business reason not to spend resources on something (that was meant to be) small/irrelevant.\nReminiscing of the past What I see in a lot of these \u0026ldquo;X by Design\u0026rdquo; discussions is a set of technical people reminiscing about how awesome it would have been if e.g. Google built their search engine in 1998 with security/privacy in mind. Yes, it would have been, but the engineers writing the code had no idea if it would take off and had neither the time nor the money to spend on expensive consultants and long consultation periods to bake security/privacy in. The same can be said of many other startups\u0026rsquo; products and of most projects in large companies that grow to become products of their own.\nIf security and privacy engineers would have to be involved in all smaller projects then innovation would seriously suffer, because there are simply too few of us and we would take too long to take a sufficiently good look at everything (that might not take off anyway). So, since we cannot be involved at the beginning of every project, the best we can hope for is to fix it afterwards \u0026ndash; there is no point in reminiscing in how awesome it would have been if we were there when Twitter started in 2006. We weren\u0026rsquo;t there, it now took off and they are offering value to their customers, bringing in revenue which they are (hopefully) using to fix their security/privacy issues. I think it\u0026rsquo;s too optimistic to assume they could have afforded the delay-to-market and the price attached to doing it \u0026ldquo;right\u0026rdquo; from the start. Most probably, they couldn\u0026rsquo;t.\nLiving in the present All in all, I think a most of the \u0026ldquo;X by Design\u0026rdquo; is wishful thinking with some sermons attached to it, telling long tales of how things could have been so much better, had the right security/privacy people been consulted. What these tales often forget to tell is that when the idea was born, and the project/product was created, the situation was not even remotely amenable to such an intervention. Hence, I think it\u0026rsquo;s time to let go for the most part \u0026ndash; we should concentrate on doing what needs to be done. We should make sure we have solid processes and good, flexible patterns for fixing already existing products.\n","permalink":"https://www.msoos.org/2018/09/the-cult-of-security-privacy-by-design/","summary":"\u003cp\u003eI have been reading a lot of privacy literature lately and the more I read, the more I got frustrated with the \u0026ldquo;\u003ca href=\"https://iab.org/wp-content/IAB-uploads/2011/03/fred_carter.pdf\"\u003ePrivacy by Design\u003c/a\u003e\u0026rdquo; motto. It somehow was not right, and made me realise that \u0026ldquo;Security by Design\u0026rdquo; motto is similarly hyped and is just as misguided. Let me explain.\u003c/p\u003e\n\u003ch3 id=\"why-securityprivacy-wasnt-baked-in-at-the-start\"\u003eWhy security/privacy wasn\u0026rsquo;t baked in at the start\u003c/h3\u003e\n\u003cp\u003eFirst of all, the basics: \u0026ldquo;X by Design\u0026rdquo; means that security/privacy is baked into the product from the inception and design through to implementation,  and all the way to operation. This of course sounds great, and one can easily see that trying to retroactively implement security or privacy features/requirements into an already existing product is a lot harder than baking it in all from the start. Where I think this starts to fall apart is that often, the reason for something being only \u0026ldquo;an afterthought\u0026rdquo; is not that it wasn\u0026rsquo;t actually considered while e.g. conceptualizing the product. It\u0026rsquo;s because it was considered but either:\u003c/p\u003e","title":"The Cult of Security/Privacy By Design"},{"content":"Since CryptoMiniSat has been getting quite a number of awards with parallel SAT solving, it\u0026rsquo;s about time I talk about how it does that.There is a ton of literature on parallel SAT solving, and I unfortunately I have barely had time to read any of them. The only research within the parallel SAT solving area that I think has truly weathered the test of time is Plingeling and Treengeling -- and they are really interesting to play with. The rest most likely has some merit too, but I am usually suspect as the results are often \u0026ndash;unintentionally \u0026ndash; skewed to show how well the new idea performs and in the end they rarely win too many awards, especially not in the long run (this is where Plingeling and Treengeling truly shine). I personally haven\u0026rsquo;t published what I do in this scene because I have always found it to be a bit too easy and to hence have little merit for publication \u0026ndash; but maybe one day I will.\nNote: by unintentionally skewed results I mean that as you change parameters, some will inevitably be better than others because of randomness in the SAT solving. This randomness is easy to mistake for positive results. It has happened to everyone, I\u0026rsquo;m sure, including myself.\nExploiting CryptoMiniSat-specific features CryptoMiniSat has many different inprocessing systems and many parameters to turn them on/off or to tune them. It has over 60k lines of code which allows this kind of flexibility. This is unlike the Maple*/Glucose* set of solvers, all coming from MiniSat, which basically can do one thing, and one thing only, really well. That seriously helps in the single-threaded setup, but may be an issue when it comes to multi-threading. They have (almost) no inprocessing (there is now vivification in some Maple* solvers), and no complicated preprocessing techniques other than BVE, subsumption and self-subsuming resolution. So, there is little to turn on and off, and there are very few parameters \u0026ndash; and the few parameters that are there are all hard-coded into the solver, making them difficult to change.\nCryptoMiniSat in parallel mode To run in parallel mode, CMS takes advantage of its potential heterogeneity by running N different threads, each with radically different parameter settings, and exchanging nothing but unit and binary clauses(!) with the most rudimentary locking system. No exchange of longer clauses, no lockless exchanges, no complicated multi-lock system. One lock for unit clauses, one for binary, even for 24 threads. Is this inefficient? Yes, but it seems good enough, and I haven\u0026rsquo;t really had too many people asking for parallel performance. To illustrate, here are the parameter sets of the different threads used and here is the sharing and locking system. It\u0026rsquo;seriously simple, I suggest you take a peek, especially at the parameter sets.\nNote that the literature is full of papers explaining what kind of complicated methods can be used to exchange clauses using different heuristics, with pretty graphs, complicated reasoning, etc. I have to admit that it might be useful to do that, however, just running heterogeneous solvers in parallel and exchanging unit\u0026amp;binary clauses performs really well. In fact, it performs so well that I never, ever, in the entire development history of 7 years of CMS, ran even one full experiment to check parallel performance. I usually concentrate on single-threaded performance because checking parallel performance is really expensive.\nChecking the performance of a 24 thread setup is about 15x more expensive than the single-threaded variant. I don\u0026rsquo;t really want to burn the resources for that, as I think it\u0026rsquo;s good enough as it is. It\u0026rsquo;s mostly beating solvers with horrendously complicated systems inside them with many research papers backing them up, etc. I think the current performance is proof enough that making things complicated is not the only way to go. Maybe one day I will implement some more sophisticated clause sharing, e.g. sharing clauses that are longer than binary and then I won\u0026rsquo;t be able to claim that I am doing something quite simple. I will think about it.\nConclusions I am kinda proud of the parallel performance of CMS as it can showcase the heterogeneity of the system and the different capabilities of the solver. It\u0026rsquo;s basically doing a form of acrobatics where the solver can behave like a very agile SAT solver with one set of parameters or like a huge monolith with another set of parameters. Since there are many different parameters, there are many different dimensions, and hence there are many orthogonal parameter sets. It\u0026rsquo;s sometimes interesting to read through the different parameter settings and wonder why one set works so much better than the other on a particular type of benchmark. Maybe there could be some value in investigating that.\n","permalink":"https://www.msoos.org/2018/07/cryptominisat-and-parallel-sat-solving/","summary":"\u003cp\u003eSince CryptoMiniSat has been getting quite a number of awards with parallel SAT solving, it\u0026rsquo;s about time I talk about how it does that.There is a ton of literature on parallel SAT solving, and I unfortunately I have barely had time to read any of them. The only research within the parallel SAT solving area that I think has truly weathered the test of time is \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003ePlingeling and Treengeling\u003c/a\u003e -- and they are really interesting to play with. The rest most likely  has some merit too, but I am usually suspect as the results are often \u0026ndash;unintentionally \u0026ndash; skewed to show how well the new idea performs and in the end they rarely win too many awards, especially not in the long run (this is where Plingeling and Treengeling truly shine). I personally haven\u0026rsquo;t published what I do in this scene because I have always found it to be a bit too easy and to hence have little merit for publication \u0026ndash; but maybe one day I will.\u003c/p\u003e","title":"CryptoMiniSat and Parallel SAT Solving"},{"content":"The latest CryptoMiniSat, version 5.6.3 has been released. This release marks the 12'000th commit to this solver that has weathered more than I originally intended it to weather. It\u0026rsquo;s been an interesting ride, and I have a lot to thank Kuldeep and NSCC\u0026rsquo;s ASPIRE-1 cluster for this release. I have burned over 200k CPU hours to make this release, so it\u0026rsquo;s a pretty well-performing release (out-performing anything out there, by a wide margin), though I\u0026rsquo;m working very hard to make sure that neither I nor anyone else will have to burn anything close to that to make a well-performing SAT solver.\nThe solver has some interesting new algorithms inside, the most interesting of which is Gauss-Jordan elimination using a Simplex-like method, generously contributed by Jie-Hong Roland Jiang and Cheng-Shen Han from the National Taiwan University. This addition should finally settle the issues regarding Gaussian vs Gauss-Jordan elimination in SAT solvers. Note that to use this novel system, you must configure with \u0026ldquo;cmake -DUSE_GAUSS=ON ..\u0026rdquo; and then re-compile.\nWhat\u0026rsquo;s also interesting is what\u0026rsquo;s not inside, though. I have been reading (maybe too much) Nassim Taleb and he is very much into via negativa. So I tried removing algorithms that have been in the solver for a while and mostly nobody would question if they are useful. In the end I removed the following algorithms from running by default, each removal leading to better solving time:\nRegular probing. Intree probing is significantly better, so regular probing is not needed. Thanks Matti/Marijn/Armin! Stamping. This was a big surprise, especially because I also had to remove caching, which is my own, crappy (\u0026ldquo;different\u0026rdquo;) version of stamping. I knew that it wasn\u0026rsquo;t always so good to have, but damn. It was a hard call, but if it\u0026rsquo;s just slowing it down, what can I do. It\u0026rsquo;s weird. Burst searching. This is when I search for a short period with high randomness all over the search space. I thought it would allow me to explore the search space in places where VSIDS/Maple doesn\u0026rsquo;t. Why this is slowing the solver down so much may say more about search heuristics/variable bumping/clause bumping than anything. Note that I never had blocked clause elimination. It doesn\u0026rsquo;t work well for incremental solving. In fact, it doesn\u0026rsquo;t work at all, though apparently the authors have some new work that allows it to work, super-interesting! I\u0026rsquo;m nowadays committed to understanding this damned thing rather than adding another impossible-to-explain magic constant to make the solving 10% faster. I think there is interesting stuff out there that could be done to make SAT solvers 10x, not 10%, faster.\n","permalink":"https://www.msoos.org/2018/06/cryptominisat-5-6-3-released/","summary":"\u003cp\u003eThe latest CryptoMiniSat, version 5.6.3 has been \u003ca href=\"https://github.com/msoos/cryptominisat/releases/tag/5.6.3\"\u003ereleased\u003c/a\u003e. This release marks the 12'000th commit to this solver that has weathered more than I originally intended it to weather. It\u0026rsquo;s been an interesting ride, and I have a lot to thank \u003ca href=\"http://www.comp.nus.edu.sg/~meel/\"\u003eKuldeep\u003c/a\u003e and \u003ca href=\"https://www.nscc.sg/\"\u003eNSCC\u003c/a\u003e\u0026rsquo;s ASPIRE-1 cluster for this release. I have burned over 200k CPU hours to make this release, so it\u0026rsquo;s a pretty well-performing release (out-performing anything out there, by a wide margin), though I\u0026rsquo;m working \u003cem\u003every\u003c/em\u003e hard to make sure that neither I nor anyone else will have to burn anything close to that to make a well-performing SAT solver.\u003c/p\u003e","title":"CryptoMiniSat 5.6.3 Released"},{"content":"Compliance and regulations are one way to achieve IT security. If one looks at industries that have been around for a very long time, and have very high stakes, for example commercial airline travel, mining, oil\u0026amp;gas, etc., one can find compliance and regulations everywhere. It\u0026rsquo;s how safety is managed in these environments. I have always been fascinated with safety incidents and read a lot of reports around them \u0026ndash; these are almost always free to read and very detailed, unlike IT security incident reports. See for example the now very famous Challenger Accident Report (\u0026ldquo;For a successful technology, reality must take precedence over public relations, for nature cannot be fooled.\u0026rdquo;) or the similarly famous, and more recent AF-447 accident report. These are fascinating reads and if you are willing to read between the lines, they all talk about systems issues \u0026ndash; not a single person making a single mistake.\nHuman Errors and the Dangers of going Down and In Sydney Dekker talks a lot about safety, trust and accountability. I strongly suggest reading The Field Guide to Understanding \u0026lsquo;Human Error\u0026rsquo;, in it, he talks a lot about going \u0026ldquo;up and out\u0026rdquo; instead of \u0026ldquo;down and in\u0026rdquo; when an accident happens. That is, instead of trying to e.g. pin the line of code that ultimately allowed the remote code execution, and who exactly wrote it, he advocates to map out the people, processes and technologies that allowed that code not only to be written, but to be approved, deployed to and stay in production until it ultimately allowed the security incident to happen. Once these are mapped out, he advocates for inviting the practitioners creating security at all these junctions to collaboratively find a way to reduce the risk of the incident happening again.\nBecause here is the issue with going down and in: you blame the person who committed the code, fix the code, berate/fire/demote her or him, and you are now \u0026ldquo;done\u0026rdquo;. Anybody who works in security knows that\u0026rsquo;s not going to fix the issue. When there is one SQLi, there is usually a lot more. When you see no AWS Config rules, you usually expect the AWS deployment to be nearly-devoid of security auditing, detective and reactive controls. That\u0026rsquo;s just how people (and hence organisations) work. We need to do better than just blame the individual.\nAs far as I can understand, what Dekker advocates for, when translated to security, is to make your practitioners not fear but embrace the security support that is available in your organisation, to make the security engineers engage with these practitioners so they better understand what to look out for \u0026ndash; from potential security vulnerabilities to indicators of compromise \u0026ndash; and not be worried to report their fears. If there is fear that reporting issues will lead to complicated and unnecessary security audits, that their work (which ultimately everybody prides themselves on) will get taken over and potentially taken out of their hands if they do report, then you will not hear of potential issues early, allowing you to remediate before the issues become serious.\nCulture of Security The above runs in parallel with what Dekker says about minor accidents in the workplace. The more there are of these (reported) the less there is of major accidents that will happen \u0026ndash; remember, BP and Transocean managers were on board to celebrate seven years without a lost-time accident on the Deepwater Horizon, when it blew up. This is as much counter-intuitive in safety as it is in security, yet it makes sense in both, for the very same reasons.\nThe more you push your small issues under the carpet, the more you are likely to have bigger ones down the road \u0026ndash; because you are actively discouraging safety/security culture in your organisation. Instead, an open discussion of both safety and security allows the practitioners to voice their concerns, and for the processes to be adapted to their concerns, allowing for higher production throughput and higher safety/security, and, crucially, for engagement from the very practitioners you must rely on to create security. Because here is the real catch: security is created every single day, by the people who write the code, review it, deploy it, and maintain and monitor the deployed environment.\nEngaging the Sharp End IT security engineers cannot read every code commit, be there at every deployment, check every change to every environment deployed. The people performing these actions are at the point the safety industry calls \u0026ldquo;the sharp end\u0026rdquo; \u0026ndash; practitioners making security-critical decisions every single day. What IT security engineers can do, however, is to educate those who are there, to give them support when they need it, and most importantly, to engender a culture where asking for help by people at the sharp end is not a recipe for someone to whack your job out of your hand and \u0026ldquo;to do it right\u0026rdquo; or create a new process without involving the practitioners, telling them how it must be done. Instead, the security engineers and culture should assure the person reporting that they will be made part of the solution, whatever it may be.\nPS: Thanks to all, some colleagues, some not, who have made me think about all of the above\u0026hellip; it\u0026rsquo;s still a work in progress :)\n","permalink":"https://www.msoos.org/2017/12/security_differently/","summary":"Compliance and regulations are one way to achieve IT security. If one looks at industries that have been around for a very long time, and have very high stakes, for example commercial airline travel, mining, oil\u0026amp;gas, etc., one can find compliance and regulations everywhere. It\u0026rsquo;s how safety is managed in these environments. I have always been fascinated with safety incidents and read a lot of reports around them \u0026ndash; these are almost always free to read and very detailed, unlike IT security incident reports. See for example the now very famous \u003ca href=\"https://www.e-education.psu.edu/files/meteo361/file/nasa_report.pdf\"\u003eChallenger Accident Report\u003c/a\u003e (\u0026ldquo;For a successful technology, reality must take precedence over public relations, for nature cannot be fooled.\u0026rdquo;) or the similarly famous, and more recent \u003ca href=\"https://www.bea.aero/docspa/2009/f-cp090601.en/pdf/f-cp090601.en.pdf\"\u003eAF-447 accident\u003c/a\u003e report. These are fascinating reads and if you are willing to read between the lines, they all talk about systems issues \u0026ndash; not a single person making a single mistake.","title":"IT Security Differently"},{"content":"I have been involved in computer security and security testing for a while and I think it\u0026rsquo;s time to talk about some aspects of it that get ignored, mostly for the worse. Let me just get this out of the way: security testing (or pentesting, if you like) and testing are very closely related.\nThe Testing Pyramid What\u0026rsquo;s really good about security testing being so close to testing is that you can apply the standard, well-know and widely used techniques from testing to the relatively new field of security testing. First of all, this chart: This chart essentially means: you should have a lot of unit tests, less but many module and integration tests, a good number of user acceptance tests, and then perform some exploratory testing. The rough definition of exploratory testing is \u0026ldquo;simultaneous learning, test design and test execution\u0026rdquo;. If you have ever seen or performed a pentest, you will know that that\u0026rsquo;s precisely what we do. We come in, at a pretty steep price per day, learn how the system works, come up with test cases on the spot and execute a stream of tests, dynamically adjusting our test strategies to the application at hand. At the end we give a report to the client of what we found and throw away our application-specific test strategies.\nOnce one realises that security testing/pentesting is exploratory testing, the question of \u0026ldquo;what about the other test types?\u0026rdquo; comes naturally. Because the test literature will tell you in no uncertain terms: exploratory testing is the most expensive and least effective way to perform regular testing. It is great to find the one-off, odd things, and has its place in the testing strategy that one must employ. But it\u0026rsquo;s incredibly ineffective for tests that can be performed at the unit, module, integration or user acceptance level. And there are many of those.\nAn Example I used to work at a large company where I was put in charge of the security of one of their products. Of course the first week I did exploratory testing \u0026ndash; to see what the application did, how did its subcomponents fare in general, to get a feel for what needs to be prioritised. And then I started walking down that pyramid. I fixed up and added a lot of user acceptance tests, e.g. using Codenomicon, a black-box testing tool perfect for user acceptance testing-level tests. The team I worked at had a very extensive test system and test infrastructure, with well-defined strategies and many-many hooks into the system to make testing easier. These are incredibly important to have if you want to perform any kind of effective testing below the exploratory testing level. Once a bunch of security acceptance tests were set up and running as part of their continuous integration system, I went lower, to the module level, and added more effective, but more difficult to set up tests such as AFL-based feedback fuzzers. At this level, you\u0026rsquo;ll be finding bugs that are a lot easier to triage, fix and validate, but it takes longer to set up the system.\nLimitations of Pentesting You will be surprised how often security consulting companies are engaged to manually test a system where testers (i.e. humans) are manually firing off trivial inputs such as \u0026ldquo;\u0026lt;script\u0026gt;alert(1)\u0026lt;/script\u0026gt;\u0026rdquo; into parameters and find bugs. Of course at this point, any sane tester would say: but why don\u0026rsquo;t we, security consultants, automate this within the scope of the engagement? It\u0026rsquo;d be kind of like an acceptance test, though still a lot more expensive, but at least fast, automated and the automation could be given to the client as a by-product of the engagement, lowering long-term costs. The reality is that one cannot just fire off those inputs for a number of reasons, mostly to do with poor/unavailable testing infrastructure or unavailable/non-existent test hooks. First of all, I cannot just spin up 20 virtual systems and fire these off in parallel. Typically there are many injection points and many inputs to fire off \u0026ndash; remember, these multiply. When I was integrated into the test team, I could just launch a bunch of VMs and perform tens of millions of tests in a matter of (wall-clock) hours. VMs are lot cheaper than humans \u0026ndash; testing infrastructure matters. Secondly, a lot of applications have controls (or poor code) in place that detect manipulation (or simply go haywire) and log out the user. Hence one must draw up strategies how to evade these controls. These controls should be turned off, but whenever I get to see the code I know that they cannot be turned off, the option is just not there. Testing hooks matter.\nSwimming Against the Tide Of course \u0026ldquo;\u0026lt;script\u0026gt;alert(1)\u0026lt;/script\u0026gt;\u0026rdquo; and \u0026ldquo;\u0026rsquo; or 1=1;\u0026ndash;\u0026rdquo; are not the end of all security testing. They are trivial inputs and don\u0026rsquo;t go deep at all. But do you really want to pay someone several hundred a day to send these? More complicated inputs can also be automated \u0026ndash; Codenomicon and AFL will create some incredibly complex inputs if you correctly hook them up and give them a week or so of CPU time (not wall-clock time). Naturally, few if any automated tests will find issues with business logic on their own \u0026ndash; e.g. one user making a transaction as another user. However, a good bunch of these can be automated too, e.g. by a hook that fixes down your session as one user and launching an automated tool, checking for transactions performed by other users. There are diminishing returns here, and some business logic and some deeper issues can probably only be revealed by a combination of threat modelling and exploratory security testing. But ignoring all unit/module/integration/user acceptance security tests will forever make you feel like you are swimming against a tide. It is not hard to find people responsible for information security in large organisations completely swamped, running from one disastrous pentest report and maybe even incident, to the next.\nAt this point, most likely you\u0026rsquo;re thinking: this all sounds good, but how will I get buy-in from upper\u0026amp;lower management and the development\u0026amp;test team to integrate security testing into standard processes? I can only talk from experience: you don\u0026rsquo;t sell security as strictly relating to \u0026ldquo;evil hackers\u0026rdquo;. I got buy-in partially also because ~80% of the security bugs that were found through all the lower-level tests also had a non-security impact (e.g. see Guy Leaver\u0026rsquo;s OpenSSL bug). Further, the inputs to exercise security issues were generally different (and often more concise and repeatable), hence issues that were known but were hard to poinpoint could finally be nailed to the exact line of code. Developers love fixing bugs that take less than 1 hour to go from bug report to fix committed. Find someone to help you draw up a strategy to add such tests and to help your developers write more secure code and soon you will no longer be swimming against the tide.\nHopes for More Interesting (and Valuable) Security Tests If all the above sounds like I\u0026rsquo;m advocating against my own work, I\u0026rsquo;m not. I\u0026rsquo;m doing the exact opposite. I\u0026rsquo;m advocating for systems to have less trivial bugs, better test infrastructure and more test hooks so when I come in and perform an exploratory security test (pentest, if you like), I can have the most leverage possible to help. I will launch \u0026ldquo;\u0026lt;script\u0026gt;alert(1)\u0026lt;/script\u0026gt;\u0026rdquo; if that\u0026rsquo;s what\u0026rsquo;s required, but I\u0026rsquo;d much rather help out with the more complicated stuff that needs specialised knowledge \u0026ndash; from business logic through security test strategies to threat modeling. There is more value in there.\n","permalink":"https://www.msoos.org/2017/05/testing-and-pentesting/","summary":"\u003cp\u003eI have been involved in computer security and security testing for a while and I think it\u0026rsquo;s time to talk about some aspects of it that get ignored, mostly for the worse. Let me just get this out of the way: security testing (or \u003ca href=\"https://en.wikipedia.org/wiki/Penetration_test\"\u003epentesting\u003c/a\u003e, if you like) and testing are \u003cem\u003every\u003c/em\u003e closely related.\u003c/p\u003e\n\u003ch3 id=\"the-testing-pyramid\"\u003eThe Testing Pyramid\u003c/h3\u003e\n\u003cp\u003eWhat\u0026rsquo;s really good about security testing being so close to testing is that you can apply the standard, well-know and widely used techniques from testing to the relatively new field of security testing. First of all, this chart:\n\u003cimg loading=\"lazy\" src=\"http://www.msoos.org/wordpress/wp-content/uploads/2017/05/triangle3.png\"\u003e\u003c/p\u003e\n","title":"Testing and pentesting, a road to effectiveness"},{"content":"I\u0026rsquo;ve been reading through the source code of the 2016 SAT Competition Main Track winner, MapleCOMSPS_DRUP, and I found that it has an important piece of code, regulating its behaviour that depends on timing:\nstatic bool switch_mode = false; static void SIGALRM_switch(int signum) { switch_mode = true; } lbool Solver::solve_() { signal(SIGALRM, SIGALRM_switch); alarm(2500); This makes it difficult or potentially impossible to reproduce results. If you are unfamiliar with SAT solvers, they are difficult to understand and debug because their behaviour is randomised by the heuristic algorithmic choices which are influenced by essentially every solving parameter and every line of the input. However, with careful coding and the same parameters and input file, they run the same way. Unfortunately, that\u0026rsquo;s not always the case for this solver. Although the authors of the solver have fixed this, and you can download their fixed solvers here, I would like to talk about this a bit longer.\nUsability issues Without reproducibility, it can be hard to check results with the solver. One could have found a solution to an instance and if it doesn\u0026rsquo;t get solved on another try, it is most likely due to the timing of that alert(), which is something neither the original designers intended, nor the person trying to reproduce the results wishes to deal with.\nAn industrial system designer would have trouble choosing systems that don\u0026rsquo;t behave in a deterministic manner, even if they are the fastest. Debugging such systems could become very difficult. For example, if there are multiple solutions, such a solver, when unpatched, may return different solutions on different runs, with possibly different runtimes. Industrial systems often contain millions of lines of code, where a complex bugs may need to be hunted down on a regular basis \u0026ndash; non-reproducibility could seriously hinder such an efforts.\nFixes First of all, I think it\u0026rsquo;s a healthy sign that the authors recognised the issue and fixed it for the next iteration. It\u0026rsquo;s a shame, however, that this bug could slip through. I actually believed that there was a requirement that the solving must be reproducible. I believe such checks should be performed before the competition begins so the authors could fix their code before they win the competition with a bug that they didn\u0026rsquo;t intend to have.\nIt is important to have these kind of bugs being eliminated. Note that Microsoft spent a non-negligible amount of time and effort to make parallel SAT solving reproducible. I imagine the pressure they had from their industrial use-cases to have been considerable for such an effort to have been undertaken.\nA potential fix for the future The authors have fixed this issue for 2017. However, the winner of the 2017 SAT Competition, Maple_LCM_Dist, has the same bug as above since that team used the original, winning code without checking or consulting with the original team. So the new winner produces an output that may be non-reproducible, like last year. I am hopeful that this bug will eventually get removed, but it would have been nicer to have a pre-run of the competition that checks for such issues and gives some time for the authors to fix the potential non-reproducibility issues.\n","permalink":"https://www.msoos.org/2017/02/non-reproducible-maplecomsps/","summary":"\u003cp\u003eI\u0026rsquo;ve been reading through the source code of the \u003ca href=\"http://baldur.iti.kit.edu/sat-competition-2016/index.php?cat=results\"\u003e2016 SAT Competition\u003c/a\u003e Main Track winner, \u003ca href=\"https://sites.google.com/a/gsd.uwaterloo.ca/maplesat/\"\u003eMapleCOMSPS_DRUP\u003c/a\u003e, and I found that it has an important piece of code, regulating its behaviour that depends on timing:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-c++\" data-lang=\"c++\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003estatic\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003ebool\u003c/span\u003e switch_mode \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e false;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003estatic\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003evoid\u003c/span\u003e \u003cspan style=\"color:#a6e22e\"\u003eSIGALRM_switch\u003c/span\u003e(\u003cspan style=\"color:#66d9ef\"\u003eint\u003c/span\u003e signum) { switch_mode \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e true; }\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003elbool Solver\u003cspan style=\"color:#f92672\"\u003e::\u003c/span\u003esolve_()\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e{\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    signal(SIGALRM, SIGALRM_switch);\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    alarm(\u003cspan style=\"color:#ae81ff\"\u003e2500\u003c/span\u003e);\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e","title":"Non-reproducible results with MapleCOMSPS"},{"content":"I read this paper about most research findings being false. Given that most research papers in SAT take a sample size that is incredibly small (especially considering that it\u0026rsquo;s cheap to have large sample sizes relative to, e.g. medical trials), and the samples are very often hand-picked, it\u0026rsquo;s easy to see why this could be the case. But that article lists a number of other factors, too, and they are interesting to consider as well. Only few true innovations stick around in SAT (glues, VSIDS, UIP, restarts, etc). Most are forgotten because, frankly, they didn\u0026rsquo;t show the promise they purported to have. It\u0026rsquo;d be interesting to force authors to e.g. run their systems on much larger sample sizes (e.g. 2-3000 instances from SAT competitions) with much longer timeouts (e.g. 5000s). Then those implementing SAT solvers wouldn\u0026rsquo;t have to wade through piles of articles to get to something worth implementing. One is allowed to dream.\n","permalink":"https://www.msoos.org/2017/01/why-most-published-research-false/","summary":"\u003cp\u003eI read this paper about \u003ca href=\"http://journals.plos.org/plosmedicine/article/file?id=10.1371/journal.pmed.0020124\u0026amp;type=printable\"\u003emost research findings being false\u003c/a\u003e. Given that most research papers in SAT take a sample size that is incredibly small (especially considering that it\u0026rsquo;s cheap to have large sample sizes relative to, e.g. medical trials), and the samples are very often hand-picked, it\u0026rsquo;s easy to see why this could be the case. But that article lists a number of other factors, too, and they are interesting to consider as well. Only few true innovations stick around in SAT (\u003ca href=\"http://www.ijcai.org/Proceedings/09/Papers/074.pdf\"\u003eglues\u003c/a\u003e, \u003ca href=\"http://www.princeton.edu/~chaff/publication/DAC2001v56.pdf\"\u003eVSIDS, UIP, restarts\u003c/a\u003e, etc). Most are forgotten because, frankly, they didn\u0026rsquo;t show the promise they purported to have. It\u0026rsquo;d be interesting to force authors to e.g. run their systems on much larger sample sizes (e.g. 2-3000 instances from SAT competitions) with much longer timeouts (e.g. 5000s). Then those implementing SAT solvers wouldn\u0026rsquo;t have to wade through piles of articles to get to something worth implementing. One is allowed to dream.\u003c/p\u003e","title":"Why Most Published Research Findings Are False"},{"content":"A new version of CryptoMiniSat, 5.0.1 has been released. It is essentially only a release to mark the move to a much more permissive, MIT license. I am changing the license so that everyone can use the system as they wish, however they wish. I want to give back to the community I have been part of for so long, and so I am making this change. Thank you all for using the solver, it makes me happy that I have been able to help some with my hobby work.\n","permalink":"https://www.msoos.org/2016/09/cryptominisat-5-0-1-released-with-mit-license/","summary":"\u003cp\u003eA new version of CryptoMiniSat, 5.0.1 has been \u003ca href=\"https://github.com/msoos/cryptominisat/releases/tag/5.0.1\"\u003ereleased\u003c/a\u003e. It is essentially only a release to mark the move to a much more permissive, MIT license. I am changing the license so that everyone can use the system as they wish, however they wish. I want to give back to the community I have been part of for so long, and so I am making this change. Thank you all for using the solver, it makes me happy that I have been able to help some with my hobby work.\u003c/p\u003e","title":"CryptoMiniSat 5.0.1 released -- with MIT license"},{"content":"An artist friend of mine gave me this idea, so here is the list of the most used words of those executed in Texas, from their last statement:\nword frequency ----------------------- you 4.670330 and 3.945360 the 3.670635 for 2.701465 love 2.419109 ** that 2.190171 all 2.113858 have 1.663614 this 1.297314 thank 1.030220 ** know 1.014957 family 0.969170 ** your 0.908120 not 0.839438 will 0.808913 god 0.801282 ** want 0.801282 would 0.778388 with 0.755495 i\u0026#39;m 0.755495 sorry 0.747863 ** like 0.740232 say 0.679182 but 0.641026 life 0.595238 ** what 0.579976 there 0.549451 ya\u0026#39;ll 0.534188 hope 0.488400 ** them 0.488400 ","permalink":"https://www.msoos.org/2016/07/texas-executed-offenders-last-words/","summary":"\u003cp\u003eAn artist friend of mine gave me this idea, so here is the list of the most used words of those \u003ca href=\"http://www.tdcj.state.tx.us/death_row/dr_executed_offenders.html\"\u003eexecuted in Texas\u003c/a\u003e, from their last statement:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-plain\" data-lang=\"plain\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eword       frequency\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-----------------------\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     you   4.670330\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     and   3.945360\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     the   3.670635\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     for   2.701465\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    love   2.419109 **\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    that   2.190171\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     all   2.113858\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    have   1.663614\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    this   1.297314\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e   thank   1.030220 **\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    know   1.014957\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  family   0.969170 **\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    your   0.908120\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     not   0.839438\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    will   0.808913\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     god   0.801282 **\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    want   0.801282\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e   would   0.778388\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    with   0.755495\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     i\u0026#39;m   0.755495\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e   sorry   0.747863 **\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    like   0.740232\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     say   0.679182\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e     but   0.641026\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    life   0.595238 **\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    what   0.579976\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e   there   0.549451\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e   ya\u0026#39;ll   0.534188\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    hope   0.488400 **\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    them   0.488400\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e","title":"Texas Executed Offenders' Last Words"},{"content":"CryptoMiniSat 5.0.0, after winning the incremental track at SAT Competition 2016 and getting 3rd place at the parallel track, has been released. The new solver contains a number of important additions. The most important are that the solver can now be used as a preprocessor and Gauss-Jordan Elimination is back.\nPreprocessor usage The solver can now be used to preprocess CNF or CNF+XOR instances into a simplified, pure CNF instance. This means you will now be able to use CrypoMiniSat as a preprocessor to your favourite SAT solver. To use CryptoMiniSat in this context, just do:\n./cryptominisat5 -p1 input.cnf simplified.cnf #let\u0026#39;s run a different solver to solve the simplified CNF some_sat_solver simplified.cnf \u0026gt; output #let\u0026#39;s get the final solution ./cryptominisat5 -p2 output You can also change the global timeout for all the preprocessing stages by setting for example \u0026ldquo;-m 2.0\u0026rdquo;, that doubles the timeout for every preprocessing step. You can also change the order of the preprocessing steps. Just pass the option \u0026lsquo;\u0026ndash;preschedule \u0026ldquo;SCHEDULE\u0026rdquo; \u0026rsquo; where the default schedule is:\nhandle-comps,scc-vrepl, cache-clean, cache-tryboth,sub-impl, intree-probe, probe, sub-str-cls-with-bin, distill-cls, scc-vrepl, sub-impl,occ-backw-sub-str, occ-xor, occ-clean-implicit, occ-bve, occ-bva, occ-gates,str-impl, cache-clean, sub-str-cls-with-bin, distill-cls, scc-vrepl, sub-impl,str-impl, sub-impl, sub-str-cls-with-bin, occ-backw-sub-str, occ-bve,check-cache-size, renumber Note that \u0026ldquo;renumber\u0026rdquo; is variable re-numbering and you probably want to have at as the very last. You can have any of these inprocessing steps any number of times. The \u0026ldquo;occ-*\u0026rdquo; ones should be next to one another as they then share the same occurrence list, reducing the number of times the occurrence list needs to be built.\nGauss-Jordan Elimination Gaussian elimination is back! It now works with all the inprocessing steps that have been mostly invented by trio of Biere, Heule and Jarvisalo. To use Gauss-Jordan elimination, build the system as:\ntar xzvf cryptominisat-5.0.0.tar.gz cd cryptominisat mkdir build \u0026amp;\u0026amp; cd build cmake -DUSE_GAUSS=ON .. make You will then end up with a cryptominisat5 that has Gauss-Jordan elimination compiled in. It auto-detects whether it\u0026rsquo;s useful on the CNF passed. In case you know you must use it, pass the option \u0026ldquo;\u0026ndash;autodisablegauss 0\u0026rdquo; so Gauss-Jordan doesn\u0026rsquo;t get disabled. If you need more matrixes than default, pass \u0026ldquo;\u0026ndash;maxnummatrixes N\u0026rdquo;.\nExecutable Binaries Static executable binaries have been released for CryptoMiniSat 5.0.0 for both Linux and Windows. It should be easy to build binaries on most platforms though, including OS X, Linux, and Windows. Please see the release page.\nFuture Work I plan on incorporating Tero Laitinen\u0026rsquo;s work so the Gauss-Jordan elimination might get somewhat better. Gauss-Jordan might come pre-compiled in the future with the system. I also plan to incorporate the SAT Competition Main track\u0026rsquo;s winner idea into mainline CryptoMiniSat. These should come with CryptoMiniSat 5.1.0\n","permalink":"https://www.msoos.org/2016/07/cryptominisat-5-0-0-released/","summary":"CryptoMiniSat 5.0.0, after winning the incremental track at \u003ca href=\"http://baldur.iti.kit.edu/sat-competition-2016/index.php?cat=results\"\u003eSAT Competition 2016\u003c/a\u003e and getting 3rd place at the parallel track, has been \u003ca href=\"https://github.com/msoos/cryptominisat/releases/tag/cryptominisat-5.0.0\"\u003ereleased\u003c/a\u003e. The new solver contains a number of important additions. The most important are that the solver can now be used as a preprocessor and Gauss-Jordan Elimination is back.","title":"CryptoMiniSat 5.0.0 released"},{"content":"I have been writing software for more than 20 years now. I thought it\u0026rsquo;s about time to gather my experiences and write some advice on building better software.\n1. Solve the right problem It is all too often that one tries solving something before understanding the problem at hand. We have a certain understanding of what the issue is, write something to solve it, but it turns out that we wrote the wrong solution because we misunderstood the problem. Do some research, read some articles, talk to people and read some books before attempting to solve a problem.\n2. Don\u0026rsquo;t rewrite the wheel You need a web server? Use an off-the-shelf one. It\u0026rsquo;ll be supported, it will be stable and it will implement the whole specification. Developers all too often think they can just write an XML parser overnight. Maybe for a simple one, but have you considered all the edge cases? How about UTF-16 character encoding in big endian mode? Are you prepared to support this code for the next 10 years?\n3. Think about who, when, and where will use the system Who is likely to use this system? How will their understanding of the system shape their usage? With what intent will they approach the system? Will they be forced to use it? Will they be trained? How can you train/help them? Will it be used for short periods of time only? You may need to make the interface very simple then \u0026ndash; you can\u0026rsquo;t have deep menus and 20 configuration parameters. Will it be used by professionals? They might easily accommodate (and need) hundreds of settings.\n4. Create simple prototype(s) and keep iterating Try creating something simple that can do the job. If it doesn\u0026rsquo;t fully address the issue yet, you can now gain a better understanding of how the product works when it\u0026rsquo;s plugged into the processes of the people it\u0026rsquo;s supposed to help. Observe and fix what seems to be missing. Remember, if it aint\u0026rsquo;t broke, don\u0026rsquo;t fix it.\n5. Focus on the customer experience The classic example is that people will be happier if you can accurately tell them that there are 10 minutes left to finish a task rather than not showing them anything but finishing in only 5 minutes. Never forget what purpose the software is supposed to fulfil. Customer experience is paramount.\n6. Design the system for change There is only one thing that is constant about any project I\u0026rsquo;ve ever worked on: change. Requirements change, our understanding of the processes change, the underlying hardware and software environment changes, the legal and social framework the system is operated in changes. If you want to build for success, you have to make sure the system can accommodate these changes over time. Building rigid systems essentially sets you up for failure.\n6. Don\u0026rsquo;t do everything that every customer wants Tactics without strategy is the noise before defeat. Have a long-term strategy in mind where you want your system to go. Without such a strategy in place, it will be hard to know which customer demands should be fulfilled.\n7. Don\u0026rsquo;t just fix bugs. Fix the specification. The specification should be part of your test suite. If there is a bug it means that your specification was incomplete or wrong. The hardest bugs are rarely technological. They are almost always a bug in the specification. Fix the specification by adding the missing tests and make sure the specification is just as agile as your software development. Your specification must change, so your test suites, tools, and environments must be easy to maintain and change.\n8. Enjoy doing what you do Enjoying what you do, and making sure everyone on the team enjoys it too, makes not only for a fun time, but will also make people on the project committed to its success. Every project experiences ups and downs. In order to wither these storms and keep people around with deep knowledge and understanding of both the product and its environment (human, technological, process, legal, social), you have to make sure that everyone in the team is enjoying working on the project. Remember: it\u0026rsquo;s the people who build, maintain, and sell the system.\n","permalink":"https://www.msoos.org/2016/04/eight-pro-tips-on-creating-better-software/","summary":"\u003cp\u003eI have been writing software for more than 20 years now. I thought it\u0026rsquo;s about time to gather my experiences and write some advice on building better software.\u003c/p\u003e\n\u003ch3 id=\"1-solve-theright-problem\"\u003e1. Solve the right problem\u003c/h3\u003e\n\u003cp\u003eIt is all too often that one tries solving something  before understanding the problem at hand. We have a certain understanding of what the issue is, write something to solve it, but it turns out that we wrote the wrong solution because we misunderstood the problem. Do some research, read some articles, talk to people and read some books before attempting to solve a problem.\u003c/p\u003e\n","title":"Eight Pro Tips on Creating Better Software"},{"content":"I have been trying to debug why some MiniSat-based solvers perform better at unit propagation than CryptoMiniSat. It took me exactly 3 full days to find out and I\u0026rsquo;d like to share this tidbit of information with everyone, as I think it might be of interest and I hardly believe many understand it.\nThe mystery of the faster unit propagation was that I tried my best to make my solver behave exactly as MiniSat to debug the issue, but even though it was behaving almost identically, it was still slower. It made no sense and I had to dig deeper. You have to understand that both solvers use their own memory managers. In fact, CryptoMiniSat had a memory manager before MiniSat. Memory managers are used so that the clauses are put close to one another so there is a chance that they are in the same memory page, or even better, close enough for them not to waste memory in the cache. This means that a contiguous memory space is reserved where the clauses are placed.\nThe code The high-level logic when consolidating memory, i.e. removing unused clauses from this space is the following in CryptoMiniSat:\nn = malloc(enough_space) start = n for offset in clauses: Clause* old_cl = base + offset copy(n, old_cl, cl-\u0026gt;size()) old_cl-\u0026gt;new_offset = n-start offset = n-start n += cl.size() for w in watches: w.offset = (base + w.offset)-\u0026gt;new_offset free(base) base = start In contrast, in MiniSat it\u0026rsquo;s:\nn = malloc(enough_space) : start = n for w in watches: Clause* old_cl = base + w.offset if !old_cl-\u0026gt;updated: copy(n, old_cl, old_cl-\u0026gt;size()) old_cl-\u0026gt;new_offset = n-start old_cl-\u0026gt;updated = true w.offset = n-start n += old_cl-\u0026gt;size() else: w.offset = old_cl-\u0026gt;new_offset for offset in clauses: offset = (base + offset)-\u0026gt;new_offset free(base) base = start So the difference seemed like this: CryptoMiniSat was a bit simpler, not using the \u0026lsquo;updated\u0026rsquo; flag, and MiniSat was a bit more complex. But if you look closely, you\u0026rsquo;ll discover something quite mind-bending. When I realized I had to stop working for about 10 minutes. The genius is right in there.\nThe trick MiniSat puts clauses next to each other in memory that are next to each other in the watchlist. This, heuristically speaking, means that with a good chance, these clauses will be dereferenced one after the other \u0026ndash; and one will pull in the other due to automatic pre-caching of contiguous memory blocks. Note that especially if blocking literals are used, watchlist elements tend to stay close to one another.\nConclusion So that is how I wasted three days of my life. It was a fun chase, though. I wonder how many more are in there. I know of only one more, which I also found to be a lot of fun, and it\u0026rsquo;s about the position of the size of the clause in the clause data structure. But I\u0026rsquo;ll let you figure that one out.\n","permalink":"https://www.msoos.org/2016/03/memory-layout-of-clauses-in-minisat/","summary":"\u003cp\u003eI have been trying to debug why some \u003ca href=\"https://github.com/niklasso/minisat\"\u003eMiniSat\u003c/a\u003e-based solvers perform better at \u003ca href=\"https://en.wikipedia.org/wiki/Unit_propagation\"\u003eunit propagation\u003c/a\u003e than CryptoMiniSat. It took me exactly 3 full days to find out and I\u0026rsquo;d like to share this tidbit of information with everyone, as I think it might be of interest and I hardly believe many understand it.\u003c/p\u003e\n\u003cp\u003eThe mystery of the faster unit propagation was that I tried my best to make my solver behave exactly as MiniSat to debug the issue, but even though it was behaving almost identically, it was still slower. It made no sense and I had to dig deeper. You have to understand that both solvers use their own memory managers. In fact, CryptoMiniSat had a memory manager before MiniSat. Memory managers are used so that the clauses are put close to one another so there is a chance that they are in the same memory page, or even better, close enough for them not to waste memory in the cache. This means that a contiguous memory space is reserved where the clauses are placed.\u003c/p\u003e\n","title":"Memory layout of clauses in MiniSat"},{"content":"Things are heating up for the SAT competition 2016. I will of course compete. However, I would publicly like to ask the organisers to please for the love of whatever you believe in, please randomise the benchmarks. Just a tiny, little bit. It\u0026rsquo;s ridiculous that people are tuning their solvers so they can solve some randomly solveable instance like the vmpc* series. It\u0026rsquo;s laughable and it\u0026rsquo;s making the whole community look bad. Really, it\u0026rsquo;s time to stop this madness. I wrote that article with a bunch of ideas in 2013. It\u0026rsquo;s time. Not even the largest of organisations move this slowly, and this is a research group of about 50 people max.\nNobody on the face of the Earth will believe that if you swap the first 2 clauses of a CNF instance that typically contains at least 100 thousand clauses, you have somehow substantially altered the problem. Please, it\u0026rsquo;s crazy what is going on. I don\u0026rsquo;t care what method you choose. Swap the literals, swap the clauses, rename some variables, propagate some of them (really, all sane solvers propagate variables, I cannot possibly see how that could in any way change the results). You are a creative crowd, I\u0026rsquo;m sure you\u0026rsquo;ll find a way that even the most nit-picking industry expert (and there are not too many of those, let\u0026rsquo;s be honest) can show that it makes a difference. It\u0026rsquo;s time to take our heads out of the sand and fix things up.\nThank you.\n","permalink":"https://www.msoos.org/2016/03/benchmark-randomisation-sat-competition2016/","summary":"Things are heating up for the \u003ca href=\"http://baldur.iti.kit.edu/sat-competition-2016/index.php\"\u003eSAT competition 2016\u003c/a\u003e. I will of course compete. However, I would publicly like to ask the organisers to please for the love of whatever you believe in, \u003cem\u003eplease\u003c/em\u003e \u003ca href=\"http://www.msoos.org/2013/03/on-benchmark-randomization/\"\u003erandomise the benchmarks\u003c/a\u003e. Just a tiny, little bit. It\u0026rsquo;s ridiculous that people are tuning their solvers so they can solve some randomly solveable instance like the vmpc* series. It\u0026rsquo;s laughable and it\u0026rsquo;s making the whole community look bad. Really, it\u0026rsquo;s time to stop this madness. I wrote that article with a bunch of ideas in 2013. It\u0026rsquo;s time. Not even the largest of organisations move this slowly, and this is a research group of about 50 people max.","title":"Benchmark randomisation for SAT Comp'16"},{"content":"I have been working in a large organization for quite a while now where I have seen a lot of testing going on. As an information security engineer, I naturally aligned more with testing and indeed, information security assurance does align well with testing: It\u0026rsquo;s done on a continuous basis, its results usually mean work for developers, operations people, system architects, etc. and not caring about it is equivalent to accepting unknown risks. Since I have been working in an environment where testing was paramount, I have been digging more and more into the testing literature.\nTesting and Information Security, Worlds Apart What was most surprising is that security engineering is miles away separated from the testing community in general. Just listen to the largest testing conference\u0026rsquo;s keynote and be astounded: no security folks in the audience at all. As a white-hat hacker I can understand where this is coming from: information security seem to have evolved on its own with little influence from the testing crowd. When I picked my Masters to be Information Security, it was the very first year that kind of Masters was taught at my university. At the largest European security conference I go every year, the Chaos Communication Congress (in Germany), I have never met any testers. It seems that a lot of the security know-how came about from the underground, people hacking together and creating know-how from scratch. If you look at one of the main reference books, Security Engineering by Ross Anderson (first published 2001), you will scarcely find a reference to testing and the testing literature.\nCommonalities and Differences I find this strict separation eerie. First of all, there is incredible overlap. For example, if you want to properly fuzz a complicated system, say, Mozilla\u0026rsquo;s javascript engine, you need to have the component under test (in this case, SpiderMonkey) made into a module so it can be fed input directly. Such stand-alone executables are normally created by and for testers (or developers who care about testing, see TDD) so that modules can be properly tested. Without such an executable, trying to fuzz Firefox\u0026rsquo;s javascript engine would be quite futile \u0026ndash; Firefox startup times would kill your fuzzing session\u0026rsquo;s efficiency. Similarly, protocol and deployment diagrams used for functional and performance testing and validation is extremely useful for security architecture reviews. Note that testers almost always know more about the overall system and the context it is deployed in than developers, who in turn tend to be more focused on individual subsystems.\nSecondly, handling security similarly as you would high/medium/low priority issues caught by testers improves the chances that security is taken into consideration at the right level and in the right way. Just as you wouldn\u0026rsquo;t ship a game that crashes after 10 minutes of play (and you might remove the functionality that crashes it as a stopgap), you wouldn\u0026rsquo;t ship a system that has an SQL injection vulnerability in it (and you might remove the functionality that allows for that unescaped input as a stopgap). In other words, insecurity is created by some functionality \u0026ndash; note that no functionality means perfect security -- and that functionality can be changed, disabled or restricted to allow for lower risk operations. Or indeed, the risk can simply be accepted as it is sometimes accepted for functional or deployment issues. In this sense information security engineers highlight risks that management then can decide to either accept, mitigate, or eliminate. This is very similar to let\u0026rsquo;s say a functional issue that may endanger the reputation of the company \u0026ndash; and even human life if it\u0026rsquo;s a medical or safety device -- in case it is released.\nFinally, it must be acknowledged that information security is different in a number of ways from normal testing. First of all, the risks are often larger and harder to control for. If you inadvertently delete your customers\u0026rsquo; data, it\u0026rsquo;s a shame and you might loose some customers. If that same data ends up in someone else\u0026rsquo;s hands, you\u0026rsquo;ll be in for a much rougher ride. Systems typically low-risk from a functional standpoint can carry large security risks \u0026ndash; as one can evidence time and again looking at the Full Disclosure mailing list. Similarly, testing of systems, even end-to-end, often doesn\u0026rsquo;t need to take into consideration a number of factors that security folk have to: the legal landscape, trust of third parties such as governmental organisations, incentives of both inside and outside threat agents, etc. In general, a security engineer needs to take into account a more broader context and may need to make calls on higher-than-average risk mitigation strategies. But note that risk mitigation is still the key component here and controlling for risk often requires changes that are not unlike what testers might demand of developers to fix performance, deployment, or functional issues.\nConclusions Successful companies seemed to have capitalized on some of this divide. Codenomicon clearly appeals to the testing crowd with its intuitive interface and the way it can be integrated into test system automation. The same can be said of Nessus. Both companies seemed to have packaged up information security know-how into something that testers can use who are not necessarily experts in information security.\nGiven the divide between these two crowds I believe there is an opportunity here. Testing is a well-established area with a large knowledge base. Similarly, information security can now be considered a well-established discipline with its own certifications, knowledge base, etc. Intermingling of the two crowds and hence some of the know-how would I think serve both communities quite well. There are some obvious low-hanging fruits such as more effective fuzzing and automated test case generation. The non-obvious ones are probably more interesting and I believe will only come about once more bridges have been built.\n","permalink":"https://www.msoos.org/2015/11/on-testing-and-security-engineering/","summary":"I have been working in a large organization for quite a while now where I have seen a lot of testing going on. As an information security engineer, I naturally aligned more with testing and indeed, information security assurance does align well with testing: It\u0026rsquo;s done on a continuous basis, its results usually mean work for developers, operations people, system architects, etc. and not caring about it is equivalent to accepting unknown risks. Since I have been working in an environment where testing was paramount, I have been digging more and more into the testing literature.","title":"On Testing and Security Engineering"},{"content":"Lately, I have been working quite hard on writing module tests for CryptoMinisat using GoogleTest. I\u0026rsquo;d like to share what I\u0026rsquo;ve learnt and what surprised me most about this exercise.\nAn example First of all, let me show how a typical test looks like:\nTEST_F(intree, fail_1) { s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34; 1, 2\u0026#34;)); s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34;-2, 3\u0026#34;)); s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34;-2, -3\u0026#34;)); inp-\u0026gt;intree_probe(); check_zero_assigned_lits_contains(s, \u0026#34;-2\u0026#34;); } Here we are checking that intree probing finds that the set of three binary clauses cause a failure and it enqueues \u0026ldquo;-2\u0026rdquo; at top level. If one looks at it, it\u0026rsquo;s a fairly trivial test. It turns out that most are in fact, fairly trivial if the system is set up well. This test\u0026rsquo;s setup is the following test fixture:\nstruct intree : public ::testing::Test { intree() { must_inter = false; s = new Solver(NULL, \u0026amp;must_inter); s-\u0026gt;new_vars(30); inp = s-\u0026gt;intree; } ~intree() { delete s; } Solver* s; InTree* inp; bool must_inter; }; Which hides no complexity, either. In fact, what\u0026rsquo;s surprising about this test is how easy it really is to write.\nThe fiddly parts Looking at the test code, it\u0026rsquo;s easy to see if a module implements a bit too much:\nTEST_F(probe, uip_fail_1) { s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34; 1, 2\u0026#34;)); s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34;-2, 3\u0026#34;)); s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34;-2, -3\u0026#34;)); s-\u0026gt;conf.doBothProp = false; s-\u0026gt;conf.doStamp = false; s-\u0026gt;conf.otfHyperbin = false; vars = tovars(\u0026#34;1\u0026#34;); p-\u0026gt;probe(\u0026amp;vars); check_zero_assigned_lits_contains(s, \u0026#34;-2\u0026#34;); //1UIP is -2 } This is testing the same principle, probing, but using the non-intree version. This probing type has been in CryptoMiniSat for a long while, and the feature creep shows. There is stamping, hyper-binary resolution and Stalmarck all in the module, separately controllable. This test needs none of these functionalities, and is only interested if the 1st UIP (i.e. -2) will be caught if \u0026ldquo;-1\u0026rdquo; is probed. Note that Stalmarck could set -2 by probing 3 and -3 so we need to make sure to turn it off.\nWhat I learned The surprising thing about this module testing exercise was that it\u0026rsquo;s much easier than I first thought. I have written about 100 tests for 11 modules in just a week. The vast majority of the tests are very simple to set up, execute and check. However, for tests to be easy to write and reliable to run, there are some prerequisites. Any time the tests were flaky, weird or plain wrong, either the module under test didn\u0026rsquo;t expose enough control or it had too many functionalities. In other words, if the module is not self-contained and manageable, it cannot be tested. What\u0026rsquo;s interesting about that is that based solely on the test code, one can discern the quality of the code being tested. That, I think, was my main takeaway.\nInterestingly, I have found no actual bugs in the code. However, while trying to hunt down why a test wasn\u0026rsquo;t working, I have often found places to clean up, fix up, and generally be more sane and readable. In other words, just because the tests haven\u0026rsquo;t caught any real bugs, they weren\u0026rsquo;t useless at all. I find this fascinating \u0026ndash; though it only takes a cursory look at the testing literature to see that there is more to testing than just quality, risk and performance metrics. It\u0026rsquo;s fun to see that first-hand, though.\nFuture Work I have written tests for all the main modules of CryptoMiniSat except for the occurrence-based systems. These are up next \u0026ndash; and these are the most hairy, and the most interdependent. For example, bounded variable elimination (BVE) calls backward-subsumption for each clause it creates. So testing BVE in isolation will either need some stubbing or more control parameters to turn off subsystems. Self-subsuming resolution is also similarly interdependent on subsumption. Handling these interdependencies in a sane way will be an fun challenge.\n","permalink":"https://www.msoos.org/2015/11/testing-cryptominisat-using-googletest/","summary":"\u003cp\u003eLately, I have been working quite hard on writing module tests for CryptoMinisat using \u003ca href=\"https://code.google.com/p/googletest/\"\u003eGoogleTest\u003c/a\u003e. I\u0026rsquo;d like to share what I\u0026rsquo;ve learnt and what surprised me most about this exercise.\u003c/p\u003e\n\u003ch2 id=\"an-example\"\u003eAn example\u003c/h2\u003e\n\u003cp\u003eFirst of all, let me show how a typical test looks like:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTEST_F(intree, fail_1)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e{\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34; 1,  2\u0026#34;));\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34;-2,  3\u0026#34;));\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    s-\u0026gt;add_clause_outer(str_to_cl(\u0026#34;-2, -3\u0026#34;));\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    inp-\u0026gt;intree_probe();\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    check_zero_assigned_lits_contains(s, \u0026#34;-2\u0026#34;);\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e}\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eHere we are checking that \u003ca href=\"http://www.cs.utexas.edu/~marijn/cpaior2013.pdf\"\u003eintree probing\u003c/a\u003e finds that the set of three binary clauses cause a failure and it enqueues \u0026ldquo;-2\u0026rdquo; at top level. If one looks at it, it\u0026rsquo;s a fairly trivial test. It turns out that most are in fact, fairly trivial if the system is set up well. This test\u0026rsquo;s setup is the following test fixture:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-gdscript3\" data-lang=\"gdscript3\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003estruct intree : public ::testing::Test {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    intree()\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        must_inter \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e false;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        s \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e new Solver(NULL, \u003cspan style=\"color:#f92672\"\u003e\u0026amp;\u003c/span\u003emust_inter);\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        s\u003cspan style=\"color:#f92672\"\u003e-\u0026gt;\u003c/span\u003enew_vars(\u003cspan style=\"color:#ae81ff\"\u003e30\u003c/span\u003e);\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        inp \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e s\u003cspan style=\"color:#f92672\"\u003e-\u0026gt;\u003c/span\u003eintree;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    }\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#f92672\"\u003e~\u003c/span\u003eintree()\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        delete s;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    }\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    Solver\u003cspan style=\"color:#f92672\"\u003e*\u003c/span\u003e s;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    InTree\u003cspan style=\"color:#f92672\"\u003e*\u003c/span\u003e inp;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#a6e22e\"\u003ebool\u003c/span\u003e must_inter;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e};\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e","title":"Testing CryptoMiniSat using GoogleTest"},{"content":"The GitHub repository for CryptoMiniSat just hit 8000 commits. To celebrate this rather weird and crazy fact, let me put together a bit of a history.\nThe Beginnings CryptoMiniSat began as a way of trying to prove that a probabilistic cryptographic scheme was not possible to break using SAT solvers. This was the year 2009, and I was working in Grenoble at INRIA. It was a fun time and I was working really hard to prove what I wanted to prove, to the point that I created a probabilistic SAT solver where one could add probability weights to clauses. The propagations and conflict engine would only work if the conflict or propagation was supported by multiple clauses. Thus began a long range of my unpublished work in SAT. This SAT solver, curiously, still works and solves problems quite well. It\u0026rsquo;s a lot of fun, actually \u0026ndash; just add some random clause into the database that bans the only correct solution and the solver will find the correct solution. A bit of a hackery, but hey, it works. Also, it\u0026rsquo;s so much faster than doing that solving with the \u0026ldquo;right\u0026rdquo; systems, it\u0026rsquo;s not even worth comparing.\nThe same year, my friend, who later became my boss, came around because he had the code of the Mifare protocol in his hands but he couldn\u0026rsquo;t crack the crypto. He pushed me to use the SAT solver for something practical and in just two days we did it, we modelled the cipher and could break it \u0026ndash; but it took too much time to solve. So the rest of the year I was working on improving the solver as much as I could. He had the idea for the XOR clauses, which I implemented in one night of crazy idea-flash.\nWinning the 2010 SAT Race Then came the end of 2009 and I was bored in Paris, wanting to work on SAT solvers no matter what. There was a completely unrelated project that I had to work on for about 2 months to get a full year of salary. This was all thanks to Claude Castelluccia who pulled that project together amazingly well, and we did so well we got selected as \u0026ldquo;Project Phare\u0026rdquo; which I already forgot what it meant, but we were around top 5%. So I had 10 months to spare and I worked all weekdays and all weekends on my shiny new SAT solver which my friend, later boss, also thought would be good to call CryptoMiniSat. I picked the name, it was the EuroCrypt'09 conference and he flew in from Berlin. I wanted to give credit to the MiniSat guys, something that later nobody did.\nI put the solver through a lot of stress test on Grid'5000, the French supercomputing cluster and I submitted it to the SAT Race. Winning it was something completely unanticipated. What was even more unanticipated was that everybody thought it was because the solver had XOR clause support. Of course it had nothing to do with it, and Gaussian elimination was not even compiled into the executable. It was interesting to win, but once I was back in the lab, things got a bit weird. My supervisor at the place was clearly not impressed. They kept on using MiniSat without ever asking me about SAT solvers.\nThe Berlin years: 2010-2014 I went to work for my friend in Berlin who I already worked with on Crypto-1. I was now working in security consultancy, but I continued to work on my SAT solver of course and submitted it to the SAT Competition of 2011. The system was exceedingly fast \u0026ndash; it should have won, but didn\u0026rsquo;t, because I memory-outed on a number of input instances. The problem was multi-fold, but essentially, the number of inprocessing systems grew to such a large number that making sure that none blew up was hard. Also, my testing was inadequate, something that I didn\u0026rsquo;t properly start fixing for years. I still won some prizes, including a gold medal for parallel solving, which was super-funny as all I did was add a blocking structure that shared unitary and binary clauses and that\u0026rsquo;s it. I fondly remember the description of some of the parallel solvers I beat that were so complicated even to explain that I gave up reading their descriptions. I can only wonder how much time it took to write them.\nThe years rolled by and I never got around to properly test or performance test the system. Whenever I submitted it, it did OK and I wasn\u0026rsquo;t too sad about it, but it never did too well. There was always something that didn\u0026rsquo;t work, that broke just the last day. Every time there was some unanticipated input with 2000 disconnected components or such. It was fun to compete, and I tried to clean up the code, but I never got to win.\nThe past year of CryptoMiniSat The beginning of this year I decided to do something slightly different. It was clear that CryptoMiniSat was not winning any major prizes. At the same time, I started working at another company, Cisco, where I saw a lot of work being done on testing. This inspired me to put a lot more effort into both performance and regular testing. It\u0026rsquo;s strange how an environment influences you. I started putting in hooks and building systems around the program. I built an AWS system for performance testing. I spun up a Jenkins server to perform regular long-running tests. I added code coverage metrics. I hooked in Coverity for good. I created ways to dump internal state and check it. Some of these were already present for the SAT Race 2015, some weren\u0026rsquo;t. But I was quite content on winning a difficult prize there, the incremental track \u0026ndash; I think that validated my approach to testing. The incremental prize was not difficult to win because it was difficult to be fast. It was difficult to win because you had to be returning the right result even though you were in the middle of the run. The race also pointed to where the bugs were still hiding: the parallel solving didn\u0026rsquo;t work because I didn\u0026rsquo;t early-exit the other threads when one thread found the satisfying solution. I never properly performance-tested the parallel version.\nConclusions There aren\u0026rsquo;t many conclusions to be had. It turns out testing is hard, and performance testing is both hard and expensive. I tried to escape them both but in the end, they both bit me. I\u0026rsquo;m now concentrating on these areas. I think CryptoMiniSat has potential, it just needs to work right :)\n","permalink":"https://www.msoos.org/2015/10/cryptominisat-8000-commits-later/","summary":"\u003cp\u003eThe GitHub \u003ca href=\"https://github.com/msoos/cryptominisat\"\u003erepository\u003c/a\u003e for CryptoMiniSat just hit 8000 commits. To celebrate this rather weird and crazy fact, let me put together a bit of a history.\u003c/p\u003e\n\u003ch2 id=\"the-beginnings\"\u003eThe Beginnings\u003c/h2\u003e\n\u003cp\u003eCryptoMiniSat began as a way of trying to prove that a probabilistic cryptographic scheme was not possible to break using SAT solvers. This was the year 2009, and I was working in Grenoble at \u003ca href=\"http://www.inria.fr/en/centre/grenoble\"\u003eINRIA\u003c/a\u003e. It was a fun time and I was working really hard to prove what I wanted to prove, to the point that I created a probabilistic SAT solver where one could add probability weights to clauses. The propagations and conflict engine would only work if the conflict or propagation was supported by multiple clauses. Thus began a long range of my unpublished work in SAT. This SAT solver, curiously, still works and solves problems quite well. It\u0026rsquo;s a lot of fun, actually \u0026ndash; just add some random clause into the database that bans the only correct solution and the solver will find the correct solution. A bit of a hackery, but hey, it works. Also, it\u0026rsquo;s so much faster than doing that solving with the \u0026ldquo;right\u0026rdquo; systems, it\u0026rsquo;s not even worth comparing.\u003c/p\u003e\n","title":"CryptoMiniSat: 8000 commits later"},{"content":"Both the SAT Race and the SMT competition of 2015 are now over. The results are in and it\u0026rsquo;s time to draw some conclusions. CryptoMiniSat won the SAT Race\u0026rsquo;s incremental solving track, and the SMT solver that uses (among other solvers) CryptoMiniSat, CVC4, won the SMT competiton. These two wins are not unrelated \u0026ndash; CryptoMiniSat is used in an incremental way by the CVC4 team. What CryptoMiniSat and STP (the other project I work on) hasn\u0026rsquo;t done is win their respective main competitions. Let me reflect on these quickly.\nThe SMT competition The SMT competition\u0026rsquo;s quantifier free boolean vector track (QF_BV) was won by Boolector. Boolector is an amazing piece of engineering and so is the SAT solver it uses, lingeling. Second was CVC using CryptoMiniSat and third was STP. The reason for STP being third was because I managed to add a bug into STP and never fuzzed it. So now fuzzing is part of the continuous integration suite. Without this bug, STP would have come pretty close to Boolector, of which I\u0026rsquo;m proud of.\nIn general, STP needs to be greatly overhauled. It\u0026rsquo;s a legacy codebase with global variables, weird dependencies and long list of weirdnesses. It\u0026rsquo;s also performing amazingly well, so one needs to be careful how to approach it. I have been trying to cut it up and slice it any way I can so it makes more sense to read the code and work on it, but it\u0026rsquo;s still quite hard.\nThe SAT competition The SAT competition had its share of surprises. One such surprise was that lingeling didn\u0026rsquo;t win any main prizes. I wonder why it wasn\u0026rsquo;t submitted to the incremental track, for example. Another surprise was the 1st and 2nd places of two solvers by the same author, Jingchao Chen, who unfortunately I have never met or conversed with. I was also a bit disappointed that CryptoMiniSat didn\u0026rsquo;t make it too high on the list. There have been a number of issues I tried to fix, but apparently that wasn\u0026rsquo;t enough. I will be interested in the sources of the winning solvers, see if I can learn something from them.\nIt\u0026rsquo;s really hard to create winning SAT solvers that behave well in all circumstances because it takes massive amount of time to code them up and properly test them. Especially the latter is really complicated and writing good test harnesses takes concentrated effort. My test scripts are easily over a thousand lines of code, mostly python. The continuous integration and build systems (both necessary for timely releases) are another thousand, and my AWS scripts for performance testing is almost a thousand as well. That\u0026rsquo;s more code than some early, well-performing SAT solvers had.\nMost competing SAT solvers (with the exception of lingeling) don\u0026rsquo;t have such elaborate test and release systems in place. Although maintaining such systems seems like a burden, in the long run, they pay off well. For example, the incremental track is particularly hard to compete in without proper tests and hence CryptoMiniSat had a good chance there \u0026ndash; and I don\u0026rsquo;t see why lingeling didn\u0026rsquo;t compete, given that is must have extremely elaborate test and release systems, too.\nConclusions It has been a good year for CryptoMiniSat and STP. Some of their strengths have been highlighted more than others, and progress has been made on all fronts. They might both be released as part of standard packages in Debian, Fedora and other distros. All this sounds great. I have put lots of effort into both, and some of that effort is paying off, which is good to hear.\nOn the CryptoMiniSat side, in the future, I need to concentrate more on experimentation so it can be as agile as some of the newly winning solvers. On the STP side, I need to put more effort into fuzzing, testing, and refactoring.\n","permalink":"https://www.msoos.org/2015/09/sat-race15-the-smt-comp15-cryptominisat-stp/","summary":"\u003cp\u003eBoth the \u003ca href=\"http://baldur.iti.kit.edu/sat-race-2015/sr15.pdf\"\u003eSAT Race\u003c/a\u003e and the \u003ca href=\"http://smtcomp.sourceforge.net/2015/\"\u003eSMT competition\u003c/a\u003e of 2015 are now over. The results are in and it\u0026rsquo;s time to draw some conclusions. \u003ca href=\"https://github.com/msoos/cryptominisat/releases\"\u003eCryptoMiniSat\u003c/a\u003e won the SAT Race\u0026rsquo;s incremental solving track, and the SMT solver that uses (among other solvers) CryptoMiniSat, \u003ca href=\"http://cvc4.cs.nyu.edu/web/\"\u003eCVC4\u003c/a\u003e, won the SMT competiton. These two wins are not unrelated \u0026ndash; CryptoMiniSat is used in an incremental way by the CVC4 team. What CryptoMiniSat and \u003ca href=\"https://github.com/stp/stp/releases\"\u003eSTP\u003c/a\u003e (the other project I work on) hasn\u0026rsquo;t done is win their respective main competitions. Let me reflect on these quickly.\u003c/p\u003e\n\u003ch3 id=\"the-smt-competition\"\u003eThe SMT competition\u003c/h3\u003e\n\u003cp\u003eThe SMT competition\u0026rsquo;s quantifier free boolean vector \u003ca href=\"http://smtcomp.sourceforge.net/2015/results-QF_BV.shtml?v=1443277739\"\u003etrack\u003c/a\u003e (QF_BV) was won by \u003ca href=\"http://smtcomp.sourceforge.net/2015/results-QF_BV.shtml?v=1443277739\"\u003eBoolector\u003c/a\u003e.  Boolector is an amazing piece of engineering and so is the SAT solver it uses, \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e. Second was CVC using CryptoMiniSat and third was STP. The reason for STP being third was because I managed to add a bug into STP and never fuzzed it. So now \u003ca href=\"https://github.com/stp/stp/blob/master/scripts/fuzz_test.py\"\u003efuzzing\u003c/a\u003e is part of the continuous integration suite. Without this bug, STP would have come pretty close to Boolector, of which I\u0026rsquo;m proud of.\u003c/p\u003e\n\u003cp\u003eIn general, STP needs to be greatly overhauled. It\u0026rsquo;s a legacy codebase with global variables, weird dependencies and long list of weirdnesses. It\u0026rsquo;s also performing amazingly well, so one needs to be careful how to approach it. I have been trying to cut it up and slice it any way I can so it makes more sense to read the code and work on it, but it\u0026rsquo;s still quite hard.\u003c/p\u003e\n\u003ch3 id=\"the-sat-competition\"\u003eThe SAT competition\u003c/h3\u003e\n\u003cp\u003eThe SAT competition had its share of surprises. One such surprise was that lingeling didn\u0026rsquo;t win any main prizes. I wonder why it wasn\u0026rsquo;t submitted to the incremental track, for example. Another surprise was the 1st and 2nd places of two solvers by the same author, \u003ca href=\"http://dblp.uni-trier.de/pers/hd/c/Chen:Jingchao\"\u003eJingchao Chen\u003c/a\u003e, who unfortunately I have never met or conversed with. I was also a bit disappointed that CryptoMiniSat didn\u0026rsquo;t make it too high on the list. There have been a number of issues I tried to fix, but apparently  that wasn\u0026rsquo;t enough. I will be interested in the sources of the winning solvers, see if I can learn something from them.\u003c/p\u003e\n\u003cp\u003eIt\u0026rsquo;s really hard to create winning SAT solvers that behave well in all circumstances because it takes massive amount of time to code them up and properly test them. Especially the latter is really complicated and writing good test harnesses takes concentrated effort. My test scripts are easily over a thousand lines of code, mostly python. The continuous integration and build systems (both necessary for timely releases) are another thousand, and my AWS scripts for performance testing is almost a thousand as well. That\u0026rsquo;s more code than some early, well-performing SAT solvers had.\u003c/p\u003e\n","title":"STP and CryptoMiniSat in the competitions of 2015"},{"content":"The use of Gmail is now ubiquitous. Unfortunately, it\u0026rsquo;s easy to read email in transit and some national governments abuse their power to read email in transit. I have always been using PGP to encrypt email, and today I thought I\u0026rsquo;d put down how to communicate with me, or with your friends, using signed and encrypted mail. I think the biggest reason email encryption is not being used is because it\u0026rsquo;s hard to set up. So, here is a simple, step-by-step tutorial that is easy to follow.\nInstalling and creating a key Install Mailvelope. Click \u0026ldquo;add to chrome\u0026rdquo;, pop-up appears, click \u0026ldquo;add\u0026rdquo; little padlock icon appears on the top right of your Chrome Click little padlock icon, click \u0026ldquo;Options\u0026rdquo; At the bottom, click \u0026ldquo;Generate key\u0026rdquo; Fill in Name (you can put fictitious name, it\u0026rsquo;s good!), Email (the email you want to use, e.g. Jon.Doe@gmail.com), put in a password that you will remember. This password is never sent anywhere. It\u0026rsquo;s used so that when you want to read email that is encrypted to you, the encryption keys can be accessed. Click submit, wait for the generation to finish. Setup is done! Obtaining keys of others You need to get the keys of others so you can send encrypted email to them. Here is how.\nLook for your friend\u0026rsquo;s email here and copy the gibberish text that appears, e.g. mine Click the little padlock icon on the top right of your Chrome Click \u0026ldquo;setup\u0026rdquo; on list of things Paste the gibberish text in the textbox Click Import It should say \u0026ldquo;success \u0026hellip; Mate Soos [or your friend\u0026rsquo;s fictitious name]\u0026hellip; imported\u0026rdquo; Done! Sending encrypted email Go to gmail.com Click compose. Fill in subject and recipient (these will not be encrypted) You will see a little notepad icon in the email text body. Click it. 1st Pop-up appears. Write your mail here! Note that these drafts are not saved, so you need to be careful Click \u0026ldquo;Encrypt\u0026rdquo; 2nd Pop-up comes up. Your own email address will be automatically added to \u0026ldquo;Encrypt for\u0026rdquo; You need to select at the top drop-down menu the destination email address (which you must have imported as per setup). Once you selected the destination, click \u0026ldquo;Add\u0026rdquo; (don\u0026rsquo;t forget to click \u0026ldquo;Add\u0026rsquo;, it\u0026rsquo;s easy to forget) You now have 2 email addresses in the bottom list. One is yourself, one is the recipient Click OK. 2nd pop-up disappears. Your email is now encrypted in this popup. Click \u0026ldquo;Transfer\u0026rdquo;, 1st Pop-up disappears You are now in the compose window again. Don\u0026rsquo;t change anything, just click \u0026ldquo;Send\u0026rdquo; Done! Reading encrypted email go to gmail.com click on email to read email window opens, email is yellow with a lock on top. Click! enter the password you used above decrypted email appears Backing up your private keys In chrome, click the top right padlock Click Options Click Export Popup appears. Click Download The file \u0026ldquo;all_keys.asc\u0026rdquo; is now saved to disk Keep this file backed up. Done! Sending your public key to others You need to send your public key to your recipient so they can send you encrypted mail (and verify your signature). Also, it\u0026rsquo;s a good idea to put them on a public site, like your blog or on pgp.mit.edu.\nIn chrome, click the top right padlock Click Options Pop-up appears. On the bottom, click the email address that says \u0026ldquo;primary\u0026rdquo; 2nd pop-up appears. On the top menu, click \u0026ldquo;Export\u0026rdquo; Here, make sure you have \u0026ldquo;Public\u0026rdquo; selected (it\u0026rsquo;s the default) Click download. Attach that file to an email to me or anyone you want to send you encypted mail Upload the contents of the file here Try no to confuse the private and the public keys. Send the public key to everyone. Never send the private key to anyone, ever.\nClosing thoughts The security professionals would point out that trusting the public key is not discussed above. It\u0026rsquo;s true, it\u0026rsquo;s not discussed, and it\u0026rsquo;s not easy to know what to trust. However, the vast majority of the time, the resurrecting duckling principle will work well \u0026ndash; it\u0026rsquo;s when you trust the first thing you see, just like the duckling trusting that the first thing it sees is its mother. It\u0026rsquo;s imperfect, but the web of trust is very unintuitive and therefore may bring less benefits than most think. A technology that is good but is unintuitive often harms more than most people would admit.\nTrusting the first key will be good for most people. In case you are in danger of being seriously harmed for the information you are about to send, though, please try to make sure the key you got was legitimate, by, e.g. phoning up your recipient and confirming the key fingerprint (displayed on the setup page).\nNote that in case your computer is compromised, the above will not help. They will be able to read your data and read your password as you type it. So, try not to visit dodgy sites, allow Windows and Mac to encrypt your drive, choose a strong login password, use a password manager for all sites, and keep your Mac and Windows updated.\n","permalink":"https://www.msoos.org/2015/09/setting-up-encrypted-mail-in-chrome-and-gmail/","summary":"\u003cp\u003eThe use of Gmail is now ubiquitous. Unfortunately, it\u0026rsquo;s easy to read email in transit and some national governments abuse their power to read email in transit. I have always been using PGP to encrypt email, and today I thought I\u0026rsquo;d put down how to communicate with me, or with your friends, using signed and encrypted mail. I think the biggest reason email encryption is not being used is because it\u0026rsquo;s hard to set up. So, here is a simple, step-by-step tutorial that is easy to follow.\u003c/p\u003e\n\u003ch2 id=\"installing-and-creating-a-key\"\u003eInstalling and creating a key\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eInstall \u003ca href=\"https://chrome.google.com/webstore/detail/mailvelope/kajibbejlbohfaggdiogboambcijhkke?hl=en\"\u003eMailvelope\u003c/a\u003e. Click \u0026ldquo;add to chrome\u0026rdquo;, pop-up appears, click \u0026ldquo;add\u0026rdquo;\u003c/li\u003e\n\u003cli\u003elittle padlock icon appears on the top right of your Chrome\u003c/li\u003e\n\u003cli\u003eClick little padlock icon, click \u0026ldquo;Options\u0026rdquo;\u003c/li\u003e\n\u003cli\u003eAt the bottom, click \u0026ldquo;Generate key\u0026rdquo;\u003c/li\u003e\n\u003cli\u003eFill in Name (you can put fictitious name, it\u0026rsquo;s good!), Email (the email you want to use, e.g. \u003ca href=\"mailto:Jon.Doe@gmail.com\"\u003eJon.Doe@gmail.com\u003c/a\u003e), put in a password that you will remember. This password is never sent anywhere. It\u0026rsquo;s used so that when you want to read email that is encrypted to you, the encryption keys can be accessed.\u003c/li\u003e\n\u003cli\u003eClick submit, wait for the generation to finish.\u003c/li\u003e\n\u003cli\u003eSetup is done!\u003c/li\u003e\n\u003c/ol\u003e","title":"Setting up encrypted mail in Chrome and Gmail"},{"content":"I have lately been digging myself into a deep hole with machine learning. While doing that it occurred to me that the SAT community has essentially been trying to imitate some of ML in a somewhat poor way. Let me explain.\nCryptoMiniSat and clause cleaning strategy selection When CryptoMiniSat won the SAT Race of 2010, it was in large part because I realized that glucose at the time was essentially unable to solve cryptographic problems. I devised a system where I could detect which problems were cryptographic. It checked the activity stability of variables and if they were more stable than a threshold, it was decided that the problem was cryptographic. Cryptographic problems were then solved using a geometric restart strategy with clause activities for learnt database cleaning. Without this hack, it would have been impossible to win the competition.\nIt is clear that there could have been a number of ways to detect that a problem is cryptographic without using such an elaborate scheme. However, that would have demanded a mixture of more features to decide. The scheme only used the average and the standard deviation.\nLingeling and clause cleaning strategy selection The decision made by lingeling about whether to use glues or activities to clean learnt clauses is somewhat similar to my approach above. It calculates the average and the standard deviation of the learnt clauses\u0026rsquo; glues and then makes a decision. Looking at the code, the option actavgmax/stdmin/stdmax gives the cutoffs and the function lglneedacts calculates the values and decides. This has been in lingeling since 2011 (lingeling-587f).\nProbably a much better decision could be made if more data was taken into account (e.g. activities) but as a human, it\u0026rsquo;s simply hard to make a decision based on more than 2-3 pieces of data.\nEnter machine learning It is clear that the above schemes were basically trying to extract some feature from the SAT solver and then decide what features (glues/activities) to use to clear the learnt clause database. It is also clear that both have been extremely effective, it\u0026rsquo;s by no luck that they have been inside successful SAT solvers.\nThe question is, can we do better? I think yes. First of all, we don\u0026rsquo;t need to cut the problem into two steps. Instead, we can integrate the features extracted from the solver (variable activities, clause glue distribution, etc) and the features from the clause (glue, activities, etc.) and make a decision whether to keep the clause or not. This means we would make keep/throwaway decisions on individual clauses based on potentially hundreds of extracted features \u0026ndash; and that requires machine learning. But it would allow much more than what we have now. By giving a large number of features to the machine learning algorithm, it could extract interesting high-level features from them. In particular, deep learning could possibly have come up with glues(!) if the decision levels of the variables (along with the current decision level) were given to it. I think there must be more and better higher-level features than just glues.\nIt\u0026rsquo;s highly inefficient to ask humans to come up with high-level features and decision trees for clause keep/throwaway when there are readily-available systems that can extract high-level features and make immensely complex (and effective!) decision trees in very reasonable amount of time on modern machines.\nConclusions I think we have been wasting research and development time on coming up with high-level features and decision trees for keeping or throwing away learnt clauses. It\u0026rsquo;s time we looked at a discipline that has been exploding in computer science and stopped mocking SATZilla -- effectively, all modern SAT solvers employ a hand-crafted poor man\u0026rsquo;s version of some of SATZilla.\nPost Scriptum This file in the SAT Race 2015 version of CryptoMiniSat will be super-controversial. It on-the-fly reconfigures CryptoMiniSat after ~160K of conflicts and three runs of pre- and in-processing based on over 50 extracted features. It\u0026rsquo;s crappy. And effective. I did it in one week, over the CAV conference. It simulates the decision by CryptoMiniSat and lingeling about activities/glues, and more. Thanks Ofer Strichman!\n","permalink":"https://www.msoos.org/2015/08/machine-learning-and-sat/","summary":"\u003cp\u003eI have lately been digging myself into a deep hole with machine learning. While doing that it occurred to me that the SAT community has essentially been trying to imitate some of ML in a somewhat poor way. Let me explain.\u003c/p\u003e\n\u003ch3 id=\"cryptominisat-and-clause-cleaning-strategy-selection\"\u003eCryptoMiniSat and clause cleaning strategy selection\u003c/h3\u003e\n\u003cp\u003eWhen CryptoMiniSat won the \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/results.html\"\u003eSAT Race of 2010\u003c/a\u003e, it was in large part because I realized that glucose at the time was \u003ca href=\"http://www.cril.univ-artois.fr/SAT09/results/globalbybench.php?idev=29\u0026amp;idcat=62\"\u003eessentially unable\u003c/a\u003e to solve cryptographic problems. I devised a system where I could \u003ca href=\"https://github.com/msoos/cryptominisat/blob/cryptominisat-2.9.7/cmsat/RestartTypeChooser.cpp\"\u003edetect which problems were cryptographic\u003c/a\u003e. It checked the activity stability of variables and if they were more stable than a threshold, it was decided that the problem was cryptographic. Cryptographic problems were then solved using a geometric restart strategy with clause activities for learnt database cleaning. Without this hack, it would have been impossible to win the competition.\u003c/p\u003e\n","title":"Machine Learning and SAT"},{"content":"I have worked a lot on CryptoMiniSat 5.0 in the past months so I thought I\u0026rsquo;d write a little bit about what I spent my time on.\nAmazon AWS I have put lots of effort into use Amazon AWS service to run CMS. This is necessary in order to compete at the SAT competition where my competitors have access to massive resources, some to clusters having over 20k CPU cores. Competing against that with a 4-core machine like I did last year will simply not cut it.\nThe system I built has a client-server infrastructure where the server is a very-very small machine (t1.micro) that hands out jobs to very-very beefy client machine(s) (c4.8xlarge with 18 real cores). I need this architecture because the client I use is a so-called spot instance so Amazon can shut it down any time. The server makes sure to keep in mind what has been solved and what needs to be solved next to complete the job. At the finish of the job, both the server and the client shut down. I simply need to issue, e.g. \u0026ldquo;./launch_server.py \u0026ndash;git 82c4e5adce \u0026ndash;s3folder newrun \u0026ndash;cnfdir satcomp091113 -t 5000\u0026rdquo; and it will launch the full SAT competition 09+11+13 instances with a 5000s timeout using a specific GIT revision of CryptoMiniSat. When it finishes (in about 4-5 hours), it (should) send me a mail with the command line to use to download all the data from Amazon S3. It\u0026rsquo;s neat, fast, and literally just one command line to use.\nAs for how much I have used it, I have spent over $100 on running costs on AWS in the past 2 months. A run like the one above costs about $2. Not super-cheap, but not the end of the world, either.\nTesting and continuous integration I have TravisCI, Coverity, and Coverall integration. These provide continious integration testing, static analysis, and code coverage analysis, respectively. I find TravisCI to be immensely valuable, I would have trouble not having it for a new project. Coverity is also pretty useful, it has actually found some pretty stupid mistakes I have made. Finally, coveralls has a terrible interface but I like the idea of having test code coverage analysis and it encourages me to put more effort into that. For example, it highlights pretty well the areas that I typically break when coding without realizing it. TravisCI usually warns me if there is something bad except when there is no (or too little) coverage. I am also looking into Docker, which would allow for continuous delivery.\nChecking against SWDiA5BY I have integrated the main idea of SWDiA5BY A26 code into CryptoMiniSat. Further, I am in the process of integrating one of thepatches available on the author\u0026rsquo;s website. I find these patches to be really interesting and using SWDiA5BY A26 as a check against my own system has allowed me to get rid of a lot of bugs. So, I am greatly indebted to the authors of MiniSat, Glucose and SWDiA5BY.\nConclusions In the past months I have put a lot of effort into cleaning up, fixing, and taking control of CryptoMiniSat in general. There have been over 240 issues filed at github against CryptoMiniSat over the years, and only 7 are currently open. This is a testament to how open and dynamic the solver development is. In case you are interested in helping to develop or have new ideas, don\u0026rsquo;t hesitate to contact me. Further, if you have any commercial interest in the solver, don\u0026rsquo;t hesitate to contact me.\n","permalink":"https://www.msoos.org/2015/06/towards-cryptominisat-5/","summary":"\u003cp\u003eI have worked a lot on CryptoMiniSat 5.0 in the past months so I thought I\u0026rsquo;d write a little bit about what I spent my time on.\u003c/p\u003e\n\u003ch3 id=\"amazon-aws\"\u003eAmazon AWS\u003c/h3\u003e\n\u003cp\u003eI have put lots of effort into use \u003ca href=\"https://en.wikipedia.org/wiki/Amazon_Web_Services\"\u003eAmazon AWS\u003c/a\u003e service to run CMS. This is necessary in order to compete at the SAT competition where my competitors have access to massive resources, some to clusters having over 20k CPU cores. Competing against that with a 4-core machine like I did last year will simply not cut it.\u003c/p\u003e","title":"Towards CryptoMiniSat 5.0"},{"content":"It\u0026rsquo;s been a while I have blogged. Lots of things happened on the way, I met people, changed countries, jobs, etc. In the meanwhile, I have been trying to bite the bullet of what has become of CryptoMiniSat: last year, it didn\u0026rsquo;t perform too well in the SAT competition. In the past half year I have tried to fix the underlying issues. Let me try to explain what and how exactly.\nValidation and cleanup First, in the past years I \u0026lsquo;innovated\u0026rsquo; a lot in directions that were simply not validated. For example, I have systems to cleanly exit the solver after N seconds have passed, but the checks were done by calling a Linux kernel function, which is actually not so cheap. It turned out that calling it took 3-5% of the time, and it was essentially doing nothing. Similar code was all over the place. I was (and still am, in certain builds) collecting massive amounts of solving data. It turns out, collecting them means not having enough registers left to do the real thing so the ASM code was horrific and so was performance. The list could go on. In the end, I had to weed out the majority of the stuff that was added as an experiment without proper validation.\nOther solvers Second, I started looking at other solvers. In particular, the swdia5by solver by Chanseok Oh. It\u0026rsquo;s a very-very weird solver and it performed exceedingly well. I\u0026rsquo;m sure it\u0026rsquo;s on the mind of many solver implementers, and for a good reason. As a personal note, I like the webpage of the author a lot. I think what s/he forgets is that MiniSat is not so well-used because it\u0026rsquo;s so well-performing. Glucose is better. It\u0026rsquo;s used because it\u0026rsquo;s relatively good and extremely well-written. However, the patches on the author\u0026rsquo;s website are anything but well-written.\nThe cloud Finally, I worked a lot on making the system work on AWS, the cloud computing framework by Amazon. Since I don\u0026rsquo;t have access to clusters like my competitors do, I need to resort to AWS. It\u0026rsquo;s not _that_ expensive, a full SATComp'14 run sets me back about $5-6. I used spot instances and a somewhat simple, 1000-line python framework for farming out computation to client nodes.\u0026lt;\nConclusions All in all, I\u0026rsquo;m happy to say, CryptoMiniSat is no longer as bad as it was last year. There are still some problems around and a lot of fine-tuning needed, but things are looking brighter. I have been thinking lately of trying to release some of the tools I developed for CryptoMiniSat for general use. For example, I have a pretty elaborate fuzz framework that could fuzz any solver using the new SAT library header system. Also, the AWS system could be of use to people. I\u0026rsquo;ll see.\n","permalink":"https://www.msoos.org/2015/05/the-past-half-year-of-sat-and-smt/","summary":"\u003cp\u003eIt\u0026rsquo;s been a while I have blogged. Lots of things happened on the way, I met people, changed countries, jobs, etc. In the meanwhile, I have been trying to bite the bullet of what has become of CryptoMiniSat: last year, it didn\u0026rsquo;t perform too well in the \u003ca href=\"http://www.satcompetition.org/2014/results.shtml\"\u003eSAT competition\u003c/a\u003e. In the past half year I have tried to fix the underlying issues. Let me try to explain what and how exactly.\u003c/p\u003e","title":"The past half year of SAT and SMT"},{"content":"In SAT solvers, removing unneeded learnt clauses from the clause database sounds like a trivial task: we somehow determine which clauses are not needed and we call remove() on them. However, in case performance is an issue, it can get a bit more more complicated.\nThe problem The issue at hand is that clauses are stored in two places: as a list of pointers to the clauses and in a list of lists called the watchlist. Removing clauses from either list can be an O(n2)O(n^2)O(n2) operation if we e.g. remove every element from the list, one by one. In fact, an old version of the most popular SAT solver, MiniSat2, used to do exactly this:\nsort(learnts, reduceDB_lt()); for (i = j = 0; i \u0026lt; learnts.size() / 2; i++){ if (learnts[i]-\u0026gt;size() \u0026gt; 2 \u0026amp;\u0026amp; !locked(*learnts[i])) removeClause(*learnts[i]); else learnts[j++] = learnts[i]; } [...] Here, removeClause() is called on each clause individually, where removeClause() eventually calls remove() twice, where remove() is a linear operation:\ntemplate static inline void remove(V\u0026amp; ts, const T\u0026amp; t) { int j = 0; for (; j \u0026lt; (int)ts.size() \u0026amp;\u0026amp; ts[j] != t; j++); assert(j \u0026lt; (int)ts.size()); for (; j \u0026lt; (int)ts.size()-1; j++) ts[j] = ts[j+1]; ts.pop(); } It is clear that if the number of learnt clauses removed is a significant percent of all clauses (which it is after some runtime), this is an O(n2)O(n^2)O(n2) operation.\nMy original solution My original solution to this problem was the following. First, I did a sweep on the watchlist and detached all learnt clauses. This is an O(n)O(n)O(n) operation. Then, I ran the algorithm above, without the removeClause(). Finally, I attached the remaining learnt clauses: again an O(n)O(n)O(n) operation. This solution is significantly faster than the MiniSat one as its worst-case runtime is only O(n)O(n)O(n). The improvement is measurable \u0026ndash; worst-case cleaning times dropped from seconds to tenths of seconds. However, it can be further improved.\nThe improved solution The improvement that came to my mind just yesterday was the following. I can keep a one bit marker in each learnt clause that indicates whether the clause needs to be detached or not. Then, I can run the algorithm as above but replace removeClause() with markclause() and run through the watchlists once to remove (and free) the marked clauses. This works really well and it only necessitates one sweep of the watchlists, without any useless detach+reattach cycles.\nThe newer GitHub version of MiniSat also marks the clauses instead of detaching them immediately and then removes them in one sweep, later. Interestingly, it keeps a list of \u0026lsquo;dirty\u0026rsquo; occurrence lists and only goes through the ones that need removal. I find that a bit strange for this specific purpose: usually almost all watchlists are affected. In other cases, though, keeping dirty lists in mind can be a good idea, e.g. if only few clauses are removed for some optimization step.\n","permalink":"https://www.msoos.org/2014/11/cleaning-the-learnt-clause-database-faster/","summary":"\u003cp\u003eIn SAT solvers, removing unneeded learnt clauses from the clause database sounds like a trivial task: we somehow determine which clauses are not needed and we call remove() on them. However, in case performance is an issue, it can get a bit more more complicated.\u003c/p\u003e\n\u003ch3 id=\"the-problem\"\u003eThe problem\u003c/h3\u003e\n\u003cp\u003eThe issue at hand is that clauses are stored in two places: as a list of pointers to the clauses and in a list of lists called the watchlist. Removing clauses from either list can be an \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003eO\u003c/mi\u003e\u003cmo stretchy=\"false\"\u003e(\u003c/mo\u003e\u003cmsup\u003e\u003cmi\u003en\u003c/mi\u003e\u003cmn\u003e2\u003c/mn\u003e\u003c/msup\u003e\u003cmo stretchy=\"false\"\u003e)\u003c/mo\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003eO(n^2)\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:1.0641em;vertical-align:-0.25em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0278em;\"\u003eO\u003c/span\u003e\u003cspan class=\"mopen\"\u003e(\u003c/span\u003e\u003cspan class=\"mord\"\u003e\u003cspan class=\"mord mathnormal\"\u003en\u003c/span\u003e\u003cspan class=\"msupsub\"\u003e\u003cspan class=\"vlist-t\"\u003e\u003cspan class=\"vlist-r\"\u003e\u003cspan class=\"vlist\" style=\"height:0.8141em;\"\u003e\u003cspan style=\"top:-3.063em;margin-right:0.05em;\"\u003e\u003cspan class=\"pstrut\" style=\"height:2.7em;\"\u003e\u003c/span\u003e\u003cspan class=\"katex-sizing reset-size6 size3 mtight\"\u003e\u003cspan class=\"mord mtight\"\u003e2\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"mclose\"\u003e)\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e operation if we e.g. remove every element from the list, one by one. In fact, an old version of the most popular SAT solver, \u003ca href=\"http://minisat.se/downloads/minisat2-070721.zip\"\u003eMiniSat2\u003c/a\u003e, used to do exactly this:\u003c/p\u003e","title":"Faster cleaning of the learnt clause database"},{"content":"The paper by Heule et al. about hyper-binary resolution using intree-based lookahead is pretty funky. The idea is actually quite simple (and as usual, not exactly trivial to come up with): we re-use past propagations by reversing the order in which literals are normally enqueued.\nA simple example First, a queue is built that starts with a leaf literal and then follows it up through binary clauses until it can. Then it backtracks (adds to the queue a special, * element) and continues. The point of the queue is to have an example order that we can use to dequeue literals from in reverse propagation order. Obviously, there are many different orders in which we can build this queue and I wouldn\u0026rsquo;t be surprised if there are some nice heuristics one can use. Let\u0026rsquo;s just assume we have such a queue.\nFor example if y leads to x, then an example queue will have first element x and then y. So we first enqueue x, propagate, and then we enqueue y. If x already fails, there is no point in enqueuing y (and y is failed along with x). If both y and z lead to x but only z fails, then we don\u0026rsquo;t have to perform the propagations done by x twice: We enqueue x, propagate, create new decision level, enqueue y, propagate (nothing fails), backtrack 1 decision level, enqueue z, and now we fail. Notice that we didn\u0026rsquo;t have to propagate x twice even though we probed two literals (y and z) that both entailed x.\nFailing mid-way The paper mentions failed literals that fail mid-way while dequeueing elements. We obviously cannot simply enqueue these literals, as they would be unset next time we backtrack. So these have to be kept in an array and set later, when we are at decision level 0. Further, once we are in a failed state, anything dequeued that is at the same or lower level also fails, so we need to keep an indicator of failure for these literals.\nKeeping reasons updated Let\u0026rsquo;s suppose we enqueued x and propagated it. Next is y. We enqueue y\u0026hellip; but we need to know what is the reason why x got set. The reason is of course the binary clause that we examined when we built the queue: (x, ~y). The reason is needed to be set because we will be jumping backwards through the implication graph to the deepest common ancestor to attach the new hyper-binary clause there. When jumping back, we might need to go back all the way to y, through x. In order to perform transitive reduction (as explained later), we need to know if the binary clause (x, ~y) was redundant or irredundant. This information needs to be stored in the queue and every time we dequeue a new literal y the reason of the previously enqueued literal needs to be set to the inverse of the currently enqueued literal i.e. ~y.\nTransitive reduction Updating reasons becomes a real problem in case we wish to perform transitive reduction. Transitive reduction removes binary clauses that are useless from a binary implication graph reachability perspective. However, if it removes a binary clause that is later used by the queue to update a reason, we encounter a problem. We may update a literal with a reason that is no longer valid as the corresponding binary clause has been replaced by a chain of binary clauses. Later transitive reductions will take into account that this binary clause exists (it doesn\u0026rsquo;t) and will make further reductions that may be incorrect. In particular, further transitive reductions might remove an element of the chain itself \u0026ndash; kind of like biting our own tail.\nThere seems to be a couple of options to fix the problem:\nNot to perform transitive reduction at all. This may have been the intention of the designers, as the BCP_NHBR function does not perform transitive reduction. Update the queue to reflect the changed set of binary clauses. Unfortunately this would be very expensive and thus basically not doable in reasonable about of time as far as I can tell. Never remove binary clauses that are used for the queue. This means we need to mark such clauses and then check for markings when removing binary clauses. This is the implementation that I chose. We can immediately unmark a clause once the corresponding element has been dequeued, making it possible to remove it later. In CryptoMiniSat I simply unmark all binary clauses at the end \u0026ndash; it\u0026rsquo;s faster. Conclusions I remember some people always asking me why I haven\u0026rsquo;t yet implemented intree-based probing. It is much faster than normal probing. However, it\u0026rsquo;s not perfect. For example, it cannot be used to perform a fast depth-first walk of the tree and as such stamping is not really possible while doing it \u0026ndash; always updating closing times for already dequeued elements seems to defeat the purpose of the whole idea (i.e. reversing the propagation order). Secondly, I haven\u0026rsquo;t yet found a way to efficiently perform Stalmarck while doing intree probing. Thirdly, it\u0026rsquo;s not exactly trivial to implement \u0026ndash; as explained above.\n[paypal-donation]\n","permalink":"https://www.msoos.org/2014/08/treelook-and-transitive-reduction/","summary":"\u003cp\u003eThe \u003ca href=\"http://link.springer.com/chapter/10.1007%2F978-3-642-38171-3_6\"\u003epaper by Heule et al.\u003c/a\u003e about hyper-binary resolution using intree-based lookahead is pretty funky. The idea is actually quite simple (and as usual, not exactly trivial to come up with): we re-use past propagations by reversing the order in which literals are normally enqueued.\u003c/p\u003e\n\u003ch3 id=\"a-simple-example\"\u003eA simple example\u003c/h3\u003e\n\u003cp\u003eFirst, a queue is built that starts with a leaf literal and then follows it up through binary clauses until it can. Then it backtracks (adds to the queue a special, * element) and continues. The point of the queue is to have an example order that we can use to dequeue literals from in reverse propagation order. Obviously, there are many different orders in which we can build this queue and I wouldn\u0026rsquo;t be surprised if there are some nice heuristics one can use. Let\u0026rsquo;s just assume we have such a queue.\u003c/p\u003e","title":"TreeLook and transitive reduction"},{"content":"Armin Biere gave a lecture at the Pragmatics of SAT workshop (proceeedings here) in Vienna about all the things inside lingeling which won a lot of awards[ PDF] this year. If you weren\u0026rsquo;t there, you missed an amazing presentation. In this blog post I\u0026rsquo;ll reflect on a particular part of the presentation dealing with a memory trickery that has been intriguing me for a long while but I did not implement. Before I begin let me say: the presentation was awesome, and it\u0026rsquo;s not by chance that lingeling won so many awards.\nThe idea The idea used by lingeling I want to talk about is easy to explain (though not easy to invent, as is usually the case). If you look at typical CNF problems, the majority of the clauses will be binary, i.e. only contain 2 literals. These clauses used to be stored exactly the same way as normal clauses: in the heap we allocate 2 literals and we put a pointer into the watchlist to these literals.\nAn improvement over this idea are the so-called implicit clauses. For the binary clause \u0026ldquo;x V y\u0026rdquo; we put into the watchlist of x the literal y, and in the watchlist of y the literal x. There is no other place we store these binary clauses, hence the word \u0026ldquo;implicit\u0026rdquo;. For other clauses, we still put pointers into the watchlist and allocate space, as usual. The problem with this approach is that the pointer to a clause is 32b (we use an 32b offset on 64b machines) but for each clause we also store a so-called blocking literal in the watchlist, which is also 32b. That makes the entries in the watchlist 64b long for normal clauses, and 32b long for binary clauses.\nThe idea is to have differing sizes of elements in a watchlist. If e.g. the first bit of the element is a 1, the next 63b relate to a long clause, and if it\u0026rsquo;s a 0, then the next 31b relate to a binary clause. In case 80% of the clauses are binary, this saves 50% of the space in 80% of the cases. Not bad at all.\nThe advantages The advantages of using this idea are twofold. First, as already mentioned, memory use is lowered. This is non-trivial as memory usage of the watchlists can be enormous and although many other improvements can be switched off (such as e.g. stamping), storage of the clauses can never be switched off. Secondly, not having holes in memory leads to much better cache usage which in turn can bring real speedup. In case you think this is not important, you might enjoy knowing that the HHVM module of Facebook was made over 2x faster by making sure that important cache lines are not knocked out[ PDF].\nThe disadvantages In case you have an array that has varying size elements in it, some non-trivial complications arise. Let me list just a few that come to my mind.\nSorting the list is no longer trivial You cannot just swap elements: they might not fit. One way to do sorting efficiently is to move all the data into another, equally-spaced container and sort there, then move it back in. However, keep in mind that the reason why quicksort is so fast is that it can do in-place sort. Merge-sorting would be another option, but it copies elements and it\u0026rsquo;s not by chance it\u0026rsquo;s not the default sort in most cases. Also, you would have to re-write merge-sort of course, to deal with the varying-sized elements.\nIn case you think that sorting is not needed, maybe you forgot to consider the lightning-quick subsumption you can do between implicit binary\u0026amp;tertiary clauses using sort to give just one example.\nRemoving an element is no longer an O(1) operation In case you need to remove element X in a watchlist, you can simply swap the last element to the position of X and make the array one smaller. This trick is used quite extensively since the order of the watchlist is usually irrelevant.\nLoops need to be re-written All your loops that go through the watchlist need to be re-written and have to have a switch() in them with some pointer arithmetic (do we advance by 32b or 64b?). In case you think you don\u0026rsquo;t need to go through the watchlist too often anyway, think again. Any time you need to do anything with clauses you will have to go through the watchlists, since they are the only place where binary (and tertiary, if your system is optimised enough) clauses are stored. This means your watchlist-gothrough function will be absolutely everywhere in the code unless you don\u0026rsquo;t want to implement any pre- or in-processing.\nYou might think you could write a function and just pass a pointer to another function to it that does the \u0026lsquo;real\u0026rsquo; job, essentially hiding the complexity in a function that you only need to write once. There are three problems with this. First, this will be a tight loop and so performance is important, which you will loose as you will need to dereference the passed-in function pointer every time. This can be overcome with the use of templates but it won\u0026rsquo;t make the code pretty. Secondly, your original, hiding function will need to be written more than a single time. For example, some such executions will need to count time (operations) and some won\u0026rsquo;t. You will need to count pointer dereferences (normal clause is fetched) and binary clauses (no pointer dereferenced) in a significantly different way as a cache-miss is very expensive and a clause-access will cause such a cache-miss most of the time. For performance reasons you will need variations that don\u0026rsquo;t dereference long clauses, variations that allow for manipulation of the array, variations that don\u0026rsquo;t, etc.\nMaintaining datastructure consistency becomes harder Unless you use hiding functions, which is non-trivial as explained above (and maybe impossible in e.g. plain C), the complexity to maintain consistency of the datastructure will be all over the code. Even if done very carefully, the constraints on the datastructure may end up being implicitly, rather than explicitly, represented in the code. It will make it easier to create bugs and harder to find them.\nConclusions This idea of using less memory for binary clauses in the watchlists is very interesting and has intrigued me for a long while \u0026ndash; Armin was kind enough to tell me about this a long time ago. It has the potential to save a lot of memory and to keep things more packed in the datastructure that is arguably the most accessed during solving and inprocessing. However, I was always daunted by the obstacles I saw in front of me \u0026ndash; though I might simply need to understand C++11 and templates better to make it work.\nCurrently, I feel like there are plenty of other optimisations that I could implement from the talk of Armin, e.g. that all watchlists are stored in the same array, using offsets and a hand-rolled memory manager. That seems to have a potential of also improving the memory usage and speed while being easier to implement and easier to hide in a class.\n","permalink":"https://www.msoos.org/2014/08/on-using-less-memory-for-binary-clauses-in-lingeling/","summary":"\u003cp\u003e\u003ca href=\"http://fmv.jku.at/biere/\"\u003eArmin Biere\u003c/a\u003e gave a lecture at the \u003ca href=\"http://www.pragmaticsofsat.org/2014/\"\u003ePragmatics of SAT workshop\u003c/a\u003e (proceeedings \u003ca href=\"http://www.easychair.org/publications/?page=624307\"\u003ehere\u003c/a\u003e) in Vienna about all the things inside \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e which won a lot of awards[ \u003ca href=\"http://satcompetition.org/2014/SAT-COMP.pdf\"\u003ePDF\u003c/a\u003e] this year. If you weren\u0026rsquo;t there, you missed an amazing presentation. In this blog post I\u0026rsquo;ll reflect on a particular part of the presentation dealing with a memory trickery that has been intriguing me for a long while but I did not implement. Before I begin let me say: the presentation was awesome, and it\u0026rsquo;s not by chance that lingeling won so many awards.\u003c/p\u003e","title":"On using less memory for binary clauses in lingeling's watchlists"},{"content":"CryptoMiniSat 4.2 has been released. This release brings multi-threading, some bug fixes, and a lot of code cleanup.\nMulti-threading Multi-threading has been implemented using the std::thread class of C++11. This makes it very portable and at the same time easy to use. Multi-threading is very simple and only shares unitary and binary learnt clauses. This is in comparison to other approaches that have some form of complex clause-sharing algorithms, sometimes even sharing clause databases. However, this system works when it\u0026rsquo;s used as a library, even with assumptions. Simply call set_num_threads(N) before calling any other functions.\nThe method used to speed up the system is the portfolio method, i.e. there are many threads started with different parameters and they share some information among them. The threads are configured as:\nswitch(thread_num) { case 1: { conf.restartType = restart_type_geom; conf.polarity_mode = CMSat::polarmode_neg; conf.varElimRatioPerIter = 1; break; } case 2: { conf.shortTermHistorySize = 80; conf.clauseCleaningType = CMSat::clean_glue_based; conf.restartType = CMSat::restart_type_glue; conf.increaseClean = 1.08; conf.ratioRemoveClauses = 0.55; break; } case 3: { conf.doVarElim = 0; conf.doGateFind = 0; conf.more_red_minim_limit_cache = 400; conf.more_red_minim_limit_binary = 200; conf.probe_bogoprops_timeoutM = 3500; conf.restartType = CMSat::restart_type_agility; conf.ratioRemoveClauses = 0.6; break; } case 4: { conf.simplify_at_startup = 1; conf.regularly_simplify_problem = 0; conf.varElimRatioPerIter = 1; conf.restartType = restart_type_geom; conf.clauseCleaningType = CMSat::clean_sum_activity_based; conf.polarity_mode = CMSat::polarmode_neg; conf.ratioRemoveClauses = 0.65; break; } case 5: { conf.doGateFind = 0; conf.more_red_minim_limit_cache = 100; conf.more_red_minim_limit_binary = 100; conf.probe_bogoprops_timeoutM = 4000; conf.ratioRemoveClauses = 0.6; break; } case 6: { conf.numCleanBetweenSimplify = 1; conf.skip_some_bve_resolvents = 1; conf.ratioRemoveClauses = 0.7; break; } case 7: { conf.clauseCleaningType = CMSat::clean_sum_confl_depth_based; conf.ratioRemoveClauses = 0.55; break; } case 8: { conf.polarity_mode = CMSat::polarmode_pos; conf.ratioRemoveClauses = 0.6; break; } case 9: { conf.do_bva = 0; conf.doGateFind = 0; conf.more_red_minim_limit_cache = 800; conf.more_red_minim_limit_binary = 400; conf.polarity_mode = CMSat::polarmode_neg; conf.ratioRemoveClauses = 0.6; break; } case 10: { conf.do_bva = 0; conf.doGateFind = 0; conf.restartType = CMSat::restart_type_agility; conf.clauseCleaningType = CMSat::clean_glue_based; conf.ratioRemoveClauses = 0.6; break; } case 11: { conf.simplify_at_startup = 1; conf.propBinFirst = 1; conf.doLHBR = 1; conf.increaseClean = 1.12; conf.ratioRemoveClauses = 0.7; break; } default: { conf.clauseCleaningType = CMSat::clean_glue_based; conf.ratioRemoveClauses = 0.7; break; } } These configurations have been chosen because they seemed to have quite orthogonal parameters. Only 12 threads are properly configured, the rest are not really configured and are only cleaning a lot more clauses than normal (so as not to run out of memory). In a certain sense, the above is the \u0026ldquo;secret sauce\u0026rdquo; that makes the parallel system work.\nCode cleanup The code has been greatly refactored. This is an ongoing effort, but its fruits are already quite visible. In general, variable and function names are more meaningful, function sizes have been drastically cut and the expressiveness of the code has been improved.\nUnfortunately, C++ (and C) are quite limiting in a number of ways, and so CryptoMiniSat might move to other languages such as Go. Go for example provides reflection and significantly improved compile times. These two are very useful for development: the former greatly simplifies testing while the latter allows for quicker build (and thus debug) cycles.\n[paypal-donation]\n","permalink":"https://www.msoos.org/2014/07/cryptominisat-4-2-released/","summary":"\u003cp\u003eCryptoMiniSat 4.2 has been \u003ca href=\"/cryptominisat4/\"\u003ereleased\u003c/a\u003e. This release brings multi-threading, some bug fixes, and a lot of code cleanup.\u003c/p\u003e\n\u003ch3 id=\"multi-threading\"\u003eMulti-threading\u003c/h3\u003e\n\u003cp\u003eMulti-threading has been implemented using the \u003ca href=\"http://en.cppreference.com/w/cpp/thread/thread\"\u003estd::thread\u003c/a\u003e class of C++11. This makes it very portable and at the same time easy to use. Multi-threading is very simple and only shares unitary and binary learnt clauses. This is in comparison to other approaches that have some form of \u003ca href=\"http://www.cril.univ-artois.fr/~jabbour/PDF/cp10.pdf\"\u003ecomplex clause-sharing algorithms\u003c/a\u003e, sometimes even sharing clause databases. However, this system works when it\u0026rsquo;s used as a library, even with assumptions. Simply call set_num_threads(N) before calling any other functions.\u003c/p\u003e","title":"CryptoMiniSat 4.2 released"},{"content":"The 2014 SMT competition\u0026rsquo;s QF_BV divison is over (benchmark tarball here), and the results are (copied from here):\nSolver Errors Solved Not Solved CPU time (solved instances) Boolector 0 2361 127 138077.59 STP-CryptoMiniSat4 0 2283 205 190660.82 [ MathSAT] 0 2199 289 262349.39 [ Z3] 0 2180 308 214087.66 CVC4 0 2166 322 87954.62 4Simp 0 2121 367 187966.86 SONOLAR 0 2026 462 174134.49 Yices2 0 1770 718 159991.55 abziz_min_features 9 2155 324 134385.22 abziz_all_features 9 2093 386 122540.04 First, let me congratulate Boolector by Armin Biere. STP came a not-so-close second. STP was meant to be submitted twice, once with MiniSat and once with CyrptoMiniSat4 \u0026ndash; this is the only reason why the STP submission is called STP-CryptoMiniSat4. Unfortunately, the other submission could not be made because of some compilation problems.\nAbout the results There are a couple of things I would like to draw your attention to. First is the cumulated solving time of solved instances. Note how it decreases compared to MathSat and Z3. Note also the differences in the DIFF of the number of solved instances. It\u0026rsquo;s relatively small between 4Simp\u0026hellip;MathSat(\u0026lt;40) and increases dramatically with STP and Boolector (with around 80 each).\nAnother thing of interest is that STP is surrounded by commercial products: Boolector, Z3 and MathSAT are all products you have to pay for to use in a commercial setting. In contrast, the biggest issue with STP is that if the optional(!) CryptoMiniSat4 is linked in, it\u0026rsquo;s LGPLv2 instead of MIT licensed. In other words, a lot of effort is in there, and it\u0026rsquo;s all free. Sometimes free as in beer, sometimes free as in freedom.\nAbout STP Lately, a lot of work has been done on STP. If you look a the github repository, it has about 80 issues resolved, about 40 open, lots of pull requests, and a lot of commits. A group of people, namely (in nickname order): Dan Liew, Vijay Ganesh, Khoo Yit Phang, Ryan Govostes, Trevor Hansen, a lot of external contributors (e.g. Stephen McCamant) and myself have been working on it pretty intensively. It now has a an automated test facility and a robust build system besides all the code cleanup and other improvements.\nIt\u0026rsquo;s a great team and I\u0026rsquo;m happy to be a minor part of it. If you feel like you could contribute, don\u0026rsquo;t hesitate to fork the repo, make some changes, and ask for a pull request. The discussions on the pull requests can be pretty elaborate which makes for a nice learning experience for all involved. Come and join \u0026ndash; next year hopefully we\u0026rsquo;ll win :)\n","permalink":"https://www.msoos.org/2014/06/smt-competition14-and-stp/","summary":"\u003cp\u003eThe \u003ca href=\"http://www.smtcomp.org/\"\u003e2014 SMT competition\u003c/a\u003e\u0026rsquo;s QF_BV divison is over (benchmark tarball \u003ca href=\"www.msoos.org/largefiles/QF_BV_smt_comp_2014.tar.gz\" title=\"QF_BV SAT-COMP'14 benchmarks\"\u003ehere\u003c/a\u003e), and the results are (copied from \u003ca href=\"http://smtcomp.sourceforge.net/2014/results-QF_BV.shtml?v=1403260059\"\u003ehere\u003c/a\u003e):\u003c/p\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth\u003e\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003e\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003e\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003e\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003e\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003cstrong\u003eSolver\u003c/strong\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003cstrong\u003eErrors\u003c/strong\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003cstrong\u003eSolved\u003c/strong\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003cstrong\u003eNot Solved\u003c/strong\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003cstrong\u003eCPU time (solved instances)\u003c/strong\u003e\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"http://fmv.jku.at/boolector/\"\u003eBoolector\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2361\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e127\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e138077.59\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"https://github.com/stp/stp\"\u003eSTP-CryptoMiniSat4\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2283\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e205\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e190660.82\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e[ \u003ca href=\"http://mathsat.fbk.eu/\"\u003eMathSAT\u003c/a\u003e]\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2199\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e289\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e262349.39\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e[ \u003ca href=\"http://z3.codeplex.com/\"\u003eZ3\u003c/a\u003e]\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2180\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e308\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e214087.66\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"http://cvc4.cs.nyu.edu/web/\"\u003eCVC4\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2166\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e322\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e87954.62\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e4Simp\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2121\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e367\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e187966.86\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"http://www.informatik.uni-bremen.de/agbs/florian/sonolar/\"\u003eSONOLAR\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2026\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e462\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e174134.49\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ca href=\"http://yices.csl.sri.com/\"\u003eYices2\u003c/a\u003e\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e1770\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e718\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e159991.55\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eabziz_min_features\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e9\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2155\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e324\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e134385.22\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eabziz_all_features\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e9\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e2093\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e386\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e122540.04\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eFirst, let me congratulate \u003ca href=\"http://fmv.jku.at/boolector/\"\u003eBoolector\u003c/a\u003e by Armin Biere. \u003ca href=\"https://github.com/stp/stp\"\u003eSTP\u003c/a\u003e came a not-so-close second. STP was meant to be submitted twice, once with MiniSat and once with CyrptoMiniSat4 \u0026ndash; this is the \u003cem\u003eonly\u003c/em\u003e reason why the STP submission is called STP-CryptoMiniSat4. Unfortunately, the other submission could not be made because of some compilation problems.\u003c/p\u003e","title":"SMT Competition'14 and STP"},{"content":"When doing multi-threading, parsing the input and inserting it into the solver threads is actually one of the most tricky part. Of course one can simply do\nvoid add_clause_to_all_threads(Clause clause) { for(int i = 0; i \u0026lt; threads; i++) { solver[i].add_clause(clause); } } It works and my SAT solver entry to the competition used this method. However, if we have 12 threads, the startup time will be 12x more than usual since only one thread is adding the clauses to all the solvers. If startup used to be 3s, it\u0026rsquo;s suddenly more than half a minute.\nA simple solution A simple solution to this problem is to create threads and add the clauses to the threads individually. The problem with this is that creating 12 threads for each clause and destroying the threads for each is actually more time than to do what\u0026rsquo;s above.\nThe correct solution The real solution is then to store the data to be added to the threads, and once a good number of them have been stored, add all the cached clauses to the solvers: create the 12 threads, for each thread add the clauses, and destroy the threads. This solution amortizes the creation\u0026amp;destruction of threads at the expense of storing clauses in a cache.\nCryptoMiniSat now uses a clause cache for exactly this purpose. Naturally, this also necessitates a cache for variable creation, though that is only a counter, so not a big deal.\n","permalink":"https://www.msoos.org/2014/05/multi-threading-and-startup-speed/","summary":"\u003cp\u003eWhen doing multi-threading, parsing the input and inserting it into the solver threads is actually one of the most tricky part. Of course one can simply do\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003evoid add_clause_to_all_threads(Clause clause) {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  for(int i = 0; i \u0026lt; threads; i++) {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    solver[i].add_clause(clause);\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  }\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e}\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eIt works and my SAT solver entry to the competition used this method. However, if we have 12 threads, the startup time will be 12x more than usual since only one thread is adding the clauses to all the solvers. If startup used to be 3s, it\u0026rsquo;s suddenly more than half a minute.\u003c/p\u003e","title":"Multi-threading and startup speed"},{"content":"[wpdm_file id=2] UPDATE: Fixed crash, UPDATE2: fixed looking for Gaussian elimination library\nIn the last days of the competition deadline, I have improved the following on the SAT solver:\nAdding N new variables is now possible in one go. This reduces variable addition overhead, especially when having many threads.\nMemory allocation overhead per new clause addition is now much smaller thanks to judicious use of globally allocated temporaries. Using such temporaries is very dangerous as CryptoMiniSat uses addClause() from multiple places in the code in a recursive manner. However, I only use the temporaries for add_clause_outer(), so things should be fine.\nIf more than 0.5M variables or 1.5M binary clauses are in the problem, on-the-fly hyper-binary resolution and transitive reduction is turned off during 1st-decision-level search. This is kind of like probing, but during search. However, unlike probing, it cannot time-out and switch off these systems in case they takes too much time.\nDiversified the threads\u0026rsquo; parameters. Also, I reduced the number of threads to 8. I wanted to run with 12, but it\u0026rsquo;s a bit dangerous from a memory-usage perspective: there is only 24GB available for 12 cores, which means 2GB/core. Some problems take more than 2GB just to parse into the watchlists.\nCheck total memory usage at startup of threads and if too much, halve the total number of threads. This is an emergency measure in case things go wild due to very weird CNF.\nOverall these are small changes but allow for a much faster startup. For example a notorious problem, AProVE07-11.cnf, now starts in 2.5s instead of 4.5s. As far as I can tell, this is very similar to the startup time of lingeling on this instance. However, lingeling only uses 1/3rd the memory (~250MB) thanks to a more tight memory manager plus I suspect it doesn\u0026rsquo;t have a couple of datastructs that I keep around.\nThe other difference, about OTF hyper-binary resolution, allows for large problems to actually get to the point of solving instead of getting stuck at adding and removing useless binary clauses. Let\u0026rsquo;s hope all goes well for the competition :)\n","permalink":"https://www.msoos.org/2014/05/final-polish-of-sat-competition-2014-entry/","summary":"\u003cp\u003e[wpdm_file id=2] UPDATE: Fixed crash, UPDATE2: fixed looking for Gaussian elimination library\u003c/p\u003e\n\u003cp\u003eIn the last days of the competition deadline, I have improved the following on the SAT solver:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eAdding N new variables is now possible in one go. This reduces variable addition overhead, especially when having many threads.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eMemory allocation overhead per new clause addition is now much smaller thanks to judicious use of globally allocated temporaries. Using such temporaries is very dangerous as CryptoMiniSat uses addClause() from multiple places in the code in a recursive manner. However, I only use the temporaries for add_clause_outer(), so things should be fine.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eIf more than 0.5M variables or 1.5M binary clauses are in the problem, on-the-fly hyper-binary resolution and transitive reduction is turned off during 1st-decision-level search. This is kind of like probing, but during search. However, unlike probing, it cannot time-out and switch off these systems in case they takes too much time.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eDiversified the threads\u0026rsquo; parameters. Also, I reduced the number of threads to 8. I wanted to run with 12, but it\u0026rsquo;s a bit dangerous from a memory-usage perspective: there is only 24GB available for 12 cores, which means 2GB/core. Some problems take more than 2GB just to parse into the watchlists.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eCheck total memory usage at startup of threads and if too much, halve the total number of threads. This is an emergency measure in case things go wild due to very weird CNF.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e","title":"Final polish of my SAT competition entry"},{"content":"[wpdm_file id=2]\nIn case you want to download my SAT competition 2014 zipfile, you can do it now. You can port the changes that you added to CryptoMiniSatv4 \u0026ndash; it should work out of the box. Nothing really important changed except some timeout fixes, bug fixes, threading, and fixing DRAT.\nUnfortunately the SAT Competition'14 setup doesn\u0026rsquo;t have Boost\u0026rsquo;s program options, so I had to create a main_simple.cpp that compiles without Boost. It only supports options \u0026ldquo;\u0026ndash;drat=1\u0026rdquo;, \u0026ldquo;\u0026ndash;threads=N\u0026rdquo;, \u0026ldquo;\u0026ndash;verbosity=N\u0026rdquo; and reading plain CNF files (not gzipped). This means you will have to edit SolverConf.cpp in case your changeset involves command line options. The command line options and their corresponding class variables are easy to look up in main.cpp, so changing SolverConf.cpp appropriately should not be difficult.\nGood luck with the competition!\n","permalink":"https://www.msoos.org/2014/04/my-sat-competition-2014-entry/","summary":"\u003cp\u003e[wpdm_file id=2]\u003c/p\u003e\n\u003cp\u003eIn case you want to download my SAT competition 2014 zipfile, you can do it now. You can port the changes that you added to CryptoMiniSatv4 \u0026ndash; it should work out of the box. Nothing really important changed except some timeout fixes, bug fixes, threading, and fixing \u003ca href=\"http://www.cs.utexas.edu/~marijn/drat-trim/\"\u003eDRAT\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eUnfortunately the SAT Competition'14 setup doesn\u0026rsquo;t have Boost\u0026rsquo;s \u003ca href=\"http://www.boost.org/doc/libs/1_55_0/doc/html/program_options.html\"\u003eprogram options\u003c/a\u003e, so I had to create a main_simple.cpp that compiles without Boost. It only supports options \u0026ldquo;\u0026ndash;drat=1\u0026rdquo;, \u0026ldquo;\u0026ndash;threads=N\u0026rdquo;, \u0026ldquo;\u0026ndash;verbosity=N\u0026rdquo; and reading plain CNF files (not gzipped). This means you will have to edit SolverConf.cpp in case your changeset involves command line options. The command line options and their corresponding class variables are easy to look up in main.cpp, so changing SolverConf.cpp appropriately should not be difficult.\u003c/p\u003e","title":"My SAT Competition 2014 entry"},{"content":"Just a short note: this Easter holiday I got a bit bored and did a mini-threading system for CryptoMiniSatv4. It will now be able to compete in the multi-threading track after quite a number of years of absence. Last time I did this, CryptoMiniSat won the UNSAT multi-threaded track, which was a bit funny because all I shared were unitary and binary clauses. For the simplicity and the fun, I\u0026rsquo;m doing the same this time around. Let\u0026rsquo;s hope all the super-complicated and extra-theoretica l stuff will get won over.\nNon-blocking datastructs Some authors implement a non-blocking data-sharing construct to gain more performance out of the system. I think/hope that what is shared is more important than how. I use one global lock for the shared unit and one for the shared binary clauses. Since there won\u0026rsquo;t be more than 8 threads under normal circumstances and I have to lock about once per 10sec per thread for about 0.01s, there won\u0026rsquo;t be any contention. Under these circumstances, simplicity wins over the complexity of using non-locking datastructures. Also, these fancy datastructs probably don\u0026rsquo;t have an implementation that is C++11 (i.e. portable) and is already implemented in gcc 4.7.1 (which doesn\u0026rsquo;t support a number of the threading constructs), the compiler used in the competition.\nLibrary usage This time around I didn\u0026rsquo;t mess it up: multi-threading can be used from the library interface. The system completely hides the fact that multiple threads are competing in the background to solve the problem. The threads are cleanly and safely stopped and then re-started when the user asks for another solve() operation, optionally with assumptions. In other words, the user doesn\u0026rsquo;t see and doesn\u0026rsquo;t have to bother with the complexity of threads. All of that is abstracted away behind a neat and clean API. This means that e.g. the different threads can have radically different variable numbers. They could have renumbered the variables differently, added new and different BVA variables, etc. All of this is hidden away and the user is presented with and always communicates using his/her own variable numbers.\nFinal notes This simple multi-threading system means that I can now port my old MPI code to use the new CryptoMiniSat. Maybe, once again, CryptoMiniSat will run on a cluster. Fun times ahead!\n","permalink":"https://www.msoos.org/2014/04/multi-threading/","summary":"\u003cp\u003eJust a short note: this Easter holiday I got a bit bored and did a mini-threading system for CryptoMiniSatv4. It will now be able to compete in the multi-threading track after quite a number of years of absence. Last time I did this, CryptoMiniSat won the \u003ca href=\"http://www.cril.univ-artois.fr/SAT11/phase2.pdf\"\u003eUNSAT multi-threaded\u003c/a\u003e track, which was a bit funny because all I shared were unitary and binary clauses. For the simplicity and the fun, I\u0026rsquo;m doing the same this time around. Let\u0026rsquo;s hope all the super-complicated and \u003ca href=\"http://www.cril.univ-artois.fr/~jabbour/PDF/jsatmanysat.pdf\"\u003eextra-theoretica\u003c/a\u003e l stuff will get won over.\u003c/p\u003e","title":"Multi-threading"},{"content":"Let\u0026rsquo;s examine why it\u0026rsquo;s hard to eliminate variables. I remember the code I looked at in SatElite that did it: it was crazy clean code and looked like it was pretty easy to perform. In this post I\u0026rsquo;ll examine how that simple code became more than a 1'000 lines of code today.\nWhat needs to be done, at first sight At first sight, variable elimination is easy. We just:\nBuild occurrence lists Pick a variable to eliminate Resolve every clause having the positive literal of the variable with negative ones. Add newly resolved clauses into the system Remove original clauses. Goto 2. These are all pretty simple steps at first sight, and one can imagine that implementing them is maybe 50-100 lines of code, no more. So, let\u0026rsquo;s examine them one-by-one to see how they get complicated.\nBuilding occurrence lists The idea is that we simply take every single clause, and for every literal they have, we insert a pointer to the clause into an array for that literal\u0026rsquo;s occurrences. This sounds easy, but what happens if we are given 1M clauses, each with 1000 literals on average? If you think this is crazy, it isn\u0026rsquo;t, and does in fact happen.\nOne option is we estimate the amount of memory we would use and abort early because we don\u0026rsquo;t want to run out of memory. So, first we check the potential size, then we link them in. Unfortunately, this means we can\u0026rsquo;t do variable elimination at all. Another possibility is that we link in clauses only partially. For example, we don\u0026rsquo;t link in clauses that are redundant but too long. Redundant clauses are ignored during resolution when eliminating, so this is OK, but then we will have to clean these clauses up later, when finishing up. However, if a redundant clause that hasn\u0026rsquo;t been linked in backward-subsumes an irredudant clause (and thus becomes irredundant itself), we have to link it in asap. Optimisation leads to complexity.\nWe don\u0026rsquo;t just want to link these clauses in to some random datastructure. I believe it was Armin Biere who put this idea into my head, or maybe someone else, but re-using watchlists for occurrence lists means we use our memory resources better: there won\u0026rsquo;t be so much fragmentation. Furthermore, an advanced SAT solver uses implicit binary \u0026amp; tertiary clauses, so those are linked in already into the watchlists. That saves memory.\nPicking a variable to eliminate The order in which you eliminate clauses is a defining part of the speed we get with the final solver. It is crucially important that this is done well. So, what can we do? We can either use some heuristic or precisely calculate the gain for each variable, and eliminate the best guess/calculated one first. These are both greedy algorithms but I think given the complexity of the task, they are the best at hand.\nUsing precise calculation is easy, we just resolve all the relevant clauses but don\u0026rsquo;t add the resolvents. It\u0026rsquo;s very expensive though. A better approach is to use a heuristic. Logically, clauses that have few literals in them are likely not to resolve such that they become tautologies. It\u0026rsquo;s unlikely that two binary clauses\u0026rsquo; resolvent becomes a tautology. It\u0026rsquo;s however likely that large clauses become tautological once resolved. I take this into account when calculating elimination cost for variable. Since redundant clauses are linked in the occurrence lists so that I can subsume them, I have to skip them.\nIt\u0026rsquo;s not enough to calculate the heuristic once, of course. We have to re-calculate after every elimination \u0026ndash; the playing field has changed. Thus, for every clause you removed, you have to keep in mind which variables were affected, and re-calculate the cost for each after every variable elimination.\nResolving clauses The base is easy. We add literals to a new array of literls and mark the literals that have been added in a quick-lookup array. If the opposite of a literal is added, the markings tell us and we can skip the rest \u0026ndash; the resolvent is tautological. Things get hairy if the clause is not tautological.\nWhat if the new clause is subsumed by already-existing clauses? Should we check for this? This is called forward-subsumption, and it\u0026rsquo;s really expensive. Backward subsumption (which asks the question \u0026lsquo;Does this clause subsume others?\u0026rsquo; instead of \u0026lsquo;Is this clause subsumed by others?\u0026rsquo;) would be cheaper, but that\u0026rsquo;s not the case here. We can thus try to subsume the clause only by e.g. binary\u0026amp;tertiary clauses and hope for the best.\nWhat if the new clause can be subsumed by stamps? That\u0026rsquo;s easy to check for, but if the new clause was used to create the stamp, that would be a self-dependency loop and not adding the resolvent would lead to an incorrect result. We can use the stamps as long as the resolving clauses were not needed for the stamp: i.e. they are not binary clauses and on-the-fly hyper-binary resolution was used during every step of stamp generation. A similar logic goes for using the implication cache.\nWe could also virtually extend the clause with literals using watchlists/stamps/impl. cache and then try to subsume that virtual clause. I forgot what 3-letter acronym Biere et al. gave to this method (it\u0026rsquo;s one of the 12 on slide 25 here), but, except for the acronym, this idea is pretty simple. You take a binary clause, e.g. xV~y, and if x is in the newly created clause, but y and ~y is not, you add y to the clause. The clause is now bigger, so has a larger chance to be subsumed. You now perform forward subsumption as above, but with the extended clause. Also, take care not to subsume clauses with themselves, which, as you might imagine, can get hairy.\nIf all of this sounds a bit intricate, this is not even the difficult part. The difficult part is keeping track of time. Where of course by time I don\u0026rsquo;t actually mean seconds \u0026ndash; I mean computation steps that you have to define one way or another and increment counters and set limits. Remember: all this has to be deterministic.\nDoing all of the above with a small but complicated instance is super-fast, under 0.001s. With a weird instance where one single literal may occur in more than a million clauses, it can be very-very expensive even for one single try \u0026ndash; over 100s. That\u0026rsquo;s about 5 orders of magnitude of difference. So, you have to be careful. The resolution we cannot skip, but we can abort it (and indicate it up in the call tree). Some of the others we can abort, but then the whole resolution has to be re-started. Some of the above is not critical at all, so you have to use a different time-limit for some, and mark them as too expensive, so at least the basic things get done. This gets complicated, because e.g. forward-subsumption you might want to re-use at other parts of the solver so you have to use a time-limit that isn\u0026rsquo;t global.\nAdding the newly resolved clauses Adding clauses is simple: we create and link them in. However, we can do more. Since backward-subsumption is fast, we can do that with the newly created clauses. Note that this means the newly created clause could subsume some of the original clauses it was created from \u0026ndash; which means the resolvents should be pre-generated and kept in memory.\nAnother thing: since we know the new clause needs to be added, we might as well shorten it before in any way we can. At this point, we can make use of all the watchlists, stamps and implication cache we have to shorten the new clause: there are no problems with self-dependencies. It will pay off. However, note that shortening the clause before adding it means that we will have to reverse-shorten it later, when this clause might be part of a group of clauses that is touched by a new variable elimination round. So, we are working against ourselves in a way \u0026ndash; especially because reverse shortening is pretty expensive and hairy as explained above.\nAlthough this is obvious, but we still have to take care of time-outs. For example, if resolution took so much time that we are already out of time, we must exit asap and not worry about the resolvents. Don\u0026rsquo;t link, don\u0026rsquo;t remove, just exit. Time is of essence.\nRemoving the original clauses Easy, just unlink them from the occurrence lists. I mean, easy if you don\u0026rsquo;t care about time, of course. Because unlinking is an O(N^2) operation if you have N clauses and all of them contain the same literal X \u0026ndash; the N-long occurrence list of literal X has to be read and updated N times. So, we don\u0026rsquo;t do this.\nFirst of all, a special case: the two occurrence lists of the variable we are removing can simply be .clear()-ed. It\u0026rsquo;s no longer needed. Secondly, we shouldn\u0026rsquo;t unlink clauses one-by-one. Instead, we should mark the clause as removed, and then not care about the clause later. Once variable elimination is finished, we do a sweep of all the occurrence lists and clauses and remove the clauses that have been marked. This means that e.g. forward and backward subsumption gets more hairy (we shouldn\u0026rsquo;t subsume with a clause that\u0026rsquo;s been marked as removed but is still in the occurrence list) but that O(N^2) becomes O(N) which for problems where N is large makes quite a bit of difference. Like, the difference of 100s vs. 10s for a the same exact thing.\nThe untold horrors On top of what\u0026rsquo;s above, you might like to generate some statistics about what worked and what didn\u0026rsquo;t. You might like to dump these statistics to a database. You might like to not create resolutions that are not needed as the irreduntant clauses form an AND/ITE gate. Or multiple gates. You might like to eliminate only a subset of variables at each call so that you don\u0026rsquo;t make your system too sparse and thus reduce arc consistency. You might want to vary this limit based on the problem at hand. You might want to do many other things that are not detailed above.\nConclusions Once I read through the above, I realized I kind of missed the essence: time-outs. It\u0026rsquo;s mentioned here and there, but it\u0026rsquo;s much more critical than it seems and makes things a hell of a lot harder. How do you cleanly exit from the middle of reverse-shortening while resolving because you ran out of time? I could just bury my head in sand of course and say: I don\u0026rsquo;t care. Or, I could make some messy algorithm that checks return values of each call and return a special value in case of time-outs. This needs to be done for every level of the call, which can be pretty deep, unless you like writing 1'500 line functions. I wanted to say writing\u0026amp;reading, but, really, nobody reads 1'500 line functions. They are throw-away,write-only code.\n","permalink":"https://www.msoos.org/2014/04/why-its-hard-to-eliminate-variables/","summary":"\u003cp\u003eLet\u0026rsquo;s examine why it\u0026rsquo;s hard to eliminate variables. I remember the code I looked at in \u003ca href=\"http://minisat.se/SatELite.html\"\u003eSatElite\u003c/a\u003e that did it: it was crazy clean code and looked like it was pretty easy to perform. In this post I\u0026rsquo;ll examine how that simple code became more than a 1'000 lines of code today.\u003c/p\u003e\n\u003ch3 id=\"what-needs-to-be-done-at-first-sight\"\u003eWhat needs to be done, at first sight\u003c/h3\u003e\n\u003cp\u003eAt first sight, variable elimination is easy. We just:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eBuild occurrence lists\u003c/li\u003e\n\u003cli\u003ePick a variable to eliminate\u003c/li\u003e\n\u003cli\u003eResolve every clause having the positive literal of the variable with negative ones.\u003c/li\u003e\n\u003cli\u003eAdd newly resolved clauses into the system\u003c/li\u003e\n\u003cli\u003eRemove original clauses.\u003c/li\u003e\n\u003cli\u003eGoto 2.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eThese are all pretty simple steps at first sight, and one can imagine that implementing them is maybe 50-100 lines of code, no more. So, let\u0026rsquo;s examine them one-by-one to see how they get complicated.\u003c/p\u003e","title":"Why it's hard to eliminate variables"},{"content":"[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.\nSAT 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\u0026rsquo;s not possible to use newer versions of lingeling or riss (see license for for details), MiniSat is rather old and glucose doesn\u0026rsquo;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\u0026rsquo;s LGPLv2 \u0026ndash; just don\u0026rsquo;t call it CryptoMiniSat.\nImprovements and techniques Here is a non-exhaustive list of techniques used in CryptoMiniSat v4:\nVariable 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 \u0026ndash; it immediately starts to solve instead. This, as everything else, is configurable and you can change it by passing `\u0026rsquo;\u0026ndash;presimp 1\u0026rsquo;` as a command-line option. There are a total of 120 command-line options so you can tune the solver as you like.\nPython interface It\u0026rsquo;s intuitive and fun to use:\n\u0026gt;\u0026gt;\u0026gt; from pycryptosat import Solver \u0026gt;\u0026gt;\u0026gt; s = Solver() \u0026gt;\u0026gt;\u0026gt; s.add_clause([-1]) \u0026gt;\u0026gt;\u0026gt; s.add_clause([1, 2]) \u0026gt;\u0026gt;\u0026gt; sat, solution = s.solve() \u0026gt;\u0026gt;\u0026gt; print sat True \u0026gt;\u0026gt;\u0026gt; print solution[1] False \u0026gt;\u0026gt;\u0026gt; print solution[2] True You can even have assumptions:\n\u0026gt;\u0026gt;\u0026gt; from pycryptosat import Solver \u0026gt;\u0026gt;\u0026gt; s = Solver() \u0026gt;\u0026gt;\u0026gt; s.add_clause([-1]) \u0026gt;\u0026gt;\u0026gt; sat, solution = s.solve([1]) \u0026gt;\u0026gt;\u0026gt; print sat False \u0026gt;\u0026gt;\u0026gt; sat, solution = s.solve() \u0026gt;\u0026gt;\u0026gt; print sat True All the power of the SAT solver in a very accessible manner. XOR clauses are trivial, too:\n\u0026gt;\u0026gt;\u0026gt; from pycryptosat import Solver \u0026gt;\u0026gt;\u0026gt; s = Solver() \u0026gt;\u0026gt;\u0026gt; s.add_xor_clause([1, 2], false) \u0026gt;\u0026gt;\u0026gt; sat, solution = s.solve([1]) \u0026gt;\u0026gt;\u0026gt; print sat True \u0026gt;\u0026gt;\u0026gt; print solution[1] True \u0026gt;\u0026gt;\u0026gt; print solution[2] True Where the second argument is the right hand side (RHS) of the equation v1 XOR v2 = False.\nC++ interface Usage is pretty simple, and the header files have been significantly cleaned up:\n#include #include #include using std::vector; using namespace CMSat; int main() { Solver solver; vector clause; //adds \u0026#34;1 0\u0026#34; clause.push_back(Lit(0, false)); solver.add_clause(clause); //adds \u0026#34;-2 0\u0026#34; clause.clear(); clause.push_back(Lit(1, true)); solver.add_clause(clause); //adds \u0026#34;-1 2 3 0\u0026#34; 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:\nAdd 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 \u0026lsquo;heavy\u0026rsquo; approach where I don\u0026rsquo;t remove all clauses that I can as I like strong propagation properties. You might try the \u0026rsquo;light\u0026rsquo; 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:\nbool 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-\u0026gt;stats.propagations_made + x-\u0026gt;stats.conflicts_made; uint64_t y_useful = y-\u0026gt;stats.propagations_made + y-\u0026gt;stats.conflicts_made; return x_useful \u0026lt; 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\u0026#39;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. ","permalink":"https://www.msoos.org/2014/04/cryptominisat-4-released/","summary":"\u003cp\u003e[wpdm_file id=1]\nCryptoMiniSat 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.\u003c/p\u003e\n\u003ch3 id=\"sat-competition-2014\"\u003eSAT Competition 2014\u003c/h3\u003e\n\u003cp\u003eThis release is made ahead of the \u003ca href=\"http://www.satcompetition.org/2014/\"\u003eSAT competition 2014\u003c/a\u003e deadlines so anybody can compete and actually have a chance to win. Unfortunately, the way I see it, it\u0026rsquo;s not possible to use newer versions of \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e or \u003ca href=\"http://tools.computational-logic.org/content/riss3g.php?run=eight\"\u003eriss\u003c/a\u003e (see license for for details), \u003ca href=\"http://minisat.se/\"\u003eMiniSat\u003c/a\u003e is rather old and \u003ca href=\"http://www.labri.fr/perso/lsimon/glucose/\"\u003eglucose\u003c/a\u003e doesn\u0026rsquo;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\u0026rsquo;s LGPLv2 \u0026ndash; just don\u0026rsquo;t call it CryptoMiniSat.\u003c/p\u003e","title":"CryptoMiniSat 4 released"},{"content":"All SAT solvers must have a tri-state class that can hold the values `true`, `false`, and `undefined`. Although it\u0026rsquo;s not hard to write code to represent such a class, it\u0026rsquo;s hard to write such it so that all typical operations are fast. In this blog post I will compare three different ways of doing it.\nThe original MiniSat 2.0 code The original MiniSat 2.0 used the following code for such a class:\nclass lbool { char value; explicit lbool(const char v) : value(v) { } public: lbool() : value(0) {} bool operator==(lbool b) const { return value == b.value; } bool operator!=(lbool b) const { return value != b.value; } lbool operator^(const bool b) const { return b ? lbool(-value) : lbool(value); } friend lbool toLbool(const char v); friend lbool boolToLBool(const bool b); friend class llbool; }; inline lbool toLbool(const char v) { return lbool(v); } const lbool l_True = toLbool( 1); const lbool l_False = toLbool(-1); const lbool l_Undef = toLbool( 0); All the operators are pretty straightforward and fast, except `operator^` which flips `true` to `false` and `false` to `true` in case `b` is `true`. As you might have noticed it\u0026rsquo;s using a branch instruction to achieve this result which is weird and slow. Branching is known to be a headache as a wrong branch prediction can slow down the CPU quite a bit. Since `b` is supposed to be random (though it\u0026rsquo;s not that random), this might slow down the flip operation. Let\u0026rsquo;s call this version of the class solution (1).\nNewest MiniSat code Current MiniSat has changed the code to the following:\nclass lbool { uint8_t value; public: explicit lbool(uint8_t v) : value(v) { } lbool() : value(0) { } explicit lbool(bool x) : value(!x) { } bool operator == (lbool b) const { return ((b.value\u0026amp;2) \u0026amp; (value\u0026amp;2)) | (!(b.value\u0026amp;2)\u0026amp;(value == b.value)); } bool operator != (lbool b) const { return !(*this == b); } lbool operator ^ (bool b) const { return lbool((uint8_t)(value^(uint8_t)b)); } lbool operator \u0026amp;\u0026amp; (lbool b) const { uint8_t sel = (this-\u0026gt;value \u0026lt;\u0026lt; 1) | (b.value \u0026lt;\u0026lt; 3); uint8_t v = (0xF7F755F4 \u0026gt;\u0026gt; sel) \u0026amp; 3; return lbool(v); } lbool operator || (lbool b) const { uint8_t sel = (this-\u0026gt;value \u0026lt;\u0026lt; 1) | (b.value \u0026lt;\u0026lt; 3); uint8_t v = (0xFCFCF400 \u0026gt;\u0026gt; sel) \u0026amp; 3; return lbool(v); } friend int toInt (lbool l); friend lbool toLbool(int v); }; inline int toInt (lbool l) { return l.value; } inline lbool toLbool(int v) { return lbool((uint8_t)v); } const lbool l_True ((uint8_t)0); const lbool l_False((uint8_t)1); const lbool l_Undef((uint8_t)2); It doesn\u0026rsquo;t use a branch operator to flip values: `operator^` uses a simple XOR. However, other operators, notably the comparison operator became much more involved, and thus expensive. Let\u0026rsquo;s call this solution to the problem solution (2).\nNumerical trickery on the old code Instead of using really tricky comparison and binary AND/OR operators, let\u0026rsquo;s try to use the original class, but replace the branch instruction with a bit of numerical trickery:\nlbool operator^(const bool b) const { //return b ? lbool(-value) : lbool(value); return lbool(value * (-2*(char)b + 1)); } This makes \u0026rsquo;extensive\u0026rsquo; use of the ALU of the chip for the flip operator to avoid using the branch instruction. However, it keeps other operators cheap as per the first version. Let\u0026rsquo;s call this solution to the problem solution (3).\nComparison I have tried to solve two different problems from the SAT Competition of 2009 with all three solutions. First is a typical electronic engineering problem, 9dlx_vliw_at_b_iq2.cnf. The second is a typical cryptographic problem, mizh-md5-47-3.cnf. Here are the timing results for my i7-3612QM (Ivy Bridge):\nProblem Solution(1) Solution(2) Solution(3) 9dlx_vliw_at_b_iq2.cnf 135.9s 138.8s 132.5s mizh-md5-47-3.cnf 60.7s 60.5s 56.3s So, in this very small test, solution(3) wins.\nAnd now for a bit of history. I have tried the trick in solution(3) about 3 years ago. Back then it seemed slower to perform the numerical trick than to use the branch. It turns out that on modern CPUs either the ALU is faster, branch misprediction is more costly, or both (or, the compilers have evolved to compile my numerical trickery into some weird thing). Anyway, it\u0026rsquo;s kind of a cool speedup for a one-liner.\n","permalink":"https://www.msoos.org/2014/03/speeding-up-minisat-with-a-one-liner/","summary":"\u003cp\u003eAll SAT solvers must have a tri-state class that can hold the values `true`, `false`, and `undefined`. Although it\u0026rsquo;s not hard to write code to represent such a class, it\u0026rsquo;s hard to write such it so that all typical operations are fast. In this blog post I will compare three different ways of doing it.\u003c/p\u003e\n\u003ch3 id=\"the-original-minisat-20-code\"\u003eThe original MiniSat 2.0 code\u003c/h3\u003e\n\u003cp\u003eThe \u003ca href=\"http://minisat.se/downloads/minisat2-070721.zip\"\u003eoriginal MiniSat 2.0\u003c/a\u003e used the following code for such a class:\u003c/p\u003e","title":"Speeding up MiniSat with a one-liner"},{"content":"Variable renumbering in SAT solvers keeps a mapping between the external variable numbers that is visible to the users and the internal variable numbers that is visible the to the system. The trivial mapping that most SAT solvers use is the one-to-one mapping where there is no difference between outer and internal variables. A smart mapping doesn\u0026rsquo;t keep track of all data related to variables that have been set or eliminated internally, so the internal datastructures can be smaller.\nAdvantages Having smaller internal data structures help in achieving a lower memory footprint and better cache usage.\nThe memory savings are useful because some CNFs have tens of millions of variables. If the solver uses the typical watched literal scheme, it needs 2 arrays for each variable. If we are using 64b pointers and 32b array sizes, it\u0026rsquo;s 32B for each variable, so 32MB for every million variable only to keep the watching literal array(!). I have seen people complaining that their 100M variable problem runs out of memory \u0026ndash; if we count that right that\u0026rsquo;s 3.2GB of memory only to hold the watching literal array pointers and sizes, not any data at all.\nAs for the CPU cache benefits: modern CPUs work using cache lines which are e.g. 64B long on Intel Sandy Bridge. If half of the variables are set already, the array holding the variable values \u0026ndash; which will be accessed non-stop during propagation \u0026ndash; will contain 50% useless data. In practice the speedup achieved can be upwards of 10%.\nThe simple problems One problem with having a renumbering scheme is that you need to keep track of which datastructure is numbered in which way. The easy solution is to renumber absolutely everything. This is costly, however, as the mapping has to change every once in a while when new variables have been set. In this case, if everything is renumbered, then the eliminated variables\u0026rsquo; data needs to be updated according to the new mapping every time. This might be quite significant. So, it\u0026rsquo;s best not to renumber that. Similarly, if disconnected component analysis is used, then the disconnected components\u0026rsquo; saved solutions need to be renumbered as well, along with the clauses that have been moved to the components.\nAn approach I have found to be satisfying is to keep every dynamic datastructure such as variable states (eliminated/decomposed/etc.), variable values (True/False/Unknown), clauses\u0026rsquo; literals, etc. renumbered, while keeping mostly static datastructures such as eliminated clauses or equivalent literal maps non-renumbered. This works very well in practice as it allows the main system to shuffle the mapping around while not caring about all the other systems\u0026rsquo; data.\nThe hard problem The above is all fine and dandy until bounded variable addition (BVA) comes to the scene. This technique adds new variables to the problem to simplify it. These new variables will look like new outer variables, which seems good at first sight: the system could simply print the solution to all variables except the last N that were added by BVA and are not part of the original problem. However, if the caller adds new variables after the call to solve(), what can we do? The actual variables by the caller and the BVA variables will be mixed up: start with a bunch of original variables, sprinkle the end with some BVA, then some original variables, then some BVA\u0026hellip;\nThe trivial solution to this is to have another mapping, one that translates variable numbers between the BVA and non-BVA system. As you might imagine, this complicates everything. Another solution is to forcibly eliminate all BVA variables after the call to solve(), let the user add the new clauses, and perform BVA again. Another even more complicated solution is to keep track of the variables being added, then re-number all variables inside all datastructures to move all BVA variables to the end of the variable array. This is expensive but only needs to be done once after the call to solve(), which may be acceptable. Currently, CryptoMiniSat uses the trivial scheme. Maybe I\u0026rsquo;ll move to the last (and most complicated) system later on.\nConclusion Variable renumbering is not for the faint of heart. Bugs become significantly harder to track, as all debug messages need to be translated to a common variable numbering or they make no sense at all. It\u0026rsquo;s also very easy to introduce bugs through variable renumbering. A truly difficult bug I had was when the disconnected component finder\u0026rsquo;s sub-solver renumbered its internal variables and when I tried to import some values from the sub-solver back to the main solver, I used the wrong variable numbers.\n","permalink":"https://www.msoos.org/2013/12/on-variable-renumbering/","summary":"\u003cp\u003eVariable renumbering in SAT solvers keeps a mapping between the external variable numbers that is visible to the users and the internal variable numbers that is visible the to the system. The trivial mapping that most SAT solvers use is the one-to-one mapping where there is no difference between outer and internal variables. A smart mapping doesn\u0026rsquo;t keep track of all data related to variables that have been set or eliminated internally, so the internal datastructures can be smaller.\u003c/p\u003e","title":"On variable renumbering"},{"content":"Learnt clauses are clauses derived while searching for a solution with a SAT solver in a CNF. They are at the heart of every modern so-called \u0026ldquo;CDCL\u0026rdquo; or \u0026ldquo;Conflict-Driven Clause-Learning\u0026rdquo; SAT solver. SAT solver writers make a very important difference between learnt and original clauses. In this blog post I\u0026rsquo;ll talk a little bit about this distinction, why it is important to make it, and why we might want to relax that distinction in the future.\nA bit of terminology First, let me call \u0026ldquo;learnt\u0026rdquo; clauses \u0026ldquo;reducible\u0026rdquo; and original clauses \u0026ldquo;irreducible\u0026rdquo;. This terminology was invented by Armin Biere I believe, and it is conceptually very important.\nIf a clause is irreducible it means that if I remove that clause from the clause database and solve the remaining system of constraints, I might end up with a solution that is not a solution to the original problem. However, these clauses might not be the \u0026ldquo;original\u0026rdquo; clauses \u0026ndash; they might have been shortened, changed, or otherwise manipulated such as through equivalent literal replacement, strengthening, etc.\nReducible clauses on the other hand are clauses that I can freely remove from the clause database without the risk of finding a solution that doesn\u0026rsquo;t satisfy the original set of constraints. These clauses could be called \u0026ldquo;learnt\u0026rdquo; but strictly speaking they might not have been learnt through the 1st UIP learning process. They could have been added through hyper-binary resolution, they could have been 1UIP clauses that have been shortened/changed, or clauses obtained through other means such as Gaussian Elimination or other high-level methods.\nThe distinction Reducible clauses are typically handled \u0026ldquo;without care\u0026rdquo; in a SAT solver. For example, during bounded variable elimination (BVE) resolutions are not carried out with reducible clauses. Only irreducible clauses are resolved with each other and are added back to the clause database. This means that during variable elimination information is lost. For this reason, when bounded variable addition (BVA) is carried out, one would not count the simplification obtained through the removal of reducible clauses, as BVE could then completely undo BVA. Naturally, the heuristics in both of these systems only count irreducible clauses.\nReducible clauses are also regularly removed or \u0026lsquo;cleaned\u0026rsquo; from the clause database. The heuristics to perform this has been a hot topic in the past years and continue to be a very interesting research problem. In particular, the solver Glucose has won multiple competitions by mostly tuning this heuristic. Reducible clauses need to be cleaned from the clause database so that they won\u0026rsquo;t slow the solver down too much. Although they represent information, if too many of them are present, propagation speed grinds to a near-halt. A balance must be achieved, and the balance lately has shifted much towards the \u0026ldquo;clean as much as possible\u0026rdquo; side \u0026ndash; we only need to observe the percentage of clauses cleaned between MiniSat and recent Glucose to confirm this.\nAn observation about glues Glues (used first by Glucose) are an interesting heuristic in that they are static in a certain way: they never degrade. Once a clause achieves glue status 2 (the lowest, and best), it can never loose this status. This is not true of dynamic heuristics such as clause activities (MiniSat) or other usability metrics (CryptoMiniSat 3). They are highly dynamic and will delete a clause eventually if it fails to perform well after a while. This makes a big difference: with glues, some reducible clauses will never be deleted from the clause database, as they have achieved a high enough status that most new clauses will have a lower status (a higher glue) and will be deleted instead in the next cleaning run.\nSince Glucose doesn\u0026rsquo;t perform variable elimination (or basically any other optimization that could forcibly remove reducible clauses), some reducible clauses are essentially \u0026ldquo;locked\u0026rdquo; into the clause database, and are never removed. These reducible clauses act as if they were irreducible.\nIt\u0026rsquo;s also interesting to note that glues are not static: they are in fact updated. The way they are updated, however, is very particular: they can obtain a lower glue number (a higher chance of not being knocked out) through some chance encounters while propagating. So, if they are propagated often enough, they have a higher chance of obtaining a lower glue number \u0026ndash; essentially having a higher chance to be locked into the database.\nSome speculation about glues What if these reducible clauses that are locked into the clause database are an important ingredient in giving glues the edge? In other words, what if it\u0026rsquo;s not only the actual glue number that is so wildly good at guessing the usefulness of a reducible clause, instead the fact that their calculation method doesn\u0026rsquo;t allow some reducible clauses ever to be removed also significantly helps?\nTo me, this sounds like a possibility. While searching and performing conflict analysis SAT solvers are essentially building a chain of lemmas, a proof. In a sense, constantly removing reducible clauses is like building a house and then knocking a good number of bricks out every once in a while. If those bricks are at the foundation of the system, what\u0026rsquo;s above might collapse. If there are however reducible clauses that are never \u0026ldquo;knocked out\u0026rdquo;, they can act as a strong foundation. Of course, it\u0026rsquo;s a good idea to be able to predict what is a good foundation, and I believe glues are good at that (though I think there could be other, maybe better measures invented). However, the fact that some of them are never removed may also play a significant role in their success.\nLocking clauses Bounded variable addition is potentially a very strong system that could help in shortening proofs. However, due to the original heuristics of BVE it cannot be applied if the clauses it removes are only reducible. So, it can only shorten the description of the original problem (and maybe incidentally some of the reducible clauses) but not only the reducible clauses themselves. This is clearly not optimal for shortening the proof. I don\u0026rsquo;t know how lingeling performs BVA and BVE, but I wouldn\u0026rsquo;t be surprised if it has some heuristic where it treats some reducible clauses as irreducible (thereby locking them) so that it could leverage the compression function of BVA over the field of reducible clauses.\nUnfortunately, lingeling code is hard to read, and it\u0026rsquo;s proprietary code so I\u0026rsquo;d rather not read it unless some licensing problems turn up. No other SAT solver performs BVA as an in-processing method (riss performs it only as pre-processing, though it is capable to perform BVA as in-processing), so I\u0026rsquo;m left on my own to guess this and code it accordingly.\nUPDATE: According to Norbert Manthey lingeling doesn\u0026rsquo;t perform BVA at all. This is more than a little surprising.\nEnd notes I believe it was first Vegard Nossum who put into my head the idea of locking some reducible clauses into the database. It only occurred to me later that glues automatically achieve that, and furthermore, they seem to automatically lock oft-propagated reducible clauses.\nThere are some problems with the above logic, though. I believe lingeling increments the glue counter of some (all?) reducible clauses on a regular basis, and lingeling is a good solver. That would defeat the above logic, though the precise way glues are incremented (and the way they are cleaned) in lingeling is not entirely clear to me. So some of the above could still hold. Furthermore, lingeling could be so well-performing for other reasons \u0026ndash; there are more to SAT solvers than just search and resolution. Lately, up to 50% or more of the time spent in modern SAT solvers could be used to perform actions other than search.\n","permalink":"https://www.msoos.org/2013/12/a-note-on-learnt-clauses/","summary":"\u003cp\u003eLearnt clauses are clauses derived while searching for a solution with a \u003ca href=\"https://en.wikipedia.org/wiki/Boolean_satisfiability_problem\"\u003eSAT solver\u003c/a\u003e in a \u003ca href=\"https://en.wikipedia.org/wiki/Conjunctive_normal_form\"\u003eCNF\u003c/a\u003e. They are at the heart of every modern so-called \u0026ldquo;CDCL\u0026rdquo; or \u0026ldquo;\u003ca href=\"https://en.wikipedia.org/wiki/Conflict_Driven_Clause_Learning\"\u003eConflict-Driven Clause-Learning\u003c/a\u003e\u0026rdquo; SAT solver. SAT solver writers make a very important difference between learnt and original clauses. In this blog post I\u0026rsquo;ll talk a little bit about this distinction, why it is important to make it, and why we might want to relax that distinction in the future.\u003c/p\u003e","title":"A note on learnt clauses"},{"content":"**CLICK HERE**to run CyrptoMiniSat in your browser Lately, I have become an LLVM nut. LLVM is amazing, it can do a lot, and, weirdly enough, a system developed from it is probably one of the biggest users of SAT solvers. I\u0026rsquo;m talking about KLEE, the symbolic virtual execution machine. It takes a source, compiles it with LLVM, then translates the LLVM IR into SMT, runs STP on it, which in turn runs CryptoMiniSat, and voila\u0026hellip; the user gets back a free bug report. Or 1'200 bug reports.\nEmscripten Another great use of LLVM is emscripten, which takes the LLVM IR (again) and turns it into javascript. This of course means we can now run SAT solvers in the browser. This is so much fun. Here you can play with it, this is MiniSat \u0026ldquo;core\u0026rdquo;, from the golden old days of 2009. Just type in any CNF in DIMACS format and enjoy :) You can now solve the most basic NP-complete problem, right from your browser!\nMiniSat in javascript Please click here to run CyrptoMiniSat in your browser \u0026ndash; much better!!\nEpiloge Yes, it\u0026rsquo;s actually running in your browser. The default CNF describes the HiTag2 cipher, with 10 output bits and 2 help bits given. The instance was generated using the Grain of Salt system. Note that the web page hangs until MiniSat finishes. Try typing in your own CNFs, play as much as you like. If you are patient, it can solve many problems, including reversing modern ciphers, finding SHA-1 collisions (PDF), verifying hardware and software\u0026hellip; you just have to be patient enough.\nProbably unbeknownst to you, you are using products of SAT solvers for your daily life: CPUs are verified using SAT solver-based techniques, airplane software is formally verified using SAT solvers, FPGA and CPU layouts are optimized using them, and if you are lucky, your car\u0026rsquo;s safety-critical systems are also verified using formal techniques, which basically means SAT solvers. Actually, even train schedules and public transport schedules are created using SAT solvers \u0026ndash; I know for a fact that many trains in Europe are scheduled using these techniques. All these can be done using the very simple problem description, the CNF, you see above \u0026ndash; and many of these systems use MiniSat.\nHow I did it and what could be improved It\u0026rsquo;s relatively easy to compile any C or C++-based SAT solver to javascript using emscripten. Here is my github repo, with included HOWTO, for MiniSat. I would love to compile current lingeling, but its license doesn\u0026rsquo;t seem to allow emscripten to even think about compiling it. I\u0026rsquo;ll compile CryptoMiniSat later, it\u0026rsquo;s a bit hairy right now, I\u0026rsquo;m trying to refactor the code since it\u0026rsquo;s a mess. Until then, I hope you\u0026rsquo;ll enjoy playing with MiniSat!\nAcknowledgements A big thanks to my colleagues who pushed me to became an LLVM nut. Also, big thanks to Niklas Eén and Niklas Sörensson for MinSat!\n","permalink":"https://www.msoos.org/2013/09/minisat-in-your-browser/","summary":"\u003ch2 id=\"click-hereto-run-cyrptominisat-in-your-browser\"\u003e**\u003ca href=\"http://msoos.github.io/cryptominisat_web/\"\u003eCLICK HERE\u003c/a\u003e**to run CyrptoMiniSat in your browser\u003c/h2\u003e\n\u003cp\u003eLately, I have become an \u003ca href=\"http://llvm.org/\"\u003eLLVM\u003c/a\u003e nut. LLVM is amazing, it can do a lot, and, weirdly enough, a system developed from it is probably one of the biggest users of SAT solvers. I\u0026rsquo;m talking about \u003ca href=\"http://ccadar.github.io/klee/\"\u003eKLEE\u003c/a\u003e, the symbolic virtual execution machine. It takes a source, compiles it with LLVM, then translates the \u003ca href=\"http://llvm.org/docs/LangRef.html#abstract\"\u003eLLVM IR\u003c/a\u003e into SMT, runs \u003ca href=\"https://sites.google.com/site/stpfastprover/\"\u003eSTP\u003c/a\u003e on it, which in turn runs \u003ca href=\"/cryptominisat2/\"\u003eCryptoMiniSat\u003c/a\u003e, and voila\u0026hellip; the user gets back a free bug report. Or \u003ca href=\"http://lists.debian.org/debian-devel/2013/06/msg00720.html\"\u003e1'200 bug reports\u003c/a\u003e.\u003c/p\u003e","title":"MiniSat in your browser"},{"content":"Since the SAT solver fuzzing paper by Brummayer, Lonsing and Biere, SAT solver fuzzing has been quite the thing in the SAT community. Many bugs have since been discovered in almost all SAT solvers, including those of this author. In this blog post I will detail my SAT fuzzing setup: what fuzzers I use and how I use them.\nMy fuzzers The most obvious fuzzers to use are those present in the paper and accompanying website: CNFFuzz and FuzzSAT. These fuzzers randomly genereate high-quality structured problem instances. The emphasis here is on the word structured. Randomly generated instances, as the authors of the original paper note, do not excercise SAT solvers enough. SAT solvers are written with very specific problem types in mind: problems containing long chains of binary clauses, gates, etc.\nOver the year(s) I have found, however, that these fuzzers are not enough. One of the revelations came when Vegard sent me lots of bugreports about CryptoMiniSat failing when Gaussian elimination was enabled. It turned out that although I ran the fuzzer for long hours, I only ran it with the default option, Gaussian turned off. So default options are sometimes not enough and when off-the track, systems can fail.\nVegard then sent me a fuzzer that wasn\u0026rsquo;t using CNFFuzz or FuzzSAT, but instead his own CNF generator for SHA-1 hash functions. Instances thus generated are not only structured, they are also very picky about the solution: they either have exactly one or zero. This helped fuzz solution reconstruction, which after blocked clause elimination may not be exactly easy. In fact, it\u0026rsquo;s so good at fuzzing that it finds a bug I have never been able to fix in CryptoMiniSat, to this day, about binary clauses. Whenever I block them, I cannot reconstruct the solution, ever, unless I disable equivalent literal replacement. The authors of the paper give a pretty complicated proof about why it should work in the presence of equivalent literal replacement, which I still haven\u0026rsquo;t understood.\nWhen I implemented disconnected component analysis into CryptoMiniSat 3, I knew I had to be careful. In the SAT Competition'11 I failed terribly with it: CryptoMiniSat 2 memory-outed and crashed on many instances with disconnected components. The solution I came up with was to make a program that could concatenate two or more problems into one problem, renumbering the variables. This meta-fuzzer (that used fuzzers as inputs) was then used to fuzz the disconnected component handling system. Although this sounds sufficient, it is in fact far from it. Firstly, the problems generated are disconnected at toplevel \u0026ndash; whereas problems in the real world sometimes disconnect later during the search. Secondly, it took 2, maybe 4 CNF inputs, but real problems sometimes have thousands of disconnected components. Both of these issues had to be addressed.\nOne of the most difficult parts of modern SAT solvers is time-outs of complicated algorithms. Time-outs sometimes make code quite convoluted, and thus are a source of bugs. However, most fuzzers generate problems that are too small for any time-outs to occur, thus severely limiting the scope of the fuzzer. So, the fuzzers don\u0026rsquo;t exercise a part of the system that is fully exercised by real-world problems. To fix this, I have written a short fuzzer script that generates enormous, but simple problems with millions of variables. This helped me fix a lot of issues in timeouts. I advise having a RAM-disk when using it though, as it writes gigabyte-size CNFs.\nI also use some other fuzzers, namely one that excercise XOR-manipulation and the sgen4 CNF generator by Ivor Spence (PDF, pages 85-86) that generates problems of tuneable hardness.\nMy fuzzing system Fuzz CNF generators are nice, but not enough on their own. A system around them is necessary for the full benefit. Writing one sounds trivial at first, but my system around the fuzzers is about 1000 lines of python code, so maybe it\u0026rsquo;s not that trivial after all. It has to do a number of things to be truly useful.\nFirst, it needs to test the solutions given by the solver. If the solution is SAT, it needs to read the (gzipped) CNF file, and check the (partial) solution. Second, if the solution is UNSAT, it either needs to call the DRUP checker to verify the proof, and/or it needs to call another solver to see if it finds a solution or not \u0026ndash; and verify that the other solver\u0026rsquo;s solution is correct. I actually run both DRUP and the other solver, you can never be sure enough. Note that solution verification also complicates time-limiting: we don\u0026rsquo;t want to wait 30 minutes because a fuzz CNF is too complicated, and we don\u0026rsquo;t want to indicate an error just because the problem is hard.\nSecondly, fuzzing is not only about generating CNFs that trigger bugs, but also about saving these problematic cases for later, as a form of regression tests. These regression tests need to be ran regularly, so that bugs that came up before don\u0026rsquo;t come up again. I have a large set of regression tests that I have accumulated over the years. These help me increase confidence that when I improve the solver, I don\u0026rsquo;t accidentally re-introduce bugs. My fuzzer system helps manage and run these regression tests.\nFinally, we don\u0026rsquo;t just want to fuzz the solver through the CNF interface. SAT solvers typically expose a library interface where one can add clauses, solve (with assumptions) and check the conflict returned in terms of the assumptions given. For now, CryptoMiniSat\u0026rsquo;s library is fuzzed through a specialized CNF format, where \u0026ldquo;c Solver::solve()\u0026rdquo; lines are interspersed with the regular clauses. These lines indicate for the solver to call the solve() method and output the solution to a file. This file is then read by the fuzzing system and verified by copying parts of the file into another CNF and using the DRUP-checker and another SAT solver to verify the results. This simulates library usage without assumptions. Thanks to Lukas Prokop who alerted me to bugs in assumptions usage, assumptions-based solving is also simulated through \u0026ldquo;c Solver::solve( LIT LIT LIT\u0026hellip;)\u0026rdquo; calls, where LITs are replaced with a random literals.\nFuture work I want to do two things related to testing and fuzzing. First, I want to improve the checker so that it checks for more problems. I want to check the conflict returned when assumptions are used. Further, I want to check timeouts \u0026ndash; this will require some coordination between the fuzzer system and the solver where times are printed that are later checked for correctness. Some optimisations must never take more than N seconds on a fast enough machine, and this could be checked relatively easily.\nSecond, I want to move CryptoMiniSat into a test-driven system. This will require some quite extensive code re-writing so that test-harnesses will be easier to write. However, it will help fix one issue that hasn\u0026rsquo;t been talked about, kind of like the elephant in the room: performance bugs. They are quite prevalent, and cannot be caught by simple fuzzing. They plague many SAT solvers, I\u0026rsquo;m sure, as I keep on finding them at every corner. They are the silent bugs that prevent solvers to be more performant, yet they don\u0026rsquo;t diminish the resulting solution \u0026ndash; only the time takes to find it.\n","permalink":"https://www.msoos.org/2013/08/my-sat-solver-fuzzing-setup/","summary":"\u003cp\u003eSince the SAT solver \u003ca href=\"https://en.wikipedia.org/wiki/Fuzz_testing\"\u003efuzzing\u003c/a\u003e \u003ca href=\"http://fmv.jku.at/papers/BrummayerLonsingBiere-SAT10.pdf\"\u003epaper\u003c/a\u003e by Brummayer, Lonsing and Biere, SAT solver fuzzing has been quite the thing in the SAT community. Many bugs have since been discovered in almost all SAT solvers, including those of this author. In this blog post I will detail my SAT fuzzing setup: what fuzzers I use and how I use them.\u003c/p\u003e\n\u003ch3 id=\"my-fuzzers\"\u003eMy fuzzers\u003c/h3\u003e\n\u003cp\u003eThe most obvious fuzzers to use are those present in the paper and accompanying \u003ca href=\"http://fmv.jku.at/fuzzddtools/\"\u003ewebsite\u003c/a\u003e: CNFFuzz and FuzzSAT. These fuzzers randomly genereate high-quality structured problem instances. The emphasis here is on the word structured. Randomly generated instances, as the authors of the original paper note, do not excercise SAT solvers enough. SAT solvers are written with very specific problem types in mind: problems containing long chains of binary clauses, gates, etc.\u003c/p\u003e","title":"My SAT solver fuzzing setup"},{"content":"I\u0026rsquo;ve had a number of inquiries about why CryptoMiniSat 3.3 doesn\u0026rsquo;t have native XOR clause support. Let me explain what I think the benefits and the drawbacks are of having native XOR support and why I made the choice of removing them.\nBenefits The most trivial benefit is that users don\u0026rsquo;t have to translate XORs into plain CNF. Although transforming is rather easy, some prefer not to go through the hassle. The principle is to cut the XOR into smaller XORs by introducing new variables and then representing the cut-down XORs by banning all the wrong combinations. For example the the XOR x+y+z+w=0x+y+z+w=0x+y+z+w=0 is cut into two XORs x+y+r=0x+y+r=0x+y+r=0, z+w+r=0z+w+r=0z+w+r=0 and then x+y+r=0x+y+r=0x+y+r=0 is represented as x∨y∨r,x∨¬y∨¬r,…x \\vee y \\vee r, x \\vee \\neg y \\vee \\neg r, \\ldotsx∨y∨r,x∨¬y∨¬r,….\nA more substantial benefit is that propagation and conflict generation can be done natively. This is quite advantageous as it means that far less clauses and variables need to be visited while propagating and generating the UIP conflict. Less variables and clauses visited means less cache-misses and due to the more compact representation, less memory overhead and thus even better cache usage. (For the aficionados: an interesting side-effect of XORs is that blocked literals cannot be used for XOR clauses).\nThe biggest benefit of having native XORs is that Gaussian elimination can be carried out at every level of the search tree, not just at top-level. Although most people I have talked with still think that CryptoMiniSat 2 only performs Gaussian elimination only at top-level, this is not the case. Performing Gauss at top-level is a two-day hack. Performing it at every level took me about half a year to implement (and about 5K lines of code). It requires leaving traces of past computations and computing reasons for propagations and conflicts indicated by the Gaussian elimination algorithm. According to my highly unofficial count, exactly 2 people use Gaussian elimination at deeper than top-level, Vegard Nossum and Kuldeep S Meel. Out of these two users, only the latter have indicated speedups. It speeds up crypto problems, but not many others, so it\u0026rsquo;s completely disabled by default.\nDrawbacks The main drawback of having native XOR clauses along normal CNF clauses is the loss of simplicity and universality. Let me explain in detail.\nLoss of simplicity. Once a variable present in both a normal and an XOR clause, it cannot be eliminated in a simple way. I don\u0026rsquo;t even want to try to express the clauses that would result from doing varelim in such cases \u0026ndash; it\u0026rsquo;s probably horribly convoluted. All algorithms in the code now need to check for XORs. On-the-fly clause strengthening cannot strengthen an XOR with a normal clause, of course. Clause cleaning has to take into account that when a 3-long XOR is shortened to a 2-long one, it indicates a new equivalent literal and that may lead to immediate UNSAT. I could go on, but the list is long.\nAnother problem is that XORs make the state more complex. Until now there were only clauses of the form a∨¬b…a \\vee \\neg b \\ldotsa∨¬b…, sometimes specially stored such as binary clauses. The state of the solver goes through many transformations \u0026ndash; think of them as llvm passes -- while it is in-processed and solved. The more complex the state, the larger and the more complex the code. While a simple clause-cleaning algorithm can be expressed in about 20 lines of code without implicit binary\u0026amp;tertiary clauses, the same algo blows up to about 100 lines of code with those optimizations. Once you add XOR clauses, it jumps to around double that. We just made our code 10x larger. Imagine adding native support for, e.g. at-most-n.\nLoss of universality. If a variable is only XOR clauses, it can now be eliminated at the XOR level. A pure variable at the XOR level indicates an XOR clause that can be removed and later always satisfied. XOR subsumption is when an XOR subsumes the other: the larger can be removed and their XOR added in. All of these are implemented in CMS 2. Probably there are many others out there, though. We could try to implement them all, but this is a whole new universe that may open up the gates of hell. Worst of all, most of these techniques on XORs are probably already simulated by in-processing techniques at the CNF level. Pure XOR variables are simulated by blocked clause elimination. XOR-based variable elimination doesn\u0026rsquo;t make practical sense at the CNF level, but it could be simulated by normal variable elimination if ignoring heuristics. I could go on.\nWhat CryptoMiniSat 3.3 does The compromise I came up with for CryptoMiniSat 3.0 is that I regularly search for XOR clauses at the top-level, perform top-level Gaussian elimination, and add the resulting new information to the CNF. Binary and unitary XOR clauses are the simplest to add back.\nIn the SAT'11 application benchmark set, out of 300 problems, 256 problems contain XOR clauses. the number of XOR clauses found, when they are found, is on average 2905 with an average size of 4.2 literals. Using Gaussian elimination, counting only when something was extracted, the average number of literal equivalences (binary XORs) extracted is 130, while the number of unitary clauses extracted is 0.15.\nHere is a typical example output:\nc Reading file \u0026#39;valves-gates-1-k617-unsat.shuffled-as.sat03-412.cnf.gz\u0026#39; c -- header says num vars: 985042 c -- header says num clauses: 3113540 [.. after about 124K conflicts ..] c XOR finding Num XORs: 104091 avg size: 3.0 T: 2.11 c Cut XORs into 2185 block(s) sum vars: 180818 T: 0.11 c Extracted XOR info. Units: 0 Bins: 1275 0-depth-assigns: 0 T: 8.34 Here, about 104K XOR clauses were found (using a sophisticated algorithm) within 2.11s, all of size 3. These XOR clauses were subjected to disconnected component analysis (within the XOR sphere) and they were found to belong to 2185 components. It is important to cut XORs into groups, because Gaussian elimination is an O(n≈2.5)O(n^{\\approx 2.5})O(n≈2.5) algorithm and if we can reduce the n by having more than one matrix, the speed is significantly increased. Next, these 2185 matrices were Gauss-eliminated and were found to contain 1275 binary XOR clauses, which were quickly marked as equivalent literals.\nTo perform Gaussian elimination at top-level, CryptoMiniSat uses the excellent m4ri library, maintained by my old college and friend Martin Albrecht. It\u0026rsquo;s a lightweight yet extremely fast Gaussian elimination system using all sorts of nifty tricks to do its job. Unfortunately, for large matrices it can still take a long while as the algorithm itself is not cheap, so I have a cut-off for matrices that are too large.\nWhat a future CryptoMiniSat 3.x could do Once we have extracted the XORs, we could just as well keep them around during search and perform Gaussian elimination at levels below the top-level. This would bring us close to the old system in terms of real performance \u0026mdash; native propagation (which would be unavailable) can only give a 1.5x-2x speedup, but Gaussian elimination at every level can give much more. I would need to clean up a lot of code and then, maybe, this would work. Maybe I\u0026rsquo;ll do this one day. Though, after spending weeks doing it, probably people will still believe it only does top-level. At least right now, it\u0026rsquo;s the case.\nConclusions Implementing a new theory such as XOR deep into the guts of a SAT solver is neither easy nor does it provide a clear advantage in most situations. Those who push for these native theories have either not tried implementing them into a complicated solver such as lingeling/ SatELite/CryptoMiniSat/ clasp or have already bit the bullet such as the clasp group and I did, and it is probably limiting them in extending the system with new techniques. The resulting larger internal state leads to edge cases, exceptions, and much-much more code.\n","permalink":"https://www.msoos.org/2013/08/why-cryptominisat-3-3-doesnt-have-xors/","summary":"\u003cp\u003eI\u0026rsquo;ve had a number of inquiries about why CryptoMiniSat 3.3 doesn\u0026rsquo;t have native \u003ca href=\"/xor-clauses/\"\u003eXOR clause\u003c/a\u003e support. Let me explain what I think the benefits and the drawbacks are of having native XOR support and why I made the choice of removing them.\u003c/p\u003e\n\u003ch3 id=\"benefits\"\u003eBenefits\u003c/h3\u003e\n\u003cp\u003eThe most trivial benefit is that users don\u0026rsquo;t have to translate XORs into plain CNF. Although transforming is rather easy, some prefer not to go through the hassle. The principle is to cut the XOR into smaller XORs by introducing new variables and then representing the cut-down XORs by banning all the wrong combinations. For example the the XOR \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ex\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003ey\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003ez\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003ew\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ex+y+z+w=0\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ex\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.7778em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ey\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.044em;\"\u003ez\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0269em;\"\u003ew\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e is cut into two XORs \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ex\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003ey\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003er\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ex+y+r=0\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ex\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.7778em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ey\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0278em;\"\u003er\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e, \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ez\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003ew\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003er\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ez+w+r=0\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.044em;\"\u003ez\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0269em;\"\u003ew\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0278em;\"\u003er\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e and then \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ex\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003ey\u003c/mi\u003e\u003cmo\u003e+\u003c/mo\u003e\u003cmi\u003er\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ex+y+r=0\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ex\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.7778em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ey\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e+\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0278em;\"\u003er\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e is represented as \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ex\u003c/mi\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ey\u003c/mi\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003er\u003c/mi\u003e\u003cmo separator=\"true\"\u003e,\u003c/mo\u003e\u003cmi\u003ex\u003c/mi\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi mathvariant=\"normal\"\u003e¬\u003c/mi\u003e\u003cmi\u003ey\u003c/mi\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi mathvariant=\"normal\"\u003e¬\u003c/mi\u003e\u003cmi\u003er\u003c/mi\u003e\u003cmo separator=\"true\"\u003e,\u003c/mo\u003e\u003cmo\u003e…\u003c/mo\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ex \\vee y \\vee r, x \\vee \\neg y \\vee \\neg r, \\ldots\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.5556em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ex\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.75em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ey\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.75em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0278em;\"\u003er\u003c/span\u003e\u003cspan class=\"mpunct\"\u003e,\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.1667em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ex\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.75em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e¬\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ey\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.625em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e¬\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0278em;\"\u003er\u003c/span\u003e\u003cspan class=\"mpunct\"\u003e,\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.1667em;\"\u003e\u003c/span\u003e\u003cspan class=\"minner\"\u003e…\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e.\u003c/p\u003e","title":"Why CryptoMiniSat 3.3 doesn't have XORs"},{"content":"In CryptoMiniSat 3.2 and above there is a disconnected component finding\u0026amp;solving system. This finds toplevel disconnected components regularly and solves them by launching an instance of the solver itself. If the component is unsatisfiable (UNSAT), the whole system is UNSAT and solving can be immediately aborted. If the component is satisfiable (SAT) the component\u0026rsquo;s solution is saved and later when printing the solution to the whole problem the component\u0026rsquo;s satisfying assignment is also printed.\nWhy deal with disconnected components? Disconnected components in SAT instances are problematic because the search logic of the solver doesn\u0026rsquo;t effectively restrict its search to a single component at a time, making its strategy ineffective. Firstly, learnt clause cleaning and variable activity heuristics behave worse. Secondly, solutions to components are thrown away when the search restarts when another component\u0026rsquo;s solution is too difficult to find. Note that some solvers, e.g. Marijn Heule\u0026rsquo;s march, do restrict their search to one component at a time, though I personally don\u0026rsquo;t know of any other.\nDisconnected components seem to be quite prevalent. In the SAT'11 competition\u0026rsquo;s set of 300 Application instances, 53 contained disconnected components at top-level at the beginning of the search. On average the number of disconnected components for these 53 instances were 393(!). When doing top-level analysis on a regular basis during search, the number of problems containing disconnected components rises to 58 and the average number of components found decreases to 294.\nFinding disconnected components The algorithm I use to find disconnected components is relatively easy. It essentially performs the following: it initializes a set of datastructures that hold information about the found component(s) and then feeds each clause one-by-one to a function that creates new component(s) and/or merges existing components. The datastructures needed are:\nArray \u0026lsquo;varToComp\u0026rsquo; that indicates which variable is in which component. If a variable is in no component yet, it has special value MAX A map of arrays \u0026lsquo;compToVar\u0026rsquo; indexed by the component. For example, compToVar[10] points to the array of variables in component number 10 Variable \u0026rsquo;nextComp\u0026rsquo;, an ever-incrementing index indicating the maximum component number used Variable \u0026lsquo;realComps\u0026rsquo; indicating the actual number of components \u0026ndash; some components counted by \u0026rsquo;nextComp\u0026rsquo; may have been merged, and are now empty The algorithm, in pseudo-python is:\nnextComp = 0; realComps = 0; varToComp = [MAXVAR] * numVars(); compToVar = {}; for clause in clauses: handleClause(clause); def handleClause(clause) : newComp = [] compsToMerge = set(); for lit in clause: var = lit.var(); if varToComp[var] != MAX : comp = varToComp[var]; compsToMerge.insert(comp); else: newComp.append(var); #no components to merge, just put all of them into one component if len(compsToMerge) == 1 : comp = compsToMerge.pop(); for var in newComp: varToComp[var] = comp compsToVar[comp].append(var); return; #delete components to merge and put their variables into newComp for comp in compsToMerge: vars = compToVar[comp]; for var in vars: newComp.append(var); compToVar.erase(comp); realComps--; #mark all variables in newComp belonging to \u0026#39;nextComp\u0026#39; for var in newComp: varToComp[var] = nextComp; compToVar[nextComp] = newComp; nextComp++; realComps++; There are ways to make this algorithm faster. A trivial one is to remove the \u0026lsquo;set()\u0026rsquo; and use an array initialized to 0 and mark components already seen. A fixed-sized array of the size of variables will do the job. Similarly, the use of \u0026rsquo;nextComp\u0026rsquo; forces us to use a map for \u0026lsquo;compToVar\u0026rsquo; which is slow \u0026ndash; a smarter algorithm will use a round-robin system with an array of arrays. We can also avoid having too many small components at the beginning by calling the handleClause() function with the longer clauses first. It doesn\u0026rsquo;t give any guarantees, but in practice works quite well.\nFinally, we need to add approximate time measurements so that we could exit early in case the algorithm takes too much time. According to my measurements, on the SAT'11 Application instances it took only 0.186s on average to find all components, and in only 34 cases out of 1186 did it take longer than the timeout \u0026ndash; which was set to around 7s. At the same time, the maximum time ever spent on finding components was 7.8s. In other words, it is almost free to execute the algorithm.\nHandling disconnected components CryptoMiniSat handles found components in the following way. First, it counts the number of components found. If there is only one component it simply continues solving it. If there are more than one, it orders them according to the number of variables inside and picks the smallest one, solves it with a sub-solver, and checks it solution. If it\u0026rsquo;s UNSAT, it exits with UNSAT, otherwise it saves the solution for later and picks the next smallest component until there is only one left. When there is only one left, it continues its job with this, largest, component.\nThe sub-solver CryptoMiniSat launches is a bit special. First of all, it renumbers the variables so if variables 100..120 are in a component, the sub-solver will be launched with variables 0..20. This saves memory in the sub-solver but it means variables must be back-numbered when extracting solutions. Since the subsolvers themselves also internally re-number variables for further speedup, this can get a little bit complicated.\nFurther, if the sub-solver is handling an extremely small problem (\u0026lt;50 vars) most of its internal functionality is turned off to reduce build-up and tear-down speed. This is important, because in case there are 5000 components we need to go through, even a 0.01s build-up\u0026amp;tear-down time is unacceptable. Finding 5000 components, by the way, is not some wild imaginary number: it happens with the instance transport-[\u0026hellip;]10packages-2008seed.040 from SAT'11. This instance actually contains ~5500 components at beginning of the search at toplevel, with an average of 8 variables each.\nDemo Let\u0026rsquo;s see an example output from CryptoMiniSat:\nc Reading file \u0026#39;traffic_3b_unknown.cnf.gz\u0026#39; [..] c -- clauses added: [..] 533919 irredundant c -- vars added 39151 [..] c Found components: 23 BP: 8.85M time: 0.06 s c large component 0 size: 833 c large component 1 size: 1071 c large component 2 size: 4879 c large component 4 size: 357 c large component 5 size: 14994 c large component 6 size: 476 c large component 7 size: 952 c large component 9 size: 952 c large component 10 size: 595 c large component 11 size: 10234 c large component 16 size: 476 c large component 17 size: 476 c large component 19 size: 476 c Not printed total small (\u0026lt;300 vars) components:10 vars: 2380 In total 23 components were found, the largest component containing 15K variables. The other 22 components contain 10K to as little as less-than 300 variables. Notice that finding the components was essentially free at 0.06s (on a i7-3612QM).\nAnother typical output is:\nc Reading file \u0026#39;transport-transport-city-sequential-25nodes-1000size-3degree-100mindistance-3trucks-10packages-2008seed.060-SAT.cnf.gz\u0026#39; [...] c -- clauses added [..] 3869060 irredundant c -- vars added 723130 [...] c Found component(s): 2779 BP: 253.02M time: 0.58 s c large component 2778 size: 657548 c Not printed total small (\u0026lt;300 vars) components:2778 vars: 25002 c Coming back to original instance, solved 2778 component(s), 25002 vars T: 1.46 In this case there were 2.8K small disconnected components with (on average) 9 variables each within a problem that originally contained 723K variables and 3.9M clauses. The components were found in 0.58s and all but the largest were solved within 1.46s. This means that 2.8K CryptoMiniSat sub-solvers were launched, initialized, ran and destroyed within a span of 1.46s. The largest component with 658K variables is what\u0026rsquo;s left to the solver to deal with. The rest have been removed and their solutions saved.\nConculsions It\u0026rsquo;s fun, useful, and relatively easy to find disconnected components in SAT problems. They appear at the beginning of the search for some problems, and for some more, during search. Although it is not a game-changer, it is a small drop of water in a cup that gets mostly filled with small drops anyway.\nPeople doing problem modeling for a living are probably crying in horror and blame the modeler who created an instance with thousands of disconnected components. As someone who deals with CNFs though, I don\u0026rsquo;t have the liberty of blaming anyone for their instances and have to deal with what comes my way.\n","permalink":"https://www.msoos.org/2013/07/handling-disconnected-components/","summary":"\u003cp\u003eIn CryptoMiniSat 3.2 and above there is a disconnected component finding\u0026amp;solving system. This finds toplevel disconnected components regularly and solves them by launching an instance of the solver itself. If the component is unsatisfiable (UNSAT), the whole system is UNSAT and solving can be immediately aborted. If the component is satisfiable (SAT) the component\u0026rsquo;s solution is saved and later when printing the solution to the whole problem the component\u0026rsquo;s satisfying assignment is also printed.\u003c/p\u003e","title":"Handling disconnected components"},{"content":"Is CryptoMiniSat just MiniSat with some hacks? No. MiniSat\u0026rsquo;s \u0026ldquo;core\u0026rdquo; version, from which CryptoMiniSat was originally developed, contained about 1,500 lines of code. CryptoMiniSat today contains over 55,000 lines of code.\nIs CryptoMiniSat only good to solve cryptographic instances? No. Naturally, it was one of the program\u0026rsquo;s aims, but it also performs well on other instances. XORs, one of the major features of CryptoMiniSat, also come up in model counting, sampling, and software verification, for example. It is the SAT solver used by our approximate model counter ApproxMC and our almost-uniform sampler UniGen, and our fast sampler CMSGen is built on it.\nIs CryptoMiniSat open source? Yes. It is MIT licensed, in other words, you are free to use CryptoMiniSat as you like, including changing it, redistributing it, selling it, etc.\nWhat\u0026rsquo;s the new thing in CryptoMiniSat compared to other solvers? Treating XORs natively, with Gauss-Jordan elimination, is an important idea, but there are many others which also contribute in a major way to the speed of solving. The original ideas are described in our SAT 2009 paper, Extending SAT Solvers to Cryptographic Problems, and the Gauss-Jordan elimination in Enhanced Gaussian Elimination in DPLL-based SAT Solvers (Pragmatics of SAT 2010) and Tinted, Detached, and Lazy CNF-XOR Solving and Its Applications to Counting and Sampling (CAV 2020). For the historical record, this 2-page description of CryptoMiniSat 2.5.1 lists the ideas it used in 2010. I also write about the ideas used on my blog.\nIs CryptoMiniSat using Gaussian elimination by default? Yes. Gauss-Jordan elimination is always compiled in and is on by default. It works on the XORs that CryptoMiniSat recovers from the CNF or that you give it directly, and it turns itself off when it is not helping (--autodisablegauss). The size of the matrices it handles can be limited with --maxmatrixrows and --maxmatrixcols.\nDo I have to use the XOR notation to fully utilise CryptoMiniSat? Not necessarily. XORs are automatically recovered from the CNF (--xor, on by default), so you can simply feed your already generated CNFs, and CryptoMiniSat will recover the XORs and treat them natively. However, only XORs over at most 12 variables are recovered: 12 is both the default and the maximum of --maxxorsize. An XOR over n variables is encoded by 2^(n-1) clauses, and XORs over more than 5 variables are only recognised when all of their clauses are present at full length. Longer XORs are not recovered, so either cut them into shorter XORs using helper variables, or give them to CryptoMiniSat directly in the XOR notation: a line x1 2 3 0 means that variable 1 XOR variable 2 XOR variable 3 must be true, and negating a literal flips this.\nHow can I get CryptoMiniSat? Can I contribute? The source code is on GitHub, and release binaries are on the releases page. You can also get it via Nix (nix shell github:msoos/cryptominisat), and the Python package via pip3 install pycryptosat. Changes are not only welcome, but also encouraged: file a bug report or create a pull request.\nHow do I use CryptoMiniSat as a library, or from Python? CryptoMiniSat has C++ and Python interfaces, with C and Rust wrappers as well. They are incremental: they support assumptions and multiple solve calls. See the README for examples.\nHow do I get all solutions to my problem? On the command line, --maxsol N gives you up to N solutions. From the library, call solve in a loop, and after each solution, add a clause that bans it; the README has an example. If there are too many solutions to list, count them with ApproxMC or Ganak instead.\nCan CryptoMiniSat produce proofs? Yes. CryptoMiniSat emits XLRUP proofs, for example cryptominisat5 input.cnf proof.xlrup, that can be checked by the formally verified checker cake_xlrup from frat-xor. With --xlrup 2, the proof is written in a smaller, faster binary encoding.\nCan I use CryptoMiniSat as a preprocessor? For that, try our model counting preprocessor, Arjun.\nWhy are there so many options for the solver? Which ones should I use? It is very difficult to know which optimisations bring what benefits. The options are there such that the individual optimisations can be tested one-by-one, eliminating spurious optimisations. The default options should be OK.\nWhat should I do if CryptoMiniSat couldn\u0026rsquo;t solve my problem in a reasonable amount of time? Please try other solvers, such as CaDiCaL or Kissat. However, most likely, you need to re-formulate your problem. In case your problem is really interesting, you can drop me an email and I might be interested in trying to solve it.\n","permalink":"https://www.msoos.org/tools/cryptominisat/faq/","summary":"\u003ch3 id=\"is-cryptominisat-just-minisat-with-some-hacks\"\u003eIs CryptoMiniSat just MiniSat with some hacks?\u003c/h3\u003e\n\u003cp\u003eNo. MiniSat\u0026rsquo;s \u0026ldquo;core\u0026rdquo; version, from which CryptoMiniSat was originally developed, contained about 1,500 lines of code. CryptoMiniSat today contains over 55,000 lines of code.\u003c/p\u003e\n\u003ch3 id=\"is-cryptominisat-only-good-to-solve-cryptographic-instances\"\u003eIs CryptoMiniSat only good to solve cryptographic instances?\u003c/h3\u003e\n\u003cp\u003eNo. Naturally, it was one of the program\u0026rsquo;s aims, but it also performs well on other instances. XORs, one of the major features of CryptoMiniSat, also come up in model counting, sampling, and software verification, for example. It is the SAT solver used by our approximate model counter \u003ca href=\"/tools/approxmc/\"\u003eApproxMC\u003c/a\u003e and our almost-uniform sampler \u003ca href=\"/tools/unigen/\"\u003eUniGen\u003c/a\u003e, and our fast sampler \u003ca href=\"/tools/cmsgen/\"\u003eCMSGen\u003c/a\u003e is built on it.\u003c/p\u003e","title":"CryptoMiniSat FAQ"},{"content":"This is just a short note that CryptoMiniSat 3.3 has been released. This is mainly a bugfix release. I have managed to make a fuzzer that simulates library usage of the system by interspersing the CNF with \u0026ldquo;c Solver::solve()\u0026rdquo; calls and then checking the intermediate solutions. Checking is either performed by verifying that all clauses are satisfied, or if the solution is UNSAT, by using a standard SAT solver (I use lingeling). This turned up a surprising number of bugs. I have also fixed the web-based statistics printing which should now work without a hitch.\nThe non-bugfix part of the release is that CryptoMiniSat now saves memory by dynamically shortening and reallocating the watchlist pointer array and some other data structures. This can save quite a bit of memory on large, sparse instances.\n","permalink":"https://www.msoos.org/2013/07/cryptominisat-3-3-released/","summary":"\u003cp\u003eThis is just a short note that CryptoMiniSat 3.3 has been \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\"\u003ereleased\u003c/a\u003e. This is mainly a bugfix release. I have managed to make a fuzzer that simulates library usage of the system by interspersing the CNF with \u0026ldquo;c Solver::solve()\u0026rdquo; calls and then checking the intermediate solutions. Checking is either performed by verifying that all clauses are satisfied, or if the solution is UNSAT, by using a standard SAT solver (I use \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e). This turned up a surprising number of bugs. I have also fixed the web-based statistics printing which should now work without a hitch.\u003c/p\u003e","title":"CryptoMiniSat 3.3 released"},{"content":"Note: the work below has been done in collaboration with Vegard Nossum, but the wording and some of the (mis-)conculsions are mine. If you are interested, check out his master thesis, it\u0026rsquo;s quite incredible\nAnyone who has ever tried to really understand clause glues in SAT solvers have probably wondered what they really mean. Their definition is simple: the number of variables in the final conflict clause that come from different decision levels. An explanation of these terms can be found here. On the surface, this sounds very simple and clean: the number of different decision levels should somehow be connected to the number of variables that need to be set before the learnt clause activates itself, i.e. it causes a propagation or a conflict. Unfortunately, this is just the surface, because if you try to draw 2-3 implication graphs, you will see that in fact the gap between the number of variables needed to be set (let\u0026rsquo;s call this \u0026lsquo;activation number\u0026rsquo;) and the glue can be virtually anything, making the glue a potentially bad indicator of the activation number.\nThe original reasoning The original reasoning behind glues is the following: variables in the same decision level, called \u0026lsquo;blocks of variables\u0026rsquo; have a chance to be linked together through direct dependencies, and these dependencies should be expressed somehow in order to reduce the number of decisions needed to reach a conflict (and thus ultimately reduce the search space). To me, this reasoning is less clear than the one above. In fact, there are about as many intuitions about glues as the number of people I have met.\nGlucosetrack With Vegard Nossum we have developed (in exactly one day) something quite fun. On the face of it, it\u0026rsquo;s just glucose 1.0, plain and simple. However, it has an option, \u0026ldquo;-track\u0026rdquo;, which does the following: whenever a learnt clause is about to cause a conflict, it jumps over this learnt clause, saves the state of the solver, and works on until the next conflict in order to measure the amount of work the SAT solver would have had to do if that particular learnt clause had not been there. Then, when the next clause wishes to cause a conflict, it records the amount of propagation and decisions between the original conflict and this new conflict, resets the state to the place saved, and continues on its journey as if nothing had happened. The fun part here is that the state is completely reset, meaning that the solver behaves exactly as glucose, but at the same time it records how much search that particular cause has saved. This is very advantageous because it doesn\u0026rsquo;t give some magical number like glue, but actually measures the usefulness of the given clause. Here is a typical output:\nc This is glucose 1.0 with usefulness tracking by c Vegard Nossum and Mate Soos. Based on glucose, which c is in run based on MiniSat, Many thanks to all teams c c ============================[ Problem Statistics ]============================= c | | c | Number of variables: 138309 | c | Number of clauses: 942285 | c | Parsing time: 0.28 s | ============================[ Search Statistics ]============================== | Conflicts | ORIGINAL | LEARNT | Progress | | | Vars Clauses Literals | Limit Clauses Lit/Cl | | =============================================================================== | 0 | 138309 942285 2636352 | 314095 0 -nan | 0.000 % | | 620 | 138074 942285 2636352 | 314095 615 82 | 1.559 % | | 919 | 135307 925938 2596895 | 314095 906 75 | 3.908 % | | 2714 | 130594 894562 2518954 | 314095 2664 67 | 6.799 % | | 2814 | 130593 894562 2518954 | 314095 2763 69 | 6.808 % | | 2930 | 130592 894562 2518954 | 314095 2879 70 | 6.808 % | | 4042 | 127772 874934 2471045 | 314095 3974 69 | 9.292 % | | 4142 | 127772 874934 2471045 | 314095 4074 70 | 9.292 % | ... c Cleaning clauses (clean number 0). Current Clause usefulness stats: INSERT INTO data(cleanno, idx, size, glue, conflicts, props, bogoprops, decisions) VALUES(0 , 961074 , 107 , 5 , 42 , 185509 , 1301341 , 0); INSERT INTO data(cleanno, idx, size, glue, conflicts, props, bogoprops, decisions) VALUES(0 , 944729 , 14 , 1 , 7 , 36865 , 268229 , 0); INSERT INTO data(cleanno, idx, size, glue, conflicts, props, bogoprops, decisions) VALUES(0 , 948275 , 7 , 1 , 15 , 27909 , 220837 , 0); INSERT INTO data(cleanno, idx, size, glue, conflicts, props, bogoprops, decisions) VALUES(0 , 953762 , 102 , 2 , 2 , 29365 , 197410 , 0); ... c End of this round of database cleaning ... | 38778 | 110896 758105 2182915 | 314095 28270 93 | 20.167 % | | 39488 | 110894 758105 2182915 | 314095 28978 93 | 20.185 % | c Cleaning clauses (clean number 1). Current Clause usefulness stats: INSERT INTO data(cleanno, idx, size, glue, conflicts, props, bogoprops, decisions) VALUES(1 , 979236 , 71 , 1 , 8 , 45531 , 280156 , 0); INSERT INTO data(cleanno, idx, size, glue, conflicts, props, bogoprops, decisions) VALUES(1 , 954908 , 2 , 2 , 7 , 0 , 232760 , 0); ... The output is in SQL format for easy SQL import. The \u0026ldquo;size\u0026rdquo; is the clause size, \u0026ldquo;glue\u0026rdquo; is the glue number, \u0026ldquo;conflicts\u0026rdquo; is the number of times the clause caused a conflict, \u0026ldquo;props\u0026rdquo; is the number of propagations gained by having that clause (i.e. by doing the conflict early), \u0026ldquo;bogoprops\u0026rdquo; is an approximation of the amount of time gained based on the number of watchlists and the type of clauses visited during propagation, and \u0026ldquo;decisions\u0026rdquo; is the number of decisions gained. The list is sorted according to \u0026ldquo;bogoprops\u0026rdquo;, though once the output is imported to MySQL, many sortings are possible. You might notice that the \u0026lsquo;glue\u0026rsquo; is 1 for some clauses (e.g. on the second output line) \u0026ndash; these are clauses that have caused a propagation at decision level 0, so they will eventually be removed through clause-cleaning, since they are satisfied. Notice that high up, there are some relatively large clauses (of size 102 for example) with glue 2, that gain quite a lot in terms of time of search. The gained conflicts/propagations/etc. are all cleared after every clause-cleaning, though since clauses are uniquely indexed (\u0026lsquo;idx\u0026rsquo;), they can be accumulated in all sorts of ways.\nThe program is 2-5x slower than normal glucose, but considering that it has to save an extreme amount of state due to the watchlists being so difficult to handle and clauses changing all the time, I think it does the job quite well \u0026ndash; as a research tool it\u0026rsquo;s certainly quite usable. In case you wish to download it, it\u0026rsquo;s up in GIT here, and you can download a source tarball here. To build, issue \u0026ldquo;cmake .\u0026rdquo; and \u0026ldquo;make\u0026rdquo;. Note that the tool only measures the amount of search saved by having the clause around when it tries to conflict. It does not measure the usefulness of the propagations that a learnt clause makes. Also, it doesn\u0026rsquo;t measure the other side of the coin: the (potentially better) conflict generated by using this clause instead of the other one. In other words, it gives a one-sided view (no measure of help through propagation) of a one-sided view (doesn\u0026rsquo;t measure the quality of difference between the conflict clauses generated). Oh well, it was a one-day hack.\nExperiments I have made very few experiments with glucosetrack, but you might be interested in the following result. I have taken UTI-20-10p0, ran it until completion, imported the output into MySQL, and executed the following two queries. The first one:\nSELECT glue, AVG(props), FROM data WHERE glue \u0026gt;= 2 AND size \u0026gt;= 2 GROUP BY glue ORDER BY glue calculates the average number of saved propagations between each round of cleaning for clauses of glue \u0026gt;= 2 (i.e. clauses that didn\u0026rsquo;t eventually cause a propagation at decision level 0), and of size \u0026gt;= 2, because unitary clauses are of no interest. The second is very similar:\nSELECT size, AVG(props), FROM data WHERE glue \u0026gt;= 2 AND size \u0026gt;= 2 GROUP BY size ORDER BY size which calculates the same as above, but for size.\nSome explanation is in order here regarding why I didn\u0026rsquo;t count SUM(), and instead opted for AVG(). In fact I personally did make graphs for SUM(), but Vegard corrected me: there is in fact no point in doing that. If I came up with a new glue calculation function that gave an output of \u0026lsquo;1\u0026rsquo; for every clause, then the SUM for that function would look perfect: every clause would be in the same bracket, saving a lot of propagations, but that would not help me make a choice of which clauses to throw out. But the point of glues is exactly that: to help me decide which clauses to throw out. So what we really want is a usefulness metric that tells me that if I keep clauses in that bracket, how much do I gain per clause. The AVG() gives me that.\nHere goes the AVG() graph for the last clause cleaning (clause cleaning iteration 33): Notice that the y axis is in logscale. In case you are interested in a larger graph, here it is. The graph for clause cleaning iteration 22 is:\n(Iteration 11 has high fluctuations due to less data, but for the interested, here it is). I think it\u0026rsquo;s visible that glues are good distinguishers. The graph for glues drops down early and stays low. For sizes, the graph is harder to read. Strangely, short clauses are not that good, and longer clauses are better on average. If I had to make a choice about which clauses to keep based on the size graph, it would be a hard choice to make: I would be having trouble selecting a group that is clearly better than the rest. There are no odd-one-out groups. On the other hand, it\u0026rsquo;s easier to characterise which clauses are good to have in terms of glues: take the low glue ones, preferably below 10, though we can skip the very low ones if we are really picky. An interesting side-effect of the inverse inclination of the size and glue graphs and the fact that \u0026ldquo;glue\u0026lt;=size\u0026rdquo; is that maybe we could choose better clauses to keep if we go for larger clauses that have a low glue.\nConclusions Unfortunately, there are no real conclusions to this post. I guess running glucosetrack for far more than just one example, and somehow also making it measure the difference between the final conflict clauses\u0026rsquo; effectiveness would help to write some partially useful conclusion. Vegard and me have tried to put some time and effort into this, but to not much avail I am afraid.\nPS: Notice that glucosetrack allows you to generate many of the graphs here using the right SQL query.\n","permalink":"https://www.msoos.org/2013/07/clause-glues-are-a-mystery-to-me/","summary":"\u003cp\u003e\u003cem\u003eNote: the work below has been done in collaboration with \u003ca href=\"http://folk.uio.no/vegardno/\"\u003eVegard Nossum\u003c/a\u003e, but the wording and some of the (mis-)conculsions are mine. If you are interested, check out his \u003ca href=\"https://www.duo.uio.no/handle/10852/34912\"\u003emaster thesis\u003c/a\u003e, it\u0026rsquo;s quite incredible\u003c/em\u003e\u003c/p\u003e\n\u003cp\u003eAnyone who has ever tried to \u003cem\u003ereally\u003c/em\u003e understand clause \u003ca href=\"http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.150.1911\u0026amp;rep=rep1\u0026amp;type=pdf\"\u003eglues\u003c/a\u003e in SAT solvers have probably wondered what they really mean. Their definition is simple: the number of variables in the final conflict clause that come from different decision levels. An explanation of these terms can be found \u003ca href=\"/understanding-implication-graphs\"\u003ehere\u003c/a\u003e. On the surface, this sounds very simple and clean: the number of different decision levels should somehow be connected to the number of variables that need to be set before the learnt clause activates itself, i.e. it causes a propagation or a conflict. Unfortunately, this is just the surface, because if you try to draw 2-3 implication graphs, you will see that in fact the gap between the number of variables needed to be set (let\u0026rsquo;s call this \u0026lsquo;activation number\u0026rsquo;) and the glue can be virtually \u003cem\u003eanything\u003c/em\u003e, making the glue a potentially bad indicator of the activation number.\u003c/p\u003e","title":"Clause glues are a mystery to me"},{"content":"CyptoMinSat 3.2.0 has been released. This code should be extremely stable and should contain no bugs. In case it does, CryptoMiniSat will fail quite bady at the competition. I have fuzzed the solver for about 2-3000 CPU hours, with some sophisticated fuzzers (all available here --- most of them not mine) so all should be fine, but fingers are crossed.\nAdditions and fixes The main addition this time is certification proofs for UNSAT through the use of DRUP. This allows for use of the solver where certainty of the UNSAT result is a necessity \u0026mdash; e.g. where lives could potentially depend on it. Unfortunately, proof checking is relatively slow through any system, though DRUP seems to be the best and fastest method. Other than the implementation of DRUP, I have fixed some issues with variable replacement.\nSAT Competition'13 The description of the solver sent in to the SAT Competition'13 is available from the subfolder \u0026ldquo;desc\u0026rdquo; of the tarball. The code of 3.2.0 is actually the same that will run during the competition, the only changes made were:\nthe DRUP output had to be put into the standard output the line \u0026ldquo;o proof DRUP\u0026rdquo; had to be printed certified UNSAT binary uses the \u0026ldquo;\u0026ndash;unsat 1\u0026rdquo; option by default compilation was changed to use the m4ri library that was included with the tarball linking is static so m4ri and other requirements don\u0026rsquo;t cause trouble boost minimum version had to be lowered You can download my submissions to the competition, forl, from here and here.\n","permalink":"https://www.msoos.org/2013/04/cryptominisat-3-2-0-released/","summary":"\u003cp\u003eCyptoMinSat 3.2.0 has been \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\"\u003ereleased\u003c/a\u003e. This code should be extremely stable and should contain no bugs. In case it does, CryptoMiniSat will fail quite bady at the \u003ca href=\"http://www.satcompetition.org/2013/\"\u003ecompetition\u003c/a\u003e. I have fuzzed the solver for about 2-3000 CPU hours, with some sophisticated fuzzers (all available \u003ca href=\"https://github.com/msoos/cnf-utils\"\u003ehere\u003c/a\u003e --- most of them not mine) so all should be fine, but fingers are crossed.\u003c/p\u003e\n\u003ch3 id=\"additions-and-fixes\"\u003eAdditions and fixes\u003c/h3\u003e\n\u003cp\u003eThe main addition this time is \u003ca href=\"/2013/04/certified-unsat-and-cryptominisat/\"\u003ecertification proofs\u003c/a\u003e for UNSAT through the use of \u003ca href=\"http://www.cs.utexas.edu/~marijn/drup/\"\u003eDRUP\u003c/a\u003e. This allows for use of the solver where certainty of the UNSAT result is a necessity \u0026mdash; e.g. where lives could potentially depend on it. Unfortunately, proof checking is relatively slow through any system, though DRUP seems to be the best and fastest method. Other than the implementation of DRUP, I have fixed some issues with variable replacement.\u003c/p\u003e","title":"CryptoMiniSat 3.2.0 released"},{"content":"(Note update below)\nJust a short note. All MiniSat-derived SAT solvers might give wrong results during the competition. No, MiniSat doesn\u0026rsquo;t have a bug. GCC has a giant bug. Vegard reported this years ago \u0026ndash; I personally put about 12h tracking it down, posted it to the CryptoMiniSat mailing list, and Vegard took it up, stripped it down and reported it.\nThis is a well-known bug, there is a thread about it on the MiniSat mailing list and I personally asked the competition organizers back in 2011 not to use the 4.5.2(or .3?) they wanted to use. I used to have code to check for this bug (there is a handy check attached to the bug report), but I removed it, though maybe I should add it back. It\u0026rsquo;s fixed in 4.5.4+, still present in 4.5.3 where Vegard\u0026amp;me found it. I hope I will be able to convince the organisers this time around, too :) By the way, the option you need to pass to gcc to avoid the bug is \u0026ldquo;-fno-tree-pre\u0026rdquo; \u0026mdash; though of course this turns off an optimisation and so slows down the final executable.\nUpdate: The organisers decided to move to gcc 4.8.0. This is very good news. They also note that the speed of the solvers is better, which is also very good news. I am happy I contributed to this welcome improvement and I hope it doesn\u0026rsquo;t cause any delays or inconveniences to anyone.\n","permalink":"https://www.msoos.org/2013/04/gcc-4-5-2-at-sat-competition-201/","summary":"\u003cp\u003e(Note \u003cem\u003eupdate\u003c/em\u003e below)\u003c/p\u003e\n\u003cp\u003eJust a short note. All MiniSat-derived SAT solvers might give wrong results during the competition. No, MiniSat doesn\u0026rsquo;t have a bug. GCC has a giant \u003ca href=\"http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47365\"\u003ebug\u003c/a\u003e. Vegard reported this years ago \u0026ndash; I personally put about 12h tracking it down, \u003ca href=\"http://lists.gforge.inria.fr/pipermail/cryptominisat-devel/2011-January/000052.html\"\u003eposted it\u003c/a\u003e to the CryptoMiniSat mailing list, and \u003ca href=\"http://folk.uio.no/vegardno/\"\u003eVegard\u003c/a\u003e took it up, stripped it down and reported it.\u003c/p\u003e\n\u003cp\u003eThis is a well-known bug, there is a thread about it on the \u003ca href=\"https://groups.google.com/forum/?fromgroups=#!topic/minisat/YHEWCFqxyFg\"\u003eMiniSat mailing list\u003c/a\u003e and I personally asked the competition organizers back in 2011 not to use the 4.5.2(or .3?) they wanted to use. I used to have code to check for this bug (there is a handy check attached to the bug report), but I removed it, though maybe I should add it back. It\u0026rsquo;s fixed in 4.5.4+, still present in 4.5.3 where Vegard\u0026amp;me found it. I hope I will be able to convince the organisers this time around, too :) By the way, the option you need to pass to gcc to avoid the bug is \u0026ldquo;-fno-tree-pre\u0026rdquo; \u0026mdash; though of course this turns off an optimisation and so slows down the final executable.\u003c/p\u003e","title":"GCC 4.5.2 at the SAT Competition'13"},{"content":"Marijn Heule kindly sent me an email on the 10th of April about DRUP, the new system used this year in the SAT Competition'13 for the UNSAT track. He kindly encouraged me to implement the DRUP system. He personally implemented it into Minisat which was a very helpful lead for me. In this post I will talk about my experiences in implementing DRUP into CryptoMiniSat within a span of 3 days.\nImplementation complexity It took only 3 days, about 1400 lines of code to implement DRUP:\ngit diff f27c74bbd c0b6ccc10 --shortstat 25 files changed, 1372 insertions(+), 307 deletions(-) It turns out that the biggest problem is that whenever I shorten a clause, I first have to add the shortened version, and then delete the old one. Since I always do in-place literal deletion, this means I have to save the old clause into a temporary place, add the new one and finally delete the old one that has been saved. I will eventually write a C++ wrapper that does this for me, but currently, it\u0026rsquo;s a lot of\nvector origCl(cl.size()); std::copy(cl.begin(), cl.end(), origCl.begin()); [blah...] drup \u0026lt;\u0026lt; cl \u0026lt;\u0026lt; \u0026#34; 0\u0026#34; \u0026lt;\u0026lt; endl; drup \u0026lt;\u0026lt; \u0026#34;d \u0026#34; \u0026lt;\u0026lt; origCl \u0026lt;\u0026lt; \u0026#34; 0\u0026#34; \u0026lt;\u0026lt; endl; So, it\u0026rsquo;s a bit messy code. Other than this, the implementation went very smoothly. The biggest pain was not to forget to add to the DRUP output all changed clauses. Since I have implicit binary and tertiary clauses and I manipulate them in-place, they are changed in quite complicated code paths.\nIf you don\u0026rsquo;t have such complicated code paths, you should be able to implement DRUP within a day or less. I encourage you to do so, it\u0026rsquo;s quite fun!\nRemaining uncertainties I am a bit confused about whether some of the optimisations in CryptoMiniSat work with DRUP. I have been fuzzing the DRUP implementation for about ~1000 CPU hours, but not with all optimisations turned on. Some are a bit shaky. In particular, XOR and stamping\u0026amp;caching come to mind.\nI cannot turn DRUP on for the top-level XOR manipulation because otherwise I would need to tell DRUP every Gaussian elimination step. Not funny, and not fast. Well, XOR is not such a big thing, and it is no longer natively implemented in CryptoMiniSat, so not a big deal, really.\nThe other, more troubling one is stamping and implied literal caching. Luckily I have on-the-fly hyper-binary resolution (this is needed for DRUP with Stalmarck if you think about it), so the binary clauses stored by caching and stamping are there\u0026hellip; but they may get deleted by variable elimination, blocked clause elimination and\u0026hellip; well, maybe nothing else. Hopefully not. Anyway, I never block binary clauses (does clause blocking ever help? I am confused) and I can of course not delete binary eliminated clauses from DRUP. However\u0026hellip; that may make the verification very slow. So, I am at crossroads here. I think I will submit a version with stamping\u0026amp;caching and one without.\nIn the end, every optimisation can be turned on except for XOR. I find that exceptionally good given the number of tweaks/hacks used by CryptoMiniSat.\nLong-term advatages of having DRUP I think DRUP allows for a lot of possibilities. Naturally I first want to draw resolution graphs. There are plenty of libraries for 3D drawing, and I have already ordered the LEAP controller (a 3D controller), which will come handy to play with the resolution graphs (zoom\u0026amp;out, rotate, etc.).\nFrom there, I want to get stats out of the graph, and I want to present it next to/with the stats that I already generate. For example, how many of the deleted clauses get re-learnt later? How many clauses get used in the resolution graph with the empty node? How often when cleaning with glues? How often when cleaning with activities? For which types of instances?\nLinking this with real-world instances by coloring the graph points according to e.g. filter functions in stream ciphers is not very hard and should be quite a lot of fun.\nAcknowledgements I think Marijn Heule deserves a lot of thanks for the work he has put into DRUP (webpage, example, DIFF for MiniSat) and all the help he has given me. I had some initial doubts about whether it\u0026rsquo;s possible to implement at all and I had some minor problems with the checker \u0026mdash; he always replied kindly and promptly. Thanks!\n","permalink":"https://www.msoos.org/2013/04/certified-unsat-and-cryptominisat/","summary":"\u003cp\u003e\u003ca href=\"http://www.cs.utexas.edu/~marijn/\"\u003eMarijn Heule\u003c/a\u003e kindly sent me an email on the 10th of April about \u003ca href=\"http://www.cs.utexas.edu/~marijn/drup/\"\u003eDRUP\u003c/a\u003e, the new system used this year in the \u003ca href=\"http://satcompetition.org/2013/\"\u003eSAT Competition'13\u003c/a\u003e for the UNSAT track. He kindly encouraged me to implement the DRUP system. He personally implemented it into Minisat which was a \u003cem\u003every\u003c/em\u003e helpful lead for me. In this post I will talk about my experiences in implementing DRUP into CryptoMiniSat within a span of 3 days.\u003c/p\u003e\n\u003ch3 id=\"implementation-complexity\"\u003eImplementation complexity\u003c/h3\u003e\n\u003cp\u003eIt took only 3 days, about 1400 lines of code to implement DRUP:\u003c/p\u003e","title":"Certified UNSAT and CryptoMiniSat"},{"content":"Lately, I have been thinking about how to improve variable elimination. It\u0026rsquo;s one of the most important things in SAT solvers, and it\u0026rsquo;s not exactly easy to do right.\nVariable elimination Variable elimination simply resolves every occurrence of a literal v1v1v1 with every occurrence of the literal ¬v1\\neg v1¬v1 , removes the original clauses and adds the resolvents. For example, let\u0026rsquo;s take the clauses\nv1∨v2∨v3v1 \\vee v2 \\vee v3v1∨v2∨v3 v1∨v4∨v5v1 \\vee v4 \\vee v5v1∨v4∨v5 ¬v1∨v10∨v11\\neg v1 \\vee v10 \\vee v11¬v1∨v10∨v11 ¬v1∨v12∨v13\\neg v1 \\vee v12 \\vee v13¬v1∨v12∨v13\nWhen v1v1v1 gets eliminated the resolvents become\nv2∨v3∨v10∨v11v2 \\vee v3 \\vee v10 \\vee v11v2∨v3∨v10∨v11 v2∨v3∨v12∨v13v2 \\vee v3 \\vee v12 \\vee v13v2∨v3∨v12∨v13 v4∨v5∨v10∨v11v4 \\vee v5 \\vee v10 \\vee v11v4∨v5∨v10∨v11 v4∨v5∨v12∨v13v4 \\vee v5 \\vee v12 \\vee v13v4∨v5∨v12∨v13\nThe fun comes when the resolvents are tautological. This happens in this case for example:\nv1∨v4v1 \\vee v4v1∨v4 ¬v1∨v5∨¬v4\\neg v1 \\vee v5\\vee \\neg v4¬v1∨v5∨¬v4\nThe resolvent is the clause\nv4∨¬v4∨v5v4 \\vee \\neg v4 \\vee v5v4∨¬v4∨v5\nWhich contains both a literal and its negation and is therefore always true. It\u0026rsquo;s good to find variables we can eliminate without and side-effects, i.e. variables that eliminate without leaving any resolvents behind. However, it\u0026rsquo;s not so cheap to find these. Until now.\nA fast procedure for calculating the no. of non-tautological resolvents The method I came up with is the following. For every clause where v1v1v1 is inside, I go through every literal and in an array the size of all possible literals, I set a bit. For every clause, I set a different bit. When going through every clause of every literal where ¬v1\\neg v1¬v1 is present, I calculate the hamming weight (a popcount(), a native ASM instruction on modern CPUs) of the array\u0026rsquo;s inverse literals and substruct this hamming weight from the number of clauses v1v1v1 was inside. I sum up all these and then the final count will be the number of non-tautological resolvents. Here is a pseudo-code:\nmybit = 1 num = 0 for clause in clauses[v1]: for l in clause: myarray[l] |= mybit mybit = mybit \u0026lt;\u0026lt; 1 num += 1 count = 0 for clause in clauses[not v1]: tmp = 0 for l in clause: tmp |= myarray[not l] count += num - popcount(tmp) print \u0026#34;number of non-tautological resolvents: %d\u0026#34; % count I think this is pretty neat. Notice that this is linear in the number of literals in the clauses where v1v1v1 and ¬v1\\neg v1¬v1 is present. The only limitation of this approach is that \u0026lsquo;myarray\u0026rsquo; has to have enough bits in its elements to hold \u0026rsquo;num\u0026rsquo; number of bits. This is of course non-trivial and can be expensive in terms of memory (and cache-misses) but I still find this approach rather fun.\nUsing this procedure, I can check whether all resolvents are tautological, and if so, remove all the clauses and not calculate anything at all. Since this happens very often, I save a lot of calculation.\n","permalink":"https://www.msoos.org/2013/04/a-variable-elimination-improvement/","summary":"\u003cp\u003eLately, I have been thinking about how to improve \u003ca href=\"http://link.springer.com/chapter/10.1007%2F11499107_5\"\u003evariable elimination\u003c/a\u003e. It\u0026rsquo;s one of the most important things in SAT solvers, and it\u0026rsquo;s not exactly easy to do right.\u003c/p\u003e\n\u003ch3 id=\"variable-elimination\"\u003eVariable elimination\u003c/h3\u003e\n\u003cp\u003eVariable elimination simply resolves every occurrence of a literal \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e1\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ev1\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e1\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e with every occurrence of the literal \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi mathvariant=\"normal\"\u003e¬\u003c/mi\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e1\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003e\\neg v1\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e¬\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e1\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e , removes the original clauses and adds the resolvents. For example, let\u0026rsquo;s take the clauses\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e1\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e2\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e3\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ev1 \\vee v2 \\vee v3\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e1\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e2\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e3\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e1\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e4\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e5\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ev1 \\vee v4 \\vee v5\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e1\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e4\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e5\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi mathvariant=\"normal\"\u003e¬\u003c/mi\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e1\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e10\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e11\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003e\\neg v1 \\vee v10 \\vee v11\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e¬\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e1\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e10\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e11\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi mathvariant=\"normal\"\u003e¬\u003c/mi\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e1\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e12\u003c/mn\u003e\u003cmo\u003e∨\u003c/mo\u003e\u003cmi\u003ev\u003c/mi\u003e\u003cmn\u003e13\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003e\\neg v1 \\vee v12 \\vee v13\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e¬\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e1\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e12\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∨\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\" style=\"margin-right:0.0359em;\"\u003ev\u003c/span\u003e\u003cspan class=\"mord\"\u003e13\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e","title":"A variable elimination improvement"},{"content":"CryptoMinisat 3.1 has been released. The short changelog is:\n$ git diff cryptoms-3.0 cryptoms-3.1 --shortstat 84 files changed, 3079 insertions(+), 2751 deletions(-) The changes made were threefold. First, memory usage has been greatly reduced. This is crucial, because memory usage was over 7GB on certain instances. Secondly, the implication cache wasn\u0026rsquo;t very well-used and an idea that came to my mind greatly improved performance on most problems. Finally, time limiting of some inprocessing techniques on certain types of problems has been improved.\nMemory usage reduction On instances that produced a lot of long learnt clauses the memory usage was very high. These learnt clauses were all automatically linked in to the occurrence list and consequently took large amounts of memory, sometimes up to 10GB. On other instances, the original clauses were too numerous and too large, so putting even them into the occurrence list was too much. On these instances, variable elimination is not carried out (or carried out only later, when enough original clauses have been removed/shortened). To debug some of these problems, I wrote a fuzzer that generates extremely large problems with many binary and many long clauses, it\u0026rsquo;s available here as \u0026ldquo;largefuzzer\u0026rdquo;. It\u0026rsquo;s actually quite nice with many-many binary clauses so it also can fuzz the problems encountered with probing of extremely weird and large instances.\nImplied literal usage improvement CryptoMiniSat uses implied literals, i.e. caches what literals were propagated by each literal during probing. It then re-uses this information to subsume and/or strengthen clauses. This is kind of similar to stamping though uses more memory. It is actually useful to have alongside stamping, and I now do both \u0026ndash; propagating DFS that stamping requires is expensive though updating cache during DFS is just as easy as during quasi- BFS.\nThe trick I discovered while playing around with cached implied literals is that if literal L1 propagates L2 and also !L2 then that means there are conceptually two binary clauses in the solver (!L1, L2), (!L1, !L2), so !L1 is TRUE. This is of course trivial, but I never checked for this. The question most would raise is: why would L1 propagate both L2 and !L2 and not fail? The answer is kind of tricky, but very interesting. Let\u0026rsquo;s say at one point, L1 propagates L2 due to a learnt clause, but that learnt clause is then removed. A new learnt clause is then later learnt, and with that learnt clause in place, L1 propagates !L2. Now, without caching, this would be ignored. Caching memorizes past conceptual binary clauses and re-uses this information.\nThis is not an optimization that only looks good on paper, it is very good to have. With this one optimization, I gained 5 instances from the SAT Comp'09 instances with a 1000s timeout (196 solved -\u0026gt; 201 solved). I can\u0026rsquo;t right now imagine how this could be done with stamping effectively, but that doesn\u0026rsquo;t mean it\u0026rsquo;s not possible. Though, according to my experience, stamping doesn\u0026rsquo;t preserve that much information over time as it\u0026rsquo;s being updated (renumbered) frequently while the cache is only improved over time, never shrunk. A possibility would be to have more than one stamp system and round-robin selecting them. However that would mean that sorting of clauses (for shrinking) would need to be done more than once, and sorting them is already relatively expensive. I sometimes feel that what stamping gains in memory it looses on sorting (i.e. processing time) and lower coverage (re-numbering).\nMore precise time-limiting Martin Maurer has been kind enough to file a lot of bug reports about probing and variable elimination taking too much time, sometimes upwards of 150s when they should take around 20-30s maximum. While investigating, it tuned out that the problem was very weird indeed. While trying to eliminate or probe one variable the time for that one variable took upwards of 100s. This was completely unexpected as the code only checked for timeouts on a per-variable basis. In the end, the code had to be improved to track time on an intra-variable basis in both systems. While at it, I also added intra-variable time-tracking to implicit clause subsumption and strengthening too. So, over-times should less prevalent from now on. As an interesting side-note, time-limiting on probing is now so fine-grained that a 32-bit unsigned integer would overflow within 15s if used as the time-tracker.\n","permalink":"https://www.msoos.org/2013/04/cryptominisat-3-1-released/","summary":"\u003cp\u003eCryptoMinisat 3.1 has been \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\u0026amp;release_id=8008\"\u003ereleased\u003c/a\u003e. The short changelog is:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e$ git diff cryptoms-3.0 cryptoms-3.1 --shortstat\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e 84 files changed, 3079 insertions(+), 2751 deletions(-)\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eThe changes made were threefold. First, memory usage has been greatly reduced. This is crucial, because memory usage was over 7GB on certain instances. Secondly, the implication cache wasn\u0026rsquo;t very well-used and an idea that came to my mind \u003cem\u003egreatly\u003c/em\u003e improved performance on most problems. Finally, time limiting of some inprocessing techniques on certain types of problems has been improved.\u003c/p\u003e","title":"CryptoMinisat 3.1 released"},{"content":"CryptoMiniSat 3.0 has been released. I could talk about how it\u0026rsquo;s got a dynamic, web-based statistics interface, how it has more than 80 options, how it uses no glues for clause-cleaning and all the other goodies, but unfortunately these don\u0026rsquo;t much matter if the speed is not up to par. So, here is the result for the 2009 SAT Competition problems on a 1000s timeout with two competing solvers, lingeling and glucose:\nThis of course does not mean that CryptoMiniSat is faster than the other solvers in general. In fact it is slower on a number of instances. What it means is that in general it\u0026rsquo;s OK and that\u0026rsquo;s good enough for the moment. It would be awesome to run the above experiment (or a similar one) with a longer timeout. Unfortunately, I don\u0026rsquo;t have a cluster to do that. However, if you have access to one, and would be willing to help with running the 3 solvers on a larger timeout, please do, I will post the updated graph here.\nUpdate Norbert Manthey kindly ran all the above solvers on the TU Dresden cluster, thanks! He also kindly included one more solver, Riss 3g. The cluster was an AMD Bulldozer architecture with 2cores/solver with an extreme, 7200s timeout. The resulting graph is here:\nRiss 3g is winning this race, with CryptoMiniSat being second, third is glucose, and very intriguingly lingeling the 4th. Note that CryptoMiniSat leads the pack most of the time. Also note, this is the first time CryptoMiniSat 3.0 has been run for such a long time, while all the other competing solvers\u0026rsquo; authors (lingeling, glucose, riss) have clusters available for research purposes.\nLicensing For those wondering if they could use this as a base for SAT Competition 2013, the good news is that the licence is LGPL so you can do whatever you want with it, provided you publish the changes you made to the code. However, I would prefer that you compete with a name such as \u0026ldquo;cms-MYNAME\u0026rdquo; unless you change at least 10% of the code, i.e. ~2000 lines. For the competitions after 2013, though, it\u0026rsquo;s all up for grabs. As for companies, it\u0026rsquo;s LGPL, so you can link it with your code, it\u0026rsquo;s safe, you only have to publish what you change in the library, you don\u0026rsquo;t have to publish your own code that uses the library.\nFeatures CryptoMiniSat has been almost completely rewritten from scratch. It features among other things:\n4 different ways to propagate Implicit binary\u0026amp;tertiary clauses Cached implied literals Stamping Blocking of long clauses Extended XOR detection and top-level manipulation Gate detection and manipulation Subsumption, variable elimination, strengthening 4 different ways to clear clauses 4 different ways to restart Large amounts of statistics data, both into console and optionally to MySQL Web-based dynamic display of gathered statistics 3 different ways to calculate optimal variable elimination order On-the-fly variable elimination order update Super-fast binary\u0026amp;tertiary subsumption\u0026amp;strengthening thanks to implicit bin\u0026amp;tri On-the-fly hyper-binary resolution with precise time-control On-the-fly transitive reduction with precise time-control Randomised literal dominator braching Internal variable renumbering Vivification On-the-fly clause strengthening Cache\u0026amp;stamp-based learnt clause minimisation Dynamic strongly connected component check and equivalent literal replacement Code layout As for those wondering how large the code base is, it\u0026rsquo;s about 20KLOC of code, organised as:\n","permalink":"https://www.msoos.org/2013/04/cryptominisat-3-0-released/","summary":"\u003cp\u003eCryptoMiniSat 3.0 has been \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\"\u003ereleased\u003c/a\u003e. I could talk about how it\u0026rsquo;s got a dynamic, web-based statistics interface, how it has more than 80 options, how it uses no glues for clause-cleaning and all the other goodies, but unfortunately these don\u0026rsquo;t much matter if the speed is not up to par. So, here is the result for the \u003ca href=\"http://www.satcompetition.org/2009/\"\u003e2009 SAT Competition\u003c/a\u003e problems on a 1000s timeout with two competing solvers, \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e and \u003ca href=\"https://www.lri.fr/~simon/?page=glucose\"\u003eglucose\u003c/a\u003e:\u003c/p\u003e\n\u003cp\u003e\u003cimg alt=\"cryptoms_speed\" loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2013/04/lingeling-glucose-cryptoms.png\"\u003e\u003c/p\u003e\n\u003cp\u003eThis of course does not mean that CryptoMiniSat is faster than the other solvers in general. In fact it is slower on a number of instances. What it means is that in general it\u0026rsquo;s OK and that\u0026rsquo;s good enough for the moment. It would be awesome to run the above experiment (or a similar one) with a longer timeout. Unfortunately, I don\u0026rsquo;t have a cluster to do that. However, if you have access to one, and would be willing to help with running the 3 solvers on a larger timeout, please do, I will post the updated graph here.\u003c/p\u003e","title":"CryptoMiniSat 3.0 released"},{"content":"As many of you have heard, the SAT Competition for this year has been announced. You can send in your benchmarks between the 12th and the 22nd of April, so get started. I have a bunch of benchmarks I have already submitted about 2 years ago, still waiting for any reply from those organizers \u0026ndash; but the organizers are different this year, so fingers crossed.\nWhat I want to talk about today is benchmark randomization. This is a very-very touchy topic. However, I fear that it\u0026rsquo;s touchy for the wrong reasons, and so I think it\u0026rsquo;s important to talk about it in detail.\nWhat is benchmark randomization? Benchmark randomization is when a benchmark that is submitted is shuffled around a bit. There are many ways to shuffle a problem, and I will discuss this in a bit, but the point is that the problem at hand that is described by the benchmark CNF should not be changed, or changed only in a very-very minor way, such that everyone agrees that it doesn\u0026rsquo;t affect the core problem itself as described by the CNF.\nWhy do we need shuffling? We need shuffling because simply put, there aren\u0026rsquo;t enough good benchmarks and so the benchmarks of yesteryear (and the year before, and before, and\u0026hellip;) re-appear often. This would be OK if SAT solvers couldn\u0026rsquo;t be tuned to solving specific problems faster. Note that I am not suggesting that SAT solvers are intentionally manipulated to solve specific problems faster by unscrupulous researchers. Instead, the following happens.\nUnintentional random seed improvements Researchers test the performance of their SAT solvers on specific instances and then tune their solvers, testing the performance again and again on the same instances to check if they have improved performance. Logically this is the best way to test and improve performance: use the same well-defined test-set all the time for meaningful comparison. Since the researcher wants to use the instances that he/she thinks is the current use-case of SAT solvers, he naturally uses the instances of SAT competitions, since those are representative. I did and still do the same.\nSo, researchers add their idea to a SAT solver, and test. If the idea is not improving things then some change is made and tested again. Since modern CDCL SAT solvers behave quite randomly, and since any change in the source code changes the behaviour quite significantly, a small change in the source code (tuning of a parameter, for example) will change the behaviour. And since the set of problems tested on is fixed, there is a chance that more problems will be solved. If more are solved, the researcher might correctly interpret this as a general improvement, not specific to the problem set. However, it may very well be generic, it is also specific.\nThe above suggests that the randomness of the SAT solver is completely unintentionally tuned to specific problems \u0026ndash; a subset of which will appear next year in the competition.\nEasy fixes Since there aren\u0026rsquo;t enough benchmark problems, and in particular some benchmark types are rare, I suggest to fix the unintentional tuning of solvers to specific problems by changing the benchmarks in minor ways. Here is a list, with an explanation why I think it\u0026rsquo;s OK to perform the manipulation:\nPropagate variables. Unitary clauses are often part of benchmarks. Propagating some of these, some recursively, gives quite a bit of problem space variation. Propagation is performed by every CDCL SAT solver, and I think many would be surprised if it didn\u0026rsquo;t help SAT solvers that worked differently than current SAT solvers. Agreeing on performing partial propagation is something that shouldn\u0026rsquo;t be too difficult. Renumber variables. For some variable X that is not used (or is fixed to a value that has been propagated), every variable that is higher than X is decremented by one, and the CNF header is fixed to reflect this change. Such a minor renumbering may be approved by every researcher as something that doesn\u0026rsquo;t change the problem or its structure. Note that if partial propagation is performed there should be quite a number of variables that can be removed. Renumbering some, but not others is a way to shuffle the problem. A more radical way of renumbering variables would be to completely shuffle them, however that would change the way the problem is described in quite a radical way, so some would correctly object and it\u0026rsquo;s not necessary anyway. Replace equivalent literals. Perform strongly connected component analysis and replace equivalent literals. This has been shown to significantly improve performance and I have never seen a case where it doesn\u0026rsquo;t. Since equivalent literal replacement can be performed with a lot of freedom, this is quite a bit of shuffling space. For example, if v1=v2=v3, then any of the v1, v2, v3 can be the one that replaces the rest in the CNF. Picking one randomly is a way to shuffle the instance There are other ways of shuffling, but either they change the instance too much (e.g. blocked clause removal), or can be undone quite easily (e.g. shuffling the order of the clauses). In fact, (3) is already quite a touchy issue I think, but with (1) and (2) all could agree on. Neither requires the order of the literals or the order of the clauses to change \u0026ndash; some clauses (e.g. unitary ones) and literals (some of those that are set) would be removed, but that\u0026rsquo;s all. The problem remains essentially unchanged such that most probably even the original problem author would easily recognize it. However, it would be different from a SAT solver point of view: these changes would change the random seed of the solver, forcing the solver to behave in a way that is less tuned to this specific problem instance.\nConclusion SAT solvers are currently tuned too much to specific instances. This is not intentional by the researchers, however it still affects the results. To obtain better, less biased results we should shuffle the problem instances we have. Above, I suggested three ways to shuffle the instances in such a way that most would agree they don\u0026rsquo;t disturb or change the complexity of the underlying problem described by the instance. I hope that some of these suggestions will be employed, if not this year then for next year\u0026rsquo;s SAT competition such that we could reach better, more meaningful results.\n","permalink":"https://www.msoos.org/2013/03/on-benchmark-randomization/","summary":"\u003cp\u003eAs many of you have heard, the SAT Competition for this year has been \u003ca href=\"http://satcompetition.org/2013/\"\u003eannounced\u003c/a\u003e. You can send in your benchmarks between the 12th and the 22nd of April, so get started. I have a \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1476\u0026amp;release_id=5351\"\u003ebunch of benchmarks\u003c/a\u003e I have already submitted about 2 years ago, still waiting for any reply from those organizers \u0026ndash; but the organizers are different this year, so fingers crossed.\u003c/p\u003e\n\u003cp\u003eWhat I want to talk about today is benchmark randomization. This is a very-very touchy topic. However, I fear that it\u0026rsquo;s touchy for the wrong reasons, and so I think it\u0026rsquo;s important to talk about it in detail.\u003c/p\u003e","title":"On benchmark randomization"},{"content":"Lately, I have been putting a lot of effort into collecting data about solver behaviour and dumping it on-the-fly to a MySQL database. Some of this data is then presented by a PHP\u0026amp;javascript interface, such as this.The goal is to better understand how solving works, and thus to possibly come up with better strategies for solving. The requirements of the data gathered are: speed to calculate, size to store and usefulness.\nGathered data There are some obvious statistics that one would like to collect, such as number of conflicts, propagations and conflicts per second, etc \u0026ndash; these are all gathered by almost every SAT solver out there. However, it would be interesting to have more. Here is what CryptoMiniSat now gathers and dumps using highly efficient prepared bulk insert statements, using at most 5% of time.\nFor each variable, dumped once in a while:\nno. times propagated false, and true (separately) no. times decided false and true (sep.) no. times flipped polarity avg \u0026amp; variance of decision level avg \u0026amp; variance of propagation level For each clause larger than 3-long, dumped once in a while:\nactivity conflict at which it was introduced (if learnt) number of propagations made number of conflicts made number of times any of its literal was looked at during BCP number of times it was looked at (dereferenced) during BCP number of times used to resolve with during learnt clause generation number of resolutions needed to during its generation (if learnt clause) For earch restart:\nno. of reducible\u0026amp;irreducible (i.e. learnt\u0026amp;non-learnt) binary clauses no. of red\u0026amp;irred tertiary clauses (separately) no. of red\u0026amp;irred long clauses (sep) avg, variance, min and max of learnt clause glues avg, var, min, max of learnt clause sizes avg, var, min, max of number of resolutions for 1st UIP avg,var,min,max of branch depths avg,var,min,max of backjump length \u0026ndash;in the number of literals unassigned avg,var,min,max of backjump lenght \u0026ndash; in the number of levels backjumped avg, var, min, max times a conflict followed a conflict without decisions being made avg,var,min,max of agility no. of propagations by red\u0026amp;irred binary clauses no. of props by red\u0026amp;irred tertiary clauses no. of props by red\u0026amp;irred long clauses no. of conflicts by red\u0026amp;irred binary clauses (separately) no. of conflicts by red\u0026amp;irred tertiary clauses (sep) no. of conflicts by red\u0026amp;irred long clauses (sep) no. of learnt unit, binary, tertiary, and long clauses (sep) avg,var, min,max of watchlist size traversed during BCP time spent no. of decisions no. of propagations no. of variables flipped no. of variables set positive\u0026amp;negative (sep) no. of variables currently unset no. of variables currently replaced no. of variables currently eliminated no. of variables currently set For each learnt clause database cleaning:\nfor reducible clauses removed: all the data in the \u0026ldquo;clauses larger than 3-long\u0026rdquo; data above, summed up for reducible clauses not removed: all the data in the \u0026ldquo;clauses larger than 3-long\u0026rdquo; data above, summed up no. of clauses removed no. of clauses not removed for all irred clauses (these are not touched): all the data in the \u0026ldquo;clauses larger than 3-long\u0026rdquo; data above, summed up For every N conflicts:\nclause size distribution clause glue distribution clause size and glue scatter data This is all, and is not all mine. Suggestions were made by many, some as much as a year ago: George Katsirelos, Luca Melette, Vegard Nossum, Valentin-Mayer Eichberger, Ben Schlabs, Said Jabbour and Niklas Sörensson. Naturally, none of these people necessarily approve of how I gather data or what I do with the data gathered, but they helped, so listing them is only fair.\nWhat\u0026rsquo;s not yet or cannot be gathered Two suggestions are still on the TODO list:\ncounting the number of conflicts done while a learnt clause was \u0026ldquo;locked\u0026rdquo;, i.e. has propagated in the current search tree. This stat of a learnt clause could tell us if the clause seemed essential to the search or not. If a clause propagated once, at the bottom of the search tree, and then the variable propagated was quickly unset, it\u0026rsquo;s not the same as if the same clause propagated at the top of the search tree, and then the variable it set was essentially never unset. for each variable, counting the number of conflicts done while the variable was set. This is interesting, because if a variable was propagated only once, at top-level, it will seem like it was never set (set only once), yet it may have had a huge influence on the search tree and consequently on the learnt clauses. Both of these require a change in the algorithm used to backjump and although I am a bit worried about the performance, I will add these soon.\nUnfortunately, the data about variables can\u0026rsquo;t really be dumped so often, because it\u0026rsquo;s huge for large problems with millions of variables. So I guess I will only dump that for the most active N variables, for some sane definition of \u0026ldquo;active\u0026rdquo;. Similarly, the data about individual clauses is not dumped, only in a summed-up way during database cleaning.\nSuggestions? In case you have any ideas what else could be interesting to dump, please put it as a comment. The idea is to dump data that is cheap to compute and cheap to dump yet would be interesting for some reason or another. I am prepared to add stuff to datastructures, as you have probably guessed from the above. Yes, it makes the clause database less space-efficient, and so increases cache-miss. But on large problems, it\u0026rsquo;s going to be a cache-miss most of the time anyway, and a cache-fetch brings in 128B of data, which should be plenty for both the stats and the clause. Similarly with variables. So, don\u0026rsquo;t refrain from suggesting some stuff that takes space. Also, weird stuff is interesting. The most weird stat on the list above is definitely the \u0026ldquo;conflict after a conflict without decisions\u0026rdquo; (suggested by Said Jabbour) which I would have guessed to be zero, or near-zero, yet is pretty high, in the 30+% range.\nSuggestions are welcome!\n","permalink":"https://www.msoos.org/2012/11/collecting-solver-data/","summary":"\u003cp\u003eLately, I have been putting a lot of effort into collecting data about solver behaviour and dumping it on-the-fly to a MySQL database. Some of this data is then presented by a PHP\u0026amp;javascript interface, such as \u003ca href=\"/sat_visualization/\"\u003ethis\u003c/a\u003e.The goal is to better understand how solving works, and thus to possibly come up with better strategies for solving. The requirements of the data gathered are: speed to calculate, size to store and usefulness.\u003c/p\u003e","title":"Collecting solver data"},{"content":"In this post I would like to share with you a personal review of my new business line laptop from Dell, the Vostro 3560. It\u0026rsquo;s a 15.6\u0026quot; laptop that has Full HD screen using TN display technology, a 750GB HDD spinning at 7500rpm, 6GB of DDR3 RAM clocked at 1600MHz, with the highest possible Core i7 processor available for this machine, the i7-3612QM, that goes to 3.1GHz with all cores still active.\nOverview of the laptop\nThe good First, let me talk about what I found to be great about this laptop. The display is great: it\u0026rsquo;s sharp, the colors are good and it\u0026rsquo;s bright enough even in strong sunlight \u0026ndash; though admittedly here in Berlin there is not much of that.\nThe keyboard is also magnificent. It\u0026rsquo;s one of the best keyboards I have ever used, even though I am very particular about my peripherals, especially keyboards and mice. I used to own business Thinkpads and this is the first keyboard that I have found to be as good as or maybe even better than a Thinkpad keyboard.\nThe system is built sturdily, and the materials used don\u0026rsquo;t feel cheap in your hands. Though the system isn\u0026rsquo;t light, it feels easy to hold due to its rigidity and smooth (but not slippery) surfaces.\nFinally, the system contains extras that are only mentioned in the service manual. For example, there is an mSATA socket inside the laptop, meaning you can plug a 256GB mSATA SSD into the system in a couple of minutes for a reasonable price (around 200EUR), significantly speeding things up.\nThe mediocre The CPU is a trade-off. It\u0026rsquo;s not the i7-3610QM which would go up to 3.3GHz with all cores still active. The reason for this is interestingly not price: the two CPUs cost the same from intel \u0026ndash; the reason is heat removal. The CPU installed only generates 35W of heat while the other generates 45W. Essentially, Dell didn\u0026rsquo;t work hard enough on the cooling system and the result is that a better CPU cannot be installed. Unfortunately, Dell is not the only one that couldn\u0026rsquo;t install the 3610QM, other manufacturers such as Sony with the Vaio S series had the same issue. Naturally, Apple with the new MacBook Pro lineup didn\u0026rsquo;t mess this up.\nThe included charger is rather bulky. Interestingly, there is a slimmer charger available, for a mere 114 EUR \u0026ndash; the one included costs 50EUR on the same Dell webpage. I find this to be rather disappointing.\nBulky charger included\nSlim charger, available at 114EUR\nThe wireless card inside the system doesn\u0026rsquo;t support 5GHz WiFi. This sounds minor, until you go to a conference or a public place with a WiFi where everyone seems to be able to connect, except you. 2.4GHz WiFi uses a band that is substantially more noisy and since routers on that band cover more area, if many people are in the same place, connection can be very spotty. In comparison, my IBM X61t, released in 2007 (!) had 5GHz WiFi, so it\u0026rsquo;s hardly new technology. In fact, for about 30EUR you can change your WiFi card inside the case for one that supports Bluetooth+802.11abgn, i.e. all that is inside plus 5GHz WiFi. I still cannot understand why a computer that costs 900+ EUR would cheap out on such a component \u0026ndash; especially since Dell can get bulk discount, so the upgrade for them would be around 10 EUR at most.\nThe system comes with a DVD writer included, but I don\u0026rsquo;t have any use for that. Who uses DVDs nowadays? If I want to watch a movie, I use Blu-Ray \u0026ndash; after all, the display is Full HD! Having a Blu-Ray option would have been easy for the manufacturer, as the DVD player included is a standard one, so it can be easily swapped to an internal notebook Blu-Ray reader. Such readers cost around 60EUR at any online retailer. In fact, a Blu-Ray internal writer would cost no more than 80EUR. Dell missed out on this completely, for no good reason. Yes, it\u0026rsquo;s for business, but even business people need to back up their HDD and a DVD writer with a capacity of 4GB won\u0026rsquo;t be of any help.\nThe bad Build quality is terrible. This is very surprising at this price range and in this category (i.e. business). First off, the screen\u0026rsquo;s backplate fits so badly to the front that there are holes larger than 2mm on the right side, and almost none on the left:\nLeft side of panel\nRight side of panel\nThe same, though less accentuated, is true for the palmrest. You can clearly see that the plastic fits differently on the two sides, and in fact fits unevenly on both:\nLeft side of front\nRight side of bottom\nSimilarly, the bottom sticker of the laptop with the most important piece of information, the Service Tag, is of such a low quality that after only 2 months of use the numbers got completely erased, and only the barcode (blacked out for privacy) remains readable:\nMy Service Tag \u0026ndash; other than the barcode (blacked out) it\u0026rsquo;s unreadable\nFinally, Linux support is terrible. I wanted to get reimbursed for the Windows 7 licence, but they refused it, which I think is clearly illegal, but of course I don\u0026rsquo;t have months to waste and money to burn to get some 50-100 EUR back. In the same spirit, there is no proper support for controlling the fan under Linux, as the highest level of the fan cannot be attained with the linux driver, and there is no proper palm detection support for the touchpad. The AMD Linux driver available at the time of purchase crashed X11 at startup, but the new one (fglrx 8.980) is flawless, and I have to commend AMD the on that.\nConclusions The Vostro 3560 is a nice piece of machine but it\u0026rsquo;s not quite business quality and its makers prefer not to hear the word Linux uttered. However, if you are ready to shell out some money on a Blu-Ray drive, don\u0026rsquo;t intend to use Linux and are content with mediocre build quality with holes between elements the size an edge of a penny, the Vostro 3560 is a good choice. Otherwise, maybe hold out for a better offer.\n[paypal-donation]\n","permalink":"https://www.msoos.org/2012/08/my-dell-vostro-3560-review/","summary":"\u003cp\u003eIn this post I would like to share with you a personal review of my new business line laptop from Dell, the Vostro 3560. It\u0026rsquo;s a 15.6\u0026quot; laptop that has Full HD screen using \u003ca href=\"http://en.wikipedia.org/wiki/TFT_LCD#Twisted_nematic_.28TN.29\"\u003eTN display\u003c/a\u003e technology, a 750GB HDD spinning at 7500rpm, 6GB of DDR3 RAM clocked at 1600MHz, with the highest possible Core i7 processor available for this machine, the \u003ca href=\"http://ark.intel.com/products/64901\"\u003ei7-3612QM\u003c/a\u003e, that goes to 3.1GHz with all cores still active.\u003c/p\u003e","title":"My Dell Vostro 3560 review"},{"content":"There have been some questions asked about how to use CryptoMiniSat as a library. Here, I give a simple example usage to help any future potential users. If there are any question that seems unanswered, please feel free to add them as a comment to this post.\nFirst, we initialize the solver with high verbosity:\n#include \u0026#34;cmsat/Solver.h\u0026#34; using namespace CMSat; SolverConf conf; conf.verbosity = 2; Solver solver(conf); Then we add the variables 0..9:\nfor(int i = 0; i \u0026lt; 10; i++) { solver.newVar(); } And add a clause that would look in the DIMACS input format as \u0026ldquo;2 -5 10 0\u0026rdquo;:\nvec clause; clause.push(Lit(1, false)); clause.push(Lit(4, true)); clause.push(Lit(9, false)); solver.addClause(clause); We now create the assumptions that would look in DIMACS input format as \u0026ldquo;1 0\u0026rdquo; and \u0026ldquo;-5 0\u0026rdquo;:\nvec assumps; assumps.push(Lit(0, false)); assumps.push(Lit(4, true)); We now solve with these assumptions:\nlbool ret = solver.solve(assumps); Let\u0026rsquo;s see if the state of the solver after solving is UNSAT regardless of the assumptions:\nif (!solver.okay()) { printf(\u0026#34;UNSAT!\\n\u0026#34;); exit(0); } Note that okay() can only be FALSE if \u0026ldquo;ret\u0026rdquo; was \u0026ldquo;l_False\u0026rdquo;. However, it is important to distinguish between two kinds of l_False: one where only the assumptions couldn\u0026rsquo;t be satisfied, and one where no matter what the assumptions are, the problem is unsatisfiable. See below for more.\nNow let\u0026rsquo;s check that the solution is UNSAT relative to the assumptions we have given. In this case, let\u0026rsquo;s print the conflicting clause:\nif (ret == l_False) { printf(\u0026#34;Conflict clause expressed in terms of the assumptions:\\n\u0026#34;); for(unsigned i = 0; i != solver.conflict.size(); i++) { printf(\u0026#34;%s%d \u0026#34;, (solver.conflict[i].sign()) ? \u0026#34;\u0026#34; : \u0026#34;-\u0026#34;, solver.conflict[i].var()+1); } printf(\u0026#34;0\\n\u0026#34;); } The above will print an empty clause if solver.okay() is FALSE.\nNow, let\u0026rsquo;s see if the solution is SAT, and if so, print the solution to console, using DIMACS notation:\nif (ret == l_True) { printf(\u0026#34;We have the solution, it\u0026#39;s here: \\n\u0026#34;); for (unsigned var = 0; var != solve.nVars(); var++) if (S.model[var] != l_Undef) { printf(\u0026#34;%s%d \u0026#34;, (solver.model[var] == l_True)? \u0026#34;\u0026#34; : \u0026#34;-\u0026#34;, var+1); printf(\u0026#34;0\\n\u0026#34;); } } If solver.okay() is still TRUE (which it must be, if the ret was l_True), we can now add new clauses and new variables without restriction, and solve again (potentially with different assumptions). Note that most of the above applies to MiniSat as well.\nWhen compiling the code, you have to pass the parameters such as:\n$ g++ -fopenmp -lcryptominisat myprogram.cpp -o myprogram PS: Thanks go to Martin Albrecht for pointing out some ambiguities in my explanation of the library usage, which have now been fixed.\n","permalink":"https://www.msoos.org/2012/06/how-to-use-cryptominisat-2-9-as-a-library/","summary":"\u003cp\u003eThere have been some questions asked about how to use CryptoMiniSat as a library. Here, I give a simple example usage to help any future potential users. If there are any question that seems unanswered, please feel free to add them as a comment to this post.\u003c/p\u003e\n\u003cp\u003eFirst, we initialize the solver with high verbosity:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-c++\" data-lang=\"c++\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#75715e\"\u003e#include\u003c/span\u003e \u003cspan style=\"color:#75715e\"\u003e\u0026#34;cmsat/Solver.h\u0026#34;\u003c/span\u003e\u003cspan style=\"color:#75715e\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eusing\u003c/span\u003e \u003cspan style=\"color:#66d9ef\"\u003enamespace\u003c/span\u003e CMSat;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eSolverConf conf;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003econf.verbosity \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eSolver \u003cspan style=\"color:#a6e22e\"\u003esolver\u003c/span\u003e(conf);\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eThen we add the variables 0..9:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003efor(int i = 0; i \u0026lt; 10; i++) {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  solver.newVar();\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e}\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eAnd add a clause that would look in the \u003ca href=\"http://people.sc.fsu.edu/%7Ejburkardt/data/cnf/cnf.html\"\u003eDIMACS\u003c/a\u003e input format as \u0026ldquo;2 -5 10 0\u0026rdquo;:\u003c/p\u003e","title":"How to use CryptoMiniSat 2.9 as a library"},{"content":" Visualizing the solving of mizh-md5-47-3.cnf\nVisualizing what happens during SAT solving has been a long-term goal of mine, and finally, I have managed to pull together something that I feel confident about. The system is fully explained in the liked i mage on the right, including how to read the graphs and why I made them. Here, I would like to talk about the challenges I had to overcome to create the system.\nGathering information Gathering information during solving is challenging for two reasons. First, it\u0026rsquo;s hard to know what to gather. Second, gathering the information should not affect overall speed of the solver (or only minimally), so the code to gather the information has to be well-written. To top it all, if much information is gathered, these have to be structured in a sane way, so it\u0026rsquo;s easy to access later.\nIt took me about 1-1.5 months to write the code to gather all information I wanted. It took a lot of time to correctly structure and to decide about how to store/summarize the information gathered. There is much more gathered than shown on the webpage, but more about that below.\nSelecting what to display, and how This may sound trivial. Some would simply say: just display all information! But what we really want is not just plain information: what good is it to print 100'000 numbers on a screen? The data has to be displayed in a meaningful and visually understandable way.\nGetting to the current layout took a lot of time and many-many discussions with all all my friends and colleagues. I am eternally grateful for their input \u0026ndash; it\u0026rsquo;s hard to know how good a layout is until someone sees it for the first time, and completely misunderstands it. Then you know you have to change it: until then, it was trivial to you what the graph meant, after all, you made it!\nWhat to display is a bit more complex. There is a lot of data gathered, but what is interesting? Naturally, I couldn\u0026rsquo;t display everything, so I had to select. But selection may become a form of misrepresentation: if some important data isn\u0026rsquo;t displayed, the system is effectively lying. So, I tried to add as much as possible that still made sense. This lead to a very large table of graphs, but I think it\u0026rsquo;s still understandable. Further, the graphs can be moved around (just drag their labels), so doing comparative analysis is not hampered much by the large set of graphs.\nThe final layout is much influenced by Edward Tufte\u0026rsquo;s books. Most graphic libraries for javascript, including what I used, Dygraphs, contain a lot of chartjunk by default. For example, the professional library HighCharts is full chartjunk (just look at their webpage), and is apparently used by many Fortune 500 companies. I was appalled at this \u0026ndash; many-many graph libraries, none that offers a clean look? Luckily, I could do away with all that colorful beautifying mess \u0026ndash; the data is interesting, and demands no embellishments.\nCreating the webpage Creating the webpage to display what I wanted was quite difficult. I am no expert at PHP or HTML, and this was the first time I had touched javascript. Although the final page doesn\u0026rsquo;t show it much, I struggled quite a bit with all these different tools. If I had to do this again, I would choose to use a page generation framework. This time, I wrote everything by hand.\nI am most proud of two things on the webpage. First is the histogram at the bottom of the graphs. I know it may not seem like it, but that is all done with a javascript I wrote that pulls data from an array that could be dynamically changed. I think it does what it\u0026rsquo;s supposed to do, and does it well. The second is that I had to tweak the graph library used (Dygraphs, the best library out there, hands down), because it was too slow at printing these ~30 graphs. The graphs can be zoomed (just click and drag on X axis), and when zooming in\u0026amp;out the speed was really terrible. It now works relatively fast though I had to tweak the system to trade speed for a bit of visual beauty.\nFinal thoughts Making the visualization webpage was a long marathon. I feel like it\u0026rsquo;s OK now, even though there were quite a number of ideas that weren\u0026rsquo;t implemented in the end. I hope you will enjoy playing with it as much as I have enjoyed making it.\n","permalink":"https://www.msoos.org/2012/06/visualizing-sat-solving/","summary":"\u003cfigure\u003e\u003ca href=\"/sat_visualization/\"\u003e\n    \u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2012/06/sat_visualization_snapshot_small.png\"\n         alt=\"Visualizing the solving of mizh-md5-47-3.cnf\"/\u003e \u003c/a\u003e\u003cfigcaption\u003e\n            \u003cp\u003eVisualizing the solving of mizh-md5-47-3.cnf\u003c/p\u003e\n        \u003c/figcaption\u003e\n\u003c/figure\u003e\n\n\u003cp\u003eVisualizing what happens during SAT solving has been a long-term goal of mine, and finally, I have managed to pull together something that I feel confident about. The system is fully explained in the \u003ca href=\"/sat_visualization/\"\u003eliked\u003c/a\u003e \u003ca href=\"/sat_visualization/\"\u003ei\u003c/a\u003e mage on the right, including how to read the graphs and why I made them. Here, I would like to talk about the challenges I had to overcome to create the system.\u003c/p\u003e","title":"Visualizing SAT solving"},{"content":"Lately, I have been having boot problems with my computer: the system would sometimes fail to boot, and at other times, it displayed the wrong memory readings. I was puzzled, so I took a look. I have six memory DIMMs installed in an ASUS motherboard. Memory modules are usually retained in their slots using two latches:\nThe point of these latches is to keep the memory modules in place when the computer is moved around. They thus serve the same purpose as the screws for PCIe slots or the mounting holes for the CPU coolers. My motherboard, however, is made by ASUS, and it has a \u0026ldquo;feature\u0026rdquo; called Q-DIMM, which is supposed to ease the installation of memory modules when the system has the video card already installed. This \u0026ldquo;feature\u0026rdquo; is rather simple: the latch on the right is completely missing:\nUnsurprisingly, over time, some of my memory modules simply came out from their slots, making the system completely unstable. And I am far from being the only one who has had this problem.\nMost probably the person who came up with this \u0026ldquo;feature\u0026rdquo; wasn\u0026rsquo;t an engineer, but a PR person. It is however rather sad that a technological company such as ASUS should make technical decisions based on PR. By the above logic, I wonder why they didn\u0026rsquo;t remove both latches. And while they were at it, get rid of all those pesky screw holes for the PCIe slots, and the mounting holes for the CPU cooler, too \u0026ndash; things would be much easier to install!\nSeriously, though, this is just unbelievable. Fun part is, ASUS sells this \u0026ldquo;feature\u0026rdquo; as an innovation that is available only to their high-end (and more expensive) motherboards. I don\u0026rsquo;t know whether to laugh or cry that you have to spend less to get a more robust, stable system.\n","permalink":"https://www.msoos.org/2012/05/q-dimm-an-innovation-by-asus/","summary":"\u003cp\u003eLately, I have been having \u003cstrong\u003eboot problems\u003c/strong\u003e with my computer: the system would sometimes fail to boot, and at other times, it displayed the wrong memory readings. I was puzzled, so I took a look. I have six memory DIMMs installed in an ASUS motherboard. Memory modules are usually retained in their slots using two latches:\u003c/p\u003e\n\u003cp\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2012/05/correct_latch.gif\"\u003e\u003c/p\u003e\n\u003cp\u003eThe point of these latches is to \u003cstrong\u003ekeep the memory modules in place\u003c/strong\u003e when the computer is moved around. They thus serve the same purpose as the screws for PCIe slots or the mounting holes for the CPU coolers. My motherboard, however, is made by ASUS, and it has a \u0026ldquo;feature\u0026rdquo; called Q-DIMM, which is supposed to ease the installation of memory modules when the system has the video card already installed. This \u0026ldquo;feature\u0026rdquo; is rather simple: the latch on the right is \u003cstrong\u003ecompletely missing:\u003c/strong\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2012/05/qdimm_kep1.jpeg\"\u003e\u003c/p\u003e","title":"Q-DIMM, an \"innovation\" by ASUS "},{"content":"Hyper-binary resolution is actually quite straightforward, or at least appears to be. Let\u0026rsquo;s take the following example. The clauses in our database are the following:\n-a V b -a V c -b V -c V g -b V -c V d -d V g Let\u0026rsquo;s set a to true, and see what happens. Immediately, b and c get set to true through binary clauses. If we now propagate g through the clause -b V -c V g, we ought to do hyper-binary resolution straight away, and add the clause -a V g -- some call this lazy hyper-binary resolution. Good, one more binary clause!\nBut then\u0026hellip; So now we have nothing to propagate using only binary clauses, we have to propagate using a long clause, -b V -c V d. As good citizens, we also do (lazy) hyper-binary resolution, coming up with the clause -a V d. Good, one more binary clause! One slight glitch now\u0026hellip; d propagates to g, using a binary clause. But this means that setting a can propagate to g without -a V g, the first hyper-binary clause we added! So the first hyper-binary clause we added is in fact useless, it needs to be removed. If we applied transitive reduction, it would remove the first hyper-binary clause -a V g automatically.\nLet\u0026rsquo;s go a bit deeper here. How could we have avoided adding the first hyper-binary clause? The obvious answer is: we should have started with -b V -c V d instead of -b V -c V g. But how easy would have it been to know (i.e. calculate) that starting with that different long clause would have made our work easier? I am not sure it would have been easy to know. And of course the example above is very trivial. It could be made much-much more complicated: g could have been reached with any number of hyper-binary resolutions from d -- so simple binary look-ahead would not have helped.\nI am stuck here. Any ideas?\n","permalink":"https://www.msoos.org/2012/05/on-hyper-binary-resolution/","summary":"\u003cp\u003eHyper-binary resolution is actually quite straightforward, or at least appears to be. Let\u0026rsquo;s take the following example. The clauses in our database are the following:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-a V b\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-a V c\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-b V -c V g\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-b V -c V d\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-d V g\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eLet\u0026rsquo;s set \u003ccode\u003ea\u003c/code\u003e to true, and see what happens. Immediately, \u003ccode\u003eb\u003c/code\u003e and \u003ccode\u003ec\u003c/code\u003e get set to true through binary clauses. If we now propagate \u003ccode\u003eg\u003c/code\u003e through the clause \u003ccode\u003e-b V -c V g\u003c/code\u003e, we ought to do hyper-binary resolution straight away, and add the clause \u003ccode\u003e-a V g\u003c/code\u003e -- some call this \u003ca href=\"http://fmv.jku.at/biere/talks/Biere-Dagstuhl09-talk.pdf\"\u003elazy hyper-binary resolution\u003c/a\u003e. Good, one more binary clause!\u003c/p\u003e","title":"On hyper-binary resolution"},{"content":"In OpenCL, the platform for using the graphics card as a form of highly parallelised machine, reading and writing to the memory of the card is very expensive. For this reason, the OpenCL standard offers a set of highly flexible ways of writing and reading data to- and from the OpenCL device. Using these flexible systems takes time to get used to, but seem to be necessary to get the most out of the graphics card.\nThe Problem If data needs to be processed, a standard way of pushing it through the compute device is to use two instances of an OpenCL kernel: while one is executing, the system is reading out the finished data and uploading the new data to compute for the other kernel. Then the kernels switch places, kernel 2 is processing, while data is read-written for kernel 1. This requires the programmer to index every data piece (since there are now two of them), and make sure to get the last iteration right. This latter is tricky, because even if there is no longer data to process, kernel 2 may still be executing even though kernel 1 can now be stopped.\nThese difficulties make the system tricky to get right, though not impossible. In this blogpost I would like to share with you a nifty trick I have found that completely eliminates this complexity, significantly cleaning up code, while keeping the same speed.\nThe Solution Since OpenCL 1.1, OpenCL supports multithreading. While managing threads is one of the most dreaded parts of programming, OpenMP makes things extremely simple. The architecture we will need is the following:\nA single-kernel system that churns through data. Let us call this Worker A simple class that keeps in mind which data pieces have been finished with. Let us call this Dealer There will be two Workers, and one Dealer. When the Worker requests data from the Dealer, it does it inside a critical OpenMP directive. The Dealer is simply initialised with the data to read through, and deals this data out to the Worker upon request, and marks the data piece as \u0026lsquo;done\u0026rsquo;. If there are no more data to work on, the Worker exits. The only tricky part is the startup, which should look like:\n//Don\u0026#39;t allow dynamic number of threads omp_set_dynamic(0); //Set the number of threads we need omp_set_num_threads(2); //Initialise Dealer Dealer dealer(my_options); #pragma omp parallel { int thread = omp_get_thread_num(); int num_threads = omp_get_num_threads(); Worker worker(\u0026amp;dealer, my_options); worker.compute(); } It\u0026rsquo;s really simple, and works on all platforms where OpenMP is supported, which is pretty much everything, including Windows, Linux, embedded devices, etc. The really nice part about this architecture though is that it allows for way more than just getting around the problems with multiple kernels in the same source code.\nThe advantages First of all, this architecture allows for the Dealer to do much more than just deal out data. You can set the number of threads to 3, set the workers to do their stuff, and wake up the Dealer every 5 seconds to dump the data, for instance. This only needs a \u0026ldquo;while(!finished) { wait(5sec); dump_my_data();}\u0026rdquo; loop in Dealer. Since the other threads can simply continue working while Dealer is writing to disk, this may be quite an important advantage in case the data you are generating is large. Similarly, Dealer could pre-load the data from disk that is to be dealt out to Workers.\nAnother very nice advantage of the above is that there can be any number of Workers, which sounds crazy until you get your hands on a multi-GPU computer. To take advantage of all GPUs in the system, the Workers simply need to be paremetrised with the device number that we wish to use. For example, if we have two OpenCL devices on a machine, we need to launch 4 threads, with device numbers 0,0 and 1,1. If the data chunks to compute are small relative to the overall data, e.g. data chunks need approx. 1 minute to process, but the overall data takes more than an hour, the dealer will distribute the load pretty evenly among the GPUs, so the GPUs can be even of a mixed speed, and it won\u0026rsquo;t affect the overall finish time much.\nConclusions Although the proposed architecture uses multi-threading, something that most programmers fear (sometimes rightly so), it leads to a significantly cleaner and more flexible code that can do more with less. Using this architecture, the code should be easier to write, maintain, and extend \u0026ndash; something all good programmers strive for.\n","permalink":"https://www.msoos.org/2012/01/a-nifty-way-of-saving-time-with-opencl/","summary":"\u003cp\u003eIn \u003ca href=\"http://en.wikipedia.org/wiki/OpenCL\"\u003eOpenCL\u003c/a\u003e, the platform for using the graphics card as a form of \u003ca href=\"http://en.wikipedia.org/wiki/GPGPU\"\u003ehighly parallelised machine\u003c/a\u003e, reading and writing to the memory of the card is very expensive. For this reason, the OpenCL \u003ca href=\"http://www.khronos.org/registry/cl/specs/opencl-1.2.pdf\"\u003estandard\u003c/a\u003e offers a set of highly flexible ways of writing and reading data to- and from the OpenCL device. Using these flexible systems takes time to get used to, but seem to be necessary to get the most out of the graphics card.\u003c/p\u003e","title":"A nifty way of saving time with OpenCL"},{"content":"I have been using the AMD\u0026rsquo;s OpenCL platform for a while now, so I\u0026rsquo;ll try to write a little overview of what I think is good and bad about OpenCL in general and AMD\u0026rsquo;s OpenCL implementation in particular.\nUpdate: AMD was working on the issues below, and temporarily fixed some of them. They are broken again, and I gave up trying to help them. They would need more engineers to fix these issues on a permanent basis.\nThe good The speed of execution is unbeatable. I can easily get 10x better speeds than current top-of-the-line desktop CPUs. And that\u0026rsquo;s not just saving on buying the CPU and all the peripherals (memory, motherboard, etc.), but also on power, which can easily be more expensive than the upfront cost of new machines Once a C/C++ template code is written, OpenCL is easy to start using. There are no difficult systems to master from the main program\u0026rsquo;s perspective, only a couple of well-named functions like clEnqueueWriteBuffer The OpenCL documentation from Khronos is very well written. They even provide a handy reference card that is well made, too There are many books available. I\u0026rsquo;ve bought The OpenCL programming guide, though I got bored from its first part (describing the specification), and never got to the supposedly interesting second part, so I can\u0026rsquo;t yet recommend it The AMD programming guide is simply great. It lists all the important factors like register usage of kernel vs. register-limited wavefronts on the compute unit. It is basically a compressed bible, written by someone extremely knowledgeable in the subject, probably some core AMD engineer(s). I highly recommend reading it OpenCL 1.1 supports mulithreading and is easy to multi-thread. I have turned a program that was single-threaded and used only one GPU into a multi-GPU, multi-threaded system in only two days with OpenMP The GNU debugger can be used to debug the OpenCL kernel if the CPU is chosen as the target platform. This is extremely useful and considerably cuts down on development time. So much for the good part. For something that is still in its infancy \u0026ndash; it has only been around for about 3.5 years \u0026ndash; the above is quite impressive. Apparently, others think it\u0026rsquo;s impressive, too, as OpenCL is already a leading solution for GPGPU developers. Now let\u0026rsquo;s get to the bad part.\nThe bad Warning and errors are sometimes silently eaten. This is very frustrating. For example, I passed a constant memory piece as clCreateBuffer\u0026amp;clEnqueueWriteBuffer, but the size of the buffer was larger than the specified maximum (which for constants is pretty low, a couple of KB). What error message did I get? None. The kernel executed \u0026lsquo;fine\u0026rsquo;, with the slight glitch that it didn\u0026rsquo;t do anything, at all, just returned immediately \u0026ndash; with CL_SUCCESS, naturally. I have hit this errors-get-eaten bug multiple times, with multiple kinds of bugs. So, if my code doesn\u0026rsquo;t work, it\u0026rsquo;s hard to know what is wrong AMD supplies debugging and analysis essentially only for Windows and Visual Studio. I have actually shelled out money on a Windows license (first time in my life) only to get these running, but then I realised I would also need a Visual Studio license, for a mere thousand dollars, to use all tools. However, after seeing the greatness of the KernelAnalyzer which I can reliably crash any moment, and gives no information other than what I can already see from the ISA file, I thought\u0026hellip; maybe it\u0026rsquo;s not worth the money Valgrind gives a lot of warnings when launched on a program that uses AMD\u0026rsquo;s OpenCL implementation. This makes debugging a lot harder, because OpenCL copies a lot of data between the GPU and the CPU, and if you got the numbers wrong, there is nothing to tell you why your data is garbage. The best would be if the AMD APP SDK was valgrind-clean, and when instructed to use the CPU as the OpenCL platform it would detect memory access errors even in the OpenCL kernel. Global memory usage of the kernel really makes a big difference. I thought that although it\u0026rsquo;s slow, it\u0026rsquo;s not a big deal. I was wrong. It\u0026rsquo;s really slow. I can make my program go 10-20% faster just by replacing something like \u0026ldquo;x = y; x ^= z;\u0026rdquo; with \u0026ldquo;x = y^z\u0026rdquo;, where \u0026ldquo;x\u0026rdquo; is global memory, and \u0026ldquo;y\u0026rdquo; and \u0026ldquo;z\u0026rdquo; are both registers. This was completely new to me. It also gives you a hint at the intelligence of the \u0026lsquo;optimising\u0026rsquo; compiler of the AMD APP SDK. But more on that later. Now that the bad part is out of the way, it\u0026rsquo;s time for what\u0026rsquo;s really ugly.\nThe ugly The \u0026lsquo;optimising\u0026rsquo; compiler in the AMD APP SDK can essentially be treated as a random function. It sometimes gives me faster code, sometimes a much slower one, and I can make it switch from one to the other with what essentially amounts to comments in the code. This is like letting a random monster eat your code then treating what came out of the monster as something to benchmark/test. Don\u0026rsquo;t be surprised if what comes out is, well, quite inedible. This \u0026lsquo;slight\u0026rsquo; problem can be evaded if you simply ask the compiler not to \u0026lsquo;optimise\u0026rsquo;, by passing the \u0026ldquo;-cl-opt-disable\u0026rdquo; option. Sometimes optimisation helps, but when debugging performance problems, it\u0026rsquo;s best to get rid of it. My current main setup doesn\u0026rsquo;t use the optimiser and I get approx 3x faster code this way. My other code is speeded up by a factor of 1.8x with the optimiser \u0026ndash; though it\u0026rsquo;s only a slow, sort-of backup implementation anyway You have to copy-paste code. Last time I copy-pasted code was when I was 12, programming Pascal. The reason for this is that in the function declaration\u0026amp;definition you have to specify whether the parameter is a register, a global, or a constant. Since you might want to use the same function twice, once with a constant parameter, once with a global one, you have no other choice than to copy-paste. Oh, yes, you could use a #define, but I am not sure that\u0026rsquo;s cleaner in any way. You also have to copy-paste if you want the same function, but with a slightly different ending. Putting an \u0026lsquo;if\u0026rsquo; at the diverging point and passing a parameter to control the \u0026lsquo;if\u0026rsquo; will be considerably slower (yes, the compiler is that bad) AMD\u0026rsquo;s fglrx dirvers on Linux are about as stable as a house of cards in high wind. If it doesn\u0026rsquo;t crash, that\u0026rsquo;s a good day. I can make it crash just by launching a video player, but I have more \u0026lsquo;fancy\u0026rsquo; ways (e.g. pushing 2 button combinations) of reliably crashing it, too. However, the \u0026lsquo;radeon\u0026rsquo; driver which is stable on Linux doesn\u0026rsquo;t work with OpenCL.Thanks to this, I actually have to reboot my machine to watch any video \u0026ndash; and I thought those days (Windows 95?) were over AMD APP SDK on Linux is about as stable as their driver. For example, compiling\u0026amp;launching a program on the 2.6 version uses 150% CPU and forces the kernel to launch 3 kworker(=kernel worker) threads, each eating up 50% CPU, completely using up a 3-core machine. However, the same exact program can be compiled\u0026amp;launched on the 2.5 version, eating exactly 1% CPU and forcing no kworker usage Conclusions The OpenCL architecture is clean, usable and user-friendly. Unfortunately, the current AMD OpenCL implementation is bad. I hope this will improve in the future, and as more and more people start using it, the bugs will eventually be reported, triaged, and fixed. As the number of people that buy a particular card for its OpenCL capabilities increase, for instance because games start using OpenCL as a way to speed up certain physics calculations, the makers of these cards will eventually be forced to fix the bugs and make development easier. Until then, we might have to keep on suffering for the speedups we get.\n[paypal-donation]\n","permalink":"https://www.msoos.org/2012/01/amds-opencl-heaven-and-hell/","summary":"\u003cp\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2012/01/OpenCL_Logo.png\"\u003eI have been using the AMD\u0026rsquo;s \u003ca href=\"http://en.wikipedia.org/wiki/OpenCL\"\u003eOpenCL\u003c/a\u003e platform for a while now, so I\u0026rsquo;ll try to write a little overview of what I think is good and bad about OpenCL in general and AMD\u0026rsquo;s OpenCL implementation in particular.\u003c/p\u003e\n\u003cp\u003e\u003cem\u003e\u003cstrong\u003eUpdate:\u003c/strong\u003e AMD was working on the issues below, and temporarily fixed some of them. They are broken again, and I gave up trying to help them. They would need more engineers to fix these issues on a permanent basis.\u003c/em\u003e\u003c/p\u003e","title":"AMD's OpenCL heaven and hell"},{"content":" If you have ever wondered how your multi-month SAT problem could be solved, the answer is here: SAT@home by some kind Russian researchers! This idea has been brewing in my head, we even started a mini-project with a friendly American researcher, but we never got it into a working condition :(. It\u0026rsquo;s great that someone took the time to do it, though. Creating such a setup has some easier and harder parts. Setting up a BOINC server is not that hard, but it needs to run 24/7, which is difficult, unless you are department head at a university or you have a company behind you. Then the scripts need to be written, which is relatively easy to do, but testing and debugging is time-consuming. The really hard part, though, is how to distribute the workload. Treatises could be written on that, and the one above uses the simplest method, that of cutting up the problem along a couple of variables. It\u0026rsquo;s a good start, I think: starting easy is always the best way to start \u0026ndash; the first automobile didn\u0026rsquo;t try to achieve 300km/h speeds, and it didn\u0026rsquo;t have to.\nIn the long run, I guess the setups will get more and more complicated, combining many techniques from cutting on variables, to clause sharing with a multitude of clause usefulness heuristics, to sharing parameter usefulness statistics. Workshares themselves could eventually be diversified, some doing \u0026lsquo;simple\u0026rsquo; search without resolution, some doing only resolution (and clause cleaning?), some doing only (specific) simplification algorithms such as subsumption or strengthening, some doing data analysis on the current state of the problem such as reachability analysis, number of gates or other higher-level elements such as adders in the problem, etc. In other words, there are many ways to improve this. Maybe even a common interface to such a system could be laid down where different SAT solvers could be plugged in and used without notice.\nA friend of mine has once written me a mail describing his work, which essentially talks about paying for a webpage not by looking at adverts, but by running a javascript program. The idea is, of course, that we could write a SAT solver in javascript, and make people run the script by putting it on a well-visited webpage. The server would then distribute SAT problems to the javascripts, which would send some computed data back (like learnt clauses), while the person is surfing the page. Cheap (maybe even free) and essentially unlimited CPU time for hard problems. We could use it to answer some fun math questions, or break some cryptographic systems, for example\u0026hellip; just have to find someone crazy enough to write a SAT solver in javascript! :)\n","permalink":"https://www.msoos.org/2011/12/thoughts-on-sat-at-home/","summary":"\u003cp\u003e\u003ca href=\"http://sat.isa.ru/pdsat/\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2011/12/sat_at_home_logo.png\"\u003e\u003c/a\u003e If you have ever wondered how your multi-month SAT problem could be solved, the answer is here: \u003ca href=\"http://sat.isa.ru/pdsat/\"\u003eSAT@home\u003c/a\u003e by some kind Russian researchers! This idea has been brewing in my head, we even started a mini-project with a  friendly \u003ca href=\"http://www.american.edu/cas/faculty/mblack.cfm\"\u003eAmerican researcher\u003c/a\u003e, but we never got it into a working condition :(. It\u0026rsquo;s great that someone took the time to do it, though. Creating such a setup has some easier and harder parts. Setting up a \u003ca href=\"http://boinc.berkeley.edu/\"\u003eBOINC\u003c/a\u003e server is not that hard, but it needs to run 24/7, which is difficult, unless you are department head at a university or you have a company behind you. Then the scripts need to be written, which is relatively easy to do, but testing and debugging is time-consuming. The \u003cem\u003ereally\u003c/em\u003e hard part, though, is how to distribute the workload. Treatises could be written on that, and the one above uses the simplest method, that of cutting up the problem along a couple of variables. It\u0026rsquo;s a good start, I think: starting easy is always the best way to start \u0026ndash; the first automobile didn\u0026rsquo;t try to achieve 300km/h speeds, and it didn\u0026rsquo;t have to.\u003c/p\u003e","title":"Thoughts on SAT@home"},{"content":"In case you\u0026rsquo;ve missed it, the CCC Camp was a great opportunity to meet people both working in security and otherwise. I have even met a very kind Taiwanese researcher who worked on SAT and Gröbner basis: in fact, if you haven\u0026rsquo;t had the chance to read this paper, I highly recommend it. A set of kind Taiwanese researchers recommended this paper to me, and I think it\u0026rsquo;s the most interesting SAT paper I have read in the past year.\nWe at SRLabs have made two releases during this camp, one that breaks GPRS encryption, and one that breaks smart card ROM encryption. I was involved with the first release, essentially working on the crypto part. In case you are interested in the videos, the one on GPRS is uploaded here, and the one on smart card ROM encryption is here. This reminds me of something: the videos from the MIT SAT/SMT Summer School are missing :( Well, given my fail there, maybe that\u0026rsquo;s a good thing :)\n","permalink":"https://www.msoos.org/2011/08/ccc-camp11/","summary":"\u003cp\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2011/08/8544_1050_500.jpeg\"\u003eIn case you\u0026rsquo;ve missed it, the \u003ca href=\"http://events.ccc.de/camp/2011/\"\u003eCCC Camp\u003c/a\u003e was a great opportunity to meet people both working in security and otherwise. I have even met a very kind Taiwanese researcher who worked on SAT and Gröbner basis: in fact, if you haven\u0026rsquo;t had the chance to read \u003ca href=\"http://zengler.eu/files/papers/zengler_casc2010.pdf\"\u003ethis\u003c/a\u003e paper, I highly recommend it. A set of kind Taiwanese researchers recommended this paper to me, and I think it\u0026rsquo;s the most interesting SAT paper I have read in the past year.\u003c/p\u003e","title":"CCC Camp'11"},{"content":"I have just realised that CryptoMiniSat, having won a number of medals, does one of the most basic things, failed literal probing, all wrong. Let me tell you why it\u0026rsquo;s all wrong. In essence, failed literal probing is trivial. We enqueue a fact, such as a, and then propagate it. If this fails, i.e. if two opposing facts such as g and -g are derived, we know that a cannot be true, so we set -a. Easy. Or maybe not so easy.\nThe devil is in the details, so let\u0026rsquo;s see how we derived both g and -g from a. Let\u0026rsquo;s assume that we have the following set of binary clauses: -a V b -b V c -b V d -d V e -d V f -e V g -f V -g\nwhich, from the point of view of a is best described as the graph:\nPropagating \u0026ldquo;a\u0026rdquo;, deriving both \u0026ldquo;g\u0026rdquo; and \u0026ldquo;-g\u0026rdquo;\nThe problem is, that if we only derive -a from this graph, we end up with only that one literal set, because -a doesn\u0026rsquo;t propagate anything on the clauses. This is quite sad, because, in fact, we could derive something stronger. From the graph it is evident that setting d would have failed: the graph would simply have its upper part cut away completely, but the lower part, including the derivation of both g and -g would still stand:\nDeriving both \u0026ldquo;g\u0026rdquo; and \u0026ldquo;-g\u0026rdquo; from \u0026ldquo;d\u0026rdquo;\nWhat is special about node d? Well, it\u0026rsquo;s where the 1st UIP, the first unique implication point, lies. And it is quite simple to see that -d is in fact the strongest thing we can derive from this graph. It\u0026rsquo;s much stronger than simply -a, because setting -d propagates on the clauses, giving -b,-a, setting three variables instead of one, including -a. An interesting observation is the following: deriving -b is the 2nd UIP, and deriving -a is the last UIP. In other words, at least in this most simple case, 1st UIP is in fact the strongest, and 2nd, 3rd.. last UIP are less strong in strict order.\nLet me remark on one more thing about failed literal probing. Once failed literal probing has been done on literal x and it visited the node set N, there is no need to try to do failed literal probing on any nodes in N, since they cannot possibly fail. Although the failing of a literal can have consequences on the failing of other literals, if we ignore this side-effect, we could speed up failed literal probing by marking literals already visited, and only carrying out failed literal probing on ones that haven\u0026rsquo;t been marked. This is really trivial, but I haven\u0026rsquo;t been using it :S\nI am quite sure that some advanced SAT solvers (such as lingeling) do all of the above things right. It\u0026rsquo;s probably only CryptoMiniSat that fails miserably :)\nNote: there is a subtle bug with marking literals visited as \u0026ldquo;OK\u0026rdquo;. If two different subgraphs could fail, but we abort on the first one, then we might mark a literal OK when in fact it isn\u0026rsquo;t. It is therefore easiest not to mark any literals if the probe failed (which is very rare).\n","permalink":"https://www.msoos.org/2011/08/failed-literal-probing-and-uip/","summary":"\u003cp\u003eI have just realised that \u003ca href=\"/cryptominisat2\"\u003eCryptoMiniSat\u003c/a\u003e, having won a number of medals, does one of the most basic things, \u003ca href=\"http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=CF33EFCD2F8DC2595B3CB93AB4B02833?doi=10.1.1.1.1941\u0026amp;rep=rep1\u0026amp;type=pdf\"\u003efailed literal probing\u003c/a\u003e, \u003cem\u003eall wrong\u003c/em\u003e. Let me tell you why it\u0026rsquo;s all wrong. In essence, failed literal probing is trivial. We enqueue a fact, such as \u003ccode\u003ea\u003c/code\u003e, and then propagate it. If this fails, i.e. if two opposing facts such as \u003ccode\u003eg\u003c/code\u003e and \u003ccode\u003e-g\u003c/code\u003e are derived, we know that \u003ccode\u003ea\u003c/code\u003e cannot be true, so we set \u003ccode\u003e-a\u003c/code\u003e. Easy. Or maybe not so easy.\u003c/p\u003e","title":"Failed literal probing and UIP"},{"content":"While reading this thesis, I have had a thought about autarkies. Let me first define what an autarky in SAT solving is:\nA partial assignment phi is called a weak autarky for F if \u0026quot; phi*F is a subset of F\u0026quot; holds, while phi is an autarky for F if phi is a weak autarky for all sub-clause-sets F' of F. (Handbook of Satisfiability, p. 355)\nWhat does this mean? Well, it means that in the clause-set {x V y, x} the assignment y=False is a weak autarky, because assigning y to False will lead to a clause that is already in the clause set (the clause x), while the assignment of x=True is a (normal) autarky, because it will satisfy all clauses that x is in. The point of autarkies is that we can remove clauses from the clause set by assigning values to a set of variables, while not changing the (un)satisfiability property of the original problem. In other words, autarkies are a cheap way of reducing the problem size. The only problem is that it seems to be relatively expensive to search for them, so conflict-driven SAT solvers don\u0026rsquo;t normally search for them (but, some lookahead solvers such as march by Marijn Heule do).\nSo, what is the idea? Well, I think we can have autarkies for equivalent literals, too. Here is an example CNF:\na V d V -f -b V d V -f -a V e b V e setting a = -b will not change the satisfiability of the problem.\nWe can add any number of clause pairs of the form X V Y where Y is any set of literals not in {a, -a, b, -b}, and X is (-)a in clause 1 and (-)b in clause 2. Further, one of the two variables, say, a can be in any clauses at will (in any literal form), though variable b can then only be in clauses defined by the clause pairs. Example:\na V d V -f -b V d V -f -a V e b V e a V c V -h a V -f An extension that is pretty simple from here, is that we can even have clauses whose Y part is somewhat different: some literals can be missing, though again in a controlled way. For example:\na V d -b V d V -f -a V e b V e is possible. It would restrict b a bit more than necessary, but if a is the only one of the pairs missing literals, we are still OK I believe.\nFinally, let me give an example of what these higher-level autarkies are capable of. Let\u0026rsquo;s assume we have the clause set:\na V d -b V d V -f -a V e b V e a V c V -h a V -f a V b V f V -g setting a=-b now simplifies this to:\na V d -a V e a V c V -h a V -f which is equisatisfiable to the first one. Further, if the latter is satisfiable, computing the satisfying solution to the former given a solution to the latter is trivial.\n","permalink":"https://www.msoos.org/2011/07/note-to-self-higher-level-autarkies/","summary":"\u003cp\u003eWhile reading \u003ca href=\"http://www.st.ewi.tudelft.nl/sat/theses/heule_phd.pdf\"\u003ethis\u003c/a\u003e thesis, I have had a thought about autarkies. Let me first define what an autarky in SAT solving is:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eA partial assignment \u003ccode\u003ephi\u003c/code\u003e is called a weak autarky for \u003ccode\u003eF\u003c/code\u003e if \u0026quot; \u003ccode\u003ephi*F\u003c/code\u003e is a subset of \u003ccode\u003eF\u003c/code\u003e\u0026quot; holds, while \u003ccode\u003ephi\u003c/code\u003e is an autarky for \u003ccode\u003eF\u003c/code\u003e if \u003ccode\u003ephi\u003c/code\u003e is a weak autarky for all sub-clause-sets \u003ccode\u003eF'\u003c/code\u003e of \u003ccode\u003eF\u003c/code\u003e. (Handbook of Satisfiability, p. 355)\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eWhat does this mean? Well, it means that in the clause-set \u003ccode\u003e{x V y, x}\u003c/code\u003e the assignment \u003ccode\u003ey=False\u003c/code\u003e is a weak autarky, because assigning \u003ccode\u003ey\u003c/code\u003e to \u003ccode\u003eFalse\u003c/code\u003e will lead to a clause that is already in the clause set (the clause \u003ccode\u003ex\u003c/code\u003e), while the assignment of \u003ccode\u003ex=True\u003c/code\u003e is a (normal) autarky, because it will satisfy all clauses that \u003ccode\u003ex\u003c/code\u003e is in. The point of autarkies is that we can remove clauses from the clause set by assigning values to a set of variables, while not changing the (un)satisfiability property of the original problem. In other words, autarkies are a cheap way of reducing the problem size. The only problem is that it seems to be relatively expensive to search for them, so conflict-driven SAT solvers don\u0026rsquo;t normally search for them (but, some lookahead solvers such as \u003ca href=\"http://www.cril.univ-artois.fr/SAT11/results/solver.php?idev=46\u0026amp;idsolver=1913\"\u003emarch\u003c/a\u003e by Marijn Heule do).\u003c/p\u003e","title":"Note to self: higher level autarkies"},{"content":"\u0026ldquo;Stay hungry. Stay foolish.\u0026rdquo;\nIn my last post, I talked a little bit about learnt clause size distributions (histograms, really), and after a long chat with Vegard Nossum, we came up with some nice 3D graphs of learnt clause size distributions et al. It\u0026rsquo;s basically a lot of brainstorming that is quite entertaining I think. First of all, instead of waiting for Godot (i.e. someone to tell me that is has been done already), we got down an dirty with time-sliced histograms, so we can see how a specific problem gets solved. Again, I won\u0026rsquo;t go into much analysis, as I think it\u0026rsquo;s quite detrimental to novel ways of interpretation, instead, I will simply display the graphs. All simplification algorithms have been switched off for these graphs, though interestingly, they look pretty similar even if simplifications are turned on. Before we start, let me note that all tools to generate these simply and easily will be available in CryptoMS-2.9.2 (and are already available from the git repository of course \u0026ndash; nothing I do on CMS is secret)\nGrain Let\u0026rsquo;s first start with the Grain cipher -- we have seen it before and it had quite a peculiar shape. The learnt clause size distribution for this cipher is the following:\nThe Z axis contains the slices\u0026ndash; one slice is 3'000 conflicts, and time flows from the back to the front (we didn\u0026rsquo;t solve the instance).The Y axis is number of clauses, and X axis is the size of the clause. Notice the bump around clause size ~130. An interesting graph would now be to compare this with glues of these clauses\u0026hellip; so it goes:\nPretty similar, actually, except that the bump is around 110. Now, this bump could be fully useless. Or the holy grail. We don\u0026rsquo;t know\u0026hellip; until we see some graphs ;) The graph for propagations caused by learnt clauses of specific sizes is the following:\nThe Z axis here is a bit different: it accumulates 3'000 propagations caused by learnt clauses, and then generates a slice. That\u0026rsquo;s the reason there are 600 of them in contrast to the one above, where there are 33 (for ~100'000 conflicts). Notice that most of the propagations are caused by small clauses. The same for glues:\nNow the number of conflicts caused by learnt clauses of specific sizes:\nNotice the slight colourchange on this graph at around 130 \u0026ndash; compared to the previous 2 graphs, conflicts are done by a relatively good number of longer clauses, too. Let\u0026rsquo;s do the same with glues now:\nColourchange (and a bit visible bump, too) at around 110. Actually, it might be best to put the Y axis into logscale\u0026hellip; next time.\nACG-20-10p0 Now that we have gone through Grain, let\u0026rsquo;s try another problem. For example the ACG-20-10p0 problem from SAT Comp'09. The clause size distributions are now:\nAnd the same for glues:\nAnd the propagations according to their size:\nNotice that the number of slices is quite large. Now the conflicts caused by learnt clauses, according to their size:\nNotice that compared to the previous graph, the distribution is shifted a lot more towards longer clauses, similarly to the Grain example. Also notice that there were 25 slices in total, and 12 slices\u0026rsquo; worth of conflicts were caused by learnt clauses \u0026ndash; in other words, about 50% of all conflicts are caused by learnt clauses. I was aware of this behaviour because CryptoMS 1.0 had a statistical interface, where this was quite obvious to see \u0026ndash; unfortunately, that statistical interface is gone now, but may be back in one form or another in CryptoMS 3.0.0. For Grain, we had 33 slices, and 8 slices\u0026rsquo; worth were caused by learnt clauses, which is not 50% but still pretty high, considering that the number of learnt clauses is usually far less than the number of original clauses.\nA lot of thanks go to Vegard Nossum for all of this. He was the one who inquired about producing these using the new CryptoMiniSat, and once I put the ~5 lines of code into the solver and wrote a hackish awk script, he wrote the perl script to parse the data up, and showed me the beautiful results. I just couldn\u0026rsquo;t wait to share them with you :)\n","permalink":"https://www.msoos.org/2011/07/learnt-clause-graphs/","summary":"\u003cp\u003e\u003cem\u003e\u0026ldquo;Stay hungry. Stay foolish.\u0026rdquo;\u003c/em\u003e\u003c/p\u003e\n\u003cp\u003eIn my \u003ca href=\"/fun-facts-about-sat-solving-part-1\"\u003elast post\u003c/a\u003e, I talked a little bit about learnt clause size distributions (histograms, really), and after a long chat with \u003ca href=\"http://folk.uio.no/vegardno/\"\u003eVegard Nossum\u003c/a\u003e, we came up with some nice 3D graphs of learnt clause size distributions et al. It\u0026rsquo;s basically a lot of brainstorming that is quite entertaining I think. First of all, instead of \u003ca href=\"http://en.wikipedia.org/wiki/Waiting_for_Godot\"\u003ewaiting for Godot\u003c/a\u003e (i.e. someone to tell me that is has been done already), we got down an dirty with time-sliced histograms, so we can see how a specific problem gets solved. Again, I won\u0026rsquo;t go into much analysis, as I think it\u0026rsquo;s quite detrimental to novel ways of interpretation, instead, I will simply display the graphs. All simplification algorithms have been switched off for these graphs, though interestingly, they look pretty similar even if simplifications are turned on. Before we start, let me note that all tools to generate these simply and easily will be available in CryptoMS-2.9.2 (and are already available from the \u003ca href=\"http://gitorious.org/cryptominisat/\"\u003egit repository\u003c/a\u003e of course \u0026ndash; nothing I do on CMS is secret)\u003c/p\u003e","title":"Learnt clause graphs"},{"content":"Last time I gave a talk, I got some quite deserved fire about the way I approach SAT solving: in a more practical than scientific way. So, to give some food for thought for those who wish to approach SAT from a more scientific viewpoint, and to demonstrate to what lengths I have gone to give (at least to myself) a scientific viewpoint, let me talk a little bit about a fun fact that I have found. The fun fact, as is quite usual for SAT, seems entirely trivial, even banal, but has somehow (so far) eluded proper explanation for me. Maybe you will be the one to give the right explanation :)\nSo, I generate a Grain cipher instance using, e.g. the Grain-of-Salt tool that I developed. If you don\u0026rsquo;t want to generate these yourself, there are a couple (multi-hundred thousand) pre-generated such problems you can download from here. I launch MiniSat 2.1 \u0026ldquo;core\u0026rdquo;(i.e. the most simple version) on these problems with a little twist: I write to a file the length of each generated learnt clause. Now, there are two kinds of CNF files I use: one that has 60 randomly picked randomly set state variables, and another one that is plain, and doesn\u0026rsquo;t have any variables set. Obviously, the CNF that has variables set should be easier to solve, and if Grain is a proper cipher, it should be about 2^60 easer to solve. Now, I print the average learnt clause length that I observe for the CNF that has 0 variables set, and I get this graph:\nI am sure one could sing long and elaborate songs about this graph, but instead, I will just say: it has a strange curvy thing at around clause length 120. Now, I will generate a similar graph, but this time, I will use a CNF that has 60 state (i.e. important) variables set. Note that this should indeed be 2^60 times easier to solve (since Grain is a nice cipher, and my CNF generation abilities aren\u0026rsquo;t that poor). So the same graph for this CNF looks like this:\nAll right. This one, as I am sure you have noticed, has a curvy thing at around 60. Using elementary math, 120-60 = 60. Right, so one could reason: well, there were X unknowns, I have set 60 of them, now there are only X-60 left, so the average clause length should be 60 less! That I think doesn\u0026rsquo;t explain much, if anything, however. First off, the number of unknowns were in fact 160 \u0026ndash; that\u0026rsquo;s the unknown state of Grain that we were trying to solve. Second, the learnt clauses don\u0026rsquo;t only contain state variables\u0026hellip; in fact, a lot of variables they contain are not state variables at all! Furthermore, why should the 1st UIP scheme be so exact about clause sizes? After all, it\u0026rsquo;s just a graph-analysis algorithm working at the local conflict \u0026ndash; it has no clue about the problem it is working with, much less about the number of state bits set in our instance of Grain.\nOne could say that this is just a dumb example, and it has no real meaning. Maybe I just stumbled upon it, after all, 120/2 = 60, etc. However, this doesn\u0026rsquo;t seem to be the case. I can, in fact, reproduce this for a lot of X\u0026rsquo;s for any of the following ciphers: Grain, Trivium, Bivium, HiTag2 and Crypto-1. Let me show one from HiTag2. Again, we are solving for the state, and we don\u0026rsquo;t set any state bits (i.e. this is the full HiTag2 problem):\nOkay, there is a bumpy thing at around 23. Now, let\u0026rsquo;s set 10 randomly picked state variables to random values, and run the example again:\nThere seems to be a bumpy thing at around 13. 23-10 = 13. That\u0026rsquo;s about right.\nBy the way, I have stumbled upon the above fun fact about 2 years ago (well before CryptoMiniSat was born), when working on my diploma thesis \u0026ndash; these graphs are actually taken verbatim from my thesis. I have worked a lot on SAT in the past 2 years, but this has been haunting me ever since. Maybe someone could explain it to me?\nPS: Does anyone know if someone has done an in-depth analysis of learnt clause length distributions, maybe even three-dimensional, showing the time on the Z axis? It would be awesome to do that, if it hasn\u0026rsquo;t been done yet!\n","permalink":"https://www.msoos.org/2011/07/fun-facts-about-sat-solving-part-1/","summary":"\u003cp\u003eLast time I gave a \u003ca href=\"/wordpress/wp-content/uploads/2011/06/soos_summerschool.pdf\"\u003etalk\u003c/a\u003e, I got some quite deserved fire about the way I approach SAT solving: in a more practical than scientific way. So, to give some food for thought for those who wish to approach SAT from a more scientific viewpoint, and to demonstrate to what lengths I have gone to give (at least to myself) a scientific viewpoint, let me talk a little bit about a fun fact that I have found. The fun fact, as is quite usual for SAT, seems entirely trivial, even banal, but has somehow (so far) eluded proper explanation for me. Maybe you will be the one to give the right explanation :)\u003c/p\u003e","title":"Fun facts about SAT solving (part 1)"},{"content":"(Note: the judges made a small mistake, and CryptoMiniSat only won 1 gold and 1 silver medal. Details below.) CryptoMiniSat\u0026rsquo;s SAT Competition'11 version, \u0026ldquo;Strange Night\u0026rdquo;won two gold medals at the competition: one shared with lingeling at the parallel SAT+UNSAT Applications track, and one at the parallel UNSAT Applications track. This is a great result, and I would like to thank everyone who helped me and the solver achieve this result: my fiancée, my current employer, Security Research Labs and Karsten Nohl in particular, who started the whole CryptoMiniSat saga, my former employer, INRIA Rhone-Alpes and in particular Claude Castelluccia, and finally, all the kind people at the development mailing list. Without the help of all these people, CryptoMiniSat would probably never exist in the first place, much less win such distinguished awards.\nThe competition was very though this year, and so it is particularly good that we have managed to win two gold medals. The most gold medals were won by the portifolio solver ppfolio, winning 5 gold medals \u0026ndash; all other solvers won at most 2 gold medals. CryptoMiniSat did very well in the parallel applications track, basically winning all gold medals that ppfolio didn\u0026rsquo;t win \u0026ndash; and ppfolio was using an older version of CryptoMiniSat as one of its internal engines, essentially making CryptoMiniSat compete with itself (and other strong solvers such as lingeling and clasp). Unfortunately, CryptoMiniSat didn\u0026rsquo;t win any awards at the sequential applications track, as most awards there were won by very new solvers such as Glucose ver 2 and GlueMiniSat. The source code and PDF description of these solvers are not yet available, but they will be shortly at the SAT Competition website.\nOverall, I think CryptoMiniSat did very well, considering that I was not very optimistic given the fact that I didn\u0026rsquo;t manage to finish the new generation (3.x) of the solver, and had to submit a variant of the very old CryptoMiniSat 2.7.0. Furthermore, in the past year I have been concentrating on ideas external to the clause learning of SAT solvers, and it seems that the best way to speed up SAT solvers is to attack the core of the solver: the learning engine. So, this year will be about cleaning up all the external ideas and implementing new ones into the core of the solver.\nOnce again, thanks to everyone who helped CryptoMiniSat get such high rankings, and I am looking forward to the next year for a similarly good competition!\nEdited to add (29/06): The judges just informed me that they made a mistake, and the originally presented results were erroneous. CryptoMiniSat won 1 gold and 1 siver, as lingeling was faster by about 7% in speed in the parallel SAT+UNSAT track. Congratulations to Armin Biere for winning this track!\n","permalink":"https://www.msoos.org/2011/06/cryptominisat-won-two-gold-medals-at-sat-comp11/","summary":"\u003cp\u003e\u003cem\u003e\u003ca href=\"/wordpress/wp-content/uploads/2011/06/cups.jpg\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2011/06/cups.jpg\"\u003e\u003c/a\u003e(Note: the judges made a small mistake, and CryptoMiniSat only won 1 gold and 1 silver medal. Details below.)\u003c/em\u003e \u003cem\u003eCryptoMiniSat\u003c/em\u003e\u0026rsquo;s SAT Competition'11 version, \u0026ldquo;Strange Night\u0026rdquo;\u003ca href=\"http://www.cril.univ-artois.fr/SAT11/results/ranking.php?idev=46\u0026amp;seqCpuLimit=5000\u0026amp;parCpuLimit=40000\u0026amp;wcLimit=5000\"\u003ewon\u003c/a\u003e two gold medals at the \u003ca href=\"http://www.cril.univ-artois.fr/SAT11/\"\u003ecompetition\u003c/a\u003e: one shared with \u003cem\u003e\u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e\u003c/em\u003e at the parallel SAT+UNSAT Applications track, and one at the parallel UNSAT Applications track. This is a great result, and I would like to thank everyone who helped me and the solver achieve this result: my fiancée, my current employer, \u003ca href=\"http://srlabs.de/\"\u003eSecurity Research Labs\u003c/a\u003e and Karsten Nohl in particular, who started the whole \u003cem\u003eCryptoMiniSat\u003c/em\u003e saga, my former employer, INRIA Rhone-Alpes and in particular \u003ca href=\"http://planete.inrialpes.fr/~ccastel/\"\u003eClaude Castelluccia\u003c/a\u003e, and finally, all the kind people at the \u003ca href=\"http://lists.gforge.inria.fr/mailman/listinfo/cryptominisat-devel\"\u003edevelopment mailing list\u003c/a\u003e. Without the help of all these people, CryptoMiniSat would probably never exist in the first place, much less win such distinguished awards.\u003c/p\u003e","title":"CryptoMiniSat won two gold medals at SAT Comp'11"},{"content":"When someone looks at the speed of solving when using parallel SAT solvers, it is easy to see that scaling doesn\u0026rsquo;t really work \u0026ndash; especially for the hard UNSAT problems. In the past months I have been struggling to think of an architecture that will enable me to write a SAT solver that solves this problem. Let me share with you where I got. It will be more of a brainstorming than a descriptive blog post, but maybe it will help you avoid pitfalls, or maybe just to get a better picture of parallel SAT solving.\nThe constraints:\nClauses must be shared\u0026hellip; all the time. Not \u0026ldquo;when it\u0026rsquo;s good enough\u0026rdquo; as per ManySat -- that architecture doesn\u0026rsquo;t work well for UNSAT problems. The performance of a fully shared scheme should be able to overtake a ManySat-like architecture with ease. Only sharing low-glue or high-activity clauses does not work. This is easy to test: write a single-threaded SAT solver with high-glue learnt clause detaching on backtracking. It will work decidedly worse, even though you would clean those clauses anyway when doing clause cleaning. The reason? I don\u0026rsquo;t know\u0026hellip; probably we need those clauses in our current local (=var activities similar) search. Clauses need to have glues and activities. Glues could be dynamically updated, but the gain is not that much and the burden is a bit too much \u0026ndash; so make that static. Activities (which are inherently dynamic) are important though (see CryptoMiniSat), and they must be lock-free as they would need to be updated frequently. Memory is scarce when implication caching is used. Implication cache must be shared and updated across the parallel solvers. This not only lowers memory usage, but is an important way to share information other than clauses. Parallel solvers must be lean otherwise the burden of programming a correct solver would be far too much Simplifications must be carried out regularly, which needs the coordinated stopping / interruption of all parallel solvers My architectural solution:\nMake a lean class that only handles: clause attachment, detachment and propagation. I will need to add on-the-fly hyper-binary resolution and on-the-fly useless binary clause removal as well, as those are tightly coupled to propagation Make a class that handles search\u0026amp; conflict generation. This class has the lean class as parent. This generates conflict clauses and has its own variable \u0026amp; clause activities. The class checks for new conflict clauses form other solvers after every conflict it generates, and attaches those clauses when that doesn\u0026rsquo;t need trail-rewriting \u0026ndash; though this latter could be made optional. This class does not store a list of clauses. The tricky part of this class is on-the-fly subsumption. We will handle that by not shortening the clause but instead adding a new one and detaching the old one. The thread-coordindating class will handle the propagation of this update to all other threads. Checks for interruption are done after every generated conflict. A thread-coordinating class that handles clause storage, clause distribution, and simplification. This class stops all threads if UNSAT or SAT is found by one thread, and interrupts them if clause-cleaning needs to be carried out. This class also has the lean class as parent, since e.g. clause vivification or variable-replacement need propagation. Data structures:\nFully shared clauses. No move-to-front strategy, instead literal-sorting is carried out once in a while (during simplification I would assume). This has already been implemented, and is only about 10% slower than non-shared clauses in single-threaded mode. Interrupt handler. This is just a flag set by the coordinating solver. The subsolvers check this flag after every conflict generated, and either exit (if SAT/UNSAT is found) or just stop and mark each learnt clause locked (if cleaning the learnt clause database) Implication cache. Needs read-write lock, as most of the time it will be read to do on-the-fly self-subsuming resolution with non-existent binary clauses. Can only have literals added, not removed. Removal and updating of literals is performed only during simplification. Updating (i.e. writing) is done by threads only when doing propagation at decision level 1. Distribution of newly learnt clauses. A \u0026rsquo;lock-free\u0026rsquo; (how I don\u0026rsquo;t like this \u0026ndash; it\u0026rsquo;s misleading, it has locks) datastructure for each thread in the thread-coordinating class that allows the storage of a pre-fixed number of clauses, accessible \u0026amp; writeable without locks until the buffer is filled (at which point we lock \u0026amp; update pointers). Dilemmas:\nMaybe thread-management while searching (i.e. learnt clause cleaning and sharing) should be a different class from the one that performs simplification. The former would not need to have propagation at all. Separation of duties always leads to cleaner code. Single-threaded solving is now only an afterthought, and it would be interesting to see how the solver performs in single-threaded mode. I hope it will be only slightly worse than if it didn\u0026rsquo;t have this architecture around it. It is interesting to note, though, that the structure of the solver will be much cleaner than huge-blob single-threaded solvers tend to be. OpenMP will probably not suffice, as read-write locks are not available, and implication cache sharing is a very important part of the architecture. Fully locking that datastructure when using it would incur too much overhead \u0026ndash; most (99.9%) of the time we will be reading it. This means the code might not be as portable as I wished it would be. I think the read-write lock is the only thing I am missing to implement all of this using OpenMP. Notes:\nThis architecture lets the designer easily change the propagation mechanism. Just re-write the lean class. I have actually done that, and I can have both move-to-front (does not work with sharing) and static clause propagation strategies. People could write their own with ease. Conflict generation\u0026amp;search class should have an object pointer passed to it that is an instance of a class that has a abstract search class as its parent. We could then change restart settings on-the-fly by passing different object pointers. We could save state (i.e. stop\u0026amp;restart search) easily by interrupting all threads and saving the clause database (+learnt clause cleaning state). Simplifications should be fully stateless, so no state would need to be saved for those. Okay, this is as far as I got. I have the lean class and the search\u0026amp;conflict generation class, the shared clause architecture, and the stateless simplifications ready, but the coordinating class is currently highly entangled with the conflict generation class, so those need to be separated. Further, I want to fix on-the-fly subsumption because it seems to be an easy way to improve the efficiency of conflict generation: if we can shorten a non-learnt clause at every 10th conflict, that is essentially a surely good conflict clause that will never be cleaned. The effect of not having to clear clauses is important when e.g. 6x more conflicts (for a 6-core CPU) are being generated per second than with a single-threaded solver.\n","permalink":"https://www.msoos.org/2011/06/dreaming-up-a-parallel-sat-architecture/","summary":"\u003cp\u003eWhen someone looks at the speed of solving when using parallel SAT solvers, it is easy to see that scaling doesn\u0026rsquo;t really work \u0026ndash; especially for the hard UNSAT problems. In the past months I have been struggling to think of an architecture that will enable me to write a SAT solver that solves this problem. Let me share with you where I got. It will be more of a brainstorming than a descriptive blog post, but maybe it will help you avoid pitfalls, or maybe just to get a better picture of parallel SAT solving.\u003c/p\u003e","title":"Dreaming up a parallel SAT architecture"},{"content":"Having won the SAT Race with CryptoMiniSat, I think I can now confess that I still don\u0026rsquo;t understand conflict generation. So today, I sat down and I tried to understand it. The result is some fun code, a lot of reading, and great pictures. Let me share with you these auto-generated graphs \u0026ndash; the generator will be released with CMSat 3.0.0, so you will be able to generate them, too. These graphs show something called an \u0026lsquo;implication graph\u0026rsquo;, which is nothing more than a graphical way to show how propagations were made by the reasoning engine. For instance, if variable x1 and x2 are both FALSE, then clause \u0026lsquo;x1 V x2 V x3\u0026rsquo; will force x3 to be TRUE to satisfy the clause. Okay, so much for talk, let\u0026rsquo;s see the graphs!\nOur first implication graph had a clause \u0026ldquo;-70 55 42\u0026rdquo; (light green box) that caused a conflict \u0026ndash; that is to say, somehow the variable setting {x70=TRUE, x55=FALSE, x42=FALSE} was set, the SAT solver realised that this is wrong, and something has to be done. Let\u0026rsquo;s look at what lead here! Guesses are coloured orange here, so it seems we made the following guesses during our SAT solving: x71=TRUE, x73 = FALSE, x42=FALSE. Now, we could just say, oh, well, setting x73 to FALSE was a dumb idea, just reverse that guess, and be done with it. That\u0026rsquo;s the easy (and the fast) way, but we are less lazy than that and we want to understand the reasons. So we do something called the conflict analysis to find something called an asserting clause that will not only let us reverse the guess x73=FALSE, but will also give the SAT solver a reason why that is a necessary assignment given its previous guesses and their consequences.\nConsequences in the graph are coloured dark green, and there are exactly 3 of them: x70=TRUE, x55=FALSE and x56=TRUE. Each of these is a consequence of a clause that is in the SAT solver, marked on the edge(s) leading to it. For example, x56 is set to TRUE, because of the guess x73=FALSE and the clause \u0026ldquo;x56 V x73\u0026rdquo; marked on the edge leading to x56. A consequence that has one edge leading to it was propagated by a 2-long clause, a consequence that has 2 edges leading to it was propagated by a 3-long clause (e.g. consequence \u0026ldquo;x70=TRUE\u0026rdquo;, propagated by \u0026ldquo;x70 V x55 V x73\u0026rdquo;), etc. Okay, so how do we get to the reason? Well, we start out with the conflict, the clause \u0026ldquo;-x70 V x55 V x42\u0026rdquo; (at the bottom), and we do resolutions with this clause, going bottom up. We do as many resolutions as needed to reach the first UIP (also called \u0026ldquo;articulation vertex\u0026rdquo; or \u0026ldquo;dominator\u0026rdquo;), which is a unique point on the graph through which all paths go through from the highest decision level guess, in this case x73=FALSE, at decision level 56 (noted with a @56). If you take a look, the paths from x73=FALSE diverge from the very first point onwards, and there is no single point where they converge again. This means that the (first and only) dominator will be x73=FALSE itself, and we have to resolve with all clauses on the path:\nStart with clause \u0026ldquo;-x70 V x55 V x42\u0026rdquo; Resolve with clause \u0026ldquo;x70 V x55 V x73\u0026rdquo; Resolve with clause \u0026ldquo;-x55 V-x56 V -x71\u0026rdquo; Resolve with clause \u0026ldquo;x56 V x73\u0026rdquo; This list is noted on the bottommost box\u0026rsquo;s lowest entry. When we resolve with these clauses, we are actually doing cuts on the graph, like this:\nMy drawing capabilities aren\u0026rsquo;t exactly great, but you can see that the cuts are successively higher and higher, until we reach the cut that has on its outer part the literals -x73, x71 and -x42. Unsurprisingly, exactly the inverse of these literals are what make up the final conflict clause. Now, if we unroll the implications until decision level 47 (but not the guess x42=FALSE), then with this clause added, variable x73 will propagate to TRUE automatically, essentially reversing the wrong guess \u0026ndash; but also giving a reason why it needs to be reversed.\nIf you enjoyed the previous graph, here is another to entertain you further:\nAnd its corresponding, not too obvious solution: Note that I was too lazy to draw cuts 10, 11 and 12 around the assignment x145=FALSE (at decision level 39). The UIP in this case is again at the decision variable, x164. If you are still interested, here are some other examples:\nA smaller one A larger one PS: Thanks to George Katsirelos for his help understanding this (disclaimer: all faults belong to me alone).\n","permalink":"https://www.msoos.org/2011/05/understanding-implication-graphs/","summary":"\u003cp\u003eHaving won the \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/results.html\"\u003eSAT Race\u003c/a\u003e with CryptoMiniSat, I think I can now confess that I still don\u0026rsquo;t understand conflict generation. So today, I sat down and I tried to understand it. The result is some fun code, a lot of reading, and great pictures. Let me share with you these auto-generated graphs \u0026ndash; the generator will be released with CMSat 3.0.0, so you will be able to generate them, too. These graphs show something called an \u0026lsquo;implication graph\u0026rsquo;, which is nothing more than a graphical way to show how propagations were made by the reasoning engine. For instance, if variable x1 and x2 are both FALSE, then clause \u0026lsquo;x1 V x2 V x3\u0026rsquo; will force x3 to be TRUE to satisfy the clause. Okay, so much for talk, let\u0026rsquo;s see the graphs!\u003c/p\u003e","title":"Understanding Implication Graphs"},{"content":"The HES'11 event was great: I had the pleasure of listening to some awesome presentations, and to meet some great people. The most interesting presentation from a non-technical point of view was the attacks at the automount feature of Linux, which everybody thinks is completely secure, but is in fact very flawed due to some buggy rendering libraries. It\u0026rsquo;s quite interesting that almost everyone thinks that their Linux installation is secure, when in fact if Linux was mainstream, viruses would be abound \u0026ndash; but Linux is only a minor player, so malicious software is rarely written for it.\nMy presentation is available here. I tried mostly to demonstrate how SAT solvers work as an element of the technique that can most amply described as:\nAs the graphics show, the SAT solver is in fact only one player in this environment. As it turns out, it is the very last step after obtaining the cipher, creating equations describing the cipher, and converting the ANF equations into CNF. The best way to create equations from the original cipher is to use the excellent Sage Maths library for this, a tutorial of which is here. Then, the ANF created by Sage can be transcribed into CNF using, e.g. the anf2cnf tool by Martin Albrecht and me. Finally, the CNF must be solved with a SAT solver to recover the key of the cipher. This last step can be carried out by many SAT solvers, such as lingeling or MiniSat, but I prefer CryptoMiniSat, since I am the main developer for that SAT solver, and it is also very convenient to use in this domain due to some domain-specific advantages it has over other solvers. The middle two steps of the diagram are all automated by the Grain-of-Salt tool if you don\u0026rsquo;t want to use Sage, and it also contains some example ciphers, so you don\u0026rsquo;t even have to do step no. 1 in case you wish to work on one of multiple pre-defined industrial ciphers.\nIn case you are interested in the visualisations I used during my presentation, here is the set of tools I used. For the 3D visualisation, I used 3Dvis by Carsten Sinz \u0026ndash; it\u0026rsquo;s a great tool to extract some structure from problems already in CNF. In case you still have the ANF, it contains more structure, though, and so it is more interesting to look at it that way. Unfortunately, that is rarely the case for typical SAT problems, and so one must often resort back to 3Dvis. For the example search tree, I used CryptoMiniSat 1.0 and gnuplot, and for the example real-time search, I used CryptoMiniSat 2.9.0, available from the same place. Unfortunately, CryptoMiniSat 2.9.0 cannot generate a search tree yet, but this eventually will be included, with time \u0026ndash; especially if you join the effort of developing the solver. We are always looking forward to people joining in and helping out with various issues from graph generation to algorithm performance tuning, or even just some fun research.\n","permalink":"https://www.msoos.org/2011/04/presentation-at-hackito-ergo-sum/","summary":"\u003cp\u003eThe \u003ca href=\"http://hackitoergosum.org/\"\u003eHES'11\u003c/a\u003e event was great: I had the pleasure of listening to some awesome presentations, and to meet some great people. The most interesting \u003ca href=\"http://www.youtube.com/watch?v=ovfYBa1EHm4\"\u003epresentation\u003c/a\u003e from a non-technical point of view was the attacks at the automount feature of Linux, which everybody thinks is completely secure, but is in fact very flawed due to some buggy rendering libraries. It\u0026rsquo;s quite interesting that almost everyone thinks that their Linux installation is secure, when in fact if Linux was mainstream, viruses would be abound \u0026ndash; but Linux is only a minor player, so malicious software is rarely written for it.\u003c/p\u003e","title":"Presentation at Hackito Ergo Sum"},{"content":" There is going to be a nice hacker conference in Paris real soon now: Hackito Ergo Sum, between the 7th and the 11th of April. There will be plenty of interesting talks, among them, I will also be presenting some fun crypto-breaking :) The schedule is here, I am scheduled for the first day, on Thursday at 11:30 AM. If you are in or near Paris, come around for the conference, I am sure it will be a really nice one :) If you are interested in meeting me, we can also meet in Paris, just drop me a mail, but better yet, come and chat with me at the conf, I will be there all day long.\nThe HES conference mainly focuses on attacks: against software, crypto, infrastructure, hardware, and the like. If you are interested what the current trend in attacking these systems is, and/or you are interested in making your organisation safer from these attacks, it\u0026rsquo;s a good idea to come and visit to get the hang of what\u0026rsquo;s happening. It\u0026rsquo;s also a great opportunity to meet all the organisations and people who are driving the change in making software and hardware systems more secure by demonstrating their weaknesses and presenting possibilities for securing them.\nMeet you at HES'11 ;)\n","permalink":"https://www.msoos.org/2011/03/come-to-hackito-ergo-sum11/","summary":"\u003cp\u003e\u003ca href=\"http://hackitoergosum.org/\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2011/03/hes2011.jpg\"\u003e\u003c/a\u003e There is going to be a nice hacker conference in Paris real soon now: \u003ca href=\"http://hackitoergosum.org/\"\u003eHackito Ergo Sum\u003c/a\u003e, between the 7th and the 11th of April. There will be plenty of interesting talks, among them, I will also be presenting some fun crypto-breaking :) The schedule is \u003ca href=\"http://hackitoergosum.org/schedule/\"\u003ehere\u003c/a\u003e, I am scheduled for the first day, on Thursday at 11:30 AM. If you are in or near Paris, come around for the conference, I am sure it will be a really nice one :) If you are interested in meeting me, we can also meet in Paris, just drop me a mail, but better yet, come and chat with me at the conf, I will be there all day long.\u003c/p\u003e","title":"Come to Hackito Ergo Sum'11"},{"content":"Let\u0026rsquo;s suppose you are looking to recover XORs. It\u0026rsquo;s fun to recover XORs, because you could try to XOR the XORs together to obtain new information, like this:\na⊕b⊕c=0a \\oplus b \\oplus c = 0a⊕b⊕c=0 a⊕d⊕b=0a \\oplus d \\oplus b = 0a⊕d⊕b=0 therefore, c⊕d=0c \\oplus d = 0c⊕d=0 therefore, c=dc = dc=d\nSimple XOR recovery The simplest way to recover an XOR clause is to look for clauses that encode it, which is the following set of clauses:\n¬a∨b∨c\\neg a \\vee b \\vee c¬a∨b∨c a∨¬b∨ca \\vee \\neg b \\vee ca∨¬b∨c a∨b∨¬ca \\vee b \\vee \\neg ca∨b∨¬c ¬a∨¬b∨¬c\\neg a \\vee \\neg b \\vee \\neg c¬a∨¬b∨¬c\nFinding such a set is not that hard: we need to first sort each clause according to its literals, then sort the list of clauses according to their sizes and variable contents and then go through the list of clauses linearly. If you think through the first two steps, you will see that it ensures that the above 4 clauses are next to each other in the list of clauses, making it trivial to find them.\nImproved XOR recovery There is only one small glitch with the algorithm above: other sets of clauses can also make up XORs. For example, this set of clauses: ¬a∨b∨c\\neg a \\vee b \\vee c¬a∨b∨c a∨¬b∨ca \\vee \\neg b \\vee ca∨¬b∨c a∨b∨¬ca \\vee b \\vee \\neg ca∨b∨¬c ¬a∨¬b\\neg a \\vee \\neg b¬a∨¬b\nNotice that all I took away was one literal from one clause. Now, if a CNF implies ¬a∨¬b\\neg a \\vee \\neg b¬a∨¬b it must surely also imply ¬a∨¬b∨¬c\\neg a \\vee \\neg b \\vee \\neg c¬a∨¬b∨¬c since this latter one is less stringent than the first one. So, we could easily have it inside our CNF, but we don\u0026rsquo;t for reasons of lazyness: who wants to keep around data that is implied by unit propagation already? However, keeping in mind that the second, less stringent clause is implied by the first one is important: it could lead to the discovery of more XORs.\nResults Let\u0026rsquo;s move on to the magical territory of practical SAT solving. Let\u0026rsquo;s first take a typically industrial problem, UTI-20-10p0:\n$./cryptominisat_old UTI-20-10p0.cnf [...] c Finding non-binary XORs: 0.10 s (found: 0, avg size: -nan) The old, 2.9.0 CryptoMiniSat seems to have no luck at finding any XOR clauses. This is very typical: industrial instances seem not to contain any XOR clauses at all. Let\u0026rsquo;s look at the new algorithm now:\n$./cryptominisat_new UTI-20-10p0.cnf [...] c XOR finding finished. Num XORs: 9288 All right, that seems better.\nEdited to add: Thanks to Vegard Nossum for telling me something was odd with XOR recovery. As usually is the case, answering a question is much easier than knowing what question to ask.\nEdited to add2: The above algorithm can be easily improved by using cached literals and stamping.\n","permalink":"https://www.msoos.org/2011/03/recovering-xors-from-a-cnf/","summary":"\u003cp\u003eLet\u0026rsquo;s suppose you are looking to recover XORs. It\u0026rsquo;s fun to recover XORs, because you could try to XOR the XORs together to obtain new information, like this:\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ea\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003eb\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003ec\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ea \\oplus b \\oplus c = 0\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ea\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.7778em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003eb\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ec\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ea\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003ed\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003eb\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ea \\oplus d \\oplus b = 0\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ea\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.7778em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ed\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003eb\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\ntherefore,\n\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ec\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003ed\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ec \\oplus d = 0\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ec\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ed\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\ntherefore,\n\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ec\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmi\u003ed\u003c/mi\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ec = d\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ec\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ed\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003ch3 id=\"simple-xor-recovery\"\u003eSimple XOR recovery\u003c/h3\u003e\n\u003cp\u003eThe simplest way to recover an XOR clause is to look for clauses that encode it, which is the following set of clauses:\u003c/p\u003e","title":"Recovering XORs from a CNF"},{"content":"I have submitted three versions of CryptoMiniSat to the 2011 SAT Competition, all available here. The releases are commonly called \u0026ldquo;Strange Night\u0026rdquo;, after the music track of the same name. Inside the archive you will find 5 binaries and a PDF description. The five binaries are made up of two single-threaded, two multi-threaded, and a unified single- and multi-threaded binary. This latter is called techdemo, as it is more of a technological demonstrator than anything else, and was developed in collaboration with George Katsirelos and Laurent Simon. All versions are collaborative, however, as they all have the hands of some people from the CryptoMiniSat development mailing list on them.\nTo be honest, I am not overly optimistic of these binaries, especially since I couldn\u0026rsquo;t get the 3.0 version of CryptoMiniSat ready for the competition, on which I have been working on the past two months. I have tried to backport some features to the 2.9.0 branch to make these releases, and so the resulting executables are pretty unstable. The techdemo version is a broken 3.0 release, as it is missing the signature feature of fully shared clauses between threads. Since I have finally obtained a 4-core CPU \u0026ndash; with hyper-threading for 8 \u0026ldquo;independent\u0026rdquo; threads \u0026ndash; I am all the more optimistic about a fully-shared scheme. The upcoming 3.0 release will be specifically made to work in multi-threaded environments, and will suffer if launched in single-threaded mode. This architectural decision was made because multi-threading nowadays no longer seems optional: it\u0026rsquo;s a must. On the CryptoMiniSat mailing list, some people are reporting performance on 64-core machines \u0026ndash; optimising for single-threaded environment (and having multi-threading as an afterthought) in these times seems like a broken approach.\nFor those interested in the actual sourcecode of what has been submitted, everything is available from GIT, as usual:\nStrange Night1 - single-threaded Strange Night1 - multi-threaded Strange Night2 - single-threaded Strange Night2 - multi-threaded Tech Demo Since these are pretty unstable, I wouldn\u0026rsquo;t use them in a production environment\u0026hellip; happy bug-hunting ;)\n","permalink":"https://www.msoos.org/2011/03/cryptominisat-in-sat-competition11/","summary":"\u003cp\u003eI have submitted three versions of \u003ca href=\"http://gitorious.org/cryptominisat/\"\u003eCryptoMiniSat\u003c/a\u003e to the 2011 \u003ca href=\"http://www.satcompetition.org/2011/\"\u003eSAT Competition\u003c/a\u003e, all available \u003ca href=\"https://gforge.inria.fr/frs/download.php/28312/StrangeNight.tar.gz\"\u003ehere\u003c/a\u003e. The releases are commonly called \u0026ldquo;Strange Night\u0026rdquo;, after the music track of the same \u003ca href=\"http://www.youtube.com/watch?v=jqmT7Fpfhp4\"\u003ename\u003c/a\u003e. Inside the archive you will find 5 binaries and a PDF description. The five binaries are made up of two single-threaded, two multi-threaded, and a unified single- and multi-threaded binary. This latter is called \u003cem\u003etechdemo\u003c/em\u003e, as it is more of a technological demonstrator than anything else, and was developed in collaboration with \u003ca href=\"http://www.cs.toronto.edu/~gkatsi/\"\u003eGeorge Katsirelos\u003c/a\u003e and \u003ca href=\"http://www.lri.fr/~simon/\"\u003eLaurent Simon\u003c/a\u003e. All versions are collaborative, however, as they all have the hands of some people from the CryptoMiniSat development mailing \u003ca href=\"http://lists.gforge.inria.fr/pipermail/cryptominisat-devel/\"\u003elist\u003c/a\u003e on them.\u003c/p\u003e","title":"CryptoMiniSat in SAT Competition'11"},{"content":" Lately I had the pleasure of visiting Linz, Armin Biere\u0026rsquo;s workplace, where I gave a quick talk on SAT solver architectures. To me, it was really interesting to think through that presentation \u0026mdash; not because it was entirely new or exciting, but because it recapped on many issues that have been bothering me lately. Namely, that it\u0026rsquo;s difficult to make a really versatile SAT solver, because the low-level choices that must be made (e.g. watchlist scheme) determines so many things when one must make higher-level architectural decisions such as clause sharing or even something as simple as hyper-binary resolution. As for this latter, thanks to Armin Biere\u0026rsquo;s thoughts I have finally managed to realise why my hyper-binary resolution was so slow: I lately took the decision not to fully propagate binary clauses before propagating normal (i.e. larger) clauses, which meant that doing hyper-binary resolution was much slower as I had to re-calculate the binary graph. The fact of not fully propagating binary clauses before normal clauses seemed also to influence my much higher-level choice of using cached implications, as they (intuitively, and also in practice) help much more if binary clauses are not fully propagated before normal clauses. This latter influence is interesting to think through, as something this trivial shouldn\u0026rsquo;t \u0026ndash; at least in principle \u0026ndash; influence such a high-level decision.\nAlso thanks to Armin Biere, I have managed to grasp a better understanding of lingeling and its superior watchlist scheme. Some of the architectural elements of lingeling\u0026rsquo;s watchlist scheme are really interesting, and when they get published I will definitely port some of them to CryptoMiniSat. It seems to use much less space, and stores information in a more cache-friendly manner, aiding the processor in its job. A related, interesting pointer that I have learnt is this paper that originally introduced blocking literals, but also talks about a range of other ideas that can help. All in all, it was great to visit Linz and the group of Armin Biere, as I have managed to learn a lot from him and his colleagues.\n","permalink":"https://www.msoos.org/2011/02/visiting-linz/","summary":"\u003cp\u003e\u003ca href=\"/wordpress/wp-content/uploads/2011/06/Linz.png\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2011/06/Linz.png\"\u003e\u003c/a\u003e Lately I had the pleasure of visiting Linz, Armin Biere\u0026rsquo;s workplace, where I gave a quick \u003ca href=\"/wordpress/wp-content/uploads/2011/02/SAT_solver_architectures_Linz.pdf\"\u003etalk\u003c/a\u003e on SAT solver architectures. To me, it was really interesting to think through that presentation \u0026mdash; not because it was entirely new or exciting, but because it recapped on many issues that have been bothering me lately. Namely, that it\u0026rsquo;s difficult to make a really versatile SAT solver, because the low-level choices that must be made (e.g. watchlist scheme) determines so many things when one must make higher-level architectural decisions such as \u003ca href=\"/changing-the-watchlist-scheme\"\u003eclause sharing\u003c/a\u003e or even something as simple as \u003ca href=\"/hyper-binary-resolution-i-was-wrong-again\"\u003ehyper-binary resolution\u003c/a\u003e. As for this latter, thanks to Armin Biere\u0026rsquo;s thoughts I have finally managed to realise why my hyper-binary resolution was so slow: I lately took the decision not to fully propagate binary clauses before propagating normal (i.e. larger) clauses, which meant that doing hyper-binary resolution was much slower as I had to re-calculate the binary graph. The fact of not fully propagating binary clauses before normal clauses seemed also to influence my much higher-level choice of using cached implications, as they (intuitively, and also in practice) help much more if binary clauses are not fully propagated before normal clauses. This latter influence is interesting to think through, as something this trivial shouldn\u0026rsquo;t \u0026ndash; at least in principle \u0026ndash; influence such a high-level decision.\u003c/p\u003e","title":"Visiting Linz"},{"content":"In this post I will try to explain how locality of reference could be exploited by grouping operations that access different memory locations. In the SAT solver program I write, there is a loop that does a something called propagation. The goal of propagation is to set a number of variables to a given value through a pretty cache-intensive process. While doing this, as the variables are set, some statistics are calculated. For example, I used to have something like this called for every variable set:\nenqueueNewFact(Literal lit, PropagatedBy someData) { trail.push_back(lit.var()); value[lit.var()] = lit.sign(); agility *= conf.agilityG; if (varPolarity[lit.var()] != lit.sign()) agility += 0.0001; varPolarity[lit.var()] = lit.sign(); varSet[lit.var()]++; level[lit.var()] = getLevel(); } The problem with this function is that it is accessing a lot of data pieces: trail[], value[], level[], varPolarity[] and varSet[]. All of these must be in cache for these to be updated, and if they aren\u0026rsquo;t, they must be pulled in from lower levels of cache or the main memory. Since enqueuNewFact() is called often, these are mostly in cache all the time, taking the space away from what really needs it: the data used during the propagate() routine.\nWhat I have just recently realised is that I don\u0026rsquo;t use the values of level[], varPolarity[], varSet[] or agility at all during the propagate() routine. Instead, they are used when the recursive calling of propagate() has finished, and a certain technical point (called a conflict) is reached. If this is indeed the case, why are we updating them all the time, immediately when enqueueNewFact() is called? If you look at the code, due to various reasons, we must save a trail (called, conveniently, trail[]) of what we have done. This trail contains all the information needed by all the statistics-update functions: var() and the sign(), both contained in Lit is all that\u0026rsquo;s necessary.\nSo, I have made a new function: delayedUpdate() that calculates all the statistics just when it is needed: when a conflict is reached. It has a simple state that saves at what trail position it was called last time, lastDelayedEnqueueUpdate. The default is trail level 0, and then whenever we reach a conflict, we update it, once the stats are calculated:\ndelayedEnqueueUpdate() { int pseudoLevel = lastDelayedEnqueueUpdateLevel; for (int i = lastDelayedEnqueueUpdate; i \u0026lt; trail.size(); i++) { Lit lit = trail[i]; agility *= conf.agilityG; if (varPolarity[lit.var()] != lit.sign()) agility += 0.0001; varPolarity[lit.var()] = lit.sign(); varSet[lit.var()]++; if (trail_lim[pseudoLevel] == i) pseudoLevel++; level[p.var()] = pseudoLevel; } lastDelayedEnqueueUpdate = trail.size(); lastDelayedEnqueueUpdateLevel = decisionLevel(); } This code, apart from the pseudoLevel and lastDelayedEnqueueUpdateLevel (both of which are SAT solver technicalities) is rather easy to understand. Basically, we take the last position we updated last time, lastDelayedEnqueueUpdate, and we work our way from there to the end, trail.size(). Once we have worked our way through, we set lastDelayedEnqueueUpdate to the current point, trail.size().\nAll this seems useless if we don\u0026rsquo;t take cache usage into consideration: we are not saving any CPU instructions. If anything, we add CPU instructions to execute, as we now need to execute an extra for loop ( propagate() is essentially a recursive for loop). However, from a cache usage point of view, we are saving a lot. When doing propagation, the propagate() routine can have all the cache it needs. Then, when that cache-intensive process has finished, we pull in a set of arrays, varPolarity[], varSet[], level[], update them all in one go, and then continue operation.\nWe have managed to group operations according to what memory pieces they are using\u0026amp;updating. This makes our program more cache-friendly, which almost always leads to a measurable speed increase.\n","permalink":"https://www.msoos.org/2011/02/delayed-updates/","summary":"\u003cp\u003eIn this post I will try to explain how \u003ca href=\"http://en.wikipedia.org/wiki/Locality_of_reference\"\u003elocality of reference\u003c/a\u003e could be exploited by grouping operations that access different memory locations. In the SAT solver program I write, there is a loop that does a something called propagation. The goal of propagation is to set a number of variables to a given value through a pretty cache-intensive process. While doing this, as the variables are set, some statistics are calculated. For example, I used to have something like this called for every variable set:\u003c/p\u003e","title":"Delayed updates"},{"content":"All right, so I am not so cool because I work on weekends, but I got this new watchlist scheme implemented. First off, let me say it was relatively easy to implement, which is a testament to the extensibility of CryptoMiniSat: it only took me ~4 hours to get it done. Secondly, I realised that I have forgotten XOR clauses when I thought through the new scheme. I used to store the current value of the XOR clause at the XOR clause itself (using the sings of the literals, being the hacker I am), and update it at every call to propXorClause(). Since we need to keep XOR clauses static just like normal clauses, this is no longer possible, so a separate data-structure needs to be built up for this. However, it won\u0026rsquo;t need too many updates, so all is fine, but it does make things a tad more complicated.\nWhen first implemented, the new scheme performed worse than the normal one \u0026ndash; much worse. We lost ~20% in terms of time. I never really give up on my ideas, however, so I started thinking which are the advantages of this new scheme, and how could we make them work for us? First of all, since the watchlists are now more expensive to go through, we might as well spend more time at the clause, looking for a watch that is not likely going to trigger again. In other words, when we are at the clause, and looking for a new watch, don\u0026rsquo;t just look for a literal that is either Undefined or True: strongly prefer to find one that is True. The idea here is that if we set the watch to be a literal that is True, during backtrack we might still have that literal be True (as we might not have undone that assignment), and so we won\u0026rsquo;t have to bother propagating it next time. This leads to more time going though the clause, but once the clause is already in the cache, going through it takes almost no time at all. This gained about ~5% of time: good, but not enough.\nFor the next idea, we have to notice that we are going through each clause from the beginning, and the literals there don\u0026rsquo;t change, in contrast to the scheme where we constantly move literals to the beginning of the clause. In almost every modern solver, we have something called polarity caching: we memorise what was the last polarity (True or False) of every variable, and then when making a branch next time, we take the cached polarity. In CryptoMiniSat there is a slight salt added, so with a low possibility we take the opposite branch, but still: the cached polarity is a pretty good indicator whether a literal will be True or False. If this is indeed the case, and we are preferably searching for literals that are True at the beginning of the clause\u0026hellip; why not move the literals that have a True cached polarity to the beginning of the clause? So, I added a trivial (~20 line) algorithm that is executed very infrequently (~once per 100'000 confl.) to do this. An interesting property of the new watchlist scheme is that this can be done without detaching and reattaching the clauses. Once implemented, the time to solve decreased by ~13%. Overall, then, the speed of the new watchlist scheme is close to the original.\nThe advantages of this new sheme are multifold. Since we are only content when finding a True watched literal in the clause, we decrease the overall number of memory requests per thread, which should help the totality of threads make less memory requests, leading to less strain on the memory architecture. Not to mention that we really don\u0026rsquo;t touch the clauses, so write-back to memory is dramatically decreased, by probably 80% or more. And finally, we can share the clauses, leading to less overall memory fetches.\nThe only drawback of this new scheme seems to be that we cannot optimise for every thread: cached polarities are stored on a per-thread basis. However, one would expect that most of the time the cached polarities of the different threads are close. Therefore, this should work relatively well. Also, we could do voting for polarities among threads, and then sort literals in the clauses according to the votes cast \u0026ndash; we would then optimise for the whole set of threads instead of only the master thread.\nWhile doing the above, I have also played around with OProfile that is a Linux tool to tell (among other things) an approximation of the number of L2 cache misses by a program. This helped me put the right prefetch builtins at the right places, and the number of cache misses is now half of that without prefetch instructions (for both watchlist schemes). CryptoMiniSat 2.9.0 had some prefetch instructions added at the very last moment, but they weren\u0026rsquo;t placed optimally enough. The new way they are organised is much better, leaving more time for the CPU to prefetch the lines (which can take lots of cycles).\nPS: Current architecture doesn\u0026rsquo;t allow CryptoMiniSat to share clauses, but even this way multi-threading is already faster by ~5% due to less memory write-back and less memory contention due to optimised watched literal picking.\n","permalink":"https://www.msoos.org/2011/01/on-the-new-watchlist-scheme/","summary":"\u003cp\u003eAll right, so I am not so cool because I work on weekends, but I got \u003ca href=\"/changing-the-watchlist-scheme\"\u003ethis\u003c/a\u003e new watchlist scheme implemented. First off, let me say it was relatively easy to implement, which is a testament to the extensibility of CryptoMiniSat: it only took me ~4 hours to get it done. Secondly, I realised that I have forgotten XOR clauses when I thought through the new scheme. I used to store the current value of the XOR clause at the XOR clause itself (using the sings of the literals, being the hacker I am), and update it at every call to propXorClause(). Since we need to keep XOR clauses static just like normal clauses, this is no longer possible, so a separate data-structure needs to be built up for this. However, it won\u0026rsquo;t need too many updates, so all is fine, but it does make things a tad more complicated.\u003c/p\u003e","title":"On the New Watchlist Scheme"},{"content":"After a long break, CryptoMiniSat 2.9.0 has finally been released. The Windows executables need this to work, and the Linux binaries need a recent (\u0026gt;=2.6.26) kernel version. The program has evolved substantially since the last release \u0026ndash; more than half of its codebase has been changed. It now works in multi-threaded mode, and uses lazy cached implications for all sorts of interesting purposes from simple transitive on-the-fly self-subsuming resolution to very efficient literal dependency analysis. Currently, the program solves ~225 problems from the 2009 SAT Competition examples given the same time and similar computing power. This is a nice improvement over other SAT solvers such as MiniSat (205), PrecoSat (210) or lingeling (207).\nIntensive testing has been carried out on this version of the program, to the extent of finding and identifying a new and unknown gcc bug affecting all gcc versions 4.5.0 and later. Many have played part in finding this and other bugs, including, but not limited to, Martin Maurer, Vegard Nossum, Oliver Kullmann, Robert Aston, and others. This release has been made possible thanks to them.\nI hope this version of the code will be useful to many, not only end users but also researchers. In fact I decided to release this version (relatively) early to let researchers merge their changes for the upcoming SAT Competition 2011. I am very interested in any and all versions of CryptoMiniSat that will be submitted to the competition. In case you personally want to change it and find something difficult to understand, just drop a mail to the nowadays very active development mailing list. With this release, I can confidently say that CryptoMiniSat is becoming not only a programming project but also a community. If you feel like you could contribute, or you are simply interested in what is going on, join us.\nAs for the technical details, the new CryptoMiniSat uses OpenMP for mutli-threading which means it is fully platform-independent. During multi-threading we share unitary and binary clauses between threads \u0026ndash; the latter is checked for redundancy using lazy cached implications. We use implicit binary clauses, which don\u0026rsquo;t help as much in terms of memory as I have hoped, but they help immensely for certain operations, in particular with subsumption checks. Literal dependencies are now calculated using the lazy cached implications and the dominating literal with the largest tree is selected as dominant literal for all literals: when picking variables, we pick the dominating literal 50% of the time instead of the original literal. Variable elimination heuristics have also been highly tuned thanks to the much better at-hand statistics due to implicit binary clauses.\nUnfortunately, this version doesn\u0026rsquo;t offer all the things I wanted it to offer: multi-threaded library interface, extended resolution, distributed solving through MPI, unified restart strategy, and others. All of these (except MPI), and more are however available from the public GIT repository. They work relatively stable, but have a terrible speed: the version with all of these only solves ~214 problems from those above. Therefore, I will personally submit version 2.9.0 to the SAT Competition unless some grave bug is found inside. I might also submit a corrected version of the upcoming 3.0.0 release as well, but as it usually takes a month to tune the solver, and I am currently very busy with some great projects at my new workplace, so a 3.0.0 version probably won\u0026rsquo;t happen until the deadline.\nI hope you will enjoy this new version of CryptoMiniSat! In case of questions, problems or bugs, please contact either me, or the development mailing list and join in to collaborate :)\n","permalink":"https://www.msoos.org/2011/01/cryptominisat-2-9-0-released/","summary":"\u003cp\u003eAfter a long break, CryptoMiniSat 2.9.0 has finally been \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\u0026amp;release_id=5810\"\u003ereleased\u003c/a\u003e. The Windows executables need \u003ca href=\"http://www.google.com/search?q=Microsoft+Visual+C%2B%2B+2008+SP1+Redistributable+Package\"\u003ethis\u003c/a\u003e to work, and the Linux binaries need a recent (\u0026gt;=2.6.26) kernel version. The program has evolved substantially since the last release \u0026ndash; more than half of its codebase has been changed. It now works in multi-threaded mode, and uses \u003ca href=\"/caching\"\u003elazy cached implications\u003c/a\u003e for all sorts of interesting purposes from simple \u003ca href=\"/transitive-otf-self-subsuming-resolution\"\u003etransitive on-the-fly self-subsuming resolution\u003c/a\u003e to very efficient \u003ca href=\"/dependent-literals\"\u003eliteral dependency analysis\u003c/a\u003e. Currently, the program solves ~225 problems from the \u003ca href=\"http://www.cril.univ-artois.fr/SAT09/\"\u003e2009 SAT Competition\u003c/a\u003e examples given the same time and similar computing power. This is a nice improvement over other SAT solvers such as \u003ca href=\"http://minisat.se/MiniSat.html\"\u003eMiniSat\u003c/a\u003e (205), \u003ca href=\"http://fmv.jku.at/precosat/\"\u003ePrecoSat\u003c/a\u003e (210) or \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e (207).\u003c/p\u003e","title":"CryptoMiniSat 2.9.0 released"},{"content":"Okay, what if we changed the watchlist scheme\u0026hellip; a bit? The way the watchlist scheme operates in SAT solvers is the following. We have a set of literals lit1, lit2, lit3, lit4 that defines the clause we want to be watched for propagation and conflict. We take two literals from this set of literals, and put them in a datastructure. It\u0026rsquo;s not important which ones we take, but we have to know which are the ones we took. So, we take the 1st and the 2nd (because we are lazy), and we put them in a set of lists called the watchlists. We now have a pointer to the clause in watchlist[~lit1] and in watchlist[~lit2], where ~ is the binary negation. If we now set lit1 = false we have to have a look at the clauses in watchlist[~lit1], see if any of the clauses forces a propagation. If not, then we remove the corresponding lit1 from the watchlist, find another literal that is unset, e.g. lit3, and put that into the watchlist[~lit3]. It is important that lit3 must not be lit1 or lit2. Obviously, we know what lit1 is (we are visiting its watchlist, after all), but how could we know what lit2 is? Well, we always update the clause such that lit1 and lit2 are the first two literals. We do this for every clause in every watchlist, and until a conflict is found, or all clauses are satisfied.\nSo, why is this inefficient? Well, what needs to be noticed, is that we updated the clause non-stop in order to keep in mind lit1 and lit2. We can implement this by changing the order of literals (that\u0026rsquo;s how it\u0026rsquo;s done in most cases), or by updating some data in the clause. However, this needs an update of the clause, and consequently of the whole cacheline on which the clause (and probably other clauses, as these are memory-packed) reside. Let\u0026rsquo;s say the average clause length is 10, but maximum clause length is 2^16. Since the maximal literal length is 32 bits, an average clause, with all the extra info it needs to keep, is around 10*32+32+32= 384 bits long. Cache line size for a Core i7 processors is 64 Bytes (=512bits), though the new architectures I believe are bumping this to 128 Bytes. We are therefore asking the CPU to grab 64Bytes from memory, store it in the CPU cache, and then put the changed value back into main memory \u0026ndash; as the cache is woefully small to keep all the clauses we will visit. If you take a CPU with 6 cores and try to run this algorithm, you are probably looking at a memory bandwidth nightmare. The clauses cannot be shared, because updating the lit1 and lit2 positions is not an option, as these would be different for each thread.Furthermore, the CPU is not only taking data from main memory, but also putting back data into main memory at an astonishing rate.\nLet\u0026rsquo;s take a Core i7 processor off the shelf, and see how its architecture looks like. We have 1MByte of L2 cache for each core, and we have 8MByte of shared L3 cache for all the CPU cores. This is like a finger pointing at us: have a big piece of shared memory that is constant and can be shared, while keep a much smaller piece of thread-local memory. Also: please lighten up the load on the memory access sub-architecture, as that isn\u0026rsquo;t going to keep up with all the 6 cores churning through the clauses. Well, a interesting solution is then to split each clause into two pieces: one to store which is lit1 and lit2, and one that stores the literals and the extra information. The first piece, let\u0026rsquo;s call this threadContext stores the point of lit1 and lit2, each of which is 16 bits (the maximal size of the clause), so 4 bytes in total. The clause will then not need any update at all. An average problem instance is typically beaten down to a size of \u0026lt;300'000 clauses by CryptoMiniSat in \u0026lt;500 seconds. Optimally, we would like to access these clauses from main memory or L3 cache (this latter is a dream, really), and keep their threadContext in the L2 cache of the core. So, this latter is 300'000*4=1.2MByte for a typical problem. There are also some other things to keep in L2, such as current variable assignment, and the current trail of assignments, but each of these should be much smaller. The total would probably be ~2MByte. Oh well, we didn\u0026rsquo;t fit them inside the 1MByte of L2 cache, but still. The net effect of this change should be positive. Furthermore, even if we only use one core, more memory bandwidth should be available, as we don\u0026rsquo;t move that much (or hardly any) information back into the main memory any more.\nSo why wouldn\u0026rsquo;t this idea work? Well, for starters, we would access two pieces of memory whenever visiting a clause: instead of only accessing the clause, we now also have to access threadContext to be able to work with the clause. I am willing to argue that this is not a problem at all. The reason is really simple: since threadContext is small, and since it is being accessed all the time, it will surely be in cache, probably L2, maybe L3. However, the clause itself is almost surely to be in main memory, but if not, then in L3. All we need to do, is to emit a non-blocking memory-prefetch assembly instruction for both entities when we want to treat the clause, and then work with the clause. Since threadContext is almost sure to arrive earlier to the CPU than the clause itself, and since these can be done in parallel, the speed difference will be either negligible or nonexistent. The other argument we could come up with is related to the following design feature: swapping the literals lit1 and lit2 to be always at the head of the clause allows the CPU to travel through less of the clause and carry out less instructions (less checking for lit1\u0026amp;lit2). This could mean less cachelines needed, and less instructions carried out. Since memory is the bottleneck, number of instructions is not of any real concern. More cachelines are more of a problem, but if we access the right literal at the right point in the clause, then parts of the clause might not be needed, and we would only need to grab more cachelines than with the original scheme if we happen to roll around the clause: starting at the middle, reaching the end and not finding a new unassigned literal, having to go to the beginning. But this shouldn\u0026rsquo;t occur too often, and the clause might be on the same cacheline anyway (with \u0026lt;50% chance for a 10-long clause and a 128Byte cachline).\nThe last, and most burning question is: will this ever be implemented? Well, if we are really to scale to 6- and 12-core CPUs, I think eventually a better way to share cache will be needed. This is just one way of doing it \u0026ndash; probably a crazy complicated and inefficient way at that. Only a good implementation can tell if this approach is worthwhile to pursue, and the 2011 SAT Competition is far too close for me to get this right. Oh well, let\u0026rsquo;s get back to removing that \u0026ldquo;last\u0026rdquo; bug in CryptoMiniSat 2.9.0\u0026hellip;.\nEdited to Add(21/01/2011): I forgot that watchlists also need to be in cache. However, most of the watchlists needed can be prefetched: when a literal is propagated, we can prefetch the corresponding watchlist immediately. The only problem is when a watchlist is needed because a clause\u0026rsquo;s watched literal is changed. This poses a headache that I haven\u0026rsquo;t yet thought through.\n","permalink":"https://www.msoos.org/2011/01/changing-the-watchlist-scheme/","summary":"\u003cp\u003eOkay, what if we changed the \u003ca href=\"http://www.ece.ucsb.edu/bears/class/256bd/RCFB256B3450-Zchoff.pdf\"\u003ewatchlist scheme\u003c/a\u003e\u0026hellip; a bit? The way the watchlist scheme operates in SAT solvers is the following. We have a set of literals \u003ccode\u003elit1, lit2, lit3, lit4\u003c/code\u003e that defines the clause we want to be watched for propagation and conflict. We take two literals from this set of literals, and put them in a datastructure. It\u0026rsquo;s not important which ones we take, but we have to know which are the ones we took. So, we take the 1st and the 2nd (because we are lazy), and we put them in a set of lists called the watchlists. We now have a pointer to the clause in \u003ccode\u003ewatchlist[~lit1]\u003c/code\u003e and in \u003ccode\u003ewatchlist[~lit2]\u003c/code\u003e, where \u003ccode\u003e~\u003c/code\u003e is the binary negation. If we now set \u003ccode\u003elit1 = false\u003c/code\u003e we have to have a look at the clauses in \u003ccode\u003ewatchlist[~lit1]\u003c/code\u003e, see if any of the clauses forces a propagation. If not, then we remove the corresponding \u003ccode\u003elit1\u003c/code\u003e from the watchlist, find another literal that is unset, e.g. \u003ccode\u003elit3\u003c/code\u003e, and put that into the watchlist[~lit3]. It is important that \u003ccode\u003elit3\u003c/code\u003e must not be \u003ccode\u003elit1\u003c/code\u003e or \u003ccode\u003elit2\u003c/code\u003e. Obviously, we know what \u003ccode\u003elit1\u003c/code\u003e is (we are visiting its watchlist, after all), but how could we know what \u003ccode\u003elit2\u003c/code\u003e is? Well, we always update the clause such that \u003ccode\u003elit1\u003c/code\u003e and \u003ccode\u003elit2\u003c/code\u003e are the first two literals. We do this for every clause in every watchlist, and until a conflict is found, or all clauses are satisfied.\u003c/p\u003e","title":"Changing the Watchlist Scheme"},{"content":"One of the most challenging problems when trying to describe cryptographic primitives in SAT solvers is the XOR function that is used very often in cryptography. MiniSat (and most DPLL-based SAT solvers) only understands the Conjunctive Normal Form, or CNF for short. However, to describe a XOR function in CNF you need to have 2^{n-1} clauses, where n is the size of your XOR function. To overcome this exponential explosion, XOR functions are cut up into manageable sizes (6-7) and then implemented in 2^5\u0026ndash;2^6 clauses each. This is not only tedious, uses a lot of memory and slow, but also makes it impossible to do interesting operations on XORs directly, such as XOR-ing two XORs to knock out variables. Note that CryptoMiniSat 2.0 and above can recover the XOR clauses from the CNF, but it is still of considerable interest in using the XOR notation described below.\nIn CryptoMiniSat, the DIMACS standard format is augmented with the following extension: having an \u0026ldquo;x\u0026rdquo; in front of a line makes that line an XOR clause. For instance, the line\nx10 2 7 0\nmeans that\nv10 + v2 + v7 = true (where + is the binary XOR)\nIf we wish to invert the xor-clause, it is sufficient to invert one of the variables:\nx10 2 -7 0\nhas now the XOR is inverted (i.e. it is equated to false):\nv10 + v2 + v7 = false (where \u0026ldquo;+\u0026rdquo; is the binary XOR)\nNaturally, if two variables are inverted, their inversions cancel each other out, and the XOR is equated to true. There is no need to cut up XOR clauses to smaller sizes, they can be of any length. Using this representation instead of the cut-and-convert-CNF will give you approximately 2x the speed, lots of memory savings and a potentially more understandable CNF file.\n","permalink":"https://www.msoos.org/xor-clauses/","summary":"\u003cp\u003eOne of the most challenging problems when trying to describe cryptographic primitives in SAT solvers is the XOR function that is used very often in cryptography. MiniSat (and most DPLL-based SAT solvers) only understands the \u003ca href=\"http://en.wikipedia.org/wiki/Conjunctive_normal_form\"\u003eConjunctive Normal Form\u003c/a\u003e, or CNF for short. However, to describe a XOR function in CNF you need to have 2^{n-1} clauses, where n is the size of your XOR function. To overcome this exponential explosion, XOR functions are cut up into manageable sizes (6-7) and then implemented in 2^5\u0026ndash;2^6 clauses each. This is not only tedious, uses a lot of memory and slow, but also makes it impossible to do interesting operations on XORs directly, such as XOR-ing two XORs to knock out variables. Note that CryptoMiniSat 2.0 and above can recover the XOR clauses from the CNF, but it is still of considerable interest in using the XOR notation described below.\u003c/p\u003e","title":"XOR clauses"},{"content":" Timings from the article \u0026ldquo;Attacking Bivium Using SAT Solvers\u0026rdquo;. The authors didn\u0026rsquo;t seem to have randomised the problems enough: the time to solve should increase exponentially, but instead it goes up and down like a roller coaster\nVegard Nossum asked me about the varying time it took for CryptoMiniSat to solve a certain instance that was satisfiable. This inspired me to write an overly long reply, which I think might interest others. So, why does the solving time vary for a specific instance if we permutate the clauses? Intuitively, just by permutating the clauses, the problem itself doesn\u0026rsquo;t get any easier or harder, so why should that make any difference at all? I will now try to go through the reasons, though they can almost all be summed up as follows: the SAT solver has absolutely no clue what it is solving, and so to solve a problem, it relies on heuristics and randomisation, both of which are influenced by its starting seed, which in turn is influenced by the order of the clauses in the CNF file. And now on to the long explanation.\nLet\u0026rsquo;s divide problems into two categories: satisfiable and unsatisfiable instances. First, let me talk about satisfiable instances. Let\u0026rsquo;s suppose that we have been solving the problem for some time, and we have connected the dots (variables) well enough through learnt clauses. All that the SAT solver is waiting for is a good guess to set 3-4 variables right, and then it will propagate all variables to the right setting to satisfy all clauses. The problem is therefore to get to the point of only needing to guess 3-4 variables, i.e. to connect the dots, which we do through resolution. We can sacrifice some or all of dot-connecting (i.e. resolution) with some more guessing, and this can in fact be coded down by simply foregoing some of the conflict analysis we do. In the extreme case, all conflict analysis can be disabled, and then the solver would not restart its search. The solver would in essence be brute-forcing the instance through BCP (boolean constraint propagation). It is easy to see why this latter is prone to variation: depending on the ordering of the variables in the search tree, the tree could be orders of magnitude smaller or larger, and the first solution can be at any point in the search tree, essentially at a random place.\nIf we decide to carry out resolution for satisfiable problems to counter the problem of the variation of the search-tree, it is interesting to realise the following: in most cases, we can not forgo guessing. The reason is simple yet leads to quite interesting properties. Essentially, a SAT instance can have multiple solutions. If there are two solutions, e.g. 01100... and 10011... i.e. the solutions are the complete inverse of one another, then the SAT solver will not be able to prove any variable to any value. The best it could do is to create binary clauses, in the example case for instance\nvar1=0 -\u0026gt; var2=1, var3=1, var4=0... and var1=1 -\u0026gt; var2=0, var3=0, var4=1...\nIf we do enough resolutions, the \u0026ldquo;guessing\u0026rdquo; part will eventually become a solution-selector, i.e. it will select a solution from the set of available solutions. If there are 2^20, evenly distributed in the search space, we might need to set 20 variables before a solution is found through a simple application of BCP. Naturally, SAT solvers don\u0026rsquo;t normally do this, as they are content in finding one satisfying assignment, reporting that to the user, and exiting. It would be interesting to know the average remaining number of variables that needed to be guessed to solve the solution at the point the SAT solver actually found the solution, but this has not been done yet as far as I know. Then, we would know the trade-off the SAT solver employs between resolution and searching when solving satisfiable instances.\nAll right, so much for satisfiable instances. What happens with UNSAT instances? Well, the solver must either go through the whole tree and realise there is no solution, or do resolution until it reaches an empty clause, essentially building a resolution tree with an empty clause at its root. Since both of these can be done at the same time, there is a similar trade-off as above, but this time it\u0026rsquo;s somewhat upside-down. First of all, the search tree can be smaller or larger depending on the ordering of the variables (as before), and secondly, the resolution tree can be smaller or larger depending on the order of resolutions. The minimal resolution tree is (I believe) NP-hard to find, which doesn\u0026rsquo;t help, but there is at least a minimum resolution tree that limits us, and there is a minimum search tree which we must go through completely, that limits us. So, in contrast to finding satisfying solutions, both of these are complete in some sense, which should make searching for them robust in terms of speed. Finding a satisfying solution is not complete, because, as I noted above, SAT solvers don\u0026rsquo;t find all satisfying solutions \u0026ndash; if they did, they would actually have the same properties as solving an unsatisfiable problem, as they would have to prove that there are no more solutions remaining, essentially proving unsatisfiability.\nThe above reasoning is probably the reason why SAT solvers tend to behave more robustly when they encounter an unsatisfiable problem. In particular, CryptoMiniSat\u0026rsquo;s running time seems more robust when solving unsatisfiable problems. Also, for problems that contain a lot of randomly placed solutions in the search space, such as the (in)famous vmpc_33 and vmpc_34 problems, the solving times seem wholly unpredictable for at least two interesting SAT solvers: lingeling and CryptoMiniSat.\n","permalink":"https://www.msoos.org/2011/01/the-variable-speed-of-sat-solving/","summary":"\u003cfigure\u003e\n    \u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2011/01/Attacking-Bivium-Using-SAT-Solvers.png\"\n         alt=\"Timings from the article \u0026ldquo;Attacking Bivium Using SAT Solvers\u0026rdquo;. The authors didn\u0026rsquo;t seem to have randomised the problems enough: the time to solve should increase exponentially, but instead it goes up and down like a roller coaster\"/\u003e \u003cfigcaption\u003e\n            \u003cp\u003eTimings from the article \u0026ldquo;Attacking Bivium Using SAT Solvers\u0026rdquo;. The authors didn\u0026rsquo;t seem to have randomised the problems enough: the time to solve should increase exponentially, but instead it goes up and down like a roller coaster\u003c/p\u003e\n        \u003c/figcaption\u003e\n\u003c/figure\u003e","title":"The variable speed of SAT solving"},{"content":"The subtitle of this post should really say: and I was wrong, again. First, let me explain what I have been wrong about \u0026ndash; wrong assumptions are always the most instructive.\nI have been convinced for the past year that it\u0026rsquo;s best to have two type of restart and corresponding learnt clause usefulness strategies: the glue-based restart\u0026amp;garbage collection of Glucose and a variation of the geometric restart and activity-based garbage collection of MiniSat. The glue-based variation was observed to be very good for industrial instances with many variables, many of which can be fixed easily, and the MiniSat-type variation was observed to be good for cryptography-type instances with typically low number of variables, almost none of which can be fixed. However, I had the chance to talk to Armin Biere a couple of weeks ago, and while talking with him, I have realised that maybe one of Lingeling\u0026rsquo;s advantages was its very interesting single restart strategy, based on agility (presentation, PDF) which seemed to let it use glue-based garbage collection all the time, succeeding to solve both types of instances. So, inspired by the CCC crowd, in only 10 minutes I have implemented a simple version of this restart strategy into CryptoMiniSat, and voilá, it seems to work on both type of instances, using only glues!\nNow that this dumb assumption of mine is out of the way, let me talk about what is really interesting. As per my last post, I have managed to add a lightweight form of Extended Resolution (ER). Since then, I have improved the heuristics here-and-there, and I have launched the solver on a somewhat strange problem (aloul-chnl11-13.cnf) that only has 2x130 variables, but seems to be hard: very few SAT solvers were able to solve this instance within 10000 secs during the last SAT Competition. So, after CryptoMiniSat cutting the problem into two distinct parts, each containing 130 variables, it started adding variables to better express the learnt clauses\u0026hellip; and the average learnt clause size dropped from ~30 literals to ~13 literals in comparison with the version that didn\u0026rsquo;t add variables. Furthermore, and this is the really interesting part, the solver was able to prove that some of these newly introduced variables must have a certain value, or that some of them were equi- or antivalent to others. So, after lightening the problem up to contain ~3000 variables, the solver was able to solve it in less than 5 minutes. This is, by the way, a problem that neither the newest MiniSat, nor Lingeling, nor Glucose can solve. Interestingly, the Extended Resolution version of Glucose can solve it, in almost the same time as CryptoMiniSat with ER added\u0026hellip;\n","permalink":"https://www.msoos.org/2010/12/extended-resolution-is-working/","summary":"\u003cp\u003eThe subtitle of this post should really say: \u003cem\u003eand I was wrong, again\u003c/em\u003e. First, let me explain what I have been wrong about \u0026ndash; wrong assumptions are always the most instructive.\u003c/p\u003e\n\u003cp\u003eI have been convinced for the past year that it\u0026rsquo;s best to have two type of restart and corresponding learnt clause usefulness strategies: the glue-based restart\u0026amp;garbage collection of \u003ca href=\"http://www.lri.fr/~simon/glucose/downloads/glucose-compet-report.pdf\"\u003eGlucose\u003c/a\u003e and a variation of the geometric restart and activity-based garbage collection of \u003ca href=\"http://minisat.se\"\u003eMiniSat\u003c/a\u003e. The glue-based variation was observed to be very good for industrial instances with many variables, many of which can be fixed easily, and the MiniSat-type variation was observed to be good for cryptography-type instances with typically low number of variables, almost none of which can be fixed. However, I had the chance to talk to \u003ca href=\"http://fmv.jku.at/biere/\"\u003eArmin Biere\u003c/a\u003e a couple of weeks ago, and while talking with him, I have realised that maybe one of Lingeling\u0026rsquo;s advantages was its very interesting single restart strategy, based on agility (\u003ca href=\"http://fmv.jku.at/biere/talks/Biere-SAT08-talk.pdf\"\u003epresentation\u003c/a\u003e, \u003ca href=\"http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.161.8085\u0026amp;rep=rep1\u0026amp;type=pdf\"\u003ePDF\u003c/a\u003e) which seemed to let it use glue-based garbage collection all the time, succeeding to solve both types of instances. So, inspired by the \u003ca href=\"http://events.ccc.de/congress/2010/wiki/Welcome\"\u003eCCC\u003c/a\u003e crowd, in only 10 minutes I have implemented a simple version of this restart strategy into CryptoMiniSat, and voilá, it seems to work on both type of instances, using only glues!\u003c/p\u003e","title":"Extended resolution is working!"},{"content":" The Chaos Computer Club (CCC) is having its yearly conference starting today. It\u0026rsquo;s a madhouse here, which is great for ideas, so I have been having this rush of ideas implemented. First off, it seems that complex problems with few variables are way too difficult to solve even with distributed solving. I have been trying to solve some difficult problems, but no matter how much computer power I throw at them (and I have been throwing \u0026gt;2 years\u0026rsquo; worth, with \u0026gt;300 CPU cores running), not much progress is being made. I have lately been attributing this \u0026ldquo;failure\u0026rdquo; to one prime problem: lack of expressiveness.\nBasically, I feel like the SAT solver is trying to express some complex functions with learnt clauses. For instance, an adder. However, the only thing it can do, is describe this function using a Karnaugh Map. Anybody who has tried to express an adder without introducing new variables is well aware that that\u0026rsquo;s a difficult task. So, we need new variables. This is the point where some collaboration I have lately been doing with some researchers (Laurent Simon and George Katsirelos) comes into play. Following their footsteps, I realised we could introduce new definitions, using a new targeting method we developed. So, I did just that, and here is a nice result for a very difficult problem:\nnum: 7750 lit1: 741 lit2: 4641 num: 2339 lit1: 1396 lit2: 1670 num: 2172 lit1: -719 lit2: 741 num: 2169 lit1: -719 lit2: 4641 num: 2061 lit1: 1669 lit2: 1670 num: 2010 lit1: 1670 lit2: 1734 num: 1973 lit1: 1670 lit2: 1882 ... time: 2.53 seconds\nWhere literals lit1 and lit2 are both present in num number of clauses. So, for example literals 741 and 4641 are both present in 7750 clauses. Which means that if we introduce a definition with a new variable 10000:\n10000 = 741 OR 4641\n(which requires 2 binary clauses and one 3-long clause) we can remove 7750 literals from the problem, while increasing the propagation potential. For example, if there was a clause\n741 OR 4641 OR 2 OR 3 = TRUE\nwe can make it into\n10000 OR 2 OR 3 = TRUE\nWhat I have just described is a (dumb) version of extended resolution, the holy grail that many have tried and only few have succeeded at. It is a holy grail because it is provably more powerful than normal resolution, but heuristics of when and how to introduce the new variables have been difficult to come up with. What I have just described at least would reduce the problem size: removing e.g. ~7700 literals while only introducing 3 short clauses seems to worth the effort. It might not simulate extended resolution (ER), but it should speed up the solving, while giving a (lowly) shot at ER.\nPS: If all of this sounds mad, that may be attributed to the ~500 people around me loudly developing and discussing issues ranging from peer-to-peer routing to FPGA programming\n","permalink":"https://www.msoos.org/2010/12/ccc-madness/","summary":"\u003cp\u003e\u003ca href=\"/wordpress/wp-content/uploads/2010/12/27c3.jpg\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/12/27c3.jpg\"\u003e\u003c/a\u003e The Chaos Computer Club (CCC) is having its yearly \u003ca href=\"http://events.ccc.de/category/27c3/\"\u003econference\u003c/a\u003e starting today. It\u0026rsquo;s a madhouse here, which is great for ideas, so I have been having this rush of ideas implemented. First off, it seems that complex problems with few variables are way too difficult to solve even with distributed solving. I have been trying to solve some difficult problems, but no matter how much computer power I throw at them (and I have been throwing \u0026gt;2 years\u0026rsquo; worth, with \u0026gt;300 CPU cores running), not much progress is being made. I have lately been attributing this \u0026ldquo;failure\u0026rdquo; to one prime problem: lack of expressiveness.\u003c/p\u003e","title":"CCC madness"},{"content":" I have lately been trying to keep my promise I made on the webpage of CryptoMiniSat: \u0026ldquo;The long-term goals of CryptoMiniSat are to be an efficient sequential, parallel and distributed solver\u0026rdquo;. The first step was to make a relatively efficient sequential solver. With the winning of the SAT Race'10, that was at least partially accomplished. The next step was to make the program parallel. Now, I have made it distributed. The parallel version was made using OpenMP, and you can try it using the \u0026ldquo;master\u0026rdquo; branch from the git repository. The distributed version uses MPI, which means it can probably work on most cluster/supercomputer architectures. This distributed version is currently alpha, and is not yet in the git repo.\nMy first impression of the distributed version is: it\u0026rsquo;s awsome to solve using 10-20 machines in parallel. The speed is just unbelievable. It\u0026rsquo;s also great to have the multi-threaded and distributed option in one program, as I can now launch just one MPI process on each machine, and the 8 cores on each machine can use threads to work together, instead of using the somewhat slower MPI. I haven\u0026rsquo;t measured the speedup, and I haven\u0026rsquo;t measured the MPI load, so I cannot say anything yet about efficiency. All I can say, is that using 160 threads is a little faster than using only one.\nAs for technical details, I am only sharing unitary and binary clauses. It\u0026rsquo;s a trivial and lazy choice, but it makes it easier to check for redundant clauses (thanks to Armin Biere for highlighting to me that this is important), and works well with CryptoMiniSat\u0026rsquo;s expand-contract loop, where a set of simplification operations are carried out at regular intervals to squeeze the most unitary and binary clauses out of the current knowledge stored inside the clause database.\nI am looking forward to breaking a somewhat problematic crypto-problem with the new distributed CryptoMiniSat. Hopefully this will work, though maybe it\u0026rsquo;s some way off \u0026ndash; I think the original time needed to break the problem might be in the hundreds of days with single-threaded non-distributed CryptoMiniSat. Fingers are crossed that the speedup is non-linear with the distributed version, and I can allocate enough computers for enough time to the job.\nEdited to add -- The solver has now been running stable on 100 computers, distributed. This is getting to be real fun. Next step is to deploy it on a 342-node cluster, each node double-core. Having 684 threads collaborate will feel mighty ;) Also, it will inspire me to build more heterogeneity into the architecture. It was never designed to run on this many nodes\u0026hellip;\n","permalink":"https://www.msoos.org/2010/12/distributed-sat-solving-is-fun/","summary":"\u003cp\u003e\u003ca href=\"/wordpress/wp-content/uploads/2010/12/LogoGrid5000.png\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/12/LogoGrid5000.png\"\u003e\u003c/a\u003e I have lately been trying to keep my promise I made on the \u003ca href=\"/cryptominisat2\"\u003ewebpage\u003c/a\u003e of CryptoMiniSat: \u0026ldquo;The long-term goals of CryptoMiniSat are to be an efficient sequential, parallel and distributed solver\u0026rdquo;. The first step was to make a relatively efficient sequential solver. With the winning of the SAT Race'10, that was at least partially accomplished. The next step was to make the program parallel. Now, I have made it distributed. The parallel version was made using \u003ca href=\"http://www.openmp.org/\"\u003eOpenMP\u003c/a\u003e, and you can try it using the \u0026ldquo;master\u0026rdquo; branch from the git \u003ca href=\"http://gitorious.com/cryptominisat/\"\u003erepository\u003c/a\u003e. The distributed version uses \u003ca href=\"http://www.mcs.anl.gov/research/projects/mpi/\"\u003eMPI\u003c/a\u003e, which means it can probably work on most cluster/supercomputer architectures. This distributed version is currently alpha, and is not yet in the git repo.\u003c/p\u003e","title":"Distributed SAT solving is fun"},{"content":"I am not perfect, so I make mistakes. One of the more memorable mistakes I have made has been regarding hyper-binary resolution. More specifically, in this post I wrote that I cannot add as many binary clauses using hyper-binary resolution as Armin Biere, one of the leading SAT solver experts, and I proposed a reason that would have meant that CryptoMiniSat was doing things differently and thus better. Well, I was wrong, on multiple accounts.\nFirst of all, there was an awful bug in the code that meant that hyper-binary resolution was not carried out on negated variables. Second, when it was decided that multiple implications need to be attached to a literal, I didn\u0026rsquo;t check for redundancy. For example, if v1 had to be connected to v2 and v3, I simply added the clauses -v1 OR v2 (1) -v1 OR v3 (2) However, this may not be very efficient, since if there is already a binary clause -v2 OR v3 (3) then clause (2) doesn\u0026rsquo;t need to be added. The added redundant binary clauses reduced the speed of solving while adding no extra knowledge. There were many of them, too: approx 2/3rd of all binary clauses added were redundant.\nHyper-binary resolution is conceptually not too difficult, but takes a lot of thinking to code efficiently, is very time consuming and its benefits are not clear-cut. I believe the problem is that many binary clauses added this way are ultimately useless, since most are connected to variables that will soon be proved to be of a fixed value. Another possibility is that since problems are pretty structured, and it\u0026rsquo;s usually best to attack problems in a specific way (which is normally correctly guessed by the VSIDS and polarity-guessing\u0026amp;caching heuristics), the binary clauses added by hyper-binary resolution do not help resolving the problem given the (typically correct) attack method employed by SAT solvers. In other words, the information added is nice, but mostly unused. This is just wild speculation, and I may only think this because my code is slow \u0026ndash; I believe Armin\u0026rsquo;s code is faster, so I should have a look.\n","permalink":"https://www.msoos.org/2010/12/hyper-binary-resolution-i-was-wrong-again/","summary":"\u003cp\u003eI am not perfect, so I make mistakes. One of the more memorable mistakes I have made has been regarding \u003ca href=\"/i-must-be-dumb\"\u003ehyper-binary resolution\u003c/a\u003e. More specifically, in \u003ca href=\"/being-dumb-is-part-of-the-deal\"\u003ethis\u003c/a\u003e post I wrote that I cannot add as many binary clauses using hyper-binary resolution as \u003ca href=\"http://fmv.jku.at/biere/\"\u003eArmin Biere\u003c/a\u003e, one of the leading SAT solver experts, and I proposed a reason that would have meant that CryptoMiniSat was doing things differently and thus better. Well, I was wrong, on multiple accounts.\u003c/p\u003e","title":"Hyper-binary resolution: I was wrong, again"},{"content":"I have lately been trying to work on branching heuristics. The idea is relatively simple. If we have a cache of what propagates what, we can try to branch on literals that propagate a lot of other literals. The algorithm boils down to the following:\nFor each literal L, we select a literal DL that propagates L and has the largest tree of propagated literals.. We call this DL the dominating literal. Naturally, some literals don\u0026rsquo;t have a dominating literal, and some literals appear as dominating literals for many other literals. When branching, if we are supposed to branch on a literal that has a dominator, we pick the dominator instead of the literal. This not only ensures that the literal will be set, but it will probably also set a number of other literals. Using the heuristic of step 2, we should reach a conflict earlier, with less decisions taken. This should lead to faster conflicting, and thus faster solving. Of course things aren\u0026rsquo;t as simple as they seem. First of all, as George has indicated to me, Jarvisalo and Junttila have published a paper entitled Limitations of restricted branching in clause learning, which deals with issues related to this branching heursitic. The baseline of that paper is that it\u0026rsquo;s a bad idea to branch only on dependent (they call them input) variables. I haven\u0026rsquo;t really got very deep into this, but there are some subtle differences between the heuristic above and dependent variables, notably that I have treated dependent literals above, while Matti and Tommi are treating dependent variables.\nAs for the advantages of the above heuristic, it seems to work on some instances in practice. In particular, it allows me to solve some cryptographic instances significantly faster \u0026ndash; in fact, some instances that have been extremely hard to solve are now solveable. To me, this looks like an indication that the heuristic is not entirely useless. There are some subtle problems, but it seems that a mixture of randomly branching either on the literal or on its dominator fixes most problems. Indeed, I think CryptoMiniSat 3.0.0 will be released with this experimental feature turned on by default.\nPS: CryptoMiniSat 3.0.0 is coming soon, I believe. It\u0026rsquo;s going to provide a fully multi-threaded library\u0026amp;executable, with a MiniSat-compatible syntax, so anyone will be able to multi-thread his or her SMT solver at a whim.\n","permalink":"https://www.msoos.org/2010/12/dependent-literals/","summary":"\u003cp\u003eI have lately been trying to work on branching heuristics. The idea is relatively simple. If we have a \u003ca href=\"/caching\"\u003ecache\u003c/a\u003e of what propagates what, we can try to branch on literals that propagate a lot of other literals. The algorithm boils down to the following:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eFor each literal L, we select a literal DL that propagates L and has the largest tree of propagated literals.. We call this DL the dominating literal. Naturally, some literals don\u0026rsquo;t have a dominating literal, and some literals appear as dominating literals for many other literals.\u003c/li\u003e\n\u003cli\u003eWhen branching, if we are supposed to branch on a literal that has a dominator, we pick the dominator instead of the literal. This not only ensures that the literal will be set, but it will probably also set a number of other literals.\u003c/li\u003e\n\u003cli\u003eUsing the heuristic of step 2, we should reach a conflict earlier, with less decisions taken. This should lead to faster conflicting, and thus faster solving.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eOf course things aren\u0026rsquo;t as simple as they seem. First of all, as \u003ca href=\"http://www.informatik.uni-trier.de/~ley/db/indices/a-tree/k/Katsirelos:George.html\"\u003eGeorge\u003c/a\u003e has indicated to me, Jarvisalo and Junttila have published  a \u003ca href=\"http://dx.doi.org/10.1007/s10601-008-9062-z\"\u003epaper\u003c/a\u003e entitled \u003cem\u003eLimitations of restricted branching in clause learning\u003c/em\u003e, which deals with issues related to this branching heursitic. The baseline of that paper is that it\u0026rsquo;s a bad idea to branch only on dependent (they call them \u003cem\u003einput\u003c/em\u003e) variables. I haven\u0026rsquo;t really got very deep into this, but there are some subtle differences between the heuristic above and dependent variables, notably that I have treated dependent \u003cem\u003eliterals\u003c/em\u003e above, while Matti and Tommi are treating dependent \u003cem\u003evariables\u003c/em\u003e.\u003c/p\u003e","title":"Dependent Literals"},{"content":"\u0026ldquo;Representation is the essence of programming\u0026rdquo; Frederic P. Brooks Jr., \u0026ldquo;The Mythical Man-month\u0026rdquo;\nLooking through the literature on SAT solvers, it is rare to find any algorithm that uses a form of time-memory trade-off. In fact, it is rare to find any algorithm that uses too much memory. This also shows up in practice, as it\u0026rsquo;s rare to find a SAT solver using too much memory. This translates to the following: if a SAT solver can in an effective way utilize the typically abundant memory, that SAT solver will have an advantage. Based on this logic, I think CryptoMiniSat is doing good.\nWhat I have realised is that it\u0026rsquo;s great to know all the literals we can reach from any given literal. Let me explain. Let\u0026rsquo;s say we have a look at literal \u0026ldquo;v1\u0026rdquo;, i.e. \u0026ldquo;v1 = true\u0026rdquo;. We propagate this literal as usual, and we reach a set of literals that are implied. For example, we reach \u0026ldquo;v2, v3, -v4\u0026rdquo;. This knowledge is regularly computed by modern SAT solvers, but is also quickly thrown away. I advocate keeping this, and here is why. There are a number of very interesting things we can do with these, three of which I have found useful.\nNumber one. This is the best, and the least obvious one. The algorithm used for computing equivalent literals (i.e. \u0026ldquo;v1 = -v2\u0026rdquo; or \u0026ldquo;v1 = v4\u0026rdquo;) is a variation of Tarjan\u0026rsquo;s algorithm for finding strongly connected components (SCC). This algorithm requires a set of binary clauses such as \u0026ldquo;-v1 v2\u0026rdquo; and \u0026ldquo;v1 -v2\u0026rdquo; as input to find equivalent literals, in the example case \u0026ldquo;v1 = -v2\u0026rdquo;. The most obvious way to \u0026ldquo;feed\u0026rdquo; this algorithm with information is to give it all the binary clauses we have. But that misses out on all the binary clauses that are not directly apparent in the problem, but could be derived from the problem. For example, if \u0026ldquo;-v1 -v4\u0026rdquo; was not directly in the problem, SCC cannot find the equivalence \u0026ldquo;v1 = v4\u0026rdquo;. Naturally, by using our cache, we can be sure that \u0026ldquo;-v1 -v4\u0026rdquo; is part of the problem (since \u0026ldquo;v1\u0026rdquo; propagates \u0026ldquo;-v4\u0026rdquo;). So, using this cache, we can substantially increase the power of SCC. More equivalent literals lead to less variables, and an overall faster solving.\nNumber two. Clause vivification is a method to make the original clauses of the problem shorter. It\u0026rsquo;s a relatively simple algorithm that enqueues the literals in the clauses one-by-one and checks if their propagation leads to a conflict. If so, then the clause can be shortened. With the cache, we can do something similar, though less powerful in terms of reasoning power, but far more effective in terms of speed. The trick is to simply try every single literal in the clause: if a literal propagates the inverse of another literal in the clause, we can remove it. For example, if the clause is \u0026ldquo;a b -c\u0026rdquo;, and in the cache for \u0026ldquo;b\u0026rdquo; there is \u0026ldquo;f,g,h,j,-c\u0026rdquo;, then we know that conceptually there exists a clause \u0026ldquo;-b -c\u0026rdquo;, which means we can now remove \u0026ldquo;b\u0026rdquo; from the original clause, using the the self-subsuming resolution rule. This form of vivification is, although technically less strong than normal vivification, is typically 50-100x faster than normal vivification and is almost as powerful. This kind of speed advantage means it can essentially be carried out without (time) penalty.\nNumber three. When generating conflict clauses, MiniSat-type conflict minimisation has now become commonplace. This uses the clauses involved in the conflict to carry out self-subsuming resolution on the conflict clause generated. Just as with clause vivification, we can use our cache to carry out self-subsuming resolution with the (conceptually binary) clauses stored in the cache. This is not much different from clause vivification, but it allows us to do simplification in the middle of a restart, instead of patiently waiting for the restart to end. Furthermore, it can uncover that certain learnt clauses can become binary, thus alleviating the problem of cleaning \u0026ldquo;useless\u0026rdquo; learnt clauses that could have become binary through, e.g. clause vivification.\nI am aware that all the above three could be carried out without a cache \u0026ndash; in fact, CryptoMiniSat could do (and most of the time did) all of the above without it. The advantage of having the cache is speed: things that used to take immense amounts of time can now be done really fast. However, what interests me the most in this cache, is the new uses that will come of it. I was originally only aware of number (3), then when I realised (1), I dived deep and realised that (2) can be done. I think more uses will eventually emerge.\n","permalink":"https://www.msoos.org/2010/11/caching/","summary":"\u003cp\u003e\u0026ldquo;Representation \u003cem\u003eis\u003c/em\u003e the essence of programming\u0026rdquo;\nFrederic P. Brooks Jr., \u0026ldquo;The Mythical Man-month\u0026rdquo;\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"/wordpress/wp-content/uploads/2010/11/memory.png\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/11/memory.png\"\u003e\u003c/a\u003e Looking through the literature on SAT solvers, it is rare to find any algorithm that uses a form of time-memory trade-off. In fact, it is rare to find any algorithm that uses too much memory. This also shows up in practice, as it\u0026rsquo;s rare to find a SAT solver using too much memory. This translates to the following: if a SAT solver can in an effective way utilize the typically abundant memory, that SAT solver will have an advantage. Based on this logic, I think CryptoMiniSat is doing good.\u003c/p\u003e","title":"Caching"},{"content":" Cathedral of Transfiguration in Habarovsk (picture credit: paukrus)\nLast week I visited Micosoft Reasearch in Cambridge, where I gave a talk on SAT solvers, Grobner basis algorithms, and Cryptography. It was nice to visit Microsoft, and in particular I enjoyed seeing how \u0026ldquo;the cathedral\u0026rdquo; works. The kind of software development carried out at Microsoft and almost all large software companies is called the cathedral model due to the book \u0026ldquo;The Mythical Man-Month\u0026rdquo;. It\u0026rsquo;s a very interesting book that talks about how software (and in particular, a \u0026ldquo;Programming Systems Product\u0026rdquo;) is developed. All Windows variants, and e.g. the IBM System/360 fall into the category of programming systems products: they are all tested, documented, extensible, have predefined inputs and outputs, come with predefined interfaces, etc. The development of these software is called the cathedral model simply because that\u0026rsquo;s the example the book uses, and it got stuck in the literature.\nI have been developing CryptoMiniSat for quite some while now, and I must say it is exceedingly difficult to create a programming systems product \u0026ndash; CryptoMiniSat doesn\u0026rsquo;t even scratch the surface of the requirements, but then almost no SAT solver does \u0026ndash; maybe SAT4J is the sole exception. Documentation is usually scarce, and even though I have added a lot, it\u0026rsquo;s still not enough. The input is rarely checked for sanity, and resource needs are usually just ignored: if memory is not enough, then the program will probably just crash; don\u0026rsquo;t expect graceful degradation.\nAs for Microsoft, I must say I was pretty impressed. It\u0026rsquo;s a nice building, with large offices, free tea/coffee/orange juice, filled with some very kind and very bright people. The audience was astonishingly good too, asking questions when they felt like they haven\u0026rsquo;t understood something, instead of just getting disinterested and e.g. browsing email. All in all, it was very interesting to visit the place, though I still feel more inclined to release my code as Free Software ;)\n","permalink":"https://www.msoos.org/2010/11/the-cathedral/","summary":"\u003cfigure\u003e\u003ca href=\"http://www.flickr.com/photos/paukrus/\"\u003e\n    \u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/11/cathedral1.jpg\"\n         alt=\"Cathedral of Transfiguration in Habarovsk (picture credit: paukrus)\"/\u003e \u003c/a\u003e\u003cfigcaption\u003e\n            \u003cp\u003eCathedral of Transfiguration in Habarovsk (picture credit: paukrus)\u003c/p\u003e\n        \u003c/figcaption\u003e\n\u003c/figure\u003e\n\n\u003cp\u003eLast week I visited \u003ca href=\"http://research.microsoft.com/en-us/labs/cambridge/\"\u003eMicosoft Reasearch\u003c/a\u003e in Cambridge, where I gave a \u003ca href=\"/wordpress/wp-content/uploads/2010/11/soos_microsoft_pres.pdf\"\u003etalk\u003c/a\u003e on SAT solvers, Grobner basis algorithms, and Cryptography. It was nice to visit Microsoft, and in particular I enjoyed seeing how \u0026ldquo;the cathedral\u0026rdquo; works. The kind of software development carried out at Microsoft and almost all large software companies is called the cathedral model due to the book \u0026ldquo;\u003ca href=\"http://en.wikipedia.org/wiki/The_Mythical_Man-Month\"\u003eThe Mythical Man-Month\u003c/a\u003e\u0026rdquo;. It\u0026rsquo;s a very interesting book that talks about how software (and in particular, a \u0026ldquo;Programming Systems Product\u0026rdquo;) is developed. All Windows variants, and e.g. the IBM System/360 fall into the category of programming systems products: they are all tested, documented, extensible, have predefined inputs and outputs, come with predefined interfaces, etc. The development of these software is called the cathedral model simply because that\u0026rsquo;s the example the book uses, and it got stuck in the literature.\u003c/p\u003e","title":"The Cathedral"},{"content":"I have lately been trying to get CryptoMiniSat to use implicit binary clauses. The idea is that since binary clauses are very trivial (just two literals), and they don\u0026rsquo;t really need to keep state (like clause activity), they don\u0026rsquo;t really need to be stored at a separate location. Instead, they can be stored directly in the watchlists. There are a number of advantages and disadvantages that come with this approach.\nThe main advantage is a notable reduction of memory usage and memory fragmentation. The first is obvious: since we don\u0026rsquo;t allocate space for binary clauses separately, the memory usage of the program should go down. This is especially true since SAT problems usually contain a huge number of binary clauses. The secondary benefit, that of reduced memory fragmentation is not really that much of an advantage if someone uses, e.g. the boost pool library.\nThe disadvantages are mainly twofold. Firstly, bugs are very difficult to find. Since there is not one central database of binary clauses (as before), it becomes difficult to check the consistency of the watchlists. However, if inconsistencies creep in, then the solution found by the SAT solver could be wrong. Worst of all, consistency is difficult to keep, as binary clauses often need to be worked on by e.g. subsumption, variable elimination, etc. The second biggest disadvatage is that if a new algorithm comes up that needs a database of binary clauses, this database would need to be re-built every time to run that algorithm, which can be very costly in terms of time.\nAll in all, it took me about 1 day to implement implicit binary clauses, and about 3 days to debug it. Surprisingly, it came with some very positive side-effects. Firstly, the debugging session took out some very long-standing bugs in CryptoMiniSat. Secondly, since binary clauses represent most clauses in typical SAT problems, and since binary clauses cannot be subsumed by anything other than binary clauses, the subsumption algorithm has been notably speeded up and its memory usage has been reduced. The worst part of using implicit binary clauses has been the fact that I can no longer use binary clause-sorting to find binary xor clauses, and I must resort back to Tarjan\u0026rsquo;s strongly connected component finding algorithm. This algorithm is algorithmically faster (only O(V+E) versus O(n*logn) ), but practically slower, since I need to carry it out repeatedly, and I cannot save state. Furthermore, I haven\u0026rsquo;t yet coded it down, so I am using boost\u0026rsquo;s graph algorithm, which means that I now have a dependency in CryptoMiniSat. This will eventually be corrected, but it is already causing some trouble.\nIn the meantime, I have been parallelising CryptoMiniSat. Funnily enough, it took me about 2 days in total to multi-thread CryptoMiniSat versus the 4 days it took to implement implicit binary clauses. Oh well.\n","permalink":"https://www.msoos.org/2010/10/implicit-binary-clauses/","summary":"\u003cp\u003eI have lately been trying to get CryptoMiniSat to use implicit binary clauses. The idea is that since binary clauses are very trivial (just two literals), and they don\u0026rsquo;t really need to keep state (like clause activity), they don\u0026rsquo;t really need to be stored at a separate location. Instead, they can be stored \u003ca href=\"/propagating-faster\"\u003edirectly\u003c/a\u003e in the watchlists. There are a number of advantages and disadvantages that come with this approach.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"/wordpress/wp-content/uploads/2010/10/implicit_bin_clauses1.png\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/10/implicit_bin_clauses1.png\"\u003e\u003c/a\u003e The main advantage is a notable reduction of memory usage and memory fragmentation. The first is obvious: since we don\u0026rsquo;t allocate space for binary clauses separately, the memory usage of the program should go down. This is especially true since SAT problems usually contain a huge number of binary clauses. The secondary benefit, that of reduced memory fragmentation is not really that much of an advantage if someone uses, e.g. the \u003ca href=\"http://www.boost.org/doc/libs/release/libs/pool/doc/\"\u003eboost pool\u003c/a\u003e library.\u003c/p\u003e","title":"Implicit binary clauses"},{"content":"Today marked the 100th cluster experiment I have conducted on the Grid'5000 cluster in Grenoble. The computers in this cluster are very powerful beasts, equipped with two Xeon Core i7-based processors, each with 4 cores for 8 cores in total with some impressive memory size and connectivity. The sad part is that since CryptoMiniSat is sequential software, I only use 1 core from the 8 total, since I cannot allow to have fluctuating test results due to memory-bandwidth problems when running multiple instances of the solver on the same physical computer. I have just counted, and using a very conservative estimate, I have wasted 41.8 years of CPU core time to get CryptoMiniSat up to speed.\nWas it worth wasting such immense amount of CPU core time to speed up a SAT solver? I think yes. First of all, I only used the cluster during night and during the weekends, when load was negligible. So, in a way I wasn\u0026rsquo;t wasting much apart from my own time launching the cluster experiments, collecting and analysing the results. Secondly, the feedback from the cluster immensely influenced my research and engineering decisions, and taught me many things regarding SAT. The best thing I have learnt is: never trust your intuitions when it comes to SAT. Secondly, good ideas on paper rarely turn out to be good ideas when first implemented, but with heavy tuning, they usually turn out to work well. Let me detail two examples.\nClause Vivification (I called it asymmetric branching) is a relatively simple example of why tuning is always necessary. This optimisation shortens clauses it is fed to, however, it is slow. The idea I used when tuning this optimisation is that the longest clauses are probably responsible for the slow solving and the long generated conflict clauses. So, I sort clauses according to size first, and then do clause vivification on the topmost (i.e. longest) clauses. Furthermore, I realised that enqueueing literals 2-by-2 on the stack (instead of enqueueing 1-by-1) saves significant time, and is almost as good as enqueueing them 1-by-1 \u0026ndash; the difference is at most 1 literal in the final simplified clause.\nA more complex example is that of speeding up self-subsuming resolution. The problem was that keeping all clauses attached in the watchlists slowed down self-subsuming resolution. However, the obvious solution of detaching all clauses and reattaching them after self-subs. resolution was incomplete, strangely enough. With multiple cluster experiments it became apparent that keeping clauses attached is important, because some propagations are made during the running of the algorithm, and propagating these (very few!) variables is crucial. The solution was to keep natively stored (2- and 3-long clauses) in the watchlists. These natively kept clauses don\u0026rsquo;t have pointers in the watchlists, and therefore their representation at the pointer\u0026rsquo;s location can be updated. The watchlists are therefore partially cleaned, then self-subsuming resolution is carried out, then the watchlists are fully cleaned and finally the watchlists are fully populated \u0026ndash; not exactly a trivial algorithm, but it achieves both goals of fast and complete self-subsuming resolution.\n--- Off-topic: For those who like contemporary art, here is a gem\n","permalink":"https://www.msoos.org/2010/10/wasting-cluster-time/","summary":"\u003cp\u003eToday marked the 100th cluster experiment I have conducted on the Grid'5000 \u003ca href=\"http://www.grid5000.fr/mediawiki/index.php/Grenoble:Hardware\"\u003ecluster\u003c/a\u003e in Grenoble. The computers in this cluster are very powerful beasts, equipped with two Xeon Core i7-based processors, each with 4 cores for 8 cores in total with some impressive memory size and connectivity. The sad part is that since CryptoMiniSat is sequential software, I only use 1 core from the 8 total, since I cannot allow to have fluctuating test results due to memory-bandwidth problems when running multiple instances of the solver on the same physical computer. I have just counted, and using a very conservative estimate, I have wasted 41.8 years of  CPU core time to get CryptoMiniSat up to \u003ca href=\"/cryptominisat-2-7-1-released\"\u003espeed\u003c/a\u003e.\u003c/p\u003e","title":"Wasting cluster time"},{"content":"It has been a long and winding road, but finally, CryptoMiniSat 2.7.1 has been released. The main additions relative to version 2.6.0 are:\nLots of documentation. I have added ~1'500 lines of comments to aid developers and user alike Transitive on-the-fly self-subsuming resolution \u0026ndash; an optimisation I have blogged about Memory allocator has been fixed and updated DIMACS parsing is now much better, which should allow for very interesting usage scenarios Although the above list doesn\u0026rsquo;t seem to talk about performance, let me talk about it first. My personal point of view on performance is that different applications have different needs, so even if overall some solver is the best, it might not mean that it is the best for a particular application. I compared the performance of CryptoMiniSat 2.7.1 to the other mainline solvers, namely MiniSat 2.2, PrecoSat465, and lingeling. I ran the problem instances of the 2009 SAT Competition, with a timeout of 6'000 seconds on some powerful computers. The results are the following:\nCryptoMiniSat could solve 225 problem instances (223 within SATComp'09 limits), and the second best solver, lingeling, could solve 211 (207 within SATComp'09 limits). Interestingly, both MiniSat 2.2 and lingeling were better than CryptoMiniSat 2.7.1 at low timeouts, and lingeling kept this advantage the longest, until ~500 seconds, above which CryptoMiniSat took over. Not being too fast at the beginning is a conscious choice by me, as I think it helps in the long run, though I might be wrong. There is much to be improved, and I hope that the immense amount of documentation added will help those willing to try to iron out these shortcomings.\nAs for the DIMACS parsing update, it basically allows to add information to clauses to distinguish between learnt and non-learnt clauses. This helps, because it is now possible to simply dump the learnt clauses at any moment during the search, and then re-start the search more-or-less where it was stopped. The command-line options for this are \u0026ldquo;\u0026ndash;dumplearnts=FILENAME \u0026ndash;maxdumplearnts=3\u0026rdquo; to dump, and \u0026ldquo;\u0026ndash;alsoread=FILENAME\u0026rdquo; to re-read. This is currently quite a crude way of stopping-and-starting, but hopefully it will improve in the future.\nAll in all, I am quite happy about the new release. I have put lots of time into it, and I hope you will enjoy using it :)\n","permalink":"https://www.msoos.org/2010/10/cryptominisat-2-7-1-released/","summary":"\u003cp\u003eIt has been a long and winding road, but finally, CryptoMiniSat 2.7.1 has been \u003ca href=\"https://gforge.inria.fr/frs/shownotes.php?release_id=5507\"\u003ereleased\u003c/a\u003e. The main additions relative to version 2.6.0 are:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eLots of \u003ca href=\"/documentation/cryptominisat/\"\u003edocumentation\u003c/a\u003e. I have added ~1'500 lines of comments to aid developers and user alike\u003c/li\u003e\n\u003cli\u003eTransitive on-the-fly self-subsuming resolution \u0026ndash; an optimisation I have \u003ca href=\"../../transitive-otf-self-subsuming-resolution\"\u003eblogged about\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMemory allocator has been fixed and updated\u003c/li\u003e\n\u003cli\u003eDIMACS parsing is now much better, which should allow for very interesting usage scenarios\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eAlthough the above list doesn\u0026rsquo;t seem to talk about performance, let me talk about it first. My personal point of view on performance is that different applications have different needs, so even if overall some solver is the best, it might not mean that it is the best for a particular application. I compared the performance of CryptoMiniSat 2.7.1 to the other mainline solvers, namely \u003ca href=\"http://minisat.se/\"\u003eMiniSat 2.2\u003c/a\u003e, \u003ca href=\"http://fmv.jku.at/precosat/\"\u003ePrecoSat465\u003c/a\u003e, and \u003ca href=\"http://fmv.jku.at/lingeling/\"\u003elingeling\u003c/a\u003e. I ran the problem instances of the 2009 SAT Competition, with a timeout of 6'000 seconds on some \u003ca href=\"http://www.grid5000.fr/mediawiki/index.php/Grenoble:Hardware\"\u003epowerful\u003c/a\u003e computers. The results are the following:\u003c/p\u003e","title":"CryptoMiniSat 2.7.1 released"},{"content":"\nToday I attended the IRILL days here in Paris. IRILL\u0026rsquo;s goal is to bring together high level researchers and scientists, FOSS (Free and Open Source) developers, and FOSS industry players to tackle the three fundamental challenges that FOSS poses:\nscientific: study problems raised by the development and maintenance of FOSS code educational: adapt the teaching curriculum to FOSS economic: help create a sustainable ecosystem for FOSS innovations The most interesting part of the conference for me was Debian package dependency management, which currently is done by a number of ad-hoc algorithms, a problem that the Mancoosi Project is tacking. Essentially, there are a number of program packages that need different libraries and services, and we need to decide which ones we need to install in order to satisfy those dependencies when installing/upgrading a package. This dependency graph and the package to be installed/upgraded is capture in a language called CUDF (complete PDF description here). When deciding which packages to retain,upgrade or install, there are some goals which we must achieve, such as minimising the number of new packages as much a possible: the different optimisation criterias are described here. There is a competition associated with this computationally difficult problem, the MISC Competition, which was first conducted this year, during the FLoC conference.\nInterestingly, the problem of package dependencies maps very well to problems faced by industry: configuration management. For instance, many high-end car models have thousands of options. Some of these options are incompatible, and some of them depend on other options being taken. For example, it may be necessary to take a certain color scheme to apply certain figurative patterns on the car. Although this sounds trivial, once the number of options go up, the complexity increases at a typically exponential rate, after which finding suitable solutions for customers might become a real challenge. For example, I wouldn\u0026rsquo;t be surprised if a modern airplane such as the A380 had customer options approaching the tens of thousands. Managing this automatically is a really interesting and a very real challenge, in the solution of which I hope CryptoMiniSat will be able to participate in.\n","permalink":"https://www.msoos.org/2010/10/configuration-management-at-irill-days/","summary":"\u003cp\u003e\u003ca href=\"/wordpress/wp-content/uploads/2010/10/Logotype-IRILL.jpg\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/10/Logotype-IRILL.jpg\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eToday I attended the \u003ca href=\"http://www.irill.org/events/irill-days-2010\"\u003eIRILL days\u003c/a\u003e here in Paris. IRILL\u0026rsquo;s goal is to bring together high level researchers and scientists, FOSS (Free and Open Source) developers, and FOSS industry players to tackle the three fundamental challenges that FOSS poses:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cem\u003escientific\u003c/em\u003e: study problems raised by the development and maintenance of FOSS code\u003c/li\u003e\n\u003cli\u003e\u003cem\u003eeducational\u003c/em\u003e: adapt the teaching curriculum to FOSS\u003c/li\u003e\n\u003cli\u003e\u003cem\u003eeconomic\u003c/em\u003e: help create a sustainable ecosystem for FOSS innovations\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eThe most interesting part of the conference for me was Debian \u003ca href=\"http://www.debian.org/doc/FAQ/ch-pkgtools.en.html\"\u003epackage dependency management\u003c/a\u003e, which currently is done by a number of ad-hoc algorithms, a problem that the \u003ca href=\"http://mancoosi.org/\"\u003eMancoosi Project\u003c/a\u003e is tacking. Essentially, there are a number of program packages that need different libraries and services, and we need to decide which ones we need to install in order to satisfy those dependencies when installing/upgrading a package. This dependency graph and the package to be installed/upgraded is capture in a language called \u003ca href=\"http://www.mancoosi.org/cudf/primer/\"\u003eCUDF\u003c/a\u003e (complete PDF description \u003ca href=\"http://www.mancoosi.org/reports/tr3.pdf\"\u003ehere\u003c/a\u003e). When deciding which packages to retain,upgrade or install, there are some goals which we must achieve, such as minimising the number of new packages as much a possible: the different optimisation criterias are described \u003ca href=\"http://www.mancoosi.org/misc-2010/criteria/\"\u003ehere\u003c/a\u003e. There is a competition associated with this computationally difficult problem, the \u003ca href=\"http://www.mancoosi.org/misc-2010/\"\u003eMISC Competition\u003c/a\u003e, which was first conducted this year, during the \u003ca href=\"http://www.floc-conference.org/\"\u003eFLoC\u003c/a\u003e conference.\u003c/p\u003e","title":"Configuration management at IRILL days"},{"content":" Today I attended the Open World Forum conference here in Paris. Basically, it\u0026rsquo;s a business-oriented conference to do networking for folks in the free/open source industry. Some of the panelists were sometimes really boring, such as the \u0026ldquo;French Secretary of State responsible for the Digital Economy\u0026rdquo; who seemed to have deeply confused \u0026ldquo;free as in speech\u0026rdquo; and \u0026ldquo;open source\u0026rdquo; software \u0026ndash; a grave mistake by my book. The panelist, who knew the difference of course, regularly overemphasised the use of \u0026ldquo;open source\u0026rdquo; software, but the notion of \u0026ldquo;free as in speech\u0026rdquo; was lost, and mentioned rarely, with the notable exception of the Red Hat folks. With the release of CryptoMiniSat, which I explicitly released under a free software licence, GPLv3, I of course disagreed.\nThe highlight of the conference for me was meeting the current Debian Leader, Stefano Zacchiroli, and researcher Roberto Di Cosmo. I have been using Debian for a very long time, and I always wanted to contribute. However, the best way to contribute is always with your expertise, which for me is SAT solvers. So, I approached Stefano with the idea of configuration management in Debian (dpkg), for which CryptoMiniSat would be a good fit, I think: complex package dependencies could be resolved with ease using CryptoMiniSat. If included in dpkg, CryptoMiniSat could take the prize of the most deployed SAT solver away from SAT4J, which currently holds this title due to its inclusion in the Eclipse development package. Fingers crossed\u0026hellip; and lots of work is ahead.\n","permalink":"https://www.msoos.org/2010/09/open-source-software-free-software/","summary":"\u003cp\u003e\u003ca href=\"http://www.nuxeo.com/en/about/events/owf2010\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/09/owf2010.jpg\"\u003e\u003c/a\u003e Today I attended the \u003ca href=\"http://www.openworldforum.org/\"\u003eOpen World Forum\u003c/a\u003e conference here in Paris. Basically, it\u0026rsquo;s a business-oriented conference to do networking for folks in the free/open source industry. Some of the panelists were sometimes really boring, such as the \u0026ldquo;French Secretary of State responsible for the Digital Economy\u0026rdquo; who seemed to have deeply confused \u0026ldquo;\u003ca href=\"http://en.wikipedia.org/wiki/Free_software\"\u003efree as in speech\u003c/a\u003e\u0026rdquo; and \u0026ldquo;\u003ca href=\"http://en.wikipedia.org/wiki/Open_source_software\"\u003eopen source\u003c/a\u003e\u0026rdquo; software \u0026ndash; a \u003cem\u003egrave\u003c/em\u003e mistake by my book. The panelist, who knew the difference of course, regularly overemphasised the use of \u0026ldquo;open source\u0026rdquo; software, but the notion of \u0026ldquo;free as in speech\u0026rdquo; was lost, and mentioned rarely, with the notable exception of the \u003ca href=\"http://www.redhat.com/\"\u003eRed Hat\u003c/a\u003e folks. With the release of CryptoMiniSat, which I explicitly released under a free software licence, \u003ca href=\"http://www.gnu.org/licenses/gpl.html\"\u003eGPLv3\u003c/a\u003e, I of course disagreed.\u003c/p\u003e","title":"Open source software? Free software?"},{"content":"Documenting code is not always so much fun. However, in order for the code to be extended by others, documentation needs to exist. Since I conceived CryptoMiniSat as a program to be extended by others, documentation was a must. So now, after investing about 2 weeks into documentation, it is finally ready. All major classes have been documented, along with all major functions and internal data structures. The number of comment lines I added is around a thousand, all in the Doxygen format. A preliminary HTML version is available here. I hope the quality of the documentation will improve with time, and that others might correct and add more documentation as they update the program.\nWhile documenting the code, it occurred to me that certain variable and function names were really awkward, or reflected the state of the class from an earlier version of the code. These variables and functions have been renamed, and some even removed, since they served no purpose other than making the code bigger for no reason. I have also found a number of TODOs while going through the code: sometimes I implemented things the fast way instead of the correct way, so some data structures are really strange, slow, or both. The sourcecode with all the documentation is available here, from the gitorious code repository. I will soon make a 2.6.1 release that contains not only this newly added documentation, but other additions as well.\n","permalink":"https://www.msoos.org/2010/09/documenting-cryptominisat/","summary":"\u003cp\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/09/documentation.jpg\"\u003eDocumenting code is not always so much fun. However, in order for the code to be extended by others, documentation needs to exist. Since I conceived \u003ca href=\"/cryptominisat2\"\u003eCryptoMiniSat\u003c/a\u003e as a program to be extended by others, documentation was a must. So now, after investing about 2 weeks into documentation, it is finally ready. All major classes have been documented, along with all major functions and internal data structures. The number of comment lines I added is around a thousand, all in the Doxygen format. A preliminary HTML version is available \u003ca href=\"/documentation/cryptominisat/index.html\"\u003ehere\u003c/a\u003e. I hope the quality of the documentation will improve with time, and that others might correct and add more documentation as they update the program.\u003c/p\u003e","title":"Documenting CryptoMiniSat"},{"content":"The title may be a bit long, but its essence is very simple: we try to shorten learnt clauses. The basic idea was described in this post: there is a clause we just derived, e.g.\nd V -e V f V g (1)\nwhere d,e,f,g are binary variables, - is binary negation, and V is the binary OR operator. We can remove a literal from this using self-subsuming resolution with e.g. the 2-long clause:\nf V -g (2)\nremoving g from clause (1). This has been achieved before using on-the-fly self-subsuming resolution. The trick we add now is the following. Let\u0026rsquo;s assume that clause (2) was not in the clause database. With the above technique, g would not be removed. However, if clauses:\nf V a -a V -g are inside the clause database, we could, in fact, remove g, since the above two clauses, when we resolve them on a become:\nf V -g\ni.e. clause (2), what we have been searching for! So, how could we do this kind of reasoning efficiently? It turns out that this is not so difficult. We simply need to try to propagate -f using only the 2-long clauses. Then, we will reach -g through the intermediary, a.\nNaturally, we can do the above recursive-propagation process not only for f but for all literals in the original clause (1), and then try to perform on-the-fly self-subsuming resolution, as before. There is only one catch: doing this kind of recursive propagation on all 2-long clauses for all literals in a clause is too time-consuming. So we only do it for clauses that are short: 5 literals or shorter. The results are in, and seem to indicate that transitive on-the-fly self-subsuming resolution with a limit of 5-long clauses is indeed viable:\nThe set of problems used were those of the SAT Competition 2009, and the time limit was 1500 seconds on some powerful machines \u0026ndash; they are approx 2x as fast as those used in the competition. As you can see, transitive OTF self-subsuming resolution seems to pay off in terms of number of problem instances solved within a certain time limit. I have decided to add this feature to the upcoming CryptoMiniSat 2.6.1, which should be ready soon.\n","permalink":"https://www.msoos.org/2010/09/transitive-otf-self-subsuming-resolution/","summary":"\u003cp\u003eThe title may be a bit long, but its essence is very simple: we try to shorten learnt clauses. The basic idea was described in \u003ca href=\"/on-the-fly-self-subsuming-resolution\"\u003ethis\u003c/a\u003e post: there is a clause we just derived, e.g.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ed V -e V f V g\u003c/code\u003e (1)\u003c/p\u003e\n\u003cp\u003ewhere \u003ccode\u003ed,e,f,g\u003c/code\u003e are binary variables, \u003ccode\u003e-\u003c/code\u003e is binary negation, and \u003ccode\u003eV\u003c/code\u003e is the binary OR operator. We can remove a literal from this using \u003ca href=\"/self-subsuming-resolution\"\u003eself-subsuming resolution\u003c/a\u003e with e.g. the 2-long clause:\u003c/p\u003e","title":"Transitive OTF self-subsuming resolution"},{"content":"I have finally managed to fix the script that converts ANF problems to CNF format in the Sage math system. The original script was having some problems that I blogged about. The new script has corrected most of the shortcomings of the original script, as well as added some textual help for the user.\nFor instance, the equations\nsage: print two_polynoms [x0*x1 + 1, x0*x1 + x1] that last time required 13 clauses and 4 variables in CNF, now look like this:\nsage: print anf2cnf.cnf(two_polynoms) p cnf 3 6 c ------------------------------ c Next definition: x0*x1 + 1 3 0 c ------------------------------ c Next definition: x0*x1 + x1 3 -2 0 -3 2 0 c ------------------------------ c Next definition: monomial x0*x1 1 -3 0 2 -3 0 3 -1 -2 0 which is 1 variable and 7 clauses shorter than the original, not to mention the visually cleaner look and human-parseable output. The new script is available here. Hopefully, some of my enhancements included in the Grain-of-Salt package will be included in this script. The problem is mainly that Grain-of-Salt uses radically different data structures, and is written in a different programming language, so porting is not trivial.\n","permalink":"https://www.msoos.org/2010/09/anf2cnf-script-released/","summary":"\u003cp\u003eI have finally managed to fix the script that converts ANF problems to CNF format in the \u003ca href=\"http://www.sagemath.org/\"\u003eSage\u003c/a\u003e math system. The \u003ca href=\"http://bitbucket.org/malb/algebraic_attacks/src/abd22969c7b5/anf2cnf.py\"\u003eoriginal script\u003c/a\u003e was having some problems that I \u003ca href=\"/anf2cnf-hell-in-sage\"\u003eblogged about\u003c/a\u003e. The new script has corrected most of the shortcomings of the original script, as well as added some textual help for the user.\u003c/p\u003e\n\u003cp\u003eFor instance, the equations\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esage: print two_polynoms\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[x0*x1 + 1, x0*x1 + x1]\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003ethat last time required 13 clauses and 4 variables in CNF, now look like this:\u003c/p\u003e","title":"anf2cnf script released"},{"content":"There is an ANF (Algebraic Normal Form) to CNF (Conjunctive Normal Form) converter by Martin Albrecht in Sage. Essentially, it performs the ANF to CNF conversion that I have described previously in this blog entry. Me, as unsuspecting as anyone else, have been using this for a couple of days now. It seemed to do its job. However, today, I wanted to backport some of my ideas to this converter. And then it hit me.\nLet me illustrate with a short example why I think something is wrong with this converter. We will try to encode that variable 0 and variable 1 cannot both be TRUE. This is as simple as saying x0*x1 = 0 in plain old math. In Sage this is done like this:\nsage: B = BooleanPolynomialRing(10,\u0026#39;x\u0026#39;) sage: load anf2cnf.py sage: anf2cnf = ANFSatSolver(B) sage: polynom = B.gen(0)*B.gen(1) sage: print polynom x0*x1 So far, so good. Let\u0026rsquo;s try to make a CNF out of this:\nsage: print anf2cnf.cnf([polynom]) p cnf 4 6 2 -4 0 3 -4 0 4 -2 -3 0 1 0 4 1 0 -4 -1 0 Oooops. Why do we need 6 clauses to describe this? It can be described with exactly one:\np cnf 2 1 -1 -2 This lonely clause simply bans the solution 1 = TRUE, 2 = TRUE, which was our original aim.\nLet me just mention one more thing about this converter: it repeats definitions. For example:\nsage: print two_polynoms [x1*x2 + 1, x1*x2 + x1] sage: print anf2cnf.cnf(two_polynoms) p cnf 4 13 2 -4 0 3 -4 0 4 -2 -3 0 1 0 4 0 2 -4 0 3 -4 0 4 -2 -3 0 1 0 4 2 1 0 -4 -2 1 0 -4 2 -1 0 4 -2 -1 0 Notice that clause 2 -4 0 and the two following it have been repeated twice, as well as the clause setting 1 to TRUE.\nI have been trying to get around these problems lately. When ready, the new script will be made available, along with some HOWTO. It will have some minor shortcomings, but already, the number of clauses in problem descriptions have dramatically dropped. For example, originally, the description of an example problem in CNF contained 221'612 clauses. After minor corrections, the same can now be described with only 122'042 clauses. This of course means faster solving, cleaner and even human-readable CNF output, etc. Fingers are crossed for an early release ;)\n","permalink":"https://www.msoos.org/2010/09/anf2cnf-hell-in-sage/","summary":"\u003cp\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/09/HieronymusBoschHellD1.jpg\"\u003eThere is an \u003ca href=\"http://en.wikipedia.org/wiki/Algebraic_normal_form\"\u003eANF\u003c/a\u003e (Algebraic Normal Form) to \u003ca href=\"http://en.wikipedia.org/wiki/Conjunctive_normal_form\"\u003eCNF\u003c/a\u003e (Conjunctive Normal Form) \u003ca href=\"http://bitbucket.org/malb/algebraic_attacks/src/ce81112bbce4/anf2cnf.py\"\u003econverter\u003c/a\u003e by Martin Albrecht in \u003ca href=\"http://www.sagemath.org/\"\u003eSage\u003c/a\u003e. Essentially, it performs the ANF to CNF conversion that I have described previously in \u003ca href=\"/anf-to-cnf-conversion\"\u003ethis\u003c/a\u003e blog entry. Me, as unsuspecting as anyone else, have been using this for a couple of days now. It seemed to do its job. However, today, I wanted to backport some of my \u003ca href=\"/wordpress/wp-content/uploads/2010/09/GrainofSalt-desc-1.0.pdf\"\u003eideas\u003c/a\u003e to this converter. And then it hit me.\u003c/p\u003e\n\u003cp\u003eLet me illustrate with a short example why I think something is wrong with this converter. We will try to encode that \u003ccode\u003evariable 0\u003c/code\u003e and \u003ccode\u003evariable 1\u003c/code\u003e cannot both be TRUE. This is as simple as saying \u003ccode\u003ex0*x1 = 0\u003c/code\u003e in plain old math. In Sage this is done like this:\u003c/p\u003e","title":"anf2cnf hell in Sage"},{"content":"I have lately been describing two techniques to speed up SAT solving: on-the-fly self-subsuming resolution, and an interesting way to apply asymmetric branching. It turns out, the first was already used in PrecoSat (by Armin Biere) under the name \u0026ldquo;strong minimization\u0026rdquo;, and the second was already published as Vivification by Piette, Hamadi and Sais. As far as I could tell, both optimisations bring tangible benefits to SAT solving. I have tried solving the problem instances of the 2009 SAT competition with and without both optimisations, and it turns out that using both is the fastest.\nOf course I am at fault for not knowing that these techniques have been published before. Maybe both have been published in respected journals/conferences, but I don\u0026rsquo;t seem to have the capacity to read every journal and conference article. I think we can safely assume that this is true for most researchers. So are we forever destined to reinvent the wheel? Probably the only techniques that don\u0026rsquo;t need to be reinvented are those that have been demonstratively shown to work well. Such a technique is for example glue-clauses, or variable elimination (VE). Glucose, the solver based on glue-clauses had won the 2009 SAT competition, and VE in the SatELite preprocessor blew away the 2005 SAT competition. Similarly, xor clauses might end up in mainline SAT solvers due to the win of CryptoMiniSat (even though I think that win was due to far more than just that).\nThis leads us to a somewhat dim conclusion, however: useful, but small techniques might get lost forever (if they are not reinvented). This is sad, because lots of small techniques bring about lots of improvements in the end, especially if they work together. For example, both techniques mentioned above lead to smaller clauses, which in turn lead to more binary and tertiary clauses. These binary and tertiary clauses lead in turn to increased solving speed due to modern solvers which keep both of them natively in the watchlists. So, as the technology changes, the smallish benefits that some techniques gave might increase due to the technical advancements that have been made since.\n","permalink":"https://www.msoos.org/2010/09/reinventing-the-wheel/","summary":"\u003cp\u003eI have lately been describing two techniques to speed up SAT solving: \u003ca href=\"/on-the-fly-self-subsuming-resolution\"\u003eon-the-fly self-subsuming resolution\u003c/a\u003e, and an interesting way to apply \u003ca href=\"/asymmetric-branching\"\u003easymmetric branching\u003c/a\u003e. It turns out, the first was already used in \u003ca href=\"http://fmv.jku.at/precosat/\"\u003ePrecoSat\u003c/a\u003e (by Armin Biere) under the name \u0026ldquo;strong minimization\u0026rdquo;, and the second was already published as \u003ca href=\"http://research.microsoft.com/en-us/people/youssefh/vivification.pdf\"\u003eVivification\u003c/a\u003e by Piette, Hamadi and Sais. As far as I could tell, both optimisations bring tangible benefits to SAT solving. I have tried solving the problem instances of the 2009 SAT competition with and without both optimisations, and it turns out that using both is the fastest.\u003c/p\u003e","title":"Reinventing the wheel"},{"content":"I have lately been trying to implement a cryptographic protocol (CryptoGPS) on an FPGA. First impressions are that VHDL is a difficult language, but once understood, it\u0026rsquo;s not all that difficult to work with it. It took me ~2 weeks to get a hold on the language, but now it feels relatively easy to program in it. I have been looking forward to getting down and dirty with FPGAs, because it\u0026rsquo;s one of my long-term goals to somehow integrate SAT solvers with FPGAs.\nSAT solvers are extremely versatile tools that can resolve a number of very complex issues with relative ease. FPGA s are also extremely versatile (essentially, they are reprogrammable hardware), and are very fast. Making once piece out of these two is like merging Batman with Superman. The trick is, of course, how to merge them? The problem with merging is that FPGAs are typically very good at executing a (preferably small) set of instructions over and over again on a relatively small dataset, while SAT solvers usually deal with large datasets, and execute an excruciatingly complex set of instructions on them over and over again.\nI think a way to resolve this issue could be to use the FPGA as a sort of oracle for the SAT solver. The solver is running on a normal computer and at the same time it is connected to an FPGA that awaits its orders. The SAT solver regularly extracts a small set of constraints from its constraint database, sends it to the FPGA, which tries every possible combination of the variables, and sends back the result to the SAT solver. While the FPGA works its wonders, the SAT solver could be executing the normal SAT procedure, and regularly process the incoming data from the FPGA.\nThe FPGA could simply try every single combination of every variable setting on the clauses it received, and return compact information such as: \u0026ldquo;variable 5 must be TRUE\u0026rdquo; or \u0026ldquo;there is no solution\u0026rdquo;. More complex return values, such as \u0026ldquo;variable 10 is always equal to variable 2\u0026rdquo; could be returned, but it would make for a more complex VHDL design, leading to an overall slowdown. The simplier the logic, the more we can fit on a given FPGA, which means more parallelisation, and therefore a speedier solution overall. Since the number of variables in the clauses will be limited (checking for 30 is already at least 2^30 operations), we could store the clauses as constant-length double-bitfields in the FPGA, and use a bitmask for the current variable settings. This could allow for massively parallelised evaluation of clauses.\nOn the SAT solver side, we need some guiding principles along which to pick the constraints for the FPGA. The usual suspects could be constraints that contain the most active variables, for example. More complex metrics could minimise the number of variables inside the constraints while maximising the number of small constraints they are present in. Other metrics could perhaps concentrate on the current restart branch of the SAT solver, and try to ask the FPGA to prove that below a certain decision level, the current branch cannot contain a solution \u0026ndash; this way, we could backjump using the data from the FPGA.\nWould this architecture work? I think its performance would depend on whether there is any compact information that the FPGA could extract from the clauses sent to it. This depends on whether there are small \u0026ldquo;cores\u0026rdquo; in the problem that contain compact information, and whether we can extract these cores. The existence of such information-rich cores depend on many things. The clauses/variable ratio is one such metric, another would be the number of symmetries in the problem: the more symmetries, the less compact information can be extracted. Cryptographic problems come to my mind when seeing these criteria. They usually have a very high clauses/variables ratio and rarely, if ever, contain symmetries.\n","permalink":"https://www.msoos.org/2010/09/fpga-programming-and-sat/","summary":"\u003cp\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/09/FPGA-pic-e1307467256310-150x117.jpg\"\u003eI have lately been trying to implement a cryptographic protocol (\u003ca href=\"http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4253016\"\u003eCryptoGPS\u003c/a\u003e) on an FPGA. First impressions are that \u003ca href=\"http://en.wikipedia.org/wiki/VHDL\"\u003eVHDL\u003c/a\u003e is a difficult language, but once understood, it\u0026rsquo;s not all that difficult to work with it. It took me ~2 weeks to get a hold on the language, but now it feels relatively easy to program in it. I have been looking forward to getting down and dirty with FPGAs, because it\u0026rsquo;s one of my long-term goals to somehow integrate SAT solvers with FPGAs.\u003c/p\u003e","title":"FPGA programming and SAT"},{"content":"I have lately been having a small chat with Francois Grieu and it inspired me to think about how difficult it would be to create a new SAT solver from scratch. Let\u0026rsquo;s take it for granted that the person who embarks on such a difficult task understands the basics well, and wishes to create a (nowadays very popular) Conflict-Driven Clause-Learning (or simply, CDCL) type SAT solver. The main parts of these solvers are:\nClause parser\u0026amp;database to store the clauses Propagation engine using watch-lists to carry out Boolean Constraint Propagation (BCP) Conflict generation code, using the first-UIP scheme Learnt clause activity calculator\u0026amp;deleter Variable state database, storing activity and polarity Search restart manager Pre-processor is recommended \u0026ndash; SatELite does the job reasonably well. None of these are very difficult to do. However, by implementing these in a minimalistic fashion, one will only end up with a reasonably fast, but not a very fast solver. Enhancements, for example, storing binary clauses implicitly in the occurrence lists in the database bring small, but nevertheless important, benefits. Similarly, having specialised watch-lists to handle binary and tertiary clauses further speed up the solving. Conflict clause minimisation, on-the-fly subsumption, and on-the-fly self-subsuming resolution improve conflict generation. Polarity- calculation and -caching comes handy for variable polarities, and dynamic restarts are also useful. Learnt clause activities might need to support both MiniSat-style and Glucose-style activities.\nThe real challenge, however, comes with bullet number 7: a fast and complete pre- and in-processor is very complex to write. The pre-processing done by SatELite, i.e. self-subsuming resolution, variable elimination and subsumption are just the icing on the cake for a good pre- and in-processor. Doing these in the middle of the solving (i.e. in-processing), using learnt clauses, doing asymmetric branching, binary clause reasoning, variable replacement, blocked clause elimination, failed literal probing, tautology elimination, clause strenghtening with tautological binary clauses, clause cleaning, and a long list of others \u0026ndash; that\u0026rsquo;s where the hard part lies.\nWith all of these challenges facing SAT solver implementers, is it reasonable to think that anyone can relatively easily participate in SAT Races and SAT Competitions? If one wishes to respond with yes to this question, then there are two paths ahead: either immense amounts of time need to be invested into writing such a solver, or an already written solver has to be taken as a base to build ideas upon. I think the only reasonable choices for a base are: lingeling, MiniSat, PrecoSat and (I hope to think) CryptoMiniSat. None of these solvers are perfect of course, so one has to put up with all the inherent problems in these solvers.\nIn the past months, I have been writing many blog entries trying to detail the inner workings of SAT solvers \u0026ndash; mostly to help others (and in the process, myself) struggling with SAT solvers. Maybe I should be spending more time trying to document the code of CryptoMiniSat, so that the barrier for entry to creating winning SAT solvers could be lowered.\n","permalink":"https://www.msoos.org/2010/09/creating-a-sat-solver-from-scratch/","summary":"\u003cp\u003eI have lately been having a small chat with \u003ca href=\"http://www.spirtech.com/fgr/index.htm\"\u003eFrancois Grieu\u003c/a\u003e and it inspired me to think about how difficult it would be to create a new SAT solver from scratch. Let\u0026rsquo;s take it for granted that the person who embarks on such a difficult task understands the basics well, and wishes to create a (nowadays very popular) Conflict-Driven Clause-Learning (or simply, CDCL) type SAT solver. The main parts of  these solvers are:\u003c/p\u003e","title":"Creating a SAT solver from scratch"},{"content":"It is sometimes important to be able to quickly convert a binary function, described in as a truth table, to its Algebraic Normal Form (or simply, ANF). The truth table basically lists the points where a function is 1 and when it is 0. For instance, if the function has two variables, and its truth table is 0110 or, in hexadecimal form, 0x5 then the ANF of this function is simply x0 + x1, where x0 is the first variable of the function, and x1 is the second.\nWhen it comes to more complex functions, an automatic method for this conversion is helpful. The Sage software can do exactly that:\nsage: from sage.crypto.boolean_function import BooleanFunction sage: B = BooleanFunction(\u0026#34;0123456789ABCDEF\u0026#34;) sage: B.algebraic_normal_form() x0*x1*x2 + x0*x1*x3 + x0*x1*x4 + x0*x1*x5 + x0*x2 + x0*x3 + x1*x2 + x1*x4 + x2 + 1 Here, we used Sage to convert the function given by the truth table (in hex) 0x0123456789ABCDEF to its ANF equivalent.\nI have long searched for a method for this, but at the end it was Luk Bettale who showed me the way. Many thanks to him for this!\n","permalink":"https://www.msoos.org/2010/09/truth-table-to-anf-conversion/","summary":"\u003cp\u003eIt is sometimes important to be able to quickly convert a binary function, described in as a \u003ca href=\"http://en.wikipedia.org/wiki/Truth_table\"\u003etruth table\u003c/a\u003e, to its \u003ca href=\"http://en.wikipedia.org/wiki/Algebraic_normal_form\"\u003eAlgebraic Normal Form\u003c/a\u003e (or simply, ANF). The truth table basically lists the points where a function is 1 and when it is 0. For instance, if the function has two variables, and its truth table is \u003ccode\u003e0110\u003c/code\u003e or, in hexadecimal form, \u003ccode\u003e0x5\u003c/code\u003e then the ANF of this function is simply \u003ccode\u003ex0 + x1\u003c/code\u003e, where \u003ccode\u003ex0\u003c/code\u003e is the first variable of the function, and \u003ccode\u003ex1\u003c/code\u003e is the second.\u003c/p\u003e","title":"Truth table to ANF conversion"},{"content":"Version 2.6.0 of the CryptoMiniSat SAT solver has been released. The new release incorporates a number of important additions and discoveries. Additions include a better memory manager and better watchlists, while the discoveries include an interesting use of asymmetric branching and an on-the-fly self-subsuming resolution algorithm.\nThe new solver can now solve 221 problems from the SAT Competition of 2009 within the same timing\u0026amp;CPU constraints, while the 2.5.0 (i.e. SAT Race) version could only solve 217. Here is a comparison plot:\nThe cut-off for the competition for these machines was approx at 5000 sec. As can be seen from the graph (which goes until 6000 sec), the new solver does even better in the longer run: the additions seem to improve the long-term behaviour.\nAs for the future, I think there is still a lot of things to do. For example, the solver still doesn\u0026rsquo;t have blocked clause elimination, which could help, and it is still missing some ideas that others have published. Notably, it doesn\u0026rsquo;t do on-the-fly subsumption at every step of the conflict generation process, only at the very last step. In case you are interested to add any of these in a transparent manner, feel free to hack away at the git repository.\nEdited to Add (3/09/2010): The performance of CryptoMiniSat on the SAT Race 2010 problems has also changed with the new version. The new CryptoMiniSat can now solve 75 problems (instead of 74) within the time limit. More importantly, the average time to solve these 75 instances has decreased considerably, to around 111 seconds per instance (from 138 s/inst), which is very close to the results of lingeling, an extremely fast and very advanced solver. There is still a lot to be learnt from lingeling, however: its memory footprint is far smaller, and its preprocessing techniques in some areas are much better than that of CryptoMiniSat.\n","permalink":"https://www.msoos.org/2010/08/cryptominisat-2-6-0-released/","summary":"\u003cp\u003eVersion 2.6.0 of the CryptoMiniSat SAT solver has been \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\u0026amp;release_id=5352\"\u003ereleased\u003c/a\u003e. The new release incorporates a number of important additions and discoveries. Additions include a better memory manager and \u003ca href=\"/wordpress/?p=7\"\u003ebetter watchlists\u003c/a\u003e, while the discoveries include an interesting use of \u003ca href=\"/wordpress/?p=6\"\u003easymmetric branching\u003c/a\u003e and an \u003ca href=\"/wordpress/?p=169\"\u003eon-the-fly self-subsuming resolution\u003c/a\u003e algorithm.\u003c/p\u003e\n\u003cp\u003eThe new solver can now solve 221 problems from the \u003ca href=\"http://www.cril.univ-artois.fr/SAT09/results/ranking.php?idev=29\"\u003eSAT Competition\u003c/a\u003e of 2009 within the same timing\u0026amp;CPU constraints, while the 2.5.0 (i.e. \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/results.html\"\u003eSAT Race\u003c/a\u003e) version could only solve 217. Here is a comparison plot:\u003c/p\u003e","title":"CryptoMiniSat 2.6.0 released"},{"content":"I have recently been trying a new method of shortening learnt clauses. There is a learnt clause minimisation paper by Sörensson and Biere, and I have recently been trying to do more. The trick I use, is that many literals can be removed from learnt clauses, if self-subsuming resolution (see my older post) is applied to them.\nDuring self-subsuming resolution, under normal circumstances, the clauses used to remove literals with are the short clauses: binary and tertiary clauses. The trick I have discovered, is that since CryptoMiniSat keeps binary and tertiary clauses natively inside the watchlists (see my previous post), so doing self-subsuming resolution can be done extremely fast. We simply need to put the literals of the newly learnt clause into a fast-addressable memory, then go through the watchlists of every literal in the clause, and remove the literals that match.\nThe code used to achieve this is the following:\nfor (uint32_t i = 0; i \u0026lt; cl.size(); i++) seen[cl[i].toInt()] = 1; for (Lit *l = cl.getData(), *end = cl.getDataEnd(); l != end; l++) { if (seen[l-\u0026gt;toInt()] == 0) continue; Lit lit = *l; //watched is messed: lit is in watched[~lit] vec\u0026amp; ws = watches[(~lit).toInt()]; for (Watched* i = ws.getData(), *end = ws.getDataEnd(); i != end; i++) { if (i-\u0026gt;isBinary()) { if (seen[(~i-\u0026gt;getOtherLit()).toInt()]) { seen[(~i-\u0026gt;getOtherLit()).toInt()] = 0; } } } } Lit *i = cl.getData(); Lit *j= i; for (Lit* end = cl.getDataEnd(); i != end; i++) { if (seen[i-\u0026gt;toInt()]) *j++ = *i; seen[i-\u0026gt;toInt()] = 0; } cl.shrink(i-j); Essentially, we set the seen vector (which is initially all 0), to 1 where the original clause contained a literal. Then, we go through the watchlists, and check if any binary clause could strengthen the clause. If so, we unset the corresponding bit in seen. Finally, we clean the clause from the literals where seen is 0 (and then set all parts of seen back to 0).\nThe actual implementation only differs from the one above by also using tertiary clauses (which are also natively inside the watchlists) to do self-subsuming resolution. The results are very promising: CryptoMiniSat can now solve 2 more problems from the 2009 SAT Competition instances within the original time limit, and seems to scale better in the longer run, too. An example statistics output of CryptoMiniSat (from the UTI-20-10p1 problem):\nc OTF cl watch-shrink : 961191 (0.64 clauses/conflict) c OTF cl watch-sh-lit : 6096451 (6.34 lits/clause) which means that in 64% of the cases, on-the-fly self-subsuming resolution was useful, and on average, it removed 6.3 literals from each clause where it was useful.\n","permalink":"https://www.msoos.org/2010/08/on-the-fly-self-subsuming-resolution/","summary":"\u003cp\u003eI have recently been trying a new method of shortening learnt clauses. There is a learnt clause minimisation \u003ca href=\"http://dx.doi.org/10.1007/978-3-642-02777-2_23\"\u003epaper\u003c/a\u003e by Sörensson and Biere, and I have recently been trying to do more. The trick I use, is that many literals can be removed from learnt clauses, if self-subsuming resolution (see my \u003ca href=\"/wordpress/?p=5\"\u003eolder post\u003c/a\u003e) is applied to them.\u003c/p\u003e\n\u003cp\u003eDuring self-subsuming resolution, under normal circumstances, the clauses used to remove literals with are the short clauses: binary and tertiary clauses. The trick I have discovered, is that since CryptoMiniSat keeps binary and tertiary clauses natively inside the watchlists (see my \u003ca href=\"/wordpress/?p=7\"\u003eprevious post\u003c/a\u003e), so doing self-subsuming resolution can be done extremely fast. We simply need to put the literals of the newly learnt clause into a fast-addressable memory, then go through the watchlists of every literal in the clause, and remove the literals that match.\u003c/p\u003e","title":"On-the-fly self-subsuming resolution"},{"content":" Jiong Yang, Yong Kiam Tan, Mate Soos, Magnus O. Myreen, Kuldeep S. Meel: Efficient Certified Reasoning for Binarized Neural Networks\nSAT 2025 [arXiv] Mate Soos, Kuldeep S. Meel: Engineering an Efficient Probabilistic Exact Model Counter\nCAV 2025 [DOI] Mate Soos, Sourav Chakraborty, Kuldeep S. Meel: Testing and Design of Uniform CNF Samplers: A Virtuous Cycle Enabled by Distribution Testing\nEngineering Trustworthy Software Systems (SETSS 2024), LNCS, 2025 [DOI] Mate Soos, Kuldeep S. Meel: Engineering an Efficient Preprocessor for Model Counting\nDAC 2024 [DOI] Yong Kiam Tan, Jiong Yang, Mate Soos, Magnus O. Myreen, Kuldeep S. Meel: Formally Certified Approximate Model Counting\nCAV 2024 [DOI] dxo, Mate Soos, Zoe Paraskevopoulou, Martin Lundfall, Mikael Brockman: Hevm, a Fast Symbolic Execution Framework for EVM Bytecode\nCAV 2024 [DOI] Mate Soos, Uddalok Sarkar, Divesh Aggarwal, Sourav Chakraborty, Kuldeep S. Meel, Maciej Obremski: Engineering an Efficient Approximate DNF-Counter\nIJCAI 2023 [DOI] Markus Anders, Pascal Schweitzer, Mate Soos: Algorithms Transcending the SAT-Symmetry Interface\nSAT 2023 [DOI] Jiong Yang, Arijit Shaw, Teodora Baluta, Mate Soos, Kuldeep S. Meel: Explaining SAT Solving Using Causal Reasoning\nSAT 2023 [DOI] Renzo Roel P. Tan, Aldrich Ellis C. Asuncion, Brian Godwin Lim, Mate Soos, Kazushi Ikeda: The Pancake Graph of Order 10 Is 4-Colorable\nICoMS 2023 [DOI] Mate Soos, Randal E. Bryant: Proof Generation for CDCL Solvers Using Gauss-Jordan Elimination\nPreprint, 2023 [arXiv] Mate Soos, Priyanka Golia, Sourav Chakraborty, Kuldeep S. Meel: On Quantitative Testing of Samplers\nCP 2022 [DOI] Mate Soos, Kuldeep S. Meel: Arjun: An Efficient Independent Support Computation Technique and its Applications to Counting and Sampling\nICCAD 2022 [DOI] Priyanka Golia, Mate Soos, Sourav Chakraborty, Kuldeep S. Meel: Designing Samplers is Easy: The Boon of Testers\nFMCAD 2021 [DOI] Mate Soos, Kuldeep S. Meel: Gaussian Elimination Meets Maximum Satisfiability\nKR 2021 [DOI] Nicolas Prevot, Mate Soos, Kuldeep S. Meel: Leveraging GPUs for Effective Clause Sharing in Parallel SAT Solving\nSAT 2021 [DOI] Mate Soos, Stephan Gocht, Kuldeep S. Meel: Tinted, Detached, and Lazy CNF-XOR Solving and Its Applications to Counting and Sampling\nCAV 2020 [DOI] Mate Soos, Raghav Kulkarni, Kuldeep S. Meel: CrystalBall: Gazing in the Black Box of SAT Solving\nSAT 2019 [DOI] Shubham Sharma, Subhajit Roy, Mate Soos, Kuldeep S. Meel: GANAK: A Scalable Probabilistic Exact Model Counter\nIJCAI 2019 [DOI] Mate Soos, Kuldeep S. Meel: BIRD: Engineering an Efficient CNF-XOR SAT Solver and Its Applications to Approximate Model Counting\nAAAI 2019 [DOI] Davin Choo, Mate Soos, Kian Ming A. Chai, Kuldeep S. Meel: Bosphorus: Bridging ANF and CNF Solvers\nDATE 2019 [DOI] Vijay Ganesh, Charles W. O\u0026rsquo;Donnell, Mate Soos, Srinivas Devadas, Martin C. Rinard, Armando Solar-Lezama: Lynx: A Programmatic SAT Solver for the RNA-Folding Problem\nSAT 2012 [DOI] Manuel San Pedro, Mate Soos, Sylvain Guilley: FIRE: Fault Injection for Reverse Engineering\nWISTP 2011 [DOI] Mate Soos: Enhanced Gaussian Elimination in DPLL-based SAT Solvers\nWorkshop paper [PDF] [Presentation PDF] [DOI]\nPragmatics of SAT, Edinborough, 2010\nBenchs used are available here. Mate Soos: Grain of Salt \u0026ndash; An Automated Way to Test Stream Ciphers through SAT Solvers\nWorkshop paper [PDF] [Presentation PDF]\nWorkshop on Tools for Cryptanalysis, Royal Holloway, University of London, 2010 Mate Soos: Privacy-preserving Security Protocols for RFIDs\nPhD Thesis [ PDF][ Presentation PDF]\nRhône-Alpes, France, 2009 Mate Soos, Karsten Nohl, Claude Castelluccia: Extending SAT Solvers to Cryptographic Problems\nFull paper [PDF] [Presentation PDF] [DOI]\nSAT'09, Swansea, 2009 Karsten Nohl, Mate Soos: Solving Low-Complexity Ciphers with Optimized SAT Solvers\nPoster [PDF]\nEurocrypt'09, Cologne, 2009 Mate Soos: Analysing the Molva and Di Pietro Private RFID Authentication Scheme\nFull paper [PDF] [Presentation PDF]\nRFIDSec'08, Budapest, 2008 Claude Castelluccia, Mate Soos: Secret Shuffling: A Novel Approach to RFID Private Identification\nFull paper [PDF] [Presentation PDF]\nRFIDSec'07, Malaga, 2007 ","permalink":"https://www.msoos.org/publications/","summary":"\u003cul\u003e\n\u003cli\u003eJiong Yang, Yong Kiam Tan, Mate Soos, Magnus O. Myreen, Kuldeep S. Meel: \u003cstrong\u003eEfficient Certified Reasoning for Binarized Neural Networks\u003c/strong\u003e\u003cbr\u003e\nSAT 2025 \u003ca href=\"https://arxiv.org/abs/2507.02916\"\u003e[arXiv]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Kuldeep S. Meel: \u003cstrong\u003eEngineering an Efficient Probabilistic Exact Model Counter\u003c/strong\u003e\u003cbr\u003e\nCAV 2025 \u003ca href=\"https://doi.org/10.1007/978-3-031-98682-6_5\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Sourav Chakraborty, Kuldeep S. Meel: \u003cstrong\u003eTesting and Design of Uniform CNF Samplers: A Virtuous Cycle Enabled by Distribution Testing\u003c/strong\u003e\u003cbr\u003e\nEngineering Trustworthy Software Systems (SETSS 2024), LNCS, 2025 \u003ca href=\"https://doi.org/10.1007/978-981-96-4656-2_5\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Kuldeep S. Meel: \u003cstrong\u003eEngineering an Efficient Preprocessor for Model Counting\u003c/strong\u003e\u003cbr\u003e\nDAC 2024 \u003ca href=\"https://doi.org/10.1145/3649329.3658489\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eYong Kiam Tan, Jiong Yang, Mate Soos, Magnus O. Myreen, Kuldeep S. Meel: \u003cstrong\u003eFormally Certified Approximate Model Counting\u003c/strong\u003e\u003cbr\u003e\nCAV 2024 \u003ca href=\"https://doi.org/10.1007/978-3-031-65627-9_8\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003edxo, Mate Soos, Zoe Paraskevopoulou, Martin Lundfall, Mikael Brockman: \u003cstrong\u003eHevm, a Fast Symbolic Execution Framework for EVM Bytecode\u003c/strong\u003e\u003cbr\u003e\nCAV 2024 \u003ca href=\"https://doi.org/10.1007/978-3-031-65627-9_22\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Uddalok Sarkar, Divesh Aggarwal, Sourav Chakraborty, Kuldeep S. Meel, Maciej Obremski: \u003cstrong\u003eEngineering an Efficient Approximate DNF-Counter\u003c/strong\u003e\u003cbr\u003e\nIJCAI 2023 \u003ca href=\"https://doi.org/10.24963/ijcai.2023/226\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMarkus Anders, Pascal Schweitzer, Mate Soos: \u003cstrong\u003eAlgorithms Transcending the SAT-Symmetry Interface\u003c/strong\u003e\u003cbr\u003e\nSAT 2023 \u003ca href=\"https://doi.org/10.4230/LIPIcs.SAT.2023.1\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eJiong Yang, Arijit Shaw, Teodora Baluta, Mate Soos, Kuldeep S. Meel: \u003cstrong\u003eExplaining SAT Solving Using Causal Reasoning\u003c/strong\u003e\u003cbr\u003e\nSAT 2023 \u003ca href=\"https://doi.org/10.4230/LIPIcs.SAT.2023.28\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eRenzo Roel P. Tan, Aldrich Ellis C. Asuncion, Brian Godwin Lim, Mate Soos, Kazushi Ikeda: \u003cstrong\u003eThe Pancake Graph of Order 10 Is 4-Colorable\u003c/strong\u003e\u003cbr\u003e\nICoMS 2023 \u003ca href=\"https://doi.org/10.1145/3613347.3613348\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Randal E. Bryant: \u003cstrong\u003eProof Generation for CDCL Solvers Using Gauss-Jordan Elimination\u003c/strong\u003e\u003cbr\u003e\nPreprint, 2023 \u003ca href=\"https://arxiv.org/abs/2304.04292\"\u003e[arXiv]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Priyanka Golia, Sourav Chakraborty, Kuldeep S. Meel: \u003cstrong\u003eOn Quantitative Testing of Samplers\u003c/strong\u003e\u003cbr\u003e\nCP 2022 \u003ca href=\"https://doi.org/10.4230/LIPIcs.CP.2022.36\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Kuldeep S. Meel: \u003cstrong\u003eArjun: An Efficient Independent Support Computation Technique and its Applications to Counting and Sampling\u003c/strong\u003e\u003cbr\u003e\nICCAD 2022 \u003ca href=\"https://doi.org/10.1145/3508352.3549406\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003ePriyanka Golia, Mate Soos, Sourav Chakraborty, Kuldeep S. Meel: \u003cstrong\u003eDesigning Samplers is Easy: The Boon of Testers\u003c/strong\u003e\u003cbr\u003e\nFMCAD 2021 \u003ca href=\"https://doi.org/10.34727/2021/isbn.978-3-85448-046-4_31\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Kuldeep S. Meel: \u003cstrong\u003eGaussian Elimination Meets Maximum Satisfiability\u003c/strong\u003e\u003cbr\u003e\nKR 2021 \u003ca href=\"https://doi.org/10.24963/kr.2021/55\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eNicolas Prevot, Mate Soos, Kuldeep S. Meel: \u003cstrong\u003eLeveraging GPUs for Effective Clause Sharing in Parallel SAT Solving\u003c/strong\u003e\u003cbr\u003e\nSAT 2021 \u003ca href=\"https://doi.org/10.1007/978-3-030-80223-3_32\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Stephan Gocht, Kuldeep S. Meel: \u003cstrong\u003eTinted, Detached, and Lazy CNF-XOR Solving and Its Applications to Counting and Sampling\u003c/strong\u003e\u003cbr\u003e\nCAV 2020 \u003ca href=\"https://doi.org/10.1007/978-3-030-53288-8_22\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Raghav Kulkarni, Kuldeep S. Meel: \u003cstrong\u003eCrystalBall: Gazing in the Black Box of SAT Solving\u003c/strong\u003e\u003cbr\u003e\nSAT 2019 \u003ca href=\"https://doi.org/10.1007/978-3-030-24258-9_26\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eShubham Sharma, Subhajit Roy, Mate Soos, Kuldeep S. Meel: \u003cstrong\u003eGANAK: A Scalable Probabilistic Exact Model Counter\u003c/strong\u003e\u003cbr\u003e\nIJCAI 2019 \u003ca href=\"https://doi.org/10.24963/ijcai.2019/163\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos, Kuldeep S. Meel: \u003cstrong\u003eBIRD: Engineering an Efficient CNF-XOR SAT Solver and Its Applications to Approximate Model Counting\u003c/strong\u003e\u003cbr\u003e\nAAAI 2019 \u003ca href=\"https://doi.org/10.1609/aaai.v33i01.33011592\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eDavin Choo, Mate Soos, Kian Ming A. Chai, Kuldeep S. Meel: \u003cstrong\u003eBosphorus: Bridging ANF and CNF Solvers\u003c/strong\u003e\u003cbr\u003e\nDATE 2019 \u003ca href=\"https://doi.org/10.23919/DATE.2019.8715061\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eVijay Ganesh, Charles W. O\u0026rsquo;Donnell, Mate Soos, Srinivas Devadas, Martin C. Rinard, Armando Solar-Lezama: \u003cstrong\u003eLynx: A Programmatic SAT Solver for the RNA-Folding Problem\u003c/strong\u003e\u003cbr\u003e\nSAT 2012 \u003ca href=\"https://doi.org/10.1007/978-3-642-31612-8_12\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eManuel San Pedro, Mate Soos, Sylvain Guilley: \u003cstrong\u003eFIRE: Fault Injection for Reverse Engineering\u003c/strong\u003e\u003cbr\u003e\nWISTP 2011 \u003ca href=\"https://doi.org/10.1007/978-3-642-21040-2_20\"\u003e[DOI]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eMate Soos: \u003cstrong\u003eEnhanced Gaussian Elimination in DPLL-based SAT Solvers\u003c/strong\u003e\u003cbr\u003e\nWorkshop paper \u003ca href=\"/wordpress/wp-content/uploads/2010/08/PoS10-Soos.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"/largefiles/pos_soos_pres.pdf\"\u003e[Presentation PDF]\u003c/a\u003e \u003ca href=\"https://doi.org/10.29007/g7ss\"\u003e[DOI]\u003c/a\u003e\u003cbr\u003e\nPragmatics of SAT, Edinborough, 2010\u003cbr\u003e\nBenchs used are available \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1476\"\u003ehere\u003c/a\u003e.\u003c/li\u003e\n\u003cli\u003eMate Soos: \u003cstrong\u003eGrain of Salt \u0026ndash; An Automated Way to Test Stream Ciphers through SAT Solvers\u003c/strong\u003e\u003cbr\u003e\nWorkshop paper \u003ca href=\"/wordpress/wp-content/uploads/2011/06/GrainOfSalt-1.1-desc.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"/largefiles/tools_soos_pres.pdf\"\u003e[Presentation PDF]\u003c/a\u003e\u003cbr\u003e\nWorkshop on Tools for Cryptanalysis, Royal Holloway, University of London, 2010\u003c/li\u003e\n\u003cli\u003eMate Soos: \u003cstrong\u003ePrivacy-preserving Security Protocols for RFIDs\u003c/strong\u003e\u003cbr\u003e\nPhD Thesis [ \u003ca href=\"/wordpress/wp-content/uploads/2012/03/soos_thesis_v3.pdf\"\u003ePDF\u003c/a\u003e][ \u003ca href=\"/largefiles/defense_soos_pres.pdf\"\u003ePresentation PDF\u003c/a\u003e]\u003cbr\u003e\nRhône-Alpes, France, 2009\u003c/li\u003e\n\u003cli\u003eMate Soos, Karsten Nohl, Claude Castelluccia: \u003cstrong\u003eExtending SAT Solvers to Cryptographic Problems\u003c/strong\u003e\u003cbr\u003e\nFull paper \u003ca href=\"/wordpress/wp-content/uploads/2011/03/Extending_SAT_2009.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"/wordpress/wp-content/uploads/2010/08/Extending_SAT_2009_pres.pdf\"\u003e[Presentation PDF]\u003c/a\u003e \u003ca href=\"https://doi.org/10.1007/978-3-642-02777-2_24\"\u003e[DOI]\u003c/a\u003e\u003cbr\u003e\nSAT'09, Swansea, 2009\u003c/li\u003e\n\u003cli\u003eKarsten Nohl, Mate Soos: \u003cstrong\u003eSolving Low-Complexity Ciphers with Optimized SAT Solvers\u003c/strong\u003e\u003cbr\u003e\nPoster \u003ca href=\"/largefiles/Low-complexity-poster.pdf\"\u003e[PDF]\u003c/a\u003e\u003cbr\u003e\nEurocrypt'09, Cologne, 2009\u003c/li\u003e\n\u003cli\u003eMate Soos: \u003cstrong\u003eAnalysing the Molva and Di Pietro Private RFID Authentication Scheme\u003c/strong\u003e\u003cbr\u003e\nFull paper \u003ca href=\"/wordpress/wp-content/uploads/2010/08/Analysing_Molva_final.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"/wordpress/wp-content/uploads/2010/09/analysing_molva_soos_pres.pdf\"\u003e[Presentation PDF]\u003c/a\u003e\u003cbr\u003e\nRFIDSec'08, Budapest, 2008\u003c/li\u003e\n\u003cli\u003eClaude Castelluccia, Mate Soos: \u003cstrong\u003eSecret Shuffling: A Novel Approach to RFID Private Identification\u003c/strong\u003e\u003cbr\u003e\nFull paper \u003ca href=\"/wordpress/wp-content/uploads/2010/08/ProbIP_final_Malaga.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"/wordpress/wp-content/uploads/2010/09/probip_pres_soos.pdf\"\u003e[Presentation PDF]\u003c/a\u003e\u003cbr\u003e\nRFIDSec'07, Malaga, 2007\u003c/li\u003e\n\u003c/ul\u003e","title":"Publications"},{"content":"This is just a short list of things that are often asked about MiniSat. The answers refer to its current version. If you have more questions, maybe you can browse the MiniSat google groups, or read the other FAQ by David A. Wheeler, and maybe the definition of the DIMACS file format. I also suggest to attentively read the output of ./minisat --help, of which the most important part is:\nUSAGE: ./minisat [options] \u0026lt;input-file\u0026gt; \u0026lt;result-output-file\u0026gt; where input may be either in plain or gzipped DIMACS. CORE OPTIONS: -luby, -no-luby (default: on) -rnd-init, -no-rnd-init (default: off) -gc-frac = \u0026lt;double\u0026gt; ( 0 .. inf) (default: 0.2) -rinc = \u0026lt;double\u0026gt; ( 1 .. inf) (default: 2) -rnd-seed = \u0026lt;double\u0026gt; ( 0 .. inf) (default: 9.16483e+07) -rnd-freq = \u0026lt;double\u0026gt; [ 0 .. 1] (default: 0) -cla-decay = \u0026lt;double\u0026gt; ( 0 .. 1) (default: 0.999) -var-decay = \u0026lt;double\u0026gt; ( 0 .. 1) (default: 0.95) -rfirst = \u0026lt;int32\u0026gt; [ 1 .. imax] (default: 100) -ccmin-mode = \u0026lt;int32\u0026gt; [ 0 .. 2] (default: 2) -phase-saving = \u0026lt;int32\u0026gt; [ 0 .. 2] (default: 2) -min-learnts = \u0026lt;int32\u0026gt; [ 0 .. imax] (default: 0) MAIN OPTIONS: -strict, -no-strict (default: off) -pre, -no-pre (default: on) -verb = \u0026lt;int32\u0026gt; [ 0 .. 2] (default: 1) How are variables picked? The function responsible is pickBranchLit() in MiniSat. There are two methods of picking. One picks from an ordered heap, and the other picks totally randomly. By default, MiniSat never picks randomly (see random_var_freq), though this is adjustable from the command line (see the -rnd-freq=X option, where X is the fraction of random picks). The ordered heap is simply an ordered set of variables. A variable is higher in the list if it appeared lots of times in the clauses that were involved in recent conflicts (see in function analyze() the part with varBumpActivity()).\nWhy doesn\u0026rsquo;t MiniSat find the solution to my problem that has at most 2-3 really important variables? This is related to the previous question. You probably have a LOT of internal variables (that are not important), and MiniSat doesn\u0026rsquo;t know which variables are important: its heuristic only looks at which variables take part in conflicts, so it can get lost in a part of the search space that is uninteresting. If you have turned on random picks with -rnd-freq, turn them off. If you use MiniSat as a library, you can call setDecisionVar(v, false) for the internal variables so that MiniSat only branches on the important ones. Only do this for variables whose values are fully determined by the important ones: when all decision variables are set, MiniSat reports the problem as satisfiable even if some non-decision variables are still unassigned.\nMiniSat is taking too long to solve my cryptographic function! Try giving some randomly selected, randomly assigned \u0026ldquo;help bits\u0026rdquo;. These \u0026ldquo;help bits\u0026rdquo; should be of course your important variables (e.g. internal state or key). Run these random experiments with N number of help bits for 1000 times, and average the time. Now run with N-1 help bits, and average the time. Repeat with N-2, N-3\u0026hellip; until you have enough points on the graph. The produced graph should be easy to extrapolate.\nDoes MiniSat check my p cnf VARS CLAUSES header? Only if you ask it to. MiniSat reads the header, but by default it doesn\u0026rsquo;t enforce it: it automatically adds variables (see newVar()) and clauses (see addClause()) as it reads them. With the -strict option, it prints PARSE ERROR! DIMACS header mismatch: wrong number of clauses if the number of clauses doesn\u0026rsquo;t match the header.\nHow do I make my CNF file prettier? It looks like a spaghetti! Use comments. They are lines starting with a c, like this:\nc ------------ c clauses that code down equation number 3749 10 -2 7 0 14 -8 2 0 9 -1 5 0 c ----------- Does variable numbering matter? No. But take care: if your variable numbers start at 100000, or a large range of variable numbers are unused, then MiniSat will have to store and work with useless memory contents. So, in general, use every variable number possible from 1 up. Don\u0026rsquo;t leave gaps, and don\u0026rsquo;t start numbering from large variable numbers.\nIf I change the order of the clauses, MiniSat solves faster/slower! That\u0026rsquo;s by chance. MiniSat inserts the first clause of the DIMACS file into the beginning of its literal watch-lists (see attachClause()). When MiniSat starts propagating, it will propagate the first possible propagatable variable. So, depending on which is the first, second, etc. MiniSat will behave differently.\nIf you need to have an average time to solve for a certain problem, you should permute the clauses and also change the random seed of the solver, for example with CryptoMiniSat\u0026rsquo;s --seed=X option.\nMiniSat is so fast to solve a problem whose unknown variables are almost all false! This is because MiniSat guesses unknown variables to false by default (see the polarity initialisation in newVar() and its use in pickBranchLit()). Once a variable has been assigned, MiniSat by default remembers its last value and guesses that next time (\u0026ldquo;phase saving\u0026rdquo;, see the -phase-saving option; -phase-saving=0 turns it off). If you use MiniSat as a library, you can set the preferred polarity of a variable yourself, see newVar() and setPolarity().\nMiniSat is so slow to solve a problem whose unknown variables are almost all true! See previous question.\nI have a simple linear set of equations, and MiniSat cannot solve it! Let\u0026rsquo;s suppose we have a linear set of equations like: ( + is the binary XOR, variables are binary)\na + b + c + ... = true a + c + e + ... = false ... Let\u0026rsquo;s convert these equations to CNF! The SAT solver will not solve it in any reasonable amount of time. However, Gaussian elimination will solve it in seconds! Why? Because MiniSat doesn\u0026rsquo;t understand the structure of the problem. It will simply guess some of the variables and try to make propagations. However, if the equations are dense, then MiniSat will need to guess a lot of variables before any propagations can be made. So, the search tree will be huge.\nTo overcome this problem, CryptoMiniSat does Gauss-Jordan elimination on XOR constraints, which is on by default. You can give it the XORs directly, or let it recover them from the CNF; see the CryptoMiniSat FAQ for the details.\nHow can I make my solving faster? This is too complex of a topic to go into. What I suggest are the following:\nHave a look at the conversion of your functions to CNF. Maybe some can be improved? Try to use the excellent espresso logic minimiser or use BOOM. Do you have a lot of XOR functions? Maybe you should consider using CryptoMiniSat. It handles XOR-s natively Maybe you have forgotten to add the redundant clauses during the Tseitin transformation? (see page 5 of article by Een et al.) Try to encode your problem by minimising the size and the number of clauses instead of the number of variables. Naturally, there is a trade-off, but focusing solely on the number of variables can lead to problems Maybe other tools would work better. Grobner base algorithms are a starting point How can I make MiniSat find ALL the solutions to a problem? First of all, make sure the number of solutions is not too big. Then simply solve once, and output the solution to a file: ./minisat satfile solution. Then simply put in a clause into the satfile that is false for the found solution. E.g. let\u0026rsquo;s suppose the solution was\n1 = true, 2 = true, 3 = false Then put into the satfile the line:\n-1 -2 3 0 and run MiniSat again. If the solution is UNSAT, then there are no other solutions. If it is SAT, then again put in a clause that bans that one solution. Iterate this as many times as you need a solution. (There is another way of doing this by using MiniSat as a library. It\u0026rsquo;s faster, too.)\nThere is a somewhat more detailed example in this FAQ, under the heading \u0026ldquo;Getting more solutions\u0026rdquo;.\nWhy is MiniSat giving me UNSAT without even looking at my file? You probably have a line in your file that only has a 0 in it:\n0 this is an empty clause and so it is unsatisfiable. Therefore the system of clauses is unsatisfiable. Remove this clause.\nHow can I control the number of clauses learnt during solving? Tweak the learntsize_factor and the learntsize_inc variables in MiniSat. Learning a lot of clauses might slow down the solver since it needs to jump to these clauses often to see if any of them make a conflict/propagation. But having too few, learning doesn\u0026rsquo;t help to trim the search tree. But the trade-off can be different for your problem. The values that are used in MiniSat are 1/3 for the init (i.e. learntsize_factor) and 1.1 for the increase per restart (i.e. learntsize_inc).\nI want to make MiniSat run faster. What can I do? If you use the gcc compiler, compile with flags \u0026quot;-O3 -g0 -march=native\u0026quot;.\nI want to know exactly what happens during solving! Use small example problems, and turn up the verbosity: MiniSat\u0026rsquo;s -verb=2, or CryptoMiniSat\u0026rsquo;s --verb, which goes up to 10. When built with SQLite support, CryptoMiniSat can also write data about the clauses it learns into an SQLite database (--sql).\nHow does MiniSat keep track of which variable caused a propagation/conflict? It\u0026rsquo;s always the first literal in the clause that is causing the propagation or conflict (see propagate()\u0026rsquo;s first reference variable).\nWhy doesn\u0026rsquo;t MiniSat simply use a vector\u0026lt;Lit\u0026gt; to store the literals in the clauses? Probably because from a cache\u0026amp;program-flow point of view, it\u0026rsquo;s simply not a good idea. vector will store a pointer to an allocated memory space, which is probably somewhere else than the other data (size, marking, etc) of the clause, so the processor would have to jump there every time. Also, when accessing the Clause\u0026rsquo;s info, e.g. size(), data that is adjacent to this memory location will be pulled into the cache automatically, pulling in exactly what will be looked at next: the literals.\nWhat is level and trail_lim? level(x) returns the decision level at which variable x was assigned; it is stored, together with the reason for the assignment, in vardata. trail is the stack of assigned literals, in the order they were assigned. trail_lim stores, for each decision level, the position in trail where that level starts. So the current decision level is simply decisionLevel(), which returns trail_lim.size().\nWhen guessing (=branching on) a variable, the following is called:\nnewDecisionLevel(); // trail_lim.push(trail.size()); uncheckedEnqueue(next); i.e. inside trail_lim the current position in the trail (trail.size()) is stored, and the newly guessed literal is pushed on the trail. Its reason is CRef_Undef, to indicate that it\u0026rsquo;s not a propagation, but a guess.\n","permalink":"https://www.msoos.org/tools/minisat-faq/","summary":"\u003cp\u003eThis is just a short list of things that are often asked about \u003ca href=\"https://github.com/niklasso/minisat\"\u003eMiniSat\u003c/a\u003e. The answers refer to its current version. If you have more questions, maybe you can browse the \u003ca href=\"http://groups.google.com/group/minisat\"\u003eMiniSat google groups\u003c/a\u003e, or read the other \u003ca href=\"http://www.dwheeler.com/essays/minisat-user-guide.html\"\u003eFAQ\u003c/a\u003e by David A. Wheeler, and maybe the definition of the \u003ca href=\"http://www.cs.ubc.ca/~hoos/SATLIB/Benchmarks/SAT/satformat.ps\"\u003eDIMACS\u003c/a\u003e file format. I also suggest to attentively read the output of \u003ccode\u003e./minisat --help\u003c/code\u003e, of which the most important part is:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-gdscript3\" data-lang=\"gdscript3\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eUSAGE: \u003cspan style=\"color:#f92672\"\u003e./\u003c/span\u003eminisat [options] \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003einput\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003efile\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003eresult\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eoutput\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003efile\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  where input may be either \u003cspan style=\"color:#f92672\"\u003ein\u003c/span\u003e plain \u003cspan style=\"color:#f92672\"\u003eor\u003c/span\u003e gzipped DIMACS\u003cspan style=\"color:#f92672\"\u003e.\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eCORE OPTIONS:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eluby, \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eno\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eluby                         (default: on)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003ernd\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003einit, \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eno\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003ernd\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003einit                 (default: off)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003egc\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003efrac      \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003edouble\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e (   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e  inf) (default: \u003cspan style=\"color:#ae81ff\"\u003e0.2\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003erinc         \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003edouble\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e (   \u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e  inf) (default: \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003ernd\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eseed     \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003edouble\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e (   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e  inf) (default: \u003cspan style=\"color:#ae81ff\"\u003e9.16483e+07\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003ernd\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003efreq     \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003edouble\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e [   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e    \u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e] (default: \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003ecla\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003edecay    \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003edouble\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e (   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e    \u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e) (default: \u003cspan style=\"color:#ae81ff\"\u003e0.999\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003e\u003cspan style=\"color:#66d9ef\"\u003evar\u003c/span\u003e\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003edecay    \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003edouble\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e (   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e    \u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e) (default: \u003cspan style=\"color:#ae81ff\"\u003e0.95\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003erfirst       \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003eint32\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e  [   \u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e imax] (default: \u003cspan style=\"color:#ae81ff\"\u003e100\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eccmin\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003emode   \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003eint32\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e  [   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e    \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e] (default: \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003ephase\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003esaving \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003eint32\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e  [   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e    \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e] (default: \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003emin\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003elearnts  \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003eint32\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e  [   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e imax] (default: \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eMAIN OPTIONS:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003estrict, \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eno\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003estrict                     (default: off)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003epre, \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003eno\u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003epre                           (default: on)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  \u003cspan style=\"color:#f92672\"\u003e-\u003c/span\u003everb         \u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e\u0026lt;\u003c/span\u003eint32\u003cspan style=\"color:#f92672\"\u003e\u0026gt;\u003c/span\u003e  [   \u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e \u003cspan style=\"color:#f92672\"\u003e..\u003c/span\u003e    \u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e] (default: \u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch3 id=\"how-are-variables-picked\"\u003eHow are variables picked?\u003c/h3\u003e\n\u003cp\u003eThe function responsible is \u003ccode\u003epickBranchLit()\u003c/code\u003e in MiniSat. There are two methods of picking. One picks from an ordered heap, and the other picks totally randomly. By default, MiniSat never picks randomly (see \u003ccode\u003erandom_var_freq\u003c/code\u003e), though this is adjustable from the command line (see the \u003ccode\u003e-rnd-freq=X\u003c/code\u003e option, where \u003ccode\u003eX\u003c/code\u003e is the fraction of random picks). The ordered heap is simply an ordered set of variables. A variable is higher in the list if it appeared lots of times in the clauses that were involved in recent conflicts (see in function \u003ccode\u003eanalyze()\u003c/code\u003e the part with \u003ccode\u003evarBumpActivity()\u003c/code\u003e).\u003c/p\u003e","title":"MiniSat FAQ"},{"content":" Naming the Harm – A privacy threat vocabulary for cypherpunks\nPresentation at Devcon 8, with Daniel Calderon\nMumbai, India, 3rd of November 2026\n[PDF] Naming the Harm – A privacy threat vocabulary for cypherpunks\nPresentation at the Neocypherpunk Summit 2026 (Berlin Blockchain Week), with Daniel Calderon\nBerlin, Germany, 14th of June 2026\n[PDF] SAT Preprocessing\nPresentation by Mate Soos at the Dagstuhl Seminar 26221\nDagstuhl, Germany, 26th of May 2026\n[PDF] Arjun as a Boolean-Function Synthesis Engine\nPresentation by Mate Soos at the Dagstuhl Seminar 26221\nDagstuhl, Germany, 26th of May 2026\n[PDF] hevm, new frontiers in symbolic execution of EVM bytecode\nPresentation at W3ST 2025 (Web3 Security Tools), Devconnect Argentina, with dxo, Martin Blicha and Zoe Paraskevopoulou\nBuenos Aires, Argentina, 19th of November 2025\n[PDF] IT Security: a game of counting the negatives, but can we do better? From Safety I to Safety II in IT Security\n2025\n[PDF] A gentle introduction to formal verification of Ethereum smart contracts\nLecture with hands-on tutorial at the 4th Summer School on Security Testing and Verification\nBrussels, Belgium, 9th of July 2025\n[PDF] Boolean Functional Synthesis and its possible application to Cryptography\nPresentation by Mate Soos at COSIC\nKU Leuven, Belgium, 8th of July 2025\n[PDF] hevm, a flexible symbolic execution framework to verify EVM bytecode\nPresentation at the Dagstuhl Seminar 25242: Testing Program Analyzers and Verifiers, with dxo and Zoe Paraskevopoulou\nDagstuhl, Germany, 11th of June 2025\n[PDF] hevm, a flexible symbolic execution framework to verify EVM bytecode\nPresentation at the BSA (Blockchain Student Association) Conference, EPFL, with dxo and Zoe Paraskevopoulou\nLausanne, Switzerland, 7th of March 2025\n[PDF] hevm, or: How I Learnt to Stop Worrying and Love the Symbolic Execution\nPresentation at Devcon 2024, with dxo and Zoe Paraskevopoulou\nBangkok, Thailand, 14th of November 2024\n[PDF] hevm, a Fast Symbolic Execution Framework for EVM Bytecode\nPresentation at Stanford University, with dxo, Zoe Paraskevopoulou, Martin Lundfall and Mikael Brockman\nStanford, USA, 19th of August 2024\n[PDF] hevm, a Fast Symbolic Execution Framework for EVM Bytecode\nPresentation at CAV 2024, with dxo, Zoe Paraskevopoulou, Martin Lundfall and Mikael Brockman\nMontreal, Canada, 26th of July 2024\n[PDF] [Paper] SAT Preprocessing\nPresentation at The SAT Winter School, based on slides by Armin Biere\nIIIT Hyderabad, India, 17th of December 2023\n[PDF] HEVM, a Smart Contract Verification Tool\nPresentation at IIT Bombay\nMumbai, India, 12th of December 2023\n[PDF] HEVM, a Smart Contract Verification Tool\nPresentation at the Berlin Ethereum Meetup\nBerlin, Germany, 25th of October 2023\n[PDF] [Video] On Quantitative Testing of Samplers\nPresentation at The Simons Institute\u0026rsquo;s Satisfiability: Theory, Practice, and Beyond Reunion, with Priyanka Golia, Sourav Chakraborty and Kuldeep S. Meel\nSimons Institute, Berkeley, USA, 15th of June 2022\n[PDF] [Paper] Solving CNF-XOR Formulas: A Practical Perspective\nPresentation at the Simons Institute SAT Program Seminar, part of Satisfiability: Theory, Practice, and Beyond\nSimons Institute, Berkeley, USA, 22nd of February 2021\n[PDF] SAT Solving and CDCL(T)\nPresentation at SAT+SMT Winter School, based on slides by Armin Biere\nIIT Bombay, Mumbai, India, 7th of December 2019\n[PDF] CrystalBall: Gazing in the Black Box of SAT Solving\nPresentation at SAT 2019, with Kuldeep S. Meel and Raghav Kulkarni\nLisbon, Portugal, July 2019\n[PDF] [Paper] Machine Learning Clause DB Management\nPresentation at Dagstuhl Seminar 19062: Bringing CP, SAT and SMT together: Next Challenges in Constraint Solving, with Raghav Kulkarni and Kuldeep S. Meel\nSchloss Dagstuhl – Leibniz Center for Informatics, Wadern, Germany, February 2019\n[PDF] Hacking using SAT and SMT Solvers\nPresentation at EMF Camp 2018\nEastnor, UK, 1st of September 2018\n[PDF] Why are SAT solvers so fast and how can you take advantage of their speed?\nPresentation at SUTD (Singapore University of Technology and Design)\nSingapore, 16th of May 2018\n[PDF] Rainbows: Creating and Looking up (without getting high)\nPresentation at AlligatorCon 2017\nKraków, Poland, August 2017\n[PDF] Lessons Learnt \u0026ndash; Seven Years of CryptoMiniSat\nPresentation at Pragmatics of SAT 2016, a workshop of the SAT 2016 conference\nBordeaux, France, 4th of July 2016\n[PDF] Infosec Through People, Process and Technology\nPresentation at kLab Kigali\nKigali, Rwanda, 23rd of December 2015\n[PDF] Inprocessing in SAT solvers\nPresentation at the 5th SAT/SMT Summer School\nStanford University, USA, July 2015\n[PDF] SAT Solvers and their Applications\nPresentation at Hackito Ergo Sum 2014\nParis, France, 26th of April 2014\n[PDF] Unknowns and complexities in SAT solving\n26th of September 2012\n[PDF] Satisfiability solving: theory and its application to cryptography\n10th of July 2012\n[PDF] Limits of SAT Solvers in Cryptography\nPresentation at CASED\nDarmstadt, Germany, 21st of July 2011\n[PDF] CryptoMiniSat \u0026ndash; A Rough Guide\nPresentation at SMT/SAT Summer School'11\nMIT, USA, 14th of June 2011\n[PDF] Breaking Industrial Ciphers at a Whim\nPresentation at Hackito Ergo Sum'11\nParis, France, 7th of April 2011\n[PDF] SAT megoldók és valós problémák – lehetőségek és határok (SAT solvers and real-world problems – possibilities and limits, in Hungarian)\nPresentation at BME (Budapest University of Technology and Economics)\nBudapest, Hungary, 15th of February 2011\n[PDF] SAT Solver Architectures\nPresentation at the Institute for Formal Models and Verification, Linz\nLinz, Austria, 9th of February 2011\n[PDF] Using SAT Solvers for Cryptographic Problems\nPresentation at Microsoft Research, Cambridge\nCambridge, UK, 5th of November 2010\n[PDF] SAT Solvers and Configuration Management\nPresentation for the Mancoosi Project\nParis, France, 2nd of November 2010\n[PDF] Enhanced Gaussian Elimination in DPLL-based SAT Solvers\nPresentation at the Pragmatics of SAT workshop 2010\nEdinburgh, Scotland, UK, 10th of July 2010\n[PDF] Grain of Salt \u0026ndash; An Automated Way to Test Stream Ciphers through SAT Solvers\nPresentation at Workshop on Tools for Cryptanalysis 2010\nRoyal Holloway, University of London, UK, 23rd of June 2010\n[PDF] SAT Solvers in the Context of Cryptography 2.0\nPresentation for the security group of Montpellier\u0026rsquo;s LIRMM laboratory\nMontpellier, France, 10th of June 2010\n[PDF] SAT Solvers in the Context of Cryptography\nPresentation for Rennes\u0026rsquo;s Cryptography Seminar\nRennes, France, 7th of May 2010\n[PDF] Enhanced handling of XOR constraints in DPLL-based SAT solvers\nPresentation at ENST (Télécom ParisTech)\nParis, France, 19th of February 2010\n[PDF] SAT Solvers in the Context of Stream Ciphers\nPresentation for Journées C2, with Karsten Nohl and Claude Castelluccia\nFréjus, France, 8th of October 2009\n[PDF] Privacy-preserving Security Protocols for RFIDs\nThesis defense\nGrenoble, France, 6th of October 2009\n[PDF] Extending SAT Solvers to Cryptographic Problems\nPresentation at SAT 2009, with Karsten Nohl and Claude Castelluccia\nSwansea, Wales, UK, 1st of July 2009\n[PDF] [Paper] RFID standards \u0026ndash; ISO14443, ISO15693 and EPCGlobal\nPlanete Seminar\nGrenoble, France, 19th of May 2008\n[PDF] ","permalink":"https://www.msoos.org/talks/","summary":"\u003cul\u003e\n\u003cli\u003e\u003cstrong\u003eNaming the Harm – A privacy threat vocabulary for cypherpunks\u003c/strong\u003e\u003cbr\u003e\nPresentation at Devcon 8, with Daniel Calderon\u003cbr\u003e\nMumbai, India, 3rd of November 2026\u003cbr\u003e\n\u003ca href=\"/talks/2026-11-naming-the-harm-privacy.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eNaming the Harm – A privacy threat vocabulary for cypherpunks\u003c/strong\u003e\u003cbr\u003e\nPresentation at the Neocypherpunk Summit 2026 (Berlin Blockchain Week), with Daniel Calderon\u003cbr\u003e\nBerlin, Germany, 14th of June 2026\u003cbr\u003e\n\u003ca href=\"/talks/2026-06-naming-the-harm-privacy.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Preprocessing\u003c/strong\u003e\u003cbr\u003e\nPresentation by Mate Soos at the \u003ca href=\"https://www.dagstuhl.de/en/seminars/seminar-calendar/seminar-details/26221\"\u003eDagstuhl Seminar 26221\u003c/a\u003e\u003cbr\u003e\nDagstuhl, Germany, 26th of May 2026\u003cbr\u003e\n\u003ca href=\"https://github.com/msoos/presentation_arjun_preproc/blob/main/arjun_preprocessor.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eArjun as a Boolean-Function Synthesis Engine\u003c/strong\u003e\u003cbr\u003e\nPresentation by Mate Soos at the \u003ca href=\"https://www.dagstuhl.de/en/seminars/seminar-calendar/seminar-details/26221\"\u003eDagstuhl Seminar 26221\u003c/a\u003e\u003cbr\u003e\nDagstuhl, Germany, 26th of May 2026\u003cbr\u003e\n\u003ca href=\"https://github.com/msoos/presentation_arjun_synth/blob/main/arjun_synth.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ehevm, new frontiers in symbolic execution of EVM bytecode\u003c/strong\u003e\u003cbr\u003e\nPresentation at W3ST 2025 (Web3 Security Tools), Devconnect Argentina, with dxo, Martin Blicha and Zoe Paraskevopoulou\u003cbr\u003e\nBuenos Aires, Argentina, 19th of November 2025\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation-W3ST-19-11-2025.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eIT Security: a game of counting the negatives, but can we do better? From Safety I to Safety II in IT Security\u003c/strong\u003e\u003cbr\u003e\n2025\u003cbr\u003e\n\u003ca href=\"/talks/2025-it-security-safety-ii.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eA gentle introduction to formal verification of Ethereum smart contracts\u003c/strong\u003e\u003cbr\u003e\nLecture with hands-on tutorial at the 4th Summer School on Security Testing and Verification\u003cbr\u003e\nBrussels, Belgium, 9th of July 2025\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/intro-smart-contract-verification/blob/main/intro-smart-contract-verif-9-july-2025-summer-school.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eBoolean Functional Synthesis and its possible application to Cryptography\u003c/strong\u003e\u003cbr\u003e\nPresentation by Mate Soos at \u003ca href=\"https://www.esat.kuleuven.be/cosic/\"\u003eCOSIC\u003c/a\u003e\u003cbr\u003e\nKU Leuven, Belgium, 8th of July 2025\u003cbr\u003e\n\u003ca href=\"https://github.com/msoos/func-synthesis-presentation-crypto/blob/main/presentation.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ehevm, a flexible symbolic execution framework to verify EVM bytecode\u003c/strong\u003e\u003cbr\u003e\nPresentation at the \u003ca href=\"https://www.dagstuhl.de/25242\"\u003eDagstuhl Seminar 25242: Testing Program Analyzers and Verifiers\u003c/a\u003e, with dxo and Zoe Paraskevopoulou\u003cbr\u003e\nDagstuhl, Germany, 11th of June 2025\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation-Dagstuhl-11-06-2025.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ehevm, a flexible symbolic execution framework to verify EVM bytecode\u003c/strong\u003e\u003cbr\u003e\nPresentation at the BSA (Blockchain Student Association) Conference, EPFL, with dxo and Zoe Paraskevopoulou\u003cbr\u003e\nLausanne, Switzerland, 7th of March 2025\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation-BSA-Lausanne-March-2025.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ehevm, or: How I Learnt to Stop Worrying and Love the Symbolic Execution\u003c/strong\u003e\u003cbr\u003e\nPresentation at Devcon 2024, with dxo and Zoe Paraskevopoulou\u003cbr\u003e\nBangkok, Thailand, 14th of November 2024\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation%20DevCon%20Nov%2014th.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ehevm, a Fast Symbolic Execution Framework for EVM Bytecode\u003c/strong\u003e\u003cbr\u003e\nPresentation at Stanford University, with dxo, Zoe Paraskevopoulou, Martin Lundfall and Mikael Brockman\u003cbr\u003e\nStanford, USA, 19th of August 2024\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation%20Stanford%2019th%20of%20Aug.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ehevm, a Fast Symbolic Execution Framework for EVM Bytecode\u003c/strong\u003e\u003cbr\u003e\nPresentation at CAV 2024, with dxo, Zoe Paraskevopoulou, Martin Lundfall and Mikael Brockman\u003cbr\u003e\nMontreal, Canada, 26th of July 2024\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation%20CAV%2026th%20July%202024.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"https://doi.org/10.1007/978-3-031-65627-9_22\"\u003e[Paper]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Preprocessing\u003c/strong\u003e\u003cbr\u003e\nPresentation at \u003ca href=\"https://sat-smt.in/\"\u003eThe SAT Winter School\u003c/a\u003e, based on slides by Armin Biere\u003cbr\u003e\nIIIT Hyderabad, India, 17th of December 2023\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2024/02/talk-preprocessing-2023-hyderabad.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eHEVM, a Smart Contract Verification Tool\u003c/strong\u003e\u003cbr\u003e\nPresentation at IIT Bombay\u003cbr\u003e\nMumbai, India, 12th of December 2023\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation%20IIT%20Bombay%2012th%20of%20Dec%202023.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eHEVM, a Smart Contract Verification Tool\u003c/strong\u003e\u003cbr\u003e\nPresentation at the Berlin Ethereum Meetup\u003cbr\u003e\nBerlin, Germany, 25th of October 2023\u003cbr\u003e\n\u003ca href=\"https://github.com/msooseth/hevm-presentation/blob/main/HEVM-presentation%20Ethereum%20Meetup%2025th%20of%20October%2C%202023.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"https://www.youtube.com/watch?v=sygfymV6AFs\"\u003e[Video]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eOn Quantitative Testing of Samplers\u003c/strong\u003e\u003cbr\u003e\nPresentation at The Simons Institute\u0026rsquo;s \u003ca href=\"https://simons.berkeley.edu/workshops/satisfiability-theory-practice-and-beyond-reunion\"\u003eSatisfiability: Theory, Practice, and Beyond Reunion\u003c/a\u003e, with Priyanka Golia, Sourav Chakraborty and Kuldeep S. Meel\u003cbr\u003e\nSimons Institute, Berkeley, USA, 15th of June 2022\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2022/07/soos-presentation-simons-institute-2022-June-15-On-Quantitative-Testing-of-Samplers.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"https://doi.org/10.4230/LIPIcs.CP.2022.36\"\u003e[Paper]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSolving CNF-XOR Formulas: A Practical Perspective\u003c/strong\u003e\u003cbr\u003e\nPresentation at the Simons Institute SAT Program Seminar, part of \u003ca href=\"https://simons.berkeley.edu/programs/sat2021\"\u003eSatisfiability: Theory, Practice, and Beyond\u003c/a\u003e\u003cbr\u003e\nSimons Institute, Berkeley, USA, 22nd of February 2021\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2022/07/simons-2021-Feb-22-talk.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Solving and CDCL(T)\u003c/strong\u003e\u003cbr\u003e\nPresentation at \u003ca href=\"https://sat-smt-ws.gitlab.io/2019/\"\u003eSAT+SMT Winter School\u003c/a\u003e, based on slides by Armin Biere\u003cbr\u003e\nIIT Bombay, Mumbai, India, 7th of December 2019\u003cbr\u003e\n\u003ca href=\"/largefiles/matesoos-satsmt-winterschool-2019.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eCrystalBall: Gazing in the Black Box of SAT Solving\u003c/strong\u003e\u003cbr\u003e\nPresentation at SAT 2019, with Kuldeep S. Meel and Raghav Kulkarni\u003cbr\u003e\nLisbon, Portugal, July 2019\u003cbr\u003e\n\u003ca href=\"/talks/2019-sat-crystalball.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"https://doi.org/10.1007/978-3-030-24258-9_26\"\u003e[Paper]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eMachine Learning Clause DB Management\u003c/strong\u003e\u003cbr\u003e\nPresentation at \u003ca href=\"https://www.dagstuhl.de/en/program/calendar/semhp/?semnr=19062\"\u003eDagstuhl Seminar 19062: Bringing CP, SAT and SMT together: Next Challenges in Constraint Solving\u003c/a\u003e, with Raghav Kulkarni and Kuldeep S. Meel\u003cbr\u003e\nSchloss Dagstuhl – Leibniz Center for Informatics, Wadern, Germany, February 2019\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2022/07/presentation_dagstuhl_2019_ML.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eHacking using SAT and SMT Solvers\u003c/strong\u003e\u003cbr\u003e\nPresentation at \u003ca href=\"https://www.emfcamp.org/\"\u003eEMF Camp 2018\u003c/a\u003e\u003cbr\u003e\nEastnor, UK, 1st of September 2018\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2018/09/EMF-camp-SAT-and-SMT-solvers-final.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eWhy are SAT solvers so fast and how can you take advantage of their speed?\u003c/strong\u003e\u003cbr\u003e\nPresentation at SUTD (Singapore University of Technology and Design)\u003cbr\u003e\nSingapore, 16th of May 2018\u003cbr\u003e\n\u003ca href=\"/talks/2018-sutd-why-sat-solvers-are-fast.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eRainbows: Creating and Looking up (without getting high)\u003c/strong\u003e\u003cbr\u003e\nPresentation at AlligatorCon 2017\u003cbr\u003e\nKraków, Poland, August 2017\u003cbr\u003e\n\u003ca href=\"https://github.com/msoos/alligatorcon-2017-presentation/blob/main/pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eLessons Learnt \u0026ndash; Seven Years of CryptoMiniSat\u003c/strong\u003e\u003cbr\u003e\nPresentation at \u003ca href=\"http://www.pragmaticsofsat.org/2016/\"\u003ePragmatics of SAT 2016\u003c/a\u003e, a workshop of the SAT 2016 conference\u003cbr\u003e\nBordeaux, France, 4th of July 2016\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2016/07/seven_years.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eInfosec Through People, Process and Technology\u003c/strong\u003e\u003cbr\u003e\nPresentation at \u003ca href=\"https://klab.rw/\"\u003ekLab Kigali\u003c/a\u003e\u003cbr\u003e\nKigali, Rwanda, 23rd of December 2015\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2018/09/Infosec-through-People-Process-and-Technology.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eInprocessing in SAT solvers\u003c/strong\u003e\u003cbr\u003e\nPresentation at the 5th SAT/SMT Summer School\u003cbr\u003e\nStanford University, USA, July 2015\u003cbr\u003e\n\u003ca href=\"/talks/2015-satsmt-summer-school-inprocessing.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Solvers and their Applications\u003c/strong\u003e\u003cbr\u003e\nPresentation at Hackito Ergo Sum 2014\u003cbr\u003e\nParis, France, 26th of April 2014\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2014/05/Hackito2014.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eUnknowns and complexities in SAT solving\u003c/strong\u003e\u003cbr\u003e\n26th of September 2012\u003cbr\u003e\n\u003ca href=\"/talks/2012-unknowns-and-complexities-in-sat-solving.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSatisfiability solving: theory and its application to cryptography\u003c/strong\u003e\u003cbr\u003e\n10th of July 2012\u003cbr\u003e\n\u003ca href=\"/talks/2012-sat-theory-and-application-to-cryptography.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eLimits of SAT Solvers in Cryptography\u003c/strong\u003e\u003cbr\u003e\nPresentation at CASED\u003cbr\u003e\nDarmstadt, Germany, 21st of July 2011\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2011/07/CASED_pres_Soos.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eCryptoMiniSat \u0026ndash; A Rough Guide\u003c/strong\u003e\u003cbr\u003e\nPresentation at SMT/SAT Summer School'11\u003cbr\u003e\nMIT, USA, 14th of June 2011\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2011/06/soos_summerschool.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eBreaking Industrial Ciphers at a Whim\u003c/strong\u003e\u003cbr\u003e\nPresentation at Hackito Ergo Sum'11\u003cbr\u003e\nParis, France, 7th of April 2011\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2011/04/hes2011.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT megoldók és valós problémák – lehetőségek és határok\u003c/strong\u003e (SAT solvers and real-world problems – possibilities and limits, in Hungarian)\u003cbr\u003e\nPresentation at BME (Budapest University of Technology and Economics)\u003cbr\u003e\nBudapest, Hungary, 15th of February 2011\u003cbr\u003e\n\u003ca href=\"/talks/2011-bme-sat-megoldok.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Solver Architectures\u003c/strong\u003e\u003cbr\u003e\nPresentation at the Institute for Formal Models and Verification, Linz\u003cbr\u003e\nLinz, Austria, 9th of February 2011\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2011/02/SAT_solver_architectures_Linz.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eUsing SAT Solvers for Cryptographic Problems\u003c/strong\u003e\u003cbr\u003e\nPresentation at Microsoft Research, Cambridge\u003cbr\u003e\nCambridge, UK, 5th of November 2010\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2010/11/soos_microsoft_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Solvers and Configuration Management\u003c/strong\u003e\u003cbr\u003e\nPresentation for the Mancoosi Project\u003cbr\u003e\nParis, France, 2nd of November 2010\u003cbr\u003e\n\u003ca href=\"/wordpress/wp-content/uploads/2010/11/soos_mancoosi_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eEnhanced Gaussian Elimination in DPLL-based SAT Solvers\u003c/strong\u003e\u003cbr\u003e\nPresentation at the Pragmatics of SAT workshop 2010\u003cbr\u003e\nEdinburgh, Scotland, UK, 10th of July 2010\u003cbr\u003e\n\u003ca href=\"/largefiles/pos_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eGrain of Salt \u0026ndash; An Automated Way to Test Stream Ciphers through SAT Solvers\u003c/strong\u003e\u003cbr\u003e\nPresentation at Workshop on Tools for Cryptanalysis 2010\u003cbr\u003e\nRoyal Holloway, University of London, UK, 23rd of June 2010\u003cbr\u003e\n\u003ca href=\"/largefiles/tools_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Solvers in the Context of Cryptography 2.0\u003c/strong\u003e\u003cbr\u003e\nPresentation for the security group of Montpellier\u0026rsquo;s LIRMM laboratory\u003cbr\u003e\nMontpellier, France, 10th of June 2010\u003cbr\u003e\n\u003ca href=\"/largefiles/montpellier_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Solvers in the Context of Cryptography\u003c/strong\u003e\u003cbr\u003e\nPresentation for Rennes\u0026rsquo;s Cryptography Seminar\u003cbr\u003e\nRennes, France, 7th of May 2010\u003cbr\u003e\n\u003ca href=\"/largefiles/rennes_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eEnhanced handling of XOR constraints in DPLL-based SAT solvers\u003c/strong\u003e\u003cbr\u003e\nPresentation at ENST (Télécom ParisTech)\u003cbr\u003e\nParis, France, 19th of February 2010\u003cbr\u003e\n\u003ca href=\"/talks/2010-xor-constraints-in-sat-solvers.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eSAT Solvers in the Context of Stream Ciphers\u003c/strong\u003e\u003cbr\u003e\nPresentation for Journées C2, with Karsten Nohl and Claude Castelluccia\u003cbr\u003e\nFréjus, France, 8th of October 2009\u003cbr\u003e\n\u003ca href=\"/largefiles/frejus_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003ePrivacy-preserving Security Protocols for RFIDs\u003c/strong\u003e\u003cbr\u003e\nThesis defense\u003cbr\u003e\nGrenoble, France, 6th of October 2009\u003cbr\u003e\n\u003ca href=\"/largefiles/defense_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eExtending SAT Solvers to Cryptographic Problems\u003c/strong\u003e\u003cbr\u003e\nPresentation at SAT 2009, with Karsten Nohl and Claude Castelluccia\u003cbr\u003e\nSwansea, Wales, UK, 1st of July 2009\u003cbr\u003e\n\u003ca href=\"/largefiles/SAT2009_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e \u003ca href=\"https://doi.org/10.1007/978-3-642-02777-2_24\"\u003e[Paper]\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eRFID standards \u0026ndash; ISO14443, ISO15693 and EPCGlobal\u003c/strong\u003e\u003cbr\u003e\nPlanete Seminar\u003cbr\u003e\nGrenoble, France, 19th of May 2008\u003cbr\u003e\n\u003ca href=\"/largefiles/rfid_soos_pres.pdf\"\u003e[PDF]\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e","title":"Talks"},{"content":"","permalink":"https://www.msoos.org/my-posts/","summary":"","title":"SAT Blog"},{"content":" I am currently working at the Argot Collective. I previously worked at the Ethereum Foundation Zalando, GDS (now part of AON), Cisco, and Security Research Labs.\nAs part of my research activities, I am interested in SAT solving, Model Counting and sampling, SMT solvers, and in general beyond-SAT. I maintain the SAT solver CryptoMiniSat and I help maintain the SMT solver STP. I am also one of the main authors of ApproxMC, UniGen, Arjun, Pepin, and Bosphorus.\nI continuously maintain these tools, and take great care to make sure they are easy to use. These tools combined have over 500 issues solved on GitHub. Most of my tools are hooked up to automated fuzzers, build systems, release systems (e.g. PyPi), and have in total have 100s of hand-written test cases. In my opinion, good research tools work, and continue to work.\nWorkplaces and Research I have done research at the University of Toronto and the National University of Singapore. I was a security architect at Zalando for 3.5 years, and a security consultant for 2 years in London working at Gotham Digital Science where I did risk assessment, threat modelling, pentesting and related work. I also worked at Cisco in London on the security of the Telepresence Server and the videoconferencing subsystem in Spark. Prior to that, I worked for nearly 4.5 years at Security Research Labs where I worked on helping clients with their threat models, mostly related to telecommunications and embedded systems, and wrote a tool to easily reverse a number of embedded ciphers. During my university studies, I worked in Pantel (thanks to Jeroen Temme there) for about 1.5 years in total, where I wrote a MySQL-based telephone-call matching system.\nI received my Masters diploma from BUTE, and I have done my PhD in the PLANETE team of INRIA Rhone-Alpes under the supervision of Claude Castelluccia, conducting research on RFID security and privacy and low-complexity cryptography. I have also done one year of Post-Doctoral study under the supervision of Jean-Charles Faugere.\nGeneral interests I like art, books, films, and making things. Nowadays, I spend quite some time making \u0026amp; flying model airplanes.\nContact personal email: soos.mate@gmail.com\n","permalink":"https://www.msoos.org/about/","summary":"\u003cfigure\u003e\n    \u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2015/05/IMG%5F1611.jpg\"/\u003e \n\u003c/figure\u003e\n\n\u003cp\u003eI am currently working at the \u003ca href=\"https://argot.org\"\u003eArgot Collective\u003c/a\u003e. I\npreviously worked at the \u003ca href=\"https://ethereum.foundation/\"\u003eEthereum Foundation\u003c/a\u003e\n\u003ca href=\"https://www.zalando.de/\"\u003eZalando\u003c/a\u003e, \u003ca href=\"https://www.gdssecurity.com/\"\u003eGDS\u003c/a\u003e (now\npart of AON), \u003ca href=\"https://www.cisco.com/\"\u003eCisco\u003c/a\u003e, and \u003ca href=\"https://www.srlabs.de/\"\u003eSecurity Research\nLabs\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eAs part of my research activities, I am interested in SAT solving, Model\nCounting and sampling,  SMT solvers, and in general beyond-SAT. I maintain the\nSAT solver \u003ca href=\"/2014/04/cryptominisat-4-released/\"\u003eCryptoMiniSat\u003c/a\u003e and I help\nmaintain the SMT solver \u003ca href=\"http://stp.github.io/\"\u003eSTP\u003c/a\u003e. I am also one of the main\nauthors of \u003ca href=\"https://github.com/meelgroup/approxmc\"\u003eApproxMC\u003c/a\u003e,\n\u003ca href=\"https://github.com/meelgroup/unigen\"\u003eUniGen\u003c/a\u003e,\n\u003ca href=\"https://github.com/meelgroup/arjun\"\u003eArjun\u003c/a\u003e,\n\u003ca href=\"https://github.com/meelgroup/pepin\"\u003ePepin\u003c/a\u003e,  and\n\u003ca href=\"https://github.com/meelgroup/bosphorus\"\u003eBosphorus\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eI continuously maintain these tools, and take great care to make sure they are\neasy to use. These tools combined have over 500 issues solved on GitHub. Most\nof my tools are hooked up to automated fuzzers, build systems, release systems\n(e.g. PyPi), and have in total have 100s of hand-written test cases. In my\nopinion, good research tools work, and continue to work.\u003c/p\u003e","title":"About Me"},{"content":"Self-subsuming resolution in SAT uses the resolution operator to carry out its magic. Resolution can be used on two clauses if they share a variable, but the sign of the variable is inverted, e.g.\nv1 V v2\n-v1 V v3 V v4\n(where v1..v4 are binary variables and \u0026quot; V\u0026quot; means binary OR) can be resolved on v1, producing the clause:\nv2 V v3 V v4\nIn SAT this is used to simplify problems as follows. Let\u0026rsquo;s assume we have many clauses, among which there are these three:\na V c (1)\na V -c V d V f (2)\na V -c V g (3)\nIn this case, if we use the resolution operator on (1) and (2), we get:\na V d V f (4)\nThe interesting thing about (4) is that it is a strict subset of (2). In other words, we could simply replace (2) with (4), thus shortening clause (2). If we use the resolution operator on (1) and (3) we get:\na V g (5)\nwhose literals form a strict subset of those of (3), so we can replace (3) with (5), again shortening a clause. We shortened 2 clauses, each with one literal. For completeness, this technique can be applied in a recursive manner on all possible clause-pairs.\nUntil now, CryptoMiniSat was doing self-subsuming resolution in such a way that the clauses being manipulated were kept inside the propagation queue. The problem was, that the propagation queue enforces a very strict position of literals in the clause. So, when e.g. removing literal \u0026quot; a\u0026quot; from clause (3), CryptoMiniSat had to completely remove the clause, and then to completely re-add it, since the position of \u0026quot; a\u0026quot; changed (it got removed). The additional overhead for this was simply too much: in certain cases, self-subsuming resolution took 130 seconds to complete, 115 of which was taken by this detach-reattach overhead.\nThe solution to this problem was to completely remove all clauses from the propagation queue, then do self-subsuming resolution, and finally re-add the clauses. Interestingly, complete removal of all clauses is very fast (essentially, a constant-time operation, even though removing clauses one-by-one is very costly), and completely re-adding them is also very fast (linear in the number of clauses). The first impressions from this technique are very positive, and I decided to release CryptoMiniSat 2.6.0 with this technique included.\nNOTE: Thanks to N. Sörensson for pointing me out that self-subsuming resolution could be done better. I am not sure this is what he meant, but fingers are crossed.\n","permalink":"https://www.msoos.org/2010/08/self-subsuming-resolution/","summary":"\u003cp\u003e\u003ca href=\"http://minisat.se/downloads/SatELite_slides.pdf\"\u003eSelf-subsuming resolution\u003c/a\u003e in SAT uses the \u003ca href=\"http://en.wikipedia.org/wiki/Resolution_%28logic%29\"\u003eresolution operator\u003c/a\u003e to carry out its magic. Resolution can be used on two clauses if they share a variable, but the sign of the variable is inverted, e.g.\u003cbr\u003e\n\u003ccode\u003ev1 V v2\u003c/code\u003e\u003cbr\u003e\n\u003ccode\u003e-v1 V v3 V v4\u003c/code\u003e\u003cbr\u003e\n(where \u003ccode\u003ev1..v4\u003c/code\u003e are binary variables and \u0026quot; \u003ccode\u003eV\u003c/code\u003e\u0026quot; means binary OR) can be resolved on \u003ccode\u003ev1\u003c/code\u003e, producing the clause:\u003cbr\u003e\n\u003ccode\u003ev2 V v3 V v4\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eIn SAT this is used to simplify problems as follows. Let\u0026rsquo;s assume we have many clauses, among which there are these three:\u003cbr\u003e\n\u003ccode\u003ea V c           (1)\u003c/code\u003e\u003cbr\u003e\n\u003ccode\u003ea V -c V d V f  (2)\u003c/code\u003e\u003cbr\u003e\n\u003ccode\u003ea V -c V g      (3)\u003c/code\u003e\u003cbr\u003e\nIn this case, if we use the resolution operator on (1) and (2), we get:\u003cbr\u003e\n\u003ccode\u003ea V d V f       (4)\u003c/code\u003e\u003cbr\u003e\nThe interesting thing about (4) is that it is a strict subset of (2). In other words, we could simply replace (2) with (4), thus shortening clause (2). If we use the resolution operator on (1) and (3) we get:\u003cbr\u003e\n\u003ccode\u003ea V g           (5)\u003c/code\u003e\u003cbr\u003e\nwhose literals form a strict subset of those of (3), so we can replace (3) with (5), again shortening a clause. We shortened 2 clauses, each with one literal. For completeness, this technique can be applied in a recursive manner on all possible clause-pairs.\u003c/p\u003e","title":"Self-subsuming resolution"},{"content":"Asymmetric branching is an algorithm that shortens CNF clauses in SAT Solvers. A clause, for instance v1 V v2 V v3 V v4 (where letters are binary variables and V represents binary OR) could possibly be shortened to v1 V v2 V v3. To find out if it can be, all we have to do is to put -v1,-v2 and -v3 into the propagation queue and then propagate. If we receive a conflict from the propagation engine, we can learn the clause v1 V v2 V v3, which (incidentally, though this was the point), subsumes the original clause, so we can simply remove variable v4 from the original clause.\nOk, so much for theory. Now comes the hard part: how do we do this such that it actually speeds up the solving? The problem is that asymmetric branching, when done on all possible clauses, is slow. However, its benefits could be large, since a shortened clause naturally leads a faster propagation and shorter resolution proofs thus less propagation need.\nI have been experimenting in getting some benefit from asymmetric branching, and now it works extremely well for CryptoMiniSat. The trick I use, is that I first sort the clauses according to size, and only try to shorten with asymmetric branching the top couple of clauses. This ensures that the largest clauses are shortened first. Since the largest clauses contribute most the to size of the resolution proof and they are the slowest to propagate, this makes sense.\nCryptoMiniSat tries to do asymmetric branching regularly, always for only a little while (~2 seconds). I believe this is useful, because as the amount of time the program has been trying to solve a problem increases, it makes sense that we have a bit more time to do things that could help resolve the problem faster. For instance, if CryptoMiniSat has been trying to solve a given problem for 30 minutes unsuccessfully with the standard clause-learning DPLL procedure in vain, we can allocate 2-3 seconds to possibly gain ~5-10% later. In the example case it can be assumed that since we haven\u0026rsquo;t been able to solve it for 30 minutes, probably we won\u0026rsquo;t solve it in the next 10 minutes, so gaining 5% on 10 minutes is 30 seconds, far more than the 2-3 seconds we invested.\nThe results with asymmetric branching with CryptoMiniSat are quite astounding. Using the 2009 SAT Competition benchmark set with an approximately correct timeout, CryptoMiniSat could normally solve 217 problems. With asymmetric branching, CryptoMiniSat can now solve 220 \u0026ndash; a huge increase: last year, 16 solvers running in parallel could only solve 229 instances in total.\nEdited to add (26/09/2010): Clause Vivification by Piette, Hamadi and Sais is a paper about the above described method, though with a number of key differences. The paper seems to advocate for a complete procedure, furthermore, it calls the conflict generation routine in certain cases. I believe that the above described way of carrying out this technique brings more tangible benefits, especially for larger problems.\n(Updated: we need to branch on the inverse of the clause\u0026rsquo;s literals. Thanks to Vegard Nossum for spotting this)\n","permalink":"https://www.msoos.org/2010/07/asymmetric-branching/","summary":"\u003cp\u003eAsymmetric branching is an algorithm that shortens CNF clauses in SAT Solvers. A clause, for instance \u003ccode\u003ev1 V v2 V v3 V v4\u003c/code\u003e (where letters are binary variables and \u003ccode\u003eV\u003c/code\u003e represents binary OR) could possibly be shortened to \u003ccode\u003ev1 V v2 V v3\u003c/code\u003e. To find out if it can be, all we have to do is to put \u003ccode\u003e-v1,-v2\u003c/code\u003e and \u003ccode\u003e-v3\u003c/code\u003e into the propagation queue and then propagate. If we receive a conflict from the propagation engine, we can learn the clause \u003ccode\u003ev1 V v2 V v3\u003c/code\u003e, which (incidentally, though this was the point), subsumes the original clause, so we can simply remove variable \u003ccode\u003ev4\u003c/code\u003e from the original clause.\u003c/p\u003e","title":"Asymmetric branching"},{"content":"Propagation (BCP) in SAT is the single most expensive operation. The algorithm essentially does the following:\nwhile (queue_head \u0026lt; trail.size()) { Literal p = trail[queue_head]; vector\u0026lt;Watch\u0026gt;\u0026amp; thiswatch = watches[p]; for (i = thiswatch.begin(); i!=thiswatch[p].end(); i++) { confl = prop_confl(i-\u0026gt;clause); if (confl != NULL) return confl; } queue_head++; } where the function prop_confl() executes the propagation or returns a conflict, if necessary.\nThe problem with the above function is that clauses come in all shapes and sizes. In CryptoMiniSat, there are two kinds of clauses, normal clauses and XOR clauses. Naturally, these need to be handled differently. Furthermore, if the clause\u0026rsquo;s size is small, it is more efficient to handle it differently. The way CryptoMiniSat has done this before was to have a separate \u0026quot; watches\u0026quot; for each of these. As you can guess, this is very suboptimal.\nThe new code in CryptoMiniSat now uses a different approach. Instead of having a watches_normal, watches_xor, watches_binary, and a for loop for each, we have one watches and one for loop, but this time, the struct Watch encodes the type of the watched clause. So our new BCP function is:\nwhile (queue_head \u0026lt; trail.size()) { Literal p = trail[queue_head]; vector\u0026lt;Watch\u0026gt;\u0026amp; thiswatch = watches[p]; for (i = thiswatch.begin(); i!=thiswatch.end(); i++) { if (i-\u0026gt;isBinary()) confl = prop_confl_bin(i-\u0026gt;clause); if (i-\u0026gt;isNormal()) confl = prop_confl_norm(i-\u0026gt;clause); if (i-\u0026gt;isXor()) confl = prop_confl_xor(i-\u0026gt;clause); if (confl != NULL) return confl; } queue_head++; } This new method reduces the jump-around that the processor otherwise would have done with all those separate for loops. It has an important drawback, though: it is now more complicated (and more expensive) to fully propagate binary clauses before any other clause. The original code had this:\nwhile (queue_head \u0026lt; trail.size()) { bin_queue_head = queue_head; while(bin_queue_head \u0026lt; trail.size()) { Literal p = trail[bin_queue_head]; vector\u0026lt;Watch\u0026gt;\u0026amp; thiswatch_bin = watches_bin[p]; for (i = thiswatch_bin.begin(); i!=thiswatch_bin.end(); i++) { confl = prop_confl_bin(i-\u0026gt;clause); if (confl != NULL) return confl; } bin_queue_head++; } Literal p = trail[queue_head]; vector\u0026lt;Watch\u0026gt;\u0026amp; thiswatch = watches[p]; for (i = thiswatch.begin(); i!=thiswatch.end(); i++) { confl = prop_confl(i-\u0026gt;clause); if (confl != NULL) return confl; } queue_head++; } Since there are no separate watchlists for binary clauses anymore, we are required to go through all clauses all the time in the first for loop, or we can simply skip the first loop. The disadvantage of this is that some variables could have possibly been set by binary clauses may now be set by non-binary clauses, which leads to a possibly increased number of literals in the resulting learnt clause \u0026ndash; since the incoming arcs into the conflict will likely contain more clauses that are larger than 2-long.\n","permalink":"https://www.msoos.org/2010/07/propagating-faster/","summary":"\u003cp\u003ePropagation (BCP) in SAT is the single most expensive operation. The algorithm essentially does the following:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ewhile (queue_head \u0026lt; trail.size()) {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  Literal p = trail[queue_head];\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  vector\u0026lt;Watch\u0026gt;\u0026amp; thiswatch = watches[p];\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  for (i = thiswatch.begin(); i!=thiswatch[p].end(); i++) {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    confl = prop_confl(i-\u0026gt;clause);\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    if (confl != NULL) return confl;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  }\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e  queue_head++;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e}\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003ewhere the function \u003ccode\u003eprop_confl()\u003c/code\u003e executes the propagation or returns a conflict, if necessary.\u003c/p\u003e\n\u003cp\u003eThe problem with the above function is that clauses come in all shapes and sizes. In \u003ca href=\"http://planete.inrialpes.fr/%7Esoos/CryptoMiniSat2/index.php\"\u003eCryptoMiniSat\u003c/a\u003e, there are two kinds of clauses, normal clauses and XOR clauses. Naturally, these need to be handled differently. Furthermore, if the clause\u0026rsquo;s size is small, it is more efficient to handle it differently. The way CryptoMiniSat has done this before was to have a separate \u0026quot; \u003ccode\u003ewatches\u003c/code\u003e\u0026quot; for each of these. As you can guess, this is very suboptimal.\u003c/p\u003e","title":"Propagating faster"},{"content":"I have just discovered the gitstats tool, and quickly put together a set of statistics on the development of CryptoMiniSat, the SAT solver I have been working on lately. I have been using the GIT repository for most of my work on CryptoMiniSat, doing ~2000 commits since its inception, so it gives a good picture of how things evolved, and how I usually work. Firstly, the hours I usually work:\nI basically work almost as much at midnight as I do at midday. The afternoon is clearly the most active and practically useful part of my day. Next, the graph to show which days I work the most:\nEssentially, I worked as much on CryptoMiniSat during Sunday as I did during Monday or Friday. Saturday was the day I must have been the most fed up with development. Finally, the number of commits by months:\nThe 2nd and 3rd months of 2010 was a struggle because of the SAT and PoS deadlines. I tried to put together a credible research paper, which finally got accepted at PoS. During the 6th and 7th months of 2010 I was mostly looking forward to the results of the SAT Race, so I wasn\u0026rsquo;t developing so much.\n","permalink":"https://www.msoos.org/2010/07/stats-on-cryptominisats-development/","summary":"\u003cp\u003eI have just discovered the \u003ca href=\"http://gitstats.sourceforge.net/\"\u003egitstats\u003c/a\u003e tool, and quickly put together a set of statistics on the development of CryptoMiniSat, the SAT solver I have been working on lately. I have been using the GIT repository for most of my work on CryptoMiniSat, doing ~2000 commits since its inception, so it gives a good picture of how things evolved, and how I usually work. Firstly, the hours I usually work:\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"/wordpress/wp-content/uploads/2010/08/hour_of_day.png\"\u003e\u003cimg loading=\"lazy\" src=\"/wordpress/wp-content/uploads/2010/08/hour_of_day.png\"\u003e\u003c/a\u003e\u003c/p\u003e","title":"Stats on CryptoMiniSat’s development"},{"content":"The software I developed, CryptoMiniSat 2.5 won the SAT Race of 2010. It is a great honour to win such a difficult race, as there were 19 other solvers submitted from 9 different countries.\nThinking back and trying to answer the question why CryptoMiniSat won, I think there are no clear answers. Naturally, I put immense effort into it, but that is only one part of the picture. Other important factors include those who supported me: my fiancée, the PLANETE project of INRIA, and in particular Claude Castelluccia and my colleagues here in Paris, the LIP6 team and my professor here, Jean-Charles Faugere. As with all randomised algorithms, luck played a good part of winning, too.\nIn all of this, it is interesting to note that I never had a colleague who worked in or even near the field of SAT: both the PLANETE and the LIP6 team use SAT solvers only as a means to an end, not as an end in itself. In other words, I had to get this far mostly alone. To be honest, I think this is one of the reasons I had won, too: there probably is too much misunderstanding in SAT that everybody takes for granted. Since I never really talked with anyone about their understanding of the subject (I only read papers, which state facts), I had a white paper in front of me, which I could fill with my own intuitions, without being lead by those of others. Naturally, this means that I have probably stepped into a large number things that are widely understood to be wrong, but at the end, it seems that I must have also made some good steps, too.\nAs for the bad steps I have made (and of which I am aware of), I had copied the subsumption algorithm from SatElite, which the authors of MiniSat told me was a bad move, since its self-subsuming resolution is slow. I had in fact observed this, but I thought it was a fact of life. Alas, it isn\u0026rsquo;t. Other errors I have made include a non-portable pointer-shortening which shortens pointers to 32 bits when using 64-bit architectures (Armin Biere\u0026rsquo;s lingeling does this right), and a wrong clause-prefetching code that Norbert Manthey put me right about. I have also conceptually misunderstood the possible impact of variable elimination on the difficulty of resolving an instance, a grave mistake that Niklas Sörensson put me right about.\nAs for the good steps, I think I have made a couple of them. Firstly, I have put the 2009 SAT paper we wrote with my colleagues to its natural conclusion: including XOR clauses and partial XOR reasoning into the innermost parts of the solver. Secondly, I have used the community to its fullest potential: CryptoMiniSat was used by the constraint solver STP far before the SAT Race began, and it was distributed to a number of highly skilled individuals who made use of it and gave feedback. Sometimes I got very negative feedbacks (these were the most valuable), which highlighted where and why the solver was failing. Thirdly, I have tried to take advantage of the academic environment I work in: I have tried to read the relevant papers, used the clusters provided by the French universities to carry out experiments, and generally took my time (rarely an option in industry) to get things right instead of rushing out a solver.\n","permalink":"https://www.msoos.org/2010/07/winning-the-sat-race/","summary":"\u003cp\u003eThe software I developed, \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\u0026amp;release_id=5231\"\u003eCryptoMiniSat 2.5\u003c/a\u003e won the \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/\"\u003eSAT Race of 2010\u003c/a\u003e. It is a great honour to win such a difficult race, as there were 19 other solvers submitted from 9 different countries.\u003c/p\u003e\n\u003cp\u003eThinking back and trying to answer the question why CryptoMiniSat won, I think there are no clear answers. Naturally, I put immense effort into it, but that is only one part of the picture. Other important factors include those who supported me: my fiancée, the \u003ca href=\"http://planete.inria.fr/\"\u003ePLANETE project\u003c/a\u003e of INRIA, and in particular \u003ca href=\"http://planete.inrialpes.fr/%7Eccastel/\"\u003eClaude Castelluccia\u003c/a\u003e and my colleagues here in Paris, the \u003ca href=\"http://www.lip6.fr/?LANG=en\"\u003eLIP6\u003c/a\u003e team and my professor here, \u003ca href=\"http://www-salsa.lip6.fr/%7Ejcf/\"\u003eJean-Charles Faugere\u003c/a\u003e. As with all randomised algorithms, luck played a good part of winning, too.\u003c/p\u003e","title":"Winning the SAT Race"},{"content":"I am currently at the SAT 2010 conference, in Edinburgh. It is my second SAT conference, but the first one where I finally have a chance to know who is who. I had a chance to talk to some great researchers. For instance, I talked to (in no particular order) Armin Biere (author of PrecoSat and Lingeling), Niklas Een, Niklas Sörensson (authors of MiniSat \u0026ndash; new version is out, btw), Marijn Heule (author of the march_* set of solvers), Matti Järvisalo (one of the authors of Blocked Clause Elimination), the author of MiraXT, and many others. It\u0026rsquo;s really a great place to meet up people and get a grasp on what SAT is really about. It\u0026rsquo;s also a great way to understand the motivation behind certain ideas, and to hear the problems encountered by others.\nFor instance, I now know that bugs, about which I have already written a blog post about is a problem that comes up for nearly everyone, and tackling them is one of the most difficult things for the developers. I have also finally understood the reason behind the MiniSat Template Library (MTL), which I\u0026rsquo;ve always found odd: it re-implements many things in the STL (the Standard Template Library), which I have always found unnecessary. Although the reasons are now clear (better control, easier debugging, less memory overhead), I think I will still replace it with STL. I have also had a chance to talk to the kind reviewer who did such an extensive review of my paper, which was quite an enlightening discussion. If you are interested in SAT, I encourage you to attend next year: there are usually some workshops associated with the conference, where it is easier to have a paper accepted: e.g. this year, a Masters student got his quite interesting paper (long version) accepted, and I am sure he has benefited a lot from it.\n","permalink":"https://www.msoos.org/2010/07/the-2010-sat-conference/","summary":"\u003cp\u003eI am currently at the \u003ca href=\"http://ie.technion.ac.il/SAT10/\"\u003eSAT 2010 conference\u003c/a\u003e, in Edinburgh. It is my second SAT conference, but the first one where I finally have a chance to know who is who. I had a chance to talk to some great researchers. For instance, I talked to (in no particular order) Armin Biere (author of PrecoSat and Lingeling), Niklas Een, Niklas Sörensson (authors of MiniSat \u0026ndash; \u003ca href=\"http://minisat.se/downloads/minisat-2.2.0.tar.gz\"\u003enew version\u003c/a\u003e is out, btw), Marijn Heule (author of the march_* set of solvers), Matti Järvisalo (one of the authors of Blocked Clause Elimination), the author of MiraXT, and many others. It\u0026rsquo;s really a great place to meet up people and get a grasp on what SAT is really about. It\u0026rsquo;s also a great way to understand the motivation behind certain ideas, and to hear the problems encountered by others.\u003c/p\u003e","title":"The 2010 SAT Conference"},{"content":"Algebraic Normal Form, or simply ANF, is the form used to describe cryptographic functions. It looks like this:\na∗b⊕b∗c⊕b⊕d=0b∗c⊕c⊕a=0… a*b \\oplus b*c \\oplus b \\oplus d = 0\\\\ b*c \\oplus c \\oplus a = 0\\\\ \\ldots a∗b⊕b∗c⊕b⊕d=0b∗c⊕c⊕a=0… Where a,…da,\\ldots da,…d are binary variables, the ⊕\\oplus⊕ sign is binary XOR, and the ∗*∗ sign is binary AND. Every item that is connected with the XOR-s is called a monomial, and its degree is the number of independent variables inside it. So, a∗ba*ba∗b is a 2-degree monomial in the first equation, and ccc is a 1-degree monomial in the second equation.\nAn important problem in SAT is to translate an ANF into the input of SAT solvers, Conjunctive Normal Form, or simply CNF. A CNF formula looks like this:\na∨b∨c=1a∨¬d=1… a \\vee b \\vee c = 1\\\\ a \\vee \\neg d = 1\\\\ \\ldots a∨b∨c=1a∨¬d=1… Where again a,…da,\\ldots da,…d are binary variables, the ∨\\vee∨ sign is the binary OR, and the ¬\\neg¬ sign is the binary NOT (i.e. inverse).\nThe scientific reference paper The most quoted article about ANF-to-CNF translation is that by Courtois and Bard, which advocates for the following translation process:\nIntroduce internal variables for every monomial of degree larger than 1 Describe the equations as large XORs using the recently introduced variables The example problem in CNF According to the original method, the equations presented above are first translated to the following form:\nv1=a∗bv2=b∗cv1⊕v2⊕b⊕d=0v2⊕c⊕a=0 v1 = a*b\\\\ v2 = b*c\\\\ v1 \\oplus v2 \\oplus b \\oplus d = 0\\\\ v2 \\oplus c \\oplus a = 0 v1=a∗bv2=b∗cv1⊕v2⊕b⊕d=0v2⊕c⊕a=0 Where v1,v2v1, v2v1,v2 are fresh binary variables. Then, each of the above equations are translated to CNF. The internal variables are translated as such:\nTranslation of v1=a∗bv1 = a*bv1=a∗b: v1∨¬a∨¬b=1¬v1∨a=1¬1∨b=1 v1 \\vee \\neg a \\vee \\neg b = 1\\\\ \\neg v1 \\vee a = 1\\\\ \\neg 1 \\vee b = 1 v1∨¬a∨¬b=1¬v1∨a=1¬1∨b=1 Translation of v2=b∗cv2 = b*cv2=b∗c v2∨¬b∨¬c=1¬v2∨b=1¬v2∨c=1 v2 \\vee \\neg b \\vee \\neg c = 1\\\\ \\neg v2 \\vee b = 1\\\\ \\neg v2 \\vee c = 1 v2∨¬b∨¬c=1¬v2∨b=1¬v2∨c=1 Translation of v1+v2+b+d=0v1 + v2 + b + d = 0v1+v2+b+d=0: ¬v1∨v2∨b∨d=1v1∨¬v2∨b∨d=1v1∨v2∨¬b∨d=1v1∨v2∨b∨−d=1¬v1∨¬v2∨¬b∨d=1¬v1∨¬v2∨b∨¬d=1¬v1∨v2∨¬b∨¬d=1v1∨¬v2∨¬b∨¬d=1 \\neg v1 \\vee v2 \\vee b \\vee d = 1\\\\ v1 \\vee \\neg v2 \\vee b \\vee d = 1\\\\ v1 \\vee v2 \\vee \\neg b \\vee d = 1\\\\ v1 \\vee v2 \\vee b \\vee -d = 1\\\\ \\neg v1 \\vee \\neg v2 \\vee \\neg b \\vee d = 1\\\\ \\neg v1 \\vee \\neg v2 \\vee b \\vee \\neg d = 1\\\\ \\neg v1 \\vee v2 \\vee \\neg b \\vee \\neg d = 1\\\\ v1 \\vee \\neg v2 \\vee \\neg b \\vee \\neg d = 1 ¬v1∨v2∨b∨d=1v1∨¬v2∨b∨d=1v1∨v2∨¬b∨d=1v1∨v2∨b∨−d=1¬v1∨¬v2∨¬b∨d=1¬v1∨¬v2∨b∨¬d=1¬v1∨v2∨¬b∨¬d=1v1∨¬v2∨¬b∨¬d=1 Translation of v2+c+a=0v2 + c + a = 0v2+c+a=0 : v2∨c∨¬a=1v2∨¬c∨a=1¬v2∨c∨a=1¬v2∨¬c∨¬a=1 v2 \\vee c \\vee \\neg a = 1\\\\ v2 \\vee \\neg c \\vee a = 1\\\\ \\neg v2 \\vee c \\vee a = 1\\\\ \\neg v2 \\vee \\neg c \\vee \\neg a = 1 v2∨c∨¬a=1v2∨¬c∨a=1¬v2∨c∨a=1¬v2∨¬c∨¬a=1 We are now done. The final CNF file is this. This final CNF has a small header, and some fluffs have been removed: variables are not named, but referred to with a number, and the = true-s have been replaced with a line-ending 0.\nAs you can imagine, there are many ways to enhance this process. I have written a set of them down in this paper. The set of improvements in a nutshell are the following:\nIf a variable\u0026rsquo;s value is given, (e.g. a = true), first substitute this value in the ANF, and transcribe the resulting ANF to CNF. If there are two monomials, such as: a*b + b in an equation, make a non-standard monomial (-a)*b from the two, and transcribe this to CNF. Since the CNF can use negations, this reduces the size of the resulting CNF If the ANF can be described using Karnaugh maps shorter than with the method presented above, use that translation method. An automated way I just got a nice script to perform step (1) from Martin Albrecht, one of the developers of Sage:\nsage: B = BooleanPolynomialRing(4500,\u0026#39;x\u0026#39;) sage: L = [B.random_element(degree=2,terms=10) for _ in range(4000)] sage: s = [B.gen(i) + GF(2).random_element() for i in range(1000)] sage: %time F = mq.MPolynomialSystem(L+s). eliminate_linear_variables(maxlength=1) CPU time: 1.03 s, Wall time: 1.11 s In this code, Martin generates a boolean system of equations with 4500 variables, with 4000 random equations each with randomly selected monomials of degree 2 and of XOR size 10. Then, he sets 1000 random variables to a random value (true or false), and finally, he substitutes the assigned values, and simplifies the system. If you think this is a trivial issue, alas, it is not. Both Maple and Sage take hours to perform it if using the standard eval function. The function above uses a variation of the ElimLin algorithm from the Courtois-Bard paper to do this efficiently.\n","permalink":"https://www.msoos.org/2010/07/anf-to-cnf-conversion/","summary":"\u003cp\u003eAlgebraic Normal Form, or simply \u003ca href=\"http://en.wikipedia.org/wiki/Algebraic_normal_form\"\u003eANF\u003c/a\u003e, is the form used to describe cryptographic functions. It looks like this:\u003c/p\u003e\n\u003cspan class=\"katex-display\"\u003e\u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ea\u003c/mi\u003e\u003cmo\u003e∗\u003c/mo\u003e\u003cmi\u003eb\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003eb\u003c/mi\u003e\u003cmo\u003e∗\u003c/mo\u003e\u003cmi\u003ec\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003eb\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003ed\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003cmspace\u003e\u003c/mspace\u003e\u003cmi\u003eb\u003c/mi\u003e\u003cmo\u003e∗\u003c/mo\u003e\u003cmi\u003ec\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003ec\u003c/mi\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003cmi\u003ea\u003c/mi\u003e\u003cmo\u003e=\u003c/mo\u003e\u003cmn\u003e0\u003c/mn\u003e\u003cmspace\u003e\u003c/mspace\u003e\u003cmo\u003e…\u003c/mo\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003e\na*b \\oplus b*c \\oplus b \\oplus d = 0\\\\\nb*c \\oplus c \\oplus a = 0\\\\\n\\ldots\n\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4653em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ea\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∗\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.7778em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003eb\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003eb\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∗\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ec\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.7778em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003eb\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ed\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003cspan class=\"mspace\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003eb\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∗\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ec\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ec\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e⊕\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ea\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003cspan class=\"mrel\"\u003e=\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2778em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6444em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e0\u003c/span\u003e\u003cspan class=\"mspace\"\u003e\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.1667em;\"\u003e\u003c/span\u003e\u003cspan class=\"minner\"\u003e…\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cp\u003eWhere \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ea\u003c/mi\u003e\u003cmo separator=\"true\"\u003e,\u003c/mo\u003e\u003cmo\u003e…\u003c/mo\u003e\u003cmi\u003ed\u003c/mi\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ea,\\ldots d\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.8889em;vertical-align:-0.1944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ea\u003c/span\u003e\u003cspan class=\"mpunct\"\u003e,\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.1667em;\"\u003e\u003c/span\u003e\u003cspan class=\"minner\"\u003e…\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.1667em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ed\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e are binary variables, the \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmo\u003e⊕\u003c/mo\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003e\\oplus\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6667em;vertical-align:-0.0833em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e⊕\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e sign is binary XOR, and the \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmo\u003e∗\u003c/mo\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003e*\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4653em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord\"\u003e∗\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e sign is binary AND. Every item that is connected with the XOR-s is called a \u003ca href=\"http://en.wikipedia.org/wiki/Monomial\"\u003emonomial\u003c/a\u003e, and its degree is the number of independent variables inside it. So, \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ea\u003c/mi\u003e\u003cmo\u003e∗\u003c/mo\u003e\u003cmi\u003eb\u003c/mi\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ea*b\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4653em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ea\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003cspan class=\"mbin\"\u003e∗\u003c/span\u003e\u003cspan class=\"mspace\" style=\"margin-right:0.2222em;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.6944em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003eb\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e is a 2-degree monomial in the first equation, and \u003cspan class=\"katex\"\u003e\u003cspan class=\"katex-mathml\"\u003e\u003cmath xmlns=\"http://www.w3.org/1998/Math/MathML\"\u003e\u003csemantics\u003e\u003cmrow\u003e\u003cmi\u003ec\u003c/mi\u003e\u003c/mrow\u003e\u003cannotation encoding=\"application/x-tex\"\u003ec\u003c/annotation\u003e\u003c/semantics\u003e\u003c/math\u003e\u003c/span\u003e\u003cspan class=\"katex-html\" aria-hidden=\"true\"\u003e\u003cspan class=\"katex-base\"\u003e\u003cspan class=\"katex-strut\" style=\"height:0.4306em;\"\u003e\u003c/span\u003e\u003cspan class=\"mord mathnormal\"\u003ec\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e is a 1-degree monomial in the second equation.\u003c/p\u003e","title":"ANF to CNF conversion"},{"content":"In my last post I have described a small problem I had regarding a C++ union that had to store a pointer and a value at the same time, plus an indicator that told us which of the two was active:\nclass WhatLeadHere { public: bool wasPointer; union{Clause* pointer; uint32_t lit;}; }; Martin Maurer has wrote this enlightening email regarding this:\nThe Clause * pointer is [..] located at least on a 4 byte boundary (at least when not forced by e.g. #pragma). If it is not at least on a 4 byte boundary, CPU must (at least some of them) do two accesses: one lower DWORD, one upper DWORD, and merge both together, which reduces speed.\nSo the lower two bits are always zero :-) Why not move the \u0026ldquo;wasPointer\u0026rdquo; to lower two bits (i think you need only one, have one spare bit). Of course before accessing the \u0026ldquo;pointer\u0026rdquo; (Clause *), you must \u0026ldquo;and\u0026rdquo; the two lower bits back to zero.\nHe is perfectly right: the pointer will never be zero on the least significant bit (LSB), so setting that to \u0026ldquo;1\u0026rdquo; can be used as an indicator. This is a form of bit-stuffing. To check if it\u0026rsquo;s a pointer or a literal the following function can be used:\nconst bool WhatLeadHere::wasPointer() const { return (lit\u0026amp;1); } As for storing lit, we need to right-shift it by one and set the LSB to 1. When lit is needed, we left-shift it to get back the original value. This is not a problem, since variables in SAT never use out the 32-bit space: there are rarely more than 10 million variables, so right-shifting this value will not lead to information loss.\n","permalink":"https://www.msoos.org/2010/06/how-to-bit-stuff-pointers/","summary":"\u003cp\u003eIn my \u003ca href=\"?p=13\"\u003elast post\u003c/a\u003e I have described a small problem I had regarding a C++ union that had to store a pointer and a value at the same time, plus an indicator that told us which of the two was active:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eclass WhatLeadHere {\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003epublic:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    bool wasPointer;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    union{Clause* pointer; uint32_t lit;};\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e};\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eMartin Maurer has wrote this enlightening email regarding this:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThe Clause * pointer is [..] located at least on a 4 byte boundary (at least when not forced by e.g. #pragma). If it is not at least on a 4 byte boundary, CPU must (at least some of them) do two accesses: one lower DWORD, one upper DWORD, and merge both together, which reduces speed.\u003c/p\u003e\n\u003cp\u003eSo the lower two bits are always zero :-) Why not move the \u0026ldquo;wasPointer\u0026rdquo; to lower two bits (i think you need only one, have one spare bit). Of course before accessing the \u0026ldquo;pointer\u0026rdquo; (Clause *), you must \u0026ldquo;and\u0026rdquo; the two lower bits back to zero.\u003c/p\u003e\n\u003c/blockquote\u003e","title":"How to bit-stuff pointers"},{"content":"Binary clauses are somewhat special. They are clauses that look like:\n-v1 or v20 = true\n-v1 or v21 = true\nwhich basically mean: if v1 is TRUE, then both v20 and v21 must be TRUE. We put these clauses into a special datastructure, that looks like this:\nwatchlist[-v1] = v20,v21, ...\nThis makes us all very happy, since this datastructure is very simple: just literals (negated or non-negated variables) one after the other, in a very trivial list. This makes the whole thing very compact, and very efficient.\nThe problem with such a list is that when v1 is indeed set to TRUE, then when we set the variables (e.g. v20,v21), we must record what set these variables to their new values. What usually is done is to simply record the pointer to the clause that does this. However, in the above datastructure, there are no clause pointers. The datastructure for GLUCOSE contained these pointers. I have lately been experimenting with removing these pointers. The tricky part is to update the conflict generation routine that examines the clauses and decisions that lead to a conflict. This routine must now automatically recognise that these binary clauses are special, and they are only 2-long: one part of them is the variable that got set, and the other part is the variable that set it. These two informations are available: watchlist[-v1] immediately tells us that literal -v1 set the variable, and the variable that got set is always known.\nArmed with this logic, one would think that moving towards this all-new no-clause-pointers heaven is the way to go. However, apparently, this might not be so. This is quite astonishing, given that doing things without pointers should mean less cache-misses (since pointers are less likely to be resolved during conflict analysis). I consistently get worse speeds, though. I am guessing that the problem lies with the datastructure I use to store the information stating what lead to the setting of the variable. I use a very simple struct:\nstruct WhatLeadHere { bool wasPointer; union{Clause* pointer; Lit lit;}; }; where wasPointer is TRUE if a non-binary clause lead here (and we store the pointer), and FALSE if it was a binary clause (and we store the other literal). The union takes care of the rest: pointer is valid when wasPointer is TRUE and lit is valid when wasPointer is FALSE.\nWhat is apparent in this datastructure is the following: we now store a 32/64 bit pointer plus we store a boolean. Right, so 42/72 bits of data? No. Data alignment in C++ means, that this datastructure will be aligned according to its largest member, so it will be aligned to 32/64-bit boundaries: this datastructure takes 128/64 bits to store on 32 and 64 bit architectures, respectively. Oops, we just doubled our demand of data writes!\nThere are some remedies, of course. We can simply pack:\n#pragma pack(push) #pragma pack(1) struct WhatLeadHere { bool wasPointer; union{Clause* pointer; Lit lit;}; }; #pragma pack(pop) which removes the memory burden of aligning to maximum size, and the actual size will really be 42/72 bits. But this reaises the overhead of accessing data inside this structure. Furthermore, I have been using a 32-bit mini-pointer on 64-bit architectures, which is a big hack, so it crumbles as soon as something as complicated as this comes up: so I am left with writing 72 bits instead of 32. This probably leads to the slowdowns. Oh well, I have got to work harder\u0026hellip;\nEDITED TO ADD: Next up, I will talk about some new ideas that let me solve 217 problems from the 2009 SAT Race within the original time limit. Remember that last year the best solver only solved 204.\n","permalink":"https://www.msoos.org/2010/06/propagating-binary-clauses/","summary":"\u003cp\u003eBinary clauses are somewhat special. They are clauses that look like:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e-v1 or v20 = true\u003c/code\u003e\u003cbr\u003e\n\u003ccode\u003e-v1 or v21 = true\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003ewhich basically mean: if \u003ccode\u003ev1\u003c/code\u003e is TRUE, then both \u003ccode\u003ev20\u003c/code\u003e and \u003ccode\u003ev21\u003c/code\u003e must be TRUE. We put these clauses into a special datastructure, that looks like this:\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ewatchlist[-v1] = v20,v21, ...\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eThis makes us all very happy, since this datastructure is very simple: just literals (negated or non-negated variables) one after the other, in a very trivial list. This makes the whole thing very compact, and very efficient.\u003c/p\u003e","title":"Propagating binary clauses"},{"content":"I have talked about optimisations before and I mentioned that there are a few left to describe. In this post I will talk about two of them.\nThe first optimisation I would like to talk about concerns compilation flags. Somehow, everyone seems obsessed with them, like if they could somehow make a slow program fast. Alas, this is not the case. Firstly, and this is quite funny: the gcc flag \u0026ldquo;-O3\u0026rdquo; usually turns on all extra flags that people tend to give. One should really ponder upon this when looking at desperate attempts to speed up code. However, there is exactly one flag-combo that is very-very useful besides \u0026ldquo;-O3\u0026rdquo;: it\u0026rsquo;s \u0026ldquo;-fprofile-generate\u0026rdquo; and \u0026ldquo;-fprofile-use\u0026rdquo;. To understand why these are useful, we must first understand that one of the challenges faced by an optimising compiler is to try to guess how many times a loop will be executed,and how many times a branch will be taken. Given a good set of guesses, the loop can be unwound (or not) and the branches can be taken by default (or not). If compiled with \u0026ldquo;-fprofile-generate\u0026rdquo;, the program generates such information on-the-fly, which later can be used by \u0026ldquo;-fprofile-use\u0026rdquo;. The speedup achieved with such an approach in the realms of DPLL-based SAT solvers is relatively high, in the order of ~5-10%. I believe many SAT solvers\u0026rsquo; binaries don\u0026rsquo;t use this trick, even though it\u0026rsquo;s cheap to use. I personally compile with \u0026ldquo;-fprofile-generate\u0026rdquo;, then run an example problem like UTI-20-10p1 on it, and then recompile with \u0026ldquo;-fprofile-use\u0026rdquo;. An important aspect, by the way, is to execute your problem with a very typical scenario: strange or non-normal scenarios will produce spurious branching and loop data which will actually slow down the program most of the time instead of speeding it up.\nThe second optimisation I would like to talk about concerns cache usage. Modern processors are extremely fast, to the point that many times what really limits the processor is no longer the ability to execute the code on the data, but to actually get the data that the code needs. This problem is usually alleviated through spatial and temporal data locality that is, that data most likely needed next is usually physically close to the one that we just accessed. However, in DPLL-based SAT solvers, the main function, propagate() goes through a list of pointers, accessing the data where each pointer points to. In other words, the CPU will fetch the next pointer in the background, but will not fetch where that pointer points to \u0026ndash; simply because it doesn\u0026rsquo;t know it\u0026rsquo;s a pointer. So, how could we alleviate this problem? Well, by telling the CPU that the next piece of information that will be needed is where the next pointer points to. Like this:\nfor (i = 0; i \u0026lt; pointers.size(); i++) { if (i+1 \u0026lt; pointers.size()) __builtin_prefetch(pointers[i+1]); treat_data(*pointers[i]); } where pointers is a vector of pointers that must each be treated. The function __builtin_prefetch() calls an assembly instruction that non-blockingly fetches the data pointed to into the Level 1 cache of the processor. This/these instruction(s) are not implemented in all CPUs, but many x86 and all AMD64 architectures have them. Essentially, while we are dealing with data where pointers[i] points at, we fetch the data where pointers[i+1] points at, in parallel. Interleaving the fetching of next data with the treatment of current data helps us do more things in less time, speeding up the program. Interestingly, since prefetching the data does not alter the flow of the program in any way, omitting the prefetch call does not alter the results of the program at all: it just makes it run slower. In CryptoMiniSat I use this optimisation, and it seems to speed up the solving by a couple of percentages, maybe 5-8%. The amount of time you will save on this depends on the locality and size of the information your pointers are pointing to. If they are very small, e.g. 2-3MB in total and are close to each other, then the CPU will fetch these after the first couple of pointers have been dereferenced, so there is no need to do explicit prefetching. But if the data you are dealing with is much larger, which is often the case with SAT solvers, then such explicit pre-fetching can save quite some time.\n","permalink":"https://www.msoos.org/2010/06/optimisations-take-two/","summary":"\u003cp\u003eI have talked about \u003ca href=\"http://msoos.blogspot.com/2010/04/optimisations.html\"\u003eoptimisations\u003c/a\u003e before and I mentioned that there are a few left to describe. In this post I will talk about two of them.\u003c/p\u003e\n\u003cp\u003eThe first optimisation I would like to talk about concerns compilation flags. Somehow, everyone seems obsessed with them, like if they could somehow make a slow program fast. Alas, this is not the case. Firstly, and this is quite funny: the \u003ca href=\"http://gcc.gnu.org/\"\u003egcc\u003c/a\u003e flag \u0026ldquo;\u003ca href=\"http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html\"\u003e-O3\u003c/a\u003e\u0026rdquo; usually turns on all extra flags that people tend to give. One should really ponder upon this when looking at desperate attempts to speed up code. However, there is exactly one flag-combo that is very-very useful besides \u0026ldquo;-O3\u0026rdquo;: it\u0026rsquo;s \u0026ldquo;-fprofile-generate\u0026rdquo; and \u0026ldquo;-fprofile-use\u0026rdquo;. To understand why these are useful, we must first understand that one of the challenges faced by an optimising compiler is to try to guess how many times a loop will be executed,and how many times a branch will be taken. Given a good set of guesses, the loop can be unwound (or not) and the branches can be taken by default (or not). If compiled with \u0026ldquo;-fprofile-generate\u0026rdquo;, the program generates such information on-the-fly, which later can be used by \u0026ldquo;-fprofile-use\u0026rdquo;. The speedup achieved with such an approach in the realms of DPLL-based SAT solvers is relatively high, in the order of ~5-10%. I believe many SAT solvers\u0026rsquo; binaries don\u0026rsquo;t use this trick, even though it\u0026rsquo;s cheap to use. I personally compile with \u0026ldquo;-fprofile-generate\u0026rdquo;, then run an example problem like \u003ca href=\"http://www.cril.univ-artois.fr/SAT09/results/bench.php?idev=29\u0026amp;idbench=71050\"\u003eUTI-20-10p1\u003c/a\u003e on it, and then recompile with \u0026ldquo;-fprofile-use\u0026rdquo;. An important aspect, by the way, is to execute your problem with a very typical scenario: strange or non-normal scenarios will produce spurious branching and loop data which will actually slow down the program most of the time instead of speeding it up.\u003c/p\u003e","title":"Optimisations, take two"},{"content":"The new CryptoMiniSat 2.5.1, codenamed \u0026ldquo;The Obvious Child\u0026rdquo; has been released. It\u0026rsquo;s very close to the system that has been sent into the SAT Race'10. This version of CryptoMS is much better than any versions before: I finally corrected a lot of bugs that went into the 2.4.x series, and added new features to treat binary clauses.\nThe release name is the song title by Paul Simon. I am a fan of the 60\u0026rsquo;s for many reasons. It was the time when Laing wrote his first books, empathy was first scientifically demonstrated for animals, the days of I have a dream, the landing on the moon, and the take-off of Simon\u0026amp;Garfunkel.; Some interesting times, shall we say.\nI probably will be working less on CryptoMiniSat from now on, instead concentrating on other things that I must do, such as publishing research papers on subjects that interest the scientific community. I will also be trying to play out in my mind how CryptoMiniSat will fare in the SAT Race. Of course I am hoping for the best, but I worked on the program for a mere 8 months, alone. Comparing this to some experts working on their solvers for multiple years in groups of 2-3, I really have no chance of winning. However, I am optimistic, as always: maybe I will get some good position in the rankings :)\n","permalink":"https://www.msoos.org/2010/06/the-obvious-child/","summary":"\u003cp\u003eThe new CryptoMiniSat 2.5.1, codenamed \u0026ldquo;The Obvious Child\u0026rdquo; has been \u003ca href=\"https://gforge.inria.fr/frs/shownotes.php?release_id=5231\"\u003ereleased\u003c/a\u003e. It\u0026rsquo;s very close to the system that has been sent into the \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/\"\u003eSAT Race'10\u003c/a\u003e. This version of CryptoMS is much better than any versions before: I finally corrected a lot of bugs that went into the 2.4.x series, and added new features to treat binary clauses.\u003c/p\u003e\n\u003cp\u003eThe release name is the \u003ca href=\"http://www.paulsimon.com/node/112\"\u003esong title\u003c/a\u003e by Paul Simon. I am a fan of the 60\u0026rsquo;s for many reasons. It was the time when \u003ca href=\"http://en.wikipedia.org/wiki/R._D._Laing\"\u003eLaing\u003c/a\u003e wrote his first books, \u003ca href=\"http://www.sciencedirect.com/science?_ob=ArticleURL\u0026amp;_udi=B8H4J-4NRKWK7-2\u0026amp;_user=10\u0026amp;_coverDate=04%2F30%2F1959\u0026amp;_rdoc=2\u0026amp;_fmt=high\u0026amp;_orig=browse\u0026amp;_srch=doc-info%28%23toc%2342608%231959%23999479997%23654711%23FLP%23display%23Volume%29\u0026amp;_cdi=42608\u0026amp;_sort=d\u0026amp;_docanchor=\u0026amp;_ct=29\u0026amp;_acct=C000050221\u0026amp;_version=1\u0026amp;_urlVersion=0\u0026amp;_userid=10\u0026amp;md5=5fe3e6800c80474f03f7e79ea5f84ee9\"\u003eempathy\u003c/a\u003e was first scientifically demonstrated for animals, the days of \u003ca href=\"http://en.wikipedia.org/wiki/I_Have_a_Dream\"\u003eI have a dream\u003c/a\u003e, the \u003ca href=\"http://en.wikipedia.org/wiki/Apollo_11\"\u003elanding\u003c/a\u003e on the moon, and the take-off of Simon\u0026amp;Garfunkel.; Some interesting times, shall we say.\u003c/p\u003e","title":"The Obvious Child"},{"content":"I just bought the book with the title of the blogpost by Andreas Zeller. Essentially, it\u0026rsquo;s about debugging, where the author analyses the chain of program defect leading to infected program state, finally leading to program failure. I bought the book because while working with CryptoMiniSat, I have encountered so many bugs that they could fill a book.\nThe problem with chasing bugs in CryptoMiniSat is that SAT solvers employ a very optimised algorithm that makes a lot of decisions per second, so recording all interesting events makes for a very big dump file. I have per-module verbosity settings, so if I can narrow down what module(s) are causing the failure, there is less debug output to go through, but sometimes I still have to wade through 10-20GB dumps to see how the program state got infected.\nWhile going through such large dumps, the following occured to me: what if we loaded all this data into a MySQL database? Some 8 years ago I had a job where I processed a large chunk of the data on all of Hungary\u0026rsquo;s phone conversations on a daily basis. Essentially, data on your phone calls are recorded in many different databases, and these must be merged to calculate your bill and to provide statistical feedback to the company. I wrote a program that processed 3million records in about 1 hour using MySQL and a number of SQL statements that spanned approx. 2-3000 lines. In other words, I am not afraid of large databases, and I think such multi-gigabyte data could easily be loaded into a MySQL database.\nThe goal of loading a SAT run into a MySQL database is the following: once the MySQL data is ready, a bit of PHP, graphviz and gnuplot will plot any relevant information at any point in time about the solving. In other words, we could dig this data visually, with some very interesting effects.\nFor example, I have been lately having problems with clause strengthening interfering with variable elimination. The idea is in theory quite simple. Variable elimination eliminates a variable and adds clauses that represent the original clauses the variable was present in. These clauses are sometimes trivial, such as:\na or b or c or !c = true which is never added since it is satisfied whether c is true or false. So far, so good. Clause strenghtening is a method whereby clauses are shortened. For example, if there was a clause:\ne or b or c = true the solver might discover that in fact it is also true that:\ne or b = true and replace the original clause with this, since this clause is \u0026ldquo;stronger\u0026rdquo;: it poses a more stringent requirement. The way variable elimination and clause strenghtening interact is as follows. Let\u0026rsquo;s suppose we eliminate on varible e. If the above clause is strenghtened before elimination, then instead of:\na or b or c or !c = true we might have got:\na or b or !c = true which must be added. We actually have more clauses because of clause strenghtening! I believe nobody ever found this anomaly. To properly quantitise how this affects solving, we need to know all states of a clause, and a web interface with a MySQL backbone could help a lot with that.\n","permalink":"https://www.msoos.org/2010/05/why-programs-fail/","summary":"\u003cp\u003eI just bought the \u003ca href=\"http://www.whyprogramsfail.com/\"\u003ebook\u003c/a\u003e with the title of the blogpost by Andreas Zeller. Essentially, it\u0026rsquo;s about debugging, where the author analyses the chain of program defect leading to infected program state, finally leading to program failure. I bought the book because while working with CryptoMiniSat, I have encountered so many bugs that they could fill a book.\u003c/p\u003e\n\u003cp\u003eThe problem with chasing bugs in CryptoMiniSat is that SAT solvers employ a very optimised algorithm that makes a lot of decisions per second, so recording all interesting events makes for a very big dump file. I have per-module verbosity settings, so if I can narrow down what module(s) are causing the failure, there is less debug output to go through, but sometimes I still have to wade through 10-20GB dumps to see how the program state got infected.\u003c/p\u003e","title":"Why programs fail"},{"content":"In my last post, I presented a fast and easy way to add binary clauses to the clause database of SAT solvers, and I conjectured that since the algorithm was so simple, there must be something wrong with it. I was, in fact, right. I ran a cluster experiment, and it turned out that adding all those binary clauses was slowing down the solving.\nMy first reaction was of course: how on Earth? Binary clauses are \u0026ldquo;good\u0026rdquo;: both MiniSat and Glucose try to amass these clauses as much as possible. So what can possibly be wrong? Well, redundant information, for a start. Let\u0026rsquo;s assume that we know that\nA leads to B B leads to C If I now tell you that\nA leads to C it wouldn\u0026rsquo;t really help you. However, the algorithm I presented last time didn\u0026rsquo;t address this issue. It simply added a good number (though, luckily, not all possible) binary clauses that were totally redundant.\nThe trick of adding binary clauses is, then, to add as little as possible to achieve maximal graph connectivity. And, while we are at it, we can of course remove all redundant information like the one I presented above. Neither of these two are easy. I use the Monte-Carlo method to approximate the degree of vertexes for the first algorithm, and then sort vertexes according to their degrees when adding binary clauses. The second algorithm just needs a bit of imagination and a will to draw graphs on a piece of paper.\nSo, there is a point in being dumb: without the hands-on knowledge how binary clauses negatively affect problem solving, I would never have thought of developing such algorithms. The final algorithms take ~3-4 seconds to complete, add (fairly close to) the minimum number of clauses, remove all redundant clauses, and work like a charm.\nThere is only one thing to understand now: why does Armin Biere add hundreds of thousands of binary clauses? I seem to be able to achieve the same effect in a couple of thousand\u0026hellip; Again, I must be dumb, and he must be doing something right. I am lost, again :(\nEDITED TO ADD: You might enjoy this plot of PrecoSat236 vs. CryptoMiniSat 2.5.0beta1 on the SAT Competition instances of 2009.\n","permalink":"https://www.msoos.org/2010/05/being-dumb-is-part-of-the-deal/","summary":"\u003cp\u003eIn my \u003ca href=\"?p=18\"\u003elast post\u003c/a\u003e, I presented a fast and easy way to add binary clauses to the clause database of \u003ca href=\"http://en.wikipedia.org/wiki/Boolean_satisfiability_problem\"\u003eSAT solvers\u003c/a\u003e, and I conjectured that since the algorithm was so simple, there must be something wrong with it. I was, in fact, right. I ran a cluster \u003ca href=\"https://www.grid5000.fr/mediawiki/index.php/Special:G5KExperiments?menu=renderexperiment\u0026amp;id=643\"\u003eexperiment\u003c/a\u003e, and it turned out that adding all those binary clauses was slowing down the solving.\u003c/p\u003e\n\u003cp\u003eMy first reaction was of course: how on Earth? Binary clauses are \u0026ldquo;good\u0026rdquo;: both \u003ca href=\"http://minisat.se/\"\u003eMiniSat\u003c/a\u003e and \u003ca href=\"http://www.cril.univ-artois.fr/%7Eaudemard/\"\u003eGlucose\u003c/a\u003e try to amass these clauses as much as possible. So what can possibly be wrong? Well, redundant information, for a start. Let\u0026rsquo;s assume that we know that\u003c/p\u003e","title":"Being dumb is part of the deal"},{"content":"Apparently, hyper-binary resolution is not easy. However, I have been reading the paper by Gershman and Strichman, and they make it sound like it\u0026rsquo;s the easiest thing of all \u0026ndash; especially if you don\u0026rsquo;t do it the way they are doing it, of course.\nHyper-binary resolution is essentially very easy. Let\u0026rsquo;s say you have three clauses:\n-a V b -a V c d V -b V -c (where V is the binary OR, - is the binary negation, and each line must be satisfied)\nIf we set a=true and propagate this, then we get to the result that d=true. Which can be coded down as the clause:\n-a V d More interestingly, this new clause actually helps: if you only use the original 3 clauses, and you set d = false and propagate, nothing happens. However, if you add the new clause to the clause list, then a=false propagates automatically.\nThe way these kind of new binary clauses (like -a V d) could be found has been done before as follows:\nBuild graph from binary clauses: literals are vertices and there are edges between vertices a and b if there is a binary clause -a V b Set a=true and propagate Check if every propagated fact can be reached starting from the vertex corresponding to a in the graph. If it cannot be reached, add the binary clause that represents the edge. One can say that this algorithm works perfectly. But I am a lazy coder, and I don\u0026rsquo;t want to implement a graph library into CryptoMiniSat. What\u0026rsquo;s there to do then? Well, we can achieve the same thing with data structures already present in all modern solvers!\nThe trick to use is that binary clauses are propagated in a very different manner than normal clauses: they have their own watchlists, and propagating binary clauses is extremely fast. So, instead of trying to fiddle with some overoptimised graph library, we can simply write a routine, called propagateBin(), which only propagates binary clauses already inside the code. We then compare the propagate() and the results of propagateBin() and if something is missing, we add it.\nIn fact, implementing this algorithm using the above trick is trivial. No use of graph libraries, nothing to do really, just write a 20-line propagateBin(), which itself is just a copy-paste of the first couple of lines of propagate() . A very short side-note: it\u0026rsquo;s also very fast. We can find 100'000 binary clauses in less than 0.1 seconds. Here is the commit that implements this in CrptoMiniSat. I think it makes sense even for those unfamiliar with the code.\nFinally, why am I dumb? Because there must be something amiss here. I can\u0026rsquo;t believe that people much more knowledgeable in the subject didn\u0026rsquo;t come up with this idea before. So, they must have, and probably already published it, or, the idea must be really bad, missing elements or is incomplete. If it is complete, however, then hyper-binary resolution is once and for all fast and efficient. Can\u0026rsquo;t wait for someone to prove me wrong.\n","permalink":"https://www.msoos.org/2010/05/i-must-be-dumb/","summary":"\u003cp\u003eApparently, hyper-binary resolution is \u003ca href=\"http://fmv.jku.at/biere/talks/Biere-Dagstuhl09-talk.pdf\"\u003enot easy\u003c/a\u003e. However, I have been reading the \u003ca href=\"http://www.cs.technion.ac.il/%7Egershman/papers/sat05_full.pdf\"\u003epaper\u003c/a\u003e by Gershman and Strichman, and they make it sound like it\u0026rsquo;s the easiest thing of all \u0026ndash; especially if you don\u0026rsquo;t do it the way they are doing it, of course.\u003c/p\u003e\n\u003cp\u003eHyper-binary resolution is essentially very easy. Let\u0026rsquo;s say you have three clauses:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-a V b\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e-a V c\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ed V -b V -c\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003e(where \u003ccode\u003eV\u003c/code\u003e is the binary OR, \u003ccode\u003e-\u003c/code\u003e is the binary negation, and each line must be satisfied)\u003c/p\u003e","title":"I must be dumb"},{"content":"Apparently, there have been quite some work done on failed literal probing, although I don\u0026rsquo;t think they have all been put into a common package yet.\nThe idea is quite simple in its purest form: try to set variable v1 to true and see if that fails. If it does, variable v1 must be false. If it doesn\u0026rsquo;t fail, try the other way around: set it to false and if that fails, it must be true.\nThere are a couple of tricks we can add, however. For example, if both v1 and !v1 set variable v10 to value X (where X can be either true or false), then set v10 to X. The reasoning here is simple: v1 must be set, so whatever both v1 and !v1 imply, it must be set, too. So we can safely set v10 to X.\nA more interesting thinking is the following. If v1 sets v20 to true, but !v1 sets v20 to false, then v1 = v20. So, we can replace v20 with v1. One less variable to worry about!\nThere are even more tricks, however. If setting v1 to true and false both shorten a longer XOR to a 2-long XOR \u0026quot; v40 + v50 = false\u0026quot;, this 2-long XOR can be learnt: v40 can be replaced with v50.\nAnd more tricks. If there is a 2-long clause v1 or v2 = true, then we can do all of the above, but with v1 and v2 this time. Since either v1 or v2 must be true, all the above ideas still work. In all previous ideas all we used was the fact that either v1 or !v1 must be true. This is still the case: either v1 or v2 must be true. This, by the way, is called 1-recursive learning. (note: the fourth paragraphs changes a bit, but we still learn a 2-long xor).\nAnd now something new. I have been thinking about trying to re-use old learnt clauses. They really code down sometimes quite important facts about the problem. What if we tried to re-use them? After all, keeping them in memory is really cheap: the only problem with them is that doing regular propagation with them takes a lot of time, thus slowing down the solver. But what if we only used them to do failed literal probing? I just launched a test on the Grid'5000 cluster to find out. Fingers crossed\u0026hellip;\n","permalink":"https://www.msoos.org/2010/05/on-failed-literal-probing/","summary":"\u003cp\u003eApparently, there have been \u003ca href=\"http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.24.6395\u0026amp;rep=rep1\u0026amp;type=pdf\"\u003equite\u003c/a\u003e \u003ca href=\"http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.25.1063\"\u003esome\u003c/a\u003e \u003ca href=\"http://www.eecs.umich.edu/%7Evaleria/research/publications/IWLS06SAT.pdf\"\u003ework\u003c/a\u003e done on failed literal probing, although I don\u0026rsquo;t think they have all been put into a common package yet.\u003c/p\u003e\n\u003cp\u003eThe idea is quite simple in its purest form: try to set variable \u003ccode\u003ev1\u003c/code\u003e to \u003ccode\u003etrue\u003c/code\u003e and see if that fails. If it does, variable \u003ccode\u003ev1\u003c/code\u003e must be \u003ccode\u003efalse\u003c/code\u003e. If it doesn\u0026rsquo;t fail, try the other way around: set it to \u003ccode\u003efalse\u003c/code\u003e and if that fails, it must be \u003ccode\u003etrue\u003c/code\u003e.\u003c/p\u003e","title":"On failed literal probing"},{"content":"The new CryptoMiniSat, version 2.4.2 now has on-the-fly Gaussian elimination compiled in by default. You can simply use it by issuing e.g.\n./cryptominisat --gaussuntil=100 trivium-cipher.cnf\nand enjoy outputs such as:\nc gauss unit truths : 0 c gauss called : 31323 c gauss conflicts : 5893 (18.81 %) c gauss propagations : 7823 (24.98 %) c gauss useful : 43.79 % c conflicts : 34186 (4073.39 / sec) c decisions : 39715 (6.86 % random)\nWhich basically tells that gaussian elimination was called 31 thousand times out of 39 thousand, and so it was essentially running almost all the time. Out of the 31'323 times it was called, 44% of the cases it found either a conflict or a propagation. This is a very good result, and is typical of the Trivium cipher. Trivium can be speeded up by up to 2x with Gaussian elimination. I will put up lots of CNFs, so you will be able to play around with them and (optionally) verify these results.\nThe magic parameter \u0026ldquo;\u0026ndash;gaussuntil=100\u0026rdquo; tells the program to execute Gaussian elimination until decision level 100, and no deeper. I haven\u0026rsquo;t implemented and automation into finding the best depth, and so I use this (very) crude fixed number 100. Probably better results could be achieved with a fine tuning of the depth cut-off, but I don\u0026rsquo;t have the time for the moment to play around with it. However, if you are interested, you will be able to try out different depths, different ciphers, etc. I will shortly be releasing a tool called \u0026ldquo;Grain of Salt\u0026rdquo; to generate CNFs for any shift-register based stream cipher, so you can test them against CryptoMiniSat or any other SAT solver.\nI hope you will enjoy using on-the-fly Gaussian elimination in CryptoMiniSat 2.4.2!\n","permalink":"https://www.msoos.org/2010/05/gaussian-elimination-is-released/","summary":"\u003cp\u003eThe \u003ca href=\"https://gforge.inria.fr/frs/?group_id=1992\"\u003enew CryptoMiniSat\u003c/a\u003e, version 2.4.2 now has on-the-fly \u003ca href=\"http://en.wikipedia.org/wiki/Gaussian_elimination\"\u003eGaussian elimination\u003c/a\u003e compiled in by default. You can simply use it by issuing e.g.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e./cryptominisat --gaussuntil=100 trivium-cipher.cnf\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eand enjoy outputs such as:\u003cbr\u003e\n\u003ccode\u003ec gauss unit truths     : 0 c gauss called          : 31323 c gauss conflicts       : 5893        (18.81      %) c gauss propagations    : 7823        (24.98      %) c gauss useful          : 43.79       % c conflicts             : 34186       (4073.39   / sec) c decisions             : 39715       (6.86      % random)\u003c/code\u003e\u003cbr\u003e\nWhich basically tells that gaussian elimination was called 31 thousand times out of 39 thousand, and so it was essentially running almost all the time. Out of the 31'323 times it was called, 44% of the cases it found either a conflict or a propagation. This is a very good result, and is typical of the \u003ca href=\"http://en.wikipedia.org/wiki/Trivium_%28cipher%29\"\u003eTrivium\u003c/a\u003e cipher. Trivium can be speeded up by up to 2x with Gaussian elimination. I will put up lots of CNFs, so you will be able to play around with them and (optionally) verify these results.\u003c/p\u003e","title":"Gaussian elimination is released"},{"content":"I have lately been reading the book Using OpenMP and thinking about how CryptoMiniSat could be parallelised. Apparently, there are multiple ways to achieve it. I haven\u0026rsquo;t yet had time to read through all previous approaches, but it seems there are at least two main ways to distribute the solving: through guiding paths and using the idea of ManySat.\nThe first approach, guiding paths, decomposes the problem into multiple sub-problems, setting some variables to true or false. The problems are then solved completely independently with a master coordinating the effort. I don\u0026rsquo;t like this approach for two reasons. Firstly, for cryptographic problems, the decomposition can be made very well since the problem in its most abstract form (i.e. key, plaintext, ciphertext) is known, and so a very good guiding path can be calculated. However, even with this very good guiding path, the expected total time to solve is far more than if the problem was given to one solver instance. In other words, if we decompose the problem into 4 sub-problems, and each sub-problem takes on average T time to solve, then the total average time is 4T, but if we gave the problem to one solver, it would have found the solution on average in e.g. 2T time. In other words, the gain is not as much as one would hope. I would guess that this ratio (2T/4T = 1/2 in this case) is even worse when the problem\u0026rsquo;s abstract form is totally unknown (which is most of the time), and the solver has to guess a guiding path.\nThe second approach, that of ManySat is to start the same solver with the same problem multiple times, but use different restart heuristics to solve the problem. Since modern DPLL-based SAT solvers use randomised algorithms, this helps to reduce the expected time to solve an instance. Also, the solvers share short clauses with one another to work in a more collaborative manner. However, I believe that given the distribution of the solving time of a problem with a given solver, even if more instances of it are launched (each with a random seed and different restart strategy), the minimum solving time of all launched solvers will not be as small as one would hope. It is extremely rare that a difficult instance can be solved in under e.g. 1 minute if the average time to solve it is 1000 minutes. So, if we were to launch 1000 solver instances, probably none would finish before 2-300 minutes. Of course I am not counting the effect of shared learnt clauses here, but I am not very convinced about them. Apparently, activity-based learnt clause sharing (instead of size-based) is more effective than size-based (see this), and ManySat shares them according to the size.\nSo, if all else fails, what is there left to do? Well, I bought the OpenMP book to find out. I wish to implement the idea of distributing clauses to different threads, thus distributing the BCP (Boolean Constraint Propagation) load. However, multi-threading can only go so far, so MPI will eventually need to be used, along with multiple instances of the solver on the same physical CPU, the way ManySAT is doing it \u0026ndash; though I will try to implement some form of clause-sharing. The good thing is, that implementing MPI will also bring the possibility of running a problem instance on a huge cluster, something I am really looking forward to.\nEDITED TO ADD (16/07/2010): I just realised that MiraXT does quite a number of things that I wish to implement into CryptoMiniSat.\n","permalink":"https://www.msoos.org/2010/05/parallelisation/","summary":"\u003cp\u003eI have lately been reading the book \u003ca href=\"http://www.amazon.com/Using-OpenMP-Programming-Engineering-Computation/dp/0262533022\"\u003eUsing OpenMP\u003c/a\u003e and thinking about how CryptoMiniSat could be \u003ca href=\"http://www.eecs.umich.edu/%7Evaleria/research/publications/IWLS06SAT.pdf\"\u003eparallelised\u003c/a\u003e. Apparently, there are multiple ways to achieve it. I haven\u0026rsquo;t yet had time to read through all previous approaches, but it seems there are at least two main ways to distribute the solving: through \u003ca href=\"http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.40.9517\"\u003eguiding paths\u003c/a\u003e and using the idea of \u003ca href=\"http://jsat.ewi.tudelft.nl/content/volume6/JSAT6_12_Hamadi.pdf\"\u003eManySat\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eThe first approach, guiding paths, decomposes the problem into multiple sub-problems, setting some variables to \u003ccode\u003etrue\u003c/code\u003e or \u003ccode\u003efalse\u003c/code\u003e. The problems are then solved completely independently with a master coordinating the effort. I don\u0026rsquo;t like this approach for two reasons. Firstly, for cryptographic problems, the decomposition can be made very well since the problem in its most abstract form (i.e. key, plaintext, ciphertext) is known, and so a very good guiding path can be calculated. However, even with this very good guiding path, the expected total time to solve is far more than if the problem was given to one solver instance. In other words, if we decompose the problem into 4 sub-problems, and each sub-problem takes on average T time to solve, then the total average time is 4T, but if we gave the problem to one solver, it would have found the solution on average in e.g. 2T time. In other words, the gain is not as much as one would hope. I would guess that this ratio (2T/4T = 1/2 in this case) is even worse when the problem\u0026rsquo;s abstract form is totally unknown (which is most of the time), and the solver has to guess a guiding path.\u003c/p\u003e","title":"Parallelisation"},{"content":"I saw a talk by Ed Catmull on the problems Pixar had in their early days. The talk is very interesting, and I recommend it. What caught me, is that at Pixar they had a \u0026ldquo;brain trust\u0026rdquo;, a certain group of people who could express their new ideas to one another without fear of backlash. This is actually very difficult to achieve, since early implementations of ideas are always \u0026ldquo;childish\u0026rdquo;, lack maturity, and are therefore not considered good enough to be shared with others. However, if you don\u0026rsquo;t share the idea with the others early, then you will get feedback too late, when you have already invested a lot of time into it. Criticism at this late stage hurts more and what is worse, it might make you so uncomfortable, that you might abandon the idea altogether.\nThe trick is to get a set of people to trust each other well enough to share not-yet mature ideas with one another in the early stage, so that criticism can help everyone get their ideas right from the start. Establishing this trust is very difficult. I started to understand what Ed Catmull was talking about while working with the STP team. The earlier I seemed to share my ideas, the better they got. For instance, CryptoMiniSat was originally never meant to be used as a library. However, once they (mostly Vijay Ganesh) helped me debug the code, it was much easier to get things \u0026ldquo;right\u0026rdquo;. I also met Laurent Simon last year for half a day, and he gave me the idea of using Grid'5000 to test the performance of CryptoMiniSat. Without these early steering ideas, I would have never been able to get CryptoMiniSat to where it is today.\n","permalink":"https://www.msoos.org/2010/04/social-coding/","summary":"\u003cp\u003eI saw a \u003ca href=\"http://www.youtube.com/watch?v=k2h2lvhzMDc\"\u003etalk\u003c/a\u003e by Ed Catmull on the problems Pixar had in their early days. The talk is very interesting, and I recommend it. What caught me, is that at Pixar they had a \u0026ldquo;brain trust\u0026rdquo;, a certain group of people who could express their new ideas to one another without fear of backlash. This is actually very difficult to achieve, since early implementations of ideas are always \u0026ldquo;childish\u0026rdquo;, lack maturity, and are therefore not considered good enough to be shared with others. However, if you don\u0026rsquo;t share the idea with the others early, then you will get feedback too late, when you have already invested a lot of time into it. Criticism at this late stage hurts more and what is worse, it might make you so uncomfortable, that you might abandon the idea altogether.\u003c/p\u003e","title":"Social coding"},{"content":"While writing the description of CryptoMiniSat for the 2010 SAT Race, I have realised how powerful the blocked clause elimination (BCE) technique by Matti Jarvisalo and Armin Biere is. For xor clauses, which represent a simple XOR like\nv1 + v2 + v3 = true\nthere is a technique called dependent variable removal by Heule and Maaren. This technique removes an xor clause if one of its variables appears only in one place: in that xor clause. The idea is that since that variable only appears there, the XOR can always be satisfied. For example, if variable v1 is dependent (i.e. it only appears in this XOR), and\nv2 = true, v3 = true\nthen this xor-clause can simply be satisfied by giving v1 = true:\ntrue + true + true = true\nSo, variable v1 can be removed from the problem along with the xor clause, and the value of variable v1 needs only to be calculated after the solving has finished.\nThe great thing about blocked clause elimination, is that it can achieve this automatically, without the use of xor-clauses! Let us convert our xor-clause into regular clauses:\nv1 v2 v3 (1)\nv1 -v2 -v3 (2)\n-v1 v2 -v3 (3)\n-v1 -v2 v3 (4)\nNow, let us try to block these clauses on variable v1. Resolving (1) with (3) gives tautology since the result of the resolution,\nv2 v3 v2 -v3\nhas both a literal and its negation ( v3 and -v3) in it. The same is true for resolving (1) and (4), this time with v2 and -v2. The same happens to (2)\u0026amp;(3) and (2)\u0026amp;(4), too, eventually removing all clauses.\nSo, can blocked clause elimination replace dependent variable removal? I am not sure. Dependent variable removal can be used in conjunction with other methods that treat xor caluses, that can lead to potentially very long XOR chains. These long XOR chains are not well handled through regular clauses, and so they are not created by solvers that don\u0026rsquo;t handle xor clauses natively \u0026ndash; creating them is avoided through heuristic cut-offs. Thus, dependent variable removal can potentially remove more of these XOR-s than blocked clause elimination. But blocked clause elimination can remove clauses that dependent variable elimination cannot. So, I believe there is point in using both.\n","permalink":"https://www.msoos.org/2010/04/blocked-clause-elimination-implies-dependent-variable-removal/","summary":"\u003cp\u003eWhile writing the description of \u003ca href=\"http://cryptominisat.gforge.inria.fr/\"\u003eCryptoMiniSat\u003c/a\u003e for the \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/\"\u003e2010 SAT Race\u003c/a\u003e, I have realised how powerful the \u003ca href=\"http://dx.doi.org/10.1007/978-3-642-12002-2_10\"\u003eblocked clause elimination\u003c/a\u003e (BCE) technique by Matti Jarvisalo and Armin Biere is. For xor clauses, which represent a simple XOR like\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ev1 + v2 + v3 = true\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003ethere is a technique called \u003ca href=\"http://www.satisfiability.org/SAT04/programme/72.pdf\"\u003edependent variable removal\u003c/a\u003e by Heule and Maaren. This technique removes an xor clause if one of its variables appears only in one place: in that xor clause. The idea is that since that variable only appears there, the XOR can always be satisfied. For example, if variable \u003ccode\u003ev1\u003c/code\u003e is dependent (i.e. it only appears in this XOR), and\u003c/p\u003e","title":"Blocked clause elimination implies dependent variable removal"},{"content":"CryptoMiniSat version 2.4.0 is finally here. I decided to use the INRIA Gforge system to coordinate bug-hunting, release management and the forums. However, the source code revision management is coordinated through Gitorious. There, you can find all revisions that have been made to CryptoMiniSat since its original SVN revision control was fixed to use trunk and branches. I believe at least a 1000 revisions are up, so you can see how the source evolved. The source now should be pretty stable, but I am looking forward to all bug reports and suggestons.\nGaussian elimination is currently disabled. It is present in the code, however, and can be enabled. The reason for disabling it is that I haven\u0026rsquo;t used it for quite some while. This means it needs testing to be stable, and some very minor tuning needs to be carried out to make work with the much updated internal state of CryptoMiniSat.\nI hope this release is just a starting point for a number of upcoming releases that will be made in a much more transparent manner than they have been done until now. I am looking forward to feature requests, bug report and merge requests both in the Gforge and the Gitorious intefaces. Good SAT solving!\n","permalink":"https://www.msoos.org/2010/04/cryptominisat-v2-finally-released/","summary":"\u003cp\u003eCryptoMiniSat version 2.4.0 is finally \u003ca href=\"http://cryptominisat.gforge.inria.fr/\"\u003ehere\u003c/a\u003e. I decided to use the \u003ca href=\"https://gforge.inria.fr/projects/cryptominisat/\"\u003eINRIA Gforge system\u003c/a\u003e to coordinate bug-hunting, release management and the forums. However, the source code revision management is coordinated through \u003ca href=\"http://gitorious.com/cryptominisat\"\u003eGitorious\u003c/a\u003e. There, you can find all revisions that have been made to CryptoMiniSat since its original SVN revision control was fixed to use trunk and branches. I believe at least a 1000 revisions are up, so you can see how the source evolved. The source now should be pretty stable, but I am looking forward to all bug reports and suggestons.\u003c/p\u003e","title":"CryptoMiniSat v2 finally released"},{"content":"Lately, I have been having a poll of who will win the SAT Race'10. Apparently, 5 people voted until now, me included. I voted PrecoSat. Not because I didn\u0026rsquo;t want to vote CryptoMiniSat, but because I honestly believe it really will win. The reason is awfully simple: Armin Biere, the (main) author of PrecoSat has had far more experience and time than me to perfect his solver. This is normal, though I only hope he might notice the amount of effort that was put into CryptoMiniSat.\nCryptoMiniSat now contains ~10'000 lines of code, compared to the original so-called \u0026lsquo;core\u0026rsquo;MiniSat it has been developed from, which contained ~1'000. A ten-fold increase in code, which represents more than 1300 commits in the main tree (and about 1.5 years of my life). This effort has not been carried out alone. Though I haven\u0026rsquo;t much talked about people that helped me on the way, CryptoMiniSat has been tested and patches have been committed by a number of people, putting a lot of their time and effort into making a working SAT solver. They all worked just for the fun of being part of the project.\nThe collaborative nature of the CryptoMiniSat project is partially the reason why, I hope, it might succeed in the end in becoming a viable alternative to PrecoSat. End of next week, I will post the whole revision history of CryptoMiniSat to Gitorious, so everyone can see how certain options evolved over time \u0026ndash; my commit messages are usually (overly) long ;) Then, bugzilla, mailing lists, forums and the rest will hopefully garner some steam, and we can start rolling. The road is wide ahead\u0026hellip;\n","permalink":"https://www.msoos.org/2010/04/on-precosat/","summary":"\u003cp\u003eLately, I have been having a poll of who will win the \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/\"\u003eSAT Race'10\u003c/a\u003e. Apparently, 5 people voted until now, me included. I voted \u003ca href=\"http://fmv.jku.at/precosat/\"\u003ePrecoSat\u003c/a\u003e. Not because I didn\u0026rsquo;t want to vote CryptoMiniSat, but because I honestly believe it really will win. The reason is awfully simple: \u003ca href=\"http://fmv.jku.at/biere/\"\u003eArmin Biere\u003c/a\u003e, the (main) author of PrecoSat has had far more experience and time than me to perfect his solver. This is normal, though I only hope he might notice the amount of effort that was put into CryptoMiniSat.\u003c/p\u003e","title":"On PrecoSat"},{"content":"There are plenty of optimisations that I have tried with CryptoMiniSat. I will try to list a few that I finally didn\u0026rsquo;t consider using, but could be implemented later to get around 4-8% speedup each.\nIt seems a good idea to use a separate CNF simplifier such as SatELite before executing the SAT solver. The reasoning is, that even though one can import (or copy-paste) the code from SatELite, the memory will stay fragmented: variable elimination might remove half the variables, and so the arrays that store variable values will have unused bytes in them, using a larger footprint than necessary, thus causing cache misses. Though this is true, SatELite is not exactly perfect. For instance, it can be seen in certain instances of the SAT Competition of 2009 that GLUCOSE sometimes had very bad performance in comparison with other solvers exactly because SatELite took, e.g. 130 seconds, but the solving only took 2 seconds. So SatELite slowed down the solving of this instance. Also, SatELite has some limitations, e.g. it cannot handle more than 4'800'000 clauses otherwise it might take just too much time. These are huge drawbacks, and in fact CryptoMiniSat (and, e.g. PrecoSat) overcomes all of these. The memory fragmentation issue remains, though. It could be treated, but that would require about 2-3 weeks of time to get corrected, and I simply don\u0026rsquo;t have that much time. P.S.: Easy solution: rename the variables everywhere. Hard (but less error-prone) solution: use different datastructure for variable values.\nAnother possible optimisation that never made it to CryptoMiniSat (though I have a branch in git that achieves it more-or-less) is the close packing of clauses in memory. It can greatly increase the cache-hit ratio, though only for relatively small (\u0026lt;20-40 MByte) problems. The reason why I never got this done is that it is a source of a lot of potential problems. Firstly, there is no point in packing clause sizes that are rare. The most common clause size is 2 (see SAT Competition instances), so it\u0026rsquo;s only logical to pack these clauses. However, this presents a problem: how should the clause be freed after usage? If it was a packed clause, it needs to be freed specially (from the packed heap). But sometimes, non-packed clauses shrink to size 2, so they should become packed. Must these clauses be freed, and then re-allocated from the packed heap? Doesn\u0026rsquo;t that add too much complexity? Also, according to my experience, packed heaps only help when the problem is small. For large problems, the cache miss rate will be very high anyway, and so packing won\u0026rsquo;t make much of a difference.\nThere are some other optimisations that I missed out on, I think. I will one day look through my very messy git tree (with 41 branches and approx. 1600 commits) to see which ones did I once implement and never got working :)\nPS: After the start of the SAT Race 2010, I will put all of the git tree up into gitorious. Then, everyone can use it and try to merge these trees into the main tree, and see what happens.\n","permalink":"https://www.msoos.org/2010/04/optimisations/","summary":"\u003cp\u003eThere are plenty of optimisations that I have tried with CryptoMiniSat. I will try to list a few that I finally didn\u0026rsquo;t consider using, but could be implemented later to get around 4-8% speedup each.\u003c/p\u003e\n\u003cp\u003eIt seems a good idea to use a separate \u003ca href=\"http://http://en.wikipedia.org/wiki/Conjunctive_normal_form\"\u003eCNF\u003c/a\u003e simplifier such as \u003ca href=\"http://http://minisat.se/SatELite.html\"\u003eSatELite\u003c/a\u003e before executing the SAT solver. The reasoning is, that even though one can import (or copy-paste) the code from SatELite, the memory will stay fragmented: \u003ca href=\"http://minisat.se/downloads/SatELite_slides.pdf\"\u003evariable elimination\u003c/a\u003e might remove half the variables, and so the arrays that store variable values will have unused bytes in them, using a larger footprint than necessary, thus causing cache misses. Though this is true, SatELite is not exactly perfect. For instance, it can be seen in certain instances of the SAT Competition of 2009 that \u003ca href=\"http://www.lri.fr/%7Esimon/glucose/\"\u003eGLUCOSE\u003c/a\u003e sometimes had very bad performance in comparison with other solvers exactly because SatELite took, e.g. \u003ca href=\"http://www.cril.univ-artois.fr/SAT09/results/trace.php?idev=29\u0026amp;idjob=1774624\"\u003e130 seconds\u003c/a\u003e, but the solving only took 2 seconds. So SatELite slowed down the solving of this instance. Also, SatELite has some limitations, e.g. it cannot handle more than 4'800'000 clauses otherwise it might take just too much time. These are huge drawbacks, and in fact CryptoMiniSat (and, e.g. \u003ca href=\"http://fmv.jku.at/precosat/\"\u003ePrecoSat\u003c/a\u003e) overcomes all of these. The memory fragmentation issue remains, though. It could be treated, but that would require about 2-3 weeks of time to get corrected, and I simply don\u0026rsquo;t have that much time. P.S.: Easy solution: rename the variables everywhere. Hard (but less error-prone) solution: use different datastructure for variable values.\u003c/p\u003e","title":"Optimisations"},{"content":"I used to use Perl a lot in the old days. Martin Albrecht, through the sage mathematics software, showed me Python. I first really hated Python. But then, I realised I can simply type away in it, as in C++, but without all the hassle of C++. I saw a little of AWK once, and I got madly in love with it \u0026ndash; when it comes to simple scripts like counting numbers printed by programs, AWK is unbeatable. I use grep a lot, and recently I realised how great a combination grep and wc (a very dumb utility that counts lines/words) are. For instance, I can simply do: \u0026ldquo;grep \u0026ldquo;s SAT\u0026rdquo; *.output | wc -l\u0026rdquo; to find how many problems have been solved by CryptoMiniSat. I am also finding myself using grep and AWK together to create shell scripts that I run later. For example, I can do: \u0026ldquo;ls *.cnf | awk \u0026lsquo;{print \u0026ldquo;./cryptominisat \u0026quot; $1 \u0026quot; \u0026gt; \u0026quot; $1.output\u0026rdquo; }\u0026rsquo; \u0026gt; script.sh\u0026rdquo; which, when executed, solves all CNF files in the directory, and generates a *.cnf.output file for each, containing the output of CryptoMiniSat. An interesting utility in UNIX is ulimit, with which can limit the memory and time (and stack, etc.) usage of a process. Putting a \u0026ldquo;ulimit -t 10000\u0026rdquo; at the beginning of our \u0026ldquo;script.sh\u0026rdquo; we can simply limit CryptoMiniSat to 10000 seconds for each instance.\nAs for failures in terms of the tools I use, I can probably list a few. I tried very hard to learn Haskell, a purely functional language, but I simply couldn\u0026rsquo;t fully wrap my head around it. Haskell bothered me, because it seems so intuitive, yet it is so hard to master. I haven\u0026rsquo;t yet got around learning sage, either, even though I think Martin Albrecht is doing a great service to the community by coordinating it. I hope one day CryptoMiniSat will be used inside it, though :)\nMy connection with the boost library is a love-hate relationship. I think boost is just amazing: it lets me program with the least amount of effort, creating a program that is less error-prone, more robust and multi-platform. However, at the same time, many programmers avoid it like the plague, for multiple reasons. Firstly, the library changes so often that something you wrote just two months ago might not compile with the new boost. Secondly, it\u0026rsquo;s a nuisance to have dependencies in the code. Thirdly, compilation times can increase significantly e.g. with the Spirit parser. I don\u0026rsquo;t agree with the second argument, since boost as a dependency isn\u0026rsquo;t significant and it saves on a lot of debugging time, and the third argument is becoming moot due to gcc 4.5. But the first argument has, actually, hit me too, and it is very unpleasant.\n","permalink":"https://www.msoos.org/2010/04/tools-that-i-use-often/","summary":"\u003cp\u003eI used to use \u003ca href=\"http://en.wikipedia.org/wiki/Perl\"\u003ePerl\u003c/a\u003e a lot in the old days. Martin Albrecht, through the \u003ca href=\"http://www.sagemath.org/\"\u003esage\u003c/a\u003e mathematics software, showed me Python. I first really hated Python. But then, I realised I can simply type away in it, as in C++, but without all the hassle of C++. I saw a little of \u003ca href=\"http://en.wikipedia.org/wiki/AWK\"\u003eAWK\u003c/a\u003e once, and I got madly in love with it \u0026ndash; when it comes to simple scripts like counting numbers printed by programs, AWK is unbeatable. I use \u003ca href=\"http://http//en.wikipedia.org/wiki/Grep\"\u003egrep\u003c/a\u003e a lot, and recently I realised how great a combination grep and \u003ca href=\"http://en.wikipedia.org/wiki/Wc_%28Unix%29\"\u003ewc\u003c/a\u003e (a very dumb utility that counts lines/words) are. For instance, I can simply do: \u0026ldquo;grep \u0026ldquo;s SAT\u0026rdquo; *.output | wc -l\u0026rdquo; to find how many problems have been solved by CryptoMiniSat. I am also finding myself using grep and AWK together to create shell scripts that I run later. For example, I can do: \u0026ldquo;ls *.cnf | awk \u0026lsquo;{print \u0026ldquo;./cryptominisat \u0026quot; $1 \u0026quot; \u0026gt; \u0026quot; $1.output\u0026rdquo; }\u0026rsquo; \u0026gt; script.sh\u0026rdquo; which, when executed, solves all CNF files in the directory, and generates a *.cnf.output file for each, containing the output of CryptoMiniSat. An interesting utility in UNIX is \u003ca href=\"http://ss64.com/bash/ulimit.html\"\u003eulimit\u003c/a\u003e, with which can limit the memory and time (and stack, etc.) usage of a process. Putting a \u0026ldquo;ulimit -t 10000\u0026rdquo; at the beginning of our \u0026ldquo;script.sh\u0026rdquo; we can simply limit CryptoMiniSat to 10000 seconds for each instance.\u003c/p\u003e","title":"Tools that I often use"},{"content":"216. I am quite proud of this number. It\u0026rsquo;s the number of instances CryptoMiniSat2 can solve from the 292 problem instances of the SAT Race'09, given roughly the same amount of time and computing resources as the solvers of 2009. Last year\u0026rsquo;s winner could solve only 204. Total solving time of CryptoMiniSat for the 216 instances was 217'814 sec, in comparison to 180'345 sec (for 12 less instances) of last year\u0026rsquo;s winner . The distribution of SAT and UNSAT for CryptoMiniSat is 85 SAT and 131 UNSAT instances solved. With this performance, it would have won all three tracks of the competition (SAT, UNSAT and SAT+UNSAT) last year.\nOf course, this performance doesn\u0026rsquo;t mean much in terms of the 2010 SAT Race. I would like to have CryptoMiniSat be in the top three, but who knows what other solvers are capable of. Also, I only tested on these 292 instances \u0026ndash; there could be some grave bugs and regressions on other types of instances. I will try to test on a larger number of instances, just to see if there are some grave regressions, but I am not very good at finding bugs. However, the STP team has been great at finding bugs: they have found 3 major ones until now. Unfortunately, I am convinced there are many more.\nWhat bugs me the most about CryptoMiniSat is that I am totally incapable of doing AIG (And-Inverter Graphs). It seems great, and some good researchers of SAT (e.g. Armin Biere, Niklas Een) are proficient in it \u0026ndash; but to me it\u0026rsquo;s completely impenetrable. I wanted to buy a book from Amazon on Electronic Design Automation, and I wanted to read through all what Biere wrote on this topic, but I need someone to guide me. However, I simply don\u0026rsquo;t know anyone in person who knows AIG. My ignorance of AIG is a real shame, and I just feel like being stupid. I really do.\n","permalink":"https://www.msoos.org/2010/04/216/","summary":"\u003cp\u003e216. I am quite proud of this number. It\u0026rsquo;s the number of instances CryptoMiniSat2 can solve from the 292 problem instances of the \u003ca href=\"http://www.cril.univ-artois.fr/SAT09/results/ranking.php?idev=29\"\u003eSAT Race'09\u003c/a\u003e, given roughly the same amount of time and computing resources as the solvers of 2009. Last year\u0026rsquo;s \u003ca href=\"http://fmv.jku.at/precosat/\"\u003ewinner\u003c/a\u003e could solve only 204. Total solving time of CryptoMiniSat for the 216 instances was 217'814 sec, in comparison to 180'345 sec (for 12 less instances) of last year\u0026rsquo;s winner \u003cem\u003e.\u003c/em\u003e The distribution of SAT and UNSAT for CryptoMiniSat is 85 SAT and 131 UNSAT instances solved. With this performance, it would have won all three tracks of the competition (SAT, UNSAT and SAT+UNSAT) last year.\u003c/p\u003e","title":"216"},{"content":"I just read this paper on cybersecurity by Daniel E. Geer, and I was very impressed. Unfortunately I haven\u0026rsquo;t heard from the author yet, but I regularly used to read the blog of Bruce Schneier, and this essay basically puts the same ideas into perspective.\nI have found the essay to be very interesting, and very thought-provoking. It shows very well that security in the cyber (or cyber-connected) world is very difficult to attain. There are no simple solutions. I personally think that security in the real world (not only the cyber world) is also very difficult to obtain, and unfortunately politicians tend to go the easy way, and simply bend in front of the will of the people by implementing \u0026ldquo;security measures\u0026rdquo; that in the end don\u0026rsquo;t help much (if at all) in terms of security, but reassure the people. An example of this is the ban of liquids on airplanes, while cockpits in Europe are still not reinforced \u0026ndash; the former doesn\u0026rsquo;t achieve much but is very visible (and so is more of a security theater), while the latter would be much less visible, but also much more effective. Also to note, that the former takes a lot of man-power to implement, and inconveniences the users (thus taking their time, too), while the latter would be relatively cheap.\nThe mentality that leads us to believe that bombing is more of a threat is that most people expect planes to be blown up, while hijacking is most only an afterthought. This serious mistake is probably a psychological effect, as most people tend to remember visually colourful incidents more, and Hollywood has made use of the \u0026ldquo;blow-up\u0026rdquo; effect too much, etching it into the brains of most people, even decision-makers. However, it is important to remember, that most serious problems in airports and airplanes were carried out through the use of arms other than bombs: to take a trivial example, no planes used in 9/11 were bombed. As a side-note, reinforced cockpits would have prevented all of 9/11, and European cockpits are still not reinforced, but my toothpaste is always taken away \u0026ndash; a serious defect, I say.\n","permalink":"https://www.msoos.org/2010/04/a-great-essay-on-security-in-the-cyberworld/","summary":"\u003cp\u003eI just read \u003ca href=\"http://www.harvardnsj.com/wp-content/uploads/2010/04/Volume-1_Geer_Final1.pdf\"\u003ethis\u003c/a\u003e paper on cybersecurity by Daniel E. Geer, and I was very impressed. Unfortunately I haven\u0026rsquo;t heard from the author yet, but I regularly used to read the \u003ca href=\"http://www.schneier.com/blog\"\u003eblog\u003c/a\u003e of Bruce Schneier, and this essay basically puts the same ideas into perspective.\u003c/p\u003e\n\u003cp\u003eI have found the essay to be very interesting, and very thought-provoking. It shows very well that security in the cyber (or cyber-connected) world is very difficult to attain. There are no simple solutions. I personally think that security in the real world (not only the cyber world) is also very difficult to obtain, and unfortunately politicians tend to go the easy way, and simply bend in front of the will of the people by implementing \u0026ldquo;security measures\u0026rdquo; that in the end don\u0026rsquo;t help much (if at all) in terms of security, but reassure the people. An example of this is the ban of liquids on airplanes, while cockpits in Europe are still not reinforced \u0026ndash; the former doesn\u0026rsquo;t achieve much but is very visible (and so is more of a \u003ca href=\"http://en.wikipedia.org/wiki/Security_theater\"\u003esecurity theater\u003c/a\u003e), while the latter would be much less visible, but also much more effective. Also to note, that the former takes a lot of man-power to implement, and inconveniences the users (thus taking their time, too), while the latter would be relatively cheap.\u003c/p\u003e","title":"A great essay on security in the cyberworld"},{"content":"The dates of the SAT Race 2010 have been announced! The deadline is the end of April, so I have to get CryptoMiniSat bug-free by then.\nI have decided to merge the code into STP, the Simple Theorem Prover made by some MIT researchers, among them Vijay Ganesh, with whom I have have worked quite a lot during the final months of 2009. Hopefully, with the help of the STP team, CryptoMiniSat will be bug-free by the end of this month, and through testing in STP, fine-tuning of options will be carried out. There are 16 new modules in the solver, and all have heuristic cut-offs, which have to be tuned. Naturally, I tried to use sensible defaults, but problems can vary widely, and different problems need different cut-offs. For instance, if the number of clauses is very low, even O(m^2) algorithms can be executed, while if the number of clauses is extremely large, e.g. 100'000, it might take too much time even to execute O(m*log(m)) algorithms.\nIf you are interested in the new CryptoMiniSat, all you need to do is to observe the developments in STP. I will also make the unstable executables accessible from this blog, through links, whenever I have a new version. Fingers crossed for a correct and fast CryptoMiniSat!\n","permalink":"https://www.msoos.org/2010/04/the-dates-of-the-sat-race-2010-have-been-announced/","summary":"\u003cp\u003eThe dates of the SAT Race 2010 have been \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/\"\u003eannounced\u003c/a\u003e! The deadline is the end of April, so I have to get CryptoMiniSat bug-free by then.\u003c/p\u003e\n\u003cp\u003eI have decided to merge the code into STP, the \u003ca href=\"http://sourceforge.net/projects/stp-fast-prover/\"\u003eSimple Theorem Prover\u003c/a\u003e made by some MIT researchers, among them \u003ca href=\"http://people.csail.mit.edu/vganesh/\"\u003eVijay Ganesh\u003c/a\u003e, with whom I have have worked quite a lot during the final months of 2009. Hopefully, with the help of the STP team, CryptoMiniSat will be bug-free by the end of this month, and through testing in STP, fine-tuning of options will be carried out. There are 16 new modules in the solver, and all have heuristic cut-offs, which have to be tuned. Naturally, I tried to use sensible defaults, but problems can vary widely, and different problems need different cut-offs. For instance, if the number of clauses is very low, even O(m^2) algorithms can be executed, while if the number of clauses is extremely large, e.g. 100'000, it might take too much time even to execute O(m*log(m)) algorithms.\u003c/p\u003e","title":"The dates of the SAT Race 2010 have been announced!"},{"content":"I am not sure I am qualified to talk about research in general, but I will try to do my best.\nTo me, it seems that the research community of any given topic is pretty small. The reason for this is many-fold. Firstly, I suspect that the number of qualified individuals willing to work for a relatively small pay (but with many benefits, like flexible schedule, less stress, etc.) is relatively small. Secondly, any given topic usually reaches a maturity level where the subdomains are very clear, and it is very difficult to say anything reasonably good about a subdomain that one is not acquainted with. For instance, Knuth\u0026rsquo;s books are brilliant, but even he (someone who is like a semi-god in computer science) acknowledges that he simply cannot be an authority on all the topics covered in the 4th volume of his series. (BTW I just bought Vol4F0 and Vol4F1, wainting for amazon to ship now).\nSince the research community is small, everyone gets to know one another. This is great since it helps collaboration, but it also might backlash against newcomers (PhD students), and against people generally not well-acquainted with the field, but who genuinely have good ideas that they wish to publish. I guess it\u0026rsquo;s a difficult integration process, that gets all the more difficult because it rarely happens that someone can simply stay in the same specific subfield for his entire research career. And even if someone stays in the same field, the field may change so much over time, attracting researchers from many distinct research domains, that even an \u0026ldquo;oldboy\u0026rdquo; can feel detached from his/her own topic after a while.\nResearch that deals with practical things is even more fast-moving than other kinds of research. Just a couple of years ago, research on botnets didn\u0026rsquo;t exist, yet now it seems it is a very rapidly evolving research domain. SAT solvers - I believe - also fall into the category of practical research. Year after year the solvers evolve so much that trying to compare two solvers with only 1-2 years of difference in their release dates seems nonsensical. This is great because there is a lot of \u0026ldquo;buzz\u0026rdquo; going on, but at the same time, it feels like a race against time: inspiring at first, but tiring at the end.\nVery theoretical domains rarely have this speed of change. For instance, last year at the SAT'09 conference, I saw Stephen Cook, the person who basically invented the notion of NP completeness (I felt honoured just to be in the same room with him, I must say). Although SAT has changed a lot in the past years (many new applications, e.g. cryptography), but the fundamental problem didn\u0026rsquo;t change - therefore, he never had the ground taken from under him. The ground sure moved, but he still masters it, I am sure.\nOh well, legends. I met Shamir twice. Very kind person. Also, I met Daniel J. Bernstein at EUROCRYPT'09. He looked somewhat shorter and younger than I imagined, and I liked his openness. I met Lenstra at CCC'08. I was so shocked it was him, I couldn\u0026rsquo;t even say hello - very embarrassing. He was very friendly, and seemed much younger than his official age would suggest. I really want to meet Knuth, but I guess that might have to wait\u0026hellip; forever, maybe. Unless I somehow manage to visit Stanford one day, in which case I will definitely show up at one of his classes. They say he is a terrific speaker.\n","permalink":"https://www.msoos.org/2010/04/on-research-in-general/","summary":"\u003cp\u003eI am not sure I am qualified to talk about research in general, but I will try to do my best.\u003c/p\u003e\n\u003cp\u003eTo me, it seems that the research community of any given topic is pretty small. The reason for this is many-fold. Firstly, I suspect that the number of qualified individuals willing to work for a relatively small pay (but with many benefits, like flexible schedule, less stress, etc.) is relatively small. Secondly, any given topic usually reaches a maturity level where the subdomains are very clear, and it is very difficult to say anything reasonably good about a subdomain that one is not acquainted with. For instance, Knuth\u0026rsquo;s books are brilliant, but even he (someone who is like a semi-god in computer science) acknowledges that he simply cannot be an authority on all the topics covered in the 4th volume of his series. (BTW I just bought Vol4F0 and Vol4F1, wainting for amazon to ship now).\u003c/p\u003e","title":"On research in general"},{"content":"Some people, who may not have thought through the problem of implementing Gaussian elimination into SAT solvers, seem to think that it\u0026rsquo;s just a matter of pulling a matlab function into a solver, and the job is done. Let met explain why I think this is not the case.\nFirstly, we don\u0026rsquo;t wish to execute Gaussian elimination simply before the solving, instead, we wish to execute it during the solving. This means the matrix\u0026rsquo;s columns need to be changed often, since as we move down the search tree, some variables will be fixed, thus the columns need to be cleared, and the augmented column needs to be updated. But how would a matlab function know which column was changed? These functions are made to work on any given matrix, churn through it, and finish with a result. However, in many cases, the change (=delta) between two matrixes is minimal (i.e. 3rd column from right was changed). In this case, the matlab routine will nevertheless start updating the matrix from the leftmost column, essentially taking far more time than an algorithm that knows that the delta was small.\nSecondly, let\u0026rsquo;s assume that a value like \u0026ldquo;x1=true\u0026rdquo; has been found by the matlab function. Since we don\u0026rsquo;t know where this information came from, there is only one way of adding it: put it into the propagation queue. This, however, would be a grave mistake. By not giving the solver a hint where this propagation came from, the solver cannot use this information during conflict generation, and we will loose most of the benefits. In case a conflict is found by our matlab function, the problem is even worse. What caused the conflict? We simply don\u0026rsquo;t know. We can send the solver back one decision level, and hope for the best, but non-historical backjumping is one of the main reason SAT solvers perform so well. On the other hand, if we keep another matrix, not assigned with the current assignements but updated with all row-xor and row-swap operations (as in CryptoMiniSat2), then we will have all these informations at our disposal, and the integration of Gaussian elimination into the SAT solving process will be correct.\nThese two reasons should be sufficient to see that matlab, or really any mathematical package that implements Gaussian elimination is not useful for CryptoMiniSat. Yes, some of their \u0026ldquo;tricks\u0026rdquo; could be used, and I think are already being used.\nPS: As a side-note, many have told me that the matrixes are sparse, and so I should use a sparse matrix data structure. Although the matrixes are indeed sparse, they are also miniscule. On very small matrixes (\u0026lt;200-300 columns) there is simply no point in doing sparse matrix elimination. Not to mention, that since two different matrixes need to be stored and handled, it is impossible to find a pivot that is optimal for both, thus the density of at least one of the matrixes must evolve faster than optimal, leading to an early switch to a dense matrix representation.\n","permalink":"https://www.msoos.org/2010/03/why-cryptominisat-cant-use-matlab-to-do-gaussian-elimination/","summary":"\u003cp\u003eSome people, who may not have thought through the problem of implementing Gaussian elimination into SAT solvers, seem to think that it\u0026rsquo;s just a matter of pulling a matlab function into a solver, and the job is done. Let met explain why I think this is not the case.\u003c/p\u003e\n\u003cp\u003eFirstly, we don\u0026rsquo;t wish to execute Gaussian elimination simply before the solving, instead, we wish to execute it during the solving. This means the matrix\u0026rsquo;s columns need to be changed often, since as we move down the search tree, some variables will be fixed, thus the columns need to be cleared, and the augmented column needs to be updated. But how would a matlab function know which column was changed? These functions are made to work on any given matrix, churn through it, and finish with a result. However, in many cases, the change (=delta) between two matrixes is minimal (i.e. 3rd column from right was changed). In this case, the matlab routine will nevertheless start updating the matrix from the leftmost column, essentially taking far more time than an algorithm that knows that the delta was small.\u003c/p\u003e","title":"Why CryptoMiniSat can’t use MATLAB to do Gaussian elimination"},{"content":"I recently got a question that intrigued me:\nI am new to this SAT solving world but I was wondering whether you thought considerable speedups were possible for crypto type problems (multivariate polys over GF(2)) by simply never converting the problem to cnf at all and thereby avoiding the combinatorial explosion that results in the conversion process. That is using the original xor formulation.\nFirst of all, the question is a follow-up to xor-clauses: they implement XOR-s natively. Using them avoids a number of problems relating to the increase of variables. Why not implement monomials (i.e. \u0026ldquo;a*b\u0026rdquo; or \u0026ldquo;a*b*c\u0026rdquo;, where \u0026ldquo;*\u0026rdquo; is binary AND and variables are binary) natively? They are the only thing left to do. Personally, I am not overly optimistic about them, though. Let me got through some of my reasons here.\nFirstly, the \u0026ldquo;exponential explosion\u0026rdquo; expressed in the question is in fact much less existent than people tend to think. The reason is that the intelligent variable activity heuristics, unit propagation, and conflict generation tend to take care of a lot of potential problems. Since the propagation of a variable will entail the propagation of many others (it depends, for crypto, around ~100), there is no real explosion, since there is not really 2^n, but more like 2^(n/100) combinations that need to be explored. This argumentation takes away some of the potential benefits that native monomials could bring.\nThe real problem, though, is the following. By moving monomials into cryptominisat and thus potentially speeding up the solving, conflict generation could become much more complex. So, if moving to an internal monomial representation entails making a mess of conflict generation, then using monomials internally may only make the solving slower.\nAnother reason that native monomials may not speed up solving so much, is that a lot of clauses inserted when converting monomials are binary clauses, which are extremely well dealt with in the CNF world \u0026ndash; it would be hard to do it any better.\nAs a last, but very minor point, using monomials would increase the complexity of the program, which would mean not only a lot of man-hours lost debugging it, but also a loss of performance due to a (probably non-negligible) increase of instruction cache misses.\nOh well, so those are my reasons. I would be interested if someone has some comments on these, though.\n","permalink":"https://www.msoos.org/2010/03/could-monomials-be-handled-natively-from-sat-solvers/","summary":"\u003cp\u003eI recently got a question that intrigued me:\u003c/p\u003e\n\u003cp\u003eI am new to this SAT solving world but I was wondering whether you thought considerable speedups were possible for crypto type problems (multivariate polys over GF(2)) by simply never converting the problem to cnf at all and thereby avoiding the combinatorial explosion that results in the conversion process. That is using the original xor formulation.\u003c/p\u003e\n\u003cp\u003eFirst of all, the question is a follow-up to xor-clauses: they implement XOR-s natively. Using them avoids a number of problems relating to the increase of variables. Why not implement monomials (i.e. \u0026ldquo;a*b\u0026rdquo; or \u0026ldquo;a*b*c\u0026rdquo;, where \u0026ldquo;*\u0026rdquo; is binary AND and variables are binary) natively? They are the only thing left to do. Personally, I am not overly optimistic about them, though. Let me got through some of my reasons here.\u003c/p\u003e","title":"Could monomials be handled natively from SAT solvers?"},{"content":"Lately, I have been working a lot with CryptoMiniSat, to get it up and running for the 2010 SAT Race, held by Carsten Sinz. Getting CryptoMiniSat fast and bug-free has been a long and winding road. I can now understand the difficulty of choosing magic parameters that these SAT solvers make use of regularly. As I have added ~6000 lines of code to a codebase of ~1500, you can probably imagine the number of magic constants that I had to come up with. Worst of all, these constants interact in non-intuitive and sometimes in a fully \u0026ldquo;magical\u0026rdquo; manner.\nTo test my choice of magic constants, I have been running experiments on the Gird5000 project of French universities. It is quite easy to get access to Grid5000 if you work in a French university, and it is surprisingly easy to run experiments. On the other hand, interpreting the results of such experiments is not so easy :) However, CryptoMiniSat is coming along. On crypto examples I think we are unbeatable. When it comes to other examples, we are good, but we will see how the new MiniSat (yes, it\u0026rsquo;s coming!) and precosat will do. Apparently, the GLUCOSE people are also planning to enter the competition, so the race will be very interesting. Fingers are crossed that CryptoMiniSat will finish somewhere in the top 3 :)\nThere are some \u0026ldquo;secret\u0026rdquo; improvements that I have made the past couple of months, and there are some open secrets. I tried to incorporate the GLUCOSE restart heuristic, and XORs are automatically detected (XOR clauses are no longer neccessary, but they are of course supported!). This means that CryptoMiniSat is now a plug-and-play experience for all the crypto-folks. I have tested the solver with a good number of crypto problems, and the speedup relative to MiniSat is on the order of 2-50x, depending on the problem.\nThe new CryptoMiniSat will be released when the SAT Race starts and everyone\u0026rsquo;s executables have been freezed. I will then detail all the new features. Until then, let me just run a couple of more experiments on that cluster :)\n","permalink":"https://www.msoos.org/2010/03/cryptominisat-v2/","summary":"\u003cp\u003eLately, I have been working a lot with CryptoMiniSat, to get it up and running for the \u003ca href=\"http://baldur.iti.uka.de/sat-race-2010/\"\u003e2010 SAT Race\u003c/a\u003e, held by Carsten Sinz. Getting CryptoMiniSat fast and bug-free has been a long and winding road. I can now understand the difficulty of choosing magic parameters that these SAT solvers make use of regularly. As I have added ~6000 lines of code to a codebase of ~1500, you can probably imagine the number of magic constants that I had to come up with. Worst of all, these constants interact in non-intuitive and sometimes in a fully \u0026ldquo;magical\u0026rdquo; manner.\u003c/p\u003e","title":"CryptoMiniSat v2"},{"content":"I used to be quite an expert on Windows, I even used to hang out on the #windows-help IRC channel. So why do I use Linux uniquely nowadays?\nFirst, I tried Linux out of curiosity. What made me interested initially is that I am a control freak: I like to know what happens with my computer. With windows there were always a billion things running in the background, and I had no clue what they were doing. With linux you always know what does what. \u0026ldquo;man programname\u0026rdquo; and you have a complete documentation. This was a real kick for me. I could read these manuals for days, literally. I hate when things \u0026ldquo;just work\u0026rdquo; - I want to know *why?*. Simple curiosity. However, this doesn\u0026rsquo;t explain why I have stuck with Linux for such a long time.\nThe reasons I have stuck with GNU/Linux are the following:\nNo adware/spyware/viruses since all programs in all Linux distributions are installed from signed packages\nHuge amount of available documentation and a howto for everything. Got stuck? Just read up\nNo vendor lock-in. Wanna change from KDE to GNOME? From KOffice to OpenOffice? No problem.\nFaster than Windows and accompanying proprietary software (Office, MSN messenger, Adobe PDF reader, etc.)\nMore customisable than Windows. Proprietary applications mean that if you change your colorscheme in Windows, almost none of your applications will have that colorscheme. If you do something different than most people (e.g. keycombinations), in Linux, you can easily change the program to suit your needs.\nInstalling applications is fast and easy: Tired of answering the 20 questions that all installers ask you in Windows? So am I. In Linux, just launch Synaptics, type in what you want to do, e.g. \u0026ldquo;instant messaging\u0026rdquo;, and you are presented with all applications offering that service. Double-click on any and you are done (this is not a joke, it\u0026rsquo;s really that simple) It\u0026rsquo;s safe, fast, and there are no questions asked.\nUninstalling is fast and efficient. Uninstalling AOL messenger is not only terribly difficult, but also leaves a lot of stuff behind. AOL browser? AOL as default webpage? And this not only applies to AOL. Windows messenger will change your default webpage when installed. Uninstalling it doesn\u0026rsquo;t reverse that.\nNo junk software. Are you, too, tired of all the popups that \u0026ldquo;The full version of this software offers this-and-that, buy it now!\u0026rdquo; ?\nSoftware upgrades are seamless. One interface for all upgrades. You don\u0026rsquo;t need 20 upgrade programs running non-stop (Java nags you non-stop? Adobe PDF Reader naggings? Windows upgrade naggings?)\nDoes all that is possible, not all that vendors want to be possible. Print to PDF? No problem. Backup your DVD? No problem.\nCheap, or even free. Tired of all the money you have to pay, and still it doesn\u0026rsquo;t work? Well, in Linux it might not work, either, but if you payed a little bit, you can call the service desk (and they are helpful), or you can ask you local linux geek (he will be all too helpful), or you can just read up on the documentation (it\u0026rsquo;s good and well-written)\nIf you have found a problem in the program, there are always helpful developers to correct the problem. They listen to what you have to say, and personally thank you for your comments. Try to do that with any proprietary software: they will send you a pre-written \u0026ldquo;thank you\u0026rdquo; notice, and promptly ignore you.\nOf course there are many other, less practical and more theoretical reasons for why I like linux: Free as in not locked-in, total control, possiblity of tweaking things, the availability of developer discussions through open mailinglists, the number of programs to do the same thing (i.e. choice), and many others.\nTo use Linux day-to-day takes a bit of courage. Your friends will be annoyed that they can\u0026rsquo;t use the ultra-cool (but ultra-useless) features of their newest MSN messenger when they talk to you. And there will be other problems. You might be forced to use Windows at work, or you might need to use a software that doesn\u0026rsquo;t run under the free windows emulator, wine (though most software does), and you will have to find a replacement. And you won\u0026rsquo;t be able to play the newest game out there (but you can play World of Warcraft, and most other big games, like Diablo, on Linux).\nThe advantages are huge, however. You simply won\u0026rsquo;t understand how can your friends get a malware infection every day, why their bankaccounts get overtaken once a year, and why on Earth does it take their computer 5 minutes to boot up. You will sleep tight, knowing full well that your computer is safe from all people who might do you harm, be them malicious (malware writers), or be them proprietary companies restricting the use of the music or video you just bought. And you will know that if some problem comes up, there will be tons and tons of free tools and lots and lots of developers ready and willing to help you out just for the kicks. You are not alone.\n","permalink":"https://www.msoos.org/2008/11/why-do-i-use-linux/","summary":"\u003cp\u003eI used to be quite an expert on Windows, I even used to hang out on the #windows-help IRC channel. So why do I use Linux uniquely nowadays?\u003c/p\u003e\n\u003cp\u003eFirst, I tried Linux out of curiosity. What made me interested initially is that I am a control freak: I like to know what happens with my computer. With windows there were always a billion things running in the background, and I had no clue what they were doing. With linux you always know what does what. \u0026ldquo;man programname\u0026rdquo; and you have a complete documentation. This was a real kick for me. I could read these manuals for days, literally. I hate when things \u0026ldquo;just work\u0026rdquo; - I want to know *why?*. Simple curiosity. However, this doesn\u0026rsquo;t explain why I have stuck with Linux for such a long time.\u003c/p\u003e","title":"Why do I use Linux?"},{"content":"I regularly have a problem with my sound card: it simply stops working, and xine (and everything else) says that it cannot open the sound socket. So, I need to unload and reload the snd_hda_intel module. Most of the time, however, I cannot since it is in use. I try to close all possibly using sound, but most of the time it is a dead process that is using it. But, I have figured out how to find these unruly processes:\nfuser -a /dev/snd/pcmxxxx (where try all here, xxxx can be anything) for each process ID (PID) listed, do a, do \u0026ldquo;ps xa | grep PID\u0026rdquo;, so see what the process is. Close it cleanly, if possible (through the gui), or \u0026ldquo;kill\u0026rdquo; it if it is a hanged process. Most of the time, it is a program in a messed-up state - in my case it is sometimes a \u0026ldquo;kio-exec\u0026rdquo; process. Killing is simply \u0026ldquo;kill PID\u0026rdquo; or, more harshly, \u0026ldquo;kill -9 PID\u0026rdquo;. Now issue \u0026ldquo;rmmod snd_hda_intel\u0026rdquo; and then \u0026ldquo;modprobe snd_hda_intel\u0026rdquo;. Done! :)\n","permalink":"https://www.msoos.org/2008/10/how-to-unload-the-sound-module/","summary":"\u003cp\u003eI regularly have a problem with my sound card: it simply stops working, and xine (and everything else) says that it cannot open the sound socket. So, I need to unload and reload the snd_hda_intel module. Most of the time, however, I cannot since it is in use. I try to close all possibly using sound, but most of the time it is a dead process that is using it. But, I have figured out how to find these unruly processes:\u003c/p\u003e","title":"How to unload the sound module"},{"content":"I have been having a hard time getting the composite effects running smoothly on KDE4 with my intel Mobile 945GM graphics card. But I have finally managed to get it up and running! This is how:\nGet the latest intel driver from your repository (I have 2.3.2)\nPut into xorg.conf at the driver section:\nSection \u0026#34;Device\u0026#34; Identifier \u0026#34;Configured Video Device\u0026#34; Driver \u0026#34;intel\u0026#34; Option \u0026#34;DRI\u0026#34; \u0026#34;true\u0026#34; EndSection Put at the end of your xorg.conf:\nSection \u0026#34;DRI\u0026#34; Mode 0666 EndSection Section \u0026#34;Extensions\u0026#34; Option \u0026#34;Composite\u0026#34; \u0026#34;Enable\u0026#34; Option \u0026#34;DAMAGE\u0026#34; \u0026#34;Enable\u0026#34; Option \u0026#34;RENDER\u0026#34; \u0026#34;Enable\u0026#34; Option \u0026#34;RandR\u0026#34; \u0026#34;on\u0026#34; EndSection Under the system settings, enable desktop effects and set in the advanced settings to use XRender! (and take out the update thumbnails and the smooth scaling).\nRestart X: restart the computer or just do: logout then push \u0026ldquo;ctrl+alt+backspace\u0026rdquo;, log in to the console as root, and restart kdm by issuing: \u0026ldquo;/etc/init.d/kdm restart\u0026rdquo;.\nI have by the way, a Dell D430, so an extremely lightweight, small computer that probably has the worst performance among its peers, and the effects are *fast* I must say that the \u0026ldquo;coverflow\u0026rdquo; effect (not enabled by default) isn\u0026rsquo;t that great, something is wrong with it, but still: scrolling is super-fast, switching windows is super-fast, so you won\u0026rsquo;t notice any slowdown at all!\n","permalink":"https://www.msoos.org/2008/09/kde4-composite-with-intel-drivers/","summary":"\u003cp\u003eI have been having a hard time getting the composite effects running smoothly on KDE4 with my intel Mobile 945GM graphics card. But I have finally managed to get it up and running! This is how:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003e\n\u003cp\u003eGet the latest intel driver from your repository (I have 2.3.2)\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003ePut into xorg.conf at the driver section:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eSection \u0026#34;Device\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eIdentifier      \u0026#34;Configured Video Device\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eDriver \u0026#34;intel\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eOption \u0026#34;DRI\u0026#34; \u0026#34;true\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eEndSection\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003ePut at the end of your xorg.conf:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eSection \u0026#34;DRI\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eMode 0666\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eEndSection\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eSection \u0026#34;Extensions\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eOption \u0026#34;Composite\u0026#34; \u0026#34;Enable\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eOption \u0026#34;DAMAGE\u0026#34; \u0026#34;Enable\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eOption \u0026#34;RENDER\u0026#34; \u0026#34;Enable\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eOption \u0026#34;RandR\u0026#34; \u0026#34;on\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eEndSection\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eUnder the system settings, enable desktop effects and set in the advanced settings to use XRender! (and take out the update thumbnails and the smooth scaling).\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eRestart X: restart the computer or just do: logout then push \u0026ldquo;ctrl+alt+backspace\u0026rdquo;, log in to the console as root, and restart kdm by issuing: \u0026ldquo;/etc/init.d/kdm restart\u0026rdquo;.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e","title":"KDE4 composite with intel drivers"},{"content":"I have been having problems suspending my Dell Latitude D420 for a long time, but finally, I have made it work! This is the simple howto:\ninstall guidance power manager install pm-utils install uswsusp Go to /usr/lib/pm-utils/ and edit the file \u0026ldquo;defaults\u0026rdquo;. Set \u0026lsquo;SLEEP_MODULE=\u0026ldquo;uswsusp\u0026rdquo;\u0026quot; Start the guidance power manager You are done. This solution is *very* neat in many respects. The old solution that is much worse, you can find on the internet is to compile atkbd and psmouse as modules, then remove and modprobe them before suspend and after resume. That can be done by adding atkbd and psmouse in /usr/lib/pm-utils/defaults under \u0026ldquo;USPEND_MODULES=\u0026hellip;\u0026rdquo;, but that has a *big* drawback. First, the resume hangs about 1% of the time. Second, the synaptics driver will no longer use the defaults you gave to it in the xorg.conf or through the synclient program - effectively, you won\u0026rsquo;t be able to control how your touchpad will work.\nThe worst thing about this suspend problem was, by the way, that there is absolutely *no* documentation on the possible suspend modes in Linux. It took me 2 months to figure out that I wasn\u0026rsquo;t in fact using s2ram! There are many modes to suspend, by the way:\npowersaved does some tricks, though it seem to fail on my computer, I think it might try s2ram without the \u0026ndash;force option (this option is given by pm-utils, in modules.d/uswsusp, have a look)\nacpi (/etc/acpi) stuff - never gets executed, as far as I know\npm-utils\ns2ram\ntuxonice\nsuspend2\nI didn\u0026rsquo;t find any info about these, how these work, when they work, etc. And it gets worse. There are multipe utilities, too: guidance, kpowersaved, just to name two. But you can most probaby configure-on-lidclose in Gnome systemsettings, too. And what do THEY execute? No clue. I wonder how the guidance-power-manager gets to use the pm-utils at all? Cannot be set what to use, as far as I now.\nWell, this much about my frustration of the suspend-stuff. BTW I would be really greatful to the package managers\u0026amp;developers; to make it absolutely clear what does what, and what gets executed by what, e.g. what is used by guidance? And kpowersaved? And powersaved? I would also appreciate if there weren\u0026rsquo;t 6 ways of suspending my machine, only 2, maybe 3. I know that choice is what drives linux forward, but in some cases, especially in such difficult hardware-oriented cases, I would really like to have a maximum of 2 or 3 clear choices. No random ones like: \u0026ldquo;I run guidace, it calls something when I close the lid, dunno what, but it works, maybe not even guidance called it but the powersaved that runs in the background, or whoknowswhat, but it works\u0026rdquo;. Or it doesn\u0026rsquo;t and then you are in deeeeep shit.\nPS: could someone please tell me what the /etc/acpi stuff is used for, and especially when is it used? I never ever \u0026lsquo;heard\u0026rsquo; it being used, but, you know, the computer doesn\u0026rsquo;t tell me what it does\u0026hellip; I thought that Linux was special because if I dug deep enough I always knew what was happening. Not with suspend!\n","permalink":"https://www.msoos.org/2008/09/suspend-on-dell-d430/","summary":"\u003cp\u003eI have been having problems suspending my Dell Latitude D420 for a long time, but finally, I have made it work! This is the simple howto:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003einstall guidance power manager\u003c/li\u003e\n\u003cli\u003einstall pm-utils\u003c/li\u003e\n\u003cli\u003einstall uswsusp\u003c/li\u003e\n\u003cli\u003eGo to /usr/lib/pm-utils/ and edit the file \u0026ldquo;defaults\u0026rdquo;. Set \u0026lsquo;SLEEP_MODULE=\u0026ldquo;uswsusp\u0026rdquo;\u0026quot;\u003c/li\u003e\n\u003cli\u003eStart the guidance power manager\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eYou are done. This solution is *very* neat in many respects. The old solution that is much worse, you can find on the internet is to compile atkbd and psmouse as modules, then remove and modprobe them before suspend and after resume. That can be done by adding atkbd and psmouse in /usr/lib/pm-utils/defaults under \u0026ldquo;USPEND_MODULES=\u0026hellip;\u0026rdquo;, but that has a *big* drawback. First, the resume hangs about 1% of the time. Second, the synaptics driver will no longer use the defaults you gave to it in the xorg.conf or through the synclient program - effectively, you won\u0026rsquo;t be able to control how your touchpad will work.\u003c/p\u003e","title":"Suspend on Dell D430"},{"content":"Well, well. I updated my xorg synaptics driver, and\u0026hellip;. the damn thing stopped working. That is, the touchpad worked, but not through the synaptics driver, so it would be really badly configured. I like my touchpad to be correctly configured. As a matter of fact, I put this file into ~/.kde4/Autostart/ :\n#!/bin/bash fetchmail synclient SingleTapTimeout=0.5 synclient MinSpeed=0.1 synclient MaxSpeed=1 synclient AccelFactor=0.3 synclient ClickTime=10 synclient EdgeMotionMinSpeed=30 synclient EdgeMotionMaxSpeed=150 synclient VertScrollDelta=24 synclient UpDownScrollRepeat=1 synclient PressureMotionMaxFactor=2 synclient HorizEdgeScroll=0 synclient VertEdgeScroll=1 synclient VertTwoFingerScroll=1 synclient HorizTwoFingerScroll=0 synclient PalmMinZ=30 killall syndaemon syndaemon -i 0.6 -d -K killall hotkeys hotkeys -t inspiron8100 As you can see, this starts my fetchmail daemon, sets up the config of the touchpad through the synclient program, and also starts \u0026ldquo;syndaemon\u0026rdquo;, which disables the touchpad while typing - VERY helpful, mind you, since when programming, I always put my finger on the touchpad by accident, and suddenly everything gets messed up. Also, it sets up the hotkeys program, which will make my volume-up and volume-down keys working (I have a Dell D420, thanks INRIA ;) )\nAnyway, I finally had a look at /var/log/Xorg.0.log and, well, synaptics didn\u0026rsquo;t find the touchpad. So, I had a look around the Internet, and apparently, others had the same issue with the new driver! So, finally, I had a look around, and I managed to cut-and-paste-and-edit the relevant section of xorg.conf to:\nSection \u0026#34;InputDevice\u0026#34; Driver \u0026#34;synaptics\u0026#34; # Option \u0026#34;Device\u0026#34; \u0026#34;/dev/input/mice\u0026#34; Option \u0026#34;Protocol\u0026#34; \u0026#34;auto-dev\u0026#34; Option \u0026#34;Emulate3Buttons\u0026#34; \u0026#34;yes\u0026#34; Option \u0026#34;SHMConfig\u0026#34; \u0026#34;on\u0026#34; Option \u0026#34;SendCoreEvents\u0026#34; \u0026#34;true\u0026#34; Option \u0026#34;TapButton1\u0026#34; \u0026#34;1\u0026#34; Option \u0026#34;TapButton2\u0026#34; \u0026#34;2\u0026#34; Identifier \u0026#34;TouchPad\u0026#34; EndSection Which finally made the thing work again through synaptics! What you have to notice here is:\nSHMConfig is NOT \u0026ldquo;true\u0026rdquo; but \u0026ldquo;on\u0026rdquo;. Important for new Xorg servers. Device is NOT given, so that Xorg can automatically find it! SendCoreEvents is set to \u0026ldquo;true\u0026rdquo; Hooraaay! :D\n","permalink":"https://www.msoos.org/2008/09/synaptics/","summary":"\u003cp\u003eWell, well. I updated my xorg synaptics driver, and\u0026hellip;. the damn thing stopped working. That is, the touchpad worked, but not through the synaptics driver, so it would be really badly configured. I like my touchpad to be correctly configured. As a matter of fact, I put this file into ~/.kde4/Autostart/ :\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#75715e\"\u003e#!/bin/bash\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003efetchmail\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient SingleTapTimeout\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e0.5\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   MinSpeed\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e0.1\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   MaxSpeed\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   AccelFactor\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e0.3\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   ClickTime\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e10\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   EdgeMotionMinSpeed\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e30\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   EdgeMotionMaxSpeed\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e150\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   VertScrollDelta\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e24\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   UpDownScrollRepeat\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   PressureMotionMaxFactor\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e2\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   HorizEdgeScroll\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   VertEdgeScroll\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   VertTwoFingerScroll\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e1\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   HorizTwoFingerScroll\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e0\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esynclient   PalmMinZ\u003cspan style=\"color:#f92672\"\u003e=\u003c/span\u003e\u003cspan style=\"color:#ae81ff\"\u003e30\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ekillall syndaemon\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003esyndaemon -i 0.6 -d -K\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ekillall hotkeys\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ehotkeys -t inspiron8100\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eAs you can see, this starts my fetchmail daemon, sets up the config of the touchpad through the synclient program, and also starts \u0026ldquo;syndaemon\u0026rdquo;, which disables the touchpad while typing - VERY helpful, mind you, since when programming, I always put my finger on the touchpad by accident, and suddenly everything gets messed up. Also, it sets up the hotkeys program, which will make my volume-up and volume-down keys working (I have a Dell D420, thanks INRIA ;) )\u003c/p\u003e","title":"Synaptics"},{"content":"ApproxMC is an approximate model counter for CNF formulas. Instead of an exact count, it gives a count that is within a chosen tolerance of the true value with a chosen confidence, which lets it handle problems of a size and complexity that were not possible before. It supports projected counting, where only the solutions over a given set of variables are counted.\nApproxMC adds random XOR constraints to the formula and solves the result with CryptoMiniSat, using its native XOR and Gauss-Jordan elimination support; the input is first simplified by Arjun. For exact or weighted counting, use Ganak instead, and for DNF formulas use Pepin. Release binaries are on GitHub, and you can try it in your browser.\nThe engineering behind the current versions is described in BIRD: Engineering an Efficient CNF-XOR SAT Solver and Its Applications to Approximate Model Counting (AAAI 2019) and Tinted, Detached, and Lazy CNF-XOR Solving and Its Applications to Counting and Sampling (CAV 2020). The blog post ApproxMCv3, a modern approximate model counter explains the main ideas.\n","permalink":"https://www.msoos.org/tools/approxmc/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/meelgroup/approxmc\"\u003eApproxMC\u003c/a\u003e is an approximate model counter for CNF formulas. Instead of an exact count, it gives a count that is within a chosen tolerance of the true value with a chosen confidence, which lets it handle problems of a size and complexity that were not possible before. It supports projected counting, where only the solutions over a given set of variables are counted.\u003c/p\u003e\n\u003cp\u003eApproxMC adds random XOR constraints to the formula and solves the result with \u003ca href=\"/tools/cryptominisat/\"\u003eCryptoMiniSat\u003c/a\u003e, using its native XOR and Gauss-Jordan elimination support; the input is first simplified by \u003ca href=\"/tools/arjun/\"\u003eArjun\u003c/a\u003e. For exact or weighted counting, use \u003ca href=\"/tools/ganak/\"\u003eGanak\u003c/a\u003e instead, and for DNF formulas use \u003ca href=\"/tools/pepin/\"\u003ePepin\u003c/a\u003e. Release binaries are on \u003ca href=\"https://github.com/meelgroup/approxmc/releases\"\u003eGitHub\u003c/a\u003e, and you can \u003ca href=\"/approxmc/\"\u003etry it in your browser\u003c/a\u003e.\u003c/p\u003e","title":"ApproxMC"},{"content":"Arjun is three tools in one: a CNF preprocessor for model counting, a Boolean functional synthesis engine, and a 2QBF solver. Its name comes from the Hindu myth of Arjuna, known as \u0026ldquo;the one who concentrates the most\u0026rdquo;. Release binaries are on GitHub, and it is available via Nix.\nAs a preprocessor, Arjun computes a small independent support of the formula and simplifies the CNF so that its count stays the same, for unweighted as well as weighted counting. It is the preprocessor of ApproxMC and should be used in front of Ganak. Part of its simplification code comes from SharpSAT-TD by Tuukka Korhonen and Matti Järvisalo. The preprocessor is described in Arjun: An Efficient Independent Support Computation Technique and its Applications to Counting and Sampling (ICCAD 2022), see also the blog post Arjun, our New CNF Model Counting Preprocessor and the talk SAT Preprocessing (Dagstuhl, 2026).\nAs a synthesis engine (--synth), Arjun computes a Skolem function for each non-input variable in terms of the input variables, using counterexample-guided repair, and writes the functions out as Verilog or as an AIG. As a 2QBF solver (--2qbf), it decides forall-exists quantified Boolean formulas given in QDIMACS: if the formula is false, it gives an assignment to the universal variables that no assignment to the existentials can extend to a model, and if it is true, it can write out the Skolem functions. For more, see the talks Arjun as a Boolean-Function Synthesis Engine (Dagstuhl, 2026) and Boolean Functional Synthesis and its possible application to Cryptography (COSIC, KU Leuven, 2025).\n","permalink":"https://www.msoos.org/tools/arjun/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/meelgroup/arjun\"\u003eArjun\u003c/a\u003e is three tools in one: a CNF preprocessor for model counting, a Boolean functional synthesis engine, and a 2QBF solver. Its name comes from the Hindu myth of \u003ca href=\"https://en.wikipedia.org/wiki/Arjuna\"\u003eArjuna\u003c/a\u003e, known as \u0026ldquo;the one who concentrates the most\u0026rdquo;. Release binaries are on \u003ca href=\"https://github.com/meelgroup/arjun/releases\"\u003eGitHub\u003c/a\u003e, and it is available via Nix.\u003c/p\u003e\n\u003cp\u003eAs a preprocessor, Arjun computes a small independent support of the formula and simplifies the CNF so that its count stays the same, for unweighted as well as weighted counting. It is the preprocessor of \u003ca href=\"/tools/approxmc/\"\u003eApproxMC\u003c/a\u003e and should be used in front of \u003ca href=\"/tools/ganak/\"\u003eGanak\u003c/a\u003e. Part of its simplification code comes from \u003ca href=\"https://github.com/Laakeri/sharpsat-td\"\u003eSharpSAT-TD\u003c/a\u003e by Tuukka Korhonen and Matti Järvisalo. The preprocessor is described in \u003ca href=\"https://doi.org/10.1145/3508352.3549406\"\u003eArjun: An Efficient Independent Support Computation Technique and its Applications to Counting and Sampling\u003c/a\u003e (ICCAD 2022), see also the blog post \u003ca href=\"/2022/08/arjun-our-new-cnf-model-counting-preprocessor/\"\u003eArjun, our New CNF Model Counting Preprocessor\u003c/a\u003e and the talk \u003ca href=\"https://github.com/msoos/presentation_arjun_preproc/blob/main/arjun_preprocessor.pdf\"\u003eSAT Preprocessing\u003c/a\u003e (Dagstuhl, 2026).\u003c/p\u003e","title":"Arjun"},{"content":"Bosphorus simplifies and solves systems of polynomial equations over GF(2), given in algebraic normal form (ANF), and converts between ANF and CNF. Such systems come up all over cryptanalysis: for example, the multivariate quadratic systems behind post-quantum schemes can be read in directly, including the Fukuoka MQ challenges and HFE systems.\nBosphorus combines many algorithms: XL, ElimLin, Gauss-Jordan elimination, Gröbner bases (its own matrix-F4 engine, a Matrix-F5 variant, or BRiAl\u0026rsquo;s), and SAT solving with CryptoMiniSat, feeding facts learnt by each into the others. Its ANF-to-CNF conversion uses Brickenstein\u0026rsquo;s algorithm for small polynomials and linearisation with native XOR clauses for larger ones, and it can map CNF solutions back to the ANF. Solutions can be counted by passing the CNF to ApproxMC. Release binaries are on GitHub, and it is available via Nix.\nBosphorus was developed by Davin Choo and Kian Ming A. Chai of DSO National Laboratories, Singapore, together with Kuldeep S. Meel and myself, and is described in Bosphorus: Bridging ANF and CNF Solvers (DATE 2019). See also the blog post Bosphorus, an ANF and CNF simplifier and converter.\n","permalink":"https://www.msoos.org/tools/bosphorus/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/meelgroup/bosphorus\"\u003eBosphorus\u003c/a\u003e simplifies and solves systems of polynomial equations over GF(2), given in algebraic normal form (ANF), and converts between ANF and CNF. Such systems come up all over cryptanalysis: for example, the multivariate quadratic systems behind \u003ca href=\"https://csrc.nist.gov/projects/post-quantum-cryptography\"\u003epost-quantum\u003c/a\u003e schemes can be read in directly, including the Fukuoka MQ challenges and HFE systems.\u003c/p\u003e\n\u003cp\u003eBosphorus combines many algorithms: XL, ElimLin, Gauss-Jordan elimination, Gröbner bases (its own matrix-F4 engine, a Matrix-F5 variant, or BRiAl\u0026rsquo;s), and SAT solving with \u003ca href=\"/tools/cryptominisat/\"\u003eCryptoMiniSat\u003c/a\u003e, feeding facts learnt by each into the others. Its ANF-to-CNF conversion uses Brickenstein\u0026rsquo;s algorithm for small polynomials and linearisation with native XOR clauses for larger ones, and it can map CNF solutions back to the ANF. Solutions can be counted by passing the CNF to \u003ca href=\"/tools/approxmc/\"\u003eApproxMC\u003c/a\u003e. Release binaries are on \u003ca href=\"https://github.com/meelgroup/bosphorus/releases\"\u003eGitHub\u003c/a\u003e, and it is available via Nix.\u003c/p\u003e","title":"Bosphorus"},{"content":"CMSGen is a fast, weighted, uniform-like sampler for CNF formulas. It gives no formal guarantee that its samples follow the desired distribution, but in our testing with the Barbarik uniformity tester it is currently the best sampler without such guarantees.\nCMSGen is built on CryptoMiniSat: it picks polarities and branching variables at random, turns off pre- and inprocessing, and restarts at static intervals, so that its solutions are spread close to uniformly over the solution space. If you need provably uniform samples, use UniGen instead. Release binaries are on GitHub for Linux, Mac and Windows, on both x86_64 and ARM, it is available via Nix, and you can try it in your browser.\nCMSGen is described in Designing Samplers is Easy: The Boon of Testers (FMCAD 2021). See also the blog posts CMSGen, a Fast Uniform-Like Sampler and Checking Uniform-Like Samplers.\n","permalink":"https://www.msoos.org/tools/cmsgen/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/meelgroup/cmsgen\"\u003eCMSGen\u003c/a\u003e is a fast, weighted, uniform-like sampler for CNF formulas. It gives no formal guarantee that its samples follow the desired distribution, but in our testing with the \u003ca href=\"https://github.com/meelgroup/barbarik\"\u003eBarbarik\u003c/a\u003e uniformity tester it is currently the best sampler without such guarantees.\u003c/p\u003e\n\u003cp\u003eCMSGen is built on \u003ca href=\"/tools/cryptominisat/\"\u003eCryptoMiniSat\u003c/a\u003e: it picks polarities and branching variables at random, turns off pre- and inprocessing, and restarts at static intervals, so that its solutions are spread close to uniformly over the solution space. If you need provably uniform samples, use \u003ca href=\"/tools/unigen/\"\u003eUniGen\u003c/a\u003e instead. Release binaries are on \u003ca href=\"https://github.com/meelgroup/cmsgen/releases\"\u003eGitHub\u003c/a\u003e for Linux, Mac and Windows, on both x86_64 and ARM, it is available via Nix, and you can \u003ca href=\"/cmsgen/\"\u003etry it in your browser\u003c/a\u003e.\u003c/p\u003e","title":"CMSGen"},{"content":"CryptoMiniSat is an advanced incremental SAT solver. It reads CNF in the DIMACS format, extended with XOR clauses, and can be used from the command line, as a C++ library, or from Python (pip3 install pycryptosat), with C and Rust wrappers as well. The library interfaces are incremental: they support assumptions and multiple solve calls.\nCryptoMiniSat emits XLRUP proofs that can be checked by the formally verified checker cake_xlrup from frat-xor. It is the SAT solver inside our counters and samplers, ApproxMC, UniGen and CMSGen; if you want to use it as a preprocessor, try Arjun instead. Release binaries are on GitHub, it is available via Nix, and you can try it in your browser. It is MIT licensed. For common questions, see the CryptoMiniSat FAQ.\nWhen citing CryptoMiniSat, always reference our SAT 2009 paper, Extending SAT Solvers to Cryptographic Problems. For its history, see the blog posts Towards CryptoMiniSat 5.0 and CryptoMiniSat 5.8.0 Released.\n","permalink":"https://www.msoos.org/tools/cryptominisat/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/msoos/cryptominisat\"\u003eCryptoMiniSat\u003c/a\u003e is an advanced incremental SAT solver. It reads CNF in the DIMACS format, extended with XOR clauses, and can be used from the command line, as a C++ library, or from Python (\u003ccode\u003epip3 install pycryptosat\u003c/code\u003e), with C and \u003ca href=\"https://github.com/msoos/cryptominisat-rs/\"\u003eRust\u003c/a\u003e wrappers as well. The library interfaces are incremental: they support assumptions and multiple \u003ccode\u003esolve\u003c/code\u003e calls.\u003c/p\u003e\n\u003cp\u003eCryptoMiniSat emits XLRUP proofs that can be checked by the formally verified checker \u003ccode\u003ecake_xlrup\u003c/code\u003e from \u003ca href=\"https://github.com/meelgroup/frat-xor\"\u003efrat-xor\u003c/a\u003e. It is the SAT solver inside our counters and samplers, \u003ca href=\"/tools/approxmc/\"\u003eApproxMC\u003c/a\u003e, \u003ca href=\"/tools/unigen/\"\u003eUniGen\u003c/a\u003e and \u003ca href=\"/tools/cmsgen/\"\u003eCMSGen\u003c/a\u003e; if you want to use it as a preprocessor, try \u003ca href=\"/tools/arjun/\"\u003eArjun\u003c/a\u003e instead. Release binaries are on \u003ca href=\"https://github.com/msoos/cryptominisat/releases\"\u003eGitHub\u003c/a\u003e, it is available via Nix, and you can \u003ca href=\"/cryptominisat/\"\u003etry it in your browser\u003c/a\u003e. It is MIT licensed. For common questions, see the \u003ca href=\"/tools/cryptominisat/faq/\"\u003eCryptoMiniSat FAQ\u003c/a\u003e.\u003c/p\u003e","title":"CryptoMiniSat"},{"content":"Ganak is a high-performance exact model counter: given a CNF formula, it tells you how many satisfying assignments it has, optionally projected onto a set of variables and weighted. It won all available awards at the 2024 and 2025 Model Counting Competitions. It can count over any field, including integers, rationals, complex numbers, integers modulo a prime, and polynomials over a finite field.\nGanak runs in probabilistic mode by default, and can also run fully non-probabilistically (--prob 0), or switch to ApproxMC after a timeout to give an approximate count (--appmct). It should be used together with our preprocessor, Arjun. Release binaries are on GitHub, it is available via Nix, and you can try it in your browser.\nThe ideas behind Ganak are described in Engineering an Efficient Probabilistic Exact Model Counter (CAV 2025) and the original GANAK: A Scalable Probabilistic Exact Model Counter (IJCAI 2019). For the story of how it came about, see Ganak: The Making of a Versatile, High Performance Model Counter and Ganakv2 Released.\n","permalink":"https://www.msoos.org/tools/ganak/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/meelgroup/ganak\"\u003eGanak\u003c/a\u003e is a high-performance exact model counter: given a CNF formula, it tells you how many satisfying assignments it has, optionally projected onto a set of variables and weighted. It won all available awards at the 2024 and 2025 Model Counting Competitions. It can count over any field, including integers, rationals, complex numbers, integers modulo a prime, and polynomials over a finite field.\u003c/p\u003e\n\u003cp\u003eGanak runs in probabilistic mode by default, and can also run fully non-probabilistically (\u003ccode\u003e--prob 0\u003c/code\u003e), or switch to \u003ca href=\"/tools/approxmc/\"\u003eApproxMC\u003c/a\u003e after a timeout to give an approximate count (\u003ccode\u003e--appmct\u003c/code\u003e). It should be used together with our preprocessor, \u003ca href=\"/tools/arjun/\"\u003eArjun\u003c/a\u003e. Release binaries are on \u003ca href=\"https://github.com/meelgroup/ganak/releases\"\u003eGitHub\u003c/a\u003e, it is available via Nix, and you can \u003ca href=\"/ganak/\"\u003etry it in your browser\u003c/a\u003e.\u003c/p\u003e","title":"Ganak"},{"content":"Grain of Salt generates CNF problems from shift-register-based stream ciphers, so that they can be attacked with SAT solvers such as CryptoMiniSat. Descriptions of Grain, Trivium, Bivium, HiTag2 and Crypto1 are included, and new ciphers are easy to add: you describe the shift registers and give the feedback, filter and output functions in algebraic normal form, one monomial per line.\nYou control how many output bits are known, how many key bits are given as help bits (--probBits), and how many problems to generate. For example, ./grainofsalt --num 100 --outputs 90 --crypto grain --probBits 70 generates 100 problems for Grain, with 90 bits of observed output and 70 randomly chosen help bits. The CNF is optimised before output, in part using the bundled espresso logic minimiser. The code is on GitHub, GPL-licensed.\nGrain of Salt is described in Grain of Salt — An Automated Way to Test Stream Ciphers through SAT Solvers (Workshop on Tools for Cryptanalysis, 2010). Karsten Nohl contributed ideas and feedback.\n","permalink":"https://www.msoos.org/tools/grain-of-salt/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/msoos/grainofsalt\"\u003eGrain of Salt\u003c/a\u003e generates CNF problems from shift-register-based stream ciphers, so that they can be attacked with SAT solvers such as \u003ca href=\"/tools/cryptominisat/\"\u003eCryptoMiniSat\u003c/a\u003e. Descriptions of Grain, Trivium, Bivium, HiTag2 and Crypto1 are included, and new ciphers are easy to add: you describe the shift registers and give the feedback, filter and output functions in algebraic normal form, one monomial per line.\u003c/p\u003e\n\u003cp\u003eYou control how many output bits are known, how many key bits are given as help bits (\u003ccode\u003e--probBits\u003c/code\u003e), and how many problems to generate. For example, \u003ccode\u003e./grainofsalt --num 100 --outputs 90 --crypto grain --probBits 70\u003c/code\u003e generates 100 problems for Grain, with 90 bits of observed output and 70 randomly chosen help bits. The CNF is optimised before output, in part using the bundled espresso logic minimiser. The code is on \u003ca href=\"https://github.com/msoos/grainofsalt\"\u003eGitHub\u003c/a\u003e, GPL-licensed.\u003c/p\u003e","title":"Grain of Salt"},{"content":"hevm is an implementation of the Ethereum Virtual Machine (EVM) made for symbolic execution, equivalence checking, and symbolic unit testing of smart contracts. It can symbolically execute smart contracts, check whether two pieces of EVM code are equivalent, and run arbitrary EVM code.\nIn particular, hevm can run Forge test suites symbolically (hevm test), which is much more thorough than fuzz testing. Static binaries for Linux and macOS are on GitHub (they need z3 installed), it is packaged in nixpkgs, and the user documentation is the hevm book. hevm was originally developed as part of dapptools, and was forked by the formal methods team at the Ethereum Foundation in August 2022.\nhevm is described in Hevm, a Fast Symbolic Execution Framework for EVM Bytecode (CAV 2024), by dxo, Mate Soos, Zoe Paraskevopoulou, Martin Lundfall and Mikael Brockman.\n","permalink":"https://www.msoos.org/tools/hevm/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/argotorg/hevm\"\u003ehevm\u003c/a\u003e is an implementation of the Ethereum Virtual Machine (EVM) made for symbolic execution, equivalence checking, and symbolic unit testing of smart contracts. It can symbolically execute smart contracts, check whether two pieces of EVM code are equivalent, and run arbitrary EVM code.\u003c/p\u003e\n\u003cp\u003eIn particular, hevm can run \u003ca href=\"https://book.getfoundry.sh/forge/writing-tests\"\u003eForge\u003c/a\u003e test suites symbolically (\u003ccode\u003ehevm test\u003c/code\u003e), which is much more thorough than fuzz testing. Static binaries for Linux and macOS are on \u003ca href=\"https://github.com/argotorg/hevm/releases\"\u003eGitHub\u003c/a\u003e (they need \u003ccode\u003ez3\u003c/code\u003e installed), it is packaged in nixpkgs, and the user documentation is the \u003ca href=\"https://hevm.dev/\"\u003ehevm book\u003c/a\u003e. hevm was originally developed as part of \u003ca href=\"https://github.com/dapphub/dapptools/\"\u003edapptools\u003c/a\u003e, and was forked by the formal methods team at the Ethereum Foundation in August 2022.\u003c/p\u003e","title":"hevm"},{"content":"Pepin is a probabilistic approximate counter for DNF formulas. Geometrically, it takes a set of possibly overlapping n-dimensional boxes and estimates the total volume they cover. It reads the cubes in a simple DNF format and outputs an approximate count with a probabilistic guarantee.\nPepin streams the cubes, keeping only a bucket of in-progress samples in memory, and it supports weighted counting as well. For CNF formulas, use ApproxMC or Ganak instead. Release binaries are on GitHub, it is available via Nix, and you can try it in your browser.\nPepin is described in Engineering an Efficient Approximate DNF-Counter (IJCAI 2023). The blog post Pepin, our Probabilistic Approximate Volume Counter explains the idea and its connection to the CVM distinct-elements algorithm.\n","permalink":"https://www.msoos.org/tools/pepin/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/meelgroup/pepin\"\u003ePepin\u003c/a\u003e is a probabilistic approximate counter for DNF formulas. Geometrically, it takes a set of possibly overlapping n-dimensional boxes and estimates the total volume they cover. It reads the cubes in a simple DNF format and outputs an approximate count with a probabilistic guarantee.\u003c/p\u003e\n\u003cp\u003ePepin streams the cubes, keeping only a bucket of in-progress samples in memory, and it supports weighted counting as well. For CNF formulas, use \u003ca href=\"/tools/approxmc/\"\u003eApproxMC\u003c/a\u003e or \u003ca href=\"/tools/ganak/\"\u003eGanak\u003c/a\u003e instead. Release binaries are on \u003ca href=\"https://github.com/meelgroup/pepin/releases\"\u003eGitHub\u003c/a\u003e, it is available via Nix, and you can \u003ca href=\"/pepin/\"\u003etry it in your browser\u003c/a\u003e.\u003c/p\u003e","title":"Pepin"},{"content":"UniGen is an almost-uniform sampler for CNF formulas: it returns satisfying assignments such that each solution is picked with nearly the same probability, with formal guarantees. It supports a sampling set, so that solutions are drawn uniformly over a chosen subset of the variables.\nThe current version is based on Tinted, Detached, and Lazy CNF-XOR Solving and Its Applications to Counting and Sampling (CAV 2020). It builds on a series of papers on the hashing-based approach, published over 2012–2020 and co-authored by Supratik Chakraborty, Daniel Fremont, Stephan Gocht, Kuldeep S. Meel, Sanjit A. Seshia, Mate Soos and Moshe Y. Vardi.\n","permalink":"https://www.msoos.org/tools/unigen/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/meelgroup/unigen\"\u003eUniGen\u003c/a\u003e is an almost-uniform sampler for CNF formulas: it returns satisfying assignments such that each solution is picked with nearly the same probability, with formal guarantees. It supports a sampling set, so that solutions are drawn uniformly over a chosen subset of the variables.\u003c/p\u003e\n\u003cp\u003eThe current version is based on \u003ca href=\"https://doi.org/10.1007/978-3-030-53288-8_22\"\u003eTinted, Detached, and Lazy CNF-XOR Solving and Its Applications to Counting and Sampling\u003c/a\u003e (CAV 2020). It builds on a series of papers on the hashing-based approach, published over 2012–2020 and co-authored by Supratik Chakraborty, Daniel Fremont, Stephan Gocht, Kuldeep S. Meel, Sanjit A. Seshia, Mate Soos and Moshe Y. Vardi.\u003c/p\u003e","title":"UniGen"}]