Function Repository Resource:

# TruthTable

Generate a truth table for a Boolean expression

Contributed by: Wolfram|Alpha Math Team (Jeremy Stratton-Smith)
 ResourceFunction["TruthTable"][expr,vars] creates a truth table for the logical expression expr with respect to vars.

## Details

The input expr is expected to be composed of symbols and logical operators such as And, Or, Xor, Nor, etc. or else a List of such expressions.
The input vars is expected to be a symbol or list of symbols.
The input boole should be any BooleanFunction, and the output will generate a number of unused parameters equal to the value of BooleanVariables[boole], in addition to formatting the BooleanFunction as the simplest explicit form found using BooleanConvert.
The input format can be either "GridForm" (default) or "ListForm". If "ListForm" is entered, ResourceFunction["TruthTable"] will return an unformatted list of lists corresponding to the rows of the truth table.

## Examples

### Basic Examples (2)

Produce a truth table for a simple logical expression:

 In[1]:=
 Out[1]=

You can also build up larger expressions:

 In[2]:=
 Out[2]=

### Scope (2)

TruthTable also accepts raw BooleanFunction inputs and produces an explicit logical expression for the function:

 In[3]:=
 Out[3]=

Display the same result using the list format:

 In[4]:=
 Out[4]=

### Applications (2)

Show DeMorgan's law by comparing two logical expressions:

 In[5]:=
 Out[5]=

Show that Implies is not associative by comparing the truth tables of two expressions:

 In[6]:=
 Out[6]=

### Neat Examples (1)

Use a truth table to easily determine if multiple logical expressions are equivalent:

 In[7]:=
 Out[7]=

## Publisher

Wolfram|Alpha Math Team

## Version History

• 2.0.0 – 23 March 2023
• 1.0.0 – 10 May 2021

## Author Notes

To view the full source code for TruthTable, evaluate the following:

 In[1]:=