I require C++ code that parses a logical formula and puts it in Conjunctive Normal Form. The compiler I am using is Turbo C++ 3.0, and thus I would appreciate the coder using only very simple code so that I can easily integrate the code you write into my software project. (I will approve the code you write when you submit it; you must be willing to make any changes I request if I accept your bid.)
Please use the apstring and apvector include files. They are all free and available from [login to view URL]~ola/ap/code/ , along with any of the other ap classes you require. I would like the logical formula to be parsed as an apstring. Each literal in the logical formula will be represented as an integer. The negation of a formula, whether a single literal or a parenthetical clause, will be represented with the minus sign "-". The "and" operator will be represented with an ampersand, "&," the "or" operator will be represented with a pipe, "|", and the implication operator (i.e., the operator such that "a implies b" means a is true if b is true) will be represented by a semicolon, ";". Incorporate the order of operations into your solution. Here is a sample formula:
((-(2&3)|-(1|-3|4)&3&-(2;3))|(1|2|3))
There is a Java version of what I want programmed available online: [login to view URL] . Do not copy their code (it's in Java anyway); however, you may look at it to get an idea of what I want.
This should be a relatively simple job for a programmer who knows what they are doing. Remember, I want the code written in a simple manner, so that my (very old) compiler will be able to use it. I want to be able to call a single function that will run on an inputted apstring and convert to conjunctive normal form as I have requested. The output should be of the following form:
(1|3|2|5)&(-3|1|4|2)&(-2)&(1|2|2)
(Obviously, that is not the CNF version of the formula listed above; but this should give you some idea of how the output should look.)
I will test the accuracy your code using Bexpred. I will not release funds until I am satisfied that your code is correct, and it meets my specification.
Thank you.
-Phil
## Deliverables
I have listed all requirements above.