An Efficient Algorithm for Solving the 2-MAXSAT Problem

: In the maximum satisfiability (MAXSAT) problem, we are given a set V of m variables and a collection C of n clauses over V . We will seek a truth assignment to maximize the number of satisfied clauses. This problem is NP -hard even for its restricted version, the 2-MAXSAT problem, in which every clause contains at most two literals. In this paper, we discuss an efficient algorithm to solve this problem. Its worst-case time complexity is bounded by 2 log 2 3 2 O( (log ) ). nm n m nm In the case that log 2 nm is bounded by a constant, our algorithm is a polynomial algorithm. In terms of Garey and Johnson, any satisfiability instance can be transformed to a 2-MAXSAT instance in polynomial time. Thus, our algorithm may lead to a proof of P = NP .


Introduction
The satisfiability problem is perhaps one of the most well-studied problems that arise in many areas of discrete optimization, such as artificial intelligence, mathematical logic, and combinatorial optimization, to name a few.Given a set V of Boolean (true/false) variables and a collection C of clauses over V, or, say, a logic formula in CNF (conjunctive normal form), the satisfiability problem is to determine if there is a truth assignment that satisfies all clauses in C [1].The problem is NP-complete even when every clause in C has at most three literals [2].The maximum satisfiability (MAXSAT) problem is an optimization version of satisfiability that seeks a truth assignment to maximize the number of satisfied clauses [3].This problem is NP-hard even for its restricted version, the so-called 2-MAXSAT problem, in which every clause in C has at most two literals [4].Its application can be seen in an extensive bibliography [5][6][7][8][9][10].
Over the past several decades, a lot of research on the MAXSAT has been conducted.Almost all of them are the approximation methods [3,7,[11][12][13]21], such as (1-1/e)-approximation and 3/4-approximation [7], as well as the method based on integer linear programming [9].The only algorithms for an exact solution are discussed in [20,21].The worst-case time complexity of [21] is bounded by O(b 2 2 m ), where b is the maximum number of occurrences of any variable in the clauses of C, while the worst-case time complexity of [20] is bounded by max{O(2 m ), O * (1.2989 n )}.Both algorithms use the traditional branch-and-bound method to solve the satisfiability problem.Its main idea is to search for a solution by letting a variable (or a literal) be 1 or 0. In terms of [7], any algorithm based on branch-and-bound runs in O*(c m ) time with c ≥ 2.
In this paper, we discuss an efficient algorithm to solve the 2-MAXSAT problem, working in a quite different way.
Its time complexity is bounded by 2 log 2 3 2 O( (log ) ), nm n m nm where n and m are the number of clauses and the number of variables in C, respectively.In the case that log 2 nm is bounded by a constant, the time complexity of our algorithm is polynomial.In terms of Garey and Johnson [8], any satisfiability instance can be transformed to a 2-MAXSAT instance in polynomial time.This shows a possibility of proving P = NP.For example, for a large problem with n = 32 and m = 64, 2 log 11 2 log 11 nm nm = is still a manageable constant.But the running time of any existing method is > O(2 64 ), which is obviously prohibitively high.
The main idea behind our algorithm can be summarized as follows: 1) Given a collection C of n clauses over a set of variables V, each containing at most two literals, construct a formula D over another set of variables U, but in DNF (disjunctive normal form), containing 2n conjunctions with each of them having at most two literals, such that there is a truth assignment for V that satisfies at least n* ≤ n clauses in C if and only if there is a truth assignment for U that satisfies at least n* conjunctions in D.
2) For each D i in D i (i ∈ {1, ..., n}) , construct a graph called a p*-graph to represent all those truth assignments σ of variables such that under σ D i evaluates to true.
3) Organize the p*-graphs for all D i 's into a trie-like graph G. Searching G bottom up, we can find a maximum subset of satisfied conjunctions in an almost polynomial time.
The organization of the rest of this paper is as follows: First, in Section 2, we restate the definition of the 2-MAXSAT problem and show how to reduce it to a problem that seeks a truth assignment to maximize the number of satisfied conjunctions in a formula in DNF.Then, we discuss our algorithm in Section 3. Section 4 is devoted to the analysis of the time complexity of the algorithm.Finally, a short conclusion is set forth in Section 5.

2-MAXSAT problem
We will deal solely with Boolean variables (that is, those that are either true or false), which we will denote by c 1 , c 2 , etc.A literal is defined as either a variable or the negation of a variable (e.g., 7 11 , c c ¬ are literals).A literal i c ¬ is true if the variable c i is false.A clause is defined as the OR of some literals, written as 1 2 ( .... ) We say that a Boolean formula is in CNF if it is presented as an AND of clauses: 1 ... ( 1). .
Finally, the MAXSAT problem is to find an assignment to the variables of a Boolean formula in CNF such that the maximum number of clauses are set to true or are satisfied.Formally: ≤ literals (i = 1, ..., n), and a positive integer n* ≤ n. • Question: Is there a truth assignment for V that satisfies at least n* clauses?In other words, we will find a maximum integer j such that j clauses in C can be satisfied under a certain truth assignment : max{ | j k σ = there exists σ such that k clauses in C are satisfied under σ }.
To find a truth assignment σ such that the number of clauses set to true is maximized under σ , we can try all the possible assignments and count the satisfied clauses as discussed in [16].We may also use a heuristic method to find an approximate solution to the problem, as described in [8].
In this paper, we propose a quite different method, by which, for we will consider another formula D in DNF constructed as follows.Let , where c i1 and c i2 denote either variables in V or their negations.For C i , define a variable x i .and a pair of conjunctions: D i1 , D i2 , where Concerning the relationship of C and D, we have the following proposition.Proposition 1 Let C and D be a formula in CNF and a formula in DNF defined above, respectively.No less than n* clauses in C can be satisfied by a truth assignment for V if and only if no less than n* conjunctions in D can be satisfied by some truth assignment for V X ∪ .Proof.Consider every pair of conjunctions in : ∧ and 2 2 ( {1,..., }).Then, similar to Theorem 1 of [11], we can find a truth assignment σ for D satisfying the following condition: For each C j = c j1 ∨ c j2 ( j = 1, ..., p), if c j1 is true and c j2 is false under σ , (1) set both c j1 and x j to true for σ .If c j1 is false and c j2 is true under σ , (1) set both c j2 to true, but x j to false for σ .If both c j1 and c j2 are true, do (1) or (2) arbitrarily.
Obviously, we have at least n* conjunctions in D satisfied under σ ."⇐" We now suppose that a truth assignment σ for D with q ≥ n* conjunctions in D is satisfied.Again, assume that those q conjunctions are Then, we can find a truth assignment σ for C satisfying the following condition: For each ( 1,..., ), j jb D j q = ( j = 1, ..., q), if b j = 1, set c j1 to true for σ ; if b j = 2, set c j2 to true for σ .Clearly, under σ , we have at least n* clauses in C satisfied.The above discussion shows that the proposition holds.
Proposition 1 demonstrates that the 2-MAXSAT problem can be transformed, in polynomial time, into a problem to find the maximum number of conjunctions in a logic formula in DNF.As an example, consider the following logic formula in CNF: (1) Under the truth assignment  }, C evaluates to true, i.e., C i = 1 for i = 1, 2, 3. Thus, n* = 3.For C, we will generate another formula, D, but in DNF, according to the above discussion: ( ) ( ) According to Proposition 1, D should also have at least n* = 3 conjunctions that evaluate to true under some truth assignment.On the other hand, if D has at least three satisfied conjunctions under a truth assignment, then C should have at least three clauses satisfied by some truth assignment, too.In fact, it can be seen that under the truth assignment, { } In the following, we will discuss an almost polynomial time algorithm to find a maximum set of satisfied conjunctions in any logic formula in DNF, not only restricted to the case that each conjunction contains up to two conjuncts.

