<!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>Efficient Counting of Models for Boolean Formulas Represented by Embedded Cycles</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Guillermo De Ita Luna</string-name>
          <email>deita@cs.buap.mx</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Pedro Bello L´opez</string-name>
          <email>pbello@cs.buap.mx</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Meliza Contreras Gonza´lez</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Faculty of Computer Sciences, Universidad Aut ́onoma de Puebla</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>To compute the number of models of a 2-CF (conjunction of clauses with two literals at most), the well-known problem as #2-SAT, is a classical #P-complete problem. We show here an extensive class of instances of 2CF's where to compute the number of models can be done in polynomial time. Given a 2-CF Σ, we show that if its constrained graph GΣ is acyclic or if its set of cycles can be arranged as a set of independent and embedded cycles then #2-SAT(Σ) can be computed in polynomial time. We present a procedure for detecting if a set of cycles can be embedded one into other. Furthermore, we design a polynomial reduction for given two restricted intersected cycles redraw those as embedded cycles. The resulting method for counting models for a 2-CF could be used to impact directly in the reduction of the complexity time of the algorithms for other counting problems. For example, for counting independent sets, counting colouring of graphs, counting cover vertex, etc.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Introduction
#SAT is a classical #P-complete problem even for formulas which are restricted
to conjunction of clauses with two literals at most, this last problem denoted as
#2-SAT. #SAT is a very hard counting problem, for example, Hunt, et. al. has
shown that #SAT to planar 3-CF formulae (its constrained graph is planar) is
#P-complete [6].</p>
      <p>#2-SAT continues being a #P-complete problem if we consider only monotone
formulas or Horn formulas [9]. Even more, #SAT restricted to formulas in the
class (2, 3µ)-CF (the class of conjunctions of 2-clauses where each variable
appears three times at most) is also #P-complete [8].</p>
      <p>On the other hand, the maximum polynomial class recognized for #2SAT
is the class (≤ 2, 2µ)-CF (conjunction of binary or unitary clauses where each
variable appears two times at most) [3, 8, 9].</p>
      <p>#SAT as well as its decision counterpart - the SAT problem, are a special
concern to Artificial Intelligence (AI), and it has a direct relationship to
Automated Theorem Proving as well as in Approximate Reasoning. For example,
#SAT has applications in estimating the degree of reliability in a
communication network, for computing the degree of belief in propositional theories, in
Bayesian inference, in a truth maintenance systems, for repairing inconsistent
databases [2, 8, 10]. The previous problems come from several AI applications
such as planning, expert systems, data-mining, approximate reasoning, etc.</p>
      <p>For example, if we assign an equal degree of belief to all basic ’situations’
that appear in a knowledge base Σ of an intelligent agent, then we can compute
the probability that Σ will be satisified. If Σ involves n variables, the probabilty
to satisfies Σ, is: PΣ = P rob(Σ ≡ ) = #SA2nT (Σ) , where stands for the Truth
value and P rob is used to denote the probability. Thus, to compute the degree
of belief of the agent in a propositional formula F with respect to its knowledge
base Σ, is the fraction of models of Σ that are consistent with the formula F ,
that is, the conditional probability of F with respect to Σ, which is denoted by
PF |Σ = P rob((Σ ∧ F ) ≡ |Σ ≡ ) = ##SASAT(TΣ(Σ∧F) ) .</p>
      <p>One important goal of research is to recognize the class of formulas for Σ
and F where the degree of belief PF |Σ can be done efficiently, and for this, to
develop smart algorithms for solving #SAT is key.</p>
      <p>By other way, many combinatorial problems ask about embeddings of graphs
into other objects [7]. For instance, the polynomial time solvable graph planarity
problem ask whether a given graph G, it can be embedded in the plane in such
a way that no two edges intersect (except at a common endpoint).</p>
      <p>In our case, we are interested in a particular subclass of planar graphs, those
graphs whose set of cycles can be arranged as independent cycles as well as
embedded cycles.</p>
      <p>We have designed some procedures for counting models for 2-CF [3–5]. In this
article, we extend those procedures. Specially, we consider the previous reduction
presented in [5] for translating a pair of intersected cycles with exactly one
common edge to a pair of embedded cycles.The main contribution in this article
is to present a way to detect if a set of cycles can be embedded one into other,
and to show how to compute #SAT for formulas whose constrained graphs have
such topology.
2.</p>
    </sec>
    <sec id="sec-2">
      <title>Notation and Preliminaries</title>
      <p>Let X = {x1, . . . , xn} be a set of n Boolean variables. A literal is either a variable
