Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ jobs:
- uses: leanprover/lean-action@v1
with:
build: true

finite-regression:
name: Exact finite regression
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Compare direct search and committed finite-result JSON
run: python3 Problems/P001_ErdosStraus1201/check_prime_divisors.py
3 changes: 3 additions & 0 deletions OutcastsMathLab.lean
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import OutcastsMathLab.Problems.P000_VerifierSmoke.Proof
import OutcastsMathLab.Problems.P001_ErdosStraus1201.Verification
import OutcastsMathLab.Problems.P001_ErdosStraus1201.ReverseDivisor
import OutcastsMathLab.Problems.P001_ErdosStraus1201.PrimeCoprimality
import OutcastsMathLab.Problems.P001_ErdosStraus1201.PrimeDivisorBranches
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import Mathlib.Data.Nat.Prime.Defs
import OutcastsMathLab.Problems.P001_ErdosStraus1201.ReverseDivisor

namespace OutcastsPrimeCoprimality

-- A general coprimality identity; primality is unnecessary here.
theorem gcd_shift_product (p x : Int)
(hpx : Int.gcd p x = 1) (hp4 : Int.gcd p 4 = 1) :
Int.gcd (4 * x - p) (p * x) = 1 := by
have hcx : Int.gcd (4 * x - p) x = 1 := by
simpa using hpx
have hxp : Int.gcd x p = 1 := by
simpa [Int.gcd_comm] using hpx
have h4xp : Int.gcd (4 * x) p = 1 := by
rw [Int.gcd_mul_left_left_of_gcd_eq_one hxp]
simpa [Int.gcd_comm] using hp4
have hcp : Int.gcd (4 * x - p) p = 1 := by
simpa using h4xp
rw [Int.gcd_mul_right_right_of_gcd_eq_one hcp]
exact hcx

