Disproof for Numbers such that the perfect deficiency of is .
| Lean accepts it | yes | compiles under the pinned toolchain |
| Standard axioms | yes | propext, Classical.choice, Quot.sound only |
| Right theorem | yes | proves exactly the negation of the reference |
| Faithful statement | yes | the reference statement has been reviewed |
| Human-verified | — | not assessed yet |
Community review
Lean accepts this disproof, and it counts: it changed the status of the problem. Because it did, it is open to community review — vote, comment (on a line if you like), or suggest a change to the file — until a moderator confirms it (human-verified) or revokes it.
Discussion
No comment yet.
Suggested changes
No suggestion yet.
Verification pipeline
Run #205 · verified · 25 Nov 2026, 15:26 UTC · Lean v4.33.1 · sandbox github:nosorry-maths/nosorry-verify
- preflight — pass0.01 s
imports: FormalConjecturesUtil
- originality — pass0.01 s
no identical earlier submission
- github run — pass155.50 s
https://github.com/nosorry-maths/nosorry-verify/actions/runs/45645189515 · leanprover/lean4:v4.33.1 · 137 s
- compile reference statement — pass0.00 s
- compile submission — pass0.00 s
- statement & axioms — pass0.00 s
axioms: [Classical.choice, propext, Quot.sound]
- kernel replay — pass0.00 s
- comparator — skipped
not applicable to disproofs
Points
| +100 | first verified proof of an open problem | 25 Nov 2026, 19:08 UTC |
Explanation
Disproof of the OEIS A108864 conjecture (∀ n > 58, Even (a n)):
Counterexample: Let . All six factors are distinct odd primes, so is odd and
Deficient-number lemma (
perfectDeficiency_eq_of_sigma_le): For any with , the sum of proper divisors of is , so every proper divisor is subtracted during the greedy fold overList.range (n + 1)and itself is skipped (since ). Hence Applying this to gives , so .Index bound (
58 < Nat.count A N): ByNat.nth_count, . Using the same deficient-number lemma, we exhibit 60 pairwise distinct elements of strictly less than :- 30 powers of two: for (each has and );
- 30 numbers of the form with an odd prime satisfying (each has , is , and is disjoint from the powers of two).
Thus , yet is odd, contradicting
∀ n > 58, Even (a n).
Lean source
327 lines · 12.6 KB · click to show
/-
Copyright 2026 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
module
public import FormalConjecturesUtil
/-!
# Numbers $n$ such that the perfect deficiency of $n$ is $\le 10$.
The perfect deficiency of $n$ (A109883) is the remainder after greedily subtracting
from $n$ its divisors in increasing order, skipping any divisor larger than the
current remainder.
*References:*
- [A108864](https://oeis.org/A108864)
- [A109883](https://oeis.org/A109883)
-/
@[expose] public section
namespace OeisA108864
open Nat Finset Int
/--
The perfect deficiency of $n$ (A109883): the remainder after greedily subtracting
from $n$ its divisors in increasing order, skipping any divisor larger than the
current remainder.
-/
def perfectDeficiency (n : ℕ) : ℕ :=
(List.range (n + 1)).foldl (fun m d => if d ∣ n ∧ d ≤ m then m - d else m) n
/--
The condition for a number $n$ to be in the sequence.
It satisfies $0 < n$ and its perfect deficiency is $\le 10$.
-/
def A (n : ℕ) : Prop :=
0 < n ∧ perfectDeficiency n ≤ 10
instance : DecidablePred A := by
unfold A
infer_instance
/--
The primary defining sequence `a`.
$a(n)$ is the $n$-th number (0-indexed) such that its perfect deficiency is $\le 10$.
-/
noncomputable def a (n : ℕ) : ℕ :=
n.nth A
/-- Term theorems verifying the first few values of the sequence against the official OEIS b-file -/
@[category test, AMS 11]
theorem a_0 : a 0 = 1 := by
have h1 : A 1 := by decide
have hcnt : Nat.count A 1 = 0 := by decide
have := Nat.nth_count (p := A) h1
rwa [hcnt] at this
@[category test, AMS 11]
theorem a_1 : a 1 = 2 := by
have h2 : A 2 := by decide
have hcnt : Nat.count A 2 = 1 := by decide
have := Nat.nth_count (p := A) h2
rwa [hcnt] at this
@[category test, AMS 11]
theorem a_2 : a 2 = 3 := by
have h3 : A 3 := by decide
have hcnt : Nat.count A 3 = 2 := by decide
have := Nat.nth_count (p := A) h3
rwa [hcnt] at this
@[category test, AMS 11]
theorem a_3 : a 3 = 4 := by
have h4 : A 4 := by decide
have hcnt : Nat.count A 4 = 3 := by decide
have := Nat.nth_count (p := A) h4
rwa [hcnt] at this
@[category test, AMS 11]
theorem a_4 : a 4 = 5 := by
have h5 : A 5 := by decide
have hcnt : Nat.count A 5 = 4 := by decide
have := Nat.nth_count (p := A) h5
rwa [hcnt] at this
private lemma foldl_perfectDeficiency_prefix (n : ℕ)
(hsum : ∑ d ∈ (Finset.range n).filter (· ∣ n), d ≤ n) :
∀ k ≤ n, (List.range k).foldl (fun m d => if d ∣ n ∧ d ≤ m then m - d else m) n =
n - ∑ d ∈ (Finset.range k).filter (· ∣ n), d := by
intro k hk
induction k with
| zero => simp
| succ k ih =>
have hk_le : k ≤ n := Nat.le_of_succ_le hk
rw [List.range_succ, List.foldl_append, List.foldl_cons, List.foldl_nil, ih hk_le]
have hsub : (Finset.range (k + 1)).filter (· ∣ n) ⊆ (Finset.range n).filter (· ∣ n) := by
intro x hx
simp only [Finset.mem_filter, Finset.mem_range] at hx ⊢
exact ⟨lt_of_lt_of_le hx.1 hk, hx.2⟩
have hle_n : ∑ d ∈ (Finset.range (k + 1)).filter (· ∣ n), d ≤ n :=
le_trans (Finset.sum_le_sum_of_subset hsub) hsum
by_cases hd : k ∣ n
· have hfilt : (Finset.range (k + 1)).filter (· ∣ n) =
insert k ((Finset.range k).filter (· ∣ n)) := by
rw [Finset.range_add_one, Finset.filter_insert, if_pos hd]
have hnotmem : k ∉ (Finset.range k).filter (· ∣ n) := by
simp
have hsum_succ : ∑ d ∈ (Finset.range (k + 1)).filter (· ∣ n), d =
(∑ d ∈ (Finset.range k).filter (· ∣ n), d) + k := by
rw [hfilt, Finset.sum_insert hnotmem, add_comm]
have hk_le_rem : k ≤ n - ∑ d ∈ (Finset.range k).filter (· ∣ n), d := by
omega
rw [if_pos ⟨hd, hk_le_rem⟩, hsum_succ]
omega
· have hfilt : (Finset.range (k + 1)).filter (· ∣ n) =
(Finset.range k).filter (· ∣ n) := by
rw [Finset.range_add_one, Finset.filter_insert, if_neg hd]
rw [if_neg (fun h => hd h.1), hfilt]
private lemma filter_range_dvd_eq_properDivisors {n : ℕ} (hn : n ≠ 0) :
(Finset.range n).filter (· ∣ n) = n.properDivisors := by
ext d
simp [Nat.mem_properDivisors, hn]
private lemma perfectDeficiency_eq_of_sigma_le {n : ℕ} (hn : 2 ≤ n)
(hσ : ArithmeticFunction.sigma 1 n ≤ 2 * n) :
perfectDeficiency n = 2 * n - ArithmeticFunction.sigma 1 n := by
have hn0 : n ≠ 0 := by omega
have hdiv_sum : ArithmeticFunction.sigma 1 n =
(∑ d ∈ n.properDivisors, d) + n := by
rw [ArithmeticFunction.sigma_apply]
simpa using (Nat.sum_divisors_eq_sum_properDivisors_add_self (n := n))
have hfilter : (Finset.range n).filter (· ∣ n) = n.properDivisors :=
filter_range_dvd_eq_properDivisors hn0
have hsum_le : ∑ d ∈ (Finset.range n).filter (· ∣ n), d ≤ n := by
rw [hfilter]; omega
have hsum_pos : 0 < ∑ d ∈ (Finset.range n).filter (· ∣ n), d := by
have h1mem : 1 ∈ (Finset.range n).filter (· ∣ n) := by
simp only [Finset.mem_filter, Finset.mem_range, one_dvd, and_true]
omega
calc 0 < 1 := by omega
_ ≤ ∑ d ∈ (Finset.range n).filter (· ∣ n), d :=
Finset.single_le_sum (f := fun x => x) (fun _ _ => Nat.zero_le _) h1mem
unfold perfectDeficiency
rw [List.range_succ, List.foldl_append, List.foldl_cons, List.foldl_nil,
foldl_perfectDeficiency_prefix n hsum_le n le_rfl]
have hnotle : ¬ (n ≤ n - ∑ d ∈ (Finset.range n).filter (· ∣ n), d) := by
omega
rw [if_neg (fun h => hnotle h.2), hfilter]
omega
private lemma sigma_one_prime {p : ℕ} (hp : p.Prime) :
ArithmeticFunction.sigma 1 p = p + 1 := by
have h := ArithmeticFunction.sigma_one_apply_prime_pow (i := 1) hp
simpa [Finset.sum_range_succ, add_comm] using h
private lemma sigma_one_two_pow (k : ℕ) :
ArithmeticFunction.sigma 1 (2 ^ k) = 2 ^ (k + 1) - 1 := by
rw [ArithmeticFunction.sigma_one_apply_prime_pow Nat.prime_two]
have h := geom_sum_mul_add 1 (k + 1)
have : (∑ i ∈ Finset.range (k + 1), 2 ^ i) + 1 = 2 ^ (k + 1) := by
simpa using h
omega
private lemma A_two_pow (k : ℕ) : A (2 ^ k) := by
cases k with
| zero => exact by decide
| succ k =>
have hge2 : 2 ≤ 2 ^ (k + 1) := by
calc 2 = 2 ^ 1 := by norm_num
_ ≤ 2 ^ (k + 1) := Nat.pow_le_pow_right (by norm_num) (by omega)
have hσ : ArithmeticFunction.sigma 1 (2 ^ (k + 1)) = 2 * 2 ^ (k + 1) - 1 := by
rw [sigma_one_two_pow]; ring_nf
have hpd : perfectDeficiency (2 ^ (k + 1)) = 1 := by
rw [perfectDeficiency_eq_of_sigma_le hge2 (by omega), hσ]
omega
exact ⟨by positivity, by omega⟩
private lemma A_two_pow_mul_prime {k p : ℕ} (hp : p.Prime) (hp_ne : p ≠ 2)
(hlo : 2 ^ (k + 1) ≤ p + 1) (hhi : p + 1 ≤ 2 ^ (k + 1) + 10) :
A (2 ^ k * p) := by
have hcop : Nat.Coprime (2 ^ k) p := by
refine Nat.Coprime.pow_left k ?_
exact (Nat.coprime_primes Nat.prime_two hp).mpr hp_ne.symm
have hmul := ArithmeticFunction.isMultiplicative_sigma (k := 1)
have hσ : ArithmeticFunction.sigma 1 (2 ^ k * p) = (2 ^ (k + 1) - 1) * (p + 1) := by
rw [hmul.map_mul_of_coprime hcop, sigma_one_two_pow, sigma_one_prime hp]
have h2pow_pos : 1 ≤ 2 ^ (k + 1) := Nat.one_le_pow _ _ (by norm_num)
have h2n : 2 * (2 ^ k * p) = 2 ^ (k + 1) * p := by ring
have hσ_eq : (2 ^ (k + 1) - 1) * (p + 1) + (p + 1 - 2 ^ (k + 1)) = 2 ^ (k + 1) * p := by
zify [h2pow_pos, hlo]
ring
have hge2 : 2 ≤ 2 ^ k * p := by
have hp2 : 2 ≤ p := hp.two_le
have h2k : 1 ≤ 2 ^ k := Nat.one_le_pow _ _ (by norm_num)
nlinarith
have hpd : perfectDeficiency (2 ^ k * p) = p + 1 - 2 ^ (k + 1) := by
rw [perfectDeficiency_eq_of_sigma_le hge2 (by omega), hσ]
omega
exact ⟨by omega, by omega⟩
private lemma A_counterexample : A 815634435 := by
have hN : (815634435 : ℕ) = 3 * 5 * 7 * 11 * 547 * 1291 := by norm_num
have hp3 : Nat.Prime 3 := by norm_num
have hp5 : Nat.Prime 5 := by norm_num
have hp7 : Nat.Prime 7 := by norm_num
have hp11 : Nat.Prime 11 := by norm_num
have hp547 : Nat.Prime 547 := by norm_num
have hp1291 : Nat.Prime 1291 := by norm_num
have hmul := ArithmeticFunction.isMultiplicative_sigma (k := 1)
have hσ : ArithmeticFunction.sigma 1 815634435 = 1631268864 := by
rw [hN,
hmul.map_mul_of_coprime (by norm_num),
hmul.map_mul_of_coprime (by norm_num),
hmul.map_mul_of_coprime (by norm_num),
hmul.map_mul_of_coprime (by norm_num),
hmul.map_mul_of_coprime (by norm_num),
sigma_one_prime hp3,
sigma_one_prime hp5,
sigma_one_prime hp7,
sigma_one_prime hp11,
sigma_one_prime hp547,
sigma_one_prime hp1291]
norm_num
have hpd : perfectDeficiency 815634435 = 6 := by
rw [perfectDeficiency_eq_of_sigma_le (by norm_num) (by omega), hσ]
exact ⟨by norm_num, by omega⟩
private lemma not_two_pow_of_odd_prime_dvd {n p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2)
(hdvd : p ∣ n) : ∀ k, n ≠ 2 ^ k := by
intro k hk
subst hk
exact hp2 ((Nat.prime_dvd_prime_iff_eq hp Nat.prime_two).mp (hp.dvd_of_dvd_pow hdvd))
/--
Disproof of A108864 conjecture: $n = 815634435 = 3 \cdot 5 \cdot 7 \cdot 11 \cdot 547 \cdot 1291$
is an odd number greater than $1155$ with $\sigma(n) = 1631268864 = 2n - 6$, hence
`perfectDeficiency 815634435 = 6 ≤ 10`. Since at least $59$ elements of `A` are strictly less
than $815634435$ (30 powers of $2$ and 30 numbers of the form $2^k p$ with $p$ an odd prime),
it appears at an index $> 58$.
-/
@[category research open, question, AMS 11]
theorem not_conjecture :
¬ (∀ n > 58, Even (a n)) := by
intro h
set N : ℕ := 815634435
have hAN : A N := A_counterexample
let idx : ℕ := Nat.count A N
have ha_idx : a idx = N := Nat.nth_count (p := A) hAN
have hidx_gt : 58 < idx := by
let S1 : Finset ℕ := (Finset.range 30).image (2 ^ ·)
-- 30 numbers of the form 2^k * p (p odd prime, 2^(k+1) ≤ p + 1 ≤ 2^(k+1) + 10), all < N
let pairs : List (ℕ × ℕ) :=
[(0, 3), (0, 5), (0, 7), (0, 11),
(1, 3), (1, 5), (1, 7), (1, 11), (1, 13),
(2, 7), (2, 11), (2, 13), (2, 17),
(3, 17), (3, 19), (3, 23),
(4, 31), (4, 37), (4, 41),
(5, 67), (5, 71), (5, 73),
(6, 127), (6, 131), (6, 137),
(7, 257), (7, 263),
(8, 521),
(9, 1031), (9, 1033)]
let S2 : Finset ℕ := (pairs.map (fun kp => 2 ^ kp.1 * kp.2)).toFinset
have hS1_card : S1.card = 30 := by
rw [Finset.card_image_of_injective _ (Nat.pow_right_injective (by norm_num)),
Finset.card_range]
have hS2_card : S2.card = 30 := by decide
have hpairs_ok : ∀ kp ∈ pairs, kp.2.Prime ∧ kp.2 ≠ 2 ∧
2 ^ (kp.1 + 1) ≤ kp.2 + 1 ∧ kp.2 + 1 ≤ 2 ^ (kp.1 + 1) + 10 ∧
2 ^ kp.1 * kp.2 < N := by
intro kp hkp
simp only [pairs, List.mem_cons, List.not_mem_nil, or_false] at hkp
rcases hkp with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl |
rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl |
rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;>
exact ⟨by norm_num, by norm_num, by norm_num, by norm_num, by norm_num⟩
have hdisj : Disjoint S1 S2 := by
rw [Finset.disjoint_left]
intro x hx1 hx2
rcases Finset.mem_image.mp hx1 with ⟨k, _, rfl⟩
rw [List.mem_toFinset, List.mem_map] at hx2
rcases hx2 with ⟨kp, hkp, hxeq⟩
have ⟨hp, hp2, _, _, _⟩ := hpairs_ok kp hkp
exact not_two_pow_of_odd_prime_dvd hp hp2 ⟨2 ^ kp.1, by rw [mul_comm]⟩ k hxeq
have hsub : S1 ∪ S2 ⊆ (Finset.range N).filter A := by
intro x hx
rw [Finset.mem_filter, Finset.mem_range]
rcases Finset.mem_union.mp hx with hx1 | hx2
· rcases Finset.mem_image.mp hx1 with ⟨k, hk, rfl⟩
have hk30 : k < 30 := Finset.mem_range.mp hk
have hlt : 2 ^ k < N := by
calc 2 ^ k ≤ 2 ^ 29 := Nat.pow_le_pow_right (by norm_num) (by omega)
_ < N := by norm_num
exact ⟨hlt, A_two_pow k⟩
· rw [List.mem_toFinset, List.mem_map] at hx2
rcases hx2 with ⟨kp, hkp, rfl⟩
have ⟨hp, hp2, hlo, hhi, hlt⟩ := hpairs_ok kp hkp
exact ⟨hlt, A_two_pow_mul_prime hp hp2 hlo hhi⟩
have hcard_le : (S1 ∪ S2).card ≤ ((Finset.range N).filter A).card :=
Finset.card_le_card hsub
rw [Finset.card_union_of_disjoint hdisj, hS1_card, hS2_card] at hcard_le
have hcnt : idx = ((Finset.range N).filter A).card := by
simp [idx, Nat.count_eq_card_filter_range]
omega
have heven : Even N := by
rw [← ha_idx]
exact h idx hidx_gt
have hodd : ¬ Even N := by norm_num [N]
exact hodd heven
end OeisA108864