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 2.1: Implement evaluate for each Formula subclass
Each logical formula is represented as a tree. The tree in blue below is essentially what pvv(q??notr) looks like:
To evaluate any non-Var Formula to true or false, you can recursively evaluate its children and combine their result(s). For example, suppose you're evaluating Or(x,y), where x and y are any Formula. To evaluate the entire Or(x,y), you can evaluate x and y 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 var2 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 2Val yourself during evaluation, and you keep passing the same var2Val 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 2: 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 50 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 pvv(q??notr) is satisfiable because you could set p=T,q=F, and r=F and the formula would evaluate to T.
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.
 In c++ Part 2.1: Implement evaluate for each Formula subclass Each

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!