This article provides a formalized proof of the so-called “the four-square theorem”, namely any natural number can be expressed by a sum of four squares, which was proved by Lagrange in 1770. An informal proof of the theorem can be found in the number theory literature, e.g. in [14], [1] or [23].
This theorem is item #19 from the “Formalizing 100 Theorems” list maintained by Freek Wiedijk at http://www.cs.ru.nl/F.Wiedijk/100/.Suginami-ku Matsunoki 6, 3-21 Tokyo, JapanAlan Baker. A Concise Introduction to the Theory of Numbers. Cambridge University Press, 1984.Grzegorz Bancerek. Cardinal numbers. Formalized Mathematics, 1(2):377–382, 1990.Grzegorz Bancerek. Cardinal arithmetics. Formalized Mathematics, 1(3):543–547, 1990.Grzegorz Bancerek. The fundamental properties of natural numbers. Formalized Mathematics, 1(1):41–46, 1990.Grzegorz Bancerek. The ordinal numbers. Formalized Mathematics, 1(1):91–96, 1990.Grzegorz Bancerek and Krzysztof Hryniewiecki. Segments of natural numbers and finite sequences. Formalized Mathematics, 1(1):107–114, 1990.Czesław Byliński. The complex numbers. Formalized Mathematics, 1(3):507–513, 1990.Czesław Byliński. Functions and their basic properties. Formalized Mathematics, 1(1): 55–65, 1990.Czesław Byliński. Functions from a set to a set. Formalized Mathematics, 1(1):153–164, 1990.Czesław Byliński. Partial functions. Formalized Mathematics, 1(2):357–367, 1990.Czesław Byliński. Some basic properties of sets. Formalized Mathematics, 1(1):47–53, 1990.Agata Darmochwał. Finite sets. Formalized Mathematics, 1(1):165–167, 1990.Yoshinori Fujisawa, Yasushi Fuwa, and Hidetaka Shimizu. Public-key cryptography and Pepin’s test for the primality of Fermat numbers. Formalized Mathematics, 7(2):317–321, 1998.G.H. Hardy and E.M. Wright. An Introduction to the Theory of Numbers. Oxford University Press, 1980.Artur Korniłowicz and Piotr Rudnicki. Fundamental Theorem of Arithmetic. Formalized Mathematics, 12(2):179–186, 2004.Rafał Kwiatek. Factorial and Newton coefficients. Formalized Mathematics, 1(5):887–890, 1990.Rafał Kwiatek and Grzegorz Zwara. The divisibility of integers and integer relatively primes. Formalized Mathematics, 1(5):829–832, 1990.Xiquan Liang, Li Yan, and Junjie Zhao. Linear congruence relation and complete residue systems. Formalized Mathematics, 15(4):181–187, 2007. doi:10.2478/v10037-007-0022-7.Piotr Rudnicki and Andrzej Trybulec. Abian’s fixed point theorem. Formalized Mathematics, 6(3):335–338, 1997.Christoph Schwarzweller. Modular integer arithmetic. Formalized Mathematics, 16(3): 247–252, 2008. doi:10.2478/v10037-008-0029-8.Michał J. Trybulec. Integers. Formalized Mathematics, 1(3):501–505, 1990.Zinaida Trybulec. Properties of subsets. Formalized Mathematics, 1(1):67–71, 1990.Hideo Wada. The World of Numbers (in Japanese). Iwanami Shoten, 1984.Edmund Woronowicz. Relations and their basic properties. Formalized Mathematics, 1 (1):73–83, 1990.Edmund Woronowicz. Relations defined on sets. Formalized Mathematics, 1(1):181–186, 1990