Algorithm description
In this section, we discuss our algorithm.First, we present the main idea in Section 3.1.Then, in Section 3.2, a recursive algorithm for solving the problem is described in great detail.The running time of the algorithm will be analyzed in the next section.

Main idea
To develop an efficient algorithm to find a truth assignment that maximizes the number of satisfied conjunctions in a formula In this way, the above D can be rewritten as a new formula in DNF as follows: ,* Doing this enables us to represent each D i as a variable sequence, but with all the negative literals removed.It is because if the variable in a negative literal is set to true, the corresponding conjunction must be false.
See Table 1 for illustration.
First, we pay attention to the variable sequence for D 2 (the second sequence in the second column of Table 1), in which the negative literal 4 c ¬ (in D 2 ) is eliminated.In the same way, you can check all the other variable sequences.Now it is easy for us to compute the appearance frequencies of different variables in the variable sequences, by which each (c, *) is counted as a single appearance of c while any negative literals are not considered, as illustrated in Table 2, in which we show the appearance frequencies of all the variables in the above D.
According to the variable appearance frequencies, we will impose a global ordering over all variables in D such that the most frequent variables appear first, but with ties broken arbitrarily.For instance, for the D shown above, we can specify a global ordering like this: 2

Conjunction
Variable sequences Sorted variable sequences Following this general ordering, each conjunction D i in D can be represented as a sorted variable sequence, as illustrated in the third column of Table 1, where the variables in a sequence are ordered in terms of their appearance frequencies, such that more frequent variables appear before less frequent ones.In addition, a start symbol # and an end symbol $ are used as sentinels for technical convenience.In fact, any global ordering of variables works well (i.e., you can specify any global ordering of variables), based on which a graph representation of assignments can be established.However, ordering variables according to their appearance frequencies can greatly improve efficiency when searching the trie (to be defined in the next subsection) constructed over all the variable sequences for conjunctions in D.
Later on, by variable sequence, we always mean a sorted variable sequence.Also, we will use D i and the variable sequence for D i interchangeably without causing any confusion.
In addition, for our algorithm, we need to introduce a graph structure to represent all those truth assignments for each D i (i = 1, …, n) (called a p*-graph), under which D i evaluates to true.In the following, however, we first define the simple concept of p-graphs for ease of explanation.
Definition 1 (p-graph).Let be a variable sequence representing a D i in D as described above (with A p-graph over α is a directed graph in which there is a node for each ( 0, ..., 1) + and an edge for 1 ( , ) In addition, there may be an edge from c j to c j+2 for each {0,..., 1} is a pair of the form (c, *), where c is a variable name.
In Figure 1(a), we show such a p-graph for 1 , , v v v < > for the span connecting v 6 and v 7 .By using spans, the meaning of '*'s (it is either 0 or 1) is appropriately represented since along a span we can bypass the corresponding variable (then its value is set to 0), while along an edge on the main path we go through the corresponding variable (then its value is set to 1).In fact, what we want is to represent all those truth assignments for each D i (i = 1, …, n) in an efficient way, under which D i evaluates to true.However, p-graphs fail to do so since when we go from a node v to another node u through a span, u must be selected.If u represents a (c, *) for some variable name c, the meaning of this '*' is not properly rendered.It is because (c, *) indicates that c is optional, but going through a span from u to (c, *) makes c always selected.So, the notation (c, *), which is used to indicate that c is optional, is not correctly implemented.
For this reason, we introduce another concept, p*-graphs, described as below.
Here, we notice that if we had one more span, < v 3 , v 4 , v 5 >, for example, it would be connected to < v 1 , v 2 , v 3 > but not overlapped with < v 1 , v 2 , v 3 >.Being aware of this difference is important since the overlapped spans imply the consecutive '*'s, just like < v 1 , v 1 , v 2 > and < v 1 , v 2 , v 3 >, which correspond to two consecutive '*'s: (c 2 , *) and (c 3 , *).Therefore, the overlapped spans exhibit some kind of transitivity.That is, if s 1 and s 2 are two overlapped spans, the s 1 ∪ s 2 must be a new but bigger span.Applying this operation to all the spans over a p-path, we will get a 'transitive closure' of overlapped spans.Based on this observation, we give the following definition.
Definition 2 (p*-graph).Let P be a p-graph.Let p be its main path, and S be the set of all spans over p. Denote by S* the 'transitive closure' of S.Then, the p*-graph with respect to P is the union of p and S*, denoted as * *.P p S = ∪ In Figure 1(b), we show the p*-graph with respect to the p-graph shown in Figure 1(a).Concerning p*-graphs, we have the following lemma.
Lemma 1 Let P* be a p*-graph for a conjunction D i (represented as a variable sequence) in D.Then, each path from # to $ in P* represents a truth assignment, under which D i evaluates to true.
Proof.(1) Corresponding to any truth assignment σ , under which D i evaluates to true, there is definitely a path from # to $ in p*-path.First, we note that under such a truth assignment, each variable in a positive literal must be set to 1, but with some '*'s set to 1 or 0. Especially, we may have more than one consecutive '*'s that are set 0, which are represented by a span that is the union of the corresponding overlapped spans.Therefore, for σ , we must have a path representing it.
(2) Each path from # to $ represents a truth assignment, under which D i evaluates to true.To see this, we observe that each path consists of several edges on the main path and several spans.Especially, any such path must go through every variable in a positive literal since for each of them there is no span covering it.But each span stands for a '*' or more than one successive '*'s.

Algorithm
To find a truth assignment to maximize the number of satisfied s j D′ in D, we will first construct a trie-like structure G over D and then search G bottom-up to find answers.
Let 1 2 *, *,..., * n P P P be all the p*-graphs constructed for all s j D′ in D, respectively.Let p j and S j * ( j = 1, ..., n) be the main path of P j * and the transitive closure over its spans, respectively.We will construct G in two steps.In the first step, we will establish a trie [13], denoted as T = trie(R) over R = {p 1 , ..., p n }, as follows.
If |R| = 0, trie(R) is, of course, empty.For |R| = 1, trie(R) is a single node.If |R| > 1, R is split into m (possibly empty) subsets R 1 , R 2 , ..., R m so that each R i (i = 1, …, m) contains all those sequences with the same first variable name.The tries: trie(R 1 ), trie(R 2 ), ..., trie(R m ) are constructed in the same way except that at the kth step, the splitting of sets is based on the kth variable name (along with the global ordering of variables).They are then connected from their respective roots to a single node to create trie(R).
In Figure 2, we show the trie constructed for the variable sequences given in the third column of Table 1.In such a trie, special attention should be paid to all the leaf nodes, each labelled with $, representing a conjunction (or a subset of conjunctions, which can be satisfied under the truth assignment represented by the corresponding main path.)The advantage of tries is to cluster common parts of variable sequences together to avoid possible repeated checking.(Then, this is the main reason why we sort variable sequences according to their appearance frequencies.)Especially, this idea can also be applied to the variable subsequences (as will be seen later), over which some dynamical tries can be recursively constructed, leading to an efficient algorithm.
Each edge in the trie is referred to as a tree edge.In addition, the variable c associated with a node v is referred to as the label of v, denoted as l(v) = c.Also, a node in T is said to be in a high position if it is close to the root.It is said to be in a low position if it is close to a leaf node.
Finally, we will associate each node v in the trie T with a pair of numbers ( pre, post) to speed up recognizing ancestor/descendant relationships of nodes in T, where pre is the order number of v when searching T in preorder and post is the order number of v when searching T in postorder.
These two numbers can be used to characterize the ancestor/descendant relationships in T as follows.
Let v and v′ be two nodes in T.Then, v′ is a descendant of v if pre(v′) > pre(v) and post(v′) < post(v).
For the proof of this property of any tree, see Exercise 2.3.220 in [12].For instance, by checking the label associated with v 2 against the label for v 9 in Figure 2, we see that v 2 is an ancestor of v 9 in terms of this property.Particularly, v 2 's label is (3,12) and v 9 's label is (10,6), and we have 3 < 10 and 12 > 6.We also see that since the pairs associated with v 14 and v 6 do not satisfy the property, v 14 must not be an ancestor of v 6 and vice versa.
In the second step, we will add all S i *(i = 1, …, n) to the trie T to construct a trie-like graph G, as illustrated in Figure 3.This trie-like graph is constructed for all the variable sequences given in Table 1, in which each span is associated with a set of numbers used to indicate what variable sequences the span belongs to.For example, the span 3) is associated with three numbers: 1, 5, and 6, indicating that the span belongs to three conjunctions: D 1 , D 5 , and D 6 .But no numbers are associated with any tree edges.From Figure 3, we can see that although the number of truth assignments for D is exponential, they can be represented by a graph with polynomial numbers of nodes and edges.In fact, in a single p*-graph, the number of edges is bounded by O(n 2 ).Thus, a trie-like graph over m p*-graphs has at most O(n 2 m) edges.
In the next step, we will search G bottom-up level by level to seek all the possible largest subsets of conjunctions that can be satisfied by a certain truth assignment.
First of all, we call each node in T with more than one child a branching node.For instance, node v 3 with two children v 4 and v 8 in G shown in Figure 3 is a branching node.For the same reason, v 2 and v 1 are another two branching nodes.Note that v 0 is not a branching node since it has one child in T (although it has more than one child in G).
Around the branching node, we have two very important concepts defined as follows.Definition 3 (reachable subsets through spans).Let v be a branching node.Let u be a node on the tree path from root to v in G (not including v itself).A reachable subset of u through spans is all those nodes with the same label c in different subgraphs in G[v] (the subgraph rooted at v) and reachable from u through a span, denoted as [ ].
v u RS c For instance, v 3 in Figure 3 is a branching node.With respect to v 3 , node v 2 on the tree path from root to v 3 has two reachable subsets: [ ] { , },

