https://github.com/average-user/lec
Transformer of propositional logic expressions to CNF and DNF
https://github.com/average-user/lec
cnf cnf-encoding haskell logic
Last synced: 5 months ago
JSON representation
Transformer of propositional logic expressions to CNF and DNF
- Host: GitHub
- URL: https://github.com/average-user/lec
- Owner: Average-user
- License: mit
- Created: 2018-04-07T18:05:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T18:21:54.000Z (over 7 years ago)
- Last Synced: 2025-07-06T08:44:00.173Z (7 months ago)
- Topics: cnf, cnf-encoding, haskell, logic
- Language: Haskell
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# Logic Expressions Converter
A program to transform logic expressions into their Conjunctive normal form (CNF) and
Disjunctive Normal Form (DNF) representations.
So far the program works fine with any expression composed by:
| Operators | ASCII representation | Also known as |
|:----------------------|:----------------------:|:--------------|
| Negation | ! | Not |
| Conjunction | & | And |
| Disjunction | \| | Or |
| Implication | > | Implies |
| Equality | = | Iff |
| Exclusive Disjunction | + | Xor |
### To do list:
- [x] Parser
- [ ] Converter
- [x] De Morgan's Law
- [x] Distributivity
- [ ] Redundant clauses elimination
- [x] Tests
- [x] Equality between a formula and his (CNF, DNF) conversion
- [x] Correctness of conversions (CNF, DNF)
- [ ] Human readable error messages
- [ ] Benchs
Some examples of how does this work:
```Text
$ stack exec LEC-exe
Insert Expression:
!(A | B) & C
Parsed Expression: !(A | B) & C
Conjunctive normal form: !A & !B & C
Disjunctive normal form: !A & !B & C
Insert Expression:
!(A | B) | C
Parsed Expression: !(A | B) | C
Conjunctive normal form: (!A | C) & (!B | C)
Disjunctive normal form: (!A & !B) | C
Insert Expression:
(A = B)
Parsed Expression: A = B
Conjunctive normal form: (A | !A) & (A | !B) & (B | !A) & (B | !B)
Disjunctive normal form: (A & B) | (!A & !B)
Insert Expression:
(A = B) > C
Parsed Expression: (A = B) > C
Conjunctive normal form: (!A | !B | C) & (A | B | C)
Disjunctive normal form: (!A & A) | (!A & B) | (!B & A) | (!B & B) | C
```