data.pnat.xgcdMathlib.Data.PNat.Xgcd

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)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(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
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Neil Strickland
 -/
 import Tactic.Ring
-import Data.Pnat.Prime
+import Data.PNat.Prime
 
 #align_import data.pnat.xgcd from "leanprover-community/mathlib"@"f2f413b9d4be3a02840d0663dace76e8fe3da053"
 
Diff
@@ -170,8 +170,8 @@ theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' :=
     repeat' rw [Nat.succ_eq_add_one]; ring
   · apply Nat.succ.inj
     replace h := congr_arg (coe : ℕ+ → ℕ) h
-    rw [mul_coe, w, z] at h 
-    repeat' rw [succ_pnat_coe, Nat.succ_eq_add_one] at h 
+    rw [mul_coe, w, z] at h
+    repeat' rw [succ_pnat_coe, Nat.succ_eq_add_one] at h
     repeat' rw [Nat.succ_eq_add_one]; rw [← h]; ring
 #align pnat.xgcd_type.is_special_iff PNat.XgcdType.isSpecial_iff
 -/
@@ -279,7 +279,7 @@ theorem rq_eq : u.R + (u.bp + 1) * u.q = u.ap + 1 :=
 theorem qp_eq (hr : u.R = 0) : u.q = u.qp + 1 :=
   by
   by_cases hq : u.q = 0
-  · let h := u.rq_eq; rw [hr, hq, MulZeroClass.mul_zero, add_zero] at h ; cases h
+  · let h := u.rq_eq; rw [hr, hq, MulZeroClass.mul_zero, add_zero] at h; cases h
   · exact (Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hq)).symm
 #align pnat.xgcd_type.qp_eq PNat.XgcdType.qp_eq
 -/
@@ -334,7 +334,7 @@ theorem finish_isSpecial (hs : u.IsSpecial) : u.finish.IsSpecial :=
 theorem finish_v (hr : u.R = 0) : u.finish.V = u.V :=
   by
   let ha : u.r + u.b * u.q = u.a := u.rq_eq
-  rw [hr, zero_add] at ha 
+  rw [hr, zero_add] at ha
   ext
   · change (u.wp + 1) * u.b + ((u.wp + 1) * u.qp + u.x) * u.b = u.w * u.a + u.x * u.b
     have : u.wp + 1 = u.w := rfl; rw [this, ← ha, u.qp_eq hr]; ring
@@ -359,7 +359,7 @@ theorem step_wf (hr : u.R ≠ 0) : SizeOf.sizeOf u.step < SizeOf.sizeOf u :=
   change u.r - 1 < u.bp
   have h₀ : u.r - 1 + 1 = u.r := Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hr)
   have h₁ : u.r < u.bp + 1 := Nat.mod_lt (u.ap + 1) u.bp.succ_pos
-  rw [← h₀] at h₁ 
+  rw [← h₀] at h₁
   exact lt_of_succ_lt_succ h₁
 #align pnat.xgcd_type.step_wf PNat.XgcdType.step_wf
 -/
@@ -557,7 +557,7 @@ theorem gcd_props :
   have huv : u.v = ⟨a, b⟩ := xgcd_type.start_v a b
   let hv : Prod.mk (w * d + x * ur.b : ℕ) (y * d + z * ur.b : ℕ) = ⟨a, b⟩ :=
     u.reduce_v.trans (xgcd_type.start_v a b)
-  rw [← hb, ← add_mul, ← add_mul, ← ha', ← hb'] at hv 
+  rw [← hb, ← add_mul, ← add_mul, ← ha', ← hb'] at hv
   have ha'' : (a : ℕ) = a' * d := (congr_arg Prod.fst hv).symm
   have hb'' : (b : ℕ) = b' * d := (congr_arg Prod.snd hv).symm
   constructor; exact Eq ha''; constructor; exact Eq hb''
@@ -583,7 +583,7 @@ theorem gcd_eq : gcdD a b = gcd a b :=
     exact Dvd.intro (gcd_b' a b) (h₂.trans (mul_comm _ _)).symm
   · have h₇ : (gcd a b : ℕ) ∣ gcd_z a b * a := (Nat.gcd_dvd_left a b).trans (dvd_mul_left _ _)
     have h₈ : (gcd a b : ℕ) ∣ gcd_x a b * b := (Nat.gcd_dvd_right a b).trans (dvd_mul_left _ _)
-    rw [h₅] at h₇ ; rw [dvd_iff]
+    rw [h₅] at h₇; rw [dvd_iff]
     exact (Nat.dvd_add_iff_right h₈).mpr h₇
 #align pnat.gcd_eq PNat.gcd_eq
 -/
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2019 Neil Strickland. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Neil Strickland
 -/
-import Mathbin.Tactic.Ring
-import Mathbin.Data.Pnat.Prime
+import Tactic.Ring
+import Data.Pnat.Prime
 
 #align_import data.pnat.xgcd from "leanprover-community/mathlib"@"f2f413b9d4be3a02840d0663dace76e8fe3da053"
 
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2019 Neil Strickland. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Neil Strickland
-
-! This file was ported from Lean 3 source module data.pnat.xgcd
-! leanprover-community/mathlib commit f2f413b9d4be3a02840d0663dace76e8fe3da053
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Tactic.Ring
 import Mathbin.Data.Pnat.Prime
 
+#align_import data.pnat.xgcd from "leanprover-community/mathlib"@"f2f413b9d4be3a02840d0663dace76e8fe3da053"
+
 /-!
 # Euclidean algorithm for ℕ
 
Diff
@@ -532,6 +532,7 @@ theorem gcdB'_coe : (gcdB' a b : ℕ) = gcdY a b + gcdZ a b :=
 #align pnat.gcd_b'_coe PNat.gcdB'_coe
 -/
 
+#print PNat.gcd_props /-
 theorem gcd_props :
     let d := gcdD a b
     let w := gcdW a b
@@ -573,6 +574,7 @@ theorem gcd_props :
   rw [ha'', hb'']; repeat' rw [← mul_assoc]; rw [hza', hwb']
   constructor <;> ring
 #align pnat.gcd_props PNat.gcd_props
+-/
 
 #print PNat.gcd_eq /-
 theorem gcd_eq : gcdD a b = gcd a b :=
@@ -589,25 +591,35 @@ theorem gcd_eq : gcdD a b = gcd a b :=
 #align pnat.gcd_eq PNat.gcd_eq
 -/
 
+#print PNat.gcd_det_eq /-
 theorem gcd_det_eq : gcdW a b * gcdZ a b = succPNat (gcdX a b * gcdY a b) :=
   (gcd_props a b).1
 #align pnat.gcd_det_eq PNat.gcd_det_eq
+-/
 
+#print PNat.gcd_a_eq /-
 theorem gcd_a_eq : a = gcdA' a b * gcd a b :=
   gcd_eq a b ▸ (gcd_props a b).2.1
 #align pnat.gcd_a_eq PNat.gcd_a_eq
+-/
 
+#print PNat.gcd_b_eq /-
 theorem gcd_b_eq : b = gcdB' a b * gcd a b :=
   gcd_eq a b ▸ (gcd_props a b).2.2.1
 #align pnat.gcd_b_eq PNat.gcd_b_eq
