Use java and regular expression
Conjunctive normal form - Wikipedia
- Add brackets to match order of precedence
- Convert "if only if" into "implies"
- Replace "implies" by "and", "or", "not"
- Doing de morgan
- Doing distributive
- neg .... "Negation"
- and
- or
- imp ..... "implies"
- iff ..... "if only if"
- ()
Any word character but non-digit.
ex.
A and AA ....... ok
A1 and B ....... not ok
javac mainclass.java java mainclass input.txt output.txt
After ....
java mainclass sample_input.txt output.txt
output.txt is
((A imp C) and (C imp A)) or B ((neg A or C) and (neg C or A)) or B ((neg A or C) and (neg C or A)) or B (A or B or neg C) and (B or C or neg A)
when input is
(A and neg A) or B
the output was
(A or B) and (neg A or B)
but it should be
B