Boolean Constraint Satisfaction System


In addition to simply building and evaluating an expression as in Arithmetica, you should allow the user a new command: to satisfy a boolean expression. 

Your program should recognize the following expressions:
expression
syntax
semantics
examples
Constant
<true/false>
a boolean constant
true
T
t
Variable
<any alpha-numeric string>
[a-zA-z0-9]+
an expression represented by a word (other than keywords true or false)
Note, the special symbol "current" refers to the current expression
a
bugs
q45
Assignment
var = expr
assigns an expression to a variable
a = false
bugs = F || a
a = bugs
Unary Operator
op expr
prefixes an expression 
~   // logical not
!a
-(t && a || F)
!F
Binary Operator
expr op expr
combines two expressions into a single expression (in precedence order)
&&  // logical and
||  // logical or
a && b
a || 2
a || T && c
Unary Functions
fun(expr)
a function that takes an expression as its single argument
satisfy(expr)    // return if it is possible for given expression to be true
satisfy(a)
satisfy(a && F)
Parentheses
(expr)
raises an expression's precedence
(a && b) || 3
!(bugs && t)

Operators have the following precedence from left to right (listed from highest to lowest):

() parentheses
~ unary operators
&&, || logical  operators
= assignment

Extra Credit

 

Resources


Comments?