We want to show that any divisor
-
$M(n) \equiv 2^n - 1 \equiv 0 \pmod d$ (given) -
$2^n \equiv 1 \pmod d$ (restatement of step (1)) -
$\left( 2^{(n/2)}\right)^{d-1} \equiv 2^{\left(\frac {n(d-1)} 2 \right)} \equiv \left(2^n\right)^{\left( \frac {d-1} 2 \right)} \equiv 1 \pmod d$ (step (2),$d-1$ is even) -
$(2^{n/2})^{d-1} \equiv 1 \pmod d \rightarrow$ $d$ is pseudo-prime in base$2^{n/2}$ (definition)
Thus,
I am working on a formalization of this argument at https://gist.github.com/tdunning/346e058011badd6b90f0b35e04aa91ef
Comments and suggestions welcome since I know soooo little about coding up proofs in Lean4.
A number
You should use the latex command \pmod for the congruence relation (rather than mod operation).$d \mid M(n)$ which is what is really given in the first place. Writing this in front of $2^n-1 = 0\pmod d$ might help to understand when a reader comes here for the first time. (I speak for myself.)
Also, the "given" relation (step 1) could be seen as restatement of
Final remark: rigorously speaking, the Definition of a pseudo-prime includes the condition that the number is composite, since one does not want all primes in the list of pseudoprimes.