Pseudocode for simplify, evaluate, substitute