/** COMP 411 Homework #0.5 * Symbolic Boolean Expressions */ /** Symbolic boolean expression representation */ sealed abstract class BoolExp // Literal Case Classes ... // Unary Operator Case Class ... // Binary Operator Case Classes ... // Ternary Operator Case Class object BoolExp { /** Internal representation for if expressions */ sealed abstract class IfExp // Three Case classes ... // Convenience declarations for boolean constants // ! Scala convention is to capitalize the first letter for a constant // ! Such (capitalized) identifiers are treated as constants in match patterns val True = IVal(true) val False = IVal(false) /** Convert boolean expressions to internal * if-representation for further processing */ def convertToIf(exp : BoolExp) : IfExp = ... /** Normalize the if-representation by making all condition-slots be literals */ def normalize(exp : IfExp) : IfExp = ... /** Perform head normalization (Helper for normalize) */ def headNormalize(test : IfExp, conseq : IfExp, alt : IfExp) : IfExp = ... /** Perform symbolic evaluation (simplification) on the given expression. */ def eval(exp : IfExp, env : Map[String,Boolean]) : IfExp = ... /** Convert if-representation back to normal * Maps several if-forms onto more concise boolean expressions */ def convertToBool(exp : IfExp) : BoolExp = null }