If you're writing that theorem: Assuming you remember to include it in your premises.
Sometimes the invariant might not be mathematical, it might be social. I recall a story where 1/0 caused a problem because stock issuance uses a 0-share disbursement as a tombstone: to indicate that "this stock account has zeroed out this security and has no remaining ownership". You might not have remembered that and you might have forgotten to record that as a necessary invariant in your proofs. If lean had defined division to have a nonzero denominator, it would have caught the problem even if you didn't know that a zero share disbursement hada a different meaning.