+-/
 
+#print PNat.gcd_rel_left' /-
 theorem gcd_rel_left' : gcdZ a b * gcdA' a b = succPNat (gcdX a b * gcdB' a b) :=
   (gcd_props a b).2.2.2.1
 #align pnat.gcd_rel_left' PNat.gcd_rel_left'
+-/
 
+#print PNat.gcd_rel_right' /-
 theorem gcd_rel_right' : gcdW a b * gcdB' a b = succPNat (gcdY a b * gcdA' a b) :=
   (gcd_props a b).2.2.2.2.1
 #align pnat.gcd_rel_right' PNat.gcd_rel_right'
+-/
 
 #print PNat.gcd_rel_left /-
 theorem gcd_rel_left : (gcdZ a b * a : ℕ) = gcdX a b * b + gcd a b :=
Diff
@@ -173,8 +173,8 @@ theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' :=
     repeat' rw [Nat.succ_eq_add_one]; ring
   · apply Nat.succ.inj
     replace h := congr_arg (coe : ℕ+ → ℕ) h
-    rw [mul_coe, w, z] at h
-    repeat' rw [succ_pnat_coe, Nat.succ_eq_add_one] at h
+    rw [mul_coe, w, z] at h 
+    repeat' rw [succ_pnat_coe, Nat.succ_eq_add_one] at h 
     repeat' rw [Nat.succ_eq_add_one]; rw [← h]; ring
 #align pnat.xgcd_type.is_special_iff PNat.XgcdType.isSpecial_iff
 -/
@@ -282,7 +282,7 @@ theorem rq_eq : u.R + (u.bp + 1) * u.q = u.ap + 1 :=
 theorem qp_eq (hr : u.R = 0) : u.q = u.qp + 1 :=
   by
   by_cases hq : u.q = 0
-  · let h := u.rq_eq; rw [hr, hq, MulZeroClass.mul_zero, add_zero] at h; cases h
+  · let h := u.rq_eq; rw [hr, hq, MulZeroClass.mul_zero, add_zero] at h ; cases h
   · exact (Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hq)).symm
 #align pnat.xgcd_type.qp_eq PNat.XgcdType.qp_eq
 -/
@@ -327,7 +327,7 @@ theorem finish_isReduced : u.finish.IsReduced := by dsimp [IsReduced]; rfl
 #print PNat.XgcdType.finish_isSpecial /-
 theorem finish_isSpecial (hs : u.IsSpecial) : u.finish.IsSpecial :=
   by
-  dsimp [is_special, finish] at hs⊢
+  dsimp [is_special, finish] at hs ⊢
   rw [add_mul _ _ u.y, add_comm _ (u.x * u.y), ← hs]
   ring
 #align pnat.xgcd_type.finish_is_special PNat.XgcdType.finish_isSpecial
@@ -337,7 +337,7 @@ theorem finish_isSpecial (hs : u.IsSpecial) : u.finish.IsSpecial :=
 theorem finish_v (hr : u.R = 0) : u.finish.V = u.V :=
   by
   let ha : u.r + u.b * u.q = u.a := u.rq_eq
-  rw [hr, zero_add] at ha
+  rw [hr, zero_add] at ha 
   ext
   · change (u.wp + 1) * u.b + ((u.wp + 1) * u.qp + u.x) * u.b = u.w * u.a + u.x * u.b
     have : u.wp + 1 = u.w := rfl; rw [this, ← ha, u.qp_eq hr]; ring
@@ -362,7 +362,7 @@ theorem step_wf (hr : u.R ≠ 0) : SizeOf.sizeOf u.step < SizeOf.sizeOf u :=
   change u.r - 1 < u.bp
   have h₀ : u.r - 1 + 1 = u.r := Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hr)
   have h₁ : u.r < u.bp + 1 := Nat.mod_lt (u.ap + 1) u.bp.succ_pos
-  rw [← h₀] at h₁
+  rw [← h₀] at h₁ 
   exact lt_of_succ_lt_succ h₁
 #align pnat.xgcd_type.step_wf PNat.XgcdType.step_wf
 -/
@@ -370,7 +370,7 @@ theorem step_wf (hr : u.R ≠ 0) : SizeOf.sizeOf u.step < SizeOf.sizeOf u :=
 #print PNat.XgcdType.step_isSpecial /-
 theorem step_isSpecial (hs : u.IsSpecial) : u.step.IsSpecial :=
   by
-  dsimp [is_special, step] at hs⊢
+  dsimp [is_special, step] at hs ⊢
   rw [mul_add, mul_comm u.y u.x, ← hs]
   ring
 #align pnat.xgcd_type.step_is_special PNat.XgcdType.step_isSpecial
@@ -559,7 +559,7 @@ theorem gcd_props :
   have huv : u.v = ⟨a, b⟩ := xgcd_type.start_v a b
   let hv : Prod.mk (w * d + x * ur.b : ℕ) (y * d + z * ur.b : ℕ) = ⟨a, b⟩ :=
     u.reduce_v.trans (xgcd_type.start_v a b)
-  rw [← hb, ← add_mul, ← add_mul, ← ha', ← hb'] at hv
+  rw [← hb, ← add_mul, ← add_mul, ← ha', ← hb'] at hv 
   have ha'' : (a : ℕ) = a' * d := (congr_arg Prod.fst hv).symm
   have hb'' : (b : ℕ) = b' * d := (congr_arg Prod.snd hv).symm
   constructor; exact Eq ha''; constructor; exact Eq hb''
@@ -584,7 +584,7 @@ theorem gcd_eq : gcdD a b = gcd a b :=
     exact Dvd.intro (gcd_b' a b) (h₂.trans (mul_comm _ _)).symm
   · have h₇ : (gcd a b : ℕ) ∣ gcd_z a b * a := (Nat.gcd_dvd_left a b).trans (dvd_mul_left _ _)
     have h₈ : (gcd a b : ℕ) ∣ gcd_x a b * b := (Nat.gcd_dvd_right a b).trans (dvd_mul_left _ _)
-    rw [h₅] at h₇; rw [dvd_iff]
+    rw [h₅] at h₇ ; rw [dvd_iff]
     exact (Nat.dvd_add_iff_right h₈).mpr h₇
 #align pnat.gcd_eq PNat.gcd_eq
 -/
Diff
@@ -532,12 +532,6 @@ theorem gcdB'_coe : (gcdB' a b : ℕ) = gcdY a b + gcdZ a b :=
 #align pnat.gcd_b'_coe PNat.gcdB'_coe
 -/
 
