Question: In c + + Part 2 . 1 : Implement evaluate for each Formula subclass Each logical formula is represented as a tree. The tree
In c
Part : Implement evaluate for each Formula subclass
Each logical formula is represented as a tree. The tree in blue below is essentially what notr looks like:
To evaluate any nonVar Formula to true or false, you can recursively evaluate its children and combine their results For example, suppose you're evaluating where and are any Formula. To evaluate the entire you can evaluate and individually first then you can combine them together using II since that's what Or means!
The leaves in Formula trees are always Vars. A Var could stand for anything, so that is why we pass along the var Valmap shown in green when we call evaluate the user must pick ahead of time what each variable's value is You never change var Val yourself during evaluation, and you keep passing the same varVal map in each recursive call. Evaluating a Var is as simple as looking up its value in the map!
Implement the proper overridden evaluate method for each subclass of Formula.
Part : SAT solve like there's no tomorrow
Make sure to watch the introduction video that explains everything! You won't need to write more than lines of code for this lab, but you'll have to think hard about every line.
SAT solving is the process of taking a Boolean formula and determining whether or not it is satisfiable that is whether it is possible to set the variables just right to make the formula be true. For example, the formula notr is satisfiable because you could set and and the formula would evaluate to
In this lab we want to find all the ways to make a formula satisfiable.
Take a look at logic.h and testLogic.cpp and notice how we're using subclasses of Formula to represent logical formulae. In particular, notice how I build the formula from above in testEval.
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
