For PG5: A logical term consists of an integer coefficient and 26 booleans (perhaps an array or list). A true means that that variable (A-Z) is present in the term, a false means it is not. A logical expression is a list of these terms. (PvQ) = P+Q-PQ would be a list of three terms. One term has P set to true with a coefficient of 1. One has Q set to true with a coefficient of 1 and one has P and Q set to true with a coefficient of -1. Multiplying two terms is just doing an "or" of the booleans. If a variable is set in either term, then it is set in the product. You also multiply the coefficients. Adding a term to an expression, means going through the list and seeing if a like term is already there. If it is, then change the coefficient to match the sum of the existing coefficient and the term you are adding. If the term is not already present, then just append the new term to the list. If a term ever gets modified to have a coefficient of zero, then remove it from the list. Multiplying two expressions means start with an empty list. In a double loop, multiply every term in the first expression by every term in the second expression, and then add that term to that list. How you parse the input? (P^Q) (PvQ) (P^Q^R) ((P^Q)^R) ~P Convert input expression to algebra: Look at first character of expression. If it is a letter of the alphabet, then generate that specific expression and remove that letter from the input string If it is ~ Remove tilde from input string, recursively process the rest of the string (removing it from the string), and return 1- If it is a ( Remove (. Recursively process the rest of the string (remembering the answer, and removing it from the string). The first character is now going to be ^ or v. Remove it, and recursively process the rest of the string (remembering and removing). The first character is now going to be ). Remove it. Do an ^ or an v on the two things you removed, and return that. (~Pv~Q) (, Remove it. ~Pv~Q) Recursively process. First character is ~. Remove it. Pv~Q) Recursively process. First character P. Remove it. v~Q) Generate term for P. and return it. Negate the expression that was returned to me. Return that. I've got an expression for the first term. Now check out the first character of the remaining string. It's an v. Remember and remove it. ~Q) Recursively process. First character is ~. Remove it. Q) Recursively process. First character Q. Remove it. ) Generate term for Q. And return it. Negate the expression that was returned to me. Return that. Remove first character from string which had better be ). I had processed an v before. So apply v to the two expressions that were returned to me.