formula-normalizer
Usage
Run the following commands to build the project:
$ cabal update
$ cabal build
Then run the program as follows:
$ cabal run hw1-app <your formula>
For example:
$ cabal run hw1-app "a -> (!(b || c))"
NNF: ((!a) || ((!b) && (!c)))
DNF: ((!a) || ((!b) && (!c)))
CNF: (((!b) || (!a)) && ((!c) || (!a)))
To launch the tests run the following command(s):
$ cabal test # for unit tests
$ cabal run hw1-quick-check # for testing with quick-check lib
Syntax
Variable names can contain only letters of both registers. For example, abcd
, VAR
, ILOVEmathloGic
.
Operators
Op | Priority | Type | Associativity | Syntax |
---|---|---|---|---|
Not | 8 | Prefix | - | ! |
And | 7 | Infix | Right | && |
Or | 6 | Infix | Right | ` |
Implication | 7 | Infix | Right | -> |
Double Implication | 7 | Infix | Right | <-> |
If you want use !!
then please use whitespaces, like p1 -> ! ! p2
.
Samples
p1 -> p2 -> p3
,
p1 || p2 && p3
,
!p1 && !(p2 -> p3)
,
(p1 && p2) || (p3) || !(p4) -> p5
.