That's actually needed for a real proof. One should keep in mind that y = ax is not injective if a=0, so that "cancel a variable" step you're thinking of is most likely incorrect without that side-condition.
Re:Division by zero in type theory: a FAQ
by thaumasiotes on Monday July 06, 2020 @05:24PM
(#23752937)
...yes?
(You may then do a separate proof in the case that x = 0, if you want to prove something for all x including 0.)