Abstract
We show a new and constructive proof of the two-squares theorem, based on a somewhat unusual, but very effective, way of rewriting the so-called extended Euclid’s algorithm. Rather than simply verifying the result—as it is usually done in the mathematical community—we use Euclid’s algorithm as an interface to investigate which numbers can be written as sums of two positive squares. The precise formulation of the problem as an algorithmic problem is the key, since it allows us to use algorithmic techniques and to avoid guessing. The notion of invariance, in particular, plays a central role in our development: it is used initially to observe that Euclid’s algorithm can actually be used to represent a given number as a sum of two positive squares, and then it is used throughout the argument to prove other relevant properties. We also show how the use of program inversion techniques can make mathematical arguments more precise.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Dickson, L.E.: History of the Theory of Numbers: Diophantine Analysis: Diophantine Analysis, vol. 2. AMS/Chelsea Publication, American Mathematical Society (August 1999)
Bell, E.T.: Men of Mathematics - The Lives and Achievements of the Great Mathematicians from Zeno to Poincaré. Touchstone (July 2008)
Gauss, C.F.: Disquisitiones Arithmeticae. G. Fleischer, Leipzig (1801) English translation by Clarke, A. A. Springer, Heidelberg (1986)
Hermite: Note au sujet de l’article précédent. Journal de Mathématiques Pures et Appliquées 13, 15 (1848)
Serret, J.A.: Sur un théorème relatif aux nombres entiers. Journal de Mathématiques Pures et Appliquées 13, 12–14 (1848)
Brillhart, J.: Note on representing a prime as a sum of two squares. Mathematics of Computation 26(120), 1011–1013 (1972)
Clarke, F.W., Everitt, W.N., Littlejohn, L.L., Vorster, S.J.R.: H. J. S. Smith and the Fermat two squares theorem. The American Mathematical Monthly 106(7), 652–665 (1999)
Zagier, D.: A one-sentence proof that every prime p ≡ 1(mod 4) is a sum of two squares. The American Mathematical Monthly 97(2), 144 (1990)
Aigner, M., Ziegler, G.: Proofs From The Book, 3rd edn. Springer, Heidelberg (2004)
Dijkstra, E.W.: A derivation of a proof by D. Zagier. Circulated privately (August 1993), http://www.cs.utexas.edu/users/EWD/ewd11xx/EWD1154.PDF
Wagon, S.: Editor’s corner: The Euclidean algorithm strikes again. The American Mathematical Monthly 97(2), 125–129 (1990)
Backhouse, R., Ferreira, J.F.: On Euclid’s algorithm and elementary number theory. To appear in the journal Science of Computer Programming (2010), http://joaoff.com/publications/2009/euclid-alg/
Backhouse, R., Ferreira, J.F.: Recounting the rationals: Twice! In: Audebaud, P., Paulin-Mohring, C. (eds.) MPC 2008. LNCS, vol. 5133, pp. 79–91. Springer, Heidelberg (2008)
Gries, D.: The Science of Programming. Springer, Heidelberg (1981)
van de Snepscheut, J.L.: What Computing Is All About. Springer, New York (1993)
Dijkstra, E.W.: Program inversion. In: Selected Writings on Computing: A Personal Perspective, pp. 351–354. Springer, Heidelberg (1982)
van de Snepscheut, J.L.A.: Inversion of a recursive tree traversal. Inf. Process. Lett. 39(5), 265–267 (1991)
Chen, W.: A formal approach to program inversion. In: CSC ’90: Proceedings of the 1990 ACM annual conference on Cooperation, pp. 398–403. ACM Press, New York (1990)
von Wright, J.: Program inversion in the refinement calculus. Inf. Process. Lett. 37(2), 95–100 (1991)
Mu, S.C., Bird, R.: Rebuilding a tree from its traversals: A case study of program inversion. In: Ohori, A. (ed.) APLAS 2003. LNCS, vol. 2895, pp. 265–282. Springer, Heidelberg (2003)
Graham, R.L., Knuth, D.E., Patashnik, O.: Concrete Mathematics: a Foundation for Computer Science, 2nd edn. Addison-Wesley Publishing Company, Reading (1994)
Buhler, J., Wagon, S.: Basic algorithms in number theory. In: Buhler, J.P., Stevenhagen, P. (eds.) Algorithmic Number Theory. Lattices, Number Fields, Curves and Cryptography, pp. 25–68. Cambridge University Press, Cambridge (2008)
Cornacchia, G.: Su di un metodo per la risoluzione in numeri interi dell’equazione \(\sum_{h=0}^{n} {C}_{h} x^{n-h} y^{h}={P}\). Giornale di Matematiche di Battaglini 46, 33–90 (1908)
Hardy, K., Muskat, J.B., Williams, K.S.: A deterministic algorithm for solving n = fu 2 + gv 2 in coprime integers u and v. Mathematics of Computation 55(191), 327–343 (1990)
Ferreira, J.F., Mendes, A., Backhouse, R., Barbosa, L.S.: Which mathematics for the information society? In: Oliveira, J. (ed.) TFM 2009. LNCS, vol. 5846, pp. 39–56. Springer, Heidelberg (2009)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Ferreira, J.F. (2010). Designing an Algorithmic Proof of the Two-Squares Theorem. In: Bolduc, C., Desharnais, J., Ktari, B. (eds) Mathematics of Program Construction. MPC 2010. Lecture Notes in Computer Science, vol 6120. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-13321-3_10
Download citation
DOI: https://doi.org/10.1007/978-3-642-13321-3_10
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-13320-6
Online ISBN: 978-3-642-13321-3
eBook Packages: Computer ScienceComputer Science (R0)