substitute_vars(x, rules) replaces subexpressions of x as given by
rules (formulas x ~ 2, pairs list(x, 2), or a named list), in one
top down pass. x may be an expression, an equation, a list, or a
System, in which case equations, unknowns, parameters, variable maps,
observed equations, costs, constraints and subsystems are substituted, as
substitute(sys, rules) in ModelingToolkit. With a named list of systems,
the subsystems of those names are replaced. This is ModelingToolkit's
substitute, renamed so that base::substitute is not masked.