The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V12. Number theory

Mathlib.NumberTheory.PellMatiyasevic

74 declarations. Mathlib docs · Source

Pell's equation and Matiyasevic's theorem

This file solves Pell's equation, i.e. integer solutions to x ^ 2 - d * y ^ 2 = 1 in the special case that d = a ^ 2 - 1. This is then applied to prove Matiyasevic's theorem that the power function is Diophantine, which is the last key ingredient in the solution to Hilbert's tenth problem. For the definition of Diophantine function, see NumberTheory.Dioph.

For results on Pell's equation for arbitrary (positive, non-square) d, see NumberTheory.Pell.

Main definition

  • pell is a function assigning to a natural number n the n-th solution to Pell's equation constructed recursively from the initial solution (0, 1).

Main statements

  • eq_pell shows that every solution to Pell's equation is recursively obtained using pell
  • matiyasevic shows that a certain system of Diophantine equations has a solution if and only if the first variable is the x-component in a solution to Pell's equation - the key step towards Hilbert's tenth problem in Davis' version of Matiyasevic's theorem.
  • eq_pow_of_pell shows that the power function is Diophantine.

Implementation notes

The proof of Matiyasevic's theorem doesn't follow Matiyasevic's original account of using Fibonacci numbers but instead Davis' variant of using solutions to Pell's equation.

References

  • [M. Carneiro, A Lean formalization of Matiyasevič's theorem][carneiro2018matiyasevic]
  • [M. Davis, Hilbert's tenth problem is unsolvable][MR317916]

Tags

Pell's equation, Matiyasevic's theorem, Hilbert's tenth problem

theorem Pell.IsPell.match_1.congr_eq_1 E1 #

∀ {d : ℤ} (motive : ℤ√d → Sort u_1) (x : ℤ√d) (h_1 : (x y : ℤ) → motive { re := x, im := y }) (x_1 y : ℤ),
  x = { re := x_1, im := y } →
    (match x with
      | { re := x, im := y } => h_1 x y) ≍
      h_1 x_1 y

theorem Pell.xn.congr_simp E1 #

∀ {a a_1 : ℕ} (e_a : a = a_1) (a1 : 1 < a) (n n_1 : ℕ), n = n_1 → Pell.xn a1 n = Pell.xn ⋯ n_1

theorem Pell.yn.congr_simp E1 #

∀ {a a_1 : ℕ} (e_a : a = a_1) (a1 : 1 < a) (n n_1 : ℕ), n = n_1 → Pell.yn a1 n = Pell.yn ⋯ n_1

theorem Pell.pellZd.congr_simp E1 #

∀ {a : ℕ} (a1 : 1 < a) (n n_1 : ℕ), n = n_1 → Pell.pellZd a1 n = Pell.pellZd a1 n_1

def Pell.IsPell E1 #

{d : ℤ} → ℤ√d → Prop

The property of being a solution to the Pell equation, expressed as a property of elements of ℤ√d.

theorem Pell.isPell_norm E1 #

∀ {d : ℤ} {b : ℤ√d}, Pell.IsPell b ↔ b * star b = 1

theorem Pell.isPell_iff_mem_unitary E1 #

∀ {d : ℤ} {b : ℤ√d}, Pell.IsPell b ↔ b ∈ unitary (ℤ√d)

theorem Pell.isPell_mul E1 #

∀ {d : ℤ} {b c : ℤ√d}, Pell.IsPell b → Pell.IsPell c → Pell.IsPell (b * c)

theorem Pell.isPell_star E1 #

∀ {d : ℤ} {b : ℤ√d}, Pell.IsPell b ↔ Pell.IsPell (star b)

theorem Pell.d_pos E1 #

∀ {a : ℕ}, 1 < a → 0 < a * a - 1

def Pell.pell E3 #

{a : ℕ} → 1 < a → ℕ → ℕ × ℕ

The Pell sequences, i.e. the sequence of integer solutions to x ^ 2 - d * y ^ 2 = 1, where d = a ^ 2 - 1, defined together in mutual recursion.

def Pell.xn E1 #

{a : ℕ} → 1 < a → ℕ → ℕ

The Pell x sequence.

def Pell.yn E1 #

{a : ℕ} → 1 < a → ℕ → ℕ

The Pell y sequence.

theorem Pell.pell_val E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.pell a1 n = (Pell.xn a1 n, Pell.yn a1 n)

theorem Pell.xn_zero E0 #

∀ {a : ℕ} (a1 : 1 < a), Pell.xn a1 0 = 1

theorem Pell.yn_zero E0 #

∀ {a : ℕ} (a1 : 1 < a), Pell.yn a1 0 = 0

theorem Pell.xn_succ E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.xn a1 (n + 1) = Pell.xn a1 n * a + (a * a - 1) * Pell.yn a1 n

theorem Pell.yn_succ E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.yn a1 (n + 1) = Pell.xn a1 n + Pell.yn a1 n * a

theorem Pell.xn_one E1 #

∀ {a : ℕ} (a1 : 1 < a), Pell.xn a1 1 = a

theorem Pell.yn_one E1 #

∀ {a : ℕ} (a1 : 1 < a), Pell.yn a1 1 = 1

def Pell.xz E1 #

{a : ℕ} → 1 < a → ℕ → ℤ

The Pell x sequence, considered as an integer sequence.

def Pell.yz E1 #

{a : ℕ} → 1 < a → ℕ → ℤ

The Pell y sequence, considered as an integer sequence.

def Pell.az E1 #

ℕ → ℤ

The element a such that d = a ^ 2 - 1, considered as an integer.

theorem Pell.asq_pos E1 #

∀ {a : ℕ}, 1 < a → 0 < a * a

theorem Pell.dz_val E0 #

∀ {a : ℕ}, 1 < a → ↑(a * a - 1) = Pell.az a * Pell.az a - 1

theorem Pell.xz_succ E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.xz a1 (n + 1) = Pell.xz a1 n * Pell.az a + ↑(a * a - 1) * Pell.yz a1 n

theorem Pell.yz_succ E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.yz a1 (n + 1) = Pell.xz a1 n + Pell.yz a1 n * Pell.az a

def Pell.pellZd E1 #

{a : ℕ} → 1 < a → ℕ → ℤ√↑(a * a - 1)

The Pell sequence can also be viewed as an element of ℤ√d

theorem Pell.re_pellZd E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), (Pell.pellZd a1 n).re = ↑(Pell.xn a1 n)

theorem Pell.im_pellZd E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), (Pell.pellZd a1 n).im = ↑(Pell.yn a1 n)

theorem Pell.isPell_nat E1 #

∀ {a : ℕ}, 1 < a → ∀ {x y : ℕ}, Pell.IsPell { re := ↑x, im := ↑y } ↔ x * x - (a * a - 1) * y * y = 1

theorem Pell.pellZd_succ E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.pellZd a1 (n + 1) = Pell.pellZd a1 n * { re := ↑a, im := 1 }

theorem Pell.isPell_one E1 #

∀ {a : ℕ}, 1 < a → Pell.IsPell { re := ↑a, im := 1 }

theorem Pell.isPell_pellZd E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.IsPell (Pell.pellZd a1 n)

theorem Pell.pell_eqz E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.xz a1 n * Pell.xz a1 n - ↑(a * a - 1) * Pell.yz a1 n * Pell.yz a1 n = 1

theorem Pell.pell_eq E0 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.xn a1 n * Pell.xn a1 n - (a * a - 1) * Pell.yn a1 n * Pell.yn a1 n = 1

theorem Pell.dnsq E1 #

∀ {a : ℕ}, 1 < a → Zsqrtd.Nonsquare (a * a - 1)

theorem Pell.xn_ge_a_pow E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), a ^ n ≤ Pell.xn a1 n

theorem Pell.n_lt_xn E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), n < Pell.xn a1 n

theorem Pell.x_pos E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), 0 < Pell.xn a1 n

theorem Pell.pellZd_add E1 #

∀ {a : ℕ} (a1 : 1 < a) (m n : ℕ), Pell.pellZd a1 (m + n) = Pell.pellZd a1 m * Pell.pellZd a1 n

theorem Pell.xn_add E1 #

∀ {a : ℕ} (a1 : 1 < a) (m n : ℕ),
  Pell.xn a1 (m + n) = Pell.xn a1 m * Pell.xn a1 n + (a * a - 1) * Pell.yn a1 m * Pell.yn a1 n

theorem Pell.yn_add E1 #

∀ {a : ℕ} (a1 : 1 < a) (m n : ℕ), Pell.yn a1 (m + n) = Pell.xn a1 m * Pell.yn a1 n + Pell.yn a1 m * Pell.xn a1 n

theorem Pell.pellZd_sub E1 #

∀ {a : ℕ} (a1 : 1 < a) {m n : ℕ}, n ≤ m → Pell.pellZd a1 (m - n) = Pell.pellZd a1 m * star (Pell.pellZd a1 n)

theorem Pell.xz_sub E1 #

∀ {a : ℕ} (a1 : 1 < a) {m n : ℕ},
  n ≤ m → Pell.xz a1 (m - n) = Pell.xz a1 m * Pell.xz a1 n - ↑(a * a - 1) * Pell.yz a1 m * Pell.yz a1 n

theorem Pell.yz_sub E1 #

∀ {a : ℕ} (a1 : 1 < a) {m n : ℕ}, n ≤ m → Pell.yz a1 (m - n) = Pell.xz a1 n * Pell.yz a1 m - Pell.xz a1 m * Pell.yz a1 n

theorem Pell.xy_coprime E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), (Pell.xn a1 n).Coprime (Pell.yn a1 n)

theorem Pell.strictMono_y E1 #

∀ {a : ℕ} (a1 : 1 < a), StrictMono (Pell.yn a1)

theorem Pell.strictMono_x E1 #

∀ {a : ℕ} (a1 : 1 < a), StrictMono (Pell.xn a1)

theorem Pell.yn_ge_n E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), n ≤ Pell.yn a1 n

theorem Pell.y_mul_dvd E1 #

∀ {a : ℕ} (a1 : 1 < a) (n k : ℕ), Pell.yn a1 n ∣ Pell.yn a1 (n * k)

theorem Pell.y_dvd_iff E0 #

∀ {a : ℕ} (a1 : 1 < a) (m n : ℕ), Pell.yn a1 m ∣ Pell.yn a1 n ↔ m ∣ n

theorem Pell.xy_modEq_yn E1 #

∀ {a : ℕ} (a1 : 1 < a) (n k : ℕ),
  Pell.xn a1 (n * k) ≡ Pell.xn a1 n ^ k [MOD Pell.yn a1 n ^ 2] ∧
    Pell.yn a1 (n * k) ≡ k * Pell.xn a1 n ^ (k - 1) * Pell.yn a1 n [MOD Pell.yn a1 n ^ 3]

theorem Pell.ysq_dvd_yy E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.yn a1 n * Pell.yn a1 n ∣ Pell.yn a1 (n * Pell.yn a1 n)

theorem Pell.dvd_of_ysq_dvd E1 #

∀ {a : ℕ} (a1 : 1 < a) {n t : ℕ}, Pell.yn a1 n * Pell.yn a1 n ∣ Pell.yn a1 t → Pell.yn a1 n ∣ t

theorem Pell.pellZd_succ_succ E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.pellZd a1 (n + 2) + Pell.pellZd a1 n = ↑(2 * a) * Pell.pellZd a1 (n + 1)

theorem Pell.xy_succ_succ E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ),
  Pell.xn a1 (n + 2) + Pell.xn a1 n = 2 * a * Pell.xn a1 (n + 1) ∧
    Pell.yn a1 (n + 2) + Pell.yn a1 n = 2 * a * Pell.yn a1 (n + 1)

theorem Pell.xn_succ_succ E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.xn a1 (n + 2) + Pell.xn a1 n = 2 * a * Pell.xn a1 (n + 1)

theorem Pell.yn_succ_succ E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.yn a1 (n + 2) + Pell.yn a1 n = 2 * a * Pell.yn a1 (n + 1)

theorem Pell.xz_succ_succ E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.xz a1 (n + 2) = ↑(2 * a) * Pell.xz a1 (n + 1) - Pell.xz a1 n

theorem Pell.yz_succ_succ E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.yz a1 (n + 2) = ↑(2 * a) * Pell.yz a1 (n + 1) - Pell.yz a1 n

theorem Pell.yn_modEq_a_sub_one E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.yn a1 n ≡ n [MOD a - 1]

