Skip to main content

Designing an Algorithmic Proof of the Two-Squares Theorem

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 6120))

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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Dickson, L.E.: History of the Theory of Numbers: Diophantine Analysis: Diophantine Analysis, vol. 2. AMS/Chelsea Publication, American Mathematical Society (August 1999)

    Google Scholar 

  2. Bell, E.T.: Men of Mathematics - The Lives and Achievements of the Great Mathematicians from Zeno to Poincaré. Touchstone (July 2008)

    Google Scholar 

  3. Gauss, C.F.: Disquisitiones Arithmeticae. G. Fleischer, Leipzig (1801) English translation by Clarke, A. A. Springer, Heidelberg (1986)

    Google Scholar 

  4. Hermite: Note au sujet de l’article précédent. Journal de Mathématiques Pures et Appliquées 13, 15 (1848)

    Google Scholar 

  5. Serret, J.A.: Sur un théorème relatif aux nombres entiers. Journal de Mathématiques Pures et Appliquées 13, 12–14 (1848)

    Google Scholar 

  6. Brillhart, J.: Note on representing a prime as a sum of two squares. Mathematics of Computation 26(120), 1011–1013 (1972)

    Article  MATH  MathSciNet  Google Scholar 

  7. 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)

    Article  MATH  MathSciNet  Google Scholar 

  8. 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)

    Article  MATH  MathSciNet  Google Scholar 

  9. Aigner, M., Ziegler, G.: Proofs From The Book, 3rd edn. Springer, Heidelberg (2004)

    Google Scholar 

  10. 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

  11. Wagon, S.: Editor’s corner: The Euclidean algorithm strikes again. The American Mathematical Monthly 97(2), 125–129 (1990)

    Article  MATH  MathSciNet  Google Scholar 

  12. 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/

  13. 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)

    Chapter  Google Scholar 

  14. Gries, D.: The Science of Programming. Springer, Heidelberg (1981)

    MATH  Google Scholar 

  15. van de Snepscheut, J.L.: What Computing Is All About. Springer, New York (1993)

    MATH  Google Scholar 

  16. Dijkstra, E.W.: Program inversion. In: Selected Writings on Computing: A Personal Perspective, pp. 351–354. Springer, Heidelberg (1982)

    Google Scholar 

  17. van de Snepscheut, J.L.A.: Inversion of a recursive tree traversal. Inf. Process. Lett. 39(5), 265–267 (1991)

    Article  MATH  Google Scholar 

  18. 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)

    Chapter  Google Scholar 

  19. von Wright, J.: Program inversion in the refinement calculus. Inf. Process. Lett. 37(2), 95–100 (1991)

    Article  MATH  Google Scholar 

  20. 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)

    Google Scholar 

  21. Graham, R.L., Knuth, D.E., Patashnik, O.: Concrete Mathematics: a Foundation for Computer Science, 2nd edn. Addison-Wesley Publishing Company, Reading (1994)

    MATH  Google Scholar 

  22. 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)

    Google Scholar 

  23. 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)

    Google Scholar 

  24. 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)

    Article  MATH  MathSciNet  Google Scholar 

  25. 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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics