pattern match and subst.