Question

In: Computer Science

Describe a polynomial time algorithm to solve following problem Input: A boolean function in CNF such...

Describe a polynomial time algorithm to solve following problem

Input: A boolean function in CNF such that each clause has exactly three literals.

Output: An assignment of the variables such that each clause has all TRUE literals or all FALSE literals.

Solutions

Expert Solution

We define 3-CNF-SAT satisfiability using the following terms. A literal in a boolean formula is an occurrence of a variable or its negation. A boolean formula is in conjunctive normal form, or CNF, if it is expressed as conjunctions (by AND) of clauses, each of which is the disjunction (by OR) of one or more literals. A boolean formula is in 3-conjunctive normal form, or 3-CNF-SAT, if each clause has exactly three distinct literals. For example, the boolean formula (?1 ∨ ?2 ∨ ?̅3 ) ∧ (?̅1 ∨ ?̅2 ∨ ?3 ) ∧ (?1 ∨ ?̅2 ∨ ?3 ) is in 3-CNF-SAT. The first clause is (?1 ∨ ?2 ∨ ?̅3 ), which contains the three literals ?1, ?2, and ?̅3. In 3-CNF-SAT, we are asked whether a given boolean formula the φ in 3-CNF-SAT is satisfiable. The following theorem shows that a polynomial-time algorithm that can determine the satisfiability of boolean formulas is unlikely to exist, even when they are expressed in this simple normal form. satisfiability of boolean formulas in 3-conjunctive normal form is NP-complete[3]. 2.2 The truth table According to the Boolean Algebra for any 3-CNF formula like φ with n variables [ x1, x2, ..., xn ], the truth table can be formed from Table 1 in order to initialize the variables in the given formula using values in one of the rows in truth table(Table 1).

2.3 Assumption The literals of each clause are sorted based on the positional index in the list of variables. ∀??????? ???ℎ ?? (??∨??∨?? ) ? < ? < ? and ?? ∈ {?? , ?̅? }, ?? ∈ {?? , ?̅? }, ?? ∈ {??, ?̅?} 2.4 Presumption The value of each clause is assumed as false. ∀??????? ???ℎ ?? (??∨??∨?? ) ????? ((?? ∨ ?? ∨ ?? )) = ????? ?? ?? = ?????, ?? = ?????, ?? = ?????, ?? ∈ {?? , ?̅? }, ?? ∈ {?? , ?̅? }, ?? ∈ {??, ?̅?}. 2.5 The table of strings The table of strings is generated from the truth table, which holds the rows and columns of the same size. For each row of the truth table, there is only one equivalent row in the table of strings and vice versa; in fact, the table of strings is a conversion of the truth table(Table 2). Table 2.

ALGORITHM 1: The method to generating Table 2 based on Table 1

??? ? ← 1 ?? 2 ? ?? // n is the number of variables

??? ? ← 1 ?? ? ??

?? ????? 1[?][?] = ????? ????

????? 2[?][?] ← ′?? ′ ;

?? ????? 1[?][?] = ????

???? ????? 2[?][?] ← ′?̅? ′ ;

end

end

Definition 1. Each row in the table of strings contains a string.

LEMMA 1. All strings are unique.

PROOF. The Lemma is correct due to the truth table (Table 1).

3 For example for ? = (?̅1 ∨ ?̅2 ∨ ?̅3 ) ∧ (?̅2 ∨ ?̅3 ∨ ?4 ) ∧ (?̅2 ∨ ?̅3 ∨ ?̅4 ) ∧ (?1 ∨ ?̅2 ∨ ?5 ) ∧ (?̅2 ∨ ?3 ∨ ?̅5 ) ∧ (?̅1 ∨ ?̅2 ∨ ?̅6 ), truth table and string table of problem φ are in Fig. 1.

Definition 2. Clause_Set (w) is said to the set of all clauses resulted from the literals of one string such as w.

ALGORITHM 2: The method to generating Clause_Set(w) //Suppose that w is a string like "?1?2?3 … . ??−1??" and the length of w is equal ?. ??????_???(?) ← ????