x or a negated variable x. As is usual, for each x ∈ X, x0 = x and x1 = x. We
use υ(l) to indicate the variable involved by the literal l.</p>
      <p>A clause is a disjunction of different literals (sometimes, we also consider a
clause as a set of literals). For k ∈ IN , a k-clause is a clause consisting of exactly
k literals and, a (≤ k)-clause is a clause with k literals at most. A unary clause
has just one literal and a binary clause has exactly two literals. The empty clause
signals a contradiction. A clause is tautological if it contains a complementary
pair of literals. From now on, we will consider just non-tautological and
noncontradictory clauses. A variable x ∈ X appears in a clause c if either x or x is
an element of c. Let υ(c) = {x ∈ X : x appears in c}.</p>
      <p>A Conjunctive Form (CF) is a conjunction of clauses (we also consider a CF
as a set of clauses). We say that Σ is a monotone CF if all of its variables appear
in unnegated form. A k-CF is a CF containing only k-clauses and, (≤ k)-CF
denotes a CF containing clauses with at most k literals. A kµ-CF is a formula
in which no variable occurs more than k times. A (k, sµ)-CF, (≤ k, sµ)-CF is a
k-CF, (≤ k) − CF , such that each variable appears no more than s times. For
any CF Σ, let υ(Σ) = {x ∈ X : x appears in any clause of Σ}.</p>
      <p>An assignment s for Σ is a function s : υ(Σ) → {0, 1}. An assignment can
be also considered as a set of no complementary pairs of literals. If l ∈ s, being
s an assignment, then s makes l true and makes l false. A clause c is satisfied
by s if and only if c ∩ s = ∅. If for all l ∈ c, l ∈ s then s falsifies c. A CF F is
satisfied by an assignment s if each clause in F is satisfied by s and s falsifies c
if c is not satisfied by s and F is contradicted if it is not satisfied.</p>
      <p>Let SAT (Σ) be the set of models that Σ has over υ(Σ). Σ is a contradiction
or unsatisfiable if SAT (Σ) = ∅. Let µυ(Σ)(Σ) = |SAT (Σ)| be the cardinality of
SAT (Σ) and [[n]] denotes the set {1, 2, ..., n}.</p>
      <p>Given Σ a CF, the SAT problem consists in determining if Σ has a model.
The #SAT consists of counting the number of models of F defined over υ(Σ).
We will also denote µυ(Σ)(Σ) by #SAT (Σ). When υ(Σ) will clear from the
context, we will omit it as a subscript.</p>
      <sec id="sec-2-1">
        <title>The Graph Representation of a 2-CF</title>
        <p>Let Σ be a 2-CF, the constrained graph of Σ is the undirected graph GΣ =
(V, E), with V = υ(Σ) and E = {(υ(x), υ(y)) : (x, y) ∈ Σ}, that is, the vertices
of GΣ are the variables of Σ and for each clause (x, y) in Σ there is an edge
(υ(x), υ(y)) ∈ E. The degree of a node v ∈ V is the number of incident edges to
v. We say that a 2-CF Σ is a cycle, a path or a tree if GΣ is a cycle, a path or a
tree, respectively.</p>
        <p>When GΣ contains several cycles, they could be independent or intersected.
We say that to cycles Ci, Cj are independent one to the other if they don’t have
common edges. If a cycle C ∈ GΣ is independent with all the other cycles in G,
we say that C is an independent cycle in GΣ.</p>
        <p>Given a 2-CF Σ, a connected component of GΣ is a maximal subgraph such
that for every pair of vertices x, y, there is a path in GΣ from x to y. We say
that the set of connected components of Σ are the subformulas corresponding to
the connected components of GΣ.</p>
        <p>
          If {G1, . . . , Gr} is a partition in connected components of Σ, then:
µυ(Σ)(Σ) = µυ(G1)(G1) ∗ · · · ∗ µυ(Gr)(Gr)
(
          <xref ref-type="bibr" rid="ref1">1</xref>
          )
        </p>
        <p>In order to compute µ(Σ), first we should determine the set of connected
components of Σ, and this procedure is done in linear time [9]. Then, compute
µ(Σ) is translated to compute µυ(G)(G) for each connected component G of Σ.
From now on, when we mention a formula Σ, we suppose that Σ is a connected
component.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Basic Procedures for computing #2-SAT</title>
      <p>For completeness purposes, we present in this chapter some procedures designed