-- Use mathlib's standard primality predicate. Subtraction takes place in Int.
theorem odd_prime_coprimality (p x : Nat)
(hp : Nat.Prime p) (hodd : p ≠ 2) (hx : 0 < x) (hxp : x < p) :
Int.gcd (4 * (x : Int) - (p : Int)) ((p : Int) * (x : Int)) = 1 := by
have hnotx : ¬ p ∣ x := by
intro h
have hle := Nat.le_of_dvd hx h
omega
have hnot2 : ¬ p ∣ 2 := by
intro h
have hle := Nat.le_of_dvd (by decide : 0 < (2 : Nat)) h
have hp2 := hp.two_le
omega
have hnot4 : ¬ p ∣ 4 := by
intro h
have h' : p ∣ 2 * 2 := h
exact (hp.dvd_mul.mp h').elim hnot2 hnot2
have hpx : Nat.gcd p x = 1 := hp.coprime_iff_not_dvd.mpr hnotx
have hp4 : Nat.gcd p 4 = 1 := hp.coprime_iff_not_dvd.mpr hnot4
apply gcd_shift_product
· exact (Int.gcd_natCast_natCast p x).trans hpx
· exact (Int.gcd_natCast_natCast p 4).trans hp4

-- The prime-range wrapper no longer assumes coprimality separately.
theorem odd_prime_reconstruction (p x : Nat) (a b : Int)
(hp : Nat.Prime p) (hodd : p ≠ 2)
(hlo : p < 4 * x) (hhi : 4 * x ≤ 3 * p)
(ha : 0 < a) (haM : a ≤ (p : Int) * (x : Int))
(hab : a * b = ((p : Int) * (x : Int)) * ((p : Int) * (x : Int)))
(hda : (4 * (x : Int) - (p : Int)) ∣ a + (p : Int) * (x : Int))
(hlower : (4 * (x : Int) - (p : Int)) * (x : Int) -
(p : Int) * (x : Int) ≤ a) :
let y := (a + (p : Int) * (x : Int)) / (4 * (x : Int) - (p : Int))
let z := (b + (p : Int) * (x : Int)) / (4 * (x : Int) - (p : Int))
0 < (x : Int) ∧ (x : Int) ≤ y ∧ y ≤ z ∧
4 * (x : Int) * y * z = (p : Int) * ((x : Int) * y + (x : Int) * z + y * z) := by
have hp2 := hp.two_le
have hx : 0 < x := by omega
have hxp : x < p := by omega
have hp0 : 0 < (p : Int) := by omega
have hx0 : 0 < (x : Int) := by omega
exact OutcastsReverseDivisor.erdos_straus_reconstruction
(p : Int) (x : Int) a b hx0 (by omega) (Int.mul_pos hp0 hx0)
ha haM hab (odd_prime_coprimality p x hp hodd hx hxp) hda hlower

end OutcastsPrimeCoprimality

#print axioms OutcastsPrimeCoprimality.gcd_shift_product
#print axioms OutcastsPrimeCoprimality.odd_prime_coprimality
#print axioms OutcastsPrimeCoprimality.odd_prime_reconstruction
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import Mathlib.Data.Nat.Prime.Defs

namespace OutcastsPrimeDivisorBranches

-- A divisor of (p*x)^2 that is coprime to p already divides x^2.
theorem remove_coprime_square (p x a : Nat)
(hcop : Nat.Coprime a p) (hd : a ∣ (p * x) * (p * x)) :
a ∣ x * x := by
have hd' : a ∣ (p * p) * (x * x) := by
simpa [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm] using hd
exact (hcop.mul_right hcop).dvd_of_dvd_mul_left hd'

-- The upper bound is essential: it excludes a second factor of p.
theorem bounded_divisor_split (p x a : Nat) (hp : Nat.Prime p)
(hxp : x < p) (ha : 0 < a) (haM : a ≤ p * x)
(hd : a ∣ (p * x) * (p * x)) :
(a ∣ x * x ∧ ¬ p ∣ a) ∨
∃ t, a = p * t ∧ 0 < t ∧ t ≤ x ∧ t ∣ x * x := by
by_cases hpa : p ∣ a
· obtain ⟨t, hat⟩ := hpa
have ht : 0 < t := by
by_contra h
have ht0 : t = 0 := by omega
simp [ht0] at hat
omega
have htx : t ≤ x := by
apply Nat.le_of_mul_le_mul_left (c := p)
· simpa [hat] using haM
· exact hp.pos
have hnot : ¬ p ∣ t := by
intro h
have := Nat.le_of_dvd ht h
omega
have hcop : Nat.Coprime t p := (hp.coprime_iff_not_dvd.mpr hnot).symm
have hpd : p * t ∣ p * (p * (x * x)) := by
simpa [hat, Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm] using hd
have htd : t ∣ p * (x * x) := Nat.dvd_of_mul_dvd_mul_left hp.pos hpd
exact Or.inr ⟨t, hat, ht, htx, hcop.dvd_of_dvd_mul_left htd⟩
· exact Or.inl ⟨remove_coprime_square p x a
(hp.coprime_iff_not_dvd.mpr hpa).symm hd, hpa⟩

-- Natural-number form of the previous factor witness; no truncated subtraction.
def FactorWitness (p x c a : Nat) : Prop :=
0 < a ∧ a ≤ p * x ∧ a ∣ (p * x) * (p * x) ∧
c ∣ a + p * x ∧ c * x ≤ a + p * x

def BranchI (p x c t : Nat) : Prop :=
0 < t ∧ t ≤ p * x ∧ t ∣ x * x ∧
c ∣ t + p * x ∧ c * x ≤ t + p * x

def BranchII (p x c t : Nat) : Prop :=
0 < t ∧ t ≤ x ∧ t ∣ x * x ∧
c ∣ t + x ∧ c * x ≤ p * (t + x)

-- Exact disjunction, retaining the order lower bound in both branches.
-- c = 4*x-p is the application; here only gcd(c,p)=1 is needed.
theorem factor_witness_iff_branches (p x c a : Nat) (hp : Nat.Prime p)
(hxp : x < p) (hcop : Nat.Coprime c p) :
FactorWitness p x c a ↔
BranchI p x c a ∨ ∃ t, a = p * t ∧ BranchII p x c t := by
constructor
· rintro ⟨ha, haM, hd, hcong, hbound⟩
rcases bounded_divisor_split p x a hp hxp ha haM hd with hI | ⟨t, hat, ht, htx, htd⟩
· exact Or.inl ⟨ha, haM, hI.1, hcong, hbound⟩
· apply Or.inr
refine ⟨t, hat, ht, htx, htd, ?_, ?_⟩
· apply hcop.dvd_of_dvd_mul_left
simpa [hat, Nat.mul_add] using hcong
· simpa [hat, Nat.mul_add] using hbound
· intro h
rcases h with hI | ⟨t, hat, ht, htx, htd, hcong, hbound⟩
· rcases hI with ⟨ha, haM, hd, hcong, hbound⟩
refine ⟨ha, haM, ?_, hcong, hbound⟩
have hd' : a ∣ (p * p) * (x * x) := Nat.dvd_mul_left_of_dvd hd (p * p)
simpa [Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm] using hd'
· refine ⟨?_, ?_, ?_, ?_, ?_⟩
· simpa [hat] using Nat.mul_pos hp.pos ht
· simpa [hat] using Nat.mul_le_mul_left p htx
· have hd' : p * t ∣ p * (x * x) := Nat.mul_dvd_mul_left p htd
have hd'' : p * t ∣ p * (p * (x * x)) := Nat.dvd_mul_left_of_dvd hd' p
simpa [hat, Nat.mul_assoc, Nat.mul_comm, Nat.mul_left_comm] using hd''
· have hcong' : c ∣ p * (t + x) := Nat.dvd_mul_left_of_dvd hcong p
simpa [hat, Nat.mul_add] using hcong'
· simpa [hat, Nat.mul_add] using hbound

end OutcastsPrimeDivisorBranches

#print axioms OutcastsPrimeDivisorBranches.remove_coprime_square
#print axioms OutcastsPrimeDivisorBranches.bounded_divisor_split
#print axioms OutcastsPrimeDivisorBranches.factor_witness_iff_branches
108 changes: 108 additions & 0 deletions OutcastsMathLab/Problems/P001_ErdosStraus1201/ReverseDivisor.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import Std

namespace OutcastsReverseDivisor

-- The general reverse specification reviewed in Outcasts #11.
theorem reconstruct (c M a b : Int)
(hc : 0 < c) (hM : 0 < M) (ha : 0 < a) (haM : a ≤ M)
(hab : a * b = M * M) (hda : c ∣ a + M) (hdb : c ∣ b + M) :
let y := (a + M) / c
let z := (b + M) / c
0 < y ∧ y ≤ z ∧ c * y * z = M * (y + z) ∧
c * y - M = a ∧ c * z - M = b := by
dsimp
have hy := Int.mul_ediv_cancel_of_dvd hda
have hz := Int.mul_ediv_cancel_of_dvd hdb
have hb : 0 < b := by
have hMM := Int.mul_pos hM hM
have habpos : 0 < a * b := by omega
exact Int.pos_of_mul_pos_right habpos (by omega)
have haborder : a ≤ b := by
have haa := Int.mul_self_le_mul_self (Int.le_of_lt ha) haM
have habineq : a * a ≤ a * b := by omega
exact Int.le_of_mul_le_mul_left habineq ha
have hyp : 0 < (a + M) / c := by
have hp : 0 < c * ((a + M) / c) := by omega
exact Int.pos_of_mul_pos_right hp (by omega)
have hyz : (a + M) / c ≤ (b + M) / c := by
apply Int.le_of_mul_le_mul_left (a := c) _ hc
omega
have hid :
c * (c * ((a + M) / c) * ((b + M) / c) -
M * (((a + M) / c) + ((b + M) / c))) = 0 := by grind
have heq := (Int.mul_eq_zero.mp hid).resolve_left (Int.ne_of_gt hc)
exact ⟨hyp, hyz, Int.eq_of_sub_eq_zero heq, by omega, by omega⟩

-- Cancellation is valid only under coprimality.
theorem second_divisibility (c M a b : Int)
(hcop : Int.gcd c M = 1) (hab : a * b = M * M)
(hda : c ∣ a + M) : c ∣ b + M := by
have hpow : Int.gcd c (M * M) = 1 := by
simpa [Int.pow_succ, Int.pow_zero] using Int.gcd_pow_right_of_gcd_eq_one (k := 2) hcop
have had : a ∣ M * M := ⟨b, hab.symm⟩
have hcad : Int.gcd c a ∣ 1 := by
simpa [hpow] using Int.gcd_dvd_gcd_of_dvd_right c had
have hca : Int.gcd c a = 1 := Nat.eq_one_of_dvd_one hcad
have hmul : c ∣ a * (b + M) := by
have hd : c ∣ M * (a + M) := Int.dvd_mul_of_dvd_right hda
have hid : a * (b + M) = M * (a + M) := by grind
exact hid.symm ▸ hd
have hg := Int.dvd_gcd_mul_iff_dvd_mul.mpr hmul
simpa [hca] using hg

theorem reconstruct_coprime (c M a b : Int)
(hc : 0 < c) (hM : 0 < M) (ha : 0 < a) (haM : a ≤ M)
(hab : a * b = M * M) (hcop : Int.gcd c M = 1) (hda : c ∣ a + M) :
let y := (a + M) / c
let z := (b + M) / c
0 < y ∧ y ≤ z ∧ c * y * z = M * (y + z) ∧
c * y - M = a ∧ c * z - M = b :=
reconstruct c M a b hc hM ha haM hab hda
(second_divisibility c M a b hcop hab hda)

-- The extra lower bound required for a sorted triple x ≤ y ≤ z.
theorem first_denominator_bound (c M a x : Int) (hc : 0 < c)
(hda : c ∣ a + M) : x ≤ (a + M) / c ↔ c * x - M ≤ a := by
have hy := Int.mul_ediv_cancel_of_dvd hda
constructor
· intro h
have hmul := Int.mul_le_mul_of_nonneg_left h (Int.le_of_lt hc)
omega
· intro h
apply Int.le_of_mul_le_mul_left (a := c) _ hc
omega

theorem noncoprime_counterexample :
(4 : Int) * 9 = 6 * 6 ∧ 0 < (4 : Int) ∧ (4 : Int) ≤ 6 ∧
Int.gcd 2 6 ≠ 1 ∧
(2 : Int) ∣ 4 + 6 ∧ ¬ (2 : Int) ∣ 9 + 6 := by decide

-- Conditional construction, not universal existence of the parameters.
theorem erdos_straus_reconstruction (p x a b : Int)
(hx : 0 < x) (hc : 0 < 4 * x - p) (hM : 0 < p * x)
(ha : 0 < a) (haM : a ≤ p * x)
(hab : a * b = (p * x) * (p * x))
(hcop : Int.gcd (4 * x - p) (p * x) = 1)
(hda : (4 * x - p) ∣ a + p * x)
(hlower : (4 * x - p) * x - p * x ≤ a) :
let y := (a + p * x) / (4 * x - p)
let z := (b + p * x) / (4 * x - p)
0 < x ∧ x ≤ y ∧ y ≤ z ∧
4 * x * y * z = p * (x * y + x * z + y * z) := by
dsimp
have hr := reconstruct_coprime (4 * x - p) (p * x) a b
hc hM ha haM hab hcop hda
dsimp at hr
have hxy := (first_denominator_bound (4 * x - p) (p * x) a x hc hda).mpr hlower
refine ⟨hx, hxy, hr.2.1, ?_⟩
have heq := hr.2.2.1
grind

end OutcastsReverseDivisor

#print axioms OutcastsReverseDivisor.reconstruct
#print axioms OutcastsReverseDivisor.second_divisibility
#print axioms OutcastsReverseDivisor.reconstruct_coprime
#print axioms OutcastsReverseDivisor.first_denominator_bound
#print axioms OutcastsReverseDivisor.noncoprime_counterexample
#print axioms OutcastsReverseDivisor.erdos_straus_reconstruction
101 changes: 101 additions & 0 deletions Problems/P001_ErdosStraus1201/BRANCHES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Bounded factor witnesses reduced to divisors of x²

## Question and scope

Can the bounded factor witness from the existing reconstruction be represented
using only divisors of `x²`, without discarding either branch or the order bound?
Yes, mathematically, by removing factors of the prime `p`. The new Lean module
`PrimeDivisorBranches.lean` formalizes this equivalence. Its verification status
is recorded against the exact commit in PR #3 and the linked CI run.

This is a normal form for a known criterion, not a new existence theorem.
It does not change the frozen P001 statement, the Python enumerator, or the
project's acceptance status. The author has written both specification and
proof; independent specification review is pending.

## Exact specification

All variables in this module are natural numbers. Let `p` be prime, `x<p`,
and `gcd(c,p)=1`. Define the factor witness for `a` by

```text
0<a, a≤px, a | (px)², c | (a+px), cx≤a+px.
```

The last inequality expresses `x≤y` for the exact quotient `y=(a+px)/c`
when `c>0`. Writing it without subtraction avoids Nat's truncated subtraction.

`factor_witness_iff_branches` proves that this witness is equivalent to
the following disjunction:

| Branch | Parameter and divisibility | Congruence and order bound |
| --- | --- | --- |
| I | `a=t`, `0<t≤px`, `t | x²` | `c | (t+px)`, `cx≤t+px` |
| II | `a=pt`, `0<t≤x`, `t | x²` | `c | (t+x)`, `cx≤p(t+x)` |

No positivity of `c` is needed for this algebraic equivalence itself. Its
Erdős–Straus application uses `c=4x-p>0`, `p<4x≤3p`, and odd primality.
The coprimality needed there follows from the preceding `PrimeCoprimality`
module. The new module does **not** formalize the Nat/Int interface to that
module or assert a theorem about the reconstructed denominators' Type labels.

## Derivation

If `p` does not divide `a`, primality gives `gcd(a,p)=1`. Cancellation of `p²`
from `a | p²x²` gives `a | x²` (Branch I).

If `p | a`, write `a=pt`. From `a≤px` obtain `t≤x<p`. Since `t>0`, `p` does
not divide `t`, so cancellation from `t | px²` yields `t | x²`. Finally,
`c | a+px` becomes `c | p(t+x)`. Coprimality of `c,p` lets us cancel `p`,
giving Branch II. The order bound is preserved exactly, not dropped.

Conversely, each branch supplies a divisor of `(px)²`, the original bounds,
and the original congruence. These are all the requirements of the factor
witness. In particular this is an iff, not merely two sufficient recipes.

For the positive prime-range application, the familiar Type interpretation
is a paper-level consequence: in Branch I, `p∤a` and the complementary factor
has two factors of `p`; in Branch II, both factors have one. Modulo `p` in
`cy=a+px, cz=b+px`, with `p∤c`, this means respectively only `z` is divisible
by `p`, or both `y,z` are divisible by `p`. This interpretation is not counted
as one of today's three Lean theorems.

## Literature and remaining question

Search terms: Erdős–Straus Type I Type II divisor criterion, fixed shift,
bounded factor-pair parametrization, smallest denominator p/2. Primary
references inspected:

- [Kyle Bradford, v1, Propositions 1–4](https://arxiv.org/html/2403.16047v1):
states these same two `d | x²` congruences and reconstructs the two Types.
That paper uses the sharper range `ceil(p/4)≤x≤ceil(p/2)`. We do not import
that range theorem here: our equivalence retains the order bound explicitly
and assumes only `x<p` and `gcd(c,p)=1`. The congruences themselves are
therefore already published, not merely analogous to prior work.
- [Elsholtz–Tao, v6, Introduction and §2](https://arxiv.org/html/1107.1010v6):
the standard prime-denominator Type I/II classification.
- [Dahan, v1, §2.3, Corollary 2.7 and Definition 2.8](https://arxiv.org/html/2608.24035v1#S2.SS3):
the complete two-branch fixed-shift criterion using coprime divisors of `x`.
The present `x²` form instead starts from our bounded factor `a | (px)²`.

These references do not supply the missing universal witness in every prime case.
Local mathlib source inspection found and reused the standard prime/coprime
and divisibility lemmas; no claim of first formalization is made.

The next existence target is explicit: for each remaining prime `p`, find
an allowed `x` and a positive divisor `t` of `x²` satisfying at least one row.
Showing a residue belongs to a generated multiplicative group is still
insufficient: `t` must divide `x²` with bounded prime exponents, and must meet
the row's numerical bounds. This theorem does not prove such a `t` exists.

## Validation contract

- Three general theorems: `remove_coprime_square`, `bounded_divisor_split`,
`factor_witness_iff_branches`.
- Success requires the exact module imported by the root, a successful pinned
Lean 4.34.0/mathlib v4.34.0 build, and inspection of all three axiom reports.
- Full build on GitHub Actions; no expanded finite search. The existing CI
finite regression remains 2,324 inputs and 970 solutions.
- This work has no stochastic experiment or training run. CI retries are
limited to correcting concrete compiler diagnostics; no acceptance-state
changes or PR merges are part of it.
Loading