A simple tool to generate a truth table from Boolean expressions.
With npm:
npm i -g simple-boolean-table
Or by cloning the repository( but first install Bun on your OS):
git clone https://github.com/KiritoEM/boolean-table
cd boolean-table
bun install
To start the tool, run:
boolean-table
Or use the tool locally by linking the project:
bun link
boolean-table
- link : Link the project
- test: Run test unit
bun run link #Link the project
bun run test #Run tests
- a-z or A-Z : Variables
- & : AND
- ~ : NOT
- | : OR
- == : EQUAL
- -> : IMPLIES
- expression
<expression>
: Generates the truth table for the given expression. - expression
<expression> --step
: Generates the truth table by printing subexpressions - help : Displays the help screen.
boolean-table expression "(a -> ~b) == (b | a)"
# Truth table for (a -> ~b) == (b | a)
| a | b | (a -> ~b) == (b | a) |
|---|---|----------------------|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Or by printing subexpressions:
boolean-table expression "(a -> ~b) == (b | a)" --step
# Truth table for (a -> ~b) == (b | a) by printing subexpressions
| a | b | ~b | (a -> ~b) | (b | a) | (a -> ~b) == (b | a) |
|------|------|-------|-----------|---------|----------------------|
| 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 | 0 |