Formalization of Amicable Numbers Theory

Zhipeng Chen, Haolun Tang, Jingyi Zhan · 2026

Read Formalization of Amicable Numbers Theory by Zhipeng Chen, Haolun Tang, Jingyi Zhan (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2601-07444.txt.

Introduction

Zhipeng Chen, Haolun Tang, and Jingyi Zhan formalize a classic number theory topic inside a proof assistant. Their 2026 preprint presents the theory of amicable numbers in Lean 4. Two positive integers form an amicable pair when each equals the sum of the other's proper divisors. The famous pair 220 and 284 has been known since ancient times.

Formalization means turning definitions and proofs into code a computer can check line by line. Every step must be exact, with no gaps left to human judgment. Building this theory in Lean tests both the software library and the clarity of the math itself. Readers interested in verified mathematics get a concrete example of an old idea made machine-checkable.

Catalog record

CREATORZhipeng Chen, Haolun Tang, Jingyi Zhan
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE47 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2601-07444

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Formalization of Amicable Numbers Theory Zhipeng Chen, Haolun Tang, Jingyi Zhan Abstract . This paper presents a formalization of the theory of amicable numbers in the Lean 4 proof assistant. Two positive integers m m and n n are called an amicable pair if the sum of proper divisors of m m equals n n and the sum of proper divisors of n n equals m m . Our formalization introduces the proper divisor sum function s ⁡ ( n ) = σ ⁡ ( n ) − n s(n)=\sigma(n)-n , defines the concepts of amicable pairs and amicable numbers, and computationally verifies historically famous amicable pairs. Furthermore, we formalize basic structural theorems, including symmetry, non-triviality, and connections to abundant/deficient numbers. A key contribution is the complete formal proof of the classical Thābit formula (9th century), using index-shifting and the zify tactic. Additionally, we provide complete formal proofs of both Thābit’s rule and Euler’s generalized rule (1747), two fundamental theorems for generating amicable pairs. A major achievement is the first complete formalization of the Borho-Hoffmann breeding method (1986), comprising 540 lines with 33 theorems and leveraging automated algebra tactics ( zify and ring ) to verify complex polynomial identities. We also formalize extensions including sociable numbers (aliquot cycles), betrothed numbers (quasi-amicable pairs), parity constraint theorems, and computational search bounds for coprime pairs ( > 10 65 >10^{65} ). We verify the smallest sociable cycle of length 5 (Poulet’s cycle) and computationally verify specific instances. The formalization comprises 2076 lines of Lean code organized into Mathlib-candidate and paper-specific modules, with 139 theorems and all necessary infrastructure for divisor sum multiplicativity and coprimality reasoning. 1. Introduction Amicable numbers are among the oldest and most fascinating objects of study in number theory. Two positive integers m and n are said to form an amicable pair if the sum of proper divisors of m equals n , and simultaneously the sum of proper divisors of n equals m . This concept dates back to ancient Greece, where the Pythagoreans knew the smallest amicable pair (220,284) as early as the 5th century BC. The ancients attributed mystical significance to these numbers, viewing them as symbols of perfect friendship—just as two friends whose individual worth precisely equals the other. The study of amicable numbers spans more than two millennia. In the 9th century, the Arab mathematician Thābit discovered a formula for systematically generating amicable pairs, a result that was rediscovered centuries later by Fermat and Descartes [ 1 , 2 ] . In 1636, Fermat used this formula to find the amicable pair (17296,18416) . Two years later, Descartes discovered (9363584,9437056) . In 1747, Euler conducted a systematic investigation and discovered 60 new pairs [ 2 ] . However, the most surprising discovery came in 1866: a 16-year-old Italian boy named Niccolò Paganini found the amicable pair (1184,1210) , which is the second smallest pair by size, yet had been overlooked by all mathematicians for over two thousand years. To date, more than 1.2 billion amicable pairs are known [ 3 ] , yet many fundamental questions remain unsolved. Erdős proved that the counting function A(x) for amicable numbers grows slower than linearly [ 4 ] , with refined bounds by Pomerance [ 5 , 6 ] . Are there infinitely many amicable pairs? Do there exist amicable pairs where both members are odd? Do coprime amicable pairs exist? Despite computational searches up to 10^{65} [ 7 ] , all these questions remain open. This state of affairs—an abundance of concrete examples coexisting with unresolved fundamental problems—makes amicable number theory an ideal subject for formalization. The use of proof assistants for formal verification of mathematical theorems has become an important component of mathematical research. The Lean theorem prover, particularly its fourth version, has gained widespread adoption in the mathematical community thanks to its powerful type system and rich mathematical library Mathlib [ 8 , 9 ] . Recent successes include the formalization of Fermat’s Last Theorem for regular primes [ 10 , 11 ] , demonstrating Lean’s capability for deep number-theoretic results. In parallel, Koutsoukou-Argyraki formalized amicable number theory in Isabelle/HOL [ 12 ] , providing formal statements of classical generation rules. These efforts not only verify the correctness of mathematical conclusions but also provide reliable formal foundations for subsequent research. This paper presents a comprehensive formalization of amicable number theory in Lean 4. Our key contributions include: (1) complete formal proofs of three classical generation methods—Thābit formula (9th century), Euler’s generalized rule (1747), and the Borho-Hoffmann breeding method (1986), the latter being the first complete machine-verified proof of this result to our knowledge; (2) novel applications of the zify and ring tactics to automate complex polynomial identities; (3) formalization of extensions including sociable numbers (aliquot cycles), betrothed numbers (quasi-amicable pairs), and formal statements of major open problems; (4) computational verification of historically famous amicable pairs and Poulet’s sociable cycle of length 5. The complete formalization comprises 2076 lines of code with 139 theorems and zero sorry placeholders, representing the most comprehensive formal treatment of amicable number theory to date. 2. Mathematical Background We first establish the mathematical foundations of amicable number theory. Let n be a positive integer and denote by \sigma(n) the sum of all positive divisors of n , i.e., \sigma(n)=\sum_{d\mid n}d . For example, \sigma(12)=1+2+3+4+6+12=28 . {defi} [Proper Divisor Sum] The proper divisor sum of a positive integer n is defined as the sum of all proper divisors of n (i.e., divisors other than n itself), denoted s(n) . Equivalently, s(n)=\sigma(n)-n=\sum_{\begin{subarray}{c}d\mid n\\ d<n\end{subarray}}d. (1) For n=1 , since 1 has no proper divisors, we have s(1)=0 . For a prime p , since the only proper divisor of p is 1, we have s(p)=1 . As a classic example in amicable number research, 220=2^{2}\cdot 5\cdot 11 has proper divisors \{1,2,4,5,10,11,20,22,44,55,110\} , whose sum is 1+2+4+5+10+11+20+22+44+55+110=284 . Similarly, 284=2^{2}\cdot 71 has proper divisors \{1,2,4,71,142\} , whose sum is 1+2+4+71+142=220 . {defi} [Amicable Pair] Two distinct positive integers m and n are called an amicable pair , denoted as (m,n) being amicable, if and only if s(m)=n\hskip 10.00002pt\text{and}\hskip 10.00002pts(n)=m. (2) Equivalently, using the divisor sum function, this can be expressed as \sigma(m)=\sigma(n)=m+n . The requirement m\neq n in the definition excludes perfect numbers. Recall that a perfect number is a positive integer n satisfying s(n)=n ; if we allowed m=n , every perfect number would form an “amicable pair with itself,” which contradicts the spirit of “amicability.” {defi} [Amicable Number] A positive integer n is called an amicable number if it is a member of some amicable pair. Thus, 220 , 284 , 1184 , 1210 , and so forth are all amicable numbers. Using the equivalent characterization via divisor sums, verifying an amicable pair is straightforward: simply compute the divisor sum of each number and check whether both equal the sum of the two numbers. Amicable numbers have natural connections with two other classical concepts—abundant and deficient numbers. A number n is called abundant if s(n)>n , deficient if s(n)<n , and perfect if s(n)=n . For an amicable pair (m,n) with m<n , since s(m)=n>m , we know m is abundant, while since s(n)=m<n , we know n is deficient. Therefore, in

Read the complete text