Question: The input is a Boolean formula in 2 - CNF , given as a string of symbols. A literal is a variable name ( at
The input is a Boolean formula in CNF given as a string of symbols. A literal is a variable name at least any small Latin letter should be a legal variable name or its negation, denoted by ~ A clause is either a literal, or L L or L L where L and L are literals. Finally, the CNF is either one clause or a conjunction of two or more clauses, where conjunction is denoted by
Example: p p qp ~r~r ~ss ~q
The first task is to check whether the given CNF is satisfiable. The second task is given a CNF report that it is not satisfiable or return one of its satisfying assignments. Solving only the first task gives you a half grade points out of Solving both gives points.
Technical Details
In order for the automated test to work fine, please carefully adhere the following technical instructions. Your solution should be implemented in Python in a file named boolean.py For the first task, you should implement a function called issatisfiable, which takes the string with the CNF as an argument and returns either True satisfiable or False not satisfiable The second task should be implemented as a function called satassignment. This function also takes one argument string and returns an associative array dictionary with the satifying assignment egp: True, q: False, r: True or None, if the CNF is not satisfiable.
Warning: the automatic tests run several iterations of your functions, with different CNFs If you use global variables, please make sure that their values from previous iterations do not make the next one work incorrectly.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
