Question

C++ test to see whether or not if two Well formed formula's (wff's) are equivalent by creating truth tables.

No Structs , Classes or Pointers can be used.

You MUST use arrays, The problem can be achieved with three one dimensional arrays or two two deminsional arrays, or you can do a combination of two and one deminsional arrays.

The purpose of this program is to test whether or not the alternative expression for the circuit is equivalent to the original expression for the circuit. This problem boils down to testing whether or not two wffs are equivalent by creating truth tables. To simplify the problem, I will guarantee that the right side of any sub-expression of the overall expression will be a variable or the negation of the variable. For example, the following are acceptable expressions: PAQ PAQ- R (P VQ) MR P But the following would not be acceptable: PA(QAR) P- QVR. (PVQ)n(PVR) P Further simplifications are as follows: l. There will be no more than three variables P Q and R (always assume exactly 3 2. The only operators will be A (for and), O (for or), I(for implication), N (for not), and E(or end of expression) 3. The input will be in postfix notation. That means, the operator follows its operand(s). For example: PAQ would be written PQAE would be written PQARIE PAQ- R PVQ R would be written PNONORIE (PVQOR P would be written PQORAPIE Postfix is nice because the order of operations is no longer a problem, and it is easily implemented on a stack. However, the simplifications are such that a stack is not necessary for this program Your program should ask for the first expression. You must enter the entire expression on one linc. 0Notc: The program docsnt nced to read the cntire expression at one time, but the uscr shouldnt be asked to enter the expression or any part of it more than one time.) The program will read each of the characters and perform the appropriate operations. The program will then ask for the second expression, read it, and perform the operations. Finally, the program will print out the final truth table for the first wff, the final truth table for the second wff, the equivalence truth table, and a statement about whether or not the two expressions are equivalent. For example, if the output is in bold and the input is in nomal font, a sample run would be input the first expression: POLE input the second expression: PNQOE first second equivalence The two expressions are equivalent

0 0
Add a comment Improve this question Transcribed image text
Answer #1

test - Notepad File Edit Format View Help #include iostream» #include algorithm» #include <sstream» #include <tuple> #include// Print DNF and CNF. string dnf, cnf; tie(dnf, cnf) computeNF (props, result); cout <<The main DNF is: << endl << dnf << e

Add a comment
Know the answer?
Add Answer to:
C++ test to see whether or not if two Well formed formula's (wff's) are equivalent by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java program for the following: Your program reads an infix expression represented by a...

    Write a java program for the following: Your program reads an infix expression represented by a string S from the standard input (the keyboard). Then your program converts the infix expression into a postfix expression P using the algorithm. Next, your program evaluates the postfix expression P to produce a single result R. At last, your program displays the original infix expression S, the corresponding postfix expression P and the final result R on the standard output ( the screen...

  • Total point: 15 Introduction: For this assignment you have to write a c program that will...

    Total point: 15 Introduction: For this assignment you have to write a c program that will take an infix expression as input and display the postfix expression of the input. After converting the postfix expression, the program should evaluate the expression from the postfix and display the result. What should you submit? Write all the code in a single file and upload the .c file. Problem We as humans write math expression in infix notation, e.g. 5 + 2 (the...

  • This project is designed to practice with OOP, stack data structure, its applications, and C++/Java programming...

    This project is designed to practice with OOP, stack data structure, its applications, and C++/Java programming language. You will write a program that reads an infix expression, converts it to a postfix expression, evaluates the postfix expression, and prints out the answer. You must define and implement your own Stack class and a Calculator class. Your Stack class supports standard basic stack operations and you can implement it with an array or a linked list. You should create a class...

  • Stacks are used by compilers to help in the process of evaluating expressions and generating machine...

    Stacks are used by compilers to help in the process of evaluating expressions and generating machine language code.In this exercise, we investigate how compilers evaluate arithmetic expressions consisting only of constants, operators and parentheses. Humans generally write expressions like 3 + 4and 7 / 9in which the operator (+ or / here) is written between its operands—this is called infix notation. Computers “prefer” postfix notation in which the operator is written to the right of its two operands. The preceding...

  • In c++ Section 1. Stack ADT – Overview  Data Items The data items in a stack...

    In c++ Section 1. Stack ADT – Overview  Data Items The data items in a stack are of generic DataType. This means use should use templating and your Node class. Structure  The stack data items are linearly ordered from the most recently added (the top) to the least recently added (the bottom). This is a LIFO scheme. Data items are inserted onto (pushed) and removed from (popped) the top of the stack.  Operations  Constructor. Creates an empty stack.  Copy constructor....

  • //C++ Problem description In this problem, we consider expressions containing brackets that are properly nested. These...

    //C++ Problem description In this problem, we consider expressions containing brackets that are properly nested. These expressions are obtained by juxtaposition of properly nested expressions in a pair of matching brackets, the left one an opening and the right one a closing bracket. ( a + $ ( b = ) ( a ) ) is properly nested ( a + $ ) b = ) ( a ( ) is not In this problem we have several pairs of...

  • C++ Programming Implement a class ExprTree for representing expression trees, including: 1. The operations to build...

    C++ Programming Implement a class ExprTree for representing expression trees, including: 1. The operations to build an expression tree from a postfix arithmetic expression. 2. A recursive function to "evaluate" a non-empty expression tree using these rules:    - If the tree has only one node (which must be a leaf), then the evaluation of the tree returns the real number (type double) that is the node's entry. - If the tree has more tha one node, and the root...

  • We as humans write math expression in infix notation, e.g. 5 + 2 (the operators are...

    We as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). In a computer’s language, however, it is preferred to have the operators on the right side of the operands, i.e. 5 2 +. For more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix. Write a program that takes an “infix” expression as input, uses...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT