Two infinite families of base-6 Lychrel numbers
Reverse-and-add in base 6 adds a number to its digits reversed. Lean proves that the numbers in two explicit infinite families never reach a palindrome, a number whose base-6 digits read the same backwards: twelve steps turn each member into a longer member of the same family.
For every m ≥ 0, twelve base-6 reverse-and-add steps take x(m) exactly to x(m + 3) and y(m) exactly to y(m + 3), and none of the numbers at steps 0 to 11 is a base-6 palindrome; so no number on the path of any member of either family is ever a base-6 palindrome, the six paths starting at x(0), x(1), x(2), y(0), y(1) and y(2) never share a number, and for every D ≥ 113 at least 12(D − 110) numbers below 6^D never reach a base-6 palindrome.
A Lychrel number never reaches a palindrome under reverse-and-add. In base 10 none has been proved to be one, and 196 is the famous suspect. OEIS A060382 says of the smallest suspects in each base: "Only a(2) is proved, all the others are conjectured." The families here were found with the search method of Y. Kusayama's public project, reimplemented from its written description and run past its limit of 16,777,216 states.
Twelve steps from x(0)
In base 6, 4555 + 5554 = 14553. In base 10 that is 1079 + 1294 = 2373, one reverse-and-add step.
Let M be the fixed 98-digit base-6 string 51205333311140120314023333455033454445045111143030303402105410435042415533433154131110322133335011. Then x(m) is 133535, then m fives, then M, then m zeros, then 003443, so it has 110 + 2m digits. And y(m) is 13343, then m zeros, then M with every digit g replaced by 5 − g, then m fives, then 52443, with 108 + 2m digits.
x(0) in base 10 is the 86-digit number 10597199767879923759424316990930862796672101123713351165673551415976972661719017382131. The numbers at steps 0 to 11 of its path have 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115 and 115 base-6 digits, none is a palindrome, and step 12 lands exactly on x(3).
Why the length of the runs never matters: a column whose two digits are 5 and 0 passes on the carry it receives. With carry 0 it writes 5 and carries 0; with carry 1 it writes 0 and carries 1.
Repeating, 2,400 steps from x(0) reach exactly x(600), a number of 1,310 base-6 digits.
Reverse-and-add on digit lists
A step adds a number to the number its base-6 digits spell backwards. A palindrome reads the same both ways, and a number is a base-6 Lychrel number when no step, including step 0, gives a palindrome. Lean also adds digit lists column by column with carries, and proves this agrees with the step on numbers, so the rest of the proof can work on digits.
Reverse-and-add on lists matches the step on numbers
For a proper list, the number spelled by its reverse-and-add list is the reverse-and-add step of the number it spells.
theorem LychrelBase6.ofDigits6MSB_revAddMSB6 {ds : List ℕ} (hds : ValidMSB6 ds) : ofDigits6MSB (revAddMSB6 ds) = revAdd6 (ofDigits6MSB ds)- The base-6 reverse
- One reverse-and-add step
- A base-6 palindrome
- A base-6 Lychrel number
- The number a digit list spells
- A proper digit list
- Column addition
Column addition adds
For lists of equal length, the output digits plus the final carry times 6 to the length equal the sum of the two inputs plus the incoming carry.
theorem LychrelBase6.ofDigits6_addLSB6Aux (as : List ℕ) (bs : List ℕ) (c : ℕ) (a.0 : as.length = bs.length) : Nat.ofDigits 6 (addLSB6Aux as bs c).1 + (addLSB6Aux as bs c).2 * 6 ^ as.length = Nat.ofDigits 6 as + Nat.ofDigits 6 bs + c
- Finishing a sum
- Reverse-and-add on a digit list
One step on a whole template at once
A template is a digit string A, a run of k copies of a digit h, a middle M, a run of k copies of l, and an end Z, with A and Z of equal length and h + l = 5. Under a step, each run lines up with the other run, and a column of h and l only passes its carry on, so one computation on A, M and Z gives the next template for every run length k at once. A template with k ≥ 1 is never a palindrome, because the digits h and l face each other and 5 is odd.
The template step is right, on numbers
For a valid template and every run length k, with k ≥ 1 if the top carries out, one reverse-and-add step on its number gives the number of the next template, with run length k, or k − 1 if the top carried out.
theorem LychrelBase6.stepForm_sound {F : Form} (hF : ValidForm F) (k : ℕ) (hk : (stepForm F).2 = true → 1 ≤ k) : revAdd6 (formVal F k) = formVal (stepForm F).1 (if (stepForm F).2 = true then k - 1 else k)- A template
- The digits of a template
- The number of a template
- A valid template
- Checking a template
A column of h and l passes its carry on
If h + l = 5 and the incoming carry c is 0 or 1, the column writes 5 and carries 0 when c = 0, and writes 0 and carries 1 when c = 1.
theorem LychrelBase6.carry_pair_sum_five {h : ℕ} {l : ℕ} {c : ℕ} (hsum : h + l = 5) (hc : c ≤ 1) : ((h + l + c) % 6 = if c = 0 then 5 else 0) ∧ (h + l + c) / 6 = cA whole run passes its carry on
Adding k copies of l to k copies of h, with h + l = 5 and incoming carry c ≤ 1, writes k copies of one digit and carries c out.
theorem LychrelBase6.addLSB6Aux_replicate (k : ℕ) {h : ℕ} {l : ℕ} {c : ℕ} (a.0 : h + l = 5) (a.0 : c ≤ 1) : addLSB6Aux (List.replicate k l) (List.replicate k h) c = (List.replicate k (if c = 0 then 5 else 0), c)- Finishing a template step
- One step on a template
The template step is right, on digits
For a valid template and every run length k, with k ≥ 1 if the top carries out, reverse-and-add on its digits gives the next template, with run length k, or k − 1 if the top carried out.
theorem LychrelBase6.stepForm_eval {F : Form} (hF : ValidForm F) (k : ℕ) (hk : (stepForm F).2 = true → 1 ≤ k) : revAddMSB6 (evalForm F k) = evalForm (stepForm F).1 (if (stepForm F).2 = true then k - 1 else k)A template with runs is never a palindrome
For a valid template and k ≥ 1, the number is not a base-6 palindrome.
theorem LychrelBase6.form_not_palindrome {F : Form} (hF : ValidForm F) {k : ℕ} (hk : 1 ≤ k) : ¬IsPalindrome6 (formVal F k)- Many template steps
- Every template on the way is valid
Many template steps are right
If every template before step n is valid and the run length m is at least the number of carry-outs, n steps on the number give the number of the template after n steps, with run length m minus the carry-outs.
theorem LychrelBase6.stepFormN_sound {F : Form} (n : ℕ) (m : ℕ) (hvalid : allValidBefore F n = true) (hm : (stepFormN F n).2 ≤ m) : revAdd6^[n] (formVal F m) = formVal (stepFormN F n).1 (m - (stepFormN F n).2)No palindrome during many template steps
If every template before step n is valid and the runs never run out, none of the numbers at steps t < n is a palindrome.
theorem LychrelBase6.stepFormN_no_pal {F : Form} (n : ℕ) (m : ℕ) (hvalid : allValidBefore F n = true) (hm : ∀ t < n, (stepFormN F t).2 + 1 ≤ m) (t : ℕ) (a.0 : t < n) : ¬IsPalindrome6 (revAdd6^[t] (formVal F m))Regrouping a template, on numbers
The same regrouping gives the same number.
theorem LychrelBase6.formVal_regroup (F : Form) (F' : Form) (p : ℕ) (q : ℕ) (k : ℕ) (hA : F'.A = F.A ++ List.replicate p F.h) (hh : F'.h = F.h) (hM : F'.M = List.replicate q F.h ++ F.M ++ List.replicate q F.l) (hl : F'.l = F.l) (hZ : F'.Z = List.replicate p F.l ++ F.Z) : formVal F' k = formVal F (p + k + q)
- Checking a run of template steps
The run check is right
If the check passes and the run length m is large enough at every step, the steps on the number reach the target number, and no number on the way is a palindrome.
theorem LychrelBase6.checkSymbolicPattern_sound (pat : List Bool) (F : Form) (Ftarget : Form) (m : ℕ) (a.0 : checkSymbolicPattern pat F Ftarget = true) (a.0 : List.count true pat ≤ m) (a.0 : ∀ t < pat.length, List.count true (List.take t pat) + 1 ≤ m) : revAdd6^[pat.length] (formVal F m) = formVal Ftarget (m - List.count true pat) ∧ ∀ t < pat.length, ¬IsPalindrome6 (revAdd6^[t] (formVal F m))
- Checking a listed chain of templates
Copying itself forever means never a palindrome
If P > 0, P steps always take f(m) to f(m + δ), and no f(m) meets a palindrome in its steps 0 to P − 1, then every f(m) is a base-6 Lychrel number.
theorem LychrelBase6.lychrel6_of_period_shift {f : ℕ → ℕ} {P : ℕ} {δ : ℕ} (hP : 0 < P) (hstep : ∀ (m : ℕ), revAdd6^[P] (f m) = f (m + δ)) (hnopal : ∀ (m t : ℕ), t < P → ¬IsPalindrome6 (revAdd6^[t] (f m))) (m : ℕ) : IsLychrel6 (f m)
Both families copy themselves every twelve steps
For m ≥ 6, Lean runs twelve template steps from the template of x(m) and checks that it arrives at the template of x(m + 3) with no palindrome on the way; six of the twelve steps carry out at the top and use up one digit of each run. For m from 0 to 5 it checks the twelve steps digit by digit. The same holds for y(m). Repeating the twelve steps forever shows that every member of both families is a base-6 Lychrel number, and x(m) never equals y(n).
Twelve steps take x(m) to x(m + 3)
For every m ≥ 0, twelve reverse-and-add steps take x(m) exactly to x(m + 3), and none of the numbers at steps 0 to 11 is a base-6 palindrome.
theorem LychrelBase6.xFam_cycle_and_no_pal (m : ℕ) : revAdd6^[12] (xFam m) = xFam (m + 3) ∧ ∀ t < 12, ¬IsPalindrome6 (revAdd6^[t] (xFam m))
Twelve steps take y(m) to y(m + 3)
For every m ≥ 0, twelve reverse-and-add steps take y(m) exactly to y(m + 3), and none of the numbers at steps 0 to 11 is a base-6 palindrome.
theorem LychrelBase6.yFam_cycle_and_no_pal (m : ℕ) : revAdd6^[12] (yFam m) = yFam (m + 3) ∧ ∀ t < 12, ¬IsPalindrome6 (revAdd6^[t] (yFam m))
- The carry-out pattern
- The template after twelve steps
- The template of x
- The family x(m)
- The twelve templates of x
The twelve template steps of x check
The run check passes from the template of x to its regrouped template after twelve steps.
theorem LychrelBase6.xForm0_symbolic_cert : checkSymbolicPattern overflowPattern12 xForm0 (regroupTarget63 xForm0) = true
x(m) for m ≥ 6
For every m ≥ 6, twelve steps take x(m) to x(m + 3), and none of the numbers at steps 0 to 11 is a palindrome.
Every x(m) is a base-6 Lychrel number
For every m, x(m) never reaches a base-6 palindrome.
theorem LychrelBase6.xFam_lychrel (m : ℕ) : IsLychrel6 (xFam m)
- The template of y
- The family y(m)
- The twelve templates of y
The twelve template steps of y check
The run check passes from the template of y to its regrouped template after twelve steps.
y(m) for m ≥ 6
For every m ≥ 6, twelve steps take y(m) to y(m + 3), and none of the numbers at steps 0 to 11 is a palindrome.
Every y(m) is a base-6 Lychrel number
For every m, y(m) never reaches a base-6 palindrome.
There are infinitely many base-6 Lychrel numbers
The set of base-6 Lychrel numbers is infinite.
The two families mirror each other
Replacing every base-6 digit d by 5 − d and every carry c by 1 − c turns a column sum into the mirrored column sum. Lean checks that at every one of the twelve steps the middle of y is the mirror of the middle of x, and the run digits are mirrored too, while the carries out of the bottom go 0, 1, 0, 1, … for x and 1, 0, 1, 0, … for y, and the carries out of the middle go the other way round.
At every step, y mirrors x
For every t ≤ 12, after t template steps the middle of y is the mirror of the middle of x, and the run digits h and l of y are the mirrors of those of x.
theorem LychrelBase6.stepFormN_xForm0_yForm0_duality {t : ℕ} (ht : t ≤ 12) : (stepFormN yForm0 t).1.M = compList6 (stepFormN xForm0 t).1.M ∧ (stepFormN yForm0 t).1.h = compDigit6 (stepFormN xForm0 t).1.h ∧ (stepFormN yForm0 t).1.l = compDigit6 (stepFormN xForm0 t).1.l- The mirror of a digit
- The mirror of a digit list
A mirrored column adds to the mirrored sum
For digits a, b < 6 and carry c ≤ 1, the column (5 − a) + (5 − b) + (1 − c) equals 11 − (a + b + c); it writes the mirror of the digit a + b + c writes, and carries 1 minus that carry.
Mirrored column addition
For two lists of base-6 digits of equal length and a carry c of 0 or 1, adding their mirrors with carry 1 − c gives the mirror of the digits and 1 minus the final carry.
- The carry out of the bottom
- The carry out of the middle
- The carry out of the top
A template step keeps the mirror
For templates F₁ and F₂ with F₁ valid: if they have mirrored middles and opposite bottom carries, and both steps carry out alike, then their middle carries in that step are opposite, and after it their middles and run digits are mirrored.
- The 13 templates of x
- The 13 templates of y
A mirror symmetry of the search machine, in every base
The search that finds such families runs a machine that reads the middle of a candidate column by column. For any base B ≥ 2, Lean defines this machine and a mirror map that sends each digit d to B − 1 − d and each carry c to 1 − c. It proves that the mirror sends the start node of one carry pattern to the start node of the opposite pattern, every move to a move, every path to a path, and every way of closing the middle to a way of closing it.
The mirror sends paths to paths, in every base
For every base B ≥ 2, valid nodes and a list of column pairs with digits below B, the machine has a path reading that list exactly when it has a path between the mirrored nodes reading the mirrored columns.
theorem LychrelBase6.centerPath_phi {B : ℕ} (hB : 2 ≤ B) {ov : List Bool} {nd : CenterNode} {nd' : CenterNode} {cols : List (ℕ × ℕ)} (hnd : ValidCenterNode B ov nd) (hnd' : ValidCenterNode B ov nd') (hcols : ∀ κ ∈ cols, κ.1 < B ∧ κ.2 < B) : CenterPath B ov nd cols nd' ↔ CenterPath B ov (phiCenterNode B ov nd) (List.map (phiCol B) cols) (phiCenterNode B ov nd')- The state for one step of the period
- The mirror of a list of states
- The mirror of a column pair
- A node of the search machine
- A valid node
- The mirror of a node
- The states at the edge of the runs
The mirror swaps the two start nodes
For B ≥ 2 and a non-empty carry pattern of 0s and 1s, the mirror of its start node is the start node of the opposite pattern.
- Reading one column at every step of the period
- A move of the machine
The mirror sends moves to moves
For B ≥ 2, valid nodes and a column pair with digits below B, there is a move by that column exactly when there is a move between the mirrored nodes by the mirrored column.
- A path of the machine
The mirror sends closings to closings
For B ≥ 2, a valid node and a middle digit below B, the mirrored node closes with middle digit B − 1 − middle exactly when the node closes with middle.
Six paths that never meet
Every step makes a positive number larger, so a path never repeats. After t steps from x(m) the number has exactly 110 + 2m + ⌊t/2⌋ base-6 digits, and from y(m) exactly 108 + 2m + ⌊t/2⌋. Every member of the families lies on the path of x(0), x(1), x(2), y(0), y(1) or y(2), and comparing digits at fixed places shows that no two of these six paths share a number. Every number on them is a base-6 Lychrel number.
The six paths never share a number
If t₁ steps from one of the six starting numbers equal t₂ steps from one of them, it is the same starting number and t₁ = t₂.
theorem LychrelBase6.sixSeedMap_injective : Function.Injective sixSeedMap
Every number on the six paths is a positive Lychrel number
For every starting number s among the six and every t, the number t steps from s is at least 1 and is a base-6 Lychrel number.
theorem LychrelBase6.sixSeedMap_pos_and_lychrel (p : Fin 6 × ℕ) : 1 ≤ sixSeedMap p ∧ IsLychrel6 (sixSeedMap p)
A path keeps growing
For n ≥ 1, the numbers at steps 0, 1, 2, … strictly increase.
Every number on a Lychrel path is Lychrel
If n is a base-6 Lychrel number, so is the number after any number of steps.
12k steps take x(m) to x(m + 3k)
For all m and k, 12k steps take x(m) to x(3k + m).
12k steps take y(m) to y(m + 3k)
For all m and k, 12k steps take y(m) to y(3k + m).
Every number on a path from x(m) is Lychrel
For all m and t, the number t steps from x(m) is a base-6 Lychrel number.
Every number on a path from y(m) is Lychrel
For all m and t, the number t steps from y(m) is a base-6 Lychrel number.
The number of digits t steps from x(m)
For all m and t, t steps from x(m) give exactly 110 + 2m + ⌊t/2⌋ base-6 digits.
The number of digits t steps from y(m)
For all m and t, t steps from y(m) give exactly 108 + 2m + ⌊t/2⌋ base-6 digits.
No x(m) is a step from y
For m₂ ≥ 6 and u < 12, x(m₁) is not the number u steps from y(m₂).
The three paths of x are separate
For r₁, r₂ < 3, if t₁ steps from x(r₁) equal t₂ steps from x(r₂), then r₁ = r₂ and t₁ = t₂.
The three paths of y are separate
For r₁, r₂ < 3, if t₁ steps from y(r₁) equal t₂ steps from y(r₂), then r₁ = r₂ and t₁ = t₂.
A path of x never meets a path of y
For all m₁, m₂, t₁, t₂, the number t₁ steps from x(m₁) differs from the number t₂ steps from y(m₂).
- A number on the six paths
Digit length on the six paths
t steps from a starting number with L digits give L + ⌊t/2⌋ base-6 digits, so the number is below 6 to the power (L + ⌊t/2⌋).
At least 12(D − 110) Lychrel numbers below 6 to the power D, for D ≥ 113
On each of the six paths, step t has L + ⌊t/2⌋ base-6 digits, where L is the length of its start, so the steps t < 2(D + 1 − L) give numbers below 6 to the power D, two for each digit length. The six paths start with 110, 112, 114, 108, 110 and 112 digits, so for D ≥ 113 these steps give exactly 12(D − 110) different numbers, all below 6 to the power D and all base-6 Lychrel numbers.
For D ≥ 113 the counted numbers are exactly 12(D − 110)
For every D ≥ 113, the steps t < 2(D + 1 − L) of the six paths give exactly 12(D − 110) different numbers.
theorem LychrelBase6.familyOrbitsFinset_card_of_ge {D : ℕ} (hD : 113 ≤ D) : (familyOrbitsFinset D).card = 12 * (D - 110)At least 12(D − 110) Lychrel numbers below 6 to the power D, for D ≥ 113
For every D ≥ 113, at least 12(D − 110) numbers below 6 to the power D are base-6 Lychrel numbers.
theorem LychrelBase6.lychrel6_ncard_lt_pow_ge {D : ℕ} (hD : 113 ≤ D) : 12 * (D - 110) ≤ {n | n < 6 ^ D ∧ IsLychrel6 n}.ncard- How many steps of a path are counted below 6 to the power D
- The counted numbers on the six paths
They are positive Lychrel numbers below 6 to the power D
Every such number is at least 1, below 6 to the power D, and a base-6 Lychrel number.
Counting them for every D
The number of counted numbers is the sum of 2(D + 1 − L) over the six starting lengths L that are at most D.