Problem: Produce a truth table for an argument and determine if the argument is valid. If the argument is not valid the program will identify which row(s) of the truth table indicate an invalid argument. The program needs to be able to run any variation of the argument (same number of statements and variables as the example below). The teacher will change the argument code directly so no user input needed. Example argument: Premise: (((P v Q) ^ (Q -> R)) XOR (P ^ R)) <-> (R ^ Q) Conclusion: (P V R) I know the following information: p q r T T T T T F T F T T F F F T T F T F F F T F F F The teacher recommended creating two functions - premise and conclusion - both with three parameters (p, q, r) and run it 8 times, one for each row in the truth table. I'm really not sure what that would look like and where it would pass the result to. I know that I need to be able to evaluate each portion of the premise and conclusion. Another student recommend I create functions AND(), OR(), XOR(), IF(), and IFF() that would be called by entering the argument in the following form: IFF(XOR(AND(OR(P,Q),IF(Q,R)),AND(P,R)),AND(R,Q)) |
Premise: ((P v Q) ^ (Q -> R) XOR (P ^ R)) <-> (R ^ Q) Conclusion: (P v R) Create a C++ program that generates the truth table for this argument, and indicates if the argument is valid or invalid. If the argument is invalid, identify the row(s) in the truth table that prove the argument is not valid. Your program must be modularized so that the argument can be assessed when your program is graded. Some more hints: a. Create a premise function with 3 parameters for the 3 variables. This function returns the different values (0 or 1) passed to the expression ((P v Q) ^ (Q -> R) XOR (P ^ R)) <-> (R ^ Q). bool getPremise(bool p, bool q, bool r) b. Create a conclusion function with 3 parameters for the 3 variables. This function returns the different values (0 or 1) passed to the expression (P v R) bool getConclusion(bool p, bool r) { return (p || r); } c. Loop through all the various boolean value combinations of P, Q, R. Apply the P, Q and R boolean values to getPremise and getConclusion Print the results in a truth table set. |