Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use Ocaml to code instead of Pathon/C/C++/Java... (** Question 2 ) (* TODO: Add test cases. *) let eval_success_tests : ((truth_assignment * formula) *
Please use Ocaml to code instead of Pathon/C/C++/Java...
(** Question 2 ) (* TODO: Add test cases. *) let eval_success_tests : ((truth_assignment * formula) * bool) list = [] (* TOD0: Add test cases. *) let eval_failure_tests : ((truth_assignment * formula) * exn) list = [] (* TODO: Implement the function. *) let eval (state : truth_assignment) (formula : formula) : bool = raise Not_implemented Implement the function eval : truth_assignment formula bool. This function is very similar to the eval function from HW2. However, now you are evaluating boolean formulae instead of float arithmetic. You also need to use the correct boolean value for each variable. We recommend using Variable_map.find_opt to perform lookups in the truth assignment. If a variable is needed but does not appear in the truth assignment, you must raise an Unassigned_variable x exception, where x is the unassigned variable. Once again, you may use any functions you want and whichever recursive style you prefer. The test cases you must implement for this problem are split into two lists. eval_success_tests is a list of tests for when eval does not raise an exception and yields a bool, and eval_failure_tests is a list of tests for when eval raises an exception. Note: " fx&&gy " is not the same as " let fx=fx in let gy =g y in fx&& gy if g has side effects (like raising an exception, which it may do in this problem). So you should prefer to use the second option in your implementation. We specifically designed tests that check for this issueStep 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