RS c v v =
We have The definition of this concept for a branching node v itself is a little bit different from any other node on the tree path (from root to v).Specifically, each of its RSs is defined as a subset of nodes reachable from a span or from a tree edge.So, for v 3 , we have: respectively, due to Based on the concept of reachable subsets through spans, we are able to define another more important concept, upper boundaries, given below.
Definition 4 (upper boundaries).Let v be a branching node.Let v 1 , v 2 , …, v k be all the nodes on the path from root to v.An upper boundary (denoted as upBounds) with respect to v is the largest subset of nodes {u 1 , u 2 , …, u f } with the following properties satisfied: 1) Each ( 1) where c is a label.2) For any two nodes , ( ), they are not related by the ancestor/descendant relationship.Figure 4 gives an intuitive illustration of this concept.As a concrete example, consider v 5 and v 8 in Figure 3.They make up an upBound with respect to v 3 (a branching node).Then, we will construct a trie-like graph over two p*subgraphs, starting from v 5 and v 8 , respectively.This can

Contemporary Mathematics
be done by a recursive call of the algorithm itself.Here, however, v 4 is not included since the truth assignment with v 4 being set to true satisfies only the conjunctions associated with leaf node v 10 .This has already been determined when the initial trie is built up.In fact, the purpose of upper boundaries is to remove all those nodes like v 4 from the subsequent computation.
Specifically, the following operations will be carried out when encountering a branching node v.
• Calculate all RSs with respect to v.
• Calculate the upBound in terms of RSs.
• Make a recursive call of the algorithm over all the subgraphs within G [v], each rooted at a node on the corresponding upBound.
The following example helps with illustration.
Example 1 When checking the branching node v 3 in the bottom-up search process, we will calculate all the reachable subsets through spans with respect to v 3 as described above.They are .In terms of these reachable subsets through spans, we will get the corresponding upBound {v 5 and v 8 }.Node v 4 (above the upBound) will not be involved.Therefore, it will not be further considered in the recursive execution of the algorithm.
Concretely, when we make a recursive call of the algorithm, applied to two subgraphs: G 1 -rooted at v 5 , and G 2rooted at v 8 (shown in Figure 5(a)), we will first construct a trie-like graph as shown in Figure 5(b).Here, we notice that the subset associated with its unique leaf node is {D 2 and D 5 }, instead of {D 1 , D 2 , D 3 , and D 5 }.It is because the number associated with span v v  → is 2, and therefore D 2 associated with v 10 survives.
1, 2, 3 In the trie-like graph shown in Figure 5(b), v 5−8 stands for the merge of v 5 and v 8 ; v 6−9 for v 6 and v 9 ; and v 7−10 for v 7 and v 10 .By searching this graph, we will find the truth assignment satisfying {D 2 and D 5 }.This truth assignment is represented by a path consisting of two parts: the tree path from root to v 2 (see Figure 3), and the path from v 2 to v 7 , i.e., the span We remember that when generating the trie T over the main paths of the p*-graphs over the variable sequences shown in Table 1, we have already found a subset of conjunctions {D 1 , D 3 , and D 5 }, which can be satisfied by a truth assignment represented by the corresponding main path.This is larger than {D 2 and D 5 }.Therefore, {D 2 and D 5 } should not be kept around, and this part of the computation is futile.However, we can avoid this kind of useless work by performing a pre-check: if the number of p*-subgraphs over which the recursive call of the algorithm will be invoked is smaller than the size of the partial answer already obtained, the corresponding recursive call of the algorithm should not be conducted.This check can be extended to a very powerful heuristic: With each recursive call, we will examine whether the input subgraph has been checked before.If this is the case, the corresponding recursive call will be suppressed.
In terms of the above discussion, we design a recursive algorithm to do the task, in which R is used to accommodate the result, represented as a set of triplets of the form: , , , > where α stands for a subset of conjunctions, β for a truth assignment satisfying the conjunctions in α, and γ is the size of α.Initially, .R = ∅ Ø.The input of 2-MAXSAT( ) is a formula C in CNF.First, we transform it to another formula D in DNF (see line 1).Then, for each D i in D, we will create its p*-graph, * i P (see line 4).Next, we will construct a trie-like graph G over all * i P 's (see line 5).In the last step, we call SEARCH(G) to produce the result (see line 6).
The input of SEARCH( ) is a trie-like subgraph G. First, we will check whether G is a single p*-graph.If this is the case, we must have found the largest subset of conjunctions associated with the leaf node, satisfied by a truth assignment represented by a path consisting of two parts: the tree path from the root to the starting node v of the single p*-graph, and the main path from v to the leaf node of the single p*-graph.This subset should be merged into R (see lines [1][2][3][4]. Otherwise, we will search G bottom-up to find all the branching nodes in G.But before that, each subset of conjunctions associated with a leaf node in R will be first merged into R (see lines 5-7).
For each branching node v encountered, we will check all the nodes u on the tree path from root to v and compute their RSs (see lines [8][9][10][11][12], based on which we then compute the corresponding upBound with respect to v (see line 13).According to the upBound L, a trie-like graph D will be created over a set of subgraphs, each rooted at a node on L (see line 14).Then, v will be added to D as its root (see line 15).Here, we notice that ∪ is a simplified representation of an operation, in which we add not only v but also the corresponding edges to D. Next, a recursive call of the algorithm is made over D′ (see line 16).Finally, the result of the recursive call of the algorithm will be merged into the global answer (see line 17).
Here, the merge operation used in lines 3, 7, and 17 is defined as below.
Let R = {r 1 , …, r t } for some t ≥ 0 with each r i = < α i , β i , γ i >.We have By merge(R, R′), we will do the following checks. • For simplicity, the heuristics discussed above are not incorporated into the algorithm.But it can be easily extended with this operation included.
The following example helps with illustration.As with branching node v 3 , we need to calculate all the relevant reachable subsets through spans for all the nodes on the tree path from the root to v 2 in G. Altogether, we have five reachable subsets through spans.Among them, associated with v 1 (on the tree path from root to v 2 in Figure 3), we have

RS c v v =
due to the following two spans (see Figure 3): Associated with v 2 (the branching node itself), we have the following four reachable subsets through spans: Due to the following four groups of spans: In terms of the reachable subsets through spans, we can establish the corresponding upper boundary {v 4 , v 8 , and v 11 } (which is illustrated as a thick line in Figure 6).Then, we can determine, over what subgraphs a recursive execution of the algorithm will be conducted.
In Figure 7(a), we show the trie-like graph built over the three p*-subgraphs (starting, respectively, from v 4 , v 8 , and v 11 on the upBound shown in Figure 6), in which v 4-11 stands for the merging of v 4 and v 11 , and v 5-12 for the merging of v 5 and v 12 .Especially, v 2 itself needs to be involved as a branching node, working as a bridge between the newly constructed trie-like graph and the rest part of G.By a recursive call of SEARCH( ), we will construct this graph and then search this graph bottom up, by which we will find two branching nodes: v 5−12 and v 2 .By checking v 5-12 , we will find [$] { , }.
The corresponding upBound is {v 7 and v 13 }.Accordingly, we will find a single path as shown in Figure 7(b), by which we will find the largest subset of conjunctions {D 3 and D 6 }, which can be satisfied by a certain truth assignment.We notice that the subset associated with this path is {D 3 and D 6 }, instead of {D 3 , D 5 , and D 6 }.It is because the span from v 5−12 to v 7 (in Figure 7(a)) is labelled with 3, and D 5 should be removed.
By checking v 2 , we will have   In the whole working process, a simple heuristic can be used to improve efficiency.Let α be the size of the largest subset of conjunctions found up to now, which can be satisfied by a certain truth assignment.Then, any recursive call of the algorithm over a smaller than α subset of p*-subgraphs will be suppressed.
After v 2 is checked, the next branching node is v 1 , which will be handled in a way similar to v 3 and v 2 .

Time complexity analysis
The total running time of the algorithm consists of four parts.The first part, denoted as τ 1 , is the cost to transform The second part, denoted as τ 2 , is the time for computing the frequencies of variable appearances in D. Since in this process each variable in a D i is accessed only once, τ 1 = O(nm).
The third part, denoted as τ 3 , is the time for constructing a trie-like graph G for D. This part of time can be further partitioned into three portions.
• τ 31 : The time for sorting variable sequences for D i 's.It is obviously bound by O(nmlog 2 m).
• τ 32 : The time for constructing p*-graphs for each D i (i = 1, ..., n).Since for each variable sequence a transitive closure over its spans should be first created and needs O(m 2 ) time, this part of the cost is bounded by O(nm 2 ).
• τ 33 : The time for merging all p*-graphs to form a trie-like graph G, which is also bounded by O(nm 2 ).The fourth part, denoted as τ 4 , is the time for searching G to find a maximum subset of conjunctions satisfied by a certain truth assignment.It is a recursive procedure.To analyze its running time, therefore, a recursive equation should be established.Let l = nm.Assume that the average outdegree of a node in T is d.Then, the average time complexity of τ 4 can be characterized by the following recurrence: Here, in the above recursive equation, O(l 2 m) is the cost for generating all the reachable subsets of a node through spans and upper boundaries, together with the cost for generating local trie-like subgraphs for each recursive call of the algorithm.We notice that the size of all the RSs together is bounded by the number of spans in G, which is O(lm).
From (4), we can get the following inequality:  But we remark that if the average outdegree of a node in T is < 2, we can use a brute-force method to find the answer in polynomial time.Hence, we claim that the worst-case time complexity is bounded by

Conclusions
In this paper, we have presented a new method to solve the 2-MAXSAT problem.The time complexity of the algorithm is bounded by where n and m are, respectively, the numbers of clauses and variables of a logic formula C (over a set V of variables) in CNF, and d is the average outdegree of a node in a trie established over a set of conjunctions that are generated from the clauses in C. The main idea behind this is to construct a different formula D (over a set U of variables) in DNF, according to C, with the property that for a given integer n* ≤ n C has at least n* clauses satisfied by a truth assignment for V if and only if D has at least n* conjunctions satisfied by a truth assignment for U. To find a truth assignment that maximizes the number of satisfied conjunctions in D, a graph structure called p*-graph is introduced to represent each conjunction in D. In this way, all the conjunctions in D can be represented as a trie-like graph.Searching G bottom up, we can find the answer efficiently.
In our future work, we will make a detailed analysis of the impact of the heuristics discussed in Section 3.2.It seems that by using the heuristics, any repeated recursive call can be effectively avoided.If that is the case, the number of recursive calls for each branching node will be bounded by O(m) since the height of the trie-like graph G is bounded by O(m).Thus, the worst-case time complexity of our algorithm should be bounded by O(n 2 m 4 ).It is because we have at most O(nm) branching nodes, and for each recursive call, we need O(nm 2 ) time to construct a dynamical trie.So, the total running time will be O(nm) × O(m) × O(nm 2 ) = O(n 2 m 4 ).
an instance of the 2-MAXSAT problem defined over a variable set V and a collection C of n clauses, we can construct a logic formula D in DNF over the set V X ∪ in polynomial time, where { | 1,..., }. i = 1, ..., n}.D has m = 2n conjunctions.
Clearly, under any truth assignment for the variables in V X ∪ , at most one of D i1 and D i2 can be satisfied.If x i = true, we have D i1 = c i1 and D i2 = false.If x i = false, we have D i2 = c i2 and D i1 = false."⇒" Suppose there exists a truth assignment σ for C that satisfies p ≥ n* clauses in C. Without loss of generality, assume that the p clauses are C 1 , C 2 , ..., C p .
conjunctions: D 11 , D 21 , and D 31 , from which the three satisfied clauses in C can be immediately determined.

5 (
,*).( ,*). ..( ,*).( ,*).$.D c c c c c c =Beside a main path going through all the variables in D 1 , there are four off-path edges (edges not on the main path), referred to as spans attached to the main path, corresponding to 2 3 span is represented by the subpath covered by it.For example, we will use the subpath going three nodes: v 0 , v 1 , and v 2 ) to stand for the span connecting v 0

Figure 1 .
Figure 1.A p-path and a p*-path

Figure 2 .
Figure 2. A trie and tree encoding

Figure 3 .
Figure 3.A trie-like graph G

2 v
out of v 2 , respectively, reaching v 5 and v 8 on two different p*-graphs in 3[ ] G v with l(v 5 ) = l(v 8 ) = 'c 5 'l(v 6 ) = l(v 9 ) = 'c 6 '.In general, we are interested only in those RS's (reachable subsets through spans) with | | RS ≥ (since any RS with |RS| = 1 only leads us to a leaf node in T: no larger subsets of conjunctions can be found.)So, in the subsequent discussion, by an RS v , we mean an RS v with |RS v | ≥ 2. upBound

Figure 4 .
Figure 4. Illustration for upBounds is 5, by which D 1 and D 3 are removed.But the number associated with span 2 2 8

Algorithm 1 : 2 -
MAXSAT(C) Input: a logic formula C in CNF.Output: the largest subset of conjunctions satisfying a certain truth assignment. 1 transform C to another formula D in DNF; i = 1 to n do 4⎿ construct a p*-graph * i P for D i ; 5 construct a trie-like graph G over * * 1 ,..., ;

-
Then, by the recursive execution of the algorithm, we will create a trie-like graph as shown in Figure8(a).The only branching node is v 5-12-8 .Checking this node, we will finally get a single path as shown in Figure8(b), showing the largest subset of conjunctions that can be satisfied by a certain truth assignment.

2
From the above analysis, we have the following proposition.Proposition The average running time of our algorithm is bounded by

Table 2 .
Appearance frequencies of variables