for us in previous articles [3,4,5] although the new contributions will be
developed until chapter 4.</p>
      <sec id="sec-3-1">
        <title>Case A:</title>
        <p>First, let us consider GΣ = (V, E) be a path (also called a chain). Let us write
down its associated formula Σ, without a loss of generality (ordering the clauses
and its literals, if it were necessary), as: Σ = {c1, ..., cm}
=</p>
        <p>{x11, xδ21 }, {x22, xδ32 }, . . . , {xmm−1, xδmm } , where |υ(ci) ∩ υ(ci+1)| = 1, i ∈
[[m − 1]], and δi, i ∈ {0, 1}, i = 1, ..., m.</p>
        <p>As Σ has m clauses then |υ(Σ)| = n = m + 1. We will compute µ(Σ) in base
to build a series (αi, βi), i = 1, ..., m, where each pair of the series is associated
to the variable xi of υ(Σ). The value αi indicates the number of times that the
variable xi is ’true’ and βi indicates the number of times that the variable xi
takes value ’false’ over the set of models of Σ.</p>
        <p>Let fi be a family of clauses of Σ built as follows: f0 = ∅,fi = {cj}j≤i,
i ∈ [[m]]. Note that fi ⊂ fi+1, i ∈ [[m − 1]]. Let SAT (fi) = {s : s satisfies fi},
Ai = {s ∈ SAT (fi) : xi ∈ s}, Bi = {s ∈ SAT (fi) : xi ∈ s}. Let αi =
|Ai|; βi = |Bi| and µi = |SAT (fi)| = αi + βi. From the total number of models
in µi, i ∈ [[m]], there are αi of which xi takes the logical value ’true’ and βi
models where xi takes the logical value ’false’.</p>
        <p>
          In general, we compute the values for (αi, βi) associated to each node xi,
i = 2, .., m, according to the signs ( i, δi) of the literals in the clause ci, by the
next recurrence equation:
(αi, βi) =
(βi−1 ,αi−1 + βi−1) if ( i, δi) = (0, 0)
(αi−1 + βi−1,βi−1 ) if ( i, δi) = (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          )
(αi−1 ,αi−1 + βi−1) if ( i, δi) = (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          )
(αi−1 + βi−1,αi−1 ) if ( i, δi) = (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          )
(
          <xref ref-type="bibr" rid="ref2">2</xref>
          )
        </p>
        <p>
          Notice that, as Σ = fm then µ(Σ) = µm = αm + βm. We denote with →
the application of one of the four rules of the recurrence (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ).
        </p>
        <p>
          If Σ is a path, we apply (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ) in order to compute µ(Σ). The procedure has
a linear time complexity over the number of variables of Σ, since (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ) is applied
while we are traversing the path, from the initial node to the final node.
Example 1 Let Υ be a monotone 2-CF with m clauses and where GΥ is a
path. I.e Υ = {(x1, x2), (x2, x3), . . . , (xm−1, xm)}. Then, at the beginning of the
recurrence (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ), (α1, β1) = (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) and (α2, β2) = (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) since ( 1, δ1) = (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ), and
in general, as ( i, δi) = (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ), for i ∈ [[m]], then the rule: (αi, βi) = (αi−1 +
βi−1, αi−1) is always applied while we are scanning each node of the path, thus
the Fibonacci numbers appear!.
        </p>
        <p>µ2 = α2 + β2 = α1 + β1 + α1 = 3,
µ3 = α3 + β3 = µ2 + α2 = 5,
(µi)i≥3 = αi + βi = µi−1 + µi−2</p>
        <p>
          Applying the Fibonacci series for a monotone formula F , we obtain the values
(αi, βi) : (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) → (
          <xref ref-type="bibr" rid="ref3 ref5">5, 3</xref>
          ) → (
          <xref ref-type="bibr" rid="ref5 ref8">8, 5</xref>
          ) → (
          <xref ref-type="bibr" rid="ref8">13, 8</xref>
          ), ..., and this last
series coincides with the Fibonacci numbers: (F2, F1) → (F3, F2) → (F4, F3) →
(F5, F4) → (F6, F5) → (F7, F6)... Then, we infer that (αi, βi) = (Fi+2, Fi+1)
and then µi = Fi+2 + Fi+1 = Fi+3, i = 1, ..., m. E.g. for m = 5, we have
#SAT (F ) = µ5 Thus, the following theorem follows:
Theorem 1 Let Σ be a monotone 2-CF with n nodes such that GΣ is a path,
then: #SAT (Σ) = Fn+2
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>Case B:</title>
        <p>Let GΣ be a simple cycle with m nodes, that is, all the variables in υ(Σ)
