Build the idea in three steps
- Put squares on a four-hour clock: 0 ^ 2 = 0, 1 ^ 2 = 1, 2 ^ 2 = 4 lands on 0, and 3 ^ 2 = 9 lands on 1. Whole-number squares only ever sit at 0 or 1 — the seat 2 stays empty.
- The theorem sq_ne_two_fin_zmod_four says exactly that on the Lean clock type ZMod 4, and its proof is fin_cases plus decide: visit every position, check all four, done — a census, not a clever trick.
- The integer version Int.sq_ne_two_mod_four transfers it to ordinary squares with remainders. This little census is a school-sized telescope: it will tell the exponent-four case which leg of a triangle must be even.
A small example
Try it: 5 ^ 2 = 25 = 6 × 4 + 1 leaves remainder 1, and 6 ^ 2 = 36 = 9 × 4 leaves remainder 0. No integer square leaves remainder 2 when divided by 4.