number_theory.pell_matiyasevicMathlib.NumberTheory.PellMatiyasevic

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -406,7 +406,7 @@ theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell
   let ⟨n, h⟩ := @Zsqrtd.le_arch d b
   eq_pell_lem n b b1 hp <|
     h.trans <| by
-      rw [Zsqrtd.coe_nat_val] <;>
+      rw [Zsqrtd.natCast_val] <;>
         exact
           Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| le_of_lt <| n_lt_xn _ _)
             (Int.ofNat_zero_le _)
@@ -619,7 +619,7 @@ theorem pellZd_succ_succ (n) : pell_zd (n + 2) + pell_zd n = (2 * a : ℕ) * pel
   by
   have : (1 : ℤ√d) + ⟨a, 1⟩ * ⟨a, 1⟩ = ⟨a, 1⟩ * (2 * a) :=
     by
-    rw [Zsqrtd.coe_nat_val]; change (⟨_, _⟩ : ℤ√d a1) = ⟨_, _⟩
+    rw [Zsqrtd.natCast_val]; change (⟨_, _⟩ : ℤ√d a1) = ⟨_, _⟩
     rw [dz_val]; dsimp [az]; rw [Zsqrtd.ext_iff]; dsimp; constructor <;> ring
   simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (· * pell_zd a1 n) this
 #align pell.pell_zd_succ_succ Pell.pellZd_succ_succ
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
 import Algebra.Star.Unitary
-import Data.Nat.Modeq
+import Data.Nat.ModEq
 import NumberTheory.Zsqrtd.Basic
 
 #align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"ce38d86c0b2d427ce208c3cee3159cb421d2b3c4"
@@ -324,7 +324,7 @@ instance dnsq : Zsqrtd.Nonsquare d :=
 theorem xn_ge_a_pow : ∀ n : ℕ, a ^ n ≤ xn n
   | 0 => le_refl 1
   | n + 1 => by
-    simp [pow_succ'] <;>
+    simp [pow_succ] <;>
       exact le_trans (Nat.mul_le_mul_right _ (xn_ge_a_pow n)) (Nat.le_add_right _ _)
 #align pell.xn_ge_a_pow Pell.xn_ge_a_pow
 -/
@@ -335,7 +335,7 @@ theorem n_lt_a_pow : ∀ n : ℕ, n < a ^ n
   | n + 1 => by
     have IH := n_lt_a_pow n
     have : a ^ n + a ^ n ≤ a ^ n * a := by rw [← mul_two]; exact Nat.mul_le_mul_left _ a1
-    simp [pow_succ']; refine' lt_of_lt_of_le _ this
+    simp [pow_succ]; refine' lt_of_lt_of_le _ this
     exact add_lt_add_of_lt_of_le IH (lt_of_le_of_lt (Nat.zero_le _) IH)
 #align pell.n_lt_a_pow Pell.n_lt_a_pow
 -/
@@ -566,25 +566,25 @@ theorem xy_modEq_yn (n) :
     have L : xn (n * k) * xn n + d * yn (n * k) * yn n ≡ xn n ^ k * xn n + 0 [MOD yn n ^ 2] :=
       (hx.mul_right _).add <|
         modEq_zero_iff_dvd.2 <| by
-          rw [pow_succ'] <;>
+          rw [pow_succ] <;>
             exact
               mul_dvd_mul_right
                 (dvd_mul_of_dvd_right
                   (modeq_zero_iff_dvd.1 <|
-                    (hy.of_dvd <| by simp [pow_succ']).trans <|
+                    (hy.of_dvd <| by simp [pow_succ]).trans <|
                       modeq_zero_iff_dvd.2 <| by simp [-mul_comm, -mul_assoc])
                   _)
                 _
     have R :
       xn (n * k) * yn n + yn (n * k) * xn n ≡ xn n ^ k * yn n + k * xn n ^ k * yn n [MOD
         yn n ^ 3] :=
-      ModEq.add (by rw [pow_succ']; exact hx.mul_right' _) <|
+      ModEq.add (by rw [pow_succ]; exact hx.mul_right' _) <|
         by
         have : k * xn n ^ (k - 1) * yn n * xn n = k * xn n ^ k * yn n := by
-          clear _let_match <;> cases' k with k <;> simp [pow_succ', mul_comm, mul_left_comm]
+          clear _let_match <;> cases' k with k <;> simp [pow_succ, mul_comm, mul_left_comm]
         rw [← this]
         exact hy.mul_right _
-    rw [add_tsub_cancel_right, Nat.mul_succ, xn_add, yn_add, pow_succ' (xn _ n), Nat.succ_mul,
+    rw [add_tsub_cancel_right, Nat.mul_succ, xn_add, yn_add, pow_succ (xn _ n), Nat.succ_mul,
       add_comm (k * xn _ n ^ k) (xn _ n ^ k), right_distrib]
     exact ⟨L, R⟩
 #align pell.xy_modeq_yn Pell.xy_modEq_yn
@@ -593,7 +593,7 @@ theorem xy_modEq_yn (n) :
 #print Pell.ysq_dvd_yy /-
 theorem ysq_dvd_yy (n) : yn n * yn n ∣ yn (n * yn n) :=
   modEq_zero_iff_dvd.1 <|
-    ((xy_modeq_yn n (yn n)).right.of_dvd <| by simp [pow_succ]).trans
+    ((xy_modeq_yn n (yn n)).right.of_dvd <| by simp [pow_succ']).trans
       (modEq_zero_iff_dvd.2 <| by simp [mul_dvd_mul_left, mul_assoc])
 #align pell.ysq_dvd_yy Pell.ysq_dvd_yy
 -/
@@ -608,7 +608,7 @@ theorem dvd_of_ysq_dvd {n t} (h : yn n * yn n ∣ yn t) : yn n ∣ t :=
       Nat.dvd_of_mul_dvd_mul_right (strict_mono_y n0l) <|
         modEq_zero_iff_dvd.1 <| by
           have xm := (xy_modeq_yn a1 n k).right <;> rw [← ke] at xm <;>
-            exact (xm.of_dvd <| by simp [pow_succ]).symm.trans h.modeq_zero_nat
+            exact (xm.of_dvd <| by simp [pow_succ']).symm.trans h.modeq_zero_nat
     rw [ke] <;>
       exact dvd_mul_of_dvd_right (((xy_coprime _ _).pow_leftₓ _).symm.dvd_of_dvd_mul_right this) _
 #align pell.dvd_of_ysq_dvd Pell.dvd_of_ysq_dvd
@@ -706,7 +706,7 @@ theorem x_sub_y_dvd_pow (y : ℕ) :
     have : (2 * a * y - y * y - 1 : ℤ) ∣ ↑(y ^ (n + 2)) - ↑(2 * a) * ↑(y ^ (n + 1)) + ↑(y ^ n) :=
       ⟨-↑(y ^ n),
         by
-        simp [pow_succ, mul_add, Int.ofNat_mul, show ((2 : ℕ) : ℤ) = 2 from rfl, mul_comm,
+        simp [pow_succ', mul_add, Int.ofNat_mul, show ((2 : ℕ) : ℤ) = 2 from rfl, mul_comm,
           mul_left_comm]
         ring⟩
     rw [xz_succ_succ, yz_succ_succ, x_sub_y_dvd_pow_lem ↑(y ^ (n + 2)) ↑(y ^ (n + 1)) ↑(y ^ n)]
@@ -755,12 +755,12 @@ theorem xn_modEq_x2n_sub_lem {n j} (h : j ≤ n) : xn (2 * n - j) + xn j ≡ 0 [
                     | rw [← Int.ofNat_add]
                     | rw [← Int.ofNat_mul] <;>
                 rw [mul_comm (xn a1 j) (yn a1 n)] <;>
-              exact Int.coe_nat_dvd.2 (xn_modeq_x2n_add_lem _ _ _))
+              exact Int.natCast_dvd_natCast.2 (xn_modeq_x2n_add_lem _ _ _))
           ((dvd_mul_right _ _).mul_left _)
   rw [two_mul, add_tsub_assoc_of_le h, xn_add, add_assoc, ← zero_add 0]
   exact
     (dvd_mul_right _ _).modEq_zero_nat.add
-      (Int.coe_nat_dvd.1 <| by simpa [xz, yz] using h1).modEq_zero_nat
+      (Int.natCast_dvd_natCast.1 <| by simpa [xz, yz] using h1).modEq_zero_nat
 #align pell.xn_modeq_x2n_sub_lem Pell.xn_modEq_x2n_sub_lem
 -/
 
@@ -1040,7 +1040,7 @@ theorem matiyasevic {a k x y} :
         have sx : s ≡ x [MOD u] := (xy_modeq_of_modeq b1 a1 ba k).left
         have tk : t ≡ k [MOD 4 * y] :=
           have : 4 * y ∣ b - 1 :=
-            Int.coe_nat_dvd.1 <| by rw [Int.ofNat_sub (le_of_lt b1)] <;> exact bm1.symm.dvd
+            Int.natCast_dvd_natCast.1 <| by rw [Int.ofNat_sub (le_of_lt b1)] <;> exact bm1.symm.dvd
           (yn_modeq_a_sub_one _ _).of_dvd this
         ⟨ky,
           Or.inr
@@ -1070,7 +1070,8 @@ theorem matiyasevic {a k x y} :
                 have yd : 4 * yn a1 i ∣ 4 * n := mul_dvd_mul_left _ <| dvd_of_ysq_dvd a1 yv
                 have jk : j ≡ k [MOD 4 * yn a1 i] :=
                   have : 4 * yn a1 i ∣ b - 1 :=
-                    Int.coe_nat_dvd.1 <| by rw [Int.ofNat_sub (le_of_lt b1)] <;> exact bm1.symm.dvd
+                    Int.natCast_dvd_natCast.1 <| by
+                      rw [Int.ofNat_sub (le_of_lt b1)] <;> exact bm1.symm.dvd
                   ((yn_modeq_a_sub_one b1 _).of_dvd this).symm.trans tk
                 have ki : k + i < 4 * yn a1 i :=
                   lt_of_le_of_lt (add_le_add ky (yn_ge_n a1 i)) <| by
Diff
@@ -211,7 +211,7 @@ end
 #print Pell.asq_pos /-
 theorem asq_pos : 0 < a * a :=
   le_trans (le_of_lt a1)
-    (by have := @Nat.mul_le_mul_left 1 a a (le_of_lt a1) <;> rwa [mul_one] at this )
+    (by have := @Nat.mul_le_mul_left 1 a a (le_of_lt a1) <;> rwa [mul_one] at this)
 #align pell.asq_pos Pell.asq_pos
 -/
 
@@ -316,7 +316,7 @@ instance dnsq : Zsqrtd.Nonsquare d :=
     have : (n + 1) * (n + 1) ≤ n * n + 1 := by rw [this] <;> exact Nat.mul_self_le_mul_self na
     have : n + n ≤ 0 :=
       @Nat.le_of_add_le_add_right (n * n + 1) _ _ (by ring_nf at this ⊢ <;> assumption)
-    ne_of_gt d_pos <| by rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h ⟩
+    ne_of_gt d_pos <| by rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h⟩
 #align pell.dnsq Pell.dnsq
 -/
 
@@ -365,7 +365,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
           (isPell_mul hp (isPell_star.1 is_pell_one))
           (by
             have t := mul_le_mul_of_nonneg_right h am1p <;>
-              rwa [pell_zd_succ, mul_assoc, a1m, mul_one] at t )
+              rwa [pell_zd_succ, mul_assoc, a1m, mul_one] at t)
       ⟨m + 1, by
         rw [show b = b * ⟨a, -1⟩ * ⟨a, 1⟩ by rw [mul_assoc, Eq.trans (mul_comm _ _) a1m] <;> simp,
           pell_zd_succ, e]⟩
@@ -378,7 +378,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
           have y0l : (0 : ℤ√d a1) < ⟨x - x, y - -y⟩ :=
             sub_lt_sub h1l fun hn : (1 : ℤ√d a1) ≤ ⟨x, -y⟩ => by
               have t := mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1) <;>
-                  rw [bm, mul_one] at t  <;>
+                  rw [bm, mul_one] at t <;>
                 exact h1l t
           have yl2 : (⟨_, _⟩ : ℤ√_) < ⟨_, _⟩ :=
             show (⟨x, y⟩ - ⟨x, -y⟩ : ℤ√d a1) < ⟨a, 1⟩ - ⟨a, -1⟩ from
@@ -386,9 +386,9 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
                 have t :=
                       mul_le_mul_of_nonneg_right
                         (mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1)) a1p <;>
-                    rw [bm, one_mul, mul_assoc, Eq.trans (mul_comm _ _) a1m, mul_one] at t  <;>
+                    rw [bm, one_mul, mul_assoc, Eq.trans (mul_comm _ _) a1m, mul_one] at t <;>
                   exact ha t
-          simp at y0l  <;> simp at yl2  <;>
+          simp at y0l <;> simp at yl2 <;>
             exact
               match y, y0l, (yl2 : (⟨_, _⟩ : ℤ√_) < ⟨_, _⟩) with
               | 0, y0l, yl2 => y0l (le_refl 0)
@@ -419,7 +419,7 @@ theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell
 theorem eq_pell {x y : ℕ} (hp : x * x - d * y * y = 1) : ∃ n, x = xn n ∧ y = yn n :=
   have : (1 : ℤ√d) ≤ ⟨x, y⟩ :=
     match x, hp with
-    | 0, (hp : 0 - _ = 1) => by rw [zero_tsub] at hp  <;> contradiction
+    | 0, (hp : 0 - _ = 1) => by rw [zero_tsub] at hp <;> contradiction
     | x + 1, hp =>
       Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| Nat.succ_pos x) (Int.ofNat_zero_le _)
   let ⟨m, e⟩ := eq_pell_zd ⟨x, y⟩ this (is_pell_nat.2 hp)
@@ -441,8 +441,8 @@ theorem xn_add (m n) : xn (m + n) = xn m * xn n + d * yn m * yn n := by
   injection pell_zd_add _ m n with h _ <;>
       repeat'
         first
-        | rw [← Int.ofNat_add] at h 
-        | rw [← Int.ofNat_mul] at h  <;>
+        | rw [← Int.ofNat_add] at h
+        | rw [← Int.ofNat_mul] at h <;>
     exact Int.ofNat.inj h
 #align pell.xn_add Pell.xn_add
 -/
@@ -452,8 +452,8 @@ theorem yn_add (m n) : yn (m + n) = xn m * yn n + yn m * xn n := by
   injection pell_zd_add _ m n with _ h <;>
       repeat'
         first
-        | rw [← Int.ofNat_add] at h 
-        | rw [← Int.ofNat_mul] at h  <;>
+        | rw [← Int.ofNat_add] at h
+        | rw [← Int.ofNat_mul] at h <;>
     exact Int.ofNat.inj h
 #align pell.yn_add Pell.yn_add
 -/
@@ -462,7 +462,7 @@ theorem yn_add (m n) : yn (m + n) = xn m * yn n + yn m * xn n := by
 theorem pellZd_sub {m n} (h : n ≤ m) : pell_zd (m - n) = pell_zd m * star (pell_zd n) :=
   by
   let t := pell_zd_add n (m - n)
-  rw [add_tsub_cancel_of_le h] at t  <;>
+  rw [add_tsub_cancel_of_le h] at t <;>
     rw [t, mul_comm (pell_zd _ n) _, mul_assoc, is_pell_norm.1 (is_pell_pell_zd _ _), mul_one]
 #align pell.pell_zd_sub Pell.pellZd_sub
 -/
@@ -514,7 +514,7 @@ theorem strictMono_x : StrictMono xn
         fun e => by rw [e]
     simp <;> refine' lt_of_lt_of_le (lt_of_le_of_lt this _) (Nat.le_add_right _ _) <;>
         have t := Nat.mul_lt_mul_of_pos_left a1 (x_pos a1 n) <;>
-      rwa [mul_one] at t 
+      rwa [mul_one] at t
 #align pell.strict_mono_x Pell.strictMono_x
 -/
 
@@ -544,9 +544,9 @@ theorem y_dvd_iff (m n) : yn m ∣ yn n ↔ m ∣ n :=
           Nat.Coprime.symm <| (xy_coprime _).coprime_dvd_right (y_mul_dvd m (n / m))
         have m0 : 0 < m :=
           m.eq_zero_or_pos.resolve_left fun e => by
-            rw [e, Nat.mod_zero] at hp  <;> rw [e] at h  <;>
+            rw [e, Nat.mod_zero] at hp <;> rw [e] at h <;>
               exact ne_of_lt (strict_mono_y a1 hp) (eq_zero_of_zero_dvd h).symm
-        rw [← Nat.mod_add_div n m, yn_add] at h  <;>
+        rw [← Nat.mod_add_div n m, yn_add] at h <;>
           exact
             not_le_of_gt (strict_mono_y _ <| Nat.mod_lt n m0)
               (Nat.le_of_dvd (strict_mono_y _ hp) <|
@@ -607,7 +607,7 @@ theorem dvd_of_ysq_dvd {n t} (h : yn n * yn n ∣ yn t) : yn n ∣ t :=
     have : yn n ∣ k * xn n ^ (k - 1) :=
       Nat.dvd_of_mul_dvd_mul_right (strict_mono_y n0l) <|
         modEq_zero_iff_dvd.1 <| by
-          have xm := (xy_modeq_yn a1 n k).right <;> rw [← ke] at xm  <;>
+          have xm := (xy_modeq_yn a1 n k).right <;> rw [← ke] at xm <;>
             exact (xm.of_dvd <| by simp [pow_succ]).symm.trans h.modeq_zero_nat
     rw [ke] <;>
       exact dvd_mul_of_dvd_right (((xy_coprime _ _).pow_leftₓ _).symm.dvd_of_dvd_mul_right this) _
@@ -629,8 +629,8 @@ theorem pellZd_succ_succ (n) : pell_zd (n + 2) + pell_zd n = (2 * a : ℕ) * pel
 theorem xy_succ_succ (n) :
     xn (n + 2) + xn n = 2 * a * xn (n + 1) ∧ yn (n + 2) + yn n = 2 * a * yn (n + 1) :=
   by
-  have := pell_zd_succ_succ a1 n; unfold pell_zd at this 
-  erw [Zsqrtd.smul_val (2 * a : ℕ)] at this 
+  have := pell_zd_succ_succ a1 n; unfold pell_zd at this
+  erw [Zsqrtd.smul_val (2 * a : ℕ)] at this
   injection this with h₁ h₂
   constructor <;> apply Int.ofNat.inj <;> [simpa using h₁; simpa using h₂]
 #align pell.xy_succ_succ Pell.xy_succ_succ
@@ -726,7 +726,7 @@ theorem xn_modEq_x2n_add_lem (n j) : xn n ∣ d * yn n * (yn n * xn j) + xn j :=
           | rw [Int.ofNat_add]
           | rw [Int.ofNat_mul] <;>
       exact add_eq_of_eq_sub' (Eq.symm <| pell_eqz _ _)
-  rw [h2] at h1  <;> rw [h1, mul_assoc] <;> exact dvd_mul_right _ _
+  rw [h2] at h1 <;> rw [h1, mul_assoc] <;> exact dvd_mul_right _ _
 #align pell.xn_modeq_x2n_add_lem Pell.xn_modEq_x2n_add_lem
 -/
 
@@ -771,7 +771,7 @@ theorem xn_modEq_x2n_sub {n j} (h : j ≤ 2 * n) : xn (2 * n - j) + xn j ≡ 0 [
     have : 2 * n - j + j ≤ n + j := by
       rw [tsub_add_cancel_of_le h, two_mul] <;> exact Nat.add_le_add_left jn _
     let t := xn_modeq_x2n_sub_lem (Nat.le_of_add_le_add_right this)
-    rwa [tsub_tsub_cancel_of_le h, add_comm] at t 
+    rwa [tsub_tsub_cancel_of_le h, add_comm] at t
 #align pell.xn_modeq_x2n_sub Pell.xn_modEq_x2n_sub
 -/
 
@@ -811,7 +811,7 @@ theorem eq_of_xn_modEq_lem1 {i n} : ∀ {j}, i < j → j < n → xn i % xn n < x
 
 #print Pell.eq_of_xn_modEq_lem2 /-
 theorem eq_of_xn_modEq_lem2 {n} (h : 2 * xn n = xn (n + 1)) : a = 2 ∧ n = 0 := by
-  rw [xn_succ, mul_comm] at h  <;>
+  rw [xn_succ, mul_comm] at h <;>
     exact
       by
       have : n = 0 :=
@@ -820,7 +820,7 @@ theorem eq_of_xn_modEq_lem2 {n} (h : 2 * xn n = xn (n + 1)) : a = 2 ∧ n = 0 :=
             (lt_of_le_of_lt (Nat.mul_le_mul_left _ a1)
               (Nat.lt_add_of_pos_right <| mul_pos (d_pos a1) (strict_mono_y a1 np)))
             h
-      cases this <;> simp at h  <;> exact ⟨h.symm, rfl⟩
+      cases this <;> simp at h <;> exact ⟨h.symm, rfl⟩
 #align pell.eq_of_xn_modeq_lem2 Pell.eq_of_xn_modEq_lem2
 -/
 
@@ -841,7 +841,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
       apply modeq.add_right_cancel' (xn a1 (2 * n - k))
       rw [tsub_add_cancel_of_le xle]
       have t := xn_modeq_x2n_sub_lem a1 k2nl.le
-      rw [tsub_tsub_cancel_of_le k2n] at t 
+      rw [tsub_tsub_cancel_of_le k2n] at t
       exact t.trans dvd_rfl.zero_modeq_nat
     (lt_trichotomy j n).elim (fun jn : j < n => eq_of_xn_modeq_lem1 ij (lt_of_le_of_ne jn jnn))
       fun o =>
@@ -885,7 +885,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
             (fun h =>
               lt_trans
                 (eq_of_xn_modeq_lem3 h (le_of_lt j2n) jn fun ⟨a1, n1, i0, j2⟩ => by
-                  rw [n1, j2] at j2n  <;> exact absurd j2n (by decide))
+                  rw [n1, j2] at j2n <;> exact absurd j2n (by decide))
                 s)
             fun h => by rw [h] <;> exact s
         lem1 (ne_of_gt jn) <|
@@ -910,12 +910,12 @@ theorem eq_of_xn_modEq_le {i j n} (ij : i ≤ j) (j2n : j ≤ 2 * n) (h : xn i 
         have x0 : 0 < xn a1 0 % xn a1 n := by
           rw [Nat.mod_eq_of_lt (strict_mono_x a1 (Nat.pos_of_ne_zero npos))] <;> exact by decide
         cases' i with i; exact x0
-        rw [jn] at ij' 
+        rw [jn] at ij'
         exact
           x0.trans
             (eq_of_xn_modeq_lem3 _ (Nat.pos_of_ne_zero npos) (Nat.succ_pos _) (le_trans ij j2n)
               (ne_of_lt ij') fun ⟨a1, n1, _, i2⟩ => by
-              rw [n1, i2] at ij'  <;> exact absurd ij' (by decide))
+              rw [n1, i2] at ij' <;> exact absurd ij' (by decide))
       else ne_of_lt (eq_of_xn_modeq_lem3 (Nat.pos_of_ne_zero npos) ij' j2n jn ntriv) h
 #align pell.eq_of_xn_modeq_le Pell.eq_of_xn_modEq_le
 -/
@@ -937,7 +937,7 @@ theorem eq_of_xn_modEq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 *
   (le_or_gt j (2 * n)).imp
     (fun j2n : j ≤ 2 * n =>
       eq_of_xn_modeq j2n i2n h fun a2 n1 =>
-        ⟨fun j0 i2 => by rw [n1, i2] at hin  <;> exact absurd hin (by decide), fun j2 i0 =>
+        ⟨fun j0 i2 => by rw [n1, i2] at hin <;> exact absurd hin (by decide), fun j2 i0 =>
           ne_of_gt ipos i0⟩)
     fun j2n : 2 * n < j =>
     suffices i = 4 * n - j by rw [this, add_tsub_cancel_of_le j4n]
@@ -948,11 +948,11 @@ theorem eq_of_xn_modEq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 *
     eq_of_xn_modeq i2n j42n
       (h.symm.trans <| by
         let t := xn_modeq_x4n_sub j42n
-        rwa [tsub_tsub_cancel_of_le j4n] at t )
+        rwa [tsub_tsub_cancel_of_le j4n] at t)
       fun a2 n1 =>
       ⟨fun i0 => absurd i0 (ne_of_gt ipos), fun i2 =>
         by
-        rw [n1, i2] at hin 
+        rw [n1, i2] at hin
         exact absurd hin (by decide)⟩
 #align pell.eq_of_xn_modeq' Pell.eq_of_xn_modEq'
 -/
@@ -1031,9 +1031,9 @@ theorem matiyasevic {a k x y} :
         have vp : 0 < v := strict_mono_y a1 (lt_trans zero_lt_one m1)
         have b1 : 1 < b :=
           have : xn a1 1 < u := strict_mono_x a1 m1
-          have : a < u := by simp at this  <;> exact this
+          have : a < u := by simp at this <;> exact this
           lt_of_lt_of_le a1 <| by
-            delta modeq at ba  <;> rw [Nat.mod_eq_of_lt this] at ba  <;> rw [← ba] <;>
+            delta modeq at ba <;> rw [Nat.mod_eq_of_lt this] at ba <;> rw [← ba] <;>
               apply Nat.mod_le
         let s := xn b1 k
         let t := yn b1 k
@@ -1049,7 +1049,7 @@ theorem matiyasevic {a k x y} :
     ⟨a1,
       match o with
       | Or.inl ⟨x1, y0⟩ => by
-        rw [y0] at ky  <;> rw [Nat.eq_zero_of_le_zero ky, x1, y0] <;> exact ⟨rfl, rfl⟩
+        rw [y0] at ky <;> rw [Nat.eq_zero_of_le_zero ky, x1, y0] <;> exact ⟨rfl, rfl⟩
       | Or.inr ⟨u, v, s, t, b, xy, uv, st, b1, rem⟩ =>
         match x, y, eq_pell a1 xy, u, v, eq_pell a1 uv, s, t, eq_pell b1 st, rem, ky with
         | _, _, ⟨i, rfl, rfl⟩, _, _, ⟨n, rfl, rfl⟩, _, _, ⟨j, rfl, rfl⟩,
@@ -1058,7 +1058,7 @@ theorem matiyasevic {a k x y} :
             (tk : yn b1 j ≡ k [MOD 4 * yn a1 i])⟩,
           (ky : k ≤ yn a1 i) =>
           (Nat.eq_zero_or_pos i).elim
-            (fun i0 => by simp [i0] at ky  <;> rw [i0, ky] <;> exact ⟨rfl, rfl⟩) fun ipos =>
+            (fun i0 => by simp [i0] at ky <;> rw [i0, ky] <;> exact ⟨rfl, rfl⟩) fun ipos =>
             by
             suffices i = k by rw [this] <;> exact ⟨rfl, rfl⟩
             clear _x o rem xy uv st _match _match _fun_match <;>
@@ -1086,7 +1086,7 @@ theorem matiyasevic {a k x y} :
                         modeq_zero_iff_dvd.1 <| (jk.symm.add_right i).trans <| ji.of_dvd yd
                 have : i % (4 * yn a1 i) = k % (4 * yn a1 i) := (ji.of_dvd yd).symm.trans jk <;>
                   rwa [Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_left _ _) ki),
-                    Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_right _ _) ki)] at this ⟩⟩
+                    Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_right _ _) ki)] at this⟩⟩
 #align pell.matiyasevic Pell.matiyasevic
 -/
 
@@ -1190,8 +1190,8 @@ theorem eq_pow_of_pell {m n k} :
       rw [te, Nat.cast_add, Nat.cast_mul, Int.ofNat_sub na]
       exact x_sub_y_dvd_pow a1 n k
     have : n ^ k % t = m % t := (this.symm.trans tm).add_left_cancel' _
-    rw [← te] at nt 
-    rwa [Nat.mod_eq_of_lt (Nat.cast_lt.1 nt), Nat.mod_eq_of_lt mt] at this 
+    rw [← te] at nt
+    rwa [Nat.mod_eq_of_lt (Nat.cast_lt.1 nt), Nat.mod_eq_of_lt mt] at this
 #align pell.eq_pow_of_pell Pell.eq_pow_of_pell
 -/
 
Diff
@@ -72,7 +72,7 @@ def IsPell : ℤ√d → Prop
 
 #print Pell.isPell_norm /-
 theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
-  | ⟨x, y⟩ => by simp [Zsqrtd.ext, is_pell, mul_comm] <;> ring_nf
+  | ⟨x, y⟩ => by simp [Zsqrtd.ext_iff, is_pell, mul_comm] <;> ring_nf
 #align pell.is_pell_norm Pell.isPell_norm
 -/
 
@@ -270,7 +270,7 @@ theorem isPell_nat {x y : ℕ} : IsPell (⟨x, y⟩ : ℤ√d) ↔ x * x - d * y
 
 #print Pell.pellZd_succ /-
 @[simp]
-theorem pellZd_succ (n : ℕ) : pell_zd (n + 1) = pell_zd n * ⟨a, 1⟩ := by simp [Zsqrtd.ext]
+theorem pellZd_succ (n : ℕ) : pell_zd (n + 1) = pell_zd n * ⟨a, 1⟩ := by simp [Zsqrtd.ext_iff]
 #align pell.pell_zd_succ Pell.pellZd_succ
 -/
 
@@ -620,7 +620,7 @@ theorem pellZd_succ_succ (n) : pell_zd (n + 2) + pell_zd n = (2 * a : ℕ) * pel
   have : (1 : ℤ√d) + ⟨a, 1⟩ * ⟨a, 1⟩ = ⟨a, 1⟩ * (2 * a) :=
     by
     rw [Zsqrtd.coe_nat_val]; change (⟨_, _⟩ : ℤ√d a1) = ⟨_, _⟩
-    rw [dz_val]; dsimp [az]; rw [Zsqrtd.ext]; dsimp; constructor <;> ring
+    rw [dz_val]; dsimp [az]; rw [Zsqrtd.ext_iff]; dsimp; constructor <;> ring
   simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (· * pell_zd a1 n) this
 #align pell.pell_zd_succ_succ Pell.pellZd_succ_succ
 -/
Diff
@@ -1140,8 +1140,8 @@ theorem eq_pow_of_pell {m n k} :
       by
       refine' eq_pow_of_pell_lem hn.ne' hk.ne' _
       calc
-        n ^ k ≤ n ^ w := Nat.pow_le_pow_of_le_right hn kw
-        _ < (w + 1) ^ w := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) wpos)
+        n ^ k ≤ n ^ w := Nat.pow_le_pow_right hn kw
+        _ < (w + 1) ^ w := (Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) wpos)
         _ ≤ a := xn_ge_a_pow w1 w
     lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le with t te
     have tm : x ≡ y * (a - n) + n ^ k [MOD t] :=
@@ -1174,8 +1174,8 @@ theorem eq_pow_of_pell {m n k} :
           (yn_modeq_a_sub_one hw1 j).symm.trans <| modeq_zero_iff_dvd.2 ⟨z, yj.symm⟩)
     have hnka : n ^ k < xn hw1 j
     calc
-      n ^ k ≤ n ^ j := Nat.pow_le_pow_of_le_right hn0 (le_trans kw wj)
-      _ < (w + 1) ^ j := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) hj0)
+      n ^ k ≤ n ^ j := Nat.pow_le_pow_right hn0 (le_trans kw wj)
+      _ < (w + 1) ^ j := (Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) hj0)
       _ ≤ xn hw1 j := xn_ge_a_pow hw1 j
     have nt : (↑(n ^ k) : ℤ) < 2 * xn hw1 j * n - n * n - 1 :=
       eq_pow_of_pell_lem hn0.ne' hk0.ne' hnka
Diff
@@ -3,9 +3,9 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
-import Mathbin.Algebra.Star.Unitary
-import Mathbin.Data.Nat.Modeq
-import Mathbin.NumberTheory.Zsqrtd.Basic
+import Algebra.Star.Unitary
+import Data.Nat.Modeq
+import NumberTheory.Zsqrtd.Basic
 
 #align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"ce38d86c0b2d427ce208c3cee3159cb421d2b3c4"
 
Diff
@@ -482,7 +482,7 @@ theorem yz_sub {m n} (h : n ≤ m) : yz (m - n) = xz n * yz m - xz m * yz n :=
 -/
 
 #print Pell.xy_coprime /-
-theorem xy_coprime (n) : (xn n).coprime (yn n) :=
+theorem xy_coprime (n) : (xn n).Coprime (yn n) :=
   Nat.coprime_of_dvd' fun k kp kx ky => by
     let p := pell_eq n
     rw [← p] <;>
@@ -540,8 +540,8 @@ theorem y_dvd_iff (m n) : yn m ∣ yn n ↔ m ∣ n :=
     Nat.dvd_of_mod_eq_zero <|
       (Nat.eq_zero_or_pos _).resolve_right fun hp =>
         by
-        have co : Nat.coprime (yn m) (xn (m * (n / m))) :=
-          Nat.coprime.symm <| (xy_coprime _).coprime_dvd_right (y_mul_dvd m (n / m))
+        have co : Nat.Coprime (yn m) (xn (m * (n / m))) :=
+          Nat.Coprime.symm <| (xy_coprime _).coprime_dvd_right (y_mul_dvd m (n / m))
         have m0 : 0 < m :=
           m.eq_zero_or_pos.resolve_left fun e => by
             rw [e, Nat.mod_zero] at hp  <;> rw [e] at h  <;>
@@ -1018,10 +1018,10 @@ theorem matiyasevic {a k x y} :
         let v := yn a1 m
         have ky : k ≤ y := yn_ge_n a1 k
         have yv : y * y ∣ v := (ysq_dvd_yy a1 k).trans <| (y_dvd_iff _ _ _).2 <| dvd_mul_left _ _
-        have uco : Nat.coprime u (4 * y) :=
+        have uco : Nat.Coprime u (4 * y) :=
           have : 2 ∣ v :=
             modeq_zero_iff_dvd.1 <| (yn_modeq_two _ _).trans (dvd_mul_right _ _).modEq_zero_nat
-          have : Nat.coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
+          have : Nat.Coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
           (this.mul_right this).mul_right <|
             (xy_coprime _ _).coprime_dvd_right (dvd_of_mul_left_dvd yv)
         let ⟨b, ba, bm1⟩ := chinese_remainder uco a 1
Diff
@@ -2,16 +2,13 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module number_theory.pell_matiyasevic
-! leanprover-community/mathlib commit ce38d86c0b2d427ce208c3cee3159cb421d2b3c4
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Algebra.Star.Unitary
 import Mathbin.Data.Nat.Modeq
 import Mathbin.NumberTheory.Zsqrtd.Basic
 
+#align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"ce38d86c0b2d427ce208c3cee3159cb421d2b3c4"
+
 /-!
 # Pell's equation and Matiyasevic's theorem
 
Diff
@@ -79,9 +79,11 @@ theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
 #align pell.is_pell_norm Pell.isPell_norm
 -/
 
+#print Pell.isPell_iff_mem_unitary /-
 theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d)
   | ⟨x, y⟩ => by rw [unitary.mem_iff, is_pell_norm, mul_comm (star _), and_self_iff]
 #align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary
+-/
 
 #print Pell.isPell_mul /-
 theorem isPell_mul {b c : ℤ√d} (hb : IsPell b) (hc : IsPell c) : IsPell (b * c) :=
@@ -101,8 +103,6 @@ section
 
 parameter {a : ℕ} (a1 : 1 < a)
 
-include a1
-
 private def d :=
   a * a - 1
 
@@ -202,8 +202,6 @@ def yz (n : ℕ) : ℤ :=
 
 section
 
-omit a1
-
 #print Pell.az /-
 /-- The element `a` such that `d = a ^ 2 - 1`, considered as an integer.-/
 def az : ℤ :=
@@ -357,6 +355,7 @@ theorem x_pos (n) : 0 < xn n :=
 #align pell.x_pos Pell.x_pos
 -/
 
+#print Pell.eq_pell_lem /-
 theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell_zd n → ∃ n, b = pell_zd n
   | 0, b => fun h1 hp hl => ⟨0, @Zsqrtd.le_antisymm _ dnsq _ _ hl h1⟩
   | n + 1, b => fun h1 hp h =>
@@ -403,7 +402,9 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
                     add_le_add t t))
               | -[y+1], y0l, yl2 => y0l trivial
 #align pell.eq_pell_lem Pell.eq_pell_lem
+-/
 
+#print Pell.eq_pellZd /-
 theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell_zd n :=
   let ⟨n, h⟩ := @Zsqrtd.le_arch d b
   eq_pell_lem n b b1 hp <|
@@ -413,6 +414,7 @@ theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell
           Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| le_of_lt <| n_lt_xn _ _)
             (Int.ofNat_zero_le _)
 #align pell.eq_pell_zd Pell.eq_pellZd
+-/
 
 #print Pell.eq_pell /-
 /-- Every solution to **Pell's equation** is recursively obtained from the initial solution
@@ -687,8 +689,6 @@ theorem yn_modEq_two : ∀ n, yn n ≡ n [MOD 2]
 
 section
 
-omit a1
-
 #print Pell.x_sub_y_dvd_pow_lem /-
 theorem x_sub_y_dvd_pow_lem (y2 y1 y0 yn1 yn0 xn1 xn0 ay a2 : ℤ) :
     (a2 * yn1 - yn0) * ay + y2 - (a2 * xn1 - xn0) =
@@ -699,6 +699,7 @@ theorem x_sub_y_dvd_pow_lem (y2 y1 y0 yn1 yn0 xn1 xn0 ay a2 : ℤ) :
 
 end
 
+#print Pell.x_sub_y_dvd_pow /-
 theorem x_sub_y_dvd_pow (y : ℕ) :
     ∀ n, (2 * a * y - y * y - 1 : ℤ) ∣ yz n * (a - y) + ↑(y ^ n) - xz n
   | 0 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one]
@@ -714,6 +715,7 @@ theorem x_sub_y_dvd_pow (y : ℕ) :
     rw [xz_succ_succ, yz_succ_succ, x_sub_y_dvd_pow_lem ↑(y ^ (n + 2)) ↑(y ^ (n + 1)) ↑(y ^ n)]
     exact dvd_sub (dvd_add this <| (x_sub_y_dvd_pow (n + 1)).mul_left _) (x_sub_y_dvd_pow n)
 #align pell.x_sub_y_dvd_pow Pell.x_sub_y_dvd_pow
+-/
 
 #print Pell.xn_modEq_x2n_add_lem /-
 theorem xn_modEq_x2n_add_lem (n j) : xn n ∣ d * yn n * (yn n * xn j) + xn j :=
Diff
@@ -1106,7 +1106,6 @@ theorem eq_pow_of_pell_lem {a y k} (hy0 : y ≠ 0) (hk0 : k ≠ 0) (hyk : y ^ k
       have := hya.le
       mono* <;> simpa only [sub_nonneg, Nat.cast_le, Nat.one_le_cast, Nat.one_le_iff_ne_zero]
     _ = 2 * a * y - y * y - 1 := by ring
-    
 #align pell.eq_pow_of_pell_lem Pell.eq_pow_of_pell_lem
 -/
 
@@ -1145,7 +1144,6 @@ theorem eq_pow_of_pell {m n k} :
         n ^ k ≤ n ^ w := Nat.pow_le_pow_of_le_right hn kw
         _ < (w + 1) ^ w := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) wpos)
         _ ≤ a := xn_ge_a_pow w1 w
-        
     lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le with t te
     have tm : x ≡ y * (a - n) + n ^ k [MOD t] :=
       by
@@ -1180,7 +1178,6 @@ theorem eq_pow_of_pell {m n k} :
       n ^ k ≤ n ^ j := Nat.pow_le_pow_of_le_right hn0 (le_trans kw wj)
       _ < (w + 1) ^ j := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) hj0)
       _ ≤ xn hw1 j := xn_ge_a_pow hw1 j
-      
     have nt : (↑(n ^ k) : ℤ) < 2 * xn hw1 j * n - n * n - 1 :=
       eq_pow_of_pell_lem hn0.ne' hk0.ne' hnka
     have na : n ≤ xn hw1 j := (Nat.le_self_pow hk0.ne' _).trans hnka.le
Diff
@@ -99,7 +99,7 @@ end
 
 section
 
-parameter {a : ℕ}(a1 : 1 < a)
+parameter {a : ℕ} (a1 : 1 < a)
 
 include a1
 
@@ -320,7 +320,7 @@ instance dnsq : Zsqrtd.Nonsquare d :=
     have na : n < a := Nat.mul_self_lt_mul_self_iff.2 (by rw [← this] <;> exact Nat.lt_succ_self _)
     have : (n + 1) * (n + 1) ≤ n * n + 1 := by rw [this] <;> exact Nat.mul_self_le_mul_self na
     have : n + n ≤ 0 :=
-      @Nat.le_of_add_le_add_right (n * n + 1) _ _ (by ring_nf  at this ⊢ <;> assumption)
+      @Nat.le_of_add_le_add_right (n * n + 1) _ _ (by ring_nf at this ⊢ <;> assumption)
     ne_of_gt d_pos <| by rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h ⟩
 #align pell.dnsq Pell.dnsq
 -/
Diff
@@ -216,7 +216,7 @@ end
 #print Pell.asq_pos /-
 theorem asq_pos : 0 < a * a :=
   le_trans (le_of_lt a1)
-    (by have := @Nat.mul_le_mul_left 1 a a (le_of_lt a1) <;> rwa [mul_one] at this)
+    (by have := @Nat.mul_le_mul_left 1 a a (le_of_lt a1) <;> rwa [mul_one] at this )
 #align pell.asq_pos Pell.asq_pos
 -/
 
@@ -320,8 +320,8 @@ instance dnsq : Zsqrtd.Nonsquare d :=
     have na : n < a := Nat.mul_self_lt_mul_self_iff.2 (by rw [← this] <;> exact Nat.lt_succ_self _)
     have : (n + 1) * (n + 1) ≤ n * n + 1 := by rw [this] <;> exact Nat.mul_self_le_mul_self na
     have : n + n ≤ 0 :=
-      @Nat.le_of_add_le_add_right (n * n + 1) _ _ (by ring_nf  at this⊢ <;> assumption)
-    ne_of_gt d_pos <| by rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h⟩
+      @Nat.le_of_add_le_add_right (n * n + 1) _ _ (by ring_nf  at this ⊢ <;> assumption)
+    ne_of_gt d_pos <| by rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h ⟩
 #align pell.dnsq Pell.dnsq
 -/
 
@@ -369,7 +369,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
           (isPell_mul hp (isPell_star.1 is_pell_one))
           (by
             have t := mul_le_mul_of_nonneg_right h am1p <;>
-              rwa [pell_zd_succ, mul_assoc, a1m, mul_one] at t)
+              rwa [pell_zd_succ, mul_assoc, a1m, mul_one] at t )
       ⟨m + 1, by
         rw [show b = b * ⟨a, -1⟩ * ⟨a, 1⟩ by rw [mul_assoc, Eq.trans (mul_comm _ _) a1m] <;> simp,
           pell_zd_succ, e]⟩
@@ -382,7 +382,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
           have y0l : (0 : ℤ√d a1) < ⟨x - x, y - -y⟩ :=
             sub_lt_sub h1l fun hn : (1 : ℤ√d a1) ≤ ⟨x, -y⟩ => by
               have t := mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1) <;>
-                  rw [bm, mul_one] at t <;>
+                  rw [bm, mul_one] at t  <;>
                 exact h1l t
           have yl2 : (⟨_, _⟩ : ℤ√_) < ⟨_, _⟩ :=
             show (⟨x, y⟩ - ⟨x, -y⟩ : ℤ√d a1) < ⟨a, 1⟩ - ⟨a, -1⟩ from
@@ -390,9 +390,9 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
                 have t :=
                       mul_le_mul_of_nonneg_right
                         (mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1)) a1p <;>
-                    rw [bm, one_mul, mul_assoc, Eq.trans (mul_comm _ _) a1m, mul_one] at t <;>
+                    rw [bm, one_mul, mul_assoc, Eq.trans (mul_comm _ _) a1m, mul_one] at t  <;>
                   exact ha t
-          simp at y0l <;> simp at yl2 <;>
+          simp at y0l  <;> simp at yl2  <;>
             exact
               match y, y0l, (yl2 : (⟨_, _⟩ : ℤ√_) < ⟨_, _⟩) with
               | 0, y0l, yl2 => y0l (le_refl 0)
@@ -420,7 +420,7 @@ theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell
 theorem eq_pell {x y : ℕ} (hp : x * x - d * y * y = 1) : ∃ n, x = xn n ∧ y = yn n :=
   have : (1 : ℤ√d) ≤ ⟨x, y⟩ :=
     match x, hp with
-    | 0, (hp : 0 - _ = 1) => by rw [zero_tsub] at hp <;> contradiction
+    | 0, (hp : 0 - _ = 1) => by rw [zero_tsub] at hp  <;> contradiction
     | x + 1, hp =>
       Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| Nat.succ_pos x) (Int.ofNat_zero_le _)
   let ⟨m, e⟩ := eq_pell_zd ⟨x, y⟩ this (is_pell_nat.2 hp)
@@ -440,7 +440,10 @@ theorem pellZd_add (m) : ∀ n, pell_zd (m + n) = pell_zd m * pell_zd n
 #print Pell.xn_add /-
 theorem xn_add (m n) : xn (m + n) = xn m * xn n + d * yn m * yn n := by
   injection pell_zd_add _ m n with h _ <;>
-      repeat' first |rw [← Int.ofNat_add] at h|rw [← Int.ofNat_mul] at h <;>
+      repeat'
+        first
+        | rw [← Int.ofNat_add] at h 
+        | rw [← Int.ofNat_mul] at h  <;>
     exact Int.ofNat.inj h
 #align pell.xn_add Pell.xn_add
 -/
@@ -448,7 +451,10 @@ theorem xn_add (m n) : xn (m + n) = xn m * xn n + d * yn m * yn n := by
 #print Pell.yn_add /-
 theorem yn_add (m n) : yn (m + n) = xn m * yn n + yn m * xn n := by
   injection pell_zd_add _ m n with _ h <;>
-      repeat' first |rw [← Int.ofNat_add] at h|rw [← Int.ofNat_mul] at h <;>
+      repeat'
+        first
+        | rw [← Int.ofNat_add] at h 
+        | rw [← Int.ofNat_mul] at h  <;>
     exact Int.ofNat.inj h
 #align pell.yn_add Pell.yn_add
 -/
@@ -457,7 +463,7 @@ theorem yn_add (m n) : yn (m + n) = xn m * yn n + yn m * xn n := by
 theorem pellZd_sub {m n} (h : n ≤ m) : pell_zd (m - n) = pell_zd m * star (pell_zd n) :=
   by
   let t := pell_zd_add n (m - n)
-  rw [add_tsub_cancel_of_le h] at t <;>
+  rw [add_tsub_cancel_of_le h] at t  <;>
     rw [t, mul_comm (pell_zd _ n) _, mul_assoc, is_pell_norm.1 (is_pell_pell_zd _ _), mul_one]
 #align pell.pell_zd_sub Pell.pellZd_sub
 -/
@@ -509,7 +515,7 @@ theorem strictMono_x : StrictMono xn
         fun e => by rw [e]
     simp <;> refine' lt_of_lt_of_le (lt_of_le_of_lt this _) (Nat.le_add_right _ _) <;>
         have t := Nat.mul_lt_mul_of_pos_left a1 (x_pos a1 n) <;>
-      rwa [mul_one] at t
+      rwa [mul_one] at t 
 #align pell.strict_mono_x Pell.strictMono_x
 -/
 
@@ -539,9 +545,9 @@ theorem y_dvd_iff (m n) : yn m ∣ yn n ↔ m ∣ n :=
           Nat.coprime.symm <| (xy_coprime _).coprime_dvd_right (y_mul_dvd m (n / m))
         have m0 : 0 < m :=
           m.eq_zero_or_pos.resolve_left fun e => by
-            rw [e, Nat.mod_zero] at hp <;> rw [e] at h <;>
+            rw [e, Nat.mod_zero] at hp  <;> rw [e] at h  <;>
               exact ne_of_lt (strict_mono_y a1 hp) (eq_zero_of_zero_dvd h).symm
-        rw [← Nat.mod_add_div n m, yn_add] at h <;>
+        rw [← Nat.mod_add_div n m, yn_add] at h  <;>
           exact
             not_le_of_gt (strict_mono_y _ <| Nat.mod_lt n m0)
               (Nat.le_of_dvd (strict_mono_y _ hp) <|
@@ -596,13 +602,13 @@ theorem ysq_dvd_yy (n) : yn n * yn n ∣ yn (n * yn n) :=
 #print Pell.dvd_of_ysq_dvd /-
 theorem dvd_of_ysq_dvd {n t} (h : yn n * yn n ∣ yn t) : yn n ∣ t :=
   have nt : n ∣ t := (y_dvd_iff n t).1 <| dvd_of_mul_left_dvd h
-  n.eq_zero_or_pos.elim (fun n0 => by rwa [n0] at nt⊢) fun n0l : 0 < n =>
+  n.eq_zero_or_pos.elim (fun n0 => by rwa [n0] at nt ⊢) fun n0l : 0 < n =>
     by
     let ⟨k, ke⟩ := nt
     have : yn n ∣ k * xn n ^ (k - 1) :=
       Nat.dvd_of_mul_dvd_mul_right (strict_mono_y n0l) <|
         modEq_zero_iff_dvd.1 <| by
-          have xm := (xy_modeq_yn a1 n k).right <;> rw [← ke] at xm <;>
+          have xm := (xy_modeq_yn a1 n k).right <;> rw [← ke] at xm  <;>
             exact (xm.of_dvd <| by simp [pow_succ]).symm.trans h.modeq_zero_nat
     rw [ke] <;>
       exact dvd_mul_of_dvd_right (((xy_coprime _ _).pow_leftₓ _).symm.dvd_of_dvd_mul_right this) _
@@ -624,10 +630,10 @@ theorem pellZd_succ_succ (n) : pell_zd (n + 2) + pell_zd n = (2 * a : ℕ) * pel
 theorem xy_succ_succ (n) :
     xn (n + 2) + xn n = 2 * a * xn (n + 1) ∧ yn (n + 2) + yn n = 2 * a * yn (n + 1) :=
   by
-  have := pell_zd_succ_succ a1 n; unfold pell_zd at this
-  erw [Zsqrtd.smul_val (2 * a : ℕ)] at this
+  have := pell_zd_succ_succ a1 n; unfold pell_zd at this 
+  erw [Zsqrtd.smul_val (2 * a : ℕ)] at this 
   injection this with h₁ h₂
-  constructor <;> apply Int.ofNat.inj <;> [simpa using h₁;simpa using h₂]
+  constructor <;> apply Int.ofNat.inj <;> [simpa using h₁; simpa using h₂]
 #align pell.xy_succ_succ Pell.xy_succ_succ
 -/
 
@@ -715,9 +721,13 @@ theorem xn_modEq_x2n_add_lem (n j) : xn n ∣ d * yn n * (yn n * xn j) + xn j :=
   have h1 : d * yn n * (yn n * xn j) + xn j = (d * yn n * yn n + 1) * xn j := by
     simp [add_mul, mul_assoc]
   have h2 : d * yn n * yn n + 1 = xn n * xn n := by
-    apply Int.ofNat.inj <;> repeat' first |rw [Int.ofNat_add]|rw [Int.ofNat_mul] <;>
+    apply Int.ofNat.inj <;>
+        repeat'
+          first
+          | rw [Int.ofNat_add]
+          | rw [Int.ofNat_mul] <;>
       exact add_eq_of_eq_sub' (Eq.symm <| pell_eqz _ _)
-  rw [h2] at h1 <;> rw [h1, mul_assoc] <;> exact dvd_mul_right _ _
+  rw [h2] at h1  <;> rw [h1, mul_assoc] <;> exact dvd_mul_right _ _
 #align pell.xn_modeq_x2n_add_lem Pell.xn_modEq_x2n_add_lem
 -/
 
@@ -740,7 +750,11 @@ theorem xn_modEq_x2n_sub_lem {n j} (h : j ≤ n) : xn (2 * n - j) + xn j ≡ 0 [
       exact
         dvd_sub
           (by
-            delta xz <;> delta yz <;> repeat' first |rw [← Int.ofNat_add]|rw [← Int.ofNat_mul] <;>
+            delta xz <;> delta yz <;>
+                  repeat'
+                    first
+                    | rw [← Int.ofNat_add]
+                    | rw [← Int.ofNat_mul] <;>
                 rw [mul_comm (xn a1 j) (yn a1 n)] <;>
               exact Int.coe_nat_dvd.2 (xn_modeq_x2n_add_lem _ _ _))
           ((dvd_mul_right _ _).mul_left _)
@@ -758,7 +772,7 @@ theorem xn_modEq_x2n_sub {n j} (h : j ≤ 2 * n) : xn (2 * n - j) + xn j ≡ 0 [
     have : 2 * n - j + j ≤ n + j := by
       rw [tsub_add_cancel_of_le h, two_mul] <;> exact Nat.add_le_add_left jn _
     let t := xn_modeq_x2n_sub_lem (Nat.le_of_add_le_add_right this)
-    rwa [tsub_tsub_cancel_of_le h, add_comm] at t
+    rwa [tsub_tsub_cancel_of_le h, add_comm] at t 
 #align pell.xn_modeq_x2n_sub Pell.xn_modEq_x2n_sub
 -/
 
@@ -798,7 +812,7 @@ theorem eq_of_xn_modEq_lem1 {i n} : ∀ {j}, i < j → j < n → xn i % xn n < x
 
 #print Pell.eq_of_xn_modEq_lem2 /-
 theorem eq_of_xn_modEq_lem2 {n} (h : 2 * xn n = xn (n + 1)) : a = 2 ∧ n = 0 := by
-  rw [xn_succ, mul_comm] at h <;>
+  rw [xn_succ, mul_comm] at h  <;>
     exact
       by
       have : n = 0 :=
@@ -807,7 +821,7 @@ theorem eq_of_xn_modEq_lem2 {n} (h : 2 * xn n = xn (n + 1)) : a = 2 ∧ n = 0 :=
             (lt_of_le_of_lt (Nat.mul_le_mul_left _ a1)
               (Nat.lt_add_of_pos_right <| mul_pos (d_pos a1) (strict_mono_y a1 np)))
             h
-      cases this <;> simp at h <;> exact ⟨h.symm, rfl⟩
+      cases this <;> simp at h  <;> exact ⟨h.symm, rfl⟩
 #align pell.eq_of_xn_modeq_lem2 Pell.eq_of_xn_modEq_lem2
 -/
 
@@ -828,7 +842,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
       apply modeq.add_right_cancel' (xn a1 (2 * n - k))
       rw [tsub_add_cancel_of_le xle]
       have t := xn_modeq_x2n_sub_lem a1 k2nl.le
-      rw [tsub_tsub_cancel_of_le k2n] at t
+      rw [tsub_tsub_cancel_of_le k2n] at t 
       exact t.trans dvd_rfl.zero_modeq_nat
     (lt_trichotomy j n).elim (fun jn : j < n => eq_of_xn_modeq_lem1 ij (lt_of_le_of_ne jn jnn))
       fun o =>
@@ -872,7 +886,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
             (fun h =>
               lt_trans
                 (eq_of_xn_modeq_lem3 h (le_of_lt j2n) jn fun ⟨a1, n1, i0, j2⟩ => by
-                  rw [n1, j2] at j2n <;> exact absurd j2n (by decide))
+                  rw [n1, j2] at j2n  <;> exact absurd j2n (by decide))
                 s)
             fun h => by rw [h] <;> exact s
         lem1 (ne_of_gt jn) <|
@@ -897,12 +911,12 @@ theorem eq_of_xn_modEq_le {i j n} (ij : i ≤ j) (j2n : j ≤ 2 * n) (h : xn i 
         have x0 : 0 < xn a1 0 % xn a1 n := by
           rw [Nat.mod_eq_of_lt (strict_mono_x a1 (Nat.pos_of_ne_zero npos))] <;> exact by decide
         cases' i with i; exact x0
-        rw [jn] at ij'
+        rw [jn] at ij' 
         exact
           x0.trans
             (eq_of_xn_modeq_lem3 _ (Nat.pos_of_ne_zero npos) (Nat.succ_pos _) (le_trans ij j2n)
               (ne_of_lt ij') fun ⟨a1, n1, _, i2⟩ => by
-              rw [n1, i2] at ij' <;> exact absurd ij' (by decide))
+              rw [n1, i2] at ij'  <;> exact absurd ij' (by decide))
       else ne_of_lt (eq_of_xn_modeq_lem3 (Nat.pos_of_ne_zero npos) ij' j2n jn ntriv) h
 #align pell.eq_of_xn_modeq_le Pell.eq_of_xn_modEq_le
 -/
@@ -924,7 +938,7 @@ theorem eq_of_xn_modEq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 *
   (le_or_gt j (2 * n)).imp
     (fun j2n : j ≤ 2 * n =>
       eq_of_xn_modeq j2n i2n h fun a2 n1 =>
-        ⟨fun j0 i2 => by rw [n1, i2] at hin <;> exact absurd hin (by decide), fun j2 i0 =>
+        ⟨fun j0 i2 => by rw [n1, i2] at hin  <;> exact absurd hin (by decide), fun j2 i0 =>
           ne_of_gt ipos i0⟩)
     fun j2n : 2 * n < j =>
     suffices i = 4 * n - j by rw [this, add_tsub_cancel_of_le j4n]
@@ -935,11 +949,11 @@ theorem eq_of_xn_modEq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 *
     eq_of_xn_modeq i2n j42n
       (h.symm.trans <| by
         let t := xn_modeq_x4n_sub j42n
-        rwa [tsub_tsub_cancel_of_le j4n] at t)
+        rwa [tsub_tsub_cancel_of_le j4n] at t )
       fun a2 n1 =>
       ⟨fun i0 => absurd i0 (ne_of_gt ipos), fun i2 =>
         by
-        rw [n1, i2] at hin
+        rw [n1, i2] at hin 
         exact absurd hin (by decide)⟩
 #align pell.eq_of_xn_modeq' Pell.eq_of_xn_modEq'
 -/
@@ -1018,9 +1032,9 @@ theorem matiyasevic {a k x y} :
         have vp : 0 < v := strict_mono_y a1 (lt_trans zero_lt_one m1)
         have b1 : 1 < b :=
           have : xn a1 1 < u := strict_mono_x a1 m1
-          have : a < u := by simp at this <;> exact this
+          have : a < u := by simp at this  <;> exact this
           lt_of_lt_of_le a1 <| by
-            delta modeq at ba <;> rw [Nat.mod_eq_of_lt this] at ba <;> rw [← ba] <;>
+            delta modeq at ba  <;> rw [Nat.mod_eq_of_lt this] at ba  <;> rw [← ba] <;>
               apply Nat.mod_le
         let s := xn b1 k
         let t := yn b1 k
@@ -1036,7 +1050,7 @@ theorem matiyasevic {a k x y} :
     ⟨a1,
       match o with
       | Or.inl ⟨x1, y0⟩ => by
-        rw [y0] at ky <;> rw [Nat.eq_zero_of_le_zero ky, x1, y0] <;> exact ⟨rfl, rfl⟩
+        rw [y0] at ky  <;> rw [Nat.eq_zero_of_le_zero ky, x1, y0] <;> exact ⟨rfl, rfl⟩
       | Or.inr ⟨u, v, s, t, b, xy, uv, st, b1, rem⟩ =>
         match x, y, eq_pell a1 xy, u, v, eq_pell a1 uv, s, t, eq_pell b1 st, rem, ky with
         | _, _, ⟨i, rfl, rfl⟩, _, _, ⟨n, rfl, rfl⟩, _, _, ⟨j, rfl, rfl⟩,
@@ -1045,7 +1059,7 @@ theorem matiyasevic {a k x y} :
             (tk : yn b1 j ≡ k [MOD 4 * yn a1 i])⟩,
           (ky : k ≤ yn a1 i) =>
           (Nat.eq_zero_or_pos i).elim
-            (fun i0 => by simp [i0] at ky <;> rw [i0, ky] <;> exact ⟨rfl, rfl⟩) fun ipos =>
+            (fun i0 => by simp [i0] at ky  <;> rw [i0, ky] <;> exact ⟨rfl, rfl⟩) fun ipos =>
             by
             suffices i = k by rw [this] <;> exact ⟨rfl, rfl⟩
             clear _x o rem xy uv st _match _match _fun_match <;>
@@ -1073,7 +1087,7 @@ theorem matiyasevic {a k x y} :
                         modeq_zero_iff_dvd.1 <| (jk.symm.add_right i).trans <| ji.of_dvd yd
                 have : i % (4 * yn a1 i) = k % (4 * yn a1 i) := (ji.of_dvd yd).symm.trans jk <;>
                   rwa [Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_left _ _) ki),
-                    Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_right _ _) ki)] at this⟩⟩
+                    Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_right _ _) ki)] at this ⟩⟩
 #align pell.matiyasevic Pell.matiyasevic
 -/
 
@@ -1103,7 +1117,7 @@ theorem eq_pow_of_pell {m n k} :
         0 < k ∧
           (n = 0 ∧ m = 0 ∨
             0 < n ∧
-              ∃ (w a t z : ℕ)(a1 : 1 < a),
+              ∃ (w a t z : ℕ) (a1 : 1 < a),
                 xn a1 k ≡ yn a1 k * (a - n) + m [MOD t] ∧
                   2 * a * n = t + (n * n + 1) ∧
                     m < t ∧
@@ -1141,7 +1155,10 @@ theorem eq_pow_of_pell {m n k} :
     have ta : 2 * a * n = t + (n * n + 1) :=
       by
       rw [← @Nat.cast_inj ℤ, Int.ofNat_add, te, sub_sub]
-      repeat' first |rw [Nat.cast_add]|rw [Nat.cast_mul]
+      repeat'
+        first
+        | rw [Nat.cast_add]
+        | rw [Nat.cast_mul]
       rw [Nat.cast_one, sub_add_cancel, Nat.cast_two]
     have zp : a * a - ((w + 1) * (w + 1) - 1) * (w * z) * (w * z) = 1 := ze ▸ pell_eq w1 w
     exact ⟨w, a, t, z, a1, tm, ta, Nat.cast_lt.1 nt, nw, kw, zp⟩
@@ -1177,8 +1194,8 @@ theorem eq_pow_of_pell {m n k} :
       rw [te, Nat.cast_add, Nat.cast_mul, Int.ofNat_sub na]
       exact x_sub_y_dvd_pow a1 n k
     have : n ^ k % t = m % t := (this.symm.trans tm).add_left_cancel' _
-    rw [← te] at nt
-    rwa [Nat.mod_eq_of_lt (Nat.cast_lt.1 nt), Nat.mod_eq_of_lt mt] at this
+    rw [← te] at nt 
+    rwa [Nat.mod_eq_of_lt (Nat.cast_lt.1 nt), Nat.mod_eq_of_lt mt] at this 
 #align pell.eq_pow_of_pell Pell.eq_pow_of_pell
 -/
 
Diff
@@ -79,12 +79,6 @@ theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
 #align pell.is_pell_norm Pell.isPell_norm
 -/
 
-/- warning: pell.is_pell_iff_mem_unitary -> Pell.isPell_iff_mem_unitary is a dubious translation:
-lean 3 declaration is
-  forall {d : Int} {b : Zsqrtd d}, Iff (Pell.IsPell d b) (Membership.Mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (SetLike.hasMem.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (Zsqrtd d) (Submonoid.setLike.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d)))) b (unitary.{0} (Zsqrtd d) (Zsqrtd.monoid d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.starRing d))))
-but is expected to have type
-  forall {d : Int} {b : Zsqrtd d}, Iff (Pell.IsPell d b) (Membership.mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (SetLike.instMembership.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (Zsqrtd d) (Submonoid.instSetLikeSubmonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d)))) b (unitary.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalCommSemiring.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalCommSemiring.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.instStarRingZsqrtdToNonUnitalSemiringToNonUnitalCommSemiringToNonUnitalCommRingCommRing d))))
-Case conversion may be inaccurate. Consider using '#align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitaryₓ'. -/
 theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d)
   | ⟨x, y⟩ => by rw [unitary.mem_iff, is_pell_norm, mul_comm (star _), and_self_iff]
 #align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary
@@ -363,12 +357,6 @@ theorem x_pos (n) : 0 < xn n :=
 #align pell.x_pos Pell.x_pos
 -/
 
-/- warning: pell.eq_pell_lem -> Pell.eq_pell_lem is a dubious translation:
-lean 3 declaration is
-  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (n : Nat) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasLe (_Private.3555558319.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)) b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasLe (_Private.3555558319.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) b (Pell.pellZd a a1 n)))
-but is expected to have type
-  forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (n : Nat) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
-Case conversion may be inaccurate. Consider using '#align pell.eq_pell_lem Pell.eq_pell_lemₓ'. -/
 theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell_zd n → ∃ n, b = pell_zd n
   | 0, b => fun h1 hp hl => ⟨0, @Zsqrtd.le_antisymm _ dnsq _ _ hl h1⟩
   | n + 1, b => fun h1 hp h =>
@@ -416,12 +404,6 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
               | -[y+1], y0l, yl2 => y0l trivial
 #align pell.eq_pell_lem Pell.eq_pell_lem
 
-/- warning: pell.eq_pell_zd -> Pell.eq_pellZd is a dubious translation:
-lean 3 declaration is
-  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasLe (_Private.3555558319.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) b (Pell.pellZd a a1 n)))
-but is expected to have type
-  forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
-Case conversion may be inaccurate. Consider using '#align pell.eq_pell_zd Pell.eq_pellZdₓ'. -/
 theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell_zd n :=
   let ⟨n, h⟩ := @Zsqrtd.le_arch d b
   eq_pell_lem n b b1 hp <|
@@ -711,12 +693,6 @@ theorem x_sub_y_dvd_pow_lem (y2 y1 y0 yn1 yn0 xn1 xn0 ay a2 : ℤ) :
 
 end
 
-/- warning: pell.x_sub_y_dvd_pow -> Pell.x_sub_y_dvd_pow is a dubious translation:
-lean 3 declaration is
-  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (y : Nat) (n : Nat), Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) a)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y))) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (Pell.yz a a1 n) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) a) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) y n))) (Pell.xz a a1 n))
-but is expected to have type
-  forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (y : Nat) (n : Nat), Dvd.dvd.{0} Int Int.instDvdInt (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) (Nat.cast.{0} Int instNatCastInt a)) (Nat.cast.{0} Int instNatCastInt y)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (Nat.cast.{0} Int instNatCastInt y) (Nat.cast.{0} Int instNatCastInt y))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (Pell.yz a a1 n) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (Nat.cast.{0} Int instNatCastInt a) (Nat.cast.{0} Int instNatCastInt y))) (Nat.cast.{0} Int instNatCastInt (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) y n))) (Pell.xz a a1 n))
-Case conversion may be inaccurate. Consider using '#align pell.x_sub_y_dvd_pow Pell.x_sub_y_dvd_powₓ'. -/
 theorem x_sub_y_dvd_pow (y : ℕ) :
     ∀ n, (2 * a * y - y * y - 1 : ℤ) ∣ yz n * (a - y) + ↑(y ^ n) - xz n
   | 0 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one]
Diff
@@ -345,11 +345,8 @@ theorem n_lt_a_pow : ∀ n : ℕ, n < a ^ n
   | 0 => Nat.le_refl 1
   | n + 1 => by
     have IH := n_lt_a_pow n
-    have : a ^ n + a ^ n ≤ a ^ n * a := by
-      rw [← mul_two]
-      exact Nat.mul_le_mul_left _ a1
-    simp [pow_succ']
-    refine' lt_of_lt_of_le _ this
+    have : a ^ n + a ^ n ≤ a ^ n * a := by rw [← mul_two]; exact Nat.mul_le_mul_left _ a1
+    simp [pow_succ']; refine' lt_of_lt_of_le _ this
     exact add_lt_add_of_lt_of_le IH (lt_of_le_of_lt (Nat.zero_le _) IH)
 #align pell.n_lt_a_pow Pell.n_lt_a_pow
 -/
@@ -484,10 +481,8 @@ theorem pellZd_sub {m n} (h : n ≤ m) : pell_zd (m - n) = pell_zd m * star (pel
 -/
 
 #print Pell.xz_sub /-
-theorem xz_sub {m n} (h : n ≤ m) : xz (m - n) = xz m * xz n - d * yz m * yz n :=
-  by
-  rw [sub_eq_add_neg, ← mul_neg]
-  exact congr_arg Zsqrtd.re (pell_zd_sub a1 h)
+theorem xz_sub {m n} (h : n ≤ m) : xz (m - n) = xz m * xz n - d * yz m * yz n := by
+  rw [sub_eq_add_neg, ← mul_neg]; exact congr_arg Zsqrtd.re (pell_zd_sub a1 h)
 #align pell.xz_sub Pell.xz_sub
 -/
 
@@ -596,10 +591,7 @@ theorem xy_modEq_yn (n) :
     have R :
       xn (n * k) * yn n + yn (n * k) * xn n ≡ xn n ^ k * yn n + k * xn n ^ k * yn n [MOD
         yn n ^ 3] :=
-      ModEq.add
-          (by
-            rw [pow_succ']
-            exact hx.mul_right' _) <|
+      ModEq.add (by rw [pow_succ']; exact hx.mul_right' _) <|
         by
         have : k * xn n ^ (k - 1) * yn n * xn n = k * xn n ^ k * yn n := by
           clear _let_match <;> cases' k with k <;> simp [pow_succ', mul_comm, mul_left_comm]
@@ -640,13 +632,8 @@ theorem pellZd_succ_succ (n) : pell_zd (n + 2) + pell_zd n = (2 * a : ℕ) * pel
   by
   have : (1 : ℤ√d) + ⟨a, 1⟩ * ⟨a, 1⟩ = ⟨a, 1⟩ * (2 * a) :=
     by
-    rw [Zsqrtd.coe_nat_val]
-    change (⟨_, _⟩ : ℤ√d a1) = ⟨_, _⟩
-    rw [dz_val]
-    dsimp [az]
-    rw [Zsqrtd.ext]
-    dsimp
-    constructor <;> ring
+    rw [Zsqrtd.coe_nat_val]; change (⟨_, _⟩ : ℤ√d a1) = ⟨_, _⟩
+    rw [dz_val]; dsimp [az]; rw [Zsqrtd.ext]; dsimp; constructor <;> ring
   simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (· * pell_zd a1 n) this
 #align pell.pell_zd_succ_succ Pell.pellZd_succ_succ
 -/
@@ -857,10 +844,8 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
       by
       let k2nl :=
         lt_of_add_lt_add_right <|
-          show 2 * n - k + k < n + k by
-            rw [tsub_add_cancel_of_le]
-            rw [two_mul] <;> exact add_lt_add_left kn n
-            exact k2n
+          show 2 * n - k + k < n + k by rw [tsub_add_cancel_of_le];
+            rw [two_mul] <;> exact add_lt_add_left kn n; exact k2n
       have xle : xn (2 * n - k) ≤ xn n := le_of_lt <| strict_mono_x k2nl
       suffices xn k % xn n = xn n - xn (2 * n - k) by rw [this, Int.ofNat_sub xle]
       rw [← Nat.mod_eq_of_lt (Nat.sub_lt (x_pos a1 n) (x_pos a1 (2 * n - k)))]
@@ -888,10 +873,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
                 xn_succ]
               exact le_trans (Nat.mul_le_mul_left _ a1) (Nat.le_add_right _ _)
             have npm : (n - 1).succ = n := Nat.succ_pred_eq_of_pos npos
-            have il : i ≤ n - 1 := by
-              apply Nat.le_of_succ_le_succ
-              rw [npm]
-              exact lin
+            have il : i ≤ n - 1 := by apply Nat.le_of_succ_le_succ; rw [npm]; exact lin
             cases' lt_or_eq_of_le il with ill ile
             · exact lt_of_lt_of_le (Nat.add_lt_add_left (strict_mono_x a1 ill) _) ll
             · rw [ile]
@@ -938,8 +920,7 @@ theorem eq_of_xn_modEq_le {i j n} (ij : i ≤ j) (j2n : j ≤ 2 * n) (h : xn i 
         rw [jn, Nat.mod_self]
         have x0 : 0 < xn a1 0 % xn a1 n := by
           rw [Nat.mod_eq_of_lt (strict_mono_x a1 (Nat.pos_of_ne_zero npos))] <;> exact by decide
-        cases' i with i
-        exact x0
+        cases' i with i; exact x0
         rw [jn] at ij'
         exact
           x0.trans
@@ -1000,14 +981,9 @@ theorem modEq_of_xn_modEq {i j n} (ipos : 0 < i) (hin : i ≤ n) (h : xn j ≡ x
     rw [Nat.mul_succ, ← add_assoc, add_comm]
     exact (xn_modeq_x4n_add _ _ _).trans IH
   Or.imp (fun ji : j' = i => by rwa [← ji])
-    (fun ji : j' + i = 4 * n =>
-      (jj.add_right _).trans <| by
-        rw [ji]
-        exact dvd_rfl.modeq_zero_nat)
+    (fun ji : j' + i = 4 * n => (jj.add_right _).trans <| by rw [ji]; exact dvd_rfl.modeq_zero_nat)
     (eq_of_xn_modeq' ipos hin jl.le <|
-      (h.symm.trans <| by
-          rw [← Nat.mod_add_div j (4 * n)]
-          exact this j' _).symm)
+      (h.symm.trans <| by rw [← Nat.mod_add_div j (4 * n)]; exact this j' _).symm)
 #align pell.modeq_of_xn_modeq Pell.modEq_of_xn_modEq
 -/
 
@@ -1019,13 +995,9 @@ theorem xy_modEq_of_modEq {a b c} (a1 : 1 < a) (b1 : 1 < b) (h : a ≡ b [MOD c]
   | 0 => by constructor <;> rfl
   | 1 => by simp <;> exact ⟨h, modeq.refl 1⟩
   | n + 2 =>
-    ⟨(xy_modeq_of_modeq n).left.add_right_cancel <|
-        by
-        rw [xn_succ_succ a1, xn_succ_succ b1]
+    ⟨(xy_modeq_of_modeq n).left.add_right_cancel <| by rw [xn_succ_succ a1, xn_succ_succ b1];
         exact (h.mul_left _).mul (xy_modeq_of_modeq (n + 1)).left,
-      (xy_modeq_of_modeq n).right.add_right_cancel <|
-        by
-        rw [yn_succ_succ a1, yn_succ_succ b1]
+      (xy_modeq_of_modeq n).right.add_right_cancel <| by rw [yn_succ_succ a1, yn_succ_succ b1];
         exact (h.mul_left _).mul (xy_modeq_of_modeq (n + 1)).right⟩
 #align pell.xy_modeq_of_modeq Pell.xy_modEq_of_modEq
 -/
@@ -1173,8 +1145,7 @@ theorem eq_pow_of_pell {m n k} :
     set a := xn w1 w
     have a1 : 1 < a := strict_mono_x w1 wpos
     have na : n ≤ a := nw.trans (n_lt_xn w1 w).le
-    set x := xn a1 k
-    set y := yn a1 k
+    set x := xn a1 k; set y := yn a1 k
     obtain ⟨z, ze⟩ : w ∣ yn w1 w
     exact modeq_zero_iff_dvd.1 ((yn_modeq_a_sub_one w1 w).trans dvd_rfl.modeq_zero_nat)
     have nt : (↑(n ^ k) : ℤ) < 2 * a * n - n * n - 1 :=
@@ -1199,8 +1170,7 @@ theorem eq_pow_of_pell {m n k} :
     have zp : a * a - ((w + 1) * (w + 1) - 1) * (w * z) * (w * z) = 1 := ze ▸ pell_eq w1 w
     exact ⟨w, a, t, z, a1, tm, ta, Nat.cast_lt.1 nt, nw, kw, zp⟩
   · rintro (⟨rfl, rfl⟩ | ⟨hk0, ⟨rfl, rfl⟩ | ⟨hn0, w, a, t, z, a1, tm, ta, mt, nw, kw, zp⟩⟩)
-    · exact pow_zero n
-    · exact zero_pow hk0
+    · exact pow_zero n; · exact zero_pow hk0
     have hw0 : 0 < w := hn0.trans_le nw
     have hw1 : 1 < w + 1 := Nat.succ_lt_succ hw0
     rcases eq_pell hw1 zp with ⟨j, rfl, yj⟩
Diff
@@ -111,7 +111,6 @@ include a1
 
 private def d :=
   a * a - 1
-#align pell.d pell.d
 
 #print Pell.d_pos /-
 @[simp]
Diff
@@ -659,7 +659,7 @@ theorem xy_succ_succ (n) :
   have := pell_zd_succ_succ a1 n; unfold pell_zd at this
   erw [Zsqrtd.smul_val (2 * a : ℕ)] at this
   injection this with h₁ h₂
-  constructor <;> apply Int.ofNat.inj <;> [simpa using h₁, simpa using h₂]
+  constructor <;> apply Int.ofNat.inj <;> [simpa using h₁;simpa using h₂]
 #align pell.xy_succ_succ Pell.xy_succ_succ
 -/
 
@@ -1186,7 +1186,7 @@ theorem eq_pow_of_pell {m n k} :
         _ < (w + 1) ^ w := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) wpos)
         _ ≤ a := xn_ge_a_pow w1 w
         
-    lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le
+    lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le with t te
     have tm : x ≡ y * (a - n) + n ^ k [MOD t] :=
       by
       apply modeq_of_dvd
Diff
@@ -1186,7 +1186,7 @@ theorem eq_pow_of_pell {m n k} :
         _ < (w + 1) ^ w := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) wpos)
         _ ≤ a := xn_ge_a_pow w1 w
         
-    lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le with t te
+    lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le
     have tm : x ≡ y * (a - n) + n ^ k [MOD t] :=
       by
       apply modeq_of_dvd
Diff
@@ -83,7 +83,7 @@ theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
 lean 3 declaration is
   forall {d : Int} {b : Zsqrtd d}, Iff (Pell.IsPell d b) (Membership.Mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (SetLike.hasMem.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (Zsqrtd d) (Submonoid.setLike.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d)))) b (unitary.{0} (Zsqrtd d) (Zsqrtd.monoid d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.starRing d))))
 but is expected to have type
-  forall {d : Int} {b : Zsqrtd d}, Iff (Pell.IsPell d b) (Membership.mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (SetLike.instMembership.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (Zsqrtd d) (Submonoid.instSetLikeSubmonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d)))) b (unitary.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.instStarRingZsqrtdToNonUnitalSemiringToNonUnitalRingToNonUnitalCommRingCommRing d))))
+  forall {d : Int} {b : Zsqrtd d}, Iff (Pell.IsPell d b) (Membership.mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (SetLike.instMembership.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (Zsqrtd d) (Submonoid.instSetLikeSubmonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d)))) b (unitary.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalCommSemiring.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalCommSemiring.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.instStarRingZsqrtdToNonUnitalSemiringToNonUnitalCommSemiringToNonUnitalCommRingCommRing d))))
 Case conversion may be inaccurate. Consider using '#align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitaryₓ'. -/
 theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d)
   | ⟨x, y⟩ => by rw [unitary.mem_iff, is_pell_norm, mul_comm (star _), and_self_iff]
Diff
@@ -369,7 +369,7 @@ theorem x_pos (n) : 0 < xn n :=
 
 /- warning: pell.eq_pell_lem -> Pell.eq_pell_lem is a dubious translation:
 lean 3 declaration is
-  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (n : Nat) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasLe (_Private.2026277129.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)) b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasLe (_Private.2026277129.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) b (Pell.pellZd a a1 n)))
+  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (n : Nat) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasLe (_Private.3555558319.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)) b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasLe (_Private.3555558319.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) b (Pell.pellZd a a1 n)))
 but is expected to have type
   forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (n : Nat) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
 Case conversion may be inaccurate. Consider using '#align pell.eq_pell_lem Pell.eq_pell_lemₓ'. -/
@@ -422,7 +422,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
 
 /- warning: pell.eq_pell_zd -> Pell.eq_pellZd is a dubious translation:
 lean 3 declaration is
-  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasLe (_Private.2026277129.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) b (Pell.pellZd a a1 n)))
+  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasLe (_Private.3555558319.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.3555558319.d a a1))) b (Pell.pellZd a a1 n)))
 but is expected to have type
   forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
 Case conversion may be inaccurate. Consider using '#align pell.eq_pell_zd Pell.eq_pellZdₓ'. -/
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 
 ! This file was ported from Lean 3 source module number_theory.pell_matiyasevic
-! leanprover-community/mathlib commit 795b501869b9fa7aa716d5fdadd00c03f983a605
+! leanprover-community/mathlib commit ce38d86c0b2d427ce208c3cee3159cb421d2b3c4
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -15,6 +15,9 @@ import Mathbin.NumberTheory.Zsqrtd.Basic
 /-!
 # Pell's equation and Matiyasevic's theorem
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 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
@@ -366,7 +369,7 @@ theorem x_pos (n) : 0 < xn n :=
 
 /- warning: pell.eq_pell_lem -> Pell.eq_pell_lem is a dubious translation:
 lean 3 declaration is
-  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (n : Nat) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasLe (_Private.563560731.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)) b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasLe (_Private.563560731.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) b (Pell.pellZd a a1 n)))
+  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (n : Nat) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasLe (_Private.2026277129.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)) b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasLe (_Private.2026277129.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) b (Pell.pellZd a a1 n)))
 but is expected to have type
   forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (n : Nat) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
 Case conversion may be inaccurate. Consider using '#align pell.eq_pell_lem Pell.eq_pell_lemₓ'. -/
@@ -419,7 +422,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
 
 /- warning: pell.eq_pell_zd -> Pell.eq_pellZd is a dubious translation:
 lean 3 declaration is
-  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasLe (_Private.563560731.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) b (Pell.pellZd a a1 n)))
+  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasLe (_Private.2026277129.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.2026277129.d a a1))) b (Pell.pellZd a a1 n)))
 but is expected to have type
   forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
 Case conversion may be inaccurate. Consider using '#align pell.eq_pell_zd Pell.eq_pellZdₓ'. -/
Diff
@@ -62,27 +62,41 @@ section
 
 variable {d : ℤ}
 
+#print Pell.IsPell /-
 /-- The property of being a solution to the Pell equation, expressed
   as a property of elements of `ℤ√d`. -/
 def IsPell : ℤ√d → Prop
   | ⟨x, y⟩ => x * x - d * y * y = 1
 #align pell.is_pell Pell.IsPell
+-/
 
+#print Pell.isPell_norm /-
 theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
   | ⟨x, y⟩ => by simp [Zsqrtd.ext, is_pell, mul_comm] <;> ring_nf
 #align pell.is_pell_norm Pell.isPell_norm
+-/
 
+/- warning: pell.is_pell_iff_mem_unitary -> Pell.isPell_iff_mem_unitary is a dubious translation:
+lean 3 declaration is
+  forall {d : Int} {b : Zsqrtd d}, Iff (Pell.IsPell d b) (Membership.Mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (SetLike.hasMem.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d))) (Zsqrtd d) (Submonoid.setLike.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.monoid d)))) b (unitary.{0} (Zsqrtd d) (Zsqrtd.monoid d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.starRing d))))
+but is expected to have type
+  forall {d : Int} {b : Zsqrtd d}, Iff (Pell.IsPell d b) (Membership.mem.{0, 0} (Zsqrtd d) (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (SetLike.instMembership.{0, 0} (Submonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d))) (Zsqrtd d) (Submonoid.instSetLikeSubmonoid.{0} (Zsqrtd d) (Monoid.toMulOneClass.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d)))) b (unitary.{0} (Zsqrtd d) (Zsqrtd.instMonoidZsqrtd d) (StarRing.toStarSemigroup.{0} (Zsqrtd d) (NonUnitalRing.toNonUnitalSemiring.{0} (Zsqrtd d) (NonUnitalCommRing.toNonUnitalRing.{0} (Zsqrtd d) (CommRing.toNonUnitalCommRing.{0} (Zsqrtd d) (Zsqrtd.commRing d)))) (Zsqrtd.instStarRingZsqrtdToNonUnitalSemiringToNonUnitalRingToNonUnitalCommRingCommRing d))))
+Case conversion may be inaccurate. Consider using '#align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitaryₓ'. -/
 theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d)
   | ⟨x, y⟩ => by rw [unitary.mem_iff, is_pell_norm, mul_comm (star _), and_self_iff]
 #align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary
 
+#print Pell.isPell_mul /-
 theorem isPell_mul {b c : ℤ√d} (hb : IsPell b) (hc : IsPell c) : IsPell (b * c) :=
   isPell_norm.2 (by simp [mul_comm, mul_left_comm, star_mul, is_pell_norm.1 hb, is_pell_norm.1 hc])
 #align pell.is_pell_mul Pell.isPell_mul
+-/
 
+#print Pell.isPell_star /-
 theorem isPell_star : ∀ {b : ℤ√d}, IsPell b ↔ IsPell (star b)
   | ⟨x, y⟩ => by simp [is_pell, Zsqrtd.star_mk]
 #align pell.is_pell_star Pell.isPell_star
+-/
 
 end
 
@@ -96,11 +110,14 @@ private def d :=
   a * a - 1
 #align pell.d pell.d
 
+#print Pell.d_pos /-
 @[simp]
 theorem d_pos : 0 < d :=
   tsub_pos_of_lt (mul_lt_mul a1 (le_of_lt a1) (by decide) (by decide) : 1 * 1 < a * a)
 #align pell.d_pos Pell.d_pos
+-/
 
+#print Pell.pell /-
 -- TODO(lint): Fix double namespace issue
 /-- 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. -/
@@ -108,108 +125,148 @@ theorem d_pos : 0 < d :=
 def pell : ℕ → ℕ × ℕ := fun n =>
   Nat.recOn n (1, 0) fun n xy => (xy.1 * a + d * xy.2, xy.1 + xy.2 * a)
 #align pell.pell Pell.pell
+-/
 
+#print Pell.xn /-
 /-- The Pell `x` sequence. -/
 def xn (n : ℕ) : ℕ :=
   (pell n).1
 #align pell.xn Pell.xn
+-/
 
+#print Pell.yn /-
 /-- The Pell `y` sequence. -/
 def yn (n : ℕ) : ℕ :=
   (pell n).2
 #align pell.yn Pell.yn
+-/
 
+#print Pell.pell_val /-
 @[simp]
 theorem pell_val (n : ℕ) : pell n = (xn n, yn n) :=
   show pell n = ((pell n).1, (pell n).2) from
     match pell n with
     | (a, b) => rfl
 #align pell.pell_val Pell.pell_val
+-/
 
+#print Pell.xn_zero /-
 @[simp]
 theorem xn_zero : xn 0 = 1 :=
   rfl
 #align pell.xn_zero Pell.xn_zero
+-/
 
+#print Pell.yn_zero /-
 @[simp]
 theorem yn_zero : yn 0 = 0 :=
   rfl
 #align pell.yn_zero Pell.yn_zero
+-/
 
+#print Pell.xn_succ /-
 @[simp]
 theorem xn_succ (n : ℕ) : xn (n + 1) = xn n * a + d * yn n :=
   rfl
 #align pell.xn_succ Pell.xn_succ
+-/
 
+#print Pell.yn_succ /-
 @[simp]
 theorem yn_succ (n : ℕ) : yn (n + 1) = xn n + yn n * a :=
   rfl
 #align pell.yn_succ Pell.yn_succ
+-/
 
+#print Pell.xn_one /-
 @[simp]
 theorem xn_one : xn 1 = a := by simp
 #align pell.xn_one Pell.xn_one
+-/
 
+#print Pell.yn_one /-
 @[simp]
 theorem yn_one : yn 1 = 1 := by simp
 #align pell.yn_one Pell.yn_one
+-/
 
+#print Pell.xz /-
 /-- The Pell `x` sequence, considered as an integer sequence.-/
 def xz (n : ℕ) : ℤ :=
   xn n
 #align pell.xz Pell.xz
+-/
 
+#print Pell.yz /-
 /-- The Pell `y` sequence, considered as an integer sequence.-/
 def yz (n : ℕ) : ℤ :=
   yn n
 #align pell.yz Pell.yz
+-/
 
 section
 
 omit a1
 
+#print Pell.az /-
 /-- The element `a` such that `d = a ^ 2 - 1`, considered as an integer.-/
 def az : ℤ :=
   a
 #align pell.az Pell.az
+-/
 
 end
 
+#print Pell.asq_pos /-
 theorem asq_pos : 0 < a * a :=
   le_trans (le_of_lt a1)
     (by have := @Nat.mul_le_mul_left 1 a a (le_of_lt a1) <;> rwa [mul_one] at this)
 #align pell.asq_pos Pell.asq_pos
+-/
 
+#print Pell.dz_val /-
 theorem dz_val : ↑d = az * az - 1 :=
   have : 1 ≤ a * a := asq_pos
   show ↑(a * a - 1) = _ by rw [Int.ofNat_sub this] <;> rfl
 #align pell.dz_val Pell.dz_val
+-/
 
+#print Pell.xz_succ /-
 @[simp]
 theorem xz_succ (n : ℕ) : xz (n + 1) = xz n * az + ↑d * yz n :=
   rfl
 #align pell.xz_succ Pell.xz_succ
+-/
 
+#print Pell.yz_succ /-
 @[simp]
 theorem yz_succ (n : ℕ) : yz (n + 1) = xz n + yz n * az :=
   rfl
 #align pell.yz_succ Pell.yz_succ
+-/
 
+#print Pell.pellZd /-
 /-- The Pell sequence can also be viewed as an element of `ℤ√d` -/
 def pellZd (n : ℕ) : ℤ√d :=
   ⟨xn n, yn n⟩
 #align pell.pell_zd Pell.pellZd
+-/
 
+#print Pell.pellZd_re /-
 @[simp]
 theorem pellZd_re (n : ℕ) : (pell_zd n).re = xn n :=
   rfl
 #align pell.pell_zd_re Pell.pellZd_re
+-/
 
+#print Pell.pellZd_im /-
 @[simp]
 theorem pellZd_im (n : ℕ) : (pell_zd n).im = yn n :=
   rfl
 #align pell.pell_zd_im Pell.pellZd_im
+-/
 
+#print Pell.isPell_nat /-
 theorem isPell_nat {x y : ℕ} : IsPell (⟨x, y⟩ : ℤ√d) ↔ x * x - d * y * y = 1 :=
   ⟨fun h =>
     Int.ofNat.inj
@@ -218,27 +275,37 @@ theorem isPell_nat {x y : ℕ} : IsPell (⟨x, y⟩ : ℤ√d) ↔ x * x - d * y
     show ((x * x : ℕ) - (d * y * y : ℕ) : ℤ) = 1 by
       rw [← Int.ofNat_sub <| le_of_lt <| Nat.lt_of_sub_eq_succ h, h] <;> rfl⟩
 #align pell.is_pell_nat Pell.isPell_nat
+-/
 
+#print Pell.pellZd_succ /-
 @[simp]
 theorem pellZd_succ (n : ℕ) : pell_zd (n + 1) = pell_zd n * ⟨a, 1⟩ := by simp [Zsqrtd.ext]
 #align pell.pell_zd_succ Pell.pellZd_succ
+-/
 
+#print Pell.isPell_one /-
 theorem isPell_one : IsPell (⟨a, 1⟩ : ℤ√d) :=
   show az * az - d * 1 * 1 = 1 by simp [dz_val] <;> ring
 #align pell.is_pell_one Pell.isPell_one
+-/
 
+#print Pell.isPell_pellZd /-
 theorem isPell_pellZd : ∀ n : ℕ, IsPell (pell_zd n)
   | 0 => rfl
   | n + 1 => by
     let o := is_pell_one
     simp <;> exact Pell.isPell_mul (is_pell_pell_zd n) o
 #align pell.is_pell_pell_zd Pell.isPell_pellZd
+-/
 
+#print Pell.pell_eqz /-
 @[simp]
 theorem pell_eqz (n : ℕ) : xz n * xz n - d * yz n * yz n = 1 :=
   is_pell_pell_zd n
 #align pell.pell_eqz Pell.pell_eqz
+-/
 
+#print Pell.pell_eq /-
 @[simp]
 theorem pell_eq (n : ℕ) : xn n * xn n - d * yn n * yn n = 1 :=
   let pn := pell_eqz n
@@ -248,7 +315,9 @@ theorem pell_eq (n : ℕ) : xn n * xn n - d * yn n * yn n = 1 :=
     Int.le_of_ofNat_le_ofNat <| Int.le.intro <| add_eq_of_eq_sub' <| Eq.symm h
   Int.ofNat.inj (by rw [Int.ofNat_sub hl] <;> exact h)
 #align pell.pell_eq Pell.pell_eq
+-/
 
+#print Pell.dnsq /-
 instance dnsq : Zsqrtd.Nonsquare d :=
   ⟨fun n h =>
     have : n * n + 1 = a * a := by rw [← h] <;> exact Nat.succ_pred_eq_of_pos (asq_pos a1)
@@ -258,14 +327,18 @@ instance dnsq : Zsqrtd.Nonsquare d :=
       @Nat.le_of_add_le_add_right (n * n + 1) _ _ (by ring_nf  at this⊢ <;> assumption)
     ne_of_gt d_pos <| by rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h⟩
 #align pell.dnsq Pell.dnsq
+-/
 
+#print Pell.xn_ge_a_pow /-
 theorem xn_ge_a_pow : ∀ n : ℕ, a ^ n ≤ xn n
   | 0 => le_refl 1
   | n + 1 => by
     simp [pow_succ'] <;>
       exact le_trans (Nat.mul_le_mul_right _ (xn_ge_a_pow n)) (Nat.le_add_right _ _)
 #align pell.xn_ge_a_pow Pell.xn_ge_a_pow
+-/
 
+#print Pell.n_lt_a_pow /-
 theorem n_lt_a_pow : ∀ n : ℕ, n < a ^ n
   | 0 => Nat.le_refl 1
   | n + 1 => by
@@ -277,15 +350,26 @@ theorem n_lt_a_pow : ∀ n : ℕ, n < a ^ n
     refine' lt_of_lt_of_le _ this
     exact add_lt_add_of_lt_of_le IH (lt_of_le_of_lt (Nat.zero_le _) IH)
 #align pell.n_lt_a_pow Pell.n_lt_a_pow
+-/
 
+#print Pell.n_lt_xn /-
 theorem n_lt_xn (n) : n < xn n :=
   lt_of_lt_of_le (n_lt_a_pow n) (xn_ge_a_pow n)
 #align pell.n_lt_xn Pell.n_lt_xn
+-/
 
+#print Pell.x_pos /-
 theorem x_pos (n) : 0 < xn n :=
   lt_of_le_of_lt (Nat.zero_le n) (n_lt_xn n)
 #align pell.x_pos Pell.x_pos
+-/
 
+/- warning: pell.eq_pell_lem -> Pell.eq_pell_lem is a dubious translation:
+lean 3 declaration is
+  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (n : Nat) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasLe (_Private.563560731.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)) b) -> (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasLe (_Private.563560731.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) b (Pell.pellZd a a1 n)))
+but is expected to have type
+  forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (n : Nat) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b (Pell.pellZd a a1 n)) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
+Case conversion may be inaccurate. Consider using '#align pell.eq_pell_lem Pell.eq_pell_lemₓ'. -/
 theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell_zd n → ∃ n, b = pell_zd n
   | 0, b => fun h1 hp hl => ⟨0, @Zsqrtd.le_antisymm _ dnsq _ _ hl h1⟩
   | n + 1, b => fun h1 hp h =>
@@ -333,6 +417,12 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell
               | -[y+1], y0l, yl2 => y0l trivial
 #align pell.eq_pell_lem Pell.eq_pell_lem
 
+/- warning: pell.eq_pell_zd -> Pell.eq_pellZd is a dubious translation:
+lean 3 declaration is
+  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (b : Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))), (LE.le.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasLe (_Private.563560731.d a a1)) (OfNat.ofNat.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (OfNat.mk.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) 1 (One.one.{0} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) (Zsqrtd.hasOne ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)))))) b) -> (Pell.IsPell ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (_Private.563560731.d a a1))) b (Pell.pellZd a a1 n)))
+but is expected to have type
+  forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (b : Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))), (LE.le.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instLEZsqrtdCastIntInstNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) (OfNat.ofNat.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) 1 (One.toOfNat1.{0} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) (Zsqrtd.instOneZsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))))) b) -> (Pell.IsPell (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1)) b) -> (Exists.{1} Nat (fun (n : Nat) => Eq.{1} (Zsqrtd (Nat.cast.{0} Int instNatCastInt (_private.Mathlib.NumberTheory.PellMatiyasevic.0.Pell.d a a1))) b (Pell.pellZd a a1 n)))
+Case conversion may be inaccurate. Consider using '#align pell.eq_pell_zd Pell.eq_pellZdₓ'. -/
 theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell_zd n :=
   let ⟨n, h⟩ := @Zsqrtd.le_arch d b
   eq_pell_lem n b b1 hp <|
@@ -343,6 +433,7 @@ theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell
             (Int.ofNat_zero_le _)
 #align pell.eq_pell_zd Pell.eq_pellZd
 
+#print Pell.eq_pell /-
 /-- Every solution to **Pell's equation** is recursively obtained from the initial solution
 `(1,0)` using the recursion `pell`. -/
 theorem eq_pell {x y : ℕ} (hp : x * x - d * y * y = 1) : ∃ n, x = xn n ∧ y = yn n :=
@@ -356,50 +447,66 @@ theorem eq_pell {x y : ℕ} (hp : x * x - d * y * y = 1) : ∃ n, x = xn n ∧ y
     match x, y, e with
     | _, _, rfl => ⟨rfl, rfl⟩⟩
 #align pell.eq_pell Pell.eq_pell
+-/
 
+#print Pell.pellZd_add /-
 theorem pellZd_add (m) : ∀ n, pell_zd (m + n) = pell_zd m * pell_zd n
   | 0 => (mul_one _).symm
   | n + 1 => by rw [← add_assoc, pell_zd_succ, pell_zd_succ, pell_zd_add n, ← mul_assoc]
 #align pell.pell_zd_add Pell.pellZd_add
+-/
 
+#print Pell.xn_add /-
 theorem xn_add (m n) : xn (m + n) = xn m * xn n + d * yn m * yn n := by
   injection pell_zd_add _ m n with h _ <;>
       repeat' first |rw [← Int.ofNat_add] at h|rw [← Int.ofNat_mul] at h <;>
     exact Int.ofNat.inj h
 #align pell.xn_add Pell.xn_add
+-/
 
+#print Pell.yn_add /-
 theorem yn_add (m n) : yn (m + n) = xn m * yn n + yn m * xn n := by
   injection pell_zd_add _ m n with _ h <;>
       repeat' first |rw [← Int.ofNat_add] at h|rw [← Int.ofNat_mul] at h <;>
     exact Int.ofNat.inj h
 #align pell.yn_add Pell.yn_add
+-/
 
+#print Pell.pellZd_sub /-
 theorem pellZd_sub {m n} (h : n ≤ m) : pell_zd (m - n) = pell_zd m * star (pell_zd n) :=
   by
   let t := pell_zd_add n (m - n)
   rw [add_tsub_cancel_of_le h] at t <;>
     rw [t, mul_comm (pell_zd _ n) _, mul_assoc, is_pell_norm.1 (is_pell_pell_zd _ _), mul_one]
 #align pell.pell_zd_sub Pell.pellZd_sub
+-/
 
+#print Pell.xz_sub /-
 theorem xz_sub {m n} (h : n ≤ m) : xz (m - n) = xz m * xz n - d * yz m * yz n :=
   by
   rw [sub_eq_add_neg, ← mul_neg]
   exact congr_arg Zsqrtd.re (pell_zd_sub a1 h)
 #align pell.xz_sub Pell.xz_sub
+-/
 
+#print Pell.yz_sub /-
 theorem yz_sub {m n} (h : n ≤ m) : yz (m - n) = xz n * yz m - xz m * yz n :=
   by
   rw [sub_eq_add_neg, ← mul_neg, mul_comm, add_comm]
   exact congr_arg Zsqrtd.im (pell_zd_sub a1 h)
 #align pell.yz_sub Pell.yz_sub
+-/
 
+#print Pell.xy_coprime /-
 theorem xy_coprime (n) : (xn n).coprime (yn n) :=
   Nat.coprime_of_dvd' fun k kp kx ky => by
     let p := pell_eq n
     rw [← p] <;>
       exact Nat.dvd_sub (le_of_lt <| Nat.lt_of_sub_eq_succ p) (kx.mul_left _) (ky.mul_left _)
 #align pell.xy_coprime Pell.xy_coprime
+-/
 
+#print Pell.strictMono_y /-
 theorem strictMono_y : StrictMono yn
   | m, 0, h => absurd h <| Nat.not_lt_zero _
   | m, n + 1, h =>
@@ -411,7 +518,9 @@ theorem strictMono_y : StrictMono yn
         rw [← mul_one (yn a1 m)] <;>
       exact mul_le_mul this (le_of_lt a1) (Nat.zero_le _) (Nat.zero_le _)
 #align pell.strict_mono_y Pell.strictMono_y
+-/
 
+#print Pell.strictMono_x /-
 theorem strictMono_x : StrictMono xn
   | m, 0, h => absurd h <| Nat.not_lt_zero _
   | m, n + 1, h =>
@@ -423,19 +532,25 @@ theorem strictMono_x : StrictMono xn
         have t := Nat.mul_lt_mul_of_pos_left a1 (x_pos a1 n) <;>
       rwa [mul_one] at t
 #align pell.strict_mono_x Pell.strictMono_x
+-/
 
+#print Pell.yn_ge_n /-
 theorem yn_ge_n : ∀ n, n ≤ yn n
   | 0 => Nat.zero_le _
   | n + 1 =>
     show n < yn (n + 1) from lt_of_le_of_lt (yn_ge_n n) (strict_mono_y <| Nat.lt_succ_self n)
 #align pell.yn_ge_n Pell.yn_ge_n
+-/
 
+#print Pell.y_mul_dvd /-
 theorem y_mul_dvd (n) : ∀ k, yn n ∣ yn (n * k)
   | 0 => dvd_zero _
   | k + 1 => by
     rw [Nat.mul_succ, yn_add] <;> exact dvd_add (dvd_mul_left _ _) ((y_mul_dvd k).mul_right _)
 #align pell.y_mul_dvd Pell.y_mul_dvd
+-/
 
+#print Pell.y_dvd_iff /-
 theorem y_dvd_iff (m n) : yn m ∣ yn n ↔ m ∣ n :=
   ⟨fun h =>
     Nat.dvd_of_mod_eq_zero <|
@@ -455,7 +570,9 @@ theorem y_dvd_iff (m n) : yn m ∣ yn n ↔ m ∣ n :=
                   (Nat.dvd_add_iff_right <| (y_mul_dvd _ _ _).mul_left _).2 h),
     fun ⟨k, e⟩ => by rw [e] <;> apply y_mul_dvd⟩
 #align pell.y_dvd_iff Pell.y_dvd_iff
+-/
 
+#print Pell.xy_modEq_yn /-
 theorem xy_modEq_yn (n) :
     ∀ k,
       xn (n * k) ≡ xn n ^ k [MOD yn n ^ 2] ∧ yn (n * k) ≡ k * xn n ^ (k - 1) * yn n [MOD yn n ^ 3]
@@ -490,13 +607,17 @@ theorem xy_modEq_yn (n) :
       add_comm (k * xn _ n ^ k) (xn _ n ^ k), right_distrib]
     exact ⟨L, R⟩
 #align pell.xy_modeq_yn Pell.xy_modEq_yn
+-/
 
+#print Pell.ysq_dvd_yy /-
 theorem ysq_dvd_yy (n) : yn n * yn n ∣ yn (n * yn n) :=
   modEq_zero_iff_dvd.1 <|
     ((xy_modeq_yn n (yn n)).right.of_dvd <| by simp [pow_succ]).trans
       (modEq_zero_iff_dvd.2 <| by simp [mul_dvd_mul_left, mul_assoc])
 #align pell.ysq_dvd_yy Pell.ysq_dvd_yy
+-/
 
+#print Pell.dvd_of_ysq_dvd /-
 theorem dvd_of_ysq_dvd {n t} (h : yn n * yn n ∣ yn t) : yn n ∣ t :=
   have nt : n ∣ t := (y_dvd_iff n t).1 <| dvd_of_mul_left_dvd h
   n.eq_zero_or_pos.elim (fun n0 => by rwa [n0] at nt⊢) fun n0l : 0 < n =>
@@ -510,7 +631,9 @@ theorem dvd_of_ysq_dvd {n t} (h : yn n * yn n ∣ yn t) : yn n ∣ t :=
     rw [ke] <;>
       exact dvd_mul_of_dvd_right (((xy_coprime _ _).pow_leftₓ _).symm.dvd_of_dvd_mul_right this) _
 #align pell.dvd_of_ysq_dvd Pell.dvd_of_ysq_dvd
+-/
 
+#print Pell.pellZd_succ_succ /-
 theorem pellZd_succ_succ (n) : pell_zd (n + 2) + pell_zd n = (2 * a : ℕ) * pell_zd (n + 1) :=
   by
   have : (1 : ℤ√d) + ⟨a, 1⟩ * ⟨a, 1⟩ = ⟨a, 1⟩ * (2 * a) :=
@@ -524,7 +647,9 @@ theorem pellZd_succ_succ (n) : pell_zd (n + 2) + pell_zd n = (2 * a : ℕ) * pel
     constructor <;> ring
   simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (· * pell_zd a1 n) this
 #align pell.pell_zd_succ_succ Pell.pellZd_succ_succ
+-/
 
+#print Pell.xy_succ_succ /-
 theorem xy_succ_succ (n) :
     xn (n + 2) + xn n = 2 * a * xn (n + 1) ∧ yn (n + 2) + yn n = 2 * a * yn (n + 1) :=
   by
@@ -533,23 +658,33 @@ theorem xy_succ_succ (n) :
   injection this with h₁ h₂
   constructor <;> apply Int.ofNat.inj <;> [simpa using h₁, simpa using h₂]
 #align pell.xy_succ_succ Pell.xy_succ_succ
+-/
 
+#print Pell.xn_succ_succ /-
 theorem xn_succ_succ (n) : xn (n + 2) + xn n = 2 * a * xn (n + 1) :=
   (xy_succ_succ n).1
 #align pell.xn_succ_succ Pell.xn_succ_succ
+-/
 
+#print Pell.yn_succ_succ /-
 theorem yn_succ_succ (n) : yn (n + 2) + yn n = 2 * a * yn (n + 1) :=
   (xy_succ_succ n).2
 #align pell.yn_succ_succ Pell.yn_succ_succ
+-/
 
+#print Pell.xz_succ_succ /-
 theorem xz_succ_succ (n) : xz (n + 2) = (2 * a : ℕ) * xz (n + 1) - xz n :=
   eq_sub_of_add_eq <| by delta xz <;> rw [← Int.ofNat_add, ← Int.ofNat_mul, xn_succ_succ]
 #align pell.xz_succ_succ Pell.xz_succ_succ
+-/
 
+#print Pell.yz_succ_succ /-
 theorem yz_succ_succ (n) : yz (n + 2) = (2 * a : ℕ) * yz (n + 1) - yz n :=
   eq_sub_of_add_eq <| by delta yz <;> rw [← Int.ofNat_add, ← Int.ofNat_mul, yn_succ_succ]
 #align pell.yz_succ_succ Pell.yz_succ_succ
+-/
 
+#print Pell.yn_modEq_a_sub_one /-
 theorem yn_modEq_a_sub_one : ∀ n, yn n ≡ n [MOD a - 1]
   | 0 => by simp
   | 1 => by simp
@@ -559,7 +694,9 @@ theorem yn_modEq_a_sub_one : ∀ n, yn n ≡ n [MOD a - 1]
       rw [yn_succ_succ, (by ring : n + 2 + n = 2 * (n + 1))]
       exact ((modeq_sub a1.le).mul_left 2).mul (yn_modeq_a_sub_one (n + 1))
 #align pell.yn_modeq_a_sub_one Pell.yn_modEq_a_sub_one
+-/
 
+#print Pell.yn_modEq_two /-
 theorem yn_modEq_two : ∀ n, yn n ≡ n [MOD 2]
   | 0 => by simp
   | 1 => by simp
@@ -569,19 +706,28 @@ theorem yn_modEq_two : ∀ n, yn n ≡ n [MOD 2]
       rw [yn_succ_succ, mul_assoc, (by ring : n + 2 + n = 2 * (n + 1))]
       exact (dvd_mul_right 2 _).modEq_zero_nat.trans (dvd_mul_right 2 _).zero_modEq_nat
 #align pell.yn_modeq_two Pell.yn_modEq_two
+-/
 
 section
 
 omit a1
 
+#print Pell.x_sub_y_dvd_pow_lem /-
 theorem x_sub_y_dvd_pow_lem (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) :=
   by ring
 #align pell.x_sub_y_dvd_pow_lem Pell.x_sub_y_dvd_pow_lem
+-/
 
 end
 
+/- warning: pell.x_sub_y_dvd_pow -> Pell.x_sub_y_dvd_pow is a dubious translation:
+lean 3 declaration is
+  forall {a : Nat} (a1 : LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) a) (y : Nat) (n : Nat), Dvd.Dvd.{0} Int (semigroupDvd.{0} Int Int.semigroup) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (OfNat.ofNat.{0} Int 2 (OfNat.mk.{0} Int 2 (bit0.{0} Int Int.hasAdd (One.one.{0} Int Int.hasOne)))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) a)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y))) (OfNat.ofNat.{0} Int 1 (OfNat.mk.{0} Int 1 (One.one.{0} Int Int.hasOne)))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.hasAdd) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.hasMul) (Pell.yz a a1 n) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.hasSub) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) a) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) y))) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) Nat Int (HasLiftT.mk.{1, 1} Nat Int (CoeTCₓ.coe.{1, 1} Nat Int (coeBase.{1, 1} Nat Int Int.hasCoe))) (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat (Monoid.Pow.{0} Nat Nat.monoid)) y n))) (Pell.xz a a1 n))
+but is expected to have type
+  forall {a : Nat} (a1 : LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) a) (y : Nat) (n : Nat), Dvd.dvd.{0} Int Int.instDvdInt (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (OfNat.ofNat.{0} Int 2 (instOfNatInt 2)) (Nat.cast.{0} Int instNatCastInt a)) (Nat.cast.{0} Int instNatCastInt y)) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (Nat.cast.{0} Int instNatCastInt y) (Nat.cast.{0} Int instNatCastInt y))) (OfNat.ofNat.{0} Int 1 (instOfNatInt 1))) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (HAdd.hAdd.{0, 0, 0} Int Int Int (instHAdd.{0} Int Int.instAddInt) (HMul.hMul.{0, 0, 0} Int Int Int (instHMul.{0} Int Int.instMulInt) (Pell.yz a a1 n) (HSub.hSub.{0, 0, 0} Int Int Int (instHSub.{0} Int Int.instSubInt) (Nat.cast.{0} Int instNatCastInt a) (Nat.cast.{0} Int instNatCastInt y))) (Nat.cast.{0} Int instNatCastInt (HPow.hPow.{0, 0, 0} Nat Nat Nat (instHPow.{0, 0} Nat Nat instPowNat) y n))) (Pell.xz a a1 n))
+Case conversion may be inaccurate. Consider using '#align pell.x_sub_y_dvd_pow Pell.x_sub_y_dvd_powₓ'. -/
 theorem x_sub_y_dvd_pow (y : ℕ) :
     ∀ n, (2 * a * y - y * y - 1 : ℤ) ∣ yz n * (a - y) + ↑(y ^ n) - xz n
   | 0 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one]
@@ -598,7 +744,8 @@ theorem x_sub_y_dvd_pow (y : ℕ) :
     exact dvd_sub (dvd_add this <| (x_sub_y_dvd_pow (n + 1)).mul_left _) (x_sub_y_dvd_pow n)
 #align pell.x_sub_y_dvd_pow Pell.x_sub_y_dvd_pow
 
-theorem xn_modeq_x2n_add_lem (n j) : xn n ∣ d * yn n * (yn n * xn j) + xn j :=
+#print Pell.xn_modEq_x2n_add_lem /-
+theorem xn_modEq_x2n_add_lem (n j) : xn n ∣ d * yn n * (yn n * xn j) + xn j :=
   by
   have h1 : d * yn n * (yn n * xn j) + xn j = (d * yn n * yn n + 1) * xn j := by
     simp [add_mul, mul_assoc]
@@ -606,8 +753,10 @@ theorem xn_modeq_x2n_add_lem (n j) : xn n ∣ d * yn n * (yn n * xn j) + xn j :=
     apply Int.ofNat.inj <;> repeat' first |rw [Int.ofNat_add]|rw [Int.ofNat_mul] <;>
       exact add_eq_of_eq_sub' (Eq.symm <| pell_eqz _ _)
   rw [h2] at h1 <;> rw [h1, mul_assoc] <;> exact dvd_mul_right _ _
-#align pell.xn_modeq_x2n_add_lem Pell.xn_modeq_x2n_add_lem
+#align pell.xn_modeq_x2n_add_lem Pell.xn_modEq_x2n_add_lem
+-/
 
+#print Pell.xn_modEq_x2n_add /-
 theorem xn_modEq_x2n_add (n j) : xn (2 * n + j) + xn j ≡ 0 [MOD xn n] :=
   by
   rw [two_mul, add_assoc, xn_add, add_assoc, ← zero_add 0]
@@ -616,7 +765,9 @@ theorem xn_modEq_x2n_add (n j) : xn (2 * n + j) + xn j ≡ 0 [MOD xn n] :=
   exact
     ((dvd_mul_right _ _).mul_left _).modEq_zero_nat.add (xn_modeq_x2n_add_lem _ _ _).modEq_zero_nat
 #align pell.xn_modeq_x2n_add Pell.xn_modEq_x2n_add
+-/
 
+#print Pell.xn_modEq_x2n_sub_lem /-
 theorem xn_modEq_x2n_sub_lem {n j} (h : j ≤ n) : xn (2 * n - j) + xn j ≡ 0 [MOD xn n] :=
   by
   have h1 : xz n ∣ ↑d * yz n * yz (n - j) + xz j := by
@@ -633,7 +784,9 @@ theorem xn_modEq_x2n_sub_lem {n j} (h : j ≤ n) : xn (2 * n - j) + xn j ≡ 0 [
     (dvd_mul_right _ _).modEq_zero_nat.add
       (Int.coe_nat_dvd.1 <| by simpa [xz, yz] using h1).modEq_zero_nat
 #align pell.xn_modeq_x2n_sub_lem Pell.xn_modEq_x2n_sub_lem
+-/
 
+#print Pell.xn_modEq_x2n_sub /-
 theorem xn_modEq_x2n_sub {n j} (h : j ≤ 2 * n) : xn (2 * n - j) + xn j ≡ 0 [MOD xn n] :=
   (le_total j n).elim xn_modeq_x2n_sub_lem fun jn =>
     by
@@ -642,14 +795,18 @@ theorem xn_modEq_x2n_sub {n j} (h : j ≤ 2 * n) : xn (2 * n - j) + xn j ≡ 0 [
     let t := xn_modeq_x2n_sub_lem (Nat.le_of_add_le_add_right this)
     rwa [tsub_tsub_cancel_of_le h, add_comm] at t
 #align pell.xn_modeq_x2n_sub Pell.xn_modEq_x2n_sub
+-/
 
+#print Pell.xn_modEq_x4n_add /-
 theorem xn_modEq_x4n_add (n j) : xn (4 * n + j) ≡ xn j [MOD xn n] :=
   ModEq.add_right_cancel' (xn (2 * n + j)) <| by
     refine' @modeq.trans _ _ 0 _ _ (by rw [add_comm] <;> exact (xn_modeq_x2n_add _ _ _).symm) <;>
         rw [show 4 * n = 2 * n + 2 * n from right_distrib 2 2 n, add_assoc] <;>
       apply xn_modeq_x2n_add
 #align pell.xn_modeq_x4n_add Pell.xn_modEq_x4n_add
+-/
 
+#print Pell.xn_modEq_x4n_sub /-
 theorem xn_modEq_x4n_sub {n j} (h : j ≤ 2 * n) : xn (4 * n - j) ≡ xn j [MOD xn n] :=
   have h' : j ≤ 2 * n := le_trans h (by rw [Nat.succ_mul] <;> apply Nat.le_add_left)
   ModEq.add_right_cancel' (xn (2 * n - j)) <| by
@@ -657,8 +814,10 @@ theorem xn_modEq_x4n_sub {n j} (h : j ≤ 2 * n) : xn (4 * n - j) ≡ xn j [MOD
         rw [show 4 * n = 2 * n + 2 * n from right_distrib 2 2 n, add_tsub_assoc_of_le h'] <;>
       apply xn_modeq_x2n_add
 #align pell.xn_modeq_x4n_sub Pell.xn_modEq_x4n_sub
+-/
 
-theorem eq_of_xn_modeq_lem1 {i n} : ∀ {j}, i < j → j < n → xn i % xn n < xn j % xn n
+#print Pell.eq_of_xn_modEq_lem1 /-
+theorem eq_of_xn_modEq_lem1 {i n} : ∀ {j}, i < j → j < n → xn i % xn n < xn j % xn n
   | 0, ij, _ => absurd ij (Nat.not_lt_zero _)
   | j + 1, ij, jn =>
     by
@@ -669,9 +828,11 @@ theorem eq_of_xn_modeq_lem1 {i n} : ∀ {j}, i < j → j < n → xn i % xn n < x
     rw [Nat.mod_eq_of_lt (strict_mono_x _ (Nat.lt_of_succ_lt jn)),
         Nat.mod_eq_of_lt (strict_mono_x _ jn)] <;>
       exact strict_mono_x _ (Nat.lt_succ_self _)
-#align pell.eq_of_xn_modeq_lem1 Pell.eq_of_xn_modeq_lem1
+#align pell.eq_of_xn_modeq_lem1 Pell.eq_of_xn_modEq_lem1
+-/
 
-theorem eq_of_xn_modeq_lem2 {n} (h : 2 * xn n = xn (n + 1)) : a = 2 ∧ n = 0 := by
+#print Pell.eq_of_xn_modEq_lem2 /-
+theorem eq_of_xn_modEq_lem2 {n} (h : 2 * xn n = xn (n + 1)) : a = 2 ∧ n = 0 := by
   rw [xn_succ, mul_comm] at h <;>
     exact
       by
@@ -682,9 +843,11 @@ theorem eq_of_xn_modeq_lem2 {n} (h : 2 * xn n = xn (n + 1)) : a = 2 ∧ n = 0 :=
               (Nat.lt_add_of_pos_right <| mul_pos (d_pos a1) (strict_mono_y a1 np)))
             h
       cases this <;> simp at h <;> exact ⟨h.symm, rfl⟩
-#align pell.eq_of_xn_modeq_lem2 Pell.eq_of_xn_modeq_lem2
+#align pell.eq_of_xn_modeq_lem2 Pell.eq_of_xn_modEq_lem2
+-/
 
-theorem eq_of_xn_modeq_lem3 {i n} (npos : 0 < n) :
+#print Pell.eq_of_xn_modEq_lem3 /-
+theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
     ∀ {j}, i < j → j ≤ 2 * n → j ≠ n → ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2) → xn i % xn n < xn j % xn n
   | 0, ij, _, _, _ => absurd ij (Nat.not_lt_zero _)
   | j + 1, ij, j2n, jnn, ntriv =>
@@ -759,8 +922,10 @@ theorem eq_of_xn_modeq_lem3 {i n} (npos : 0 < n) :
             refine' sub_lt_sub_left (Int.ofNat_lt_ofNat_of_lt <| strict_mono_x _ _) _
             rw [Nat.sub_succ]
             exact Nat.pred_lt (ne_of_gt <| tsub_pos_of_lt j2n)
-#align pell.eq_of_xn_modeq_lem3 Pell.eq_of_xn_modeq_lem3
+#align pell.eq_of_xn_modeq_lem3 Pell.eq_of_xn_modEq_lem3
+-/
 
+#print Pell.eq_of_xn_modEq_le /-
 theorem eq_of_xn_modEq_le {i j n} (ij : i ≤ j) (j2n : j ≤ 2 * n) (h : xn i ≡ xn j [MOD xn n])
     (ntriv : ¬(a = 2 ∧ n = 1 ∧ i = 0 ∧ j = 2)) : i = j :=
   if npos : n = 0 then by simp_all
@@ -781,7 +946,9 @@ theorem eq_of_xn_modEq_le {i j n} (ij : i ≤ j) (j2n : j ≤ 2 * n) (h : xn i 
               rw [n1, i2] at ij' <;> exact absurd ij' (by decide))
       else ne_of_lt (eq_of_xn_modeq_lem3 (Nat.pos_of_ne_zero npos) ij' j2n jn ntriv) h
 #align pell.eq_of_xn_modeq_le Pell.eq_of_xn_modEq_le
+-/
 
+#print Pell.eq_of_xn_modEq /-
 theorem eq_of_xn_modEq {i j n} (i2n : i ≤ 2 * n) (j2n : j ≤ 2 * n) (h : xn i ≡ xn j [MOD xn n])
     (ntriv : a = 2 → n = 1 → (i = 0 → j ≠ 2) ∧ (i = 2 → j ≠ 0)) : i = j :=
   (le_total i j).elim
@@ -789,8 +956,10 @@ theorem eq_of_xn_modEq {i j n} (i2n : i ≤ 2 * n) (j2n : j ≤ 2 * n) (h : xn i
     fun ij =>
     (eq_of_xn_modeq_le ij i2n h.symm fun ⟨a2, n1, j0, i2⟩ => (ntriv a2 n1).right i2 j0).symm
 #align pell.eq_of_xn_modeq Pell.eq_of_xn_modEq
+-/
 
-theorem eq_of_xn_modeq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 * n)
+#print Pell.eq_of_xn_modEq' /-
+theorem eq_of_xn_modEq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 * n)
     (h : xn j ≡ xn i [MOD xn n]) : j = i ∨ j + i = 4 * n :=
   have i2n : i ≤ 2 * n := by apply le_trans hin <;> rw [two_mul] <;> apply Nat.le_add_left
   (le_or_gt j (2 * n)).imp
@@ -813,8 +982,10 @@ theorem eq_of_xn_modeq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 *
         by
         rw [n1, i2] at hin
         exact absurd hin (by decide)⟩
-#align pell.eq_of_xn_modeq' Pell.eq_of_xn_modeq'
+#align pell.eq_of_xn_modeq' Pell.eq_of_xn_modEq'
+-/
 
+#print Pell.modEq_of_xn_modEq /-
 theorem modEq_of_xn_modEq {i j n} (ipos : 0 < i) (hin : i ≤ n) (h : xn j ≡ xn i [MOD xn n]) :
     j ≡ i [MOD 4 * n] ∨ j + i ≡ 0 [MOD 4 * n] :=
   let j' := j % (4 * n)
@@ -836,9 +1007,11 @@ theorem modEq_of_xn_modEq {i j n} (ipos : 0 < i) (hin : i ≤ n) (h : xn j ≡ x
           rw [← Nat.mod_add_div j (4 * n)]
           exact this j' _).symm)
 #align pell.modeq_of_xn_modeq Pell.modEq_of_xn_modEq
+-/
 
 end
 
+#print Pell.xy_modEq_of_modEq /-
 theorem xy_modEq_of_modEq {a b c} (a1 : 1 < a) (b1 : 1 < b) (h : a ≡ b [MOD c]) :
     ∀ n, xn a1 n ≡ xn b1 n [MOD c] ∧ yn a1 n ≡ yn b1 n [MOD c]
   | 0 => by constructor <;> rfl
@@ -853,7 +1026,9 @@ theorem xy_modEq_of_modEq {a b c} (a1 : 1 < a) (b1 : 1 < b) (h : a ≡ b [MOD c]
         rw [yn_succ_succ a1, yn_succ_succ b1]
         exact (h.mul_left _).mul (xy_modeq_of_modeq (n + 1)).right⟩
 #align pell.xy_modeq_of_modeq Pell.xy_modEq_of_modEq
+-/
 
+#print Pell.matiyasevic /-
 theorem matiyasevic {a k x y} :
     (∃ a1 : 1 < a, xn a1 k = x ∧ yn a1 k = y) ↔
       1 < a ∧
@@ -950,7 +1125,9 @@ theorem matiyasevic {a k x y} :
                   rwa [Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_left _ _) ki),
                     Nat.mod_eq_of_lt (lt_of_le_of_lt (Nat.le_add_right _ _) ki)] at this⟩⟩
 #align pell.matiyasevic Pell.matiyasevic
+-/
 
+#print Pell.eq_pow_of_pell_lem /-
 theorem eq_pow_of_pell_lem {a y k} (hy0 : y ≠ 0) (hk0 : k ≠ 0) (hyk : y ^ k < a) :
     (↑(y ^ k) : ℤ) < 2 * a * y - y * y - 1 :=
   have hya : y < a := (Nat.le_self_pow hk0 _).trans_lt hyk
@@ -967,7 +1144,9 @@ theorem eq_pow_of_pell_lem {a y k} (hy0 : y ≠ 0) (hk0 : k ≠ 0) (hyk : y ^ k
     _ = 2 * a * y - y * y - 1 := by ring
     
 #align pell.eq_pow_of_pell_lem Pell.eq_pow_of_pell_lem
+-/
 
+#print Pell.eq_pow_of_pell /-
 theorem eq_pow_of_pell {m n k} :
     n ^ k = m ↔
       k = 0 ∧ m = 1 ∨
@@ -1053,6 +1232,7 @@ theorem eq_pow_of_pell {m n k} :
     rw [← te] at nt
     rwa [Nat.mod_eq_of_lt (Nat.cast_lt.1 nt), Nat.mod_eq_of_lt mt] at this
 #align pell.eq_pow_of_pell Pell.eq_pow_of_pell
+-/
 
 end Pell
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 
 ! This file was ported from Lean 3 source module number_theory.pell_matiyasevic
-! leanprover-community/mathlib commit 2af0836443b4cfb5feda0df0051acdb398304931
+! leanprover-community/mathlib commit 795b501869b9fa7aa716d5fdadd00c03f983a605
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -60,6 +60,34 @@ open Nat
 
 section
 
+variable {d : ℤ}
+
+/-- The property of being a solution to the Pell equation, expressed
+  as a property of elements of `ℤ√d`. -/
+def IsPell : ℤ√d → Prop
+  | ⟨x, y⟩ => x * x - d * y * y = 1
+#align pell.is_pell Pell.IsPell
+
+theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
+  | ⟨x, y⟩ => by simp [Zsqrtd.ext, is_pell, mul_comm] <;> ring_nf
+#align pell.is_pell_norm Pell.isPell_norm
+
+theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d)
+  | ⟨x, y⟩ => by rw [unitary.mem_iff, is_pell_norm, mul_comm (star _), and_self_iff]
+#align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary
+
+theorem isPell_mul {b c : ℤ√d} (hb : IsPell b) (hc : IsPell c) : IsPell (b * c) :=
+  isPell_norm.2 (by simp [mul_comm, mul_left_comm, star_mul, is_pell_norm.1 hb, is_pell_norm.1 hc])
+#align pell.is_pell_mul Pell.isPell_mul
+
+theorem isPell_star : ∀ {b : ℤ√d}, IsPell b ↔ IsPell (star b)
+  | ⟨x, y⟩ => by simp [is_pell, Zsqrtd.star_mk]
+#align pell.is_pell_star Pell.isPell_star
+
+end
+
+section
+
 parameter {a : ℕ}(a1 : 1 < a)
 
 include a1
@@ -182,13 +210,7 @@ theorem pellZd_im (n : ℕ) : (pell_zd n).im = yn n :=
   rfl
 #align pell.pell_zd_im Pell.pellZd_im
 
-/-- The property of being a solution to the Pell equation, expressed
-  as a property of elements of `ℤ√d`. -/
-def IsPell : ℤ√d → Prop
-  | ⟨x, y⟩ => x * x - d * y * y = 1
-#align pell.is_pell Pell.IsPell
-
-theorem isPell_nat {x y : ℕ} : is_pell ⟨x, y⟩ ↔ x * x - d * y * y = 1 :=
+theorem isPell_nat {x y : ℕ} : IsPell (⟨x, y⟩ : ℤ√d) ↔ x * x - d * y * y = 1 :=
   ⟨fun h =>
     Int.ofNat.inj
       (by rw [Int.ofNat_sub (Int.le_of_ofNat_le_ofNat <| Int.le.intro_sub h)] <;> exact h),
@@ -197,32 +219,15 @@ theorem isPell_nat {x y : ℕ} : is_pell ⟨x, y⟩ ↔ x * x - d * y * y = 1 :=
       rw [← Int.ofNat_sub <| le_of_lt <| Nat.lt_of_sub_eq_succ h, h] <;> rfl⟩
 #align pell.is_pell_nat Pell.isPell_nat
 
-theorem isPell_norm : ∀ {b : ℤ√d}, is_pell b ↔ b * star b = 1
-  | ⟨x, y⟩ => by simp [Zsqrtd.ext, is_pell, mul_comm] <;> ring_nf
-#align pell.is_pell_norm Pell.isPell_norm
-
-theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, is_pell b ↔ b ∈ unitary (ℤ√d)
-  | ⟨x, y⟩ => by rw [unitary.mem_iff, is_pell_norm, mul_comm (star _), and_self_iff]
-#align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary
-
-theorem isPell_mul {b c : ℤ√d} (hb : is_pell b) (hc : is_pell c) : is_pell (b * c) :=
-  is_pell_norm.2
-    (by simp [mul_comm, mul_left_comm, star_mul, Pell.isPell_norm.1 hb, Pell.isPell_norm.1 hc])
-#align pell.is_pell_mul Pell.isPell_mul
-
-theorem isPell_star : ∀ {b : ℤ√d}, is_pell b ↔ is_pell (star b)
-  | ⟨x, y⟩ => by simp [is_pell, Zsqrtd.star_mk]
-#align pell.is_pell_star Pell.isPell_star
-
 @[simp]
 theorem pellZd_succ (n : ℕ) : pell_zd (n + 1) = pell_zd n * ⟨a, 1⟩ := by simp [Zsqrtd.ext]
 #align pell.pell_zd_succ Pell.pellZd_succ
 
-theorem isPell_one : is_pell ⟨a, 1⟩ :=
+theorem isPell_one : IsPell (⟨a, 1⟩ : ℤ√d) :=
   show az * az - d * 1 * 1 = 1 by simp [dz_val] <;> ring
 #align pell.is_pell_one Pell.isPell_one
 
-theorem isPell_pellZd : ∀ n : ℕ, is_pell (pell_zd n)
+theorem isPell_pellZd : ∀ n : ℕ, IsPell (pell_zd n)
   | 0 => rfl
   | n + 1 => by
     let o := is_pell_one
@@ -281,16 +286,16 @@ theorem x_pos (n) : 0 < xn n :=
   lt_of_le_of_lt (Nat.zero_le n) (n_lt_xn n)
 #align pell.x_pos Pell.x_pos
 
-theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → is_pell b → b ≤ pell_zd n → ∃ n, b = pell_zd n
+theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → IsPell b → b ≤ pell_zd n → ∃ n, b = pell_zd n
   | 0, b => fun h1 hp hl => ⟨0, @Zsqrtd.le_antisymm _ dnsq _ _ hl h1⟩
   | n + 1, b => fun h1 hp h =>
     have a1p : (0 : ℤ√d) ≤ ⟨a, 1⟩ := trivial
     have am1p : (0 : ℤ√d) ≤ ⟨a, -1⟩ := show (_ : Nat) ≤ _ by simp <;> exact Nat.pred_le _
-    have a1m : (⟨a, 1⟩ * ⟨a, -1⟩ : ℤ√d) = 1 := is_pell_norm.1 is_pell_one
+    have a1m : (⟨a, 1⟩ * ⟨a, -1⟩ : ℤ√d) = 1 := isPell_norm.1 is_pell_one
     if ha : (⟨↑a, 1⟩ : ℤ√d) ≤ b then
       let ⟨m, e⟩ :=
         eq_pell_lem n (b * ⟨a, -1⟩) (by rw [← a1m] <;> exact mul_le_mul_of_nonneg_right ha am1p)
-          (is_pell_mul hp (is_pell_star.1 is_pell_one))
+          (isPell_mul hp (isPell_star.1 is_pell_one))
           (by
             have t := mul_le_mul_of_nonneg_right h am1p <;>
               rwa [pell_zd_succ, mul_assoc, a1m, mul_one] at t)
@@ -328,7 +333,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → is_pell b → b ≤ pel
               | -[y+1], y0l, yl2 => y0l trivial
 #align pell.eq_pell_lem Pell.eq_pell_lem
 
-theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : is_pell b) : ∃ n, b = pell_zd n :=
+theorem eq_pellZd (b : ℤ√d) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b = pell_zd n :=
   let ⟨n, h⟩ := @Zsqrtd.le_arch d b
   eq_pell_lem n b b1 hp <|
     h.trans <| by
@@ -373,7 +378,7 @@ theorem pellZd_sub {m n} (h : n ≤ m) : pell_zd (m - n) = pell_zd m * star (pel
   by
   let t := pell_zd_add n (m - n)
   rw [add_tsub_cancel_of_le h] at t <;>
-    rw [t, mul_comm (pell_zd _ n) _, mul_assoc, (is_pell_norm _).1 (is_pell_pell_zd _ _), mul_one]
+    rw [t, mul_comm (pell_zd _ n) _, mul_assoc, is_pell_norm.1 (is_pell_pell_zd _ _), mul_one]
 #align pell.pell_zd_sub Pell.pellZd_sub
 
 theorem xz_sub {m n} (h : n ≤ m) : xz (m - n) = xz m * xz n - d * yz m * yz n :=
Diff
@@ -4,10 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 
 ! This file was ported from Lean 3 source module number_theory.pell_matiyasevic
-! leanprover-community/mathlib commit a66d07e27d5b5b8ac1147cacfe353478e5c14002
+! leanprover-community/mathlib commit 2af0836443b4cfb5feda0df0051acdb398304931
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
+import Mathbin.Algebra.Star.Unitary
 import Mathbin.Data.Nat.Modeq
 import Mathbin.NumberTheory.Zsqrtd.Basic
 
@@ -196,19 +197,22 @@ theorem isPell_nat {x y : ℕ} : is_pell ⟨x, y⟩ ↔ x * x - d * y * y = 1 :=
       rw [← Int.ofNat_sub <| le_of_lt <| Nat.lt_of_sub_eq_succ h, h] <;> rfl⟩
 #align pell.is_pell_nat Pell.isPell_nat
 
-theorem isPell_norm : ∀ {b : ℤ√d}, is_pell b ↔ b * b.conj = 1
+theorem isPell_norm : ∀ {b : ℤ√d}, is_pell b ↔ b * star b = 1
   | ⟨x, y⟩ => by simp [Zsqrtd.ext, is_pell, mul_comm] <;> ring_nf
 #align pell.is_pell_norm Pell.isPell_norm
 
+theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, is_pell b ↔ b ∈ unitary (ℤ√d)
+  | ⟨x, y⟩ => by rw [unitary.mem_iff, is_pell_norm, mul_comm (star _), and_self_iff]
+#align pell.is_pell_iff_mem_unitary Pell.isPell_iff_mem_unitary
+
 theorem isPell_mul {b c : ℤ√d} (hb : is_pell b) (hc : is_pell c) : is_pell (b * c) :=
   is_pell_norm.2
-    (by
-      simp [mul_comm, mul_left_comm, Zsqrtd.conj_mul, Pell.isPell_norm.1 hb, Pell.isPell_norm.1 hc])
+    (by simp [mul_comm, mul_left_comm, star_mul, Pell.isPell_norm.1 hb, Pell.isPell_norm.1 hc])
 #align pell.is_pell_mul Pell.isPell_mul
 
-theorem isPell_conj : ∀ {b : ℤ√d}, is_pell b ↔ is_pell b.conj
-  | ⟨x, y⟩ => by simp [is_pell, Zsqrtd.conj]
-#align pell.is_pell_conj Pell.isPell_conj
+theorem isPell_star : ∀ {b : ℤ√d}, is_pell b ↔ is_pell (star b)
+  | ⟨x, y⟩ => by simp [is_pell, Zsqrtd.star_mk]
+#align pell.is_pell_star Pell.isPell_star
 
 @[simp]
 theorem pellZd_succ (n : ℕ) : pell_zd (n + 1) = pell_zd n * ⟨a, 1⟩ := by simp [Zsqrtd.ext]
@@ -286,7 +290,7 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√d), 1 ≤ b → is_pell b → b ≤ pel
     if ha : (⟨↑a, 1⟩ : ℤ√d) ≤ b then
       let ⟨m, e⟩ :=
         eq_pell_lem n (b * ⟨a, -1⟩) (by rw [← a1m] <;> exact mul_le_mul_of_nonneg_right ha am1p)
-          (is_pell_mul hp (is_pell_conj.1 is_pell_one))
+          (is_pell_mul hp (is_pell_star.1 is_pell_one))
           (by
             have t := mul_le_mul_of_nonneg_right h am1p <;>
               rwa [pell_zd_succ, mul_assoc, a1m, mul_one] at t)
@@ -365,7 +369,7 @@ theorem yn_add (m n) : yn (m + n) = xn m * yn n + yn m * xn n := by
     exact Int.ofNat.inj h
 #align pell.yn_add Pell.yn_add
 
-theorem pellZd_sub {m n} (h : n ≤ m) : pell_zd (m - n) = pell_zd m * (pell_zd n).conj :=
+theorem pellZd_sub {m n} (h : n ≤ m) : pell_zd (m - n) = pell_zd m * star (pell_zd n) :=
   by
   let t := pell_zd_add n (m - n)
   rw [add_tsub_cancel_of_le h] at t <;>
Diff
@@ -992,7 +992,7 @@ theorem eq_pow_of_pell {m n k} :
       refine' eq_pow_of_pell_lem hn.ne' hk.ne' _
       calc
         n ^ k ≤ n ^ w := Nat.pow_le_pow_of_le_right hn kw
-        _ < (w + 1) ^ w := Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) wpos
+        _ < (w + 1) ^ w := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) wpos)
         _ ≤ a := xn_ge_a_pow w1 w
         
     lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le with t te
@@ -1025,7 +1025,7 @@ theorem eq_pow_of_pell {m n k} :
     have hnka : n ^ k < xn hw1 j
     calc
       n ^ k ≤ n ^ j := Nat.pow_le_pow_of_le_right hn0 (le_trans kw wj)
-      _ < (w + 1) ^ j := Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) hj0
+      _ < (w + 1) ^ j := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) hj0)
       _ ≤ xn hw1 j := xn_ge_a_pow hw1 j
       
     have nt : (↑(n ^ k) : ℤ) < 2 * xn hw1 j * n - n * n - 1 :=

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 3 (#12372)

A PR analogous to #12338 and #12361: reformatting proofs following the multiple goals linter of #12339.

Diff
@@ -675,7 +675,8 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
         lt_of_add_lt_add_right <|
           show 2 * n - k + k < n + k by
             rw [tsub_add_cancel_of_le]
-            rw [two_mul]; exact add_lt_add_left kn n
+            · rw [two_mul]
+              exact add_lt_add_left kn n
             exact k2n
       have xle : xn a1 (2 * n - k) ≤ xn a1 n := le_of_lt <| strictMono_x a1 k2nl
       suffices xn a1 k % xn a1 n = xn a1 n - xn a1 (2 * n - k) by rw [this, Int.ofNat_sub xle]
@@ -754,7 +755,7 @@ theorem eq_of_xn_modEq_le {i j n} (ij : i ≤ j) (j2n : j ≤ 2 * n)
           rw [Nat.mod_eq_of_lt (strictMono_x a1 (Nat.pos_of_ne_zero npos))]
           exact Nat.succ_pos _
         cases' i with i
-        exact x0
+        · exact x0
         rw [jn] at ij'
         exact
           x0.trans
chore: superfluous parentheses part 2 (#12131)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -965,7 +965,7 @@ theorem eq_pow_of_pell {m n k} :
       refine' eq_pow_of_pell_lem hn.ne' hk.ne' _
       calc
         n ^ k ≤ n ^ w := Nat.pow_le_pow_of_le_right hn kw
-        _ < (w + 1) ^ w := (Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) wpos.ne')
+        _ < (w + 1) ^ w := Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) wpos.ne'
         _ ≤ a := xn_ge_a_pow w1 w
     lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le with t te
     have tm : x ≡ y * (a - n) + n ^ k [MOD t] := by
@@ -994,7 +994,7 @@ theorem eq_pow_of_pell {m n k} :
           (yn_modEq_a_sub_one hw1 j).symm.trans <| modEq_zero_iff_dvd.2 ⟨z, yj.symm⟩)
     have hnka : n ^ k < xn hw1 j := calc
       n ^ k ≤ n ^ j := Nat.pow_le_pow_of_le_right hn0 (le_trans kw wj)
-      _ < (w + 1) ^ j := (Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) hj0.ne')
+      _ < (w + 1) ^ j := Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) hj0.ne'
       _ ≤ xn hw1 j := xn_ge_a_pow hw1 j
     have nt : (↑(n ^ k) : ℤ) < 2 * xn hw1 j * n - n * n - 1 :=
       eq_pow_of_pell_lem hn0.ne' hk0.ne' hnka
chore: Rename coe_nat/coe_int/coe_rat to natCast/intCast/ratCast (#11499)

This is less exhaustive than its sibling #11486 because edge cases are harder to classify. No fundamental difficulty, just me being a bit fast and lazy.

Reduce the diff of #11203

Diff
@@ -337,7 +337,7 @@ theorem eq_pellZd (b : ℤ√(d a1)) (b1 : 1 ≤ b) (hp : IsPell b) : ∃ n, b =
   let ⟨n, h⟩ := @Zsqrtd.le_arch (d a1) b
   eq_pell_lem a1 n b b1 hp <|
     h.trans <| by
-      rw [Zsqrtd.coe_nat_val]
+      rw [Zsqrtd.natCast_val]
       exact
         Zsqrtd.le_of_le_le (Int.ofNat_le_ofNat_of_le <| le_of_lt <| n_lt_xn _ _)
           (Int.ofNat_zero_le _)
@@ -508,7 +508,7 @@ theorem dvd_of_ysq_dvd {n t} (h : yn a1 n * yn a1 n ∣ yn a1 t) : yn a1 n ∣ t
 theorem pellZd_succ_succ (n) :
     pellZd a1 (n + 2) + pellZd a1 n = (2 * a : ℕ) * pellZd a1 (n + 1) := by
   have : (1 : ℤ√(d a1)) + ⟨a, 1⟩ * ⟨a, 1⟩ = ⟨a, 1⟩ * (2 * a) := by
-    rw [Zsqrtd.coe_nat_val]
+    rw [Zsqrtd.natCast_val]
     change (⟨_, _⟩ : ℤ√(d a1)) = ⟨_, _⟩
     rw [dz_val]
     dsimp [az]
style: replace '.-/' by '. -/' (#11938)

Purely automatic replacement. If this is in any way controversial; I'm happy to just close this PR.

Diff
@@ -154,19 +154,19 @@ theorem xn_one : xn a1 1 = a := by simp
 theorem yn_one : yn a1 1 = 1 := by simp
 #align pell.yn_one Pell.yn_one
 
-/-- The Pell `x` sequence, considered as an integer sequence.-/
+/-- The Pell `x` sequence, considered as an integer sequence. -/
 def xz (n : ℕ) : ℤ :=
   xn a1 n
 #align pell.xz Pell.xz
 
-/-- The Pell `y` sequence, considered as an integer sequence.-/
+/-- The Pell `y` sequence, considered as an integer sequence. -/
 def yz (n : ℕ) : ℤ :=
   yn a1 n
 #align pell.yz Pell.yz
 
 section
 
-/-- The element `a` such that `d = a ^ 2 - 1`, considered as an integer.-/
+/-- The element `a` such that `d = a ^ 2 - 1`, considered as an integer. -/
 def az (a : ℕ) : ℤ :=
   a
 #align pell.az Pell.az
chore(Data/Int): Rename coe_nat to natCast (#11637)

Reduce the diff of #11499

Renames

All in the Int namespace:

  • ofNat_eq_castofNat_eq_natCast
  • cast_eq_cast_iff_NatnatCast_inj
  • natCast_eq_ofNatofNat_eq_natCast
  • coe_nat_subnatCast_sub
  • coe_nat_nonnegnatCast_nonneg
  • sign_coe_add_onesign_natCast_add_one
  • nat_succ_eq_int_succnatCast_succ
  • succ_neg_nat_succsucc_neg_natCast_succ
  • coe_pred_of_posnatCast_pred_of_pos
  • coe_nat_divnatCast_div
  • coe_nat_edivnatCast_ediv
  • sign_coe_nat_of_nonzerosign_natCast_of_ne_zero
  • toNat_coe_nattoNat_natCast
  • toNat_coe_nat_add_onetoNat_natCast_add_one
  • coe_nat_dvdnatCast_dvd_natCast
  • coe_nat_dvd_leftnatCast_dvd
  • coe_nat_dvd_rightdvd_natCast
  • le_coe_nat_suble_natCast_sub
  • succ_coe_nat_possucc_natCast_pos
  • coe_nat_modEq_iffnatCast_modEq_iff
  • coe_natAbsnatCast_natAbs
  • coe_nat_eq_zeronatCast_eq_zero
  • coe_nat_ne_zeronatCast_ne_zero
  • coe_nat_ne_zero_iff_posnatCast_ne_zero_iff_pos
  • abs_coe_natabs_natCast
  • coe_nat_nonpos_iffnatCast_nonpos_iff

Also rename Nat.coe_nat_dvd to Nat.cast_dvd_cast

Diff
@@ -615,7 +615,7 @@ theorem xn_modEq_x2n_sub_lem {n j} (h : j ≤ n) : xn a1 (2 * n - j) + xn a1 j 
   rw [two_mul, add_tsub_assoc_of_le h, xn_add, add_assoc, ← zero_add 0]
   exact
     (dvd_mul_right _ _).modEq_zero_nat.add
-      (Int.coe_nat_dvd.1 <| by simpa [xz, yz] using h1).modEq_zero_nat
+      (Int.natCast_dvd_natCast.1 <| by simpa [xz, yz] using h1).modEq_zero_nat
 #align pell.xn_modeq_x2n_sub_lem Pell.xn_modEq_x2n_sub_lem
 
 theorem xn_modEq_x2n_sub {n j} (h : j ≤ 2 * n) : xn a1 (2 * n - j) + xn a1 j ≡ 0 [MOD xn a1 n] :=
@@ -877,7 +877,7 @@ theorem matiyasevic {a k x y} :
       have sx : s ≡ x [MOD u] := (xy_modEq_of_modEq b1 a1 ba k).left
       have tk : t ≡ k [MOD 4 * y] :=
         have : 4 * y ∣ b - 1 :=
-          Int.coe_nat_dvd.1 <| by rw [Int.ofNat_sub (le_of_lt b1)]; exact bm1.symm.dvd
+          Int.natCast_dvd_natCast.1 <| by rw [Int.ofNat_sub (le_of_lt b1)]; exact bm1.symm.dvd
         (yn_modEq_a_sub_one _ _).of_dvd this
       ⟨ky,
         Or.inr
@@ -904,7 +904,7 @@ theorem matiyasevic {a k x y} :
             have yd : 4 * yn a1 i ∣ 4 * n := mul_dvd_mul_left _ <| dvd_of_ysq_dvd a1 yv
             have jk : j ≡ k [MOD 4 * yn a1 i] :=
               have : 4 * yn a1 i ∣ b - 1 :=
-                Int.coe_nat_dvd.1 <| by rw [Int.ofNat_sub (le_of_lt b1)]; exact bm1.symm.dvd
+                Int.natCast_dvd_natCast.1 <| by rw [Int.ofNat_sub (le_of_lt b1)]; exact bm1.symm.dvd
               ((yn_modEq_a_sub_one b1 _).of_dvd this).symm.trans tk
             have ki : k + i < 4 * yn a1 i :=
               lt_of_le_of_lt (_root_.add_le_add ky (yn_ge_n a1 i)) <| by
change the order of operation in zsmulRec and nsmulRec (#11451)

We change the following field in the definition of an additive commutative monoid:

 nsmul_succ : ∀ (n : ℕ) (x : G),
-  AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
+  AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x

where the latter is more natural

We adjust the definitions of ^ in monoids, groups, etc. Originally there was a warning comment about why this natural order was preferred

use x * npowRec n x and not npowRec n x * x in the definition to make sure that definitional unfolding of npowRec is blocked, to avoid deep recursion issues.

but it seems to no longer apply.

Remarks on the PR :

  • pow_succ and pow_succ' have switched their meanings.
  • Most of the time, the proofs were adjusted by priming/unpriming one lemma, or exchanging left and right; a few proofs were more complicated to adjust.
  • In particular, [Mathlib/NumberTheory/RamificationInertia.lean] used Ideal.IsPrime.mul_mem_pow which is defined in [Mathlib/RingTheory/DedekindDomain/Ideal.lean]. Changing the order of operation forced me to add the symmetric lemma Ideal.IsPrime.mem_pow_mul.
  • the docstring for Cauchy condensation test in [Mathlib/Analysis/PSeries.lean] was mathematically incorrect, I added the mention that the function is antitone.
Diff
@@ -261,7 +261,7 @@ instance dnsq : Zsqrtd.Nonsquare (d a1) :=
 theorem xn_ge_a_pow : ∀ n : ℕ, a ^ n ≤ xn a1 n
   | 0 => le_refl 1
   | n + 1 => by
-    simp only [_root_.pow_succ', xn_succ]
+    simp only [_root_.pow_succ, xn_succ]
     exact le_trans (Nat.mul_le_mul_right _ (xn_ge_a_pow n)) (Nat.le_add_right _ _)
 #align pell.xn_ge_a_pow Pell.xn_ge_a_pow
 
@@ -272,7 +272,7 @@ theorem n_lt_a_pow : ∀ n : ℕ, n < a ^ n
     have : a ^ n + a ^ n ≤ a ^ n * a := by
       rw [← mul_two]
       exact Nat.mul_le_mul_left _ a1
-    simp only [_root_.pow_succ', gt_iff_lt]
+    simp only [_root_.pow_succ, gt_iff_lt]
     refine' lt_of_lt_of_le _ this
     exact add_lt_add_of_lt_of_le IH (lt_of_le_of_lt (Nat.zero_le _) IH)
 #align pell.n_lt_a_pow Pell.n_lt_a_pow
@@ -463,25 +463,25 @@ theorem xy_modEq_yn (n) :
         xn a1 n ^ k * xn a1 n + 0 [MOD yn a1 n ^ 2] :=
       (hx.mul_right _).add <|
         modEq_zero_iff_dvd.2 <| by
-          rw [_root_.pow_succ']
+          rw [_root_.pow_succ]
           exact
             mul_dvd_mul_right
               (dvd_mul_of_dvd_right
                 (modEq_zero_iff_dvd.1 <|
-                  (hy.of_dvd <| by simp [_root_.pow_succ']).trans <|
+                  (hy.of_dvd <| by simp [_root_.pow_succ]).trans <|
                     modEq_zero_iff_dvd.2 <| by simp)
                 _) _
     have R : xn a1 (n * k) * yn a1 n + yn a1 (n * k) * xn a1 n ≡
         xn a1 n ^ k * yn a1 n + k * xn a1 n ^ k * yn a1 n [MOD yn a1 n ^ 3] :=
       ModEq.add
           (by
-            rw [_root_.pow_succ']
+            rw [_root_.pow_succ]
             exact hx.mul_right' _) <| by
         have : k * xn a1 n ^ (k - 1) * yn a1 n * xn a1 n = k * xn a1 n ^ k * yn a1 n := by
-          cases' k with k <;> simp [_root_.pow_succ']; ring_nf
+          cases' k with k <;> simp [_root_.pow_succ]; ring_nf
         rw [← this]
         exact hy.mul_right _
-    rw [add_tsub_cancel_right, Nat.mul_succ, xn_add, yn_add, pow_succ' (xn _ n), Nat.succ_mul,
+    rw [add_tsub_cancel_right, Nat.mul_succ, xn_add, yn_add, pow_succ (xn _ n), Nat.succ_mul,
       add_comm (k * xn _ n ^ k) (xn _ n ^ k), right_distrib]
     exact ⟨L, R⟩
 #align pell.xy_modeq_yn Pell.xy_modEq_yn
chore(Data/Nat): Use Std lemmas (#11661)

Move basic Nat lemmas from Data.Nat.Order.Basic and Data.Nat.Pow to Data.Nat.Defs. Most proofs need adapting, but that's easily solved by replacing the general mathlib lemmas by the new Std Nat-specific lemmas and using omega.

Other changes

  • Move the last few lemmas left in Data.Nat.Pow to Algebra.GroupPower.Order
  • Move the deprecated aliases from Data.Nat.Pow to Algebra.GroupPower.Order
  • Move the bit/bit0/bit1 lemmas from Data.Nat.Order.Basic to Data.Nat.Bits
  • Fix some fallout from not importing Data.Nat.Order.Basic anymore
  • Add a few Nat-specific lemmas to help fix the fallout (look for nolint simpNF)
  • Turn Nat.mul_self_le_mul_self_iff and Nat.mul_self_lt_mul_self_iff around (they were misnamed)
  • Make more arguments to Nat.one_lt_pow implicit
Diff
@@ -250,7 +250,7 @@ theorem pell_eq (n : ℕ) : xn a1 n * xn a1 n - d a1 * yn a1 n * yn a1 n = 1 :=
 instance dnsq : Zsqrtd.Nonsquare (d a1) :=
   ⟨fun n h =>
     have : n * n + 1 = a * a := by rw [← h]; exact Nat.succ_pred_eq_of_pos (asq_pos a1)
-    have na : n < a := Nat.mul_self_lt_mul_self_iff.2 (by rw [← this]; exact Nat.lt_succ_self _)
+    have na : n < a := Nat.mul_self_lt_mul_self_iff.1 (by rw [← this]; exact Nat.lt_succ_self _)
     have : (n + 1) * (n + 1) ≤ n * n + 1 := by rw [this]; exact Nat.mul_self_le_mul_self na
     have : n + n ≤ 0 :=
       @Nat.le_of_add_le_add_right _ (n * n + 1) _ (by ring_nf at this ⊢; assumption)
style: homogenise porting notes (#11145)

Homogenises porting notes via capitalisation and addition of whitespace.

It makes the following changes:

  • converts "--porting note" into "-- Porting note";
  • converts "porting note" into "Porting note".
Diff
@@ -88,7 +88,7 @@ end
 
 section
 
---Porting note: was parameter in Lean3
+-- Porting note: was parameter in Lean3
 variable {a : ℕ} (a1 : 1 < a)
 
 private def d (_a1 : 1 < a) :=
@@ -104,7 +104,7 @@ theorem d_pos : 0 < d a1 :=
 `d = a ^ 2 - 1`, defined together in mutual recursion. -/
 --@[nolint dup_namespace]
 def pell : ℕ → ℕ × ℕ
-  --Porting note: used pattern matching because `Nat.recOn` is noncomputable
+  -- Porting note: used pattern matching because `Nat.recOn` is noncomputable
   | 0 => (1, 0)
   | n+1 => ((pell n).1 * a + d a1 * (pell n).2, (pell n).1 + (pell n).2 * a)
 #align pell.pell Pell.pell
chore: remove stream-of-conciousness syntax for obtain (#11045)

This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.

Diff
@@ -959,8 +959,8 @@ theorem eq_pow_of_pell {m n k} :
     have na : n ≤ a := nw.trans (n_lt_xn w1 w).le
     set x := xn a1 k
     set y := yn a1 k
-    obtain ⟨z, ze⟩ : w ∣ yn w1 w
-    exact modEq_zero_iff_dvd.1 ((yn_modEq_a_sub_one w1 w).trans dvd_rfl.modEq_zero_nat)
+    obtain ⟨z, ze⟩ : w ∣ yn w1 w :=
+      modEq_zero_iff_dvd.1 ((yn_modEq_a_sub_one w1 w).trans dvd_rfl.modEq_zero_nat)
     have nt : (↑(n ^ k) : ℤ) < 2 * a * n - n * n - 1 := by
       refine' eq_pow_of_pell_lem hn.ne' hk.ne' _
       calc
chore: classify simp can do this porting notes (#10619)

Classify by adding issue number (#10618) to porting notes claiming anything semantically equivalent to simp can prove this or simp can simplify this.

Diff
@@ -146,11 +146,11 @@ theorem yn_succ (n : ℕ) : yn a1 (n + 1) = xn a1 n + yn a1 n * a :=
   rfl
 #align pell.yn_succ Pell.yn_succ
 
---@[simp] Porting note: `simp` can prove it
+--@[simp] Porting note (#10618): `simp` can prove it
 theorem xn_one : xn a1 1 = a := by simp
 #align pell.xn_one Pell.xn_one
 
---@[simp] Porting note: `simp` can prove it
+--@[simp] Porting note (#10618): `simp` can prove it
 theorem yn_one : yn a1 1 = 1 := by simp
 #align pell.yn_one Pell.yn_one
 
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -992,8 +992,7 @@ theorem eq_pow_of_pell {m n k} :
       Nat.le_of_dvd hj0
         (modEq_zero_iff_dvd.1 <|
           (yn_modEq_a_sub_one hw1 j).symm.trans <| modEq_zero_iff_dvd.2 ⟨z, yj.symm⟩)
-    have hnka : n ^ k < xn hw1 j
-    calc
+    have hnka : n ^ k < xn hw1 j := calc
       n ^ k ≤ n ^ j := Nat.pow_le_pow_of_le_right hn0 (le_trans kw wj)
       _ < (w + 1) ^ j := (Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) hj0.ne')
       _ ≤ xn hw1 j := xn_ge_a_pow hw1 j
feat: The support of f ^ n (#9617)

This involves moving lemmas from Algebra.GroupPower.Ring to Algebra.GroupWithZero.Basic and changing some 0 < n assumptions to n ≠ 0.

From LeanAPAP

Diff
@@ -947,7 +947,8 @@ theorem eq_pow_of_pell {m n k} :
   constructor
   · rintro rfl
     refine' k.eq_zero_or_pos.imp (fun k0 : k = 0 => k0.symm ▸ ⟨rfl, rfl⟩) fun hk => ⟨hk, _⟩
-    refine' n.eq_zero_or_pos.imp (fun n0 : n = 0 => n0.symm ▸ ⟨rfl, zero_pow hk⟩) fun hn => ⟨hn, _⟩
+    refine n.eq_zero_or_pos.imp (fun n0 : n = 0 ↦ n0.symm ▸ ⟨rfl, zero_pow hk.ne'⟩)
+      fun hn ↦ ⟨hn, ?_⟩
     set w := max n k
     have nw : n ≤ w := le_max_left _ _
     have kw : k ≤ w := le_max_right _ _
@@ -979,7 +980,7 @@ theorem eq_pow_of_pell {m n k} :
     exact ⟨w, a, t, z, a1, tm, ta, Nat.cast_lt.1 nt, nw, kw, zp⟩
   · rintro (⟨rfl, rfl⟩ | ⟨hk0, ⟨rfl, rfl⟩ | ⟨hn0, w, a, t, z, a1, tm, ta, mt, nw, kw, zp⟩⟩)
     · exact _root_.pow_zero n
-    · exact zero_pow hk0
+    · exact zero_pow hk0.ne'
     have hw0 : 0 < w := hn0.trans_le nw
     have hw1 : 1 < w + 1 := Nat.succ_lt_succ hw0
     rcases eq_pell hw1 zp with ⟨j, rfl, yj⟩
fix: shake the import tree (#9749)

cherry-picked from #9347

Co-Authored-By: @digama0

Diff
@@ -7,6 +7,7 @@ import Mathlib.Algebra.Star.Unitary
 import Mathlib.Data.Nat.ModEq
 import Mathlib.NumberTheory.Zsqrtd.Basic
 import Mathlib.Tactic.Monotonicity
+import Mathlib.Algebra.GroupPower.Order
 
 #align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"795b501869b9fa7aa716d5fdadd00c03f983a605"
 
chore(NumberTheory/Zsqrtd): use @[ext] (#9299)

Added @[ext] to definition structure Zsqrtd (d : ℤ). (also added lemma sub_re, sub_im)

Diff
@@ -67,7 +67,7 @@ def IsPell : ℤ√d → Prop
 #align pell.is_pell Pell.IsPell
 
 theorem isPell_norm : ∀ {b : ℤ√d}, IsPell b ↔ b * star b = 1
-  | ⟨x, y⟩ => by simp [Zsqrtd.ext, IsPell, mul_comm]; ring_nf
+  | ⟨x, y⟩ => by simp [Zsqrtd.ext_iff, IsPell, mul_comm]; ring_nf
 #align pell.is_pell_norm Pell.isPell_norm
 
 theorem isPell_iff_mem_unitary : ∀ {b : ℤ√d}, IsPell b ↔ b ∈ unitary (ℤ√d)
@@ -217,7 +217,7 @@ theorem isPell_nat {x y : ℕ} : IsPell (⟨x, y⟩ : ℤ√(d a1)) ↔ x * x -
 #align pell.is_pell_nat Pell.isPell_nat
 
 @[simp]
-theorem pellZd_succ (n : ℕ) : pellZd a1 (n + 1) = pellZd a1 n * ⟨a, 1⟩ := by simp [Zsqrtd.ext]
+theorem pellZd_succ (n : ℕ) : pellZd a1 (n + 1) = pellZd a1 n * ⟨a, 1⟩ := by ext <;> simp
 #align pell.pell_zd_succ Pell.pellZd_succ
 
 theorem isPell_one : IsPell (⟨a, 1⟩ : ℤ√(d a1)) :=
@@ -511,9 +511,7 @@ theorem pellZd_succ_succ (n) :
     change (⟨_, _⟩ : ℤ√(d a1)) = ⟨_, _⟩
     rw [dz_val]
     dsimp [az]
-    rw [Zsqrtd.ext]
-    dsimp
-    constructor <;> ring_nf
+    ext <;> dsimp <;> ring_nf
   simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (· * pellZd a1 n) this
 #align pell.pell_zd_succ_succ Pell.pellZd_succ_succ
 
chore: remove uses of cases' (#9171)

I literally went through and regex'd some uses of cases', replacing them with rcases; this is meant to be a low effort PR as I hope that tools can do this in the future.

rcases is an easier replacement than cases, though with better tools we could in future do a second pass converting simple rcases added here (and existing ones) to cases.

Diff
@@ -696,7 +696,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
             show 2 * n - (n + 1) = n - 1 by
               rw [two_mul, tsub_add_eq_tsub_tsub, add_tsub_cancel_right]]
           refine' lt_sub_left_of_add_lt (Int.ofNat_lt_ofNat_of_lt _)
-          cases' lt_or_eq_of_le <| Nat.le_of_succ_le_succ ij with lin ein
+          rcases lt_or_eq_of_le <| Nat.le_of_succ_le_succ ij with lin | ein
           · rw [Nat.mod_eq_of_lt (strictMono_x _ lin)]
             have ll : xn a1 (n - 1) + xn a1 (n - 1) ≤ xn a1 n := by
               rw [← two_mul, mul_comm,
@@ -708,7 +708,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
               apply Nat.le_of_succ_le_succ
               rw [npm]
               exact lin
-            cases' lt_or_eq_of_le il with ill ile
+            rcases lt_or_eq_of_le il with ill | ile
             · exact lt_of_lt_of_le (Nat.add_lt_add_left (strictMono_x a1 ill) _) ll
             · rw [ile]
               apply lt_of_le_of_ne ll
chore: Rename pow monotonicity lemmas (#9095)

The names for lemmas about monotonicity of (a ^ ·) and (· ^ n) were a mess. This PR tidies up everything related by following the naming convention for (a * ·) and (· * b). Namely, (a ^ ·) is pow_right and (· ^ n) is pow_left in lemma names. All lemma renames follow the corresponding multiplication lemma names closely.

Renames

Algebra.GroupPower.Order

  • pow_monopow_right_mono
  • pow_le_powpow_le_pow_right
  • pow_le_pow_of_le_leftpow_le_pow_left
  • pow_lt_pow_of_lt_leftpow_lt_pow_left
  • strictMonoOn_powpow_left_strictMonoOn
  • pow_strictMono_rightpow_right_strictMono
  • pow_lt_powpow_lt_pow_right
  • pow_lt_pow_iffpow_lt_pow_iff_right
  • pow_le_pow_iffpow_le_pow_iff_right
  • self_lt_powlt_self_pow
  • strictAnti_powpow_right_strictAnti
  • pow_lt_pow_iff_of_lt_onepow_lt_pow_iff_right_of_lt_one
  • pow_lt_pow_of_lt_onepow_lt_pow_right_of_lt_one
  • lt_of_pow_lt_powlt_of_pow_lt_pow_left
  • le_of_pow_le_powle_of_pow_le_pow_left
  • pow_lt_pow₀pow_lt_pow_right₀

Algebra.GroupPower.CovariantClass

  • pow_le_pow_of_le_left'pow_le_pow_left'
  • nsmul_le_nsmul_of_le_rightnsmul_le_nsmul_right
  • pow_lt_pow'pow_lt_pow_right'
  • nsmul_lt_nsmulnsmul_lt_nsmul_left
  • pow_strictMono_leftpow_right_strictMono'
  • nsmul_strictMono_rightnsmul_left_strictMono
  • StrictMono.pow_right'StrictMono.pow_const
  • StrictMono.nsmul_leftStrictMono.const_nsmul
  • pow_strictMono_right'pow_left_strictMono
  • nsmul_strictMono_leftnsmul_right_strictMono
  • Monotone.pow_rightMonotone.pow_const
  • Monotone.nsmul_leftMonotone.const_nsmul
  • lt_of_pow_lt_pow'lt_of_pow_lt_pow_left'
  • lt_of_nsmul_lt_nsmullt_of_nsmul_lt_nsmul_right
  • pow_le_pow'pow_le_pow_right'
  • nsmul_le_nsmulnsmul_le_nsmul_left
  • pow_le_pow_of_le_one'pow_le_pow_right_of_le_one'
  • nsmul_le_nsmul_of_nonposnsmul_le_nsmul_left_of_nonpos
  • le_of_pow_le_pow'le_of_pow_le_pow_left'
  • le_of_nsmul_le_nsmul'le_of_nsmul_le_nsmul_right'
  • pow_le_pow_iff'pow_le_pow_iff_right'
  • nsmul_le_nsmul_iffnsmul_le_nsmul_iff_left
  • pow_lt_pow_iff'pow_lt_pow_iff_right'
  • nsmul_lt_nsmul_iffnsmul_lt_nsmul_iff_left

Data.Nat.Pow

  • Nat.pow_lt_pow_of_lt_leftNat.pow_lt_pow_left
  • Nat.pow_le_iff_le_leftNat.pow_le_pow_iff_left
  • Nat.pow_lt_iff_lt_leftNat.pow_lt_pow_iff_left

Lemmas added

  • pow_le_pow_iff_left
  • pow_lt_pow_iff_left
  • pow_right_injective
  • pow_right_inj
  • Nat.pow_le_pow_left to have the correct name since Nat.pow_le_pow_of_le_left is in Std.
  • Nat.pow_le_pow_right to have the correct name since Nat.pow_le_pow_of_le_right is in Std.

Lemmas removed

  • self_le_pow was a duplicate of le_self_pow.
  • Nat.pow_lt_pow_of_lt_right is defeq to pow_lt_pow_right.
  • Nat.pow_right_strictMono is defeq to pow_right_strictMono.
  • Nat.pow_le_iff_le_right is defeq to pow_le_pow_iff_right.
  • Nat.pow_lt_iff_lt_right is defeq to pow_lt_pow_iff_right.

Other changes

  • A bunch of proofs have been golfed.
  • Some lemma assumptions have been turned from 0 < n or 1 ≤ n to n ≠ 0.
  • A few Nat lemmas have been protected.
  • One docstring has been fixed.
Diff
@@ -965,7 +965,7 @@ theorem eq_pow_of_pell {m n k} :
       refine' eq_pow_of_pell_lem hn.ne' hk.ne' _
       calc
         n ^ k ≤ n ^ w := Nat.pow_le_pow_of_le_right hn kw
-        _ < (w + 1) ^ w := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) wpos)
+        _ < (w + 1) ^ w := (Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) wpos.ne')
         _ ≤ a := xn_ge_a_pow w1 w
     lift (2 * a * n - n * n - 1 : ℤ) to ℕ using (Nat.cast_nonneg _).trans nt.le with t te
     have tm : x ≡ y * (a - n) + n ^ k [MOD t] := by
@@ -995,7 +995,7 @@ theorem eq_pow_of_pell {m n k} :
     have hnka : n ^ k < xn hw1 j
     calc
       n ^ k ≤ n ^ j := Nat.pow_le_pow_of_le_right hn0 (le_trans kw wj)
-      _ < (w + 1) ^ j := (Nat.pow_lt_pow_of_lt_left (Nat.lt_succ_of_le nw) hj0)
+      _ < (w + 1) ^ j := (Nat.pow_lt_pow_left (Nat.lt_succ_of_le nw) hj0.ne')
       _ ≤ xn hw1 j := xn_ge_a_pow hw1 j
     have nt : (↑(n ^ k) : ℤ) < 2 * xn hw1 j * n - n * n - 1 :=
       eq_pow_of_pell_lem hn0.ne' hk0.ne' hnka
chore: Remove nonterminal simp at (#7795)

Removes nonterminal uses of simp at. Replaces most of these with instances of simp? ... says.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -319,7 +319,8 @@ theorem eq_pell_lem : ∀ (n) (b : ℤ√(d a1)), 1 ≤ b → IsPell b →
                       (mul_le_mul_of_nonneg_left hn (le_trans zero_le_one h1)) a1p
               erw [bm, one_mul, mul_assoc, Eq.trans (mul_comm _ _) a1m, mul_one] at t
               exact ha t
-        simp at y0l; simp at yl2
+        simp only [sub_self, sub_neg_eq_add] at y0l; simp only [Zsqrtd.neg_re, add_right_neg,
+          Zsqrtd.neg_im, neg_neg] at yl2
         exact
           match y, y0l, (yl2 : (⟨_, _⟩ : ℤ√_) < ⟨_, _⟩) with
           | 0, y0l, _ => y0l (le_refl 0)
chore: replace exact_mod_cast tactic with mod_cast elaborator where possible (#8404)

We still have the exact_mod_cast tactic, used in a few places, which somehow (?) works a little bit harder to prevent the expected type influencing the elaboration of the term. I would like to get to the bottom of this, and it will be easier once the only usages of exact_mod_cast are the ones that don't work using the term elaborator by itself.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -610,7 +610,7 @@ theorem xn_modEq_x2n_sub_lem {n j} (h : j ≤ n) : xn a1 (2 * n - j) + xn a1 j 
         (by
           delta xz; delta yz
           rw [mul_comm (xn _ _ : ℤ)]
-          exact_mod_cast (xn_modEq_x2n_add_lem _ n j))
+          exact mod_cast (xn_modEq_x2n_add_lem _ n j))
         ((dvd_mul_right _ _).mul_left _)
   rw [two_mul, add_tsub_assoc_of_le h, xn_add, add_assoc, ← zero_add 0]
   exact
@@ -1001,7 +1001,7 @@ theorem eq_pow_of_pell {m n k} :
     have na : n ≤ xn hw1 j := (Nat.le_self_pow hk0.ne' _).trans hnka.le
     have te : (t : ℤ) = 2 * xn hw1 j * n - n * n - 1 := by
       rw [sub_sub, eq_sub_iff_add_eq]
-      exact_mod_cast ta.symm
+      exact mod_cast ta.symm
     have : xn a1 k ≡ yn a1 k * (xn hw1 j - n) + n ^ k [MOD t] := by
       apply modEq_of_dvd
       rw [te, Nat.cast_add, Nat.cast_mul, Int.ofNat_sub na]
chore: bump to v4.3.0-rc2 (#8366)

PR contents

This is the supremum of

along with some minor fixes from failures on nightly-testing as Mathlib master is merged into it.

Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.

I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0 branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.

Lean PRs involved in this bump

In particular this includes adjustments for the Lean PRs

leanprover/lean4#2778

We can get rid of all the

local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)

macros across Mathlib (and in any projects that want to write natural number powers of reals).

leanprover/lean4#2722

Changes the default behaviour of simp to (config := {decide := false}). This makes simp (and consequentially norm_num) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp or norm_num to decide or rfl, or adding (config := {decide := true}).

leanprover/lean4#2783

This changed the behaviour of simp so that simp [f] will only unfold "fully applied" occurrences of f. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true }). We may in future add a syntax for this, e.g. simp [!f]; please provide feedback! In the meantime, we have made the following changes:

  • switching to using explicit lemmas that have the intended level of application
  • (config := { unfoldPartialApp := true }) in some places, to recover the old behaviour
  • Using @[eqns] to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp and Function.flip.

This change in Lean may require further changes down the line (e.g. adding the !f syntax, and/or upstreaming the special treatment for Function.comp and Function.flip, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>

Diff
@@ -551,8 +551,8 @@ theorem yn_modEq_a_sub_one : ∀ n, yn a1 n ≡ n [MOD a - 1]
 #align pell.yn_modeq_a_sub_one Pell.yn_modEq_a_sub_one
 
 theorem yn_modEq_two : ∀ n, yn a1 n ≡ n [MOD 2]
-  | 0 => by simp
-  | 1 => by simp
+  | 0 => by rfl
+  | 1 => by simp; rfl
   | n + 2 =>
     (yn_modEq_two n).add_right_cancel <| by
       rw [yn_succ_succ, mul_assoc, (by ring : n + 2 + n = 2 * (n + 1))]
chore: remove nonterminal simp (#7580)

Removes nonterminal simps on lines looking like simp [...]

Diff
@@ -260,7 +260,7 @@ instance dnsq : Zsqrtd.Nonsquare (d a1) :=
 theorem xn_ge_a_pow : ∀ n : ℕ, a ^ n ≤ xn a1 n
   | 0 => le_refl 1
   | n + 1 => by
-    simp [_root_.pow_succ']
+    simp only [_root_.pow_succ', xn_succ]
     exact le_trans (Nat.mul_le_mul_right _ (xn_ge_a_pow n)) (Nat.le_add_right _ _)
 #align pell.xn_ge_a_pow Pell.xn_ge_a_pow
 
@@ -271,7 +271,7 @@ theorem n_lt_a_pow : ∀ n : ℕ, n < a ^ n
     have : a ^ n + a ^ n ≤ a ^ n * a := by
       rw [← mul_two]
       exact Nat.mul_le_mul_left _ a1
-    simp [_root_.pow_succ']
+    simp only [_root_.pow_succ', gt_iff_lt]
     refine' lt_of_lt_of_le _ this
     exact add_lt_add_of_lt_of_le IH (lt_of_le_of_lt (Nat.zero_le _) IH)
 #align pell.n_lt_a_pow Pell.n_lt_a_pow
chore: bump to v4.1.0-rc1 (2nd attempt) (#7216)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -391,7 +391,7 @@ theorem yz_sub {m n} (h : n ≤ m) : yz a1 (m - n) = xz a1 n * yz a1 m - xz a1 m
   exact congr_arg Zsqrtd.im (pellZd_sub a1 h)
 #align pell.yz_sub Pell.yz_sub
 
-theorem xy_coprime (n) : (xn a1 n).coprime (yn a1 n) :=
+theorem xy_coprime (n) : (xn a1 n).Coprime (yn a1 n) :=
   Nat.coprime_of_dvd' fun k _ kx ky => by
     let p := pell_eq a1 n
     rw [← p]
@@ -436,8 +436,8 @@ theorem y_dvd_iff (m n) : yn a1 m ∣ yn a1 n ↔ m ∣ n :=
   ⟨fun h =>
     Nat.dvd_of_mod_eq_zero <|
       (Nat.eq_zero_or_pos _).resolve_right fun hp => by
-        have co : Nat.coprime (yn a1 m) (xn a1 (m * (n / m))) :=
-          Nat.coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
+        have co : Nat.Coprime (yn a1 m) (xn a1 (m * (n / m))) :=
+          Nat.Coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
         have m0 : 0 < m :=
           m.eq_zero_or_pos.resolve_left fun e => by
             rw [e, Nat.mod_zero] at hp;rw [e] at h
@@ -855,10 +855,10 @@ theorem matiyasevic {a k x y} :
       let v := yn a1 m
       have ky : k ≤ y := yn_ge_n a1 k
       have yv : y * y ∣ v := (ysq_dvd_yy a1 k).trans <| (y_dvd_iff _ _ _).2 <| dvd_mul_left _ _
-      have uco : Nat.coprime u (4 * y) :=
+      have uco : Nat.Coprime u (4 * y) :=
         have : 2 ∣ v :=
           modEq_zero_iff_dvd.1 <| (yn_modEq_two _ _).trans (dvd_mul_right _ _).modEq_zero_nat
-        have : Nat.coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
+        have : Nat.Coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
         (this.mul_right this).mul_right <|
           (xy_coprime _ _).coprime_dvd_right (dvd_of_mul_left_dvd yv)
       let ⟨b, ba, bm1⟩ := chineseRemainder uco a 1
Revert "chore: bump to v4.1.0-rc1 (#7174)" (#7198)

This reverts commit 6f8e8104. Unfortunately this bump was not linted correctly, as CI did not run runLinter Mathlib.

We can unrevert once that's fixed.

Diff
@@ -391,7 +391,7 @@ theorem yz_sub {m n} (h : n ≤ m) : yz a1 (m - n) = xz a1 n * yz a1 m - xz a1 m
   exact congr_arg Zsqrtd.im (pellZd_sub a1 h)
 #align pell.yz_sub Pell.yz_sub
 
-theorem xy_coprime (n) : (xn a1 n).Coprime (yn a1 n) :=
+theorem xy_coprime (n) : (xn a1 n).coprime (yn a1 n) :=
   Nat.coprime_of_dvd' fun k _ kx ky => by
     let p := pell_eq a1 n
     rw [← p]
@@ -436,8 +436,8 @@ theorem y_dvd_iff (m n) : yn a1 m ∣ yn a1 n ↔ m ∣ n :=
   ⟨fun h =>
     Nat.dvd_of_mod_eq_zero <|
       (Nat.eq_zero_or_pos _).resolve_right fun hp => by
-        have co : Nat.Coprime (yn a1 m) (xn a1 (m * (n / m))) :=
-          Nat.Coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
+        have co : Nat.coprime (yn a1 m) (xn a1 (m * (n / m))) :=
+          Nat.coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
         have m0 : 0 < m :=
           m.eq_zero_or_pos.resolve_left fun e => by
             rw [e, Nat.mod_zero] at hp;rw [e] at h
@@ -855,10 +855,10 @@ theorem matiyasevic {a k x y} :
       let v := yn a1 m
       have ky : k ≤ y := yn_ge_n a1 k
       have yv : y * y ∣ v := (ysq_dvd_yy a1 k).trans <| (y_dvd_iff _ _ _).2 <| dvd_mul_left _ _
-      have uco : Nat.Coprime u (4 * y) :=
+      have uco : Nat.coprime u (4 * y) :=
         have : 2 ∣ v :=
           modEq_zero_iff_dvd.1 <| (yn_modEq_two _ _).trans (dvd_mul_right _ _).modEq_zero_nat
-        have : Nat.Coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
+        have : Nat.coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
         (this.mul_right this).mul_right <|
           (xy_coprime _ _).coprime_dvd_right (dvd_of_mul_left_dvd yv)
       let ⟨b, ba, bm1⟩ := chineseRemainder uco a 1
chore: bump to v4.1.0-rc1 (#7174)

Some changes have already been review and delegated in #6910 and #7148.

The diff that needs looking at is https://github.com/leanprover-community/mathlib4/pull/7174/commits/64d6d07ee18163627c8f517eb31455411921c5ac

The std bump PR was insta-merged already!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -391,7 +391,7 @@ theorem yz_sub {m n} (h : n ≤ m) : yz a1 (m - n) = xz a1 n * yz a1 m - xz a1 m
   exact congr_arg Zsqrtd.im (pellZd_sub a1 h)
 #align pell.yz_sub Pell.yz_sub
 
-theorem xy_coprime (n) : (xn a1 n).coprime (yn a1 n) :=
+theorem xy_coprime (n) : (xn a1 n).Coprime (yn a1 n) :=
   Nat.coprime_of_dvd' fun k _ kx ky => by
     let p := pell_eq a1 n
     rw [← p]
@@ -436,8 +436,8 @@ theorem y_dvd_iff (m n) : yn a1 m ∣ yn a1 n ↔ m ∣ n :=
   ⟨fun h =>
     Nat.dvd_of_mod_eq_zero <|
       (Nat.eq_zero_or_pos _).resolve_right fun hp => by
-        have co : Nat.coprime (yn a1 m) (xn a1 (m * (n / m))) :=
-          Nat.coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
+        have co : Nat.Coprime (yn a1 m) (xn a1 (m * (n / m))) :=
+          Nat.Coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
         have m0 : 0 < m :=
           m.eq_zero_or_pos.resolve_left fun e => by
             rw [e, Nat.mod_zero] at hp;rw [e] at h
@@ -855,10 +855,10 @@ theorem matiyasevic {a k x y} :
       let v := yn a1 m
       have ky : k ≤ y := yn_ge_n a1 k
       have yv : y * y ∣ v := (ysq_dvd_yy a1 k).trans <| (y_dvd_iff _ _ _).2 <| dvd_mul_left _ _
-      have uco : Nat.coprime u (4 * y) :=
+      have uco : Nat.Coprime u (4 * y) :=
         have : 2 ∣ v :=
           modEq_zero_iff_dvd.1 <| (yn_modEq_two _ _).trans (dvd_mul_right _ _).modEq_zero_nat
-        have : Nat.coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
+        have : Nat.Coprime u 2 := (xy_coprime a1 m).coprime_dvd_right this
         (this.mul_right this).mul_right <|
           (xy_coprime _ _).coprime_dvd_right (dvd_of_mul_left_dvd yv)
       let ⟨b, ba, bm1⟩ := chineseRemainder uco a 1
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,17 +2,14 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module number_theory.pell_matiyasevic
-! leanprover-community/mathlib commit 795b501869b9fa7aa716d5fdadd00c03f983a605
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Algebra.Star.Unitary
 import Mathlib.Data.Nat.ModEq
 import Mathlib.NumberTheory.Zsqrtd.Basic
 import Mathlib.Tactic.Monotonicity
 
+#align_import number_theory.pell_matiyasevic from "leanprover-community/mathlib"@"795b501869b9fa7aa716d5fdadd00c03f983a605"
+
 /-!
 # Pell's equation and Matiyasevic's theorem
 
chore: remove occurrences of semicolon after space (#5713)

This is the second half of the changes originally in #5699, removing all occurrences of ; after a space and implementing a linter rule to enforce it.

In most cases this 2-character substring has a space after it, so the following command was run first:

find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;

The remaining cases were few enough in number that they were done manually.

Diff
@@ -664,7 +664,7 @@ theorem eq_of_xn_modEq_lem2 {n} (h : 2 * xn a1 n = xn a1 (n + 1)) : a = 2 ∧ n
         (lt_of_le_of_lt (Nat.mul_le_mul_left _ a1)
           (Nat.lt_add_of_pos_right <| mul_pos (d_pos a1) (strictMono_y a1 np)))
         h
-  cases this ; simp at h; exact ⟨h.symm, rfl⟩
+  cases this; simp at h; exact ⟨h.symm, rfl⟩
 #align pell.eq_of_xn_modeq_lem2 Pell.eq_of_xn_modEq_lem2
 
 theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
chore: fix focusing dots (#5708)

This PR is the result of running

find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;

which firstly replaces . focusing dots with · and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.

Diff
@@ -809,7 +809,7 @@ theorem modEq_of_xn_modEq {i j n} (ipos : 0 < i) (hin : i ≤ n)
   have jj : j ≡ j' [MOD 4 * n] := by delta ModEq; rw [Nat.mod_eq_of_lt jl]
   have : ∀ j q, xn a1 (j + 4 * n * q) ≡ xn a1 j [MOD xn a1 n] := by
     intro j q; induction' q with q IH
-    . simp [ModEq.refl]
+    · simp [ModEq.refl]
     rw [Nat.mul_succ, ← add_assoc, add_comm]
     exact (xn_modEq_x4n_add _ _ _).trans IH
   Or.imp (fun ji : j' = i => by rwa [← ji])
chore: clean up spacing around at and goals (#5387)

Changes are of the form

  • some_tactic at h⊢ -> some_tactic at h ⊢
  • some_tactic at h -> some_tactic at h
Diff
@@ -255,7 +255,7 @@ instance dnsq : Zsqrtd.Nonsquare (d a1) :=
     have na : n < a := Nat.mul_self_lt_mul_self_iff.2 (by rw [← this]; exact Nat.lt_succ_self _)
     have : (n + 1) * (n + 1) ≤ n * n + 1 := by rw [this]; exact Nat.mul_self_le_mul_self na
     have : n + n ≤ 0 :=
-      @Nat.le_of_add_le_add_right _ (n * n + 1) _ (by ring_nf  at this⊢; assumption)
+      @Nat.le_of_add_le_add_right _ (n * n + 1) _ (by ring_nf at this ⊢; assumption)
     Nat.ne_of_gt (d_pos a1) <| by
       rwa [Nat.eq_zero_of_le_zero ((Nat.le_add_left _ _).trans this)] at h⟩
 #align pell.dnsq Pell.dnsq
chore: formatting issues (#4947)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -944,7 +944,7 @@ theorem eq_pow_of_pell_lem {a y k : ℕ} (hy0 : y ≠ 0) (hk0 : k ≠ 0) (hyk :
 
 theorem eq_pow_of_pell {m n k} :
     n ^ k = m ↔ k = 0 ∧ m = 1 ∨0 < k ∧ (n = 0 ∧ m = 0 ∨
-      0 < n ∧ ∃ (w a t z : ℕ)(a1 : 1 < a), xn a1 k ≡ yn a1 k * (a - n) + m [MOD t] ∧
+      0 < n ∧ ∃ (w a t z : ℕ) (a1 : 1 < a), xn a1 k ≡ yn a1 k * (a - n) + m [MOD t] ∧
       2 * a * n = t + (n * n + 1) ∧ m < t ∧
       n ≤ w ∧ k ≤ w ∧ a * a - ((w + 1) * (w + 1) - 1) * (w * z) * (w * z) = 1) := by
   constructor
chore: update std 05-22 (#4248)

The main breaking change is that tac <;> [t1, t2] is now written tac <;> [t1; t2], to avoid clashing with tactics like cases and use that take comma-separated lists.

Diff
@@ -525,7 +525,7 @@ theorem xy_succ_succ (n) :
   have := pellZd_succ_succ a1 n; unfold pellZd at this
   erw [Zsqrtd.smul_val (2 * a : ℕ)] at this
   injection this with h₁ h₂
-  constructor <;> apply Int.ofNat.inj <;> [simpa using h₁, simpa using h₂]
+  constructor <;> apply Int.ofNat.inj <;> [simpa using h₁; simpa using h₂]
 #align pell.xy_succ_succ Pell.xy_succ_succ
 
 theorem xn_succ_succ (n) : xn a1 (n + 2) + xn a1 n = 2 * a * xn a1 (n + 1) :=
chore: bye-bye, solo bys! (#3825)

This PR puts, with one exception, every single remaining by that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh. The exception is when the by begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.

Essentially this is s/\n *by$/ by/g, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated bys".

Diff
@@ -438,8 +438,7 @@ theorem y_mul_dvd (n) : ∀ k, yn a1 n ∣ yn a1 (n * k)
 theorem y_dvd_iff (m n) : yn a1 m ∣ yn a1 n ↔ m ∣ n :=
   ⟨fun h =>
     Nat.dvd_of_mod_eq_zero <|
-      (Nat.eq_zero_or_pos _).resolve_right fun hp =>
-        by
+      (Nat.eq_zero_or_pos _).resolve_right fun hp => by
         have co : Nat.coprime (yn a1 m) (xn a1 (m * (n / m))) :=
           Nat.coprime.symm <| (xy_coprime a1 _).coprime_dvd_right (y_mul_dvd a1 m (n / m))
         have m0 : 0 < m :=
@@ -478,8 +477,7 @@ theorem xy_modEq_yn (n) :
       ModEq.add
           (by
             rw [_root_.pow_succ']
-            exact hx.mul_right' _) <|
-        by
+            exact hx.mul_right' _) <| by
         have : k * xn a1 n ^ (k - 1) * yn a1 n * xn a1 n = k * xn a1 n ^ k * yn a1 n := by
           cases' k with k <;> simp [_root_.pow_succ']; ring_nf
         rw [← this]
@@ -497,8 +495,7 @@ theorem ysq_dvd_yy (n) : yn a1 n * yn a1 n ∣ yn a1 (n * yn a1 n) :=
 
 theorem dvd_of_ysq_dvd {n t} (h : yn a1 n * yn a1 n ∣ yn a1 t) : yn a1 n ∣ t :=
   have nt : n ∣ t := (y_dvd_iff a1 n t).1 <| dvd_of_mul_left_dvd h
-  n.eq_zero_or_pos.elim (fun n0 => by rwa [n0] at nt⊢) fun n0l : 0 < n =>
-    by
+  n.eq_zero_or_pos.elim (fun n0 => by rwa [n0] at nt ⊢) fun n0l : 0 < n => by
     let ⟨k, ke⟩ := nt
     have : yn a1 n ∣ k * xn a1 n ^ (k - 1) :=
       Nat.dvd_of_mul_dvd_mul_right (strictMono_y a1 n0l) <|
@@ -551,8 +548,7 @@ theorem yn_modEq_a_sub_one : ∀ n, yn a1 n ≡ n [MOD a - 1]
   | 0 => by simp [Nat.ModEq.refl]
   | 1 => by simp [Nat.ModEq.refl]
   | n + 2 =>
-    (yn_modEq_a_sub_one n).add_right_cancel <|
-      by
+    (yn_modEq_a_sub_one n).add_right_cancel <| by
       rw [yn_succ_succ, (by ring : n + 2 + n = 2 * (n + 1))]
       exact ((modEq_sub a1.le).mul_left 2).mul (yn_modEq_a_sub_one (n + 1))
 #align pell.yn_modeq_a_sub_one Pell.yn_modEq_a_sub_one
@@ -561,8 +557,7 @@ theorem yn_modEq_two : ∀ n, yn a1 n ≡ n [MOD 2]
   | 0 => by simp
   | 1 => by simp
   | n + 2 =>
-    (yn_modEq_two n).add_right_cancel <|
-      by
+    (yn_modEq_two n).add_right_cancel <| by
       rw [yn_succ_succ, mul_assoc, (by ring : n + 2 + n = 2 * (n + 1))]
       exact (dvd_mul_right 2 _).modEq_zero_nat.trans (dvd_mul_right 2 _).zero_modEq_nat
 #align pell.yn_modeq_two Pell.yn_modEq_two
@@ -581,11 +576,9 @@ theorem x_sub_y_dvd_pow (y : ℕ) :
     ∀ n, (2 * a * y - y * y - 1 : ℤ) ∣ yz a1 n * (a - y) + ↑(y ^ n) - xz a1 n
   | 0 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one]
   | 1 => by simp [xz, yz, Int.ofNat_zero, Int.ofNat_one]
-  | n + 2 =>
-    by
+  | n + 2 => by
     have : (2 * a * y - y * y - 1 : ℤ) ∣ ↑(y ^ (n + 2)) - ↑(2 * a) * ↑(y ^ (n + 1)) + ↑(y ^ n) :=
-      ⟨-↑(y ^ n),
-        by
+      ⟨-↑(y ^ n), by
         simp [_root_.pow_succ, mul_add, Int.ofNat_mul, show ((2 : ℕ) : ℤ) = 2 from rfl, mul_comm,
           mul_left_comm]
         ring⟩
@@ -653,8 +646,7 @@ theorem xn_modEq_x4n_sub {n j} (h : j ≤ 2 * n) : xn a1 (4 * n - j) ≡ xn a1 j
 
 theorem eq_of_xn_modEq_lem1 {i n} : ∀ {j}, i < j → j < n → xn a1 i % xn a1 n < xn a1 j % xn a1 n
   | 0, ij, _ => absurd ij (Nat.not_lt_zero _)
-  | j + 1, ij, jn =>
-    by
+  | j + 1, ij, jn => by
     suffices xn a1 j % xn a1 n < xn a1 (j + 1) % xn a1 n from
       (lt_or_eq_of_le (Nat.le_of_succ_le_succ ij)).elim
         (fun h => lt_trans (eq_of_xn_modEq_lem1 h (le_of_lt jn)) this) fun h => by
@@ -708,8 +700,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
           refine' lt_sub_left_of_add_lt (Int.ofNat_lt_ofNat_of_lt _)
           cases' lt_or_eq_of_le <| Nat.le_of_succ_le_succ ij with lin ein
           · rw [Nat.mod_eq_of_lt (strictMono_x _ lin)]
-            have ll : xn a1 (n - 1) + xn a1 (n - 1) ≤ xn a1 n :=
-              by
+            have ll : xn a1 (n - 1) + xn a1 (n - 1) ≤ xn a1 n := by
               rw [← two_mul, mul_comm,
                 show xn a1 n = xn a1 (n - 1 + 1) by rw [tsub_add_cancel_of_le (succ_le_of_lt npos)],
                 xn_succ]
@@ -725,8 +716,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
               apply lt_of_le_of_ne ll
               rw [← two_mul]
               exact fun e =>
-                ntriv <|
-                  by
+                ntriv <| by
                   let ⟨a2, s1⟩ :=
                     @eq_of_xn_modEq_lem2 _ a1 (n - 1)
                       (by rwa [tsub_add_cancel_of_le (succ_le_of_lt npos)])
@@ -747,8 +737,7 @@ theorem eq_of_xn_modEq_lem3 {i n} (npos : 0 < n) :
                 s)
             fun h => by rw [h]; exact s
         lem1 (_root_.ne_of_gt jn) <|
-          Int.lt_of_ofNat_lt_ofNat <|
-            by
+          Int.lt_of_ofNat_lt_ofNat <| by
             rw [lem2 j jn (le_of_lt j2n), lem2 (j + 1) (Nat.le_succ_of_le jn) j2n]
             refine' sub_lt_sub_left (Int.ofNat_lt_ofNat_of_lt <| strictMono_x _ _) _
             rw [Nat.sub_succ]
@@ -806,8 +795,7 @@ theorem eq_of_xn_modEq' {i j n} (ipos : 0 < i) (hin : i ≤ n) (j4n : j ≤ 4 *
         let t := xn_modEq_x4n_sub a1 j42n
         rwa [tsub_tsub_cancel_of_le j4n] at t)
       fun a2 n1 =>
-      ⟨fun i0 => absurd i0 (_root_.ne_of_gt ipos), fun i2 =>
-        by
+      ⟨fun i0 => absurd i0 (_root_.ne_of_gt ipos), fun i2 => by
         rw [n1, i2] at hin
         exact absurd hin (by decide)⟩
 #align pell.eq_of_xn_modeq' Pell.eq_of_xn_modEq'
@@ -819,8 +807,7 @@ theorem modEq_of_xn_modEq {i j n} (ipos : 0 < i) (hin : i ≤ n)
   have n4 : 0 < 4 * n := mul_pos (by decide) (ipos.trans_le hin)
   have jl : j' < 4 * n := Nat.mod_lt _ n4
   have jj : j ≡ j' [MOD 4 * n] := by delta ModEq; rw [Nat.mod_eq_of_lt jl]
-  have : ∀ j q, xn a1 (j + 4 * n * q) ≡ xn a1 j [MOD xn a1 n] :=
-    by
+  have : ∀ j q, xn a1 (j + 4 * n * q) ≡ xn a1 j [MOD xn a1 n] := by
     intro j q; induction' q with q IH
     . simp [ModEq.refl]
     rw [Nat.mul_succ, ← add_assoc, add_comm]
@@ -843,12 +830,10 @@ theorem xy_modEq_of_modEq {a b c} (a1 : 1 < a) (b1 : 1 < b) (h : a ≡ b [MOD c]
   | 0 => by constructor <;> rfl
   | 1 => by simp; exact ⟨h, ModEq.refl 1⟩
   | n + 2 =>
-    ⟨(xy_modEq_of_modEq a1 b1 h n).left.add_right_cancel <|
-        by
+    ⟨(xy_modEq_of_modEq a1 b1 h n).left.add_right_cancel <| by
         rw [xn_succ_succ a1, xn_succ_succ b1]
         exact (h.mul_left _).mul (xy_modEq_of_modEq _ _ h (n + 1)).left,
-      (xy_modEq_of_modEq _ _ h n).right.add_right_cancel <|
-        by
+      (xy_modEq_of_modEq _ _ h n).right.add_right_cancel <| by
         rw [yn_succ_succ a1, yn_succ_succ b1]
         exact (h.mul_left _).mul (xy_modEq_of_modEq _ _ h (n + 1)).right⟩
 #align pell.xy_modeq_of_modeq Pell.xy_modEq_of_modEq
@@ -946,8 +931,7 @@ theorem eq_pow_of_pell_lem {a y k : ℕ} (hy0 : y ≠ 0) (hk0 : k ≠ 0) (hyk :
   have hya : y < a := (Nat.le_self_pow hk0 _).trans_lt hyk
   calc
     (↑(y ^ k) : ℤ) < a := Nat.cast_lt.2 hyk
-    _ ≤ (a : ℤ) ^ 2 - (a - 1 : ℤ) ^ 2 - 1 :=
-      by
+    _ ≤ (a : ℤ) ^ 2 - (a - 1 : ℤ) ^ 2 - 1 := by
       rw [sub_sq, mul_one, one_pow, sub_add, sub_sub_cancel, two_mul, sub_sub, ← add_sub,
         le_add_iff_nonneg_right, sub_nonneg, Int.add_one_le_iff]
       norm_cast
@@ -979,8 +963,7 @@ theorem eq_pow_of_pell {m n k} :
     set y := yn a1 k
     obtain ⟨z, ze⟩ : w ∣ yn w1 w
     exact modEq_zero_iff_dvd.1 ((yn_modEq_a_sub_one w1 w).trans dvd_rfl.modEq_zero_nat)
-    have nt : (↑(n ^ k) : ℤ) < 2 * a * n - n * n - 1 :=
-      by
+    have nt : (↑(n ^ k) : ℤ) < 2 * a * n - n * n - 1 := by
       refine' eq_pow_of_pell_lem hn.ne' hk.ne' _
       calc
         n ^ k ≤ n ^ w := Nat.pow_le_pow_of_le_right hn kw
@@ -1019,8 +1002,7 @@ theorem eq_pow_of_pell {m n k} :
     have nt : (↑(n ^ k) : ℤ) < 2 * xn hw1 j * n - n * n - 1 :=
       eq_pow_of_pell_lem hn0.ne' hk0.ne' hnka
     have na : n ≤ xn hw1 j := (Nat.le_self_pow hk0.ne' _).trans hnka.le
-    have te : (t : ℤ) = 2 * xn hw1 j * n - n * n - 1 :=
-      by
+    have te : (t : ℤ) = 2 * xn hw1 j * n - n * n - 1 := by
       rw [sub_sub, eq_sub_iff_add_eq]
       exact_mod_cast ta.symm
     have : xn a1 k ≡ yn a1 k * (xn hw1 j - n) + n ^ k [MOD t] := by
chore: fix #align lines (#3640)

This PR fixes two things:

  • Most align statements for definitions and theorems and instances that are separated by two newlines from the relevant declaration (s/\n\n#align/\n#align). This is often seen in the mathport output after ending calc blocks.
  • All remaining more-than-one-line #align statements. (This was needed for a script I wrote for #3630.)
Diff
@@ -520,7 +520,6 @@ theorem pellZd_succ_succ (n) :
     dsimp
     constructor <;> ring_nf
   simpa [mul_add, mul_comm, mul_left_comm, add_comm] using congr_arg (· * pellZd a1 n) this
-
 #align pell.pell_zd_succ_succ Pell.pellZd_succ_succ
 
 theorem xy_succ_succ (n) :
@@ -957,7 +956,6 @@ theorem eq_pow_of_pell_lem {a y k : ℕ} (hy0 : y ≠ 0) (hk0 : k ≠ 0) (hyk :
       have := hya.le
       mono * <;> norm_cast <;> simp [Nat.zero_le, Nat.succ_le_of_lt (Nat.pos_of_ne_zero hy0)]
     _ = 2 * a * y - y * y - 1 := by ring
-
 #align pell.eq_pow_of_pell_lem Pell.eq_pow_of_pell_lem
 
 theorem eq_pow_of_pell {m n k} :
feat: port NumberTheory.PellMatiyasevic (#3083)

Co-authored-by: Scott Morrison <scott@tqft.net>

Dependencies 8 + 479

480 files ported (98.4%)
198756 lines ported (98.5%)
Show graph

The unported dependencies are