Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab you will be implementing resolution for propositional logic. At this point, corsider this lab's task an exerdise in agorithm implementation Coming up,

image text in transcribed

In this lab you will be implementing resolution for propositional logic. At this point, corsider this lab's task an exerdise in agorithm implementation Coming up, we wiW use resolution "refutotion for the purpose of theorem prowing by cantrodiction Complete your implementation of the resolution algorithm from Lab 7. You may copy your lab code to a new file 'resolve hw2.py Create and edit your own file resolve_ab7.py Problem 1: In the lab, you used the following set of clauses, The input data structure should be the following list: CLS: [['not P , , notQ', R"], ['P', 'R,], ["Q,, ,R, ], [.not R' ] ] Each sublist is a list of literals and the sublist itself is called clause. Literals can be positive or negative; negative literals are prefixed with not, Two Rerals are complements whenone ispositive and theother isnegative, forexample: 'notP'and P and resolution should find that it is contradictory. The algorithm should eventually produce an empty clauseII and terminate with the message that the set of clauses is UNSATISFIABLE. If necessary, complete Lab 7. Then continue with the below Implement the following algorithm: Given: set of clauses CLS The given algorithm, when properly implemented, also handles the case where the set of clauses is not contradictory. Demonstrate this as follows: While True: Let CLS_SAT be a copy of CLS with one small modification that makes CLS_SAT satisfiable - no longer contradictory). a. 1. Record the current number N of dlauses CLS. Set oldN to N. Random shuffle CLS 2. For (C1,02) in unordered pairs of clauses from CLS If C1 contains a literal L and C2 contains the Iteral (notL) that is a complement to L b. Run resolve for CLS SAT and show that it will report SATISFIBILITY of the set of clauses. Create a new clause C3 which is a combination of C1 and C2, hut without Problem 2: Manually apply CNF conversion to the H2CO3 example form the lecture. Cast the resulting clauses into a Python list representation analogous to CLS and CLS SAT Literals L and notl. If C3 is equal to (empty clause l, retum with "UNSATISFIARLE If C3 contains two literals that are complements, e.A and nOtA C3 is irrelevant Continue with the next pairs of clauses. If C3 contains any literal more than ance, remove any duplicates. Now add clause C3 to cLs and increase N by 1 Exit from the (inner) loop. Add to your list of clauses one more clause [notH2CO3]. The run the resolve function- you should be able to arrive at a clauses [1, indicative that the set of clauses is unsatisfiable. The meaning of that- and why this is exactly the result we want will be explained in the upcoming lectures. Hand in: (1) Hardcopy of your file resolve_hw2.py with completed code form Lab7, and two additional lists of clauses CLS SAT and CLS H2CO3. (2) A script file that shows your successful loading of module resolve_hw2.py and 3 runs: resolve(CLS), resolve(CLS_SAT), and resolve(CLS_H2CO3) 3. If N is equal to oldN [no new clauses were addedl, retum with "SATISFIABLE The objecthe of resolution refutation is to prove that the set of clauses is "unsat fiable". Your program should exhibit behavior similar to the following Due Date: Feb 28, 2019, at the beginning of the lecture In this lab you will be implementing resolution for propositional logic. At this point, corsider this lab's task an exerdise in agorithm implementation Coming up, we wiW use resolution "refutotion for the purpose of theorem prowing by cantrodiction Complete your implementation of the resolution algorithm from Lab 7. You may copy your lab code to a new file 'resolve hw2.py Create and edit your own file resolve_ab7.py Problem 1: In the lab, you used the following set of clauses, The input data structure should be the following list: CLS: [['not P , , notQ', R"], ['P', 'R,], ["Q,, ,R, ], [.not R' ] ] Each sublist is a list of literals and the sublist itself is called clause. Literals can be positive or negative; negative literals are prefixed with not, Two Rerals are complements whenone ispositive and theother isnegative, forexample: 'notP'and P and resolution should find that it is contradictory. The algorithm should eventually produce an empty clauseII and terminate with the message that the set of clauses is UNSATISFIABLE. If necessary, complete Lab 7. Then continue with the below Implement the following algorithm: Given: set of clauses CLS The given algorithm, when properly implemented, also handles the case where the set of clauses is not contradictory. Demonstrate this as follows: While True: Let CLS_SAT be a copy of CLS with one small modification that makes CLS_SAT satisfiable - no longer contradictory). a. 1. Record the current number N of dlauses CLS. Set oldN to N. Random shuffle CLS 2. For (C1,02) in unordered pairs of clauses from CLS If C1 contains a literal L and C2 contains the Iteral (notL) that is a complement to L b. Run resolve for CLS SAT and show that it will report SATISFIBILITY of the set of clauses. Create a new clause C3 which is a combination of C1 and C2, hut without Problem 2: Manually apply CNF conversion to the H2CO3 example form the lecture. Cast the resulting clauses into a Python list representation analogous to CLS and CLS SAT Literals L and notl. If C3 is equal to (empty clause l, retum with "UNSATISFIARLE If C3 contains two literals that are complements, e.A and nOtA C3 is irrelevant Continue with the next pairs of clauses. If C3 contains any literal more than ance, remove any duplicates. Now add clause C3 to cLs and increase N by 1 Exit from the (inner) loop. Add to your list of clauses one more clause [notH2CO3]. The run the resolve function- you should be able to arrive at a clauses [1, indicative that the set of clauses is unsatisfiable. The meaning of that- and why this is exactly the result we want will be explained in the upcoming lectures. Hand in: (1) Hardcopy of your file resolve_hw2.py with completed code form Lab7, and two additional lists of clauses CLS SAT and CLS H2CO3. (2) A script file that shows your successful loading of module resolve_hw2.py and 3 runs: resolve(CLS), resolve(CLS_SAT), and resolve(CLS_H2CO3) 3. If N is equal to oldN [no new clauses were addedl, retum with "SATISFIABLE The objecthe of resolution refutation is to prove that the set of clauses is "unsat fiable". Your program should exhibit behavior similar to the following Due Date: Feb 28, 2019, at the beginning of the lecture

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago