fun printEnv env = (List.app (fn (name) => (print("\n"); print(name); print(" = "); print(Bool.toString(valOf(lookupVar env name))))) (varList env) ; print "\n")
datatype formula = True | False | Var of string | Not of formula | And of formula * formula | Or of formula * formulaDefine a function verify that given a formula and an environment determines whether the formula holds.
Example:
Given the empty environment, verify should return true for the formula True and false for the formula False.
Given an environment that maps "x" to true and "y" to false, verify should give:
Or(True, x) simplifies to True Or(False, x) simplifies to x Or(x, True) simplifies to True Or(x, False) simplifies to x And(True, x) simplifies to x And(False, x) simplifies to False And(x, True) simplifies to x And(x, False) simplifies to False Not(Not(x)) simplifies to x Not(True) simplifies to False Not(False) simplifies to TrueIn the rules, x refers to any formula. You should be able to apply the rules to sub-formulas. Also, application of one simplification rule might other simplifications possible. For example,
Not(And(And(False, Var("x")), Var("y")))can be simplied to
Not(And(False, Var("y")))which can in turn be simplified to
Not(False)and further to
True.