Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started