<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>The BWConverter Toolchain: An Incomplete Way to Convert SAT Problems into Directed Graphs∗</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Tamás Balla</string-name>
          <email>balla.tamas@uni-eszterhazy.hu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Csaba Biró</string-name>
          <email>biro.csaba@uni-eszterhazy.hu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Gábor Kusper</string-name>
          <email>kusper.gabor@uni-eszterhazy.hu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Eszterházy Károly University, Faculty of Informatics</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2020</year>
      </pub-date>
      <fpage>29</fpage>
      <lpage>31</lpage>
      <abstract>
        <p>In our previous works we showed, how to convert a directed graph into a SAT problem. We showed that if the directed graph is strongly connected, then the converted SAT problem is Black-and-White. A SAT problem is Black-and-White if it has exactly two solutions, the black assignment, where each variable is false, and the white one, where each variable is true. In this paper, we study the other way: How to convert a SAT problem into a directed graph. This direction seems to be very dificult, so we introduce the BWConverter toolchain which helps us to create Black-and-White SAT instances, and convert them to directed graphs using diferent strategies. The toolchain consist of two tools: the BWConverter and the NPP tool. As a first step, one has to use the BWConverter tool, which creates a Black-and-White SAT problem from any UNSAT problems. The resulting SAT problem is Black-and-White if the input was UNSAT . As a second step, we generate a directed graph using our NPP tool. This tool generates edges from clauses which contain either exactly one positive literal, or exactly one negative one using the observations of our previous models.</p>
      </abstract>
      <kwd-group>
        <kwd>SAT</kwd>
        <kwd>Strongly Connected Directed Graphs</kwd>
        <kwd>BWConverter</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>The propositional satisfiability problem, for short the SAT problem, is the problem
to find an assignment to the the Boolean variables of the input formula which
∗This research was supported by the grant EFOP-3.6.1-16-2016-00001 “Complex improvement
of research capacities and services at Eszterházy Károly University”.</p>
      <p>
        Copyright © 2020 for this paper by its authors. Use permitted under Creative Commons License
Attribution 4.0 International (CC BY 4.0).
makes it true. The formula is given in conjunctive normal form (CNF) which is
represented as a clause set. If each clause consists of at most  literals, then it is a
 -SAT problem. We know that the 2-SAT problem is solvable in linear time [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. On
the other hand 3-SAT is NP-complete [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. So, there is a big the gap between the
easiness of 2-SAT and hardness of 3-SAT. We know some classes which are between
them:
      </p>
      <p>
        Horn SAT is the restriction to instances where each clause has at most one
positive literal. Horn SAT is solvable in linear time [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], as are a number of
generalizations such as renamable Horn SAT [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], extended Horn SAT [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] and q-Horn
SAT [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>
        The hierarchy of tractable satisfiability problems [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], which is based on Horn
SAT and 2-SAT, is solvable in polynomial time. An instance on the  -th level of
the hierarchy is solvable in  (  +1) time.
      </p>
      <p>
        , -SAT, where  , -SAT is the class of problems in which every clause has
exactly  literals and every variable has at most  occurrences. All  , -SAT problems
are satisfiable in polynomial time [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ].
      </p>
      <p>
        A formula is SLUR (Single Lookahead Unit Resolution) solvable if, for all possible
sequences of selected variables, algorithm SLUR does not give up. Algorithm SLUR
is a non-deterministic algorithm based on unit propagation. It eventually gives
up the search if it starts with, or creates, an unsatisfiable formula with no unit
clauses. The class of SLUR solvable formulae was developed as a generalization
including Horn SAT, renamable Horn SAT, extended Horn SAT, and the class of
CC-balanced formulae [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ].
      </p>
      <p>In this paper we restrict the general SAT problem such that each clause should
contain at least one positive and one negative literal. We study how can we generate
a directed graph from this kind of problem. Our goal is to give tools which help to
do this work.</p>
      <p>
        In our previous works we showed, how to convert a directed graph into a SAT
problem [
        <xref ref-type="bibr" rid="ref12 ref3">3, 12</xref>
        ]. We have presented two SAT solvers [
        <xref ref-type="bibr" rid="ref10 ref11 ref4">4, 10, 11</xref>
        ] and introduced
several models [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]. We showed that if the directed graph is strongly connected,
then the converted SAT problem is Black-and-White.
      </p>
      <p>A SAT problem is Black-and-White if it has exactly two solutions, the black
assignment, where each variable is false, and the white one, where each variable is
true. In this paper, we study the other way: How to convert a SAT problem into a
directed graph.</p>
      <p>This direction seems to be very dificult, because if we would have a complete
converter from SAT to directed graphs, then we could use our previous result to
convert it to 2-SAT, i.e., we would have a SAT to 2-SAT converter. What we present
is just an incomplete converter, so we do not attack the P = NP question.</p>
      <p>The BWConverter toolchain contains two tools: the BWConverter and the
NPP tool. As a first step, one has to use the BWConverter tool, which creates a
Black-and-White SAT problem from UNSAT problems.</p>
      <p>The BWConverter makes sure that its output has the same set of solutions as the
input, except the black and the white assignment. To do so, we have implemented
several algorithms.</p>
      <p>The most interesting one introduces two new variables,  and  ; then it adds
(¬ ) to each clause which contains only positive literals; then it adds ( ) to each
clause which contains only negative ones; finally, it adds (¬ ∨  ) as a new clause
to the output. The resulting SAT problem is Black-and-White if the input was
UNSAT.</p>
      <p>As a second step, we generate a directed graph using our NPP tool. This tool
generates edges from clauses which contain either exactly one positive literal, or
exactly one negative one using the observations of our previous models.</p>
      <p>From example from the clause (¬ ∨  ∨  ) it generates the edges:  → 
with weight 50%, and  →  with weight 50%. From the clause (¬ ∨ ¬ ∨  )
it generates the edges (the weights are in ()):  →  (50%),  →  (50%),
 →  (50%), and  →  (50%). This conversation is too eager, because it creates
a strongly connected graph even if the input was not a Black-and-White SAT
problem. As a solution, we attach to each edge a weight number which indicates,
how likely is that the edge is important. Then we iteratively remove the edges with
the smallest and / or with the highest weight until we would have a non strongly
connected directed graph in the next iteration. We call this directed graph to be
the directed graph representation of the input SAT problem.</p>
      <p>We studied where this state transition point is in case of unsatisfiable random
3-SAT problems.</p>
    </sec>
    <sec id="sec-2">
      <title>2. The BWConverter tool</title>
      <p>The BWConverter tool can create a Black-and-White SAT problem from an UNSAT
problem. It has 3 main switches:
BWConverter -nooverlap num | BWConverter -n num
BWConverter -overlap num | BWConverter -o num
BWConverter -pigeonholeeater | BWConverter -p</p>
      <p>After the first two ones we give a number, which shows how smart do we use
these strategies. If the number is 0, then we do not use other input clauses to
generate less clauses. 1 means that we use always the same clause to generate less
clauses. 2 means that we use one of the best clause in order to generate as few
clauses as possible.</p>
      <p>They remove the black and the white clauses from each input clause. We
introduce them by examples. Let us assume that the input has 6 variables: from 
to  , these clauses was already processed: {, ,  }, {, ,  }, and the current clause
is {, ,  }. Then:
-n 0 generates: ¬ }, {, , , , , ¬ }.
-n 1 generates: ¬ }.
-n 2 generates:
-o 0 generates: ¬ }, {, , , ¬ }.
-o 1 generates: ¬ }.
-o 2 generates:
¬ }, {, , , ,
¬ }, {, , , ,
¬ }.
¬ }, {, , ,
¬ }, {, , ,
¬ }.
{, , ,
{, , ,
{, , ,
{, , ,
{, , ,
{, , ,</p>
      <p>Note, that in case of -n there is no such full-length clause which is subsumed
by the generated clauses, so they do not overlap.</p>
      <p>-p introduces two new variables  and  ; then it adds (¬ ) to each clause which
contains only positive literals; then it adds ( ) to each clause which contains only
negative ones; finally, it adds (¬ ∨  ) as a new clause to the output. The resulting
SAT problem is Black-and-White if the input was UNSAT.</p>
      <p>An example for -p is the following: Let us assume that the input is ( ∨  ) ∧ ( ∨
 ) ∧ ( ∨  ) ∧ (¬ ∨ ¬ ) ∧ (¬ ∨ ¬ ) ∧ (¬ ∨ ¬ ) ∧ (¬ ∨ ¬ ) ∧ (¬ ∨ ¬ ) ∧ (¬ ∨ ¬ ),
which is actually the Pigeon Hole problem1 with 3 pigeons and 2 holes. Then the
output is: (¬ ∨  ∨  ) ∧ (¬ ∨  ∨  ) ∧ (¬ ∨  ∨  ) ∧ ( ∨ ¬ ∨ ¬ ) ∧ ( ∨ ¬ ∨ ¬ ) ∧
( ∨ ¬ ∨ ¬ ) ∧ ( ∨ ¬ ∨ ¬ ) ∧ ( ∨ ¬ ∨ ¬ ) ∧ ( ∨ ¬ ∨ ¬ ) ∧ (¬ ∨  ).</p>
      <p>There are some more minor switches:
-nob means that the output will not subsume the black clause.
-now means that the output will not subsume the white clause.
-bw means that the generated output will be a black-and-what SAT problem, if
the input was an UNSAT problem. This is the same as -nob -now, and this is a
default switch.
-same means that the output problem will have the same set of solutions as the
input, because it adds the black and the white clauses at the end of the output.
-help prints the help.</p>
    </sec>
    <sec id="sec-3">
      <title>3. The NPP Tool</title>
      <p>The NPP tool work as follows: it reads a CNF file in DIMACS format. For each
clause  it adds the edges (, ,  ) to the graph, where  is a negative literal, 
is a positive literal, and  is 1/ , where  is the number of positive literals in
 . It also adds the edges ( 1,  2,  ) to the graph, where  1 and  2 are diferent
negative literals, and  = 1/ , where  is the number of positive literals in
 .</p>
      <p>For example if  = {¬, ¬, ¬, ,  }, then the following edges is added to the
graph: (, , 0.5), (, , 0.5), (, , 0.5), (, , 0.5), (, , 0.5), (, , 0.5), (, , 0.33),
(, , 0.33), (, , 0.33), (, , 0.33), (, , 0.33), (, , 0.33).</p>
      <p>The tool has the following switches:
NPP -autominlimit | NPP -a
NPP -automaxlimit | NPP -A
NPP -setminlimit num | NPP -s num
NPP -setmaxlimit num | NPP -S num
NPP -normalized | NPP -N</p>
      <p>-a finds the biggest limit, such that by deleting edges with weight ≤ limit the
directed graph is still strongly connected. -A finds the lowest limit, such that by
deleting edges with weight ≥ limit the directed graph is still strongly connected.
-s sets the lower limit to num, i.e., it deletes all edges where the weight ≤ num.
1https://www.cs.ubc.ca/~hoos/SATLIB/Benchmarks/SAT/DIMACS/PHOLE/descr.html
-S sets the upper limit to num, i.e., it deletes all edges where the weight ≥ num.</p>
      <p>The most typical usage is NPP -a -A which finds automatically both limits.</p>
      <p>The output of the NNP tool is the adjency matrix of the constructed and
modified graph. If   = −1 that means that there is no directed vertex from  to
 , otherwise the value is the weight of vertex from  to  . If we use -N switch the
tool will normalize the weight values to [0; 1] interval before it removes any edge
from graph.</p>
    </sec>
    <sec id="sec-4">
      <title>4. An Example</title>
      <p>The initial UNSAT 3-SAT formula let be as follows: (¬ ∨  ∨  ) ∧ ( ∨ ¬ ∨  ) ∧
( ∨ ¬ ∨ ¬ ) ∧ ( ∨ ¬ ∨ ¬ ) ∧ (¬ ∨  ∨ ¬ ) ∧ ( ∨  ∨  ) ∧ (¬ ∨ ¬ ∨ ¬ ).</p>
      <p>After running the BWConverter tool, the modified formula is as follows: (¬ ∨
 ∨ )∧( ∨¬ ∨ )∧( ∨¬ ∨¬ )∧( ∨¬ ∨¬ )∧(¬ ∨ ∨¬ )∧( ∨ ∨ ∨¬ )∧(¬ ∨
¬ ∨ ¬ ∨  ). Note, that this is not UNSAT any more, it is Black-and-White.
5. Usage and Conclusion
The toolchain can be found here: http://fmv.ektf.hu/tools.html. It consists
of two tools: BWConverter, and NPP. Its typical usage is the following:
• java BWConverter -o 2 unsat.cnf bw.cnf
• java NPP -a -A -N bw.cnf</p>
      <p>This work was an inner project, because we used to need a tool to test our
theories. For us the toolchain was very useful, so we decided to publish it. As future
work we should prove the lemmas what we found by the help of this toolchain.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>B.</given-names>
            <surname>Aspvall</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. F.</given-names>
            <surname>Plass</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. E.</given-names>
            <surname>Tarjan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A</given-names>
            <surname>Linear-Time Algorithm For Testing The Truth Of Certain Quantified Boolean Formulas</surname>
          </string-name>
          ,
          <source>Information Processing Letters</source>
          , pp.
          <fpage>121</fpage>
          -
          <lpage>123</lpage>
          ,
          <year>1979</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>B.</given-names>
            <surname>Aspvall</surname>
          </string-name>
          ,
          <article-title>Recognizing Disguised NR(1) Instances of the Satisfiability Problem</article-title>
          ,
          <source>J. of Algorithms</source>
          , 1, pp.
          <fpage>97</fpage>
          -
          <lpage>103</lpage>
          ,
          <year>1980</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Cs</surname>
          </string-name>
          . Biró, G. Kusper,
          <article-title>Equivalence of Strongly Connected Graphs and Black-andWhite 2</article-title>
          -
          <string-name>
            <given-names>SAT</given-names>
            <surname>Problems</surname>
          </string-name>
          ,
          <source>Miskolc Mathematical Notes</source>
          , Vol.
          <volume>19</volume>
          , No.
          <issue>2</issue>
          , pp.
          <fpage>755</fpage>
          -
          <lpage>768</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Cs</surname>
          </string-name>
          . Biró and G. Kusper, BaW
          <volume>1</volume>
          .0
          <article-title>- A Problem Specific SAT Solver for Efective Strong Connectivity Testing in Sparse Directed Graphs</article-title>
          , CINTI-2018, pp.
          <fpage>137</fpage>
          -
          <lpage>142</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>E.</given-names>
            <surname>Boros</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. L.</given-names>
            <surname>Hammer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Sun</surname>
          </string-name>
          ,
          <article-title>Recognition of q-Horn Formulae in Linear Time</article-title>
          . Discrete Applied Mathematics, v.
          <volume>55</volume>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>13</lpage>
          ,
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>V.</given-names>
            <surname>Chandru</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Hooker</surname>
          </string-name>
          , Extended Horn Sets in Propositional Logic,
          <source>J. of the ACM</source>
          ,
          <volume>38</volume>
          (
          <issue>1</issue>
          ), pp.
          <fpage>205</fpage>
          -
          <lpage>221</lpage>
          ,
          <year>1991</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>S. A.</given-names>
            <surname>Cook</surname>
          </string-name>
          ,
          <article-title>The Complexity of Theorem-Proving Procedures</article-title>
          ,
          <source>Proc of STOC'71</source>
          , pp.
          <fpage>151</fpage>
          -
          <lpage>158</lpage>
          ,
          <year>1971</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>M.</given-names>
            <surname>Dalal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. W.</given-names>
            <surname>Etherington</surname>
          </string-name>
          ,
          <article-title>A Hierarchy of Tractable Satisfiability Problems</article-title>
          . Information Processing Letters, v.
          <volume>44</volume>
          , pp.
          <fpage>173</fpage>
          -
          <lpage>180</lpage>
          ,
          <year>1992</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>W. F.</given-names>
            <surname>Dowling</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. H.</given-names>
            <surname>Gallier</surname>
          </string-name>
          ,
          <article-title>Linear-Time Algorithms for Testing the Satisfiability of Propositional Horn Formulae</article-title>
          .
          <source>J. of Logic Programming</source>
          ,
          <volume>1</volume>
          (
          <issue>3</issue>
          ), pp.
          <fpage>267</fpage>
          -
          <lpage>284</lpage>
          ,
          <year>1984</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Kusper and Cs. Biró, Solving SAT by an Iterative Version of the InclusionExclusion Principle</article-title>
          ,
          <string-name>
            <surname>SYNASC</surname>
          </string-name>
          <year>2015</year>
          , IEEE Computer Society Press pp.
          <fpage>189</fpage>
          -
          <lpage>190</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>G.</given-names>
            <surname>Kusper</surname>
          </string-name>
          , Cs. Biró, Gy. B.
          <string-name>
            <surname>Iszály</surname>
          </string-name>
          ,
          <article-title>SAT solving by CSFLOC, the next generation of full-length clause counting algorithms</article-title>
          ,
          <source>Future IoT</source>
          <year>2018</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>9</lpage>
          ,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>G.</given-names>
            <surname>Kusper</surname>
          </string-name>
          , Cs. Biró,
          <article-title>Convert a Strongly Connected Directed Graph to a Blackand-White 3-SAT Problem by the Balatonboglár Model, submitted to Theory of Computing, 17 pages</article-title>
          ,
          <source>arrived on 24.08</source>
          .
          <year>2019</year>
          ,
          <article-title>status: under review</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>G.</given-names>
            <surname>Kusper</surname>
          </string-name>
          , Cs. Biró, T. Balla,
          <article-title>Representing Directed Graphs as 3-SAT Problems Using The Simplified Balatonboglár Model</article-title>
          , The 11th International Conference on Applied Informatics to be held in Eger,
          <source>Hungary January 29-31</source>
          ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>J. S.</given-names>
            <surname>Schlipf</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Annexstein</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Franco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. P.</given-names>
            <surname>Swaminathan</surname>
          </string-name>
          ,
          <article-title>On finding solutions for extended Horn formulas</article-title>
          ,
          <source>Information Processing Letters</source>
          , v.
          <volume>54</volume>
          , pp.
          <fpage>133</fpage>
          -
          <lpage>137</lpage>
          ,
          <year>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>C. A.</given-names>
            <surname>Tovey</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A Simplified</given-names>
            <surname>NP-complete Satisfiability</surname>
          </string-name>
          Problem Mathematics, v. 8, pp.
          <fpage>85</fpage>
          -
          <lpage>89</lpage>
          ,
          <year>1984</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>