Question: PROBLEM 1 (Regular): Your first task is to write a function that, given truth values for the propositional variables, produces a truth value for an
PROBLEM 1 (Regular): Your first task is to write a function that, given truth values for the propositional variables, produces a truth value for an entire formula. For example, given the formula A \/ (B /\ ~C) and the mapping `[("A", False), ("B", True), ("C", False)]`, your function should return `True`. The truth values for the propositional variables are provided as a list of string-Boolean pairs. The `lookup` function (from the standard Prelude) can be used to find values in this list. Your evaluation function may behave arbitrarily (i.e., it may fail, or return an arbitrary truth value) if it encounters a propositional variable whose truth value has not been provided The structure of your evaluation function should *exactly* follow the structure of formulae: you need a case for variables, a (single) case for negated formulae, and so forth, and you should rely on recursion whenever the definition of formulae is itself recursive. --------------------------------------------------------------------------------} eval :: [(String, Bool)] -> Formula -> Bool eval = error "eval not implemented" evalTests = TestList [ "A /\\ (B \\/ ~B) with A = True, B = True" ~: eval [("A", True), ("B", True)] (And (Var "A") (Or (Var "B") (Not (Var "B")))) ~?= True , "A /\\ (B \\/ ~B) with A = False, B = True" ~: eval [("A", False), ("B", True)] (And (Var "A") (Or (Var "B") (Not (Var "B")))) ~?= False -- Your tests go here ] 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