appear twice, |V | = m = n = |E|. Ordering the clauses in Σ in such a way
that | υ(ci) ∩ υ(ci+1) |= 1, and ci1 =m ci2 whenever i1 ≡ i2 mod m, hence
x1 = xm, then Σ = ci = {xi−i1, xiδi } i=1 , where δi, i ∈ {0, 1}. Decomposing
Σ as Σ = Σ ∪ cm, where Σ = {c1, ..., cm−1} is a path and cm = (xmm−1, xδ1m ) is
the edge which conforms with GΣ the simple cycle: x1, x2, ..., xm−1, x1. We can
apply the linear procedure described in the case A for computing µ(Σ ).</p>
        <p>
          Every model of Σ had determined logical values for the variables: xm−1
and x1 since those variables appear in υ(Σ ). Any model s of Σ satisfies cm
if and only if (x1m−−1m ∈/ s and x1m−δm ∈/ s), that is, SAT (Σ ∪ cm) ⊆ SAT (Σ ),
and SAT (Σ ∪ cm) = SAT (Σ ) − {s ∈ SAT (Σ ) : s falsifies cm}. Let X =
Σ ∪ {(x1m−−1m ) ∧ (x1m−δm )}, then µ(X) can be computed as a path with two unary
clauses, that is:
#SAT (Σ) = µ(Σ) = µ(Σ ) − µ(X)
= µ(Σ ) − µ(Σ ∧ (x1m−−1m ) ∧ (x1m−δm ))
(
          <xref ref-type="bibr" rid="ref3">3</xref>
          )
For example, let us consider Σ be a monotone 2-CF with m clauses such
m
that GΣ is a simple cycle. Σ = ci = {xi−i1, xiδi } i=1 , where δi = i = 1, υ(ci) ∩
υ(ci+1) = {xi}, and ci1 = ci2 whenever i1 ≡ i2 mod m, hence x1 = xm. Let Σ =
{c1, ..., cm−1}, then: µ(Σ ) = µm−1 = Fm+2 for theorem 1. As m = δm = 1 then
µ(X) = µ(Σ ∧(x1)∧(xm−1)) which is computed by the series: (α1, β1) = (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          ) =
(F0, F1) since (x1) ∈ X, (α2, β2) = (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) = (F1, F0); (α3, β3) = (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) = (F2, F1);
(α4, β4) = (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) = (F3, F2); and in general (αi, βi) = (Fi, Fi−1), then for the
variable xm−1, (αm−1, βm−1) = (Fm−1, Fm−2), then µ(X) = βm−1 = Fm−2
since (xm) ∈ X. Finally, #SAT (Σ) = µ(Σ) = µ(Σ ) − µ(X) = Fm+2 − Fm−2.
Thus, the following theorem holds.
        </p>
        <p>Theorem 2 Let Σ be a monotone 2-CF with m clauses and where GΣ is a
simple cycle, then: #SAT (Σ) = Fm+2 − Fm−2.</p>
        <p>Example 2 Let Σ = {ci}i6=1 = {{x1, x2}, {x2, x3}, {x3, x4}, {x4, x5}, {x5, x6},
{x6, x1}} be a monotone 2-CF which represents the cycle GΣ=(V ,E), see Figure
1. Let G = (V, E ) where E = E ∪ {c6}, that is, the new graph G is Σ minus
the edge c6. Applying theorem 2, #SAT (Σ) = F7 + F5 = 13 + 5 = 18</p>
      </sec>
      <sec id="sec-3-3">
        <title>Case C:</title>
        <p>Let GΣ = (V, E) be a tree. As GΣ Notice that since GΣ is a tree, all of its edges
are tree edges and, there are no back edges. We denote with (αv, βv) the
associated pair to a node v (v ∈ GΣ ). We compute #SAT (Σ) while we are traversing
GΣ in depth-first search.</p>
        <p>
          Algorithm Count Models for trees(AΣ )
