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

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!