folding in the subtype checking and simplification for derivative