Question
Write a program in Rust which accepts as an input a logic expression with up to four variables (A, B, C, D) and outputs a
Write a program in Rust which accepts as an input a logic expression with up to four variables (A, B, C, D) and outputs a truth table, and accepts inputs as rows in a truth table and outputs a Sum of Products logic expression.
To represent the logic expression
The only variables to use are A, B, C, D.
OR is represented as +. A OR B is read as A + B.
AND is represented as *. A AND B is written as A * B.
Precedence of operation is left to write. A AND B OR C AND D first ANDS A and B, then ORs the result with C, finally that result is ANDed with D.
Parentheses are used to associate subexpressions. (A AND B) OR (C AND D) first calculates A AND B, and C AND D, then ORs the results together (hint: recursive calls to subexpressions).
Use / to represent NOT. So NOT A is written as /A. NOT (A OR B) is written as /(A + B).
Other logical operators need not be implemented (XOR, NOR, etc.).
A function can be any arbitrary length as long as it only contains four or fewer variables, the allowed operators (*+/), parentheses, and white space.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started