truthtable

Truth tables in code? How to structure state machine?

I have a (somewhat) large truth table / state machine that I need to implement in my code (embedded C). I anticipate the behavior specification of this state machine to change in the future, and so I'd like to keep this easily modifiable in the future. My truth table has 4 inputs and 4 outputs. I have it all in an Excel spreadsheet, and...

Can anybody explain the contrapositive

I'm trying to construct a contrapositive for the following statement: If A is 0 or B is 0, then A*B is 0. Here is my attempt: If A*B is not 0, then A is not 0 or B is not 0. The original statement is true, but the contrapositive is false since both A and B must be non-zero in order for A*B to be non-zero... am I doing something wrong? ...

How can I build a Truth Table Generator?

I'm looking to write a Truth Table Generator as a personal project. There are several web-based online ones here and here. (Example screenshot of an existing Truth Table Generator) I have the following questions: How should I go about parsing expressions like: ((P => Q) & (Q => R)) => (P => R) Should I use a parser generator like A...

Algorithmic Approach to generating all combinations based on a large Truth-Table

I apologize if this has been answered elsewhere, but I have yet to find it using my limited algorithmic terminology. ;) My situation is this - I have a variable number of data elements, each of which has been tested against each other data element to determine compatibility. The compatibilities are stored in the equivalent to a 2-dimens...

Prolog First Order Logic - Printing a Truth Table

I have to write program that prints a truth table of expressions. So, I wrote the following function: bool(true). bool(fail). tableBody(A,B,E) :- bool(A), bool(B) , write(A) , write(' '), write(B), write(' '), write(E),nl, fail. My problem is that E (wich is expression that contains A and B) is not e...

Boolean Logic and Truth Tables Explanation

I'm needing to create a truth table, and I really need to find a resource to explain how it works. I'll give an example of a problem. I have to create a truth table based on this: A*(B+A*B)=A*B So the truth table looks something like: 0 0 0 1 1 0 1 1 for A*(B+A*B)=A*B How do I even begin to solve this? Are there any good res...

Digital Logic - truth tables

I am trying to solve these problems with truth tables using the formulas below. I am having a problem with the NOT to NAND I think i got the first 2 problems correct using: AND is equivalent to NOR, AND is equivalent to NAND The equations for AND, OR and NOT using the NAND operator are: X + Y = x' NAND y' ?? X * Y = X' = X NAND 1 ...

Minimum number of checks to validate a truth table

Hi all, I have a java program where I want to validate if any of 3 booleans is false. I want to figure out the smallest expression I can write to check against the permutations. if(!(needsWork && (needsApproval || isAdmin) )) I think this is enough to make sure that if any of the 3 booleans is false I want to stop processing. H...