Input: AΣ the tree defined by a depth-first search over GΣ
Output: The number of models of Σ
Procedure: Traversing AΣ in depth-first, and when a node v ∈ AΣ is left,
assign:
1. (αv, βv) = (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) if v is a leaf node in AΣ .
2. If v is a father node with a list of child nodes associated, i.e., u1, u2, ..., uk
are the child nodes of v, then as we have already visited all child nodes, then
each pair (αuj , βuj ) j = 1, ..., k has been defined based on (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ). (αvi , βvi ) is
obtained by applying (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ) over (αi−1, βi−1) = (αuj , βuj ). This step is iterated
k
j=1 αvj
until computes the values (αvj , βvj ), j = 1, ..., k. Finally, let αv =
and βv = jk=1 βvj .
3. If v is the root node of AΣ then returns(αv + βv).
        </p>
        <p>This procedure returns the number of models for Σ in time O(n + m) which
is the necessary time for traversing GΣ in depth-first search.</p>
        <p>Notice that the combination of the procedure for trees and the processing
of cycles (equation 3) can be applied for computing #SAT (Σ) if GΣ is a
graph where the depth-first search generates a tree and a set of independent
fundamental cycles.</p>
        <p>Thus, the procedures presented in this section, for computing #SAT (Σ)
being Σ a cycle, a path, a tree, or a tree union independent cycles, each one
runs in linear time over the size of the graph.</p>
        <p>The class of Boolean formulas Σ depth-first search builds a tree and a set
of fundamental independent cycles conforms a new polynomial instances for
#2-SAT. This class of instances is a superclass of (2, 2µ)-CF, and it has not
restrictions over the number of occurrences of a variable in the formulas, although
(2, 3µ)-CF is a #P -complete problem.</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Processing Embedded Cycles</title>
      <p>Given a constrained graph GΣ of a Boolean formula Σ, if GΣ contains some
intersected cycles, we look at if those cycles can be considered as embedded
cycles, see figure 2. It is possible that some cycles can be expressed as embedded
cycles although they are not initially recognized as such.</p>
      <p>In order to recognize when two cycles Ci and Cj can be expressed as
embedded cycles, we use the or-exclusive operation. Given two intersected cycles Ci,
Cj of a graph we say that Ci can be embedded into Cj, if:
a)V (Ci) ⊂ V (Cj) : the set of nodes of Ci is a subset of the nodes of Cj.
b)|E(Ci) − E(Cj)| = 1 : there is only one edge from Ci which is not edge of Cj.
c)Ci ⊕ Cj = Ck : being Ck a new cycle distinct to Ci and Cj and ⊕ is the
or-exclusive operation between the edges of the cycles.</p>
      <p>If the cycles Ci and Cj hold the previous three conditions, we say that Ci is
an internal embedded cycle of Cj while Cj is an external embedded cycle of Ci.
Notice that the embedded property can be extended to a set of embedded cycles.
Let D = (C1, C2, . . . , Ck) be a tuple of cycles of GΣ such that Ci is embedded in
Ci+1, i = 1, . . . , k − 1, then we say that C1 is the most internal embedded cycle
of D while Ck is the most external cycle of D.</p>
      <p>Given a tuple of embedded cycles D = (C1, C2, . . . , Ck), we present in this
section how to compute #SAT (D). First, the order of processing is from the most
internal embedded cycle to the most external embedded cycle. The beginning
of the processing of each cycle starts for traversing a cycle in depth-first order,
visiting the nodes of the cycle as a path from its initial node v0 to its end node
vf .</p>
      <p>Three computing threads are used for carry on the values of the number of
models for each node which is visted during the depht-first search. So, a
computing thread is a sequence of pairs (αi, βi), i = 1, ...m used for computing the
number of models over a path of m nodes. A main thread, denoted by Lp, is
associated to the spanning tree of the graph, this thread is always active during
all the counting process.</p>
      <p>9
103
6
5
1
2
3
4
7
8
11</p>
      <sec id="sec-4-1">
        <title>Case 1: Processing an Internal Embedded Cycle</title>
        <p>
          Consider that we are processing the most internal cycle C1 of a tuple D =
(C1, C2, . . . , Ck) of embedded cycles. We starts the depht-first search in the first
node of the path defined by the cycle C1 and assigning the values (α10, β01) =
(
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) to the main computing thread, the second thread starts with the values
(α20, β02) = (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) indicating that this thread carry on the number of models of C1
where the first variable x0 does not appear while the third thread starts with the
pair (α30, β03) = (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          ) indicating that this thread carry on the number of models
of C1 where the first variable x0 appears.
        </p>
        <p>
          We traverse by C1 as a path from its initial node v0 to its end node vf .