??? ? ← 1 ?? ? − 2 ?? ??? ? ← ? + 1 ?? ? − 1 ??

??? ? ← ? + 1 ?? ? ?? ??????_???(?) ← ??????_???(?) ∪ (?? ∨ ?? ∨ ??)

end

end

end

end


Related Solutions

Show that the following problem is NP-hard. Input: A boolean function in CNF such that every...
Show that the following problem is NP-hard. Input: A boolean function in CNF such that every clause has at most three literals and every variable appears in at most three clauses. Output: An assignment that evaluates the given function TRUE.
Show that if P=NP then there is a polynomial-time algorithm for the following search problem: given...
Show that if P=NP then there is a polynomial-time algorithm for the following search problem: given a graph, find its largest clique.
(a) Assume that a polynomial-time primality testing algorithm, calledPrimes is available, which takes as input a...
(a) Assume that a polynomial-time primality testing algorithm, calledPrimes is available, which takes as input a single numbern >1 and outputs whethernis a primenumber or not. Now consider the following algorithm: Input: A natural number n > 1 Algorithm Mystery(n) if ( n mod 2 == 0 ) then if (n == 2) then output ‘‘Input is a prime number’’    else ‘‘Input is not a prime number’’ else Primes(n) What is Algorithm Mystery trying to achieve? What is tightest...
5. Design a dynamic programming algorithm to solve the following problem. Input: An array A[1, ....
5. Design a dynamic programming algorithm to solve the following problem. Input: An array A[1, . . . , n] of positive integers, an integer K. Decide: Are there integers in A such that their sum is K. (Return T RUE or F ALSE) Example: The answer is TRUE for the array A = [1, 2, 3] and 5, since 2 + 3 = 5. The answer is FALSE for A = [2, 3, 4] and 8. Note that you...
How much time does an algorithm take to solve a problem of size n if this...
How much time does an algorithm take to solve a problem of size n if this algorithm uses 2n2 + 2n operations, each requiring 10-8 seconds, with these values of n? a) 10: b) 20: c) 50: d) 100
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm...
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm being used) Requirements Choose one problem with an algorithm and implement it. You should show and explain the result whatever you got. I recommend using N-Queen problem (at least N=8 or more) or any simple perfect games. For example, - N-Queen problem with hill climbing - N-Queen problem with simulated annealing - N-Queen problem with genetic algorithm - Tic-Tac-Toe with Minimax
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm...
Using Java implement a searching algorithm to solve the following problem (please specify the searching algorithm being used) N-Queen problem with genetic algorithm Please use the N-Queen problem (at least N=8 or more) or any simple perfect games. Please provide a screenshot of output and please heavily comment the code. Thanks!
Write an algorithm (flowchart OR Pseudocode) for the following problem Take input character from the user...
Write an algorithm (flowchart OR Pseudocode) for the following problem Take input character from the user unless he enters '$'. Thereafter display how may vowels were entered by the user. Also display the number of each vowel ('a', 'e', 'i', 'o' and 'u') separately. For example if the user enters B a b e c o o d i u g o a l $ Then we have the output below: #A=2 #E=1 #I=1 #O=3 #U=2
Provide an algorithm that solves the following problem: input: a binary heap B, an integer value...
Provide an algorithm that solves the following problem: input: a binary heap B, an integer value x output: all keys in B that are smaller than x Constraint: your algorithm must run in time O(K), where K is the number of keys output. Explain why your algorithm has the required runtime behaviour. (Use pseudocode or C++, or any informal (but clear) description. You are free to choose any kind of representation of binary heaps, as long as it was mentioned...
Describe an algorithm to solve the variant of the Towers of Hanoi in as few moves...
Describe an algorithm to solve the variant of the Towers of Hanoi in as few moves as possible. Prove that your algorithm is correct. Initially, all the n disks are on peg 1, and you need to move the disks to peg 2. You are not allowed to put a bigger disk on top of a smaller disk. 1. Suppose you are forbidden to move any disk directly between peg 1 and peg 2, and every move must involve (the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT