Big O and Termination
We want to make sure that we cannot get into a loop by transforming an equation endlessly.
Well-founded Ordering: If a program has an input that is finite and gets smaller in each recursion, and the program stops when the input reaches a lower boundary, then the program is guaranteed to terminate.
Our program assumes that initially the lhs is only a single variable. Each recursive step makes the rhs smaller.
We don't have to worry about Big O for this problem because the number of operations is limited by the size of the expression tree, which is always small.