https://github.com/salahsheikh/boolean-decomposer
Parses and computes a truth table for any logical expression using ANTLR4
https://github.com/salahsheikh/boolean-decomposer
antlr4 boolean-algebra boolean-expression-parser java truth-table
Last synced: 3 months ago
JSON representation
Parses and computes a truth table for any logical expression using ANTLR4
- Host: GitHub
- URL: https://github.com/salahsheikh/boolean-decomposer
- Owner: salahsheikh
- Created: 2018-11-10T20:45:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-15T01:46:37.000Z (over 7 years ago)
- Last Synced: 2025-04-15T14:07:18.268Z (about 1 year ago)
- Topics: antlr4, boolean-algebra, boolean-expression-parser, java, truth-table
- Language: Java
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Boolean Decomposer
> Parses and computes a truth table, minterms, and maxterms for any logical expression
# Usage example
Example code:
```java
String exp = "A + (B XOR C) NAND B";
TruthTable t = new TruthTable(exp);
t.generateTruthTable();
t.print();
System.out.println("MINTERMS:");
System.out.println(t.getMinterms().stream().map(String::toString).collect(Collectors.joining(" + ")));
System.out.println("MAXTERMS:");
System.out.println(t.getMaxterms().stream().map(String::toString).collect(Collectors.joining()));
```
For the logical expression `"A + (B XOR C) NAND B"`
```
A B C OUTPUT
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0
MINTERMS:
A'B'C' + A'B'C + A'BC + AB'C' + AB'C
MAXTERMS:
(A'+B+C')(A+B+C')(A+B+C)
```
# Supported Logical Functions
* AND
* OR
* NOT
* NAND
* NOR
* XOR
* XNOR
Also supports alternate representations for logical functions such as "&&" (AND) and "+" (OR).
# Building
Simply run `gradle build` for Linux/Unix or `./gradlew build` for Windows