Algebraic Polynomial Sum Solver Over { 0 , 1 }

Given a polynomial P ( x 1 , x 2 , . . . , x n ) which is the sum of terms, where each term is a product of two distinct variables, then the problem APSS consists in calculating the total sum value of P ∀ U i P ( u 1 , u 2 , . . . , u n ), for all the possible assignments U i = { u 1 , u 2 , ...u n } to the variables such that u j ∈ { 0 , 1 } . APSS is the abbreviation for the problem name Algebraic Polynomial Sum Solver Over { 0 , 1 } . We show that APSS is in # L and therefore, it is in FP as well. The functional polynomial time solution was implemented with Scala in https://github.com/frankvegadelgado/sat using the DIMACS format for the formulas in MONOTONE-2SAT . 2012 ACM Subject Classiﬁcation Theory of computation → Complexity classes; Theory of computation → Problems, reductions and completeness


Polynomial time verifiers
Let Σ be a finite alphabet with at least two elements, and let Σ * be the set of finite strings over Σ [2]. A Turing machine M has an associated input alphabet Σ [2]. For each string w in Σ * there is a computation associated with M on input w [2]. We say that M accepts w if this computation terminates in the accepting state, that is M (w) = "yes" [2]. Note that M fails to accept w either if this computation ends in the rejecting state, that is M (w) = "no", or if the computation fails to terminate, or the computation ends in the halting state with some output, that is M (w) = y (when M outputs the string y on the input w) [2]. The language accepted by a Turing machine M , denoted L(M ), has an associated alphabet Σ and is defined by:  [4]. We denote by t M (w) the number of steps in the computation of M on input w [2]. For n ∈ N we denote by T M (n) the worst case run time of M ; that is: where Σ n is the set of all strings over Σ of length n [2]. We say that M runs in polynomial time if there is a constant k such that for all n, T M (n) ≤ n k + k [2]. In other words, this means the language L(M ) can be decided by the Turing machine M in polynomial time. Therefore, P is the complexity class of languages that can be decided by deterministic Turing machines in polynomial time [4]. A verifier for a language L 1 is a deterministic Turing machine M , where: We measure the time of a verifier only in terms of the length of w, so a polynomial time verifier runs in polynomial time in the length of w [2]. A verifier uses additional information, represented by the symbol c, to verify that a string w is a member of L 1 . This information Preprints (www.preprints.org) | NOT PEER-REVIEWED | Posted: 11 February 2021 doi:10.20944/preprints201908.0037.v6 is called certificate. N P is also the complexity class of languages defined by polynomial time verifiers [7]. A decision problem in N P can be restated in this way: There is a string c with M (w, c) = "yes" if and only if w ∈ L 1 , where L 1 is defined by the polynomial time verifier M [7]. The function problem associated with L 1 , denoted F L 1 , is the following computational problem: Given w, find a string c such that M (w, c) = "yes" if such string exists; if no such string exists, then reject, that is, return "no" [7]. The complexity class of all function problems associated with languages in N P is called F N P [7]. F P is the complexity class that contains those problems in F N P which can be solved in polynomial time [7].
To attack the P versus N P question the concept of NP-completeness has been very useful [6]. A principal NP-complete problem is SAT [6]. An instance of SAT is a Boolean formula φ which is composed of: A truth assignment for a Boolean formula φ is a set of values for the variables in φ. On the one hand, a satisfying truth assignment is a truth assignment that causes φ to be evaluated as true. On the other hand, a truth assignment that causes φ to be evaluated as false is a unsatisfying truth assignment. A Boolean formula with some satisfying truth assignment is satisfiable and without any satisfying truth assignment is unsatisfiable. The problem SAT asks whether a given Boolean formula is satisfiable [6].
An important complexity is Sharp-P (denoted as #P ) [9]. We can also define the class #P using polynomial time verifiers. Let {0, 1} * be the infinite set of binary strings, a function f : {0, 1} * → N is in #P if there exists a polynomial time verifier M such that for every where | · · · | denotes the cardinality set function [2]. We could use the parsimonious reduction for the completeness of this class [2]. In computational complexity theory, a parsimonious reduction is a transformation from one problem to another that preserves the number of solutions [2].

Logarithmic space verifiers
A logarithmic space Turing machine has a read-only input tape, a write-only output tape, and read/write work tapes [8]. The work tapes may contain at most O(log n) symbols [8]. In computational complexity theory, L is the complexity class containing those decision problems that can be decided by a deterministic logarithmic space Turing machine [7]. N L is the complexity class containing the decision problems that can be decided by a nondeterministic logarithmic space Turing machine [7].
We can give a certificate-based definition for N L [2]. The certificate-based definition of N L assumes that a logarithmic space Turing machine has another separated read-only tape [2]. On each step of the machine, the machine's head on that tape can either stay in place or move to the right [2]. In particular, it cannot reread any bit to the left of where the head currently is [2]. For that reason, this kind of special tape is called "read-once" [2].

F. Vega 3
A language L 1 is in N L if there exists a deterministic logarithmic space Turing machine M with an additional special read-once input tape polynomial p : N → N such that for every x ∈ {0, 1} * : where by M (x, u) we denote the computation of M where x is placed on its input tape, and the certificate u is placed on its special read-once tape, and M uses at most O(log[x]) space on its read/write work tapes for every input x, where [. . .] is the bit-length function [2]. M is called a logarithmic space verifier [2].
An interesting complexity class is Sharp-L (denoted as #L). #L has the same relation to L as #P does to P [1]. We can define the class #L using logarithmic space verifiers as well.
Let {0, 1} * be the infinite set of binary strings, a function f : where | · · · | denotes the cardinality set function [1]. We could use the parsimonious reduction for the completeness of this class too [2].
A logarithmic space transducer is a Turing machine with a read-only input tape, a write-only output tape, and read/write work tapes [8]. The work tapes must contain at most O(log n) symbols [8]. A logarithmic space transducer M computes a function f : Σ * → Σ * , where f (w) is the string remaining on the output tape after M halts when it is started with w on its input tape [8]. We call f a logarithmic space computable function [8]. We say that a language L 1 ⊆ {0, 1} * is logarithmic space reducible to a language L 2 ⊆ {0, 1} * , written For example, this kind of reduction is used for the completeness in the N L.
A literal in a Boolean formula is an occurrence of a variable or its negation [4]. A Boolean formula is in conjunctive normal form, or CN F , if it is expressed as an AND of clauses, each of which is the OR of one or more literals [4]. A Boolean formula is in 2-conjunctive normal form or 2CN F , if each clause has exactly two distinct literals [7]. A relevant NL-complete language is 2CN F satisfiability, or 2SAT [7]. In 2SAT , it is asked whether a given Boolean formula φ in 2CN F is satisfiable. The instances of MONOTONE-2SAT does not contain any negated variable.

A polynomial time problem
Let's define the following problem Let's see an example: Preprints (www.preprints.org) | NOT PEER-REVIEWED | Posted: 11 February 2021 doi:10.20944/preprints201908.0037.v6 Table 1 Evaluation for all possible assignments x1 x2 x3 P (x1, x2, x3) Answer: The total sum value is 4 for all the possible assignments: Total : 2 + 1 + 1 + 0 + 0 + 0 + 0 + 0 = 4 (see it in Table 1). We solve this problem reducing in logarithmic space and parsimoniously to another problem #CLAUSES-2UNSAT. We show an algorithm for the problem #CLAUSES-2UNSAT which is in #L and therefore, it is in F P as well. In this way, we prove that AP SS can be solved in polynomial time.

Definition 2. Given a Boolean formula φ with m clauses, the density of states n(E) for some integer 0 ≤ E ≤ m counts the number of truth assignments that leave exactly E clauses unsatisfied in φ [5]. The weighted density of states m(E) is equal to E × n(E). The sum of the weighted densities of states of a Boolean formula in 2CN F with m clauses is equal to
Let's consider a function problem: Proof. We are going to show there is a nondeterministic Turing machine M such that M runs in logarithmic space in the length of (n, m, C). We use the nondeterministic logarithmic space Algorithm 1, where this routine generates a truth assignment in logarithmic space just selecting a negation or a positive representation of a variable 1 ≤ i ≤ n, since every variable is represented by an integer between 1 and n in C. We also assume the value of each literal selected within y is false over the generated truth assignment. First of all, the Algorithm 1 select the index in C of a clause from the value of the variable k. Later, we increment the variable count as much as the literal y appears in the clause C[k]. Since a clause contains only two literals, then if we finish the iteration of the possible values in the generated truth assignment, then we can say the clause indexed with the number k in C is unsatisfied when count = 2.
Furthermore, we can make this Algorithm 1 in logarithmic space, because the variables that we could use for the iteration of the variables and elements in C have a logarithmic space in relation to the length of the instance (n, m, C). Besides, the Algorithm 1 is nondeterministic, since we generate in a nondeterministic way the values of the variables k and y. In addition, every generated truth assignment is always stored in logarithmic space in relation to the instance (n, m, C), since we only focus in a single literal of the truth assignment from the for loop each time.
For every unsatisfying truth assignment represented by a generated truth assignment, then there will be always as many acceptance paths as unsatisfied clauses have the evaluation of that truth assignment in the formula φ. Consequently, we demonstrate that #CLAUSES-2UNSAT belongs to the complexity class #L. Certainly, the number of all accepting paths in the Algorithm 1 is exactly the sum of the number of unsatisfied clauses from all the truth assignments in φ, that is exactly the sum of the weighted densities of states of the Boolean formula φ. In conclusion, we show that #CLAUSES-2UNSAT is indeed in #L.
Let's consider an interesting reduction: Theorem 5. AP SS ≤ l #CLAUSES-2UNSAT, where this logarithm space reduction is a parsimonious reduction.
Proof. We solve this problem reducing in logarithmic space the polynomial P (x 1 , x 2 , . . . , x n ) into a MONOTONE-2SAT formula φ such that for each term x i × x j , we make a clause (x i ∨ x j ) and join all the summands by a disjunction with the ∧(AND) operator. Let's take as example the previous instance P (x 1 , x 2 , x 3 ) = x 1 × x 2 + x 2 × x 3 of AP SS which could be reduced to φ = (x 1 ∨ x 2 ) ∧ (x 2 ∨ x 3 ) (the sum of the weighted densities of states for the Boolean formula φ is 4). This is equivalent to p cnf 3 2 1 2 0 2 3 0 in the format DIMACS. Certainly, we can affirm the value of a term x i × x j is equal to 1 when (x i ∨ x j ) is unsatisfied. Consequently, the sum of the weighted densities of states of the Boolean formula φ will be equal to the answer of the instance for AP SS, that is a parsimonious reduction. Indeed, every unsatisfying truth assignment T i = {t 1 , t 2 , ...t n } in φ with K unsatisfied clauses corresponds to an assignment U i = {u 1 , u 2 , ...u n } such that P (u 1 , u 2 , . . . , u n ) = K, where for each j we have "u j = t j " (which actually means u j = 1 if and only if t j is false). Theorem 6. AP SS ∈ #L and therefore, AP SS ∈ F P .
Proof. We know #L is closed under a logarithm space reduction when this one is also a parsimonious reduction. Furthermore, we know that #L is contained in the class F P [1], [3], [2].

Code
This project was implemented on February 8th of 2021 in a GitHub Repository [10]. This was a partial implementation since this project receives as input the already reduced MONOTONE-2SAT formulas in the format DIMACS instead of instances from AP SS.