Question: 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... Please use Ocaml to code instead of Pathon/C/C++/Java... (** Question 2 )(* TODO: Add test cases. *) let eval_success_tests : ((truth_assignment * formula)

(** 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 issue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!