Each time that a new node of the path in C1 is visited, the recurrence (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ) is
applied, obtaining: (αi, βi) → (αi+1, βi+1). When the search arrives to the end
node of the cycle, we have obtained the pairs (αf1 , βf1), (αf2 , βf2) and (αf3 , βf3)
corresponding with the final pairs of the three different computing threads. Finally,
for processing the back edge in C1 we use the temporal variables αC1 and βC1
defined as: αC1 = α1 , βC1 = βf1 − β3, and the numbers of models for the internal
f f
cycle C1, is: #SAT (C1) = αC1 + βC1.
        </p>
      </sec>
      <sec id="sec-4-2">
        <title>Case 2: Processing an External Embedded Cycle</title>
        <p>If a current cycle Ci is embedded into other Cj , the pairs (αf2 , βf2) and (αf3 , βf3)
corresponding to the threads for processing Ci are used for processing the
external cycle Cj . Furthermore, after to process Ci, all the cycle is contracted into a
single node Crsf where s is the number of the initial node and f is the number
of the final node of the path in Ci. Then, the new node Crij is now part of the
path contained in the cycle Cj (see figure 4).</p>
        <p>
          We use the three threads for processing the external cycle Cj, as it was
explained previously. The depth-first search is applied over the path defined by
Cj and the recurrence (
          <xref ref-type="bibr" rid="ref2">2</xref>
          ) is applied over each node of the path until arrive
to the node Crsf . When a computing thread arrive to Crsf , each current pair
(αix, βxi), i = 1, 2, 3 is updated according to the following recurrence.
        </p>
        <p>αix+1 = αf2 ∗ αix + αf3 ∗ βxi
βx+1 = βf2 ∗ αix + βf ∗ βxi, for i = 1, 2, 3.</p>
        <p>
          i 3
(
          <xref ref-type="bibr" rid="ref4">4</xref>
          )
        </p>
        <p>
          Obtaining then the new pairs (αix+1, βxi+1), for i = 1, 2, 3. We will denote the
application of the recurrence (
          <xref ref-type="bibr" rid="ref4">4</xref>
          ) as (αx, βx) (αx+1, βx+1).
        </p>
        <p>How it exists an implicit back edge into the contracted node Crsf then we
have to update only the pair (α1x+1, βx1+1) as (α1x+1, βx1+1) = (α1x+1, βx1+1 −
β1</p>
        <p>x ∗ βf3). We will denote the processing of a back edge as , then (αx, βx)
(αx+1, βx+1) meaning the application of the formula (αx+1, βx+1) = (αx+1, βx+1−
βx ∗ βf2).</p>
        <p>The processing of the current cycle continues as in the Case 1 until arrives
to the final node vf of the external cycle Cj . Obtaining new current values for
(αf1 , βf1),(αf2 , βf2),(αf3 , βf3). We illustrate in figures 2-5 how to process a set of
embedded cycles.</p>
        <p>Example 3 Let Ge be a graph with embedded cycles (see Figure 2), applying the
case 1 for processing the internal cycle from node 1 to node 4, we obtain the new
node Cr14. In Figure 4, appears a new graph G2 which contains a cycle from
node 6 to node 8, this cycle has a Cr14 as an internal node. Applying the case
2 the graph G3 is obtained (see Figure 5). This graph has the node Cr68 which
comes from the contracted cycle G2. And again, the case 2 is applied obtaining
the value for #SAT (Ge).</p>
        <p>1
2
3</p>
        <p>4
Nodes : Node1 Node2 Node3 Node4</p>
        <p>
          Lp : (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) → (
          <xref ref-type="bibr" rid="ref3 ref5">5, 3</xref>
          ) = (α41, β41)
L1 ∈/ S : (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) = (α42, β42)
L2 ∈ S : (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) = (α43, β43)
        </p>
        <p>
          ⇒ (
          <xref ref-type="bibr" rid="ref3 ref5">5, 3</xref>
          ) − (
          <xref ref-type="bibr" rid="ref2">0, 2</xref>
          ) = (
          <xref ref-type="bibr" rid="ref2 ref5">5, 2</xref>
          )
Suppose that we want to process the graph G on Figure 6, the depth-first search
over G builds the graph on Figure 7, which has to be processed (count the number
of models) as it is illustrated in the same figure. But, if the graph G were reduced
to the equivalent graph on Figure 8, then the number of computing threads
is smaller. Furthermore, we can apply the procedure for processing embedded
6 - 8
G3 N ode9 N ode10 N ode6−8
Lp : (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) (84, 50)
L1 ∈/ S : (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) (52, 31)
L2 ∈ S : (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) (32, 19)
⇒ (120, 84) − (0, 32) = (120, 52)
(84, 36) →
(52, 24) →
(32, 12) →
        </p>
        <p>N ode11
