A Polynomial Time Algorithm for 3SAT
Abstract
It is shown that any two clauses in an instance of 3SAT sharing the same terminal which is positive in one clause and negated in the other can imply a new clause composed of the remaining terms from both clauses. Clauses can also imply other clauses as long as all the terms in the implying clauses exist in the implied clause. It is shown an instance of 3SAT is unsatisfiable if and only if it can derive contradicting 1-terminal clauses in exponential time. It is further shown that these contradicting clauses can be implied with the aforementioned techniques without processing clauses of length 4 or greater, reducing the computation to polynomial time. Therefore there is a polynomial time algorithm that will produce contradicting 1-terminal clauses if and only if the instance of 3SAT is unsatisfiable. Since such an algorithm exists and 3SAT is NP-Complete, P = NP.
missingum@section Introduction
This section introduces the 3SAT problem, the implications of solving it in polynomial time, and the structure of the paper.
As seen in [1], The boolean satisfiability problem is given as a set of terminals, , each of which can be assigned a value of True or False, combined by logical AND operators, logical OR operators, and negations. The problem is to determine whether or not there exists an assignment for each terminal that allows the instance to evaluate to True. As seen in [2], the satisfiability problem with exactly 3 literals per clause is NP-Complete. This is the same as the boolean satisfiability problem, but it is presented such that a clause contains exactly three terminals combined with logical OR operators and possibly negations, and each clause is combined with logical AND operators. The idea of NP-completeness shows that if one NP-complete problem can be solved in polynomial time, then all problems in the class NP can be solved in polynomial time. In other words, P = NP.
The paper is structured as follows:
-
1.
Introduction
-
2.
Standard Definitions
-
β’
Terms relating to the 3SAT problem
-
β’
-
3.
Algorithm-Specific Definitions
-
β’
Terms relating to specific aspects of 3SAT regularly referenced in this paper
-
β’
-
4.
Reformatting and Processing
-
β’
Defines how clauses and instances of the 3SAT problem will appear within the paper
-
β’
-
5.
Lemmas
-
β’
A list of lemmas and their proofs pertaining to the algorithm
-
β’
-
6.
Algorithm
-
β’
A step-by-step description of the algorithm to solve 3SAT in polynomial time
-
β’
-
7.
Time Complexity Analysis
-
β’
An analysis of the time complexity of the algorithm
-
β’
-
8.
Proof of Correctness
-
β’
A proof showing the algorithm works for every instance of 3SAT
-
β’
-
9.
Conclusion
-
10.
References
missingum@section Standard Definitions
Definition 2.1.
Terminals: symbols used in the 3SAT problem that can be assigned a value of either 0 or 1, True or False, or any other binary assignment. They usually take the form where is a natural number.
Definition 2.2.
Terms: terminals in either the positive or negated form that appear in a clause. If a term is positive, then the value of the terminal will be the same as the value of the term. If a term is negated, then the value of the terminal will be the opposite of the value of the term.
Definition 2.3.
Clauses: a set of terms combined by logical OR operators. Clauses usually take the form where .
Definition 2.4.
(3SAT) Instance: a set of any number of clauses combined by logical AND operators. Terminals may not repeat within a clause 111See Lemma 5.3 , but they are free to repeat between clauses. Instances usually take the form:
.
Definition 2.5.
Assignment: A list of values in which each value represents either True or False such that each item in the list corresponds to a terminal and all terminals are assigned a value.
Definition 2.6.
Satisfying Assignment: An assignment, , is said to satisfy the instance if applying will make the instance evaluate to True.
Definition 2.7.
Satisfiable: an instance is satisfiable iff there exists a satisfying assignment.
Definition 2.8.
Unsatisfiable: an instance is unsatisfiable iff there does not exist a satisfying assignment.
missingum@section Algorithm-Specific Definitions
Definition 3.1.
Blocking an Assignment: An assignment, , is said to be blocked by a clause, if, given an instance containing , there is no way that allows to evaluate to True, and thus there is no way allows the instance to evaluate to True.
Definition 3.2.
Implication: A clause, , is said to imply another clause, , if all assignments blocked by are also blocked by .
Definition 3.3.
Given Clauses: clauses which were given in the original instance.
Definition 3.4.
Derived or Implied Clauses: clauses which are implied by the clauses in the original instance.
Definition 3.5.
k-terminal (k-t) clause: a clause is described as a k-terminal or a k-t clause if there are terminals in the clause.
Definition 3.6.
Reduction: A special type of implication in which the implied clause is shorter than the implying clause(s).
Definition 3.7.
Expansion: A special type of implication in which the implied clause is longer than the implying clause(s) and all terms in the implying clause exist in the implied clause.
Definition 3.8.
Contradicting 1-terminal Clauses: A set of two clauses are considered to be contradicting 1-terminal clauses if (1) they are both of length 1, (2) they contain the same terminal, and (3) the terminal is positive in one clause and negated in the other.
missingum@section Reformatting and Processing
Since there are a lot of constant characteristics about an instance of 3SAT, we can remove most of them to allow ourselves to focus only on what changes from instance to instance. A list of unchanging characteristics follows:
-
β’
the symbol
-
β’
logical AND operators
-
β’
logical OR operators
The only difference between instances, therefore, is the subscript of the terminal.
Additionally, the following items will be changed to improve compatibility with the Python programming language wherein an instance is expressed as a list of lists and each inner list represents a clause:
-
β’
parentheses will become square brackets
-
β’
negation symbols will become minus signs
-
β’
an instance may be surrounded with square brackets to show it is a list of lists
For example, the instance:
will be written as:
Instances of 3SAT will further be processed by removing any clauses that do not block any assignments. Since this algorithm relies on implications of new clauses, if we ever come across a clause that blocks no assignments, then by definition it will not be able to imply any additional clauses that block at least one assignment.
As such, we will ignore any clauses given or derived that are described in Lemma 5.3
missingum@section Lemmas
Lemma 5.1.
A clause can block an assignment.
Proof.
Recall an assignment is blocked if it does not allow the clause to evaluate to True.
Since terms in a clause are combined by logical OR operators, a clause cannot evaluate to True if all terms in the clause evaluate to False.
A term evaluates to False if itβs either (1) negated and the terminalβs value is True or (2) positive and the terminalβs value is False.
Given a clause, we know there are some number of unique terminals.
Want to find an assignment where all the terms are assigned a value of False.
Since an assignment exists for all possible values for each terminal, then there exists an assignment such that all the terms in the clause evaluate to False.
Since all the terms evaluate to False and are combined by logical OR operators, the clause will evaluate to False.
Since the instance is composed of clauses combined by logical AND operators and one clause evaluates to False, then the entire instance evaluates to False.
Since the instance evaluates to False, the assignment cannot satisfy the instance. β
Lemma 5.2.
For a given instance with terminals, there are possible assignments.
Proof.
An assignment for this instance consists of values, each with two possible values, True or False.
Therefore, there are possible assignments. β
Lemma 5.3.
If a clause contains the same terminal in its negated and positive form, it will not block any assignments.
Proof.
Consider a clause containing the same terminal in both the positive and negative form.
We know that terminal must either be True or False. Consider both cases:
That terminalβs value is True: The positive form of the terminal will be True and the clause will evaluate to True.
That terminalβs value is False: The negated form of the terminal will be True and the clause will evaluate to True.
Since the clause evaluates to True in every case, there will never be an assignment with which it is impossible to make this clause evaluate to False.
In other words, this clause blocks no assignments. β
Lemma 5.4.
Each clause of length blocks assignments.
Proof.
Consider the generic -terminal clause, , in an instance with terminals.
As seen in Lemma 5.1, this blocks all assignments where all of the terms evaluate to False.
Since the values for terminals are set, there are terminals left whose values could be True or False.
Since an assignment exists for every possible way to assign values to each terminal, we know an assignment exists for every possible way to assign a value for these terminals.
There are two possible ways to assign values to each of these terminals so there are unique assignments blocked by . β
Lemma 5.5.
For any clause, , if we select a terminal, , thatβs not in then half of the assignments blocked by will assign True to and the other half will assign False to .
Proof.
We have a clause, , of fixed yet arbitrary length, :
Now we select a terminal, , thatβs not in .
Want to show half of the assignments blocked by assign True to and the other half assign False to .
We know there will be no overlap between these assignments because a single assignment cannot assign both the values True and False to the same terminal.
Now we just have to show that exactly half of the assignments are blocked by assigning either True or False to .
By Lemma 5.4, blocks assignments.
If we fix the value of , then there are only terminals whose values could be 0 or 1.
Since there are two choices per terminal and there are terminals, then there are assignments blocked by where the value of is fixed.
Divide to get the ratio of the number of assignments blocked by adding to the number of assignments blocked by without :
=
=
=
This shows that half of the assignments blocked by assign a fixed value to .
Since there are two possible values for and each block mutually exclusive halves of the assignments blocked by , the lemma holds. β
Lemma 5.6.
Given a clause, , and another clause, , such that all of the terms in also exist in , then all of the assignments blocked by are also blocked by .
Proof.
Given a clause, , of a fixed yet arbitrary length:
And another clause, , containing all the terms in with possibly additional terms:
Want to show all the assignments blocked by are also blocked by .
We know that blocks all assignments that cause all the terms to evaluate to False.
In other words, blocks all assignments where
Similarly, blocks all assignments where
Clearly all assignments consistent with the terminal assignments from are also consistent with the terminal assignments from .
Therefore, every assignment blocked by is also blocked by . β
Lemma 5.7 (Reduction).
Given the following conditions:
-
β’
is a clause of length
-
β’
is a clause of length
-
β’
and share identical terms
-
β’
and share one terminal that is negated in one clause and positive in the other
-
β’
is a clause of length composed of the shared terms from and
Then and imply .
Proof.
Given clauses consistent with the description:
where is shared between the clauses and is a terminal not in
Want to show this implies .
Recall by Lemma 5.3 that the same terminal cannot appear both negated and positive within the same clause and still block an assignment, so cannot exist in
Consider the clause
We know by Lemma 5.5 that if we select a terminal thatβs not in , say , then half of the assignments blocked by assign True to and the other half of the assignments blocked by assign False to .
Let this terminal thatβs not in be the terminal thatβs in and .
We know that blocks all assignments blocked by where is assigned the value of False.
We know that blocks all assignments blocked by where is assigned the value of True.
Since and both block mutually exclusive halves of the assignments blocked by , then all of the assignments blocked by are blocked by and/or and we can say that and imply . β
Lemma 5.8 (Expansion).
Given a clause, , and a terminal, , thatβs not in , then two new clauses can be implied consisting of all the terms of appended to either the positive form of or the negated form of .
Proof.
Given a clause, , and a terminal, , thatβs not in :
We can compose two new clauses:
Since all of the terms in exist in and , then by Lemma 5.6 all of the assignments blocked by or are blocked by and we can say and are implied by . β
Lemma 5.9 (General Lemma 5.7).
If two clauses share the same terminal, , such that is positive in one clause and negated in the other, then these clauses imply a new clause which is composed of all the terms in both clauses except terms containing .
Proof.
Consider two clauses,
Where within a clause, the same terminal does not repeat, but between clauses the same terminal may repeat.
Want to show we can imply a clause consistent with the lemma description:
Letβs define some additional clauses:
By Lemma 5.6, we know that implies because all the terms in exist in .
By Lemma 5.6, we know that implies .
By Lemma 5.7, since and share all the same terms except for , which is positive in one clause and negated in the other, we can create a new clause composed of all the shared terms in and .
Such a clause is already defined as .
Now there are a couple extra cases to consider:
-
β’
There is some overlap between and
-
β’
There is the same terminal thatβs positive in and negated in
First, if the same term exists in and , then we can just remove one of the duplicates since one term being True implies an identical term being True.
Secondly, if the same terminal exists, but is of the opposite form in and then by Lemma 5.3, this clause will always be True and thus blocks no assignments. In this case, the lemma is vacuously true, but we disregard the clause as it is of no value. β
Lemma 5.10.
Given two clauses of lengths and that imply another clause by Lemma 5.9, the length of the implied clause will fall in the range to where the represents the parameter with the greatest value.
Proof.
The smallest clause that can be implied by clauses of length and using Lemma 5.9 occur when all but one of the terms in one clause exist in the other.
As such, the unique terms will come from the clause thatβs longer.
Removing , you are left with 1 less than the maximum of and .
The largest clause can be implied if there are no terms shared between the two clauses. In this case you subtract from the length of each clause to account for and since no duplicates will be removed, the resulting clauseβs length is less than the sum of the lengths of the clauses. β
Lemma 5.11.
Given the following:
-
β’
A clause, , of length less than
-
β’
A clause, , of length less than
-
β’
A clause, , of length less than
-
β’
A clause, , of length or
-
β’
A clause, , of length
-
β’
and imply by Lemma 5.9
-
β’
and imply by Lemma 5.9
Then , , and , imply by processing only clauses with a maximum length of .
Proof.
Define the clauses in the following manner:
A := [a, b, , i]
B := [c, d, -i]
C := [-a, e, f, ]
Then the following are derived by Lemma 5.9:
(By and )
(By and or by and )
(By and )
Where and are generic sets of terms in the instance.
Consider the following figure:
Note that since and imply , then and must share the same terminal such that it is positive in one clause and negated in the other.
Since all of the terms in came from or (not including ), then such a term in must have the same term of the opposite form in or .
And since and are fixed yet arbitrary clauses treated in the same way, it does not matter which clause we pick as long as it is fixed for the rest of the proof. Letβs pick a the terminal, , from clause . Now contains .
Recall from Lemma 5.3 that if a clause blocks any assignments, it cannot contain the same term in both forms, so if , or contain the same terminal in both forms then blocks no assignments and the resulting clause may be disregarded.
We know is of length and there are two cases for : (1) is of length or (2) is of length .
In the following equations, let the presence of a term represent a count of one, and the presence of a set of terms represent the number of terms in that set. If multiple sets of terms are shown in parentheses, let this represent the number of terms found in the intersection of both sets.
Consider (1) the case where has length then we can define in terms of :
length of
Want to show length of is less than
As seen by using a Venn Diagram or other set intuition, , represents the number of terminals in not in and not in .
The lowest case for the right hand side of the inequality is where this is 0, ie, all of the terms in are in or . In this case, the inequality becomes:
Which is true as long as and exist in .
Want to show and always exists in :
Suppose not, then at most one of or exists.
Recall we have the clauses:
And since only or exist, we can redefine some clauses:
Where x is represents either or , but not both.
Note that no terms may exist in because any terms in could be extracted and treated as or , but we know already represents the one of these terms that exist and the other term cannot exist.
Notice the length of is the same as the length of .
This is a contradiction because the length of is given as less than and the length of is given as .
Therefore both and must exist and the inequality is true.
Therefore is shorter than when is of length .
Consider (2) the case where the length of is :
This means is one greater than the length of , so is now:
length of
Want to show length of is less than
Similarly as before, the inequality will become:
Which is true as long as at least or exist.
It was seen that both and must exist and since the proof does not rely on the length of , the inequality is true.
Therefore the length of is shorter than when the length of is .
Since the length of is less than in all cases, you can derive by processing only clauses with a maximum length of . β
Lemma 5.12.
Given the following:
-
β’
is a clause of length less than
-
β’
is a clause of length
-
β’
is a clause of length less than
-
β’
is a clause of length or
-
β’
expands to imply by Lemma 5.8
-
β’
and imply by Lemma 5.9
Then can be implied by processing clauses of at most length .
Proof.
Let the clauses be defined as follows:
:= [-a, e, f, ]
:= [-c, e, f, ]
:= [b, , c, d, , e, f, ]
:= [a, b, , d, , e, f, ]
E := [b, , e, f, ]
Where , and are fixed, yet arbitrary sets of terms such that the clauses block at least one assignment.
Consider the following figure
Notice that has to contain a term from in the opposite form by Lemma 5.9.
Notice that is made up of terms from and terms not in by Lemma 5.6.
The term in which is opposite from the term in can therefore be opposite (1) from a term in (in this case, use and ) or (2) a term not in (in this case use and ).
(1) Consider the opposite form term in is in (use and ):
Recall the clauses:
:= [-a, e, f, ]
:= [b, , c, d, , e, f, ]
Notice and share an opposite term, so they can derive a clause, , by Lemma 5.9.
Notice all the terms in exist in so can be expanded to derive by Lemma 5.8.
Consider the path of implication in the following figure:
Want to show you only have to process clauses whose length is less than to derive .
Since is derived using only , , and and and are given to be shorter than , want to show length of is less than .
Consider two cases: (1a) is of length and (1b) is of length
Consider (1a) where is of length :
In the following equations, let the presence of a term represent a count of one, and the presence of a set of terms represent the number of terms in that set. If multiple sets of terms are shown in parentheses, let this represent the number of terms found in the intersection of both sets.
Since is of length , we can define as follows:
Length of
Want to show the length of is less than :
Which is true as long as at least one term exists on the R.H.S.
Want to show at least one term exists on the R.H.S.
Suppose not, then no terms exist on the R.H.S. and we can redefine some clauses.
Recall the original clause definitions:
Since no terms exist on the R.H.S. we can redefine some clauses:
Note that no terms may exist in because any term in can be extracted and treated as or and those are explicitly removed from existence.
Notice is exactly .
This is a contradiction because the length of is given as less than while the length of is given as .
Therefore at least one term must exist on the R.H.S. and the inequality holds.
Therefore is shorter than when is of length and we use and .
Consider (1b) is of length :
Then the length of is redefined as:
Similarly as before, the inequality becomes:
Which is always true so the length of is indeed less than when is of length and we use and .
(2) Consider the case using and :
Recall the clauses:
Since all of the terms in exist in , we can expand to using Lemma 5.8
Since the length of is given as less than , we can derive by processing clauses with a maximum length of .
Since the possible lengths of are or and in both cases we derive by processing clauses with a maximum length of then can always be derived by processing clauses with a maximum length of . β
Lemma 5.13.
Given an instance of 3SAT, you can expand all of the given clauses to the point where you are considering clauses of length .
Proof.
Given an instance of 3SAT, we know all clauses are of length 3.
If we want to consider a generic -terminal clause, , thatβs implied by a given clause, , then by Lemma 5.6 we know itβs implied if all the terms in exist in . β
Lemma 5.14.
If you expand given 3-t clauses as described in Lemma 5.13, you will derive unique clauses of length iff the instance is unsatisfiable.
Proof.
Want to show an unsatisfiable instance unique n-terminal clauses can be derived from the given 3-t clauses:
By lemma 5.4, a clause of length blocks 1 assignment.
Recall an instance is unsatisfiable iff all assignments are blocked.
If a 3-terminal clause blocks an assignment, then it also implies the corresponding n-terminal assignment because there is one possible n-terminal clause for any given assignment.
Notice that for each of these n-terminal clauses, they must contain three terms from at least one given clause. If they didnβt, then the assignment blocked by that n-terminal clause would not be blocked and the instance would be satisfiable.
Since each n-terminal clause blocks one assignment, blocking all assignments requires n-terminal clauses.
Want to show unique n-terminal clauses are derived by the given 3-t clauses then the instance is unsatisfiable.
By lemma 5.4, a clause of length blocks 1 assignment.
Therefore if there are unique n-terminal clauses, then all assignments will be blocked.
Note that there will be no overlap because each n-terminal clause sets the value for each terminal and overlap would imply the same terminal having two values by the same assignment which is impossible. β
Lemma 5.15.
The n-terminal clauses described in Lemma 5.14 can be reduced to derive any pair of contradicting 1-terminal clauses.
Proof.
Given n-terminal clauses, want to show you can imply any pair of contradicting 1-terminal clauses by lemma 5.7.
Algorithm:
Pick a terminal that will not exist in the final 1-terminal clauses.
Notice half of the existing n-terminal clauses have that terminal assigned the value of False and the other half have that terminal assigned the value of True.
Pick one clause that blocks an assignment where the terminal is True.
Then there exists an assignment for each possible value for the remaining n-1 terminals.
Therefore, there must exist another clause that shares all of the same terms, but where that one terminal is assigned the value of False.
Using these two clauses, we can create a new clause by lemma 5.7.
Now all of the clauses of length n - 1 do not contain that terminal.
Repeat this process while never selecting the same terminal twice until you are left with two contradicting 1-terminal clauses.
Each clause is guaranteed to have a matching clause since every possible combination of terminal assignments exists and when you use Lemma 5.7 to create new clauses, the rest of all of the clauses remain the same except the selected terminal is removed. β
Lemma 5.16.
Contradicting 1-terminal clauses can be expanded to imply every possible clause.
Proof.
Let the following clauses be a pair of contradicting 1-t clauses:
Any possible clause could either contain , , or neither.
By lemma 5.8, we can expand to any clause that contains or .
Now want to show these clauses imply another clause that does not contain or .
Let the following be a generic k-terminal clause that does not contain or :
By Lemma 5.8, we know the 1-terminal clauses imply the following clauses:
By Lemma 5.9, these clauses imply:
Therefore a set of contradicting 1-terminal clauses can imply any clause containing , or neither, which encompasses every possible clause. β
Lemma 5.17.
Given the following:
-
β’
A, B, C, and D, are clauses shorter than k
-
β’
E and F are clauses of length k
-
β’
G is a clause of length k or k - 1
-
β’
A and B imply E by Lemma 5.9
-
β’
C and D imply F by Lemma 5.9
-
β’
E and F imply G by Lemma 5.9
Then G can be implied by processing clauses with a maximum length of k - 1.
Proof.
Consider the following figure:
Let the clauses be defined as follows:
Then the following are implied by Lemma 5.9:
Where and are fixed yet arbitrary sets of terms such that the clauses block at least one assignment.
Notice that and have to share a term of the opposite form in order to imply by Lemma 5.9.
All of the terms in and came from and .
Since and are all arbitrary clauses, selecting which term to negate does not have an effect on the outcome as long as one form of the term exists in and the other form exists in .
Here the opposite term is shared between and , but any term that appears positive in or and negated in or or vice versa will yield the same results.
Want to show can be derived by processing clauses with a maximum length of .
Define additional implications by Lemma 5.9:
(By clauses and )
(By clauses and )
(By clauses and )
Notice is equivalent to .
Want to show all clauses used to derive are shorter than .
Want to show , , , , , and are shorter than .
It was given that , , , and are shorter than so just want to show and are shorter than .
Want to show (1) is shorter than and (2) is shorter than
(1) Want to show is shorter than
Two cases to consider (1a) is of length and (1b) is of length
(1a) is of length
In the following equations, let the presence of a term represent a count of one, and the presence of a set of terms represent the number of terms in that set. If multiple sets of terms are shown in parentheses, let this represent the number of terms found in the intersection of both sets.
Since is of length we can define as follows:
Length of
Want to show the length of is less than :
Which is true as long as at least three terms exist on the R.H.S.
Consider the following cases:
-
β’
No terms exist on the R.H.S.
-
β’
Exactly one term exists on the R.H.S.
-
β’
Exactly two terms exist on the R.H.S.
Consider case 1 where no terms exist on the R.H.S.
Recall the clauses:
But since no terms exist on the R.H.S., specifically and donβt exist, we can redefine the clauses:
Notice that no terms may exist in because any term in can be extracted and treated as or , but we defined these to not exist.
Notice the length of is shorter than the length of .
This is a contradiction because the length of is given as less than while the length of is given as .
Therefore this case is impossible and at least one term must exist on the R.H.S.
Consider case 2 where exactly one term exists on the R.H.S.
Recall the clauses:
Recall at least one term must exist on the R.H.S., specifically either or must exist, but not both.
We know or must exist because if neither exist, thereβs a contradiction (see case 1).
Since these terms are treated in the same way, letβs pick to be the term that exists.
We can redefine some clauses as follows:
Notice the length of is the same as the length of .
This is a contradiction because the length of is given as less than while the length of is given as .
Therefore at least two terms must exist on the R.H.S.
Consider case 3 where exactly two terms exists on the R.H.S.
Notice how if both and do not exist, then a contradiction is reached.
Therefore both and must exist and the rest of the terms on the R.H.S. may not exist.
Recall we have the clauses:
But since no terms on the R.H.S. exist besides and , then , , and may not exist.
Notice that no terms in may exist because if any terms in exist, then they can be extracted and treated as or .
Then we can redefine the clauses:
Notice that is shorter than .
This is a contradiction because the length of is given as less than while the length of is given as .
Therefore at least three terms must exist on the R.H.S.
Since at least three terms must exist on the R.H.S., the inequality is true.
Therefore is shorter than when the length of is .
(1b) is of length
If is of length , then k is defined as:
Length of
Similarly to before, the inequality becomes:
Which is true as long as at least two terms exist on the R.H.S.
It was already shown that at least three terms must exist on the R.H.S. and the proof does not rely on the length of so the inequality holds.
Therefore is always shorter than .
(2) Want to show is shorter than
Two cases to consider (2a) is of length and (2b) is of length
(2a) is of length
Since is of length we can define as follows:
Length of
Want to show the length of is less than :
Which is true as long as at least two terms exist on the R.H.S.
Suppose not, then a maximum of one term exists on the R.H.S.
Recall the clauses
Due to the restriction of a maximum of one term existing on the R.H.S., we can redefine some clauses:
Where represents a maximum of one term.
Note that if was more than one term, then the two terms could be used as and , but we know these do not exist.
Notice the length of is at most the length of .
This is a contradiction because the length of is given as less than while the length of is given as
Therefore at least two terms exist on the R.H.S. and the inequality is true.
Therefore I is shorter than when is of length .
(2b) is of length
Similarly as before, we define k in terms of the length of G:
Length of
Similarly to before, the inequality becomes
Which is true as long as at least one term exists on the R.H.S.
It was already shown at least two terms exist on the R.H.S. and the proof does not rely on the length of so the inequality is true.
Therefore, the length of is shorter than when is of length .
Since can be derived by processing only , , , , , and and all of those clauses are shorter than , we can derive by processing clauses with a maximum length of . β
Lemma 5.18.
Given the following:
-
β’
a clause, , of length less than
-
β’
a clause, , of length less than
-
β’
a clause, , of length less than
-
β’
a clause, , of length
-
β’
a clause , of length
-
β’
a clause , of length or
-
β’
A and B imply D by Lemma 5.9
-
β’
C expands to E by Lemma 5.8
-
β’
D and E imply F by Lemma 5.9
Then can be implied by only processing clauses with a maximum length of .
Proof.
Consider the following figure:
Let the following clauses be defined:
Then the following clauses are implied:
Where and are generic sets of terms such that A, B, and C block at least one clause by Lemma 5.3.
Notice E and D must share a term of the opposite form and there are two possible cases for what this term is:
-
β’
it exists in C (use , , and )
-
β’
it does not exist in C (use , , and )
Either way the opposite term must exist in A or B since it must exist in D and D is composed of terms from A or B.
Since A and B are both generic clauses treated in the same way, it does not matter which clause the term exists in as long as it is fixed.
Letβs pick to contain the opposite form term from .
Consider (1) the opposite form term exists in C (use , , and ).
Want to show can be derived by processing clauses with a maximum length of k - 1.
Let the following clauses be defined:
(By clause and with Lemma 5.9)
(By clause and with Lemma 5.9)
Since all of the terms in exist in , Lemma 5.8 can be used to derive from .
Want to show (1a) is shorter than and (1b) is shorter than
(1a) is shorter than
Consider two cases (1ai) is of length and (1aii) is of length .
(1ai) is of length
In the following equations, let the presence of a term represent a count of one, and the presence of a set of terms represent the number of terms in that set. If multiple sets of terms are shown in parentheses, let this represent the number of terms found in the intersection of both sets.
Recall is of length so can be defined as follows:
Length of
Want to show length of is less than :
Which is true as long as at least two terms exist on the R.H.S.
Want to show at least two terms exist on the R.H.S.
Suppose not, then at most one term exists on the R.H.S.
Recall the clauses
We can redefine some clauses since at most one term may exists on the R.H.S.
Where represents one term from , , or .
Note that if was more than one term, the two terms could be extracted and treated as and , but we know at most one of these terms exist.
Note the length of is the same as the length of .
This is a contradiction because the length of is given as less than while the length of is given as .
Therefore at least two terms exist on the R.H.S. and the inequality is true.
Therefore is shorter than when using and the length of is .
(1aii) is of length
Recall is of length so can be defined as follows:
Length of
Want to show length of is less than :
Similarly as before, the inequality will become:
Which is true as long as at least one term exists on the R.H.S.
We already showed at least two terms exist on the R.H.S. and the proof does not rely on the length of .
Therefore at least one term exists on the R.H.S. and the inequality is true.
Therefore the length of is less than when using and the length of is .
(1b) Want to show is shorter than .
We have two cases to consider: (1bi) is of length and (1bii) is of length
Consider (1bi) is of length
Recall is of length , so we can define as follows:
Length of
Want to show the length of is less than .
Which is true if at least one term exists on the R.H.S.
Want to show at least one term exists on the R.H.S.
Suppose not, then no terms exist on the R.H.S.
Recall the clauses
Since no terms exist on the R.H.S., we can redefine some clauses:
Note that no other terms may exist in because any other terms could be used as or , but we know these donβt exist.
Notice is exactly .
This is a contradiction because the length of is given as less than while the length of is given as .
Therefore at least one term exists on the R.H.S. and the inequality is true.
Therefore is shorter than when using and the length of is .
Consider (1bii) is of length
Since is of length , we can define as follows:
Length of
Want to show the length of H is less than k.
Similarly to before, this will derive
Which is always true.
Therefore the length of is less than when using and the length of is .
Consider (2) the opposite form term does not exist in , use , , and .
Recall we have the clauses:
Notice all of the terms in exist in so can expand to using Lemma 5.9.
Since the length of is given as less than , we can derive by processing clauses with a maximum length of .
Since and are all possible cases of and they can be derived without processing clauses longer than length , can be derived by processing only clauses with a maximum length of . β
Lemma 5.19.
Given the following:
-
β’
a clause , of length less than k
-
β’
a clause , of length less than k
-
β’
a clause , of length k
-
β’
a clause , of length k
-
β’
a clause , of length k or k - 1
-
β’
expands to by lemma 5.8
-
β’
expands to by lemma 5.8
-
β’
and imply by lemma 5.7
Then can be derived by processing clauses whose length is at most k - 1.
Proof.
Consider the following figure:
In the following clause definitions let and be fixed yet arbitrary set of terms in which the clauses block at least one assignment by Lemma 5.3.
In order for and to imply E by Lemma 5.9, they have to share a terminal which is positive in one clause and negated in the other.
Note that is composed of terms in and terms not in .
Similarly is composed of terms in and terms not in .
There are 3 cases for this opposite form term existing in regards to and :
-
1.
the opposite form term does not exist in or
-
2.
the opposite form term exists in either or but not both
-
3.
the opposite form term exists in and
Consider case (1) the opposite form term does not exist in A or B.
Then we have the clauses:
Notice all of the terms in exist in so we can expand to by Lemma 5.8.
Since the length of is given as less than , we can derive by processing clauses with a maximum length of .
Consider case (2) the opposite form term exists in either A or B.
Since and are treated the same, letβs say the opposite form term exists in and .
Now we have the clauses:
Notice all of the terms in exist in so we can expand to by Lemma 5.8.
Since the length of is given as shorter than , we can derive by processing clauses with a maximum length of .
Consider case (3) the opposite form term exists in A and B.
In this case, we redefine the clauses as follows:
In this case, by Lemma 5.9, and can imply a new clause:
Want to show is shorter than .
Consider two cases (3a) the length of is and (3b) the length of is .
Consider (3a) the length of is .
We can define as follows:
And the length of is:
Length of
Want to show the length of is less than :
Which is true as long as at least one term exists on the R.H.S.
Want to show at least one term exists on the R.H.S.
Suppose not, then no terms exist on the R.H.S.
Recall we have the clauses
Since the terms on the R.H.S. do not exist, we can redefine the clause:
Notice no more terms may exist in because any new term could be treated as or and we know those donβt exist.
Notice is exactly .
This is a contradiction because the length of is given as less than and the length of is given as .
Therefore at least one term must exist on the R.H.S. and the inequality is true.
Therefore is shorter than when is of length .
Consider (3b) the length of is .
We can define as follows:
And the length of is:
Length of
Want to show the length of is less than :
Similarly to before, this will derive
Which is always true.
Therefore is shorter than when the length of is .
Since we can derive by processing clauses with a maximum length of for all possible cases of the lemma, then the lemma holds. β
missingum@section Algorithm
-
1.
For each clause in the instance, C, of length 3 or less:
-
(a)
For each clause in the instance, D, of length 3 or less:
-
i.
Get all clauses implied by C and D according to Lemma 5.9 and add them to the instance
-
ii.
Check if this new clause is in the instance and update a flag accordingly
-
i.
-
(b)
Expand C to get all possible clauses with a maximum length of 3 and add them to the instance
-
(c)
For each new clause from the previous step
-
i.
Check if the new clause is in the instance
-
i.
-
(a)
-
2.
For each clause in the instance, E, of length 1:
-
(a)
For each clause in the instance, F, of length 1:
-
i.
if E and F contain the same terminal in which it is positive in one clause and negated in the other, the clauses are contradicting and the instance is unsatisfiable, end
-
i.
-
(a)
-
3.
Repeat (1)-(2) until no new clauses are added
-
4.
If it reaches here, the instance is satisfiable, end
missingum@section Time Complexity Analysis
In this section I will analyze the time complexity of the algorithm in section 4
(1) - - At most clauses to iterate which is on the order of
(1.a) - - At most clauses to iterate which is on the order of
(1.a.i) - - For each terminal in C, check if itβs opposite form is in D. Since each clause is of length 3 or less, the worst case we iterate over 3 terms in C and check each term in D. If itβs a match, we iterate over each clause again and create a new clause as described in Lemma 5.9. This time complexity is intuitively which is constant time.
(1.a.ii) - - For each clause in the instance, iterate through the instance to check if it exists already. There are on the order of clauses in the instance.
(1.b) - - For a 2-terminal clause, there are possible 3-terminal clauses that could be expanded to. For a 1-terminal clause, there are possible 3-terminal clauses that could be expanded to. This is upper bounded by the latter case.
(1.c) - - Upper bounded by at most new clauses from the last step
(1.c.i) - - At most clauses to iterate which is on the order of
(2) - - Iterating through an instance where there are on the order of clauses
(2.a) - - Iterating through an instance where there are on the order of clauses
(2.b.i) - - Constant time to check if two 1-terminal clauses contain the same terminal in the opposite form
(3) - - Worst case, we add one new clause each time so we have to loop times which is on the order of
(4) - - Constant time to check and return satisfiable
The time complexity breaks down:
It is seen the most computationally expensive steps are
missingum@section Proof of Correctness
Want to show an instance is unsatisfiable iff we can derive contradicting 1-terminal clauses by the algorithm.
WTS Contradicting 1-terminal clauses can be derived the instance is unsatisfiable
Contradicting 1-terminal clauses take the form:
Where is a terminal in the problem.
In all possible assignments, can have the value of True or False.
If is True, the clause will be False and the assignment does not satisfy the instance. If is False, the clause will be False and the assignment does not satisfy the instance.
Since all possible assignments do not allow both clauses to be True, the instance is unsatisfiable.
Therefore contradicting 1-terminal clauses can be derived the instance is unsatisfiable
Want to show an unsatisfiable instance the algorithm will derive contradicting 1-terminal clauses
By Lemma 5.14, since the instance is unsatisfiable, the given 3-terminal clauses can be expanded to every possible -terminal clause.
By Lemma 5.15 these -terminal clauses can be reduced by Lemma 5.7 to derive contradicting 1-terminal clauses.
So we know if we can derive these -terminal clauses, we can derive contradicting 1-terminal clauses.
The idea behind the proof is that we know the -terminal clauses can be used to derive the -terminal via reduction but weβll show that we donβt ever have to process a clause above length 3 to derive these contradicting 1-terminal clauses.
This relies on the fact that all clauses of length 4 or greater, say of length , have to be derived by shorter clauses and we can process the shorter clauses to derive any clauses that the clauses of length would derive.
We can do this without processing a clause of length or greater.
The way in which we derive these 1-terminal clauses is we use Lemma 5.7 to reduce the -terminal clauses to -terminal clauses which are reduced to -terminal clauses which are reduced to β¦ which are reduced to -terminal clauses and which finally get reduced to -terminal clauses.
Notice this passes through every possible from length to .
Recall that deriving all of the -terminal clauses was done by using Lemma 5.8.
These -terminal clauses were then used to derive clauses of length by Lemma 5.7.
By Lemma 5.18, such a case allows us to derive the clauses of length without ever having to process a clause of length .
Now we have all of the clauses of length that we would have derived if we processed clauses of length .
Note how each of these clauses are either derived from given clauses by Lemma 5.8 or by Lemma 5.9 (all Lemma 5.7 derivations are a subset of all Lemma 5.9 derivations).
We now want to use these -terminal clauses to derive clauses of length , but we want to do it without processing clauses whose length is greater than .
Since it takes two -terminal clauses to derive a -terminal clause by Lemma 5.7, the possible clauses could be of the form:
-
1.
both clauses were derived by Lemma 5.8 (expansion)
-
2.
both clauses were derived by Lemma 5.9 (reduction/implication)
-
3.
each clause was derived in a different manner
Note that this list is exhaustive because these are the only manner of implications used in the lemmas that allowed us to derive these clauses.
We can use the following lemmas to handle each case:
-
1.
Lemma 5.19
-
2.
Lemma 5.17
-
3.
Lemma 5.18
As such we can derive the clauses of length without processing a clause whose length is greater than .
In a more general sense, for any implied clause of length , say , that is used to derive a clause of length or , say , then we can use the fact that is derived by shorter clauses and we can use these shorter clauses to directly derive without ever processing a clause of length or greater.
At this point, we have 4-terminal clauses and we want to derive 3-terminal clauses.
Notice that Lemmas 5.17, 5.18, and 5.19 require the input clauses to be derived so we cannot use those lemmas to derive all the clauses of length 3 we need.
We need two input clauses to derive the necessary 3-terminal clauses and we have three cases:
-
1.
Both inputs are of length 4
-
2.
One input is of length 4, the other is of length 3
-
3.
Both inputs are of length 3
We can disregard the last point because we want to derive a 3-terminal clause without processing a clause of length 4 or greater so the claim is vacuously true in this case.
In the case where both inputs are of length 4, we know they are both derived using smaller clauses and we can use Lemmas 5.17, 5.18, or 5.19.
In the case where one input is of length 4 and the other is of length 3, there are two cases for how the 4-terminal clause was derived:
-
1.
It was derived using Lemma 5.9 (reduction/implication)
-
2.
It was derived using Lemma 5.8 (expansion)
We can handle the cases in the following ways:
-
1.
Using Lemma 5.11
-
2.
Using Lemma 5.12
Now we have all the 3-terminal clauses that would have been derived while the -terminal clauses were being reduced to contradicting 1-terminal clauses.
We can now reduce the 3-terminal clauses to 1-terminal clauses.
Since we have all the necessary 3-terminal clauses without having to process a clause of length 4 or greater, this shows we do not have to process any clauses of 4 or greater to derive contradicting 1-terminal clauses.
Even though the algorithm only explicitly uses Lemma 5.9 and Lemma 5.8, this will cover cases where reduction is needed because Lemma 5.9 is a more general case of Lemma 5.7. Notice, too, that Lemmas 5.11, 5.12, 5.17, 5.18, and 5.19 rely on Lemmas 5.8 and 5.9 so we do not have to explicitly capture the cases where the intermediate lemmas would apply.
Therefore, this coincides with the described algorithm.
missingum@section Conclusion
In this paper, we present an algorithm to solve 3SAT in polynomial time.
This algorithm relies on Lemmas 5.8 and 5.9. The former of which says a clause can expand to imply another clause by appending any term thatβs not in the original clause. The latter of which says two clauses sharing one terminal which is positive in one clause and negated in the other can imply a new clause composed of the rest of the terms in either clause. Using these strategies, we can process an instance of 3SAT while only considering clauses of length 3 or less and are guaranteed to derive a pair of contradicting 1-terminal clauses if and only if the instance is unsatisfiable.
According to [2], 3SAT is NP-complete so if 3SAT can be solved in polynomial time then every problem in NP can be solved in polynomial time.
Since such an algorithm exists, all problems in NP can be solved in polynomial time.
Thus, P = NP.
References
- [1] StephenΒ A. Cook. The complexity of theorem-proving procedures. In Proceedings of the Third Annual ACM Symposium on Theory of Computing, STOC β71, page 151β158, New York, NY, USA, 1971. Association for Computing Machinery.
- [2] RichardΒ M. Karp. Reducibility among Combinatorial Problems, pages 85β103. Springer US, Boston, MA, 1972.