<s>[INST] Logically speaking, why can variables be substituted? Suppose that
$$a^2+a+1=b$$
Suppose also that $a=5/4$. What makes it valid to substitute $5/4$ into the first equation? Is it because equality is transitive?
 [/INST] The reason why you can make such a substitution is that $a$ and $\dfrac{5}{4}$ are precisely the same, just written differently. Here's a long-winded way of making the substitution you describe.
\begin{align*}
a &= \frac{5}{4} & \\
a^2 &= \left(\frac{5}{4}\right)^2 &\text{squaring both sides}\\
a^2 + a &= \left(\frac{5}{4}\right)^2 + \frac{5}{4} &\text{adding the first two lines}\\
a^2 + a + 1 &= \left(\frac{5}{4}\right)^2 + \frac{5}{4}+1 &\text{adding $1$ to both sides}\\
b &= \left(\frac{5}{4}\right)^2 + \frac{5}{4}+1 &\text{using the fact that $a$ satisfies the given equation}
\end{align*}
The right hand side is precisely what you obtain when you replace $a$ by $\dfrac{5}{4}$.
</s>