(120, 84) = (α111, β111)
(76, 52) = (α121, β121)
(44, 32) = (α131, β131)</p>
        <p>Fig. 7. Computing #SAT (GΣ) with intersected cycles
cycles as it was explained previously. We design a polynomial reduction whose
main purpose is to translate some intersected cycles as set of embedded cycles.
This polynomial graphical reduction is sketching in the following procedure.</p>
      </sec>
      <sec id="sec-4-3">
        <title>Procedure Graph Reduction</title>
        <p>Input: The graph TG = df s(G) and the set C = {C1, C2, ..., Ck} containing the
fundamental cycles of the graph G.</p>
        <p>Output: An equivalent graph to TG where some of its fundamental cycles were
redrawn as embedded cycles.</p>
        <p>Procedure:
1. for i = 1 to k
(a) If not (Ci is intersected with other cycle Cj ∈ C and Ci and Cj are not
embedded and |E(Ci) ∩ E(Cj)| = 1) then continue
(b) /* in other case apply reduction * /
i. Choose the node vs which is incident to the back edge of Ci and to
the common edge e between Ci and Cj
ii. Redraw Cj starting with the node vs and its edge which is not in
E(Ci). The cycle Cj is redrawed being the last redrawing edge: e
(the common edge between Ci and Cj).
iii. From the last node vf of Cj, now we redrawing Ci using its incident
edge which is not e. All the nodes and edges of Ci are redrawing
being the back edge of Ci the last redrawing edge.</p>
        <p>The original common edge e is translated now as a back edge.
(c) Continue</p>
        <p>C1
5</p>
        <p>C2
3
6
4
1</p>
        <p>
          2
G2 Node3 Node6 Node5
Lp : (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) →
L1 ∈/ S : (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) →
L2 ∈ S : (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) → (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) →
⇒ (
          <xref ref-type="bibr" rid="ref3 ref5">5, 3</xref>
          ) − (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          ) = (
          <xref ref-type="bibr" rid="ref2 ref5">5, 2</xref>
          )
G3 Node3−4
Lp : (
          <xref ref-type="bibr" rid="ref1 ref1">1, 1</xref>
          ) (
          <xref ref-type="bibr" rid="ref3 ref5">5, 3</xref>
          ) (
          <xref ref-type="bibr" rid="ref2 ref5">5, 2</xref>
          ) →
L1 ∈/ S : (
          <xref ref-type="bibr" rid="ref1">1, 0</xref>
          ) (
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) (
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) →
L2 ∈ S : (
          <xref ref-type="bibr" rid="ref1">0, 1</xref>
          ) (
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) (
          <xref ref-type="bibr" rid="ref2">2, 0</xref>
          ) →
⇒ (
          <xref ref-type="bibr" rid="ref7">12, 7</xref>
          ) − (
          <xref ref-type="bibr" rid="ref2">0, 2</xref>
          ) = (
          <xref ref-type="bibr" rid="ref5">12, 5</xref>
          )
        </p>
        <p>
          Node4
(
          <xref ref-type="bibr" rid="ref3 ref5">5, 3</xref>
          ) = (α41, β41)
(
          <xref ref-type="bibr" rid="ref2 ref3">3, 2</xref>
          ) = (α42, β4 )
        </p>
        <p>
          2
(
          <xref ref-type="bibr" rid="ref1 ref2">2, 1</xref>
          ) = (α43, β4 )
        </p>
        <p>
          3
Node1
(
          <xref ref-type="bibr" rid="ref5 ref7">7, 5</xref>
          ) →
(
          <xref ref-type="bibr" rid="ref3 ref5">5, 3</xref>
          ) →
(
          <xref ref-type="bibr" rid="ref2 ref2">2, 2</xref>
          ) →
        </p>
        <p>
          Node2
(
          <xref ref-type="bibr" rid="ref7">12, 7</xref>
          ) = (α21, β21)
(
          <xref ref-type="bibr" rid="ref5 ref8">8, 5</xref>
          ) = (α22, β2)
        </p>
        <p>
          2
(
          <xref ref-type="bibr" rid="ref2 ref4">4, 2</xref>
          ) = (α23, β2)
3
        </p>
        <p>Fig. 8. Applying the method for embedded cycles for computing #SAT (G)
This reduction is helping for pre-processing cycles of G, since we have
translated the maximum number of intersected cycles as embedded cycles before to
apply the algorithm for counting models over embedded cycles.
5.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Conclusions</title>
      <p>We present different efficient procedures to compute #SAT for subclasses of
2-CF. Let Σ be a 2-CF where GΣ (the constrained undirected graph of Σ) is
acyclic or, if GΣ contains cyles they can be drawn as independent cycles and
embedded cycles, in all those cases, we show that #SAT (Σ) is computed in
polynomial time over the length of the formula Σ.</p>
      <p>We also show how to detect if a set of cycles can be embedded one into
other. Furthermore, we design a polynomial reduction for given two restricted
intersected cycles redraw those as embedded cycles.</p>
      <p>The efficient methods presented here can be adapted for solving other
counting problems and then, to incide directly over the complexity time of those
problems.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Creignou</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hermann</surname>
            <given-names>M.</given-names>
          </string-name>
          ,
          <source>Complexity of Generalized Satisfiability Counting Problems, Information and Computation</source>
          <volume>125</volume>
          , (
          <year>1996</year>
          ),
          <fpage>1</fpage>
          -
          <lpage>12</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Darwiche</given-names>
            <surname>Adnan</surname>
          </string-name>
          ,
          <article-title>On the Tractability of Counting Theory Models and its Application to Belief Revision and Truth Maintenance, Jour</article-title>
          . of Applied Non-classical
          <string-name>
            <surname>Logics</surname>
          </string-name>
          ,
          <volume>11</volume>
          (
          <issue>1-2</issue>
          ), (
          <year>2001</year>
          ),
          <fpage>11</fpage>
          -
          <lpage>34</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3. De Ita G.,
          <article-title>Polynomial Classes of Boolean Formulas for Computing the Degree of Belief</article-title>
          ,
          <source>Advances in Artificial Intelligence LNAI 3315</source>
          ,
          <year>2004</year>
          ,
          <fpage>430</fpage>
          -
          <lpage>440</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. De Ita G.,
          <string-name>
            <surname>Tovar</surname>
            <given-names>M.</given-names>
          </string-name>
          , Applying Counting Models of Boolean Formulas to Propositional Inference,
          <source>Advances in Computer Science and Engineering</source>
          , Vol
          <volume>19</volume>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5. De Ita G.,
          <string-name>
            <surname>Contreras</surname>
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>A Polynomial</given-names>
            <surname>Graphical</surname>
          </string-name>
          <article-title>Reduction to Speed Up the Counting of Models for Boolean Formulas</article-title>
          ,
          <source>Proc. of the Workshop in Logic, Language and Computation, CEUR Workshop Proceedings</source>
          , Vol.
          <volume>220</volume>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Harry</surname>
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Hunt</surname>
          </string-name>
          ,
          <string-name>
            <surname>Madhav</surname>
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Marathe</surname>
          </string-name>
          , Venkatesh Radhakrishnan, Richard E. Stearn,
          <article-title>The complexity of planar counting problems</article-title>
          ,
          <source>SIAM Journal on Computing</source>
          ,
          <volume>27</volume>
          (
          <issue>4</issue>
          ):
          <fpage>1142</fpage>
          -
          <lpage>1167</lpage>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. Johnson David S.,
          <string-name>
            <surname>The NP-Completeness</surname>
            <given-names>Column</given-names>
          </string-name>
          :
          <article-title>An Ongoing Guide</article-title>
          ,
          <source>J. Algorithms 3</source>
          ,
          <year>1982</year>
          , pp.
          <fpage>89</fpage>
          -
          <lpage>99</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Roth</surname>
            <given-names>D.</given-names>
          </string-name>
          ,
          <article-title>On the hardness of approximate reasoning</article-title>
          ,
          <source>Artificial Intelligence 82</source>
          , (
          <year>1996</year>
          ),
          <fpage>273</fpage>
          -
          <lpage>302</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Russ</surname>
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Randomized</surname>
            <given-names>Algorithms</given-names>
          </string-name>
          : Approximation, Generation, and
          <string-name>
            <surname>Counting</surname>
          </string-name>
          , Distingished dissertations Springer,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Vadhan Salil</surname>
            <given-names>P.</given-names>
          </string-name>
          , The complexity of Counting in Sparse, Regular, and Planar Graphs,
          <source>SIAM Journal on Computing</source>
          , Vol.
          <volume>31</volume>
          , No.
          <volume>2</volume>
          , (
          <year>2001</year>
          ),
          <fpage>398</fpage>
          -
          <lpage>427</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>