Question

10 points (bonus) A propositional formula on n variables, P(ri,2,... ,Tn) is satisfiable if there exists an assignment of truth values (true or false) to its variables such that it evaluates to true. (a) Give an algorithm (pseudocode) that, given a formula P determines if it is satisfiable or not. Analyze your algorithm. b) Suppose that we are given a free algorithm A that, given P and a partial assignment of truth values (that is, some variables are set to T, others to F, others remain variables) outputs true if the formula is still satisfiable and false if it is not. Further suppose that the cost of this algorithm is constant. Give an algorithm that, given a formula determines if it is satisfiable or not and returns a satisfying assignment. Make use of A as a subroutine and analyze your algorithm

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:-

Given :-

“ n variables” formula p(X1,X2.......Xn)

(a)

Pseudocode:-

Function bool CheckIfSatisfy(std::vector<int> v,int numberOfVariable):

. check using the array values as variable input to the function and check if it evalutes to true

. return true if it evalutes to true.

Function void RecursiveCheck(vector<int> v,int numberOfVariable):

. if sizeof(v)==numberOfVariable:

.if CheckIfSatisfy(v,numberOfVariable) == true:

. insert v into solution

.pop last value from vector

.return v

. else:

.push back true in v

.v=RecursiveCheck(v,numberOfVariable)

.push back false in v

.v=RecursiveCheck(v,numberOfVariable)

.return v

(b)

given free algorithm A,

P and a partial assignment of truth values,

if the output is truth then prove that the formula is still satisfiable are not.

code:-

Function int[] CheckIfSatisfy(int numberOfVariable):

. declare int[]solution(size=numberOfVariable)

. for int i=0 to numberOfVariable-1:

.assign i th variable to true, use all previous assignments (i.e 0 to i-1) along with this to pass as partial assignment in A

. if A returns true

. solution[i] = true

. else

. solution[i] = false

return solution

==>> the system shows the numbers of times of loops = no.of vaiables , so that the

no.of complexity is O(constant*numberOfVariable)~ O(numberOfVariable).

Add a comment
Know the answer?
Add Answer to:
10 points (bonus) A propositional formula on n variables, P(ri,2,... ,Tn) is satisfiable if there exists...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Check is 2-CNF satisfiable? Return one of its satisfying assignments.

    The input is a Boolean formula in 2-CNF, given as a string of symbols.Example: p /\ (p -> q) /\ (p -> ~r) /\ (~r \/ ~s) /\ (s \/ ~q)1) check whether the given 2-CNF is satisfiable.2) given a 2-CNF, report that it is not satisfiable or return one of its satisfying assignments.Solution in Python3For the first task, you should implement a function called is_satisfiable, which takes the string with the 2-CNF as an argument and returns either True (satisfiable) or False (not satisfiable). The second task...

  • 4. The NOT-ALL-EQUAL 3SAT problem is defined as follows: Given a 3-CNF formula F, is there...

    4. The NOT-ALL-EQUAL 3SAT problem is defined as follows: Given a 3-CNF formula F, is there a truth assignment for the variables such that each clause has at least one true literal and at least one false literal? The NOT-ALL-EQUAL 3SAT problem is NP-complete. This question is about trying to reduce the NOT-ALL-EQUAL 3SAT problem to the MAX-CUT problem defined below to show the latter to be NP-complete. A cut in an undirected graph G=(V.E) is a partitioning of the...

  • C++ 1st) [Note: This assignment is adapted from programming project #7 in Savitch, Chapter 10, p.616.]...

    C++ 1st) [Note: This assignment is adapted from programming project #7 in Savitch, Chapter 10, p.616.] Write a rational number class. Recall that a rational number is a ratio-nal number, composed of two integers with division indicated. The division is not carried out, it is only indicated, as in 1/2, 2/3, 15/32. You should represent rational numbers using two int values, numerator and denominator. A principle of abstract data type construction is that constructors must be present to create objects...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT