// Expression trait // Write specifications for Eval, Simplify, & ConstantOf: // Eval needs a precondition? // Simplify needs a postcondition, the result should be correct w.r.t. Eval? // ConstantOf needs a postcondition, maybe the result is a conservative estimate? datatype Option = None | Some(value: T) type Var = string type Env = map trait Expression { ghost predicate Valid() ghost function FreeVars(): set requires Valid() // Compute an expression's value, given values for all of its variables. function Eval(env: Env): real // Create a new expression where algebraic simplification rules have been applied. method Simplify() returns (e: Expression) // Check if this expression represents a constant. function ConstantOf(): (k: Option) }