Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM 3 (Regular): Disjunctive normal form (DNF) refers to a form of Boolean formulae which is in negation normal form and in which no disjunction

PROBLEM 3 (Regular): Disjunctive normal form (DNF) refers to a form of Boolean formulae which is in negation normal form and in which no disjunction appears inside a conjunction. For example, this formula is in DNF: A \/ (B /\ C) \/ (B /\ ~D) while this formula is not: A \/ (B /\ (C \/ D)) nor is this one: A \/ (B /\ ~(C /\ D)) Your third task is to write a function `dnf` which transforms input Boolean formulae *in NNF* into Boolean formulae in DNF. Your implementation will need the following equations (A,B, and C are arbitrary formulae) Distribution of /\ over \/: A /\ (B \/ C) == (A /\ B) \/ (A /\ C) (A \/ B) /\ C == (A /\ C) \/ (B /\ C) You do not need to perform other simplifications (such as reducing A /\ A to A or reducing A \/ ~A to True). For testing, I have provided a function `isDnf`, which returns `True` if its input is in disjunctive normal form and `False` otherwise. You should NOT use the `isDnf` function in your implementation of `dnf`. -------------------------------------------------------------------------------} dnf :: Formula -> Formula dnf = error "dnf not implemented" isDnf phi = isDnf' 0 phi where isDnf' _ (Var x) = True isDnf' _ (Not (Var x)) = True isDnf' 0 (Or phi psi) = isDnf' 0 phi && isDnf' 0 psi isDnf' 0 (And phi psi) = isDnf' 1 phi && isDnf' 1 psi isDnf' 1 (And phi psi) = isDnf' 1 phi && isDnf' 1 psi isDnf' _ _ = False dnfTests = TestList [ "right distribution" ~: isDnf (dnf (And (Var "A") (Or (Var "B") (Var "C")))) ~?= True , "left distribution" ~: isDnf (dnf (And (Or (Var "A") (Var "B")) (Var "C"))) ~?= True -- Your tests go here ] 

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

Database And Expert Systems Applications 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

More Books

Students also viewed these Databases questions