theorem Pell.yn_modEq_two E1 #

∀ {a : ℕ} (a1 : 1 < a) (n : ℕ), Pell.yn a1 n ≡ n [MOD 2]

theorem Pell.x_sub_y_dvd_pow_lem E1 #

∀ (y2 y1 y0 yn1 yn0 xn1 xn0 ay a2 : ℤ),
  (a2 * yn1 - yn0) * ay + y2 - (a2 * xn1 - xn0) = y2 - a2 * y1 + y0 + a2 * (yn1 * ay + y1 - xn1) - (yn0 * ay + y0 - xn0)

theorem Pell.x_sub_y_dvd_pow E1 #

∀ {a : ℕ} (a1 : 1 < a) (y n : ℕ), 2 * ↑a * ↑y - ↑y * ↑y - 1 ∣ Pell.yz a1 n * (↑a - ↑y) + ↑(y ^ n) - Pell.xz a1 n

theorem Pell.xn_modEq_x2n_add_lem E1 #

∀ {a : ℕ} (a1 : 1 < a) (n j : ℕ),
  Pell.xn a1 n ∣ (a * a - 1) * Pell.yn a1 n * (Pell.yn a1 n * Pell.xn a1 j) + Pell.xn a1 j

theorem Pell.xn_modEq_x2n_add E1 #

∀ {a : ℕ} (a1 : 1 < a) (n j : ℕ), Pell.xn a1 (2 * n + j) + Pell.xn a1 j ≡ 0 [MOD Pell.xn a1 n]

theorem Pell.xn_modEq_x2n_sub_lem E1 #

∀ {a : ℕ} (a1 : 1 < a) {n j : ℕ}, j ≤ n → Pell.xn a1 (2 * n - j) + Pell.xn a1 j ≡ 0 [MOD Pell.xn a1 n]

theorem Pell.xn_modEq_x2n_sub E1 #

∀ {a : ℕ} (a1 : 1 < a) {n j : ℕ}, j ≤ 2 * n → Pell.xn a1 (2 * n - j) + Pell.xn a1 j ≡ 0 [MOD Pell.xn a1 n]

theorem Pell.xn_modEq_x4n_add E1 #

∀ {a : ℕ} (a1 : 1 < a) (n j : ℕ), Pell.xn a1 (4 * n + j) ≡ Pell.xn a1 j [MOD Pell.xn a1 n]

theorem Pell.xn_modEq_x4n_sub E1 #

∀ {a : ℕ} (a1 : 1 < a) {n j : ℕ}, j ≤ 2 * n → Pell.xn a1 (4 * n - j) ≡ Pell.xn a1 j [MOD Pell.xn a1 n]

theorem Pell.modEq_of_xn_modEq E1 #

∀ {a : ℕ} (a1 : 1 < a) {i j n : ℕ},
  0 < i → i ≤ n → Pell.xn a1 j ≡ Pell.xn a1 i [MOD Pell.xn a1 n] → j ≡ i [MOD 4 * n] ∨ j + i ≡ 0 [MOD 4 * n]

theorem Pell.xy_modEq_of_modEq E1 #

∀ {a b c : ℕ} (a1 : 1 < a) (b1 : 1 < b),
  a ≡ b [MOD c] → ∀ (n : ℕ), Pell.xn a1 n ≡ Pell.xn b1 n [MOD c] ∧ Pell.yn a1 n ≡ Pell.yn b1 n [MOD c]

theorem Pell.matiyasevic E3 #

∀ {a k x y : ℕ},
  (∃ (a1 : 1 < a), Pell.xn a1 k = x ∧ Pell.yn a1 k = y) ↔
    1 < a ∧
      k ≤ y ∧
        (x = 1 ∧ y = 0 ∨
          ∃ u v s t b,
            x * x - (a * a - 1) * y * y = 1 ∧
              u * u - (a * a - 1) * v * v = 1 ∧
                s * s - (b * b - 1) * t * t = 1 ∧
                  1 < b ∧ b ≡ 1 [MOD 4 * y] ∧ b ≡ a [MOD u] ∧ 0 < v ∧ y * y ∣ v ∧ s ≡ x [MOD u] ∧ t ≡ k [MOD 4 * y])