Windmills of the Minds: A Hopping Algorithm for Fermat's Two Squares Theorem

Hing Lun Chan
DOI: https://doi.org/10.1007/s10817-024-09708-3
2024-10-23
Journal of Automated Reasoning
Abstract:Fermat's two squares theorem asserts that a prime one more than a multiple of 4 is a sum of two squares. There are many proofs of this gem in number theory, including a remarkable one-sentence proof by Don Zagier based on two involutions on a finite set built from such a prime. Applying the two involutions alternatively leads to an iterative algorithm to find the two squares for the prime. Moreover, a detailed analysis of the computation reveals that it is possible to jump through the iteration nodes, leading to a better hopping algorithm. Here is a formalisation of Zagier's proof, deriving the involutions using windmill patterns. Theories developed for the formal proof are used to establish the correctness of both algorithms.
computer science, artificial intelligence
What problem does this paper attempt to address?