OP 4020- Spring 2002 Assignment 5 - Prolog Assignment Due Date: April 22 until midnight Write a parser and evaluator for boolean formulae. Your program will take 2 inputs, namely the formula and the Boolean variables' assignments as two lists. The formula will be stored as a list of constant names corresponding to Boolean variables, and the three operators, "and", "or", and, "not". Boolean variable assignments will be stored as a list constants corresponding to true variables. For example: [p,or,q,and,not,p] represents the Boolean formula: p OR q AND NOT p [q] represents that p is FALSE (since it is not in the list) and q is TRUE. Since there is no parenthesis, only operator precedences will be used to determine the order of the evaluation. NOT has the highest precedence, followed by AND, then OR, which has the lowest precedence. Therefore, for the above example is equivalent to the fully parenthesized expression (p OR (q AND (NOT p))). (This expression evaluates to TRUE.) Associativity of the binary operators is left to right. Your main predicate should be named as eval and should take two lists as its inputs, a formula and an assignment and return the result as its 3rd argument as 0 (corresponding to false) or 1 (corresponding to true). The query will be like: ?-eval([p,or,q,and,not,p],[q],L). And for this example, the answer will be like: L=1 Yes If there is any syntax error in your formula your program is not required to work properly. Essentially, we will ONLY test your program with valid inputs. Only worry about your program running properly in these cases. It is okay if your program crashes given invalid input. Hints: Ignore the efficiency. Define predicates which will never fail. You can use 0/1 as truth values rather than predicates succeding and failing. Then the folowing functions can be used to combined the results. andOP(Result1,Result2,Result):-Result is Result1*Result2. orOP(Result1,Result2,Result):-Result1>0,Result is 1. orOP(Result1,Result2,Result):-Result2>0,Result is 1. orOP(Result1,Result2,Result):-Result is 0. In order to evaluate the "not" you can use the following predicate. not(X):-call(X),!,fail. not(X).