Average-user / LEC

Transformer of propositional logic expressions to CNF and DNF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  • Parser
  • Converter
    • De Morgan's Law
    • Distributivity
    • Redundant clauses elimination
  • Tests
    • Equality between a formula and his (CNF, DNF) conversion
    • Correctness of conversions (CNF, DNF)
  • Human readable error messages
  • Benchs

Some examples of how does this work:

$ 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

About

Transformer of propositional logic expressions to CNF and DNF

License:MIT License


Languages

Language:Haskell 100.0%