Theorem: Pell.eq_of_xn_modEq_le
File: Mathlib/NumberTheory/PellMatiyasevic.lean

tactic: simp_all
state_before: a : ℕ
a1 : 1 < a
i j n : ℕ
ij : i ≤ j
j2n : j ≤ 2 * n
h : xn a1 i ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)
npos : n = 0
⊢ i = j

tactic: refine' _root_.ne_of_gt _ h
state_before: a : ℕ
a1 : 1 < a
i j n : ℕ
ij : i ≤ j
j2n : j ≤ 2 * n
h : xn a1 i ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)
npos : ¬n = 0
ij' : i < j
jn : j = n
⊢ False

tactic: rw [jn, Nat.mod_self]
state_before: a : ℕ
a1 : 1 < a
i j n : ℕ
ij : i ≤ j
j2n : j ≤ 2 * n
h : xn a1 i ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)
npos : ¬n = 0
ij' : i < j
jn : j = n
⊢ xn a1 j % xn a1 n < xn a1 i % xn a1 n

tactic: have x0 : 0 < xn a1 0 % xn a1 n := by
  rw [Nat.mod_eq_of_lt (strictMono_x a1 (Nat.pos_of_ne_zero npos))]
  exact Nat.succ_pos _
state_before: a : ℕ
a1 : 1 < a
i j n : ℕ
ij : i ≤ j
j2n : j ≤ 2 * n
h : xn a1 i ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)
npos : ¬n = 0
ij' : i < j
jn : j = n
⊢ 0 < xn a1 i % xn a1 n

tactic: cases' i with i
state_before: a : ℕ
a1 : 1 < a
i j n : ℕ
ij : i ≤ j
j2n : j ≤ 2 * n
h : xn a1 i ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)
npos : ¬n = 0
ij' : i < j
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
⊢ 0 < xn a1 i % xn a1 n

tactic: exact x0
state_before: case zero
a : ℕ
a1 : 1 < a
j n : ℕ
j2n : j ≤ 2 * n
npos : ¬n = 0
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
ij : zero ≤ j
h : xn a1 zero ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ zero = 0 ∧ j = 2)
ij' : zero < j
⊢ 0 < xn a1 zero % xn a1 n

case succ
a : ℕ
a1 : 1 < a
j n : ℕ
j2n : j ≤ 2 * n
npos : ¬n = 0
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
i : ℕ
ij : succ i ≤ j
h : xn a1 (succ i) ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ succ i = 0 ∧ j = 2)
ij' : succ i < j
⊢ 0 < xn a1 (succ i) % xn a1 n

tactic: rw [jn] at ij'
state_before: case succ
a : ℕ
a1 : 1 < a
j n : ℕ
j2n : j ≤ 2 * n
npos : ¬n = 0
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
i : ℕ
ij : succ i ≤ j
h : xn a1 (succ i) ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ succ i = 0 ∧ j = 2)
ij' : succ i < j
⊢ 0 < xn a1 (succ i) % xn a1 n

tactic: exact
  x0.trans
    (eq_of_xn_modEq_lem3 _ (Nat.pos_of_ne_zero npos) (Nat.succ_pos _) (le_trans ij j2n)
      (_root_.ne_of_lt ij') fun ⟨_, n1, _, i2⟩ => by
      rw [n1, i2] at ij'; exact absurd ij' (by decide))
state_before: case succ
a : ℕ
a1 : 1 < a
j n : ℕ
j2n : j ≤ 2 * n
npos : ¬n = 0
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
i : ℕ
ij : succ i ≤ j
h : xn a1 (succ i) ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ succ i = 0 ∧ j = 2)
ij' : succ i < n
⊢ 0 < xn a1 (succ i) % xn a1 n

tactic: rw [Nat.mod_eq_of_lt (strictMono_x a1 (Nat.pos_of_ne_zero npos))]
state_before: a : ℕ
a1 : 1 < a
i j n : ℕ
ij : i ≤ j
j2n : j ≤ 2 * n
h : xn a1 i ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)
npos : ¬n = 0
ij' : i < j
jn : j = n
⊢ 0 < xn a1 0 % xn a1 n

tactic: exact Nat.succ_pos _
state_before: a : ℕ
a1 : 1 < a
i j n : ℕ
ij : i ≤ j
j2n : j ≤ 2 * n
h : xn a1 i ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)
npos : ¬n = 0
ij' : i < j
jn : j = n
⊢ 0 < xn a1 0

tactic: rw [n1, i2] at ij'
state_before: a : ℕ
a1 : 1 < a
j n : ℕ
j2n : j ≤ 2 * n
npos : ¬n = 0
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
i : ℕ
ij : succ i ≤ j
h : xn a1 (succ i) ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ succ i = 0 ∧ j = 2)
ij' : succ i < n
x✝ : a = 2 ∧ n = 1 ∧ 0 = 0 ∧ succ i = 2
left✝¹ : a = 2
n1 : n = 1
left✝ : 0 = 0
i2 : succ i = 2
⊢ False

tactic: exact absurd ij' (by decide)
state_before: a : ℕ
a1 : 1 < a
j n : ℕ
j2n : j ≤ 2 * n
npos : ¬n = 0
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
i : ℕ
ij : succ i ≤ j
h : xn a1 (succ i) ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ succ i = 0 ∧ j = 2)
ij' : 2 < 1
x✝ : a = 2 ∧ n = 1 ∧ 0 = 0 ∧ succ i = 2
left✝¹ : a = 2
n1 : n = 1
left✝ : 0 = 0
i2 : succ i = 2
⊢ False

tactic: decide
state_before: a : ℕ
a1 : 1 < a
j n : ℕ
j2n : j ≤ 2 * n
npos : ¬n = 0
jn : j = n
x0 : 0 < xn a1 0 % xn a1 n
i : ℕ
ij : succ i ≤ j
h : xn a1 (succ i) ≡ xn a1 j [MOD xn a1 n]
ntriv : ¬(a = 2 ∧ n = 1 ∧ succ i = 0 ∧ j = 2)
ij' : 2 < 1
x✝ : a = 2 ∧ n = 1 ∧ 0 = 0 ∧ succ i = 2
left✝¹ : a = 2
n1 : n = 1
left✝ : 0 = 0
i2 : succ i = 2
⊢ ¬2 < 1