-/- warning: pnat.gcd_props -> PNat.gcd_props is a dubious translation:
-lean 3 declaration is
-  forall (a : PNat) (b : PNat), let d : PNat := PNat.gcdD a b; let w : PNat := PNat.gcdW a b; let x : Nat := PNat.gcdX a b; let y : Nat := PNat.gcdY a b; let z : PNat := PNat.gcdZ a b; let a' : PNat := PNat.gcdA' a b; let b' : PNat := PNat.gcdB' a b; And (Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) w z) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) x y))) (And (Eq.{1} PNat a (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) a' d)) (And (Eq.{1} PNat b (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) b' d)) (And (Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) z a') (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) b')))) (And (Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) w b') (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) y ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) a')))) (And (Eq.{1} Nat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) z) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) a)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) x ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) b)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) d))) (Eq.{1} Nat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) w) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) b)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) y ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) a)) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) d))))))))
-but is expected to have type
-  forall (a : PNat) (b : PNat), let d : PNat := PNat.gcdD a b; let w : PNat := PNat.gcdW a b; let x : Nat := PNat.gcdX a b; let y : Nat := PNat.gcdY a b; let z : PNat := PNat.gcdZ a b; let a' : PNat := PNat.gcdA' a b; let b' : PNat := PNat.gcdB' a b; And (Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) w z) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) x y))) (And (Eq.{1} PNat a (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) a' d)) (And (Eq.{1} PNat b (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) b' d)) (And (Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) z a') (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) x (PNat.val b')))) (And (Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) w b') (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) y (PNat.val a')))) (And (Eq.{1} Nat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (PNat.val z) (PNat.val a)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) x (PNat.val b)) (PNat.val d))) (Eq.{1} Nat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (PNat.val w) (PNat.val b)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) y (PNat.val a)) (PNat.val d))))))))
-Case conversion may be inaccurate. Consider using '#align pnat.gcd_props PNat.gcd_propsₓ'. -/
 theorem gcd_props :
     let d := gcdD a b
     let w := gcdW a b
@@ -595,52 +589,22 @@ theorem gcd_eq : gcdD a b = gcd a b :=
 #align pnat.gcd_eq PNat.gcd_eq
 -/
 
-/- warning: pnat.gcd_det_eq -> PNat.gcd_det_eq is a dubious translation:
-lean 3 declaration is
-  forall (a : PNat) (b : PNat), Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) (PNat.gcdW a b) (PNat.gcdZ a b)) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (PNat.gcdX a b) (PNat.gcdY a b)))
-but is expected to have type
-  forall (a : PNat) (b : PNat), Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) (PNat.gcdW a b) (PNat.gcdZ a b)) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (PNat.gcdX a b) (PNat.gcdY a b)))
-Case conversion may be inaccurate. Consider using '#align pnat.gcd_det_eq PNat.gcd_det_eqₓ'. -/
 theorem gcd_det_eq : gcdW a b * gcdZ a b = succPNat (gcdX a b * gcdY a b) :=
   (gcd_props a b).1
 #align pnat.gcd_det_eq PNat.gcd_det_eq
 
-/- warning: pnat.gcd_a_eq -> PNat.gcd_a_eq is a dubious translation:
-lean 3 declaration is
-  forall (a : PNat) (b : PNat), Eq.{1} PNat a (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) (PNat.gcdA' a b) (PNat.gcd a b))
-but is expected to have type
-  forall (a : PNat) (b : PNat), Eq.{1} PNat a (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) (PNat.gcdA' a b) (PNat.gcd a b))
-Case conversion may be inaccurate. Consider using '#align pnat.gcd_a_eq PNat.gcd_a_eqₓ'. -/
 theorem gcd_a_eq : a = gcdA' a b * gcd a b :=
   gcd_eq a b ▸ (gcd_props a b).2.1
 #align pnat.gcd_a_eq PNat.gcd_a_eq
 
-/- warning: pnat.gcd_b_eq -> PNat.gcd_b_eq is a dubious translation:
-lean 3 declaration is
-  forall (a : PNat) (b : PNat), Eq.{1} PNat b (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) (PNat.gcdB' a b) (PNat.gcd a b))
-but is expected to have type
-  forall (a : PNat) (b : PNat), Eq.{1} PNat b (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) (PNat.gcdB' a b) (PNat.gcd a b))
-Case conversion may be inaccurate. Consider using '#align pnat.gcd_b_eq PNat.gcd_b_eqₓ'. -/
 theorem gcd_b_eq : b = gcdB' a b * gcd a b :=
   gcd_eq a b ▸ (gcd_props a b).2.2.1
 #align pnat.gcd_b_eq PNat.gcd_b_eq
 
-/- warning: pnat.gcd_rel_left' -> PNat.gcd_rel_left' is a dubious translation:
-lean 3 declaration is
-  forall (a : PNat) (b : PNat), Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) (PNat.gcdZ a b) (PNat.gcdA' a b)) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (PNat.gcdX a b) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) (PNat.gcdB' a b))))
-but is expected to have type
-  forall (a : PNat) (b : PNat), Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) (PNat.gcdZ a b) (PNat.gcdA' a b)) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (PNat.gcdX a b) (PNat.val (PNat.gcdB' a b))))
-Case conversion may be inaccurate. Consider using '#align pnat.gcd_rel_left' PNat.gcd_rel_left'ₓ'. -/
 theorem gcd_rel_left' : gcdZ a b * gcdA' a b = succPNat (gcdX a b * gcdB' a b) :=
   (gcd_props a b).2.2.2.1
 #align pnat.gcd_rel_left' PNat.gcd_rel_left'
 
-/- warning: pnat.gcd_rel_right' -> PNat.gcd_rel_right' is a dubious translation:
-lean 3 declaration is
-  forall (a : PNat) (b : PNat), Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat PNat.hasMul) (PNat.gcdW a b) (PNat.gcdB' a b)) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat Nat.hasMul) (PNat.gcdY a b) ((fun (a : Type) (b : Type) [self : HasLiftT.{1, 1} a b] => self.0) PNat Nat (HasLiftT.mk.{1, 1} PNat Nat (CoeTCₓ.coe.{1, 1} PNat Nat (coeBase.{1, 1} PNat Nat coePNatNat))) (PNat.gcdA' a b))))
-but is expected to have type
-  forall (a : PNat) (b : PNat), Eq.{1} PNat (HMul.hMul.{0, 0, 0} PNat PNat PNat (instHMul.{0} PNat instPNatMul) (PNat.gcdW a b) (PNat.gcdB' a b)) (Nat.succPNat (HMul.hMul.{0, 0, 0} Nat Nat Nat (instHMul.{0} Nat instMulNat) (PNat.gcdY a b) (PNat.val (PNat.gcdA' a b))))
-Case conversion may be inaccurate. Consider using '#align pnat.gcd_rel_right' PNat.gcd_rel_right'ₓ'. -/
 theorem gcd_rel_right' : gcdW a b * gcdB' a b = succPNat (gcdY a b * gcdA' a b) :=
   (gcd_props a b).2.2.2.2.1
 #align pnat.gcd_rel_right' PNat.gcd_rel_right'
Diff
@@ -169,18 +169,13 @@ theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' :=
   by
   dsimp [is_special, is_special']
   constructor <;> intro h
-  · apply Eq
-    dsimp [w, z, succ_pnat]
-    rw [← h]
-    repeat' rw [Nat.succ_eq_add_one]
-    ring
+  · apply Eq; dsimp [w, z, succ_pnat]; rw [← h]
+    repeat' rw [Nat.succ_eq_add_one]; ring
   · apply Nat.succ.inj
     replace h := congr_arg (coe : ℕ+ → ℕ) h
     rw [mul_coe, w, z] at h
     repeat' rw [succ_pnat_coe, Nat.succ_eq_add_one] at h
-    repeat' rw [Nat.succ_eq_add_one]
-    rw [← h]
-    ring
+    repeat' rw [Nat.succ_eq_add_one]; rw [← h]; ring
 #align pnat.xgcd_type.is_special_iff PNat.XgcdType.isSpecial_iff
 -/
 
@@ -260,29 +255,19 @@ theorem flip_b : (flip u).b = u.a :=
 -/
 
 #print PNat.XgcdType.flip_isReduced /-
-theorem flip_isReduced : (flip u).IsReduced ↔ u.IsReduced :=
-  by
-  dsimp [IsReduced, flip]
+theorem flip_isReduced : (flip u).IsReduced ↔ u.IsReduced := by dsimp [IsReduced, flip];
   constructor <;> intro h <;> exact h.symm
 #align pnat.xgcd_type.flip_is_reduced PNat.XgcdType.flip_isReduced
 -/
 
 #print PNat.XgcdType.flip_isSpecial /-
-theorem flip_isSpecial : (flip u).IsSpecial ↔ u.IsSpecial :=
-  by
-  dsimp [is_special, flip]
+theorem flip_isSpecial : (flip u).IsSpecial ↔ u.IsSpecial := by dsimp [is_special, flip];
   rw [mul_comm u.x, mul_comm u.zp, add_comm u.zp]
 #align pnat.xgcd_type.flip_is_special PNat.XgcdType.flip_isSpecial
 -/
 
 #print PNat.XgcdType.flip_v /-
-theorem flip_v : (flip u).V = u.V.symm := by
-  dsimp [v]
-  ext
-  · simp only
-    ring
-  · simp only
-    ring
+theorem flip_v : (flip u).V = u.V.symm := by dsimp [v]; ext; · simp only; ring; · simp only; ring
 #align pnat.xgcd_type.flip_v PNat.XgcdType.flip_v
 -/
 
@@ -297,9 +282,7 @@ theorem rq_eq : u.R + (u.bp + 1) * u.q = u.ap + 1 :=
 theorem qp_eq (hr : u.R = 0) : u.q = u.qp + 1 :=
   by
   by_cases hq : u.q = 0
-  · let h := u.rq_eq
-    rw [hr, hq, MulZeroClass.mul_zero, add_zero] at h
-    cases h
+  · let h := u.rq_eq; rw [hr, hq, MulZeroClass.mul_zero, add_zero] at h; cases h
   · exact (Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hq)).symm
 #align pnat.xgcd_type.qp_eq PNat.XgcdType.qp_eq
 -/
@@ -316,10 +299,7 @@ def start (a b : ℕ+) : XgcdType :=
 -/
 
 #print PNat.XgcdType.start_isSpecial /-
-theorem start_isSpecial (a b : ℕ+) : (start a b).IsSpecial :=
-  by
-  dsimp [start, is_special]
-  rfl
+theorem start_isSpecial (a b : ℕ+) : (start a b).IsSpecial := by dsimp [start, is_special]; rfl
 #align pnat.xgcd_type.start_is_special PNat.XgcdType.start_isSpecial
 -/
 
@@ -340,10 +320,7 @@ def finish : XgcdType :=
 -/
 
 #print PNat.XgcdType.finish_isReduced /-
-theorem finish_isReduced : u.finish.IsReduced :=
-  by
-  dsimp [IsReduced]
-  rfl
+theorem finish_isReduced : u.finish.IsReduced := by dsimp [IsReduced]; rfl
 #align pnat.xgcd_type.finish_is_reduced PNat.XgcdType.finish_isReduced
 -/
 
@@ -363,12 +340,9 @@ theorem finish_v (hr : u.R = 0) : u.finish.V = u.V :=
   rw [hr, zero_add] at ha
   ext
   · change (u.wp + 1) * u.b + ((u.wp + 1) * u.qp + u.x) * u.b = u.w * u.a + u.x * u.b
-    have : u.wp + 1 = u.w := rfl
-    rw [this, ← ha, u.qp_eq hr]
-    ring
+    have : u.wp + 1 = u.w := rfl; rw [this, ← ha, u.qp_eq hr]; ring
   · change u.y * u.b + (u.y * u.qp + u.z) * u.b = u.y * u.a + u.z * u.b
-    rw [← ha, u.qp_eq hr]
-    ring
+    rw [← ha, u.qp_eq hr]; ring
 #align pnat.xgcd_type.finish_v PNat.XgcdType.finish_v
 -/
 
@@ -410,11 +384,9 @@ theorem step_v (hr : u.R ≠ 0) : u.step.V = u.V.symm :=
   let hr : u.r - 1 + 1 = u.r := (add_comm _ 1).trans (add_tsub_cancel_of_le (Nat.pos_of_ne_zero hr))
   ext
   · change ((u.y * u.q + u.z) * u.b + u.y * (u.r - 1 + 1) : ℕ) = u.y * u.a + u.z * u.b
-    rw [← ha, hr]
-    ring
+    rw [← ha, hr]; ring
   · change ((u.w * u.q + u.x) * u.b + u.w * (u.r - 1 + 1) : ℕ) = u.w * u.a + u.x * u.b
-    rw [← ha, hr]
-    ring
+    rw [← ha, hr]; ring
 #align pnat.xgcd_type.step_v PNat.XgcdType.step_v
 -/
 
@@ -435,31 +407,22 @@ def reduce : XgcdType → XgcdType
 -/
 
 #print PNat.XgcdType.reduce_a /-
-theorem reduce_a {u : XgcdType} (h : u.R = 0) : u.reduce = u.finish :=
-  by
-  rw [reduce]
-  simp only
+theorem reduce_a {u : XgcdType} (h : u.R = 0) : u.reduce = u.finish := by rw [reduce]; simp only;
   rw [if_pos h]
 #align pnat.xgcd_type.reduce_a PNat.XgcdType.reduce_a
 -/
 
 #print PNat.XgcdType.reduce_b /-
-theorem reduce_b {u : XgcdType} (h : u.R ≠ 0) : u.reduce = u.step.reduce.flip :=
-  by
-  rw [reduce]
-  simp only
-  rw [if_neg h, step]
+theorem reduce_b {u : XgcdType} (h : u.R ≠ 0) : u.reduce = u.step.reduce.flip := by rw [reduce];
+  simp only; rw [if_neg h, step]
 #align pnat.xgcd_type.reduce_b PNat.XgcdType.reduce_b
 -/
 
 #print PNat.XgcdType.reduce_isReduced /-
 theorem reduce_isReduced : ∀ u : XgcdType, u.reduce.IsReduced
   | u =>
-    dite (u.R = 0)
-      (fun h => by
-        rw [reduce_a h]
-        exact u.finish_is_reduced)
-      fun h => by
+    dite (u.R = 0) (fun h => by rw [reduce_a h]; exact u.finish_is_reduced) fun h =>
+      by
       have : SizeOf.sizeOf u.step < SizeOf.sizeOf u := u.step_wf h
       rw [reduce_b h, flip_is_reduced]
       apply reduce_reduced
@@ -475,11 +438,8 @@ theorem reduce_isReduced' (u : XgcdType) : u.reduce.IsReduced' :=
 #print PNat.XgcdType.reduce_isSpecial /-
 theorem reduce_isSpecial : ∀ u : XgcdType, u.IsSpecial → u.reduce.IsSpecial
   | u =>
-    dite (u.R = 0)
-      (fun h hs => by
-        rw [reduce_a h]
-        exact u.finish_is_special hs)
-      fun h hs => by
+    dite (u.R = 0) (fun h hs => by rw [reduce_a h]; exact u.finish_is_special hs) fun h hs =>
+      by
       have : SizeOf.sizeOf u.step < SizeOf.sizeOf u := u.step_wf h
       rw [reduce_b h]
       exact (flip_is_special _).mpr (reduce_special _ (u.step_is_special hs))
@@ -600,8 +560,7 @@ theorem gcd_props :
   have ha' : (a' : ℕ) = w + x := gcd_a'_coe a b
   have hb' : (b' : ℕ) = y + z := gcd_b'_coe a b
   have hdet : w * z = succ_pnat (x * y) := u.reduce_special' rfl
-  constructor
-  exact hdet
+  constructor; exact hdet
   have hdet' : (w * z : ℕ) = x * y + 1 := by rw [← mul_coe, hdet, succ_pnat_coe]
   have huv : u.v = ⟨a, b⟩ := xgcd_type.start_v a b
   let hv : Prod.mk (w * d + x * ur.b : ℕ) (y * d + z * ur.b : ℕ) = ⟨a, b⟩ :=
@@ -609,27 +568,15 @@ theorem gcd_props :
   rw [← hb, ← add_mul, ← add_mul, ← ha', ← hb'] at hv
   have ha'' : (a : ℕ) = a' * d := (congr_arg Prod.fst hv).symm
   have hb'' : (b : ℕ) = b' * d := (congr_arg Prod.snd hv).symm
+  constructor; exact Eq ha''; constructor; exact Eq hb''
+  have hza' : (z * a' : ℕ) = x * b' + 1 := by
+    rw [ha', hb', mul_add, mul_add, mul_comm (z : ℕ), hdet']; ring
+  have hwb' : (w * b' : ℕ) = y * a' + 1 := by rw [ha', hb', mul_add, mul_add, hdet']; ring
   constructor
-  exact Eq ha''
-  constructor
-  exact Eq hb''
-  have hza' : (z * a' : ℕ) = x * b' + 1 :=
-    by
-    rw [ha', hb', mul_add, mul_add, mul_comm (z : ℕ), hdet']
-    ring
-  have hwb' : (w * b' : ℕ) = y * a' + 1 :=
-    by
-    rw [ha', hb', mul_add, mul_add, hdet']
-    ring
-  constructor
-  · apply Eq
-    rw [succ_pnat_coe, Nat.succ_eq_add_one, mul_coe, hza']
+  · apply Eq; rw [succ_pnat_coe, Nat.succ_eq_add_one, mul_coe, hza']
   constructor
-  · apply Eq
-    rw [succ_pnat_coe, Nat.succ_eq_add_one, mul_coe, hwb']
-  rw [ha'', hb'']
-  repeat' rw [← mul_assoc]
-  rw [hza', hwb']
+  · apply Eq; rw [succ_pnat_coe, Nat.succ_eq_add_one, mul_coe, hwb']
+  rw [ha'', hb'']; repeat' rw [← mul_assoc]; rw [hza', hwb']
   constructor <;> ring
 #align pnat.gcd_props PNat.gcd_props
 
@@ -643,8 +590,7 @@ theorem gcd_eq : gcdD a b = gcd a b :=
     exact Dvd.intro (gcd_b' a b) (h₂.trans (mul_comm _ _)).symm
   · have h₇ : (gcd a b : ℕ) ∣ gcd_z a b * a := (Nat.gcd_dvd_left a b).trans (dvd_mul_left _ _)
     have h₈ : (gcd a b : ℕ) ∣ gcd_x a b * b := (Nat.gcd_dvd_right a b).trans (dvd_mul_left _ _)
-    rw [h₅] at h₇
-    rw [dvd_iff]
+    rw [h₅] at h₇; rw [dvd_iff]
     exact (Nat.dvd_add_iff_right h₈).mpr h₇
 #align pnat.gcd_eq PNat.gcd_eq
 -/
Diff
@@ -262,7 +262,7 @@ theorem flip_b : (flip u).b = u.a :=
 #print PNat.XgcdType.flip_isReduced /-
 theorem flip_isReduced : (flip u).IsReduced ↔ u.IsReduced :=
   by
-  dsimp [is_reduced, flip]
+  dsimp [IsReduced, flip]
   constructor <;> intro h <;> exact h.symm
 #align pnat.xgcd_type.flip_is_reduced PNat.XgcdType.flip_isReduced
 -/
@@ -342,7 +342,7 @@ def finish : XgcdType :=
 #print PNat.XgcdType.finish_isReduced /-
 theorem finish_isReduced : u.finish.IsReduced :=
   by
-  dsimp [is_reduced]
+  dsimp [IsReduced]
   rfl
 #align pnat.xgcd_type.finish_is_reduced PNat.XgcdType.finish_isReduced
 -/
Diff
@@ -298,7 +298,7 @@ theorem qp_eq (hr : u.R = 0) : u.q = u.qp + 1 :=
   by
   by_cases hq : u.q = 0
   · let h := u.rq_eq
-    rw [hr, hq, mul_zero, add_zero] at h
+    rw [hr, hq, MulZeroClass.mul_zero, add_zero] at h
     cases h
   · exact (Nat.succ_pred_eq_of_pos (Nat.pos_of_ne_zero hq)).symm
 #align pnat.xgcd_type.qp_eq PNat.XgcdType.qp_eq
@@ -327,7 +327,7 @@ theorem start_isSpecial (a b : ℕ+) : (start a b).IsSpecial :=
 theorem start_v (a b : ℕ+) : (start a b).V = ⟨a, b⟩ :=
   by
   dsimp [start, v, xgcd_type.a, xgcd_type.b, w, z]
-  rw [one_mul, one_mul, zero_mul, zero_mul, zero_add, add_zero]
+  rw [one_mul, one_mul, MulZeroClass.zero_mul, MulZeroClass.zero_mul, zero_add, add_zero]
   rw [← Nat.pred_eq_sub_one, ← Nat.pred_eq_sub_one]
   rw [Nat.succ_pred_eq_of_pos a.pos, Nat.succ_pred_eq_of_pos b.pos]
 #align pnat.xgcd_type.start_v PNat.XgcdType.start_v

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 1 (#12338)

A PR accompanying #12339.

Zulip discussion

Diff
@@ -473,7 +473,7 @@ theorem gcd_props :
   have hb' : (b' : ℕ) = y + z := gcdB'_coe a b
   have hdet : w * z = succPNat (x * y) := u.reduce_isSpecial' rfl
   constructor
-  exact hdet
+  · exact hdet
   have hdet' : (w * z : ℕ) = x * y + 1 := by rw [← mul_coe, hdet, succPNat_coe]
   have _ : u.v = ⟨a, b⟩ := XgcdType.start_v a b
   let hv : Prod.mk (w * d + x * ur.b : ℕ) (y * d + z * ur.b : ℕ) = ⟨a, b⟩ :=
@@ -482,9 +482,9 @@ theorem gcd_props :
   have ha'' : (a : ℕ) = a' * d := (congr_arg Prod.fst hv).symm
   have hb'' : (b : ℕ) = b' * d := (congr_arg Prod.snd hv).symm
   constructor
-  exact eq ha''
+  · exact eq ha''
   constructor
-  exact eq hb''
+  · exact eq hb''
   have hza' : (z * a' : ℕ) = x * b' + 1 := by
     rw [ha', hb', mul_add, mul_add, mul_comm (z : ℕ), hdet']
     ring
@@ -498,7 +498,7 @@ theorem gcd_props :
   · apply eq
     rw [succPNat_coe, Nat.succ_eq_add_one, mul_coe, hwb']
   rw [ha'', hb'']
-  repeat' rw [← @mul_assoc]
+  repeat rw [← @mul_assoc]
   rw [hza', hwb']
   constructor <;> ring
 #align pnat.gcd_props PNat.gcd_props
@@ -507,8 +507,8 @@ theorem gcd_eq : gcdD a b = gcd a b := by
   rcases gcd_props a b with ⟨_, h₁, h₂, _, _, h₅, _⟩
   apply dvd_antisymm
   · apply dvd_gcd
-    exact Dvd.intro (gcdA' a b) (h₁.trans (mul_comm _ _)).symm
-    exact Dvd.intro (gcdB' a b) (h₂.trans (mul_comm _ _)).symm
+    · exact Dvd.intro (gcdA' a b) (h₁.trans (mul_comm _ _)).symm
+    · exact Dvd.intro (gcdB' a b) (h₂.trans (mul_comm _ _)).symm
   · have h₇ : (gcd a b : ℕ) ∣ gcdZ a b * a := (Nat.gcd_dvd_left a b).trans (dvd_mul_left _ _)
     have h₈ : (gcd a b : ℕ) ∣ gcdX a b * b := (Nat.gcd_dvd_right a b).trans (dvd_mul_left _ _)
     rw [h₅] at h₇
chore: use string gaps (#9193)

For error messages that span multiple lines, now we can use the new "string gap" escape sequence (a \ at the end of the line, which causes all the whitespace at the beginning of the next line ignored), rather than using append operations or hacks involving { and } for s! and m! strings.

Style-wise, we suggest for long messages that the body of the message start on the next line if possible, by starting the message with a string gap sequence. This eliminates needing to decide whether to indent continuing lines at the " or at the next column. For example:

    logError m!"\
      Tactic 'more_magic' cannot \
      apply expression{indentD e}\n\
      due to some reason or another."

Note that to get whitespace to appear between one line and the next, you include it before the \.

Diff
@@ -70,9 +70,9 @@ instance : SizeOf XgcdType :=
  reflects the matrix/vector interpretation as above. -/
 instance : Repr XgcdType where
   reprPrec
-  | g, _ => s!"[[[ {repr (g.wp + 1)}, {(repr g.x)} ], [" ++
-            s!"{repr g.y}, {repr (g.zp + 1)}]], [" ++
-            s!"{repr (g.ap + 1)}, {repr (g.bp + 1)}]]"
+  | g, _ => s!"[[[{repr (g.wp + 1)}, {repr g.x}], \
+                 [{repr g.y}, {repr (g.zp + 1)}]], \
+                [{repr (g.ap + 1)}, {repr (g.bp + 1)}]]"
 
 /-- Another `mk` using ℕ and ℕ+ -/
 def mk' (w : ℕ+) (x : ℕ) (y : ℕ) (z : ℕ+) (a : ℕ+) (b : ℕ+) : XgcdType :=
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,15 +2,12 @@
 Copyright (c) 2019 Neil Strickland. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Neil Strickland
-
-! This file was ported from Lean 3 source module data.pnat.xgcd
-! leanprover-community/mathlib commit 6afc9b06856ad973f6a2619e3e8a0a8d537a58f2
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Tactic.Ring
 import Mathlib.Data.PNat.Prime
 
+#align_import data.pnat.xgcd from "leanprover-community/mathlib"@"6afc9b06856ad973f6a2619e3e8a0a8d537a58f2"
+
 /-!
 # Euclidean algorithm for ℕ
 
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
@@ -155,8 +155,8 @@ theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
   let ⟨wp, x, y, zp, ap, bp⟩ := u
   constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
     simp only [← coe_inj, mul_coe, mk_coe] at *
-  . simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring
-  . simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h; rw [← h]; ring
+  · simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring
+  · simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h; rw [← h]; ring
   -- Porting note: Old code has been removed as it was much more longer.
 #align pnat.xgcd_type.is_special_iff PNat.XgcdType.isSpecial_iff
 
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
@@ -281,7 +281,7 @@ theorem finish_isReduced : u.finish.IsReduced := by
 #align pnat.xgcd_type.finish_is_reduced PNat.XgcdType.finish_isReduced
 
 theorem finish_isSpecial (hs : u.IsSpecial) : u.finish.IsSpecial := by
-  dsimp [IsSpecial, finish] at hs⊢
+  dsimp [IsSpecial, finish] at hs ⊢
   rw [add_mul _ _ u.y, add_comm _ (u.x * u.y), ← hs]
   ring
 #align pnat.xgcd_type.finish_is_special PNat.XgcdType.finish_isSpecial
@@ -316,7 +316,7 @@ theorem step_wf (hr : u.r ≠ 0) : SizeOf.sizeOf u.step < SizeOf.sizeOf u := by
 #align pnat.xgcd_type.step_wf PNat.XgcdType.step_wf
 
 theorem step_isSpecial (hs : u.IsSpecial) : u.step.IsSpecial := by
-  dsimp [IsSpecial, step] at hs⊢
+  dsimp [IsSpecial, step] at hs ⊢
   rw [mul_add, mul_comm u.y u.x, ← hs]
   ring
 #align pnat.xgcd_type.step_is_special PNat.XgcdType.step_isSpecial
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
@@ -392,8 +392,7 @@ theorem reduce_isSpecial' (u : XgcdType) (hs : u.IsSpecial) : u.reduce.IsSpecial
 
 theorem reduce_v : ∀ u : XgcdType, u.reduce.v = u.v
   | u =>
-    dite (u.r = 0) (fun h => by rw [reduce_a h, finish_v u h]) fun h =>
-      by
+    dite (u.r = 0) (fun h => by rw [reduce_a h, finish_v u h]) fun h => by
       have : SizeOf.sizeOf u.step < SizeOf.sizeOf u := u.step_wf h
       rw [reduce_b h, flip_v, reduce_v (step u), step_v u h, Prod.swap_swap]
 #align pnat.xgcd_type.reduce_v PNat.XgcdType.reduce_v
@@ -444,8 +443,7 @@ def gcdB' : ℕ+ :=
   succPNat ((xgcd a b).y + (xgcd a b).zp)
 #align pnat.gcd_b' PNat.gcdB'
 
-theorem gcdA'_coe : (gcdA' a b : ℕ) = gcdW a b + gcdX a b :=
-  by
+theorem gcdA'_coe : (gcdA' a b : ℕ) = gcdW a b + gcdX a b := by
   dsimp [gcdA', gcdX, gcdW, XgcdType.w]
   rw [Nat.succ_eq_add_one, Nat.succ_eq_add_one, add_right_comm]
 #align pnat.gcd_a'_coe PNat.gcdA'_coe
@@ -508,8 +506,7 @@ theorem gcd_props :
   constructor <;> ring
 #align pnat.gcd_props PNat.gcd_props
 
-theorem gcd_eq : gcdD a b = gcd a b :=
-  by
+theorem gcd_eq : gcdD a b = gcd a b := by
   rcases gcd_props a b with ⟨_, h₁, h₂, _, _, h₅, _⟩
   apply dvd_antisymm
   · apply dvd_gcd
chore: bump to nightly-2023-04-11 (#3139)
Diff
@@ -293,7 +293,7 @@ theorem finish_v (hr : u.r = 0) : u.finish.v = u.v := by
   · change (u.wp + 1) * u.b + ((u.wp + 1) * u.qp + u.x) * u.b = u.w * u.a + u.x * u.b
     have : u.wp + 1 = u.w := rfl
     rw [this, ← ha, u.qp_eq hr]
-    ring_nf
+    ring
   · change u.y * u.b + (u.y * u.qp + u.z) * u.b = u.y * u.a + u.z * u.b
     rw [← ha, u.qp_eq hr]
     ring
chore: fix casing errors per naming scheme (#1670)
Diff
@@ -400,7 +400,7 @@ theorem reduce_v : ∀ u : XgcdType, u.reduce.v = u.v
 
 end XgcdType
 
-section Gcd
+section gcd
 
 variable (a b : ℕ+)
 
@@ -550,6 +550,6 @@ theorem gcd_rel_right : (gcdW a b * b : ℕ) = gcdY a b * a + gcd a b :=
   gcd_eq a b ▸ (gcd_props a b).2.2.2.2.2.2
 #align pnat.gcd_rel_right PNat.gcd_rel_right
 
-end Gcd
+end gcd
 
 end PNat
chore: fix names in Xgcd.lean (#1540)

I misapplied the naming conventions when reviewing the PR that ported this file. This PR fixes the capitalization of some Props.

Diff
@@ -28,8 +28,8 @@ the theory of continued fractions.
 
 * `XgcdType`: Helper type in defining the gcd. Encapsulates `(wp, x, y, zp, ap, bp)`. where `wp`
   `zp`, `ap`, `bp` are the variables getting changed through the algorithm.
-* `isSpecial`: States `wp * zp = x * y + 1`
-* `isReduced`: States `ap = a ∧ bp = b`
+* `IsSpecial`: States `wp * zp = x * y + 1`
+* `IsReduced`: States `ap = a ∧ bp = b`
 
 ## Notes
 
@@ -140,41 +140,40 @@ theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
   ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; ring_nf)
 #align pnat.xgcd_type.v_eq_succ_vp PNat.XgcdType.v_eq_succ_vp
 
-/-- `isSpecial` holds if the matrix has determinant one. -/
-def isSpecial : Prop :=
+/-- `IsSpecial` holds if the matrix has determinant one. -/
+def IsSpecial : Prop :=
   u.wp + u.zp + u.wp * u.zp = u.x * u.y
-#align pnat.xgcd_type.is_special PNat.XgcdType.isSpecial
+#align pnat.xgcd_type.is_special PNat.XgcdType.IsSpecial
 
-/-- `isSpecial'` is an alternative of `isSpecial`. -/
-def isSpecial' : Prop :=
+/-- `IsSpecial'` is an alternative of `IsSpecial`. -/
+def IsSpecial' : Prop :=
   u.w * u.z = succPNat (u.x * u.y)
-#align pnat.xgcd_type.is_special' PNat.XgcdType.isSpecial'
+#align pnat.xgcd_type.is_special' PNat.XgcdType.IsSpecial'
 
-theorem isSpecial_iff : u.isSpecial ↔ u.isSpecial' := by
-  dsimp [isSpecial, isSpecial']
+theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
+  dsimp [IsSpecial, IsSpecial']
   let ⟨wp, x, y, zp, ap, bp⟩ := u
   constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
     simp only [← coe_inj, mul_coe, mk_coe] at *
   . simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring
   . simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h; rw [← h]; ring
   -- Porting note: Old code has been removed as it was much more longer.
-
 #align pnat.xgcd_type.is_special_iff PNat.XgcdType.isSpecial_iff
 
-/-- `isReduced` holds if the two entries in the vector are the
+/-- `IsReduced` holds if the two entries in the vector are the
  same.  The reduction algorithm will produce a system with this
  property, whose product vector is the same as for the original
  system. -/
-def isReduced : Prop :=
+def IsReduced : Prop :=
   u.ap = u.bp
-#align pnat.xgcd_type.is_reduced PNat.XgcdType.isReduced
+#align pnat.xgcd_type.is_reduced PNat.XgcdType.IsReduced
 
-/-- `isReduced'` is an alternative of `isReduced`. -/
-def isReduced' : Prop :=
+/-- `IsReduced'` is an alternative of `IsReduced`. -/
+def IsReduced' : Prop :=
   u.a = u.b
-#align pnat.xgcd_type.is_reduced' PNat.XgcdType.isReduced'
+#align pnat.xgcd_type.is_reduced' PNat.XgcdType.IsReduced'
 
-theorem isReduced_iff : u.isReduced ↔ u.isReduced' :=
+theorem isReduced_iff : u.IsReduced ↔ u.IsReduced' :=
   succPNat_inj.symm
 #align pnat.xgcd_type.is_reduced_iff PNat.XgcdType.isReduced_iff
 
@@ -218,13 +217,13 @@ theorem flip_b : (flip u).b = u.a :=
   rfl
 #align pnat.xgcd_type.flip_b PNat.XgcdType.flip_b
 
-theorem flip_isReduced : (flip u).isReduced ↔ u.isReduced := by
-  dsimp [isReduced, flip]
+theorem flip_isReduced : (flip u).IsReduced ↔ u.IsReduced := by
+  dsimp [IsReduced, flip]
   constructor <;> intro h <;> exact h.symm
 #align pnat.xgcd_type.flip_is_reduced PNat.XgcdType.flip_isReduced
 
-theorem flip_isSpecial : (flip u).isSpecial ↔ u.isSpecial := by
-  dsimp [isSpecial, flip]
+theorem flip_isSpecial : (flip u).IsSpecial ↔ u.IsSpecial := by
+  dsimp [IsSpecial, flip]
   rw [mul_comm u.x, mul_comm u.zp, add_comm u.zp]
 #align pnat.xgcd_type.flip_is_special PNat.XgcdType.flip_isSpecial
 
@@ -252,15 +251,15 @@ theorem qp_eq (hr : u.r = 0) : u.q = u.qp + 1 := by
 
 /-- The following function provides the starting point for
  our algorithm.  We will apply an iterative reduction process
- to it, which will produce a system satisfying isReduced.
+ to it, which will produce a system satisfying IsReduced.
  The gcd can be read off from this final system.
 -/
 def start (a b : ℕ+) : XgcdType :=
   ⟨0, 0, 0, 0, a - 1, b - 1⟩
 #align pnat.xgcd_type.start PNat.XgcdType.start
 
-theorem start_isSpecial (a b : ℕ+) : (start a b).isSpecial := by
-  dsimp [start, isSpecial]
+theorem start_isSpecial (a b : ℕ+) : (start a b).IsSpecial := by
+  dsimp [start, IsSpecial]
 #align pnat.xgcd_type.start_is_special PNat.XgcdType.start_isSpecial
 
 theorem start_v (a b : ℕ+) : (start a b).v = ⟨a, b⟩ := by
@@ -276,13 +275,13 @@ def finish : XgcdType :=
   XgcdType.mk u.wp ((u.wp + 1) * u.qp + u.x) u.y (u.y * u.qp + u.zp) u.bp u.bp
 #align pnat.xgcd_type.finish PNat.XgcdType.finish
 
-theorem finish_isReduced : u.finish.isReduced := by
-  dsimp [isReduced]
+theorem finish_isReduced : u.finish.IsReduced := by
+  dsimp [IsReduced]
   rfl
 #align pnat.xgcd_type.finish_is_reduced PNat.XgcdType.finish_isReduced
 
-theorem finish_isSpecial (hs : u.isSpecial) : u.finish.isSpecial := by
-  dsimp [isSpecial, finish] at hs⊢
+theorem finish_isSpecial (hs : u.IsSpecial) : u.finish.IsSpecial := by
+  dsimp [IsSpecial, finish] at hs⊢
   rw [add_mul _ _ u.y, add_comm _ (u.x * u.y), ← hs]
   ring
 #align pnat.xgcd_type.finish_is_special PNat.XgcdType.finish_isSpecial
@@ -316,8 +315,8 @@ theorem step_wf (hr : u.r ≠ 0) : SizeOf.sizeOf u.step < SizeOf.sizeOf u := by
   exact lt_of_succ_lt_succ h₁
 #align pnat.xgcd_type.step_wf PNat.XgcdType.step_wf
 
-theorem step_isSpecial (hs : u.isSpecial) : u.step.isSpecial := by
-  dsimp [isSpecial, step] at hs⊢
+theorem step_isSpecial (hs : u.IsSpecial) : u.step.IsSpecial := by
+  dsimp [IsSpecial, step] at hs⊢
   rw [mul_add, mul_comm u.y u.x, ← hs]
   ring
 #align pnat.xgcd_type.step_is_special PNat.XgcdType.step_isSpecial
@@ -359,7 +358,7 @@ theorem reduce_b {u : XgcdType} (h : u.r ≠ 0) : u.reduce = u.step.reduce.flip
   exact if_neg h
 #align pnat.xgcd_type.reduce_b PNat.XgcdType.reduce_b
 
-theorem reduce_reduced : ∀ u : XgcdType, u.reduce.isReduced
+theorem reduce_isReduced : ∀ u : XgcdType, u.reduce.IsReduced
   | u =>
     dite (u.r = 0)
       (fun h => by
@@ -368,14 +367,14 @@ theorem reduce_reduced : ∀ u : XgcdType, u.reduce.isReduced
       fun h => by
       have : SizeOf.sizeOf u.step < SizeOf.sizeOf u := u.step_wf h
       rw [reduce_b h, flip_isReduced]
-      apply reduce_reduced
-#align pnat.xgcd_type.reduce_reduced PNat.XgcdType.reduce_reduced
+      apply reduce_isReduced
+#align pnat.xgcd_type.reduce_reduced PNat.XgcdType.reduce_isReduced
 
-theorem reduce_reduced' (u : XgcdType) : u.reduce.isReduced' :=
-  (isReduced_iff _).mp u.reduce_reduced
-#align pnat.xgcd_type.reduce_reduced' PNat.XgcdType.reduce_reduced'
+theorem reduce_isReduced' (u : XgcdType) : u.reduce.IsReduced' :=
+  (isReduced_iff _).mp u.reduce_isReduced
+#align pnat.xgcd_type.reduce_reduced' PNat.XgcdType.reduce_isReduced'
 
-theorem reduce_special : ∀ u : XgcdType, u.isSpecial → u.reduce.isSpecial
+theorem reduce_isSpecial : ∀ u : XgcdType, u.IsSpecial → u.reduce.IsSpecial
   | u =>
     dite (u.r = 0)
       (fun h hs => by
@@ -384,12 +383,12 @@ theorem reduce_special : ∀ u : XgcdType, u.isSpecial → u.reduce.isSpecial
       fun h hs => by
       have : SizeOf.sizeOf u.step < SizeOf.sizeOf u := u.step_wf h
       rw [reduce_b h]
-      exact (flip_isSpecial _).mpr (reduce_special _ (u.step_isSpecial hs))
-#align pnat.xgcd_type.reduce_special PNat.XgcdType.reduce_special
+      exact (flip_isSpecial _).mpr (reduce_isSpecial _ (u.step_isSpecial hs))
+#align pnat.xgcd_type.reduce_special PNat.XgcdType.reduce_isSpecial
 
-theorem reduce_special' (u : XgcdType) (hs : u.isSpecial) : u.reduce.isSpecial' :=
-  (isSpecial_iff _).mp (u.reduce_special hs)
-#align pnat.xgcd_type.reduce_special' PNat.XgcdType.reduce_special'
+theorem reduce_isSpecial' (u : XgcdType) (hs : u.IsSpecial) : u.reduce.IsSpecial' :=
+  (isSpecial_iff _).mp (u.reduce_isSpecial hs)
+#align pnat.xgcd_type.reduce_special' PNat.XgcdType.reduce_isSpecial'
 
 theorem reduce_v : ∀ u : XgcdType, u.reduce.v = u.v
   | u =>
@@ -474,10 +473,10 @@ theorem gcd_props :
   let ur := u.reduce
 
   have _ : d = ur.a := rfl
-  have hb : d = ur.b := u.reduce_reduced'
+  have hb : d = ur.b := u.reduce_isReduced'
   have ha' : (a' : ℕ) = w + x := gcdA'_coe a b
   have hb' : (b' : ℕ) = y + z := gcdB'_coe a b
-  have hdet : w * z = succPNat (x * y) := u.reduce_special' rfl
+  have hdet : w * z = succPNat (x * y) := u.reduce_isSpecial' rfl
   constructor
   exact hdet
   have hdet' : (w * z : ℕ) = x * y + 1 := by rw [← mul_coe, hdet, succPNat_coe]
feat: port Data.PNat.Xgcd (#1408)

Initial files generated by start_port.sh has been moved from Data/Pnat to Data/PNat.

Co-authored-by: qawbecrdtey <40463813+qawbecrdtey@users.noreply.github.com>

Dependencies 3 + 145

146 files ported (98.0%)
57906 lines ported (98.2%)
Show graph

The unported dependencies are