Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

YOUR ANSWER HERE SAT problems are represented by noting down ( a ) the number of variables , ( b ) the number of clauses

YOUR ANSWER HERE
SAT problems are represented by noting down (a) the number of variables
,(b) the number of clauses
, and (c) for each clause, the list of literals (variables or their negations).
We will use a data structure in python that has the following fields:
n: the number of variables.
clauses : a list of clauses --[c0,...,cm-1]
Each clause ci is itself a list ci: [l1, l2,.., lk] wherein li is a positive number between 1 to n representing the variable
OR a negative number between -n and -1 representing the literal
.
Example
Let's revisit the problem from previous example. It is represented as
n=4
clauses=[[1,2,-4],[-2,-3,1],[-1,-2,-3]]
We have provided a data-structure called SATInstance. Your goal is to complete the function evaluate that inputs a partial truth assignment: a dictionary that maps variable numbers from 1- n (inclusive) to true/false. If a variable is unmapped then it is not assigned to either value.
evaluate should return -1 if the partial truth assignment already violates a clause.
evaluate should return 0 if the partial truth assignment neither violates nor satisfies the formula.
evaluate should return +1 if the partial truth assignment satisfies each and every clause in the formula.
Example 1
Revisiting the example above, let us take the partial assignment 1true
. It leaves 2,3,4
unassigned.
Under this assignment:
The clause 124
is true since 1
is true.
The clause 231
is true since 1
is true.
The clause 123
is unresolved since 1
is false and we do not know what 2
or 3
are.
Therefore your function evaluate must return 0
since at least one clause is unresolved and remaining clauses are all true.
Example 2
Revisiting the example above, let us take the partial assignment 1true,2false
. It leaves 3,4
unassigned. Under this assignment:
The clause 124
is true since 1
is true.
The clause 231
is true since 1
is true.
The clause 123
is true because 2
is false and the clause has 2
.
Since all clauses are true, the formula is already satisfied even though we do not know at 3,4
are. evaluate must return +1 for this formula and partial truth assignment.
Example 3
Revisiting the example above, let us take the partial assignment 1true,2true,3true
. It leaves 4
unassigned. Under this assignment:
The clause 124
is true since 1
is true.
The clause 231
is true since 1
is true.
The clause 123
is false since 1,
x_2, x_3$ are true.
Since at least one clause is false, the formula is already violated even though we do not know what 4
is. evaluate must return -1 for this formula and partial truth assignment.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions