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).
10 points (bonus) A propositional formula on n variables, P(ri,2,... ,Tn) is satisfiable if there exists...
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 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.] 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...