number_theory.diophMathlib.NumberTheory.Dioph

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)

(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: Mario Carneiro
 -/
 import Data.Fin.Fin2
-import Data.Pfun
+import Data.PFun
 import Data.Vector3
 import NumberTheory.PellMatiyasevic
 
Diff
@@ -346,9 +346,9 @@ theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.Forall fun a : Poly α =>
               le_antisymm
                 (by
                   rw [← h] <;> have t := add_le_add_left (sumsq_nonneg x ps) (p x * p x) <;>
-                    rwa [add_zero] at t )
+                    rwa [add_zero] at t)
                 (hMul_self_nonneg _)
-          ⟨this, by simp [this] at h  <;> exact h⟩,
+          ⟨this, by simp [this] at h <;> exact h⟩,
           fun ⟨h1, h2⟩ => by rw [h1, h2] <;> rfl⟩
 #align poly.sumsq_eq_zero Poly.sumsq_eq_zero
 -/
@@ -456,7 +456,7 @@ theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
     ⟨β, Poly.sumsq pl, fun v => (h v).trans <| exists_congr fun t => (Poly.sumsq_eq_zero _ _).symm⟩
   induction' l with S l IH
   exact ⟨ULift Empty, [], fun v => by simp <;> exact ⟨fun ⟨t⟩ => Empty.rec _ t, trivial⟩⟩
-  simp at d 
+  simp at d
   exact
     let ⟨⟨β, p, pe⟩, dl⟩ := d
     let ⟨γ, pl, ple⟩ := IH dl
@@ -479,14 +479,14 @@ theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
               ⟨⟨t ∘ inl, by
                   rwa [show (v ⊗ t) ∘ (inl ⊗ inr ∘ inl) = v ⊗ t ∘ inl from
                       funext fun s => by cases' s with a b <;> rfl] at
-                    hl ⟩,
+                    hl⟩,
                 ⟨t ∘ inr, by
-                  refine' List.Forall.imp (fun q hq => _) hr; dsimp [(· ∘ ·)] at hq 
+                  refine' List.Forall.imp (fun q hq => _) hr; dsimp [(· ∘ ·)] at hq
                   rwa [show
                       (fun x : Sum α γ => (v ⊗ t) ((inl ⊗ fun x : γ => inr (inr x)) x)) =
                         v ⊗ t ∘ inr
                       from funext fun s => by cases' s with a b <;> rfl] at
-                    hq ⟩⟩⟩⟩
+                    hq⟩⟩⟩⟩
 #align dioph.dioph_list.all₂ Dioph.DiophList.forall
 -/
 
@@ -547,10 +547,10 @@ theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph {v | ∃ x, v
         ⟨t ∘ inl,
           (pe _).2
             ⟨t ∘ inr, by
-              simp at ht  <;>
+              simp at ht <;>
                 rwa [show (v ⊗ t) ∘ ((inl ⊗ inr ∘ inl) ⊗ inr ∘ inr) = (v ⊗ t ∘ inl) ⊗ t ∘ inr from
                     funext fun s => by cases' s with a b <;> try cases a <;> rfl] at
-                  ht ⟩⟩⟩⟩
+                  ht⟩⟩⟩⟩
 #align dioph.ex_dioph Dioph.ex_dioph
 -/
 
@@ -569,10 +569,10 @@ theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x,
         ⟨t none,
           (pe _).2
             ⟨t ∘ some, by
-              simp at ht  <;>
+              simp at ht <;>
                 rwa [show (v ⊗ t) ∘ (inr none ::ₒ inl ⊗ inr ∘ some) = t none ::ₒ v ⊗ t ∘ some from
                     funext fun s => by cases' s with a b <;> try cases a <;> rfl] at
-                  ht ⟩⟩⟩⟩
+                  ht⟩⟩⟩⟩
 #align dioph.ex1_dioph Dioph.ex1_dioph
 -/
 
@@ -606,7 +606,7 @@ theorem diophPFun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : Di
     Dioph {v : α → ℕ | ∃ h : f.Dom v, f.fn v h ::ₒ v ∈ S} :=
   ext (ex1_dioph (d.inter df)) fun v =>
     ⟨fun ⟨x, hS, (h : Exists _)⟩ => by
-      rw [show (x ::ₒ v) ∘ some = v from funext fun s => rfl] at h  <;> cases' h with hf h <;>
+      rw [show (x ::ₒ v) ∘ some = v from funext fun s => rfl] at h <;> cases' h with hf h <;>
             refine' ⟨hf, _⟩ <;>
           rw [PFun.fn, h] <;>
         exact hS,
Diff
@@ -110,10 +110,10 @@ namespace Poly
 
 section
 
-#print Poly.instDFunLike /-
-instance instDFunLike : DFunLike (Poly α) (α → ℕ) fun _ => ℤ :=
+#print Poly.instFunLike /-
+instance instFunLike : DFunLike (Poly α) (α → ℕ) fun _ => ℤ :=
   ⟨Subtype.val, Subtype.val_injective⟩
-#align poly.fun_like Poly.instDFunLike
+#align poly.fun_like Poly.instFunLike
 -/
 
 /-- Helper instance for when there are too many metavariables to apply `fun_like.has_coe_to_fun`
Diff
@@ -110,16 +110,16 @@ namespace Poly
 
 section
 
-#print Poly.funLike /-
-instance funLike : FunLike (Poly α) (α → ℕ) fun _ => ℤ :=
+#print Poly.instDFunLike /-
+instance instDFunLike : DFunLike (Poly α) (α → ℕ) fun _ => ℤ :=
   ⟨Subtype.val, Subtype.val_injective⟩
-#align poly.fun_like Poly.funLike
+#align poly.fun_like Poly.instDFunLike
 -/
 
 /-- Helper instance for when there are too many metavariables to apply `fun_like.has_coe_to_fun`
 directly. -/
 instance : CoeFun (Poly α) fun _ => (α → ℕ) → ℤ :=
-  FunLike.hasCoeToFun
+  DFunLike.hasCoeToFun
 
 #print Poly.isPoly /-
 /-- The underlying function of a `poly` is a polynomial -/
@@ -132,7 +132,7 @@ protected theorem isPoly (f : Poly α) : IsPoly f :=
 /-- Extensionality for `poly α` -/
 @[ext]
 theorem ext {f g : Poly α} : (∀ x, f x = g x) → f = g :=
-  FunLike.ext _ _
+  DFunLike.ext _ _
 #align poly.ext Poly.ext
 -/
 
Diff
@@ -329,7 +329,7 @@ def sumsq : List (Poly α) → Poly α
 theorem sumsq_nonneg (x : α → ℕ) : ∀ l, 0 ≤ sumsq l x
   | [] => le_refl 0
   | p::ps => by
-    rw [sumsq] <;> simp [-add_comm] <;> exact add_nonneg (mul_self_nonneg _) (sumsq_nonneg ps)
+    rw [sumsq] <;> simp [-add_comm] <;> exact add_nonneg (hMul_self_nonneg _) (sumsq_nonneg ps)
 #align poly.sumsq_nonneg Poly.sumsq_nonneg
 -/
 
@@ -347,7 +347,7 @@ theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.Forall fun a : Poly α =>
                 (by
                   rw [← h] <;> have t := add_le_add_left (sumsq_nonneg x ps) (p x * p x) <;>
                     rwa [add_zero] at t )
-                (mul_self_nonneg _)
+                (hMul_self_nonneg _)
           ⟨this, by simp [this] at h  <;> exact h⟩,
           fun ⟨h1, h2⟩ => by rw [h1, h2] <;> rfl⟩
 #align poly.sumsq_eq_zero Poly.sumsq_eq_zero
Diff
@@ -512,11 +512,11 @@ theorem union : ∀ (d : Dioph S) (d' : Dioph S'), Dioph (S ∪ S')
 #align dioph.union Dioph.union
 -/
 
-#print Dioph.DiophPfun /-
+#print Dioph.DiophPFun /-
 /-- A partial function is Diophantine if its graph is Diophantine. -/
-def DiophPfun (f : (α → ℕ) →. ℕ) : Prop :=
+def DiophPFun (f : (α → ℕ) →. ℕ) : Prop :=
   Dioph {v : Option α → ℕ | f.graph (v ∘ some, v none)}
-#align dioph.dioph_pfun Dioph.DiophPfun
+#align dioph.dioph_pfun Dioph.DiophPFun
 -/
 
 #print Dioph.DiophFn /-
@@ -577,13 +577,13 @@ theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x,
 -/
 
 #print Dioph.dom_dioph /-
-theorem dom_dioph {f : (α → ℕ) →. ℕ} (d : DiophPfun f) : Dioph f.Dom :=
+theorem dom_dioph {f : (α → ℕ) →. ℕ} (d : DiophPFun f) : Dioph f.Dom :=
   cast (congr_arg Dioph <| Set.ext fun v => (PFun.dom_iff_graph _ _).symm) (ex1_dioph d)
 #align dioph.dom_dioph Dioph.dom_dioph
 -/
 
 #print Dioph.diophFn_iff_pFun /-
-theorem diophFn_iff_pFun (f : (α → ℕ) → ℕ) : DiophFn f = @DiophPfun α f := by
+theorem diophFn_iff_pFun (f : (α → ℕ) → ℕ) : DiophFn f = @DiophPFun α f := by
   refine' congr_arg Dioph (Set.ext fun v => _) <;> exact pfun.lift_graph.symm
 #align dioph.dioph_fn_iff_pfun Dioph.diophFn_iff_pFun
 -/
@@ -601,8 +601,8 @@ theorem proj_dioph (i : α) : DiophFn fun v => v i :=
 #align dioph.proj_dioph Dioph.proj_dioph
 -/
 
-#print Dioph.diophPfun_comp1 /-
-theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : DiophPfun f) :
+#print Dioph.diophPFun_comp1 /-
+theorem diophPFun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : DiophPFun f) :
     Dioph {v : α → ℕ | ∃ h : f.Dom v, f.fn v h ::ₒ v ∈ S} :=
   ext (ex1_dioph (d.inter df)) fun v =>
     ⟨fun ⟨x, hS, (h : Exists _)⟩ => by
@@ -614,13 +614,13 @@ theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : Di
       ⟨f.fn v x, hS,
         show Exists _ by
           rw [show (f.fn v x ::ₒ v) ∘ some = v from funext fun s => rfl] <;> exact ⟨x, rfl⟩⟩⟩
-#align dioph.dioph_pfun_comp1 Dioph.diophPfun_comp1
+#align dioph.dioph_pfun_comp1 Dioph.diophPFun_comp1
 -/
 
 #print Dioph.diophFn_comp1 /-
 theorem diophFn_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f : (α → ℕ) → ℕ} (df : DiophFn f) :
     Dioph {v | f v ::ₒ v ∈ S} :=
-  ext (diophPfun_comp1 d <| cast (diophFn_iff_pFun f) df) fun v =>
+  ext (diophPFun_comp1 d <| cast (diophFn_iff_pFun f) df) fun v =>
     ⟨fun ⟨_, h⟩ => h, fun h => ⟨trivial, h⟩⟩
 #align dioph.dioph_fn_comp1 Dioph.diophFn_comp1
 -/
@@ -669,10 +669,10 @@ theorem diophFn_vec (f : Vector3 ℕ n → ℕ) : DiophFn f ↔ Dioph {v | f (v
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print Dioph.diophPfun_vec /-
-theorem diophPfun_vec (f : Vector3 ℕ n →. ℕ) : DiophPfun f ↔ Dioph {v | f.graph (v ∘ fs, v fz)} :=
+#print Dioph.diophPFun_vec /-
+theorem diophPFun_vec (f : Vector3 ℕ n →. ℕ) : DiophPFun f ↔ Dioph {v | f.graph (v ∘ fs, v fz)} :=
   ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
-#align dioph.dioph_pfun_vec Dioph.diophPfun_vec
+#align dioph.dioph_pfun_vec Dioph.diophPFun_vec
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -942,11 +942,11 @@ theorem pell_dioph :
 -/
 
 #print Dioph.xn_dioph /-
-theorem xn_dioph : DiophPfun fun v : Vector3 ℕ 2 => ⟨1 < v &0, fun h => xn h (v &1)⟩ :=
+theorem xn_dioph : DiophPFun fun v : Vector3 ℕ 2 => ⟨1 < v &0, fun h => xn h (v &1)⟩ :=
   have : Dioph fun v : Vector3 ℕ 3 => ∃ y, ∃ h : 1 < v &1, xn h (v &2) = v &0 ∧ yn h (v &2) = y :=
     let D_pell := pell_dioph.reindex_dioph (Fin2 4) [&2, &3, &1, &0]
     (D∃) 3 D_pell
-  (diophPfun_vec _).2 <|
+  (diophPFun_vec _).2 <|
     Dioph.ext this fun v => ⟨fun ⟨y, h, xe, ye⟩ => ⟨h, xe⟩, fun ⟨h, xe⟩ => ⟨_, h, xe, rfl⟩⟩
 #align dioph.xn_dioph Dioph.xn_dioph
 -/
Diff
@@ -855,7 +855,7 @@ theorem mod_dioph : DiophFn fun v => f v % g v :=
               exact mod_eq_of_lt hl, fun e => by
               rw [← e] <;>
                 exact
-                  ⟨or_iff_not_imp_left.2 fun h => mod_lt _ (Nat.pos_of_ne_zero h), x / y,
+                  ⟨Classical.or_iff_not_imp_left.2 fun h => mod_lt _ (Nat.pos_of_ne_zero h), x / y,
                     mod_add_div _ _⟩⟩
 #align dioph.mod_dioph Dioph.mod_dioph
 -/
Diff
@@ -335,10 +335,10 @@ theorem sumsq_nonneg (x : α → ℕ) : ∀ l, 0 ≤ sumsq l x
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 #print Poly.sumsq_eq_zero /-
-theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.All₂ fun a : Poly α => a x = 0
+theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.Forall fun a : Poly α => a x = 0
   | [] => eq_self_iff_true _
   | p::ps => by
-    rw [List.all₂_cons, ← sumsq_eq_zero ps] <;> rw [sumsq] <;> simp [-add_comm] <;>
+    rw [List.forall_cons, ← sumsq_eq_zero ps] <;> rw [sumsq] <;> simp [-add_comm] <;>
       exact
         ⟨fun h : p x * p x + sumsq ps x = 0 =>
           have : p x = 0 :=
@@ -442,15 +442,15 @@ theorem reindex_dioph (f : α → β) : ∀ d : Dioph S, Dioph {v | v ∘ f ∈
 variable {β}
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print Dioph.DiophList.all₂ /-
-theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
-    Dioph {v | l.All₂ fun S : Set (α → ℕ) => v ∈ S} :=
+#print Dioph.DiophList.forall /-
+theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
+    Dioph {v | l.Forall fun S : Set (α → ℕ) => v ∈ S} :=
   by
   suffices
     ∃ (β : _) (pl : List (Poly (Sum α β))),
       ∀ v,
-        List.All₂ (fun S : Set _ => S v) l ↔
-          ∃ t, List.All₂ (fun p : Poly (Sum α β) => p (v ⊗ t) = 0) pl
+        List.Forall (fun S : Set _ => S v) l ↔
+          ∃ t, List.Forall (fun p : Poly (Sum α β) => p (v ⊗ t) = 0) pl
     from
     let ⟨β, pl, h⟩ := this
     ⟨β, Poly.sumsq pl, fun v => (h v).trans <| exists_congr fun t => (Poly.sumsq_eq_zero _ _).symm⟩
@@ -470,7 +470,7 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
                       funext fun s => by cases' s with a b <;> rfl] <;>
                   exact hm,
                 by
-                refine' List.All₂.imp (fun q hq => _) hn; dsimp [(· ∘ ·)]
+                refine' List.Forall.imp (fun q hq => _) hn; dsimp [(· ∘ ·)]
                 rw [show
                       (fun x : Sum α γ => (v ⊗ m ⊗ n) ((inl ⊗ fun x : γ => inr (inr x)) x)) = v ⊗ n
                       from funext fun s => by cases' s with a b <;> rfl] <;>
@@ -481,18 +481,18 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
                       funext fun s => by cases' s with a b <;> rfl] at
                     hl ⟩,
                 ⟨t ∘ inr, by
-                  refine' List.All₂.imp (fun q hq => _) hr; dsimp [(· ∘ ·)] at hq 
+                  refine' List.Forall.imp (fun q hq => _) hr; dsimp [(· ∘ ·)] at hq 
                   rwa [show
                       (fun x : Sum α γ => (v ⊗ t) ((inl ⊗ fun x : γ => inr (inr x)) x)) =
                         v ⊗ t ∘ inr
                       from funext fun s => by cases' s with a b <;> rfl] at
                     hq ⟩⟩⟩⟩
-#align dioph.dioph_list.all₂ Dioph.DiophList.all₂
+#align dioph.dioph_list.all₂ Dioph.DiophList.forall
 -/
 
 #print Dioph.inter /-
 theorem inter (d : Dioph S) (d' : Dioph S') : Dioph (S ∩ S') :=
-  DiophList.all₂ [S, S'] ⟨d, d'⟩
+  DiophList.forall [S, S'] ⟨d, d'⟩
 #align dioph.inter Dioph.inter
 -/
 
Diff
@@ -3,10 +3,10 @@ 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.Data.Fin.Fin2
-import Mathbin.Data.Pfun
-import Mathbin.Data.Vector3
-import Mathbin.NumberTheory.PellMatiyasevic
+import Data.Fin.Fin2
+import Data.Pfun
+import Data.Vector3
+import NumberTheory.PellMatiyasevic
 
 #align_import number_theory.dioph from "leanprover-community/mathlib"@"087c325ae0ab42dbdd5dee55bc37d3d5a0bf2197"
 
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.dioph
-! leanprover-community/mathlib commit 087c325ae0ab42dbdd5dee55bc37d3d5a0bf2197
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Data.Fin.Fin2
 import Mathbin.Data.Pfun
 import Mathbin.Data.Vector3
 import Mathbin.NumberTheory.PellMatiyasevic
 
+#align_import number_theory.dioph from "leanprover-community/mathlib"@"087c325ae0ab42dbdd5dee55bc37d3d5a0bf2197"
+
 /-!
 # Diophantine functions and Matiyasevic's theorem
 
Diff
@@ -60,10 +60,8 @@ Matiyasevic's theorem, Hilbert's tenth problem
 
 open Fin2 Function Nat Sum
 
--- mathport name: «expr ::ₒ »
 local infixr:67 " ::ₒ " => Option.elim'
 
--- mathport name: «expr ⊗ »
 local infixr:65 " ⊗ " => Sum.elim
 
 universe u
@@ -370,10 +368,12 @@ def map {α β} (f : α → β) (g : Poly α) : Poly β :=
 #align poly.map Poly.map
 -/
 
+#print Poly.map_apply /-
 @[simp]
 theorem map_apply {α β} (f : α → β) (g : Poly α) (v) : map f g v = g (v ∘ f) :=
   rfl
 #align poly.map_apply Poly.map_apply
+-/
 
 end Poly
 
@@ -493,10 +493,13 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
 #align dioph.dioph_list.all₂ Dioph.DiophList.all₂
 -/
 
+#print Dioph.inter /-
 theorem inter (d : Dioph S) (d' : Dioph S') : Dioph (S ∩ S') :=
   DiophList.all₂ [S, S'] ⟨d, d'⟩
 #align dioph.inter Dioph.inter
+-/
 
+#print Dioph.union /-
 theorem union : ∀ (d : Dioph S) (d' : Dioph S'), Dioph (S ∪ S')
   | ⟨β, p, pe⟩, ⟨γ, q, qe⟩ =>
     ⟨Sum β γ, p.map (inl ⊗ inr ∘ inl) * q.map (inl ⊗ inr ∘ inr), fun v =>
@@ -510,6 +513,7 @@ theorem union : ∀ (d : Dioph S) (d' : Dioph S'), Dioph (S ∪ S')
       exact inject_dummies_lem _ (some ⊗ fun _ => none) (fun x => rfl) _ _
       exact inject_dummies_lem _ ((fun _ => none) ⊗ some) (fun x => rfl) _ _⟩
 #align dioph.union Dioph.union
+-/
 
 #print Dioph.DiophPfun /-
 /-- A partial function is Diophantine if its graph is Diophantine. -/
@@ -720,16 +724,12 @@ theorem diophFn_comp {f : Vector3 ℕ n → ℕ} (df : DiophFn f) (g : Vector3 (
 #align dioph.dioph_fn_comp Dioph.diophFn_comp
 -/
 
--- mathport name: dioph.inter
 scoped notation:35 x " D∧ " y => Dioph.inter x y
 
--- mathport name: dioph.union
 scoped notation:35 x " D∨ " y => Dioph.union x y
 
--- mathport name: dioph.vec_ex1_dioph
 scoped notation:30 "D∃" => Dioph.vec_ex1_dioph
 
--- mathport name: fin2.of_nat'
 scoped prefix:arg "&" => Fin2.ofNat'
 
 #print Dioph.proj_dioph_of_nat /-
@@ -738,7 +738,6 @@ theorem proj_dioph_of_nat {n : ℕ} (m : ℕ) [IsLT m n] : DiophFn fun v : Vecto
 #align dioph.proj_dioph_of_nat Dioph.proj_dioph_of_nat
 -/
 
--- mathport name: proj_dioph_of_nat
 scoped prefix:100 "D&" => Dioph.proj_dioph_of_nat
 
 #print Dioph.const_dioph /-
@@ -747,13 +746,10 @@ theorem const_dioph (n : ℕ) : DiophFn (const (α → ℕ) n) :=
 #align dioph.const_dioph Dioph.const_dioph
 -/
 
--- mathport name: const_dioph
 scoped prefix:100 "D." => Dioph.const_dioph
 
 variable {f g : (α → ℕ) → ℕ} (df : DiophFn f) (dg : DiophFn g)
 
-include df dg
-
 #print Dioph.dioph_comp2 /-
 theorem dioph_comp2 {S : ℕ → ℕ → Prop} (d : Dioph fun v : Vector3 ℕ 2 => S (v &0) (v &1)) :
     Dioph fun v => S (f v) (g v) :=
@@ -776,7 +772,6 @@ theorem eq_dioph : Dioph fun v => f v = g v :=
 #align dioph.eq_dioph Dioph.eq_dioph
 -/
 
--- mathport name: eq_dioph
 scoped infixl:50 " D= " => Dioph.eq_dioph
 
 #print Dioph.add_dioph /-
@@ -785,7 +780,6 @@ theorem add_dioph : DiophFn fun v => f v + g v :=
 #align dioph.add_dioph Dioph.add_dioph
 -/
 
--- mathport name: add_dioph
 scoped infixl:80 " D+ " => Dioph.add_dioph
 
 #print Dioph.mul_dioph /-
@@ -794,7 +788,6 @@ theorem mul_dioph : DiophFn fun v => f v * g v :=
 #align dioph.mul_dioph Dioph.mul_dioph
 -/
 
--- mathport name: mul_dioph
 scoped infixl:90 " D* " => Dioph.mul_dioph
 
 #print Dioph.le_dioph /-
@@ -804,7 +797,6 @@ theorem le_dioph : Dioph {v | f v ≤ g v} :=
 #align dioph.le_dioph Dioph.le_dioph
 -/
 
--- mathport name: le_dioph
 scoped infixl:50 " D≤ " => Dioph.le_dioph
 
 #print Dioph.lt_dioph /-
@@ -813,7 +805,6 @@ theorem lt_dioph : Dioph {v | f v < g v} :=
 #align dioph.lt_dioph Dioph.lt_dioph
 -/
 
--- mathport name: lt_dioph
 scoped infixl:50 " D< " => Dioph.lt_dioph
 
 #print Dioph.ne_dioph /-
@@ -822,7 +813,6 @@ theorem ne_dioph : Dioph {v | f v ≠ g v} :=
 #align dioph.ne_dioph Dioph.ne_dioph
 -/
 
--- mathport name: ne_dioph
 scoped infixl:50 " D≠ " => Dioph.ne_dioph
 
 #print Dioph.sub_dioph /-
@@ -844,7 +834,6 @@ theorem sub_dioph : DiophFn fun v => f v - g v :=
 #align dioph.sub_dioph Dioph.sub_dioph
 -/
 
--- mathport name: sub_dioph
 scoped infixl:80 " D- " => Dioph.sub_dioph
 
 #print Dioph.dvd_dioph /-
@@ -853,7 +842,6 @@ theorem dvd_dioph : Dioph fun v => f v ∣ g v :=
 #align dioph.dvd_dioph Dioph.dvd_dioph
 -/
 
--- mathport name: dvd_dioph
 scoped infixl:50 " D∣ " => Dioph.dvd_dioph
 
 #print Dioph.mod_dioph /-
@@ -875,7 +863,6 @@ theorem mod_dioph : DiophFn fun v => f v % g v :=
 #align dioph.mod_dioph Dioph.mod_dioph
 -/
 
--- mathport name: mod_dioph
 scoped infixl:80 " D% " => Dioph.mod_dioph
 
 #print Dioph.modEq_dioph /-
@@ -884,7 +871,6 @@ theorem modEq_dioph {h : (α → ℕ) → ℕ} (dh : DiophFn h) : Dioph fun v =>
 #align dioph.modeq_dioph Dioph.modEq_dioph
 -/
 
--- mathport name: modeq_dioph
 scoped notation " D≡ " => Dioph.modEq_dioph
 
 #print Dioph.div_dioph /-
@@ -914,11 +900,8 @@ theorem div_dioph : DiophFn fun v => f v / g v :=
 #align dioph.div_dioph Dioph.div_dioph
 -/
 
--- mathport name: div_dioph
 scoped infixl:80 " D/ " => Dioph.div_dioph
 
-omit df dg
-
 open Pell
 
 #print Dioph.pell_dioph /-
@@ -971,8 +954,6 @@ theorem xn_dioph : DiophPfun fun v : Vector3 ℕ 2 => ⟨1 < v &0, fun h => xn h
 #align dioph.xn_dioph Dioph.xn_dioph
 -/
 
-include df dg
-
 #print Dioph.pow_dioph /-
 /-- A version of **Matiyasevic's theorem** -/
 theorem pow_dioph : DiophFn fun v => f v ^ g v :=
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.dioph
-! leanprover-community/mathlib commit a66d07e27d5b5b8ac1147cacfe353478e5c14002
+! leanprover-community/mathlib commit 087c325ae0ab42dbdd5dee55bc37d3d5a0bf2197
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -16,6 +16,9 @@ import Mathbin.NumberTheory.PellMatiyasevic
 /-!
 # Diophantine functions and Matiyasevic's theorem
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Hilbert's tenth problem asked whether there exists an algorithm which for a given integer polynomial
 determines whether this polynomial has integer solutions. It was answered in the negative in 1970,
 the final step being completed by Matiyasevic who showed that the power function is Diophantine.
Diff
@@ -76,6 +76,7 @@ section Polynomials
 
 variable {α β γ : Type _}
 
+#print IsPoly /-
 /-- A predicate asserting that a function is a multivariate integer polynomial.
   (We are being a bit lazy here by allowing many representations for multiplication,
   rather than only allowing monomials and addition, but the definition is equivalent
@@ -86,63 +87,84 @@ inductive IsPoly : ((α → ℕ) → ℤ) → Prop
   | sub : ∀ {f g : (α → ℕ) → ℤ}, IsPoly f → IsPoly g → IsPoly fun x => f x - g x
   | mul : ∀ {f g : (α → ℕ) → ℤ}, IsPoly f → IsPoly g → IsPoly fun x => f x * g x
 #align is_poly IsPoly
+-/
 
+#print IsPoly.neg /-
 theorem IsPoly.neg {f : (α → ℕ) → ℤ} : IsPoly f → IsPoly (-f) := by rw [← zero_sub];
   exact (IsPoly.const 0).sub
 #align is_poly.neg IsPoly.neg
+-/
 
+#print IsPoly.add /-
 theorem IsPoly.add {f g : (α → ℕ) → ℤ} (hf : IsPoly f) (hg : IsPoly g) : IsPoly (f + g) := by
   rw [← sub_neg_eq_add]; exact hf.sub hg.neg
 #align is_poly.add IsPoly.add
+-/
 
+#print Poly /-
 /-- The type of multivariate integer polynomials -/
 def Poly (α : Type u) :=
   { f : (α → ℕ) → ℤ // IsPoly f }
 #align poly Poly
+-/
 
 namespace Poly
 
 section
 
+#print Poly.funLike /-
 instance funLike : FunLike (Poly α) (α → ℕ) fun _ => ℤ :=
   ⟨Subtype.val, Subtype.val_injective⟩
 #align poly.fun_like Poly.funLike
+-/
 
 /-- Helper instance for when there are too many metavariables to apply `fun_like.has_coe_to_fun`
 directly. -/
 instance : CoeFun (Poly α) fun _ => (α → ℕ) → ℤ :=
   FunLike.hasCoeToFun
 
+#print Poly.isPoly /-
 /-- The underlying function of a `poly` is a polynomial -/
 protected theorem isPoly (f : Poly α) : IsPoly f :=
   f.2
 #align poly.is_poly Poly.isPoly
+-/
 
+#print Poly.ext /-
 /-- Extensionality for `poly α` -/
 @[ext]
 theorem ext {f g : Poly α} : (∀ x, f x = g x) → f = g :=
   FunLike.ext _ _
 #align poly.ext Poly.ext
+-/
 
+#print Poly.proj /-
 /-- The `i`th projection function, `x_i`. -/
 def proj (i) : Poly α :=
   ⟨_, IsPoly.proj i⟩
 #align poly.proj Poly.proj
+-/
 
+#print Poly.proj_apply /-
 @[simp]
 theorem proj_apply (i : α) (x) : proj i x = x i :=
   rfl
 #align poly.proj_apply Poly.proj_apply
+-/
 
+#print Poly.const /-
 /-- The constant function with value `n : ℤ`. -/
 def const (n) : Poly α :=
   ⟨_, IsPoly.const n⟩
 #align poly.const Poly.const
+-/
 
+#print Poly.const_apply /-
 @[simp]
 theorem const_apply (n) (x : α → ℕ) : const n x = n :=
   rfl
 #align poly.const_apply Poly.const_apply
+-/
 
 instance : Zero (Poly α) :=
   ⟨const 0⟩
@@ -162,65 +184,89 @@ instance : Sub (Poly α) :=
 instance : Mul (Poly α) :=
   ⟨fun f g => ⟨f * g, f.2.mul g.2⟩⟩
 
+#print Poly.coe_zero /-
 @[simp]
 theorem coe_zero : ⇑(0 : Poly α) = const 0 :=
   rfl
 #align poly.coe_zero Poly.coe_zero
+-/
 
+#print Poly.coe_one /-
 @[simp]
 theorem coe_one : ⇑(1 : Poly α) = const 1 :=
   rfl
 #align poly.coe_one Poly.coe_one
+-/
 
+#print Poly.coe_neg /-
 @[simp]
 theorem coe_neg (f : Poly α) : ⇑(-f) = -f :=
   rfl
 #align poly.coe_neg Poly.coe_neg
+-/
 
+#print Poly.coe_add /-
 @[simp]
 theorem coe_add (f g : Poly α) : ⇑(f + g) = f + g :=
   rfl
 #align poly.coe_add Poly.coe_add
+-/
 
+#print Poly.coe_sub /-
 @[simp]
 theorem coe_sub (f g : Poly α) : ⇑(f - g) = f - g :=
   rfl
 #align poly.coe_sub Poly.coe_sub
+-/
 
+#print Poly.coe_mul /-
 @[simp]
 theorem coe_mul (f g : Poly α) : ⇑(f * g) = f * g :=
   rfl
 #align poly.coe_mul Poly.coe_mul
+-/
 
+#print Poly.zero_apply /-
 @[simp]
 theorem zero_apply (x) : (0 : Poly α) x = 0 :=
   rfl
 #align poly.zero_apply Poly.zero_apply
+-/
 
+#print Poly.one_apply /-
 @[simp]
 theorem one_apply (x) : (1 : Poly α) x = 1 :=
   rfl
 #align poly.one_apply Poly.one_apply
+-/
 
+#print Poly.neg_apply /-
 @[simp]
 theorem neg_apply (f : Poly α) (x) : (-f) x = -f x :=
   rfl
 #align poly.neg_apply Poly.neg_apply
+-/
 
+#print Poly.add_apply /-
 @[simp]
 theorem add_apply (f g : Poly α) (x : α → ℕ) : (f + g) x = f x + g x :=
   rfl
 #align poly.add_apply Poly.add_apply
+-/
 
+#print Poly.sub_apply /-
 @[simp]
 theorem sub_apply (f g : Poly α) (x : α → ℕ) : (f - g) x = f x - g x :=
   rfl
 #align poly.sub_apply Poly.sub_apply
+-/
 
+#print Poly.mul_apply /-
 @[simp]
 theorem mul_apply (f g : Poly α) (x : α → ℕ) : (f * g) x = f x * g x :=
   rfl
 #align poly.mul_apply Poly.mul_apply
+-/
 
 instance (α : Type _) : Inhabited (Poly α) :=
   ⟨0⟩
@@ -258,6 +304,7 @@ instance : CommRing (Poly α) := by
       refine' ext fun _ => _ <;>
     simp [sub_eq_add_neg, mul_add, mul_left_comm, mul_comm, add_comm, add_assoc]
 
+#print Poly.induction /-
 theorem induction {C : Poly α → Prop} (H1 : ∀ i, C (proj i)) (H2 : ∀ n, C (const n))
     (H3 : ∀ f g, C f → C g → C (f - g)) (H4 : ∀ f g, C f → C g → C (f * g)) (f : Poly α) : C f :=
   by
@@ -265,8 +312,10 @@ theorem induction {C : Poly α → Prop} (H1 : ∀ i, C (proj i)) (H2 : ∀ n, C
   induction' pf with i n f g pf pg ihf ihg f g pf pg ihf ihg
   apply H1; apply H2; apply H3 _ _ ihf ihg; apply H4 _ _ ihf ihg
 #align poly.induction Poly.induction
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Poly.sumsq /-
 /-- The sum of squares of a list of polynomials. This is relevant for
   Diophantine equations, because it means that a list of equations
   can be encoded as a single equation: `x = 0 ∧ y = 0 ∧ z = 0` is
@@ -275,15 +324,19 @@ def sumsq : List (Poly α) → Poly α
   | [] => 0
   | p::ps => p * p + sumsq ps
 #align poly.sumsq Poly.sumsq
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Poly.sumsq_nonneg /-
 theorem sumsq_nonneg (x : α → ℕ) : ∀ l, 0 ≤ sumsq l x
   | [] => le_refl 0
   | p::ps => by
     rw [sumsq] <;> simp [-add_comm] <;> exact add_nonneg (mul_self_nonneg _) (sumsq_nonneg ps)
 #align poly.sumsq_nonneg Poly.sumsq_nonneg
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Poly.sumsq_eq_zero /-
 theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.All₂ fun a : Poly α => a x = 0
   | [] => eq_self_iff_true _
   | p::ps => by
@@ -300,9 +353,11 @@ theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.All₂ fun a : Poly α =>
           ⟨this, by simp [this] at h  <;> exact h⟩,
           fun ⟨h1, h2⟩ => by rw [h1, h2] <;> rfl⟩
 #align poly.sumsq_eq_zero Poly.sumsq_eq_zero
+-/
 
 end
 
+#print Poly.map /-
 /-- Map the index set of variables, replacing `x_i` with `x_(f i)`. -/
 def map {α β} (f : α → β) (g : Poly α) : Poly β :=
   ⟨fun v => g <| v ∘ f,
@@ -310,6 +365,7 @@ def map {α β} (f : α → β) (g : Poly α) : Poly β :=
       (fun f g pf pg => by simp <;> apply IsPoly.sub pf pg) fun f g pf pg => by
       simp <;> apply IsPoly.mul pf pg⟩
 #align poly.map Poly.map
+-/
 
 @[simp]
 theorem map_apply {α β} (f : α → β) (g : Poly α) (v) : map f g v = g (v ∘ f) :=
@@ -323,11 +379,13 @@ end Polynomials
 /-! ### Diophantine sets -/
 
 
+#print Dioph /-
 /-- A set `S ⊆ ℕ^α` is Diophantine if there exists a polynomial on
   `α ⊕ β` such that `v ∈ S` iff there exists `t : ℕ^β` with `p (v, t) = 0`. -/
 def Dioph {α : Type u} (S : Set (α → ℕ)) : Prop :=
   ∃ (β : Type u) (p : Poly (Sum α β)), ∀ v, S v ↔ ∃ t, p (v ⊗ t) = 0
 #align dioph Dioph
+-/
 
 namespace Dioph
 
@@ -335,13 +393,18 @@ section
 
 variable {α β γ : Type u} {S S' : Set (α → ℕ)}
 
+#print Dioph.ext /-
 theorem ext (d : Dioph S) (H : ∀ v, v ∈ S ↔ v ∈ S') : Dioph S' := by rwa [← Set.ext H]
 #align dioph.ext Dioph.ext
+-/
 
+#print Dioph.of_no_dummies /-
 theorem of_no_dummies (S : Set (α → ℕ)) (p : Poly α) (h : ∀ v, S v ↔ p v = 0) : Dioph S :=
   ⟨PEmpty, p.map inl, fun v => (h v).trans ⟨fun h => ⟨PEmpty.rec _, h⟩, fun ⟨t, ht⟩ => ht⟩⟩
 #align dioph.of_no_dummies Dioph.of_no_dummies
+-/
 
+#print Dioph.inject_dummies_lem /-
 theorem inject_dummies_lem (f : β → γ) (g : γ → Option β) (inv : ∀ x, g (f x) = some x)
     (p : Poly (Sum α β)) (v : α → ℕ) :
     (∃ t, p (v ⊗ t) = 0) ↔ ∃ t, p.map (inl ⊗ inr ∘ f) (v ⊗ t) = 0 :=
@@ -353,15 +416,19 @@ theorem inject_dummies_lem (f : β → γ) (g : γ → Option β) (inv : ∀ x,
   · have : v ⊗ t ∘ f = (v ⊗ t) ∘ (inl ⊗ inr ∘ f) := funext fun s => by cases' s with a b <;> rfl
     exact ⟨t ∘ f, by rwa [this]⟩
 #align dioph.inject_dummies_lem Dioph.inject_dummies_lem
+-/
 
+#print Dioph.inject_dummies /-
 theorem inject_dummies (f : β → γ) (g : γ → Option β) (inv : ∀ x, g (f x) = some x)
     (p : Poly (Sum α β)) (h : ∀ v, S v ↔ ∃ t, p (v ⊗ t) = 0) :
     ∃ q : Poly (Sum α γ), ∀ v, S v ↔ ∃ t, q (v ⊗ t) = 0 :=
   ⟨p.map (inl ⊗ inr ∘ f), fun v => (h v).trans <| inject_dummies_lem f g inv _ _⟩
 #align dioph.inject_dummies Dioph.inject_dummies
+-/
 
 variable (β)
 
+#print Dioph.reindex_dioph /-
 theorem reindex_dioph (f : α → β) : ∀ d : Dioph S, Dioph {v | v ∘ f ∈ S}
   | ⟨γ, p, pe⟩ =>
     ⟨γ, p.map (inl ∘ f ⊗ inr), fun v =>
@@ -370,10 +437,12 @@ theorem reindex_dioph (f : α → β) : ∀ d : Dioph S, Dioph {v | v ∘ f ∈
           suffices v ∘ f ⊗ t = (v ⊗ t) ∘ (inl ∘ f ⊗ inr) by simp [this]
           funext fun s => by cases' s with a b <;> rfl⟩
 #align dioph.reindex_dioph Dioph.reindex_dioph
+-/
 
 variable {β}
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Dioph.DiophList.all₂ /-
 theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
     Dioph {v | l.All₂ fun S : Set (α → ℕ) => v ∈ S} :=
   by
@@ -419,6 +488,7 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
                       from funext fun s => by cases' s with a b <;> rfl] at
                     hq ⟩⟩⟩⟩
 #align dioph.dioph_list.all₂ Dioph.DiophList.all₂
+-/
 
 theorem inter (d : Dioph S) (d' : Dioph S') : Dioph (S ∩ S') :=
   DiophList.all₂ [S, S'] ⟨d, d'⟩
@@ -438,20 +508,27 @@ theorem union : ∀ (d : Dioph S) (d' : Dioph S'), Dioph (S ∪ S')
       exact inject_dummies_lem _ ((fun _ => none) ⊗ some) (fun x => rfl) _ _⟩
 #align dioph.union Dioph.union
 
+#print Dioph.DiophPfun /-
 /-- A partial function is Diophantine if its graph is Diophantine. -/
 def DiophPfun (f : (α → ℕ) →. ℕ) : Prop :=
   Dioph {v : Option α → ℕ | f.graph (v ∘ some, v none)}
 #align dioph.dioph_pfun Dioph.DiophPfun
+-/
 
+#print Dioph.DiophFn /-
 /-- A function is Diophantine if its graph is Diophantine. -/
 def DiophFn (f : (α → ℕ) → ℕ) : Prop :=
   Dioph {v : Option α → ℕ | f (v ∘ some) = v none}
 #align dioph.dioph_fn Dioph.DiophFn
+-/
 
+#print Dioph.reindex_diophFn /-
 theorem reindex_diophFn {f : (α → ℕ) → ℕ} (g : α → β) (d : DiophFn f) :
     DiophFn fun v => f (v ∘ g) := by convert reindex_dioph (Option β) (Option.map g) d
 #align dioph.reindex_dioph_fn Dioph.reindex_diophFn
+-/
 
+#print Dioph.ex_dioph /-
 theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph {v | ∃ x, v ⊗ x ∈ S}
   | ⟨γ, p, pe⟩ =>
     ⟨Sum β γ, p.map ((inl ⊗ inr ∘ inl) ⊗ inr ∘ inr), fun v =>
@@ -471,7 +548,9 @@ theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph {v | ∃ x, v
                     funext fun s => by cases' s with a b <;> try cases a <;> rfl] at
                   ht ⟩⟩⟩⟩
 #align dioph.ex_dioph Dioph.ex_dioph
+-/
 
+#print Dioph.ex1_dioph /-
 theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x, x ::ₒ v ∈ S}
   | ⟨β, p, pe⟩ =>
     ⟨Option β, p.map (inr none ::ₒ inl ⊗ inr ∘ some), fun v =>
@@ -491,24 +570,34 @@ theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x,
                     funext fun s => by cases' s with a b <;> try cases a <;> rfl] at
                   ht ⟩⟩⟩⟩
 #align dioph.ex1_dioph Dioph.ex1_dioph
+-/
 
+#print Dioph.dom_dioph /-
 theorem dom_dioph {f : (α → ℕ) →. ℕ} (d : DiophPfun f) : Dioph f.Dom :=
   cast (congr_arg Dioph <| Set.ext fun v => (PFun.dom_iff_graph _ _).symm) (ex1_dioph d)
 #align dioph.dom_dioph Dioph.dom_dioph
+-/
 
+#print Dioph.diophFn_iff_pFun /-
 theorem diophFn_iff_pFun (f : (α → ℕ) → ℕ) : DiophFn f = @DiophPfun α f := by
   refine' congr_arg Dioph (Set.ext fun v => _) <;> exact pfun.lift_graph.symm
 #align dioph.dioph_fn_iff_pfun Dioph.diophFn_iff_pFun
+-/
 
+#print Dioph.abs_poly_dioph /-
 theorem abs_poly_dioph (p : Poly α) : DiophFn fun v => (p v).natAbs :=
   of_no_dummies _ ((p.map some - Poly.proj none) * (p.map some + Poly.proj none)) fun v => by dsimp;
     exact Int.eq_natAbs_iff_mul_eq_zero
 #align dioph.abs_poly_dioph Dioph.abs_poly_dioph
+-/
 
+#print Dioph.proj_dioph /-
 theorem proj_dioph (i : α) : DiophFn fun v => v i :=
   abs_poly_dioph (Poly.proj i)
 #align dioph.proj_dioph Dioph.proj_dioph
+-/
 
+#print Dioph.diophPfun_comp1 /-
 theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : DiophPfun f) :
     Dioph {v : α → ℕ | ∃ h : f.Dom v, f.fn v h ::ₒ v ∈ S} :=
   ext (ex1_dioph (d.inter df)) fun v =>
@@ -522,12 +611,15 @@ theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : Di
         show Exists _ by
           rw [show (f.fn v x ::ₒ v) ∘ some = v from funext fun s => rfl] <;> exact ⟨x, rfl⟩⟩⟩
 #align dioph.dioph_pfun_comp1 Dioph.diophPfun_comp1
+-/
 
+#print Dioph.diophFn_comp1 /-
 theorem diophFn_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f : (α → ℕ) → ℕ} (df : DiophFn f) :
     Dioph {v | f v ::ₒ v ∈ S} :=
   ext (diophPfun_comp1 d <| cast (diophFn_iff_pFun f) df) fun v =>
     ⟨fun ⟨_, h⟩ => h, fun h => ⟨trivial, h⟩⟩
 #align dioph.dioph_fn_comp1 Dioph.diophFn_comp1
+-/
 
 end
 
@@ -543,15 +635,18 @@ attribute [local reducible] Vector3
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Dioph.diophFn_vec_comp1 /-
 theorem diophFn_vec_comp1 {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) {f : Vector3 ℕ n → ℕ}
     (df : DiophFn f) : Dioph {v : Vector3 ℕ n | (f v::v) ∈ S} :=
   ext (diophFn_comp1 (reindex_dioph _ (none::some) d) df) fun v => by dsimp; congr; ext x;
     cases x <;> rfl
 #align dioph.dioph_fn_vec_comp1 Dioph.diophFn_vec_comp1
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Dioph.vec_ex1_dioph /-
 theorem vec_ex1_dioph (n) {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) :
     Dioph {v : Fin2 n → ℕ | ∃ x, (x::v) ∈ S} :=
   ext (ex1_dioph <| reindex_dioph _ (none::some) d) fun v =>
@@ -560,21 +655,27 @@ theorem vec_ex1_dioph (n) {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) :
       rw [show Option.elim' x v ∘ cons none some = x::v from
           funext fun s => by cases' s with a b <;> rfl]
 #align dioph.vec_ex1_dioph Dioph.vec_ex1_dioph
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Dioph.diophFn_vec /-
 theorem diophFn_vec (f : Vector3 ℕ n → ℕ) : DiophFn f ↔ Dioph {v | f (v ∘ fs) = v fz} :=
   ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
 #align dioph.dioph_fn_vec Dioph.diophFn_vec
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Dioph.diophPfun_vec /-
 theorem diophPfun_vec (f : Vector3 ℕ n →. ℕ) : DiophPfun f ↔ Dioph {v | f.graph (v ∘ fs, v fz)} :=
   ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
 #align dioph.dioph_pfun_vec Dioph.diophPfun_vec
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Dioph.diophFn_compn /-
 theorem diophFn_compn :
     ∀ {n} {S : Set (Sum α (Fin2 n) → ℕ)} (d : Dioph S) {f : Vector3 ((α → ℕ) → ℕ) n}
       (df : VectorAllP DiophFn f), Dioph {v : α → ℕ | (v ⊗ fun i => f i v) ∈ S}
@@ -594,13 +695,17 @@ theorem diophFn_compn :
             @dioph_fn_compn n (fun v => S (v ∘ inl ⊗ f (v ∘ inl)::v ∘ inr)) this _ dfl
           ext this fun v => by dsimp; congr; ext x; obtain _ | _ | _ := x <;> rfl
 #align dioph.dioph_fn_compn Dioph.diophFn_compn
+-/
 
+#print Dioph.dioph_comp /-
 theorem dioph_comp {S : Set (Vector3 ℕ n)} (d : Dioph S) (f : Vector3 ((α → ℕ) → ℕ) n)
     (df : VectorAllP DiophFn f) : Dioph {v | (fun i => f i v) ∈ S} :=
   diophFn_compn (reindex_dioph _ inr d) df
 #align dioph.dioph_comp Dioph.dioph_comp
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Dioph.diophFn_comp /-
 theorem diophFn_comp {f : Vector3 ℕ n → ℕ} (df : DiophFn f) (g : Vector3 ((α → ℕ) → ℕ) n)
     (dg : VectorAllP DiophFn g) : DiophFn fun v => f fun i => g i v :=
   dioph_comp ((diophFn_vec _).1 df) ((fun v => v none)::fun i v => g i (v ∘ some)) <| by
@@ -610,6 +715,7 @@ theorem diophFn_comp {f : Vector3 ℕ n → ℕ} (df : DiophFn f) (g : Vector3 (
           (vectorAllP_iff_forall _ _).2 fun i =>
             reindex_dioph_fn _ <| (vectorAllP_iff_forall _ _).1 dg _⟩
 #align dioph.dioph_fn_comp Dioph.diophFn_comp
+-/
 
 -- mathport name: dioph.inter
 scoped notation:35 x " D∧ " y => Dioph.inter x y
@@ -623,16 +729,20 @@ scoped notation:30 "D∃" => Dioph.vec_ex1_dioph
 -- mathport name: fin2.of_nat'
 scoped prefix:arg "&" => Fin2.ofNat'
 
+#print Dioph.proj_dioph_of_nat /-
 theorem proj_dioph_of_nat {n : ℕ} (m : ℕ) [IsLT m n] : DiophFn fun v : Vector3 ℕ n => v &m :=
   proj_dioph &m
 #align dioph.proj_dioph_of_nat Dioph.proj_dioph_of_nat
+-/
 
 -- mathport name: proj_dioph_of_nat
 scoped prefix:100 "D&" => Dioph.proj_dioph_of_nat
 
+#print Dioph.const_dioph /-
 theorem const_dioph (n : ℕ) : DiophFn (const (α → ℕ) n) :=
   abs_poly_dioph (Poly.const n)
 #align dioph.const_dioph Dioph.const_dioph
+-/
 
 -- mathport name: const_dioph
 scoped prefix:100 "D." => Dioph.const_dioph
@@ -641,61 +751,78 @@ variable {f g : (α → ℕ) → ℕ} (df : DiophFn f) (dg : DiophFn g)
 
 include df dg
 
+#print Dioph.dioph_comp2 /-
 theorem dioph_comp2 {S : ℕ → ℕ → Prop} (d : Dioph fun v : Vector3 ℕ 2 => S (v &0) (v &1)) :
     Dioph fun v => S (f v) (g v) :=
   dioph_comp d [f, g] ⟨df, dg⟩
 #align dioph.dioph_comp2 Dioph.dioph_comp2
+-/
 
+#print Dioph.diophFn_comp2 /-
 theorem diophFn_comp2 {h : ℕ → ℕ → ℕ} (d : DiophFn fun v : Vector3 ℕ 2 => h (v &0) (v &1)) :
     DiophFn fun v => h (f v) (g v) :=
   diophFn_comp d [f, g] ⟨df, dg⟩
 #align dioph.dioph_fn_comp2 Dioph.diophFn_comp2
+-/
 
+#print Dioph.eq_dioph /-
 theorem eq_dioph : Dioph fun v => f v = g v :=
   dioph_comp2 df dg <|
     of_no_dummies _ (Poly.proj &0 - Poly.proj &1) fun v =>
       (Int.ofNat_inj _ _).symm.trans ⟨@sub_eq_zero_of_eq ℤ _ (v &0) (v &1), eq_of_sub_eq_zero⟩
 #align dioph.eq_dioph Dioph.eq_dioph
+-/
 
 -- mathport name: eq_dioph
 scoped infixl:50 " D= " => Dioph.eq_dioph
 
+#print Dioph.add_dioph /-
 theorem add_dioph : DiophFn fun v => f v + g v :=
   diophFn_comp2 df dg <| abs_poly_dioph (Poly.proj &0 + Poly.proj &1)
 #align dioph.add_dioph Dioph.add_dioph
+-/
 
 -- mathport name: add_dioph
 scoped infixl:80 " D+ " => Dioph.add_dioph
 
+#print Dioph.mul_dioph /-
 theorem mul_dioph : DiophFn fun v => f v * g v :=
   diophFn_comp2 df dg <| abs_poly_dioph (Poly.proj &0 * Poly.proj &1)
 #align dioph.mul_dioph Dioph.mul_dioph
+-/
 
 -- mathport name: mul_dioph
 scoped infixl:90 " D* " => Dioph.mul_dioph
 
+#print Dioph.le_dioph /-
 theorem le_dioph : Dioph {v | f v ≤ g v} :=
   dioph_comp2 df dg <|
     ext ((D∃) 2 <| D&1 D+ D&0 D= D&2) fun v => ⟨fun ⟨x, hx⟩ => le.intro hx, le.dest⟩
 #align dioph.le_dioph Dioph.le_dioph
+-/
 
 -- mathport name: le_dioph
 scoped infixl:50 " D≤ " => Dioph.le_dioph
 
+#print Dioph.lt_dioph /-
 theorem lt_dioph : Dioph {v | f v < g v} :=
   df D+ D.1 D≤ dg
 #align dioph.lt_dioph Dioph.lt_dioph
+-/
 
 -- mathport name: lt_dioph
 scoped infixl:50 " D< " => Dioph.lt_dioph
 
+#print Dioph.ne_dioph /-
 theorem ne_dioph : Dioph {v | f v ≠ g v} :=
   ext (df D< dg D∨ dg D< df) fun v => by dsimp; exact lt_or_lt_iff_ne
 #align dioph.ne_dioph Dioph.ne_dioph
+-/
 
 -- mathport name: ne_dioph
 scoped infixl:50 " D≠ " => Dioph.ne_dioph
 
+#print Dioph.sub_dioph /-
 theorem sub_dioph : DiophFn fun v => f v - g v :=
   diophFn_comp2 df dg <|
     (diophFn_vec _).2 <|
@@ -712,17 +839,21 @@ theorem sub_dioph : DiophFn fun v => f v - g v :=
               · exact Or.inr ⟨yz, tsub_eq_zero_iff_le.mpr yz⟩
               · exact Or.inl (tsub_add_cancel_of_le zy).symm⟩
 #align dioph.sub_dioph Dioph.sub_dioph
+-/
 
 -- mathport name: sub_dioph
 scoped infixl:80 " D- " => Dioph.sub_dioph
 
+#print Dioph.dvd_dioph /-
 theorem dvd_dioph : Dioph fun v => f v ∣ g v :=
   dioph_comp ((D∃) 2 <| D&2 D= D&1 D* D&0) [f, g] ⟨df, dg⟩
 #align dioph.dvd_dioph Dioph.dvd_dioph
+-/
 
 -- mathport name: dvd_dioph
 scoped infixl:50 " D∣ " => Dioph.dvd_dioph
 
+#print Dioph.mod_dioph /-
 theorem mod_dioph : DiophFn fun v => f v % g v :=
   have : Dioph fun v : Vector3 ℕ 3 => (v &2 = 0 ∨ v &0 < v &2) ∧ ∃ x : ℕ, v &0 + v &2 * x = v &1 :=
     (D&2 D= D.0 D∨ D&0 D< D&2) D∧ (D∃) 3 <| D&1 D+ D&3 D* D&0 D= D&2
@@ -739,17 +870,21 @@ theorem mod_dioph : DiophFn fun v => f v % g v :=
                   ⟨or_iff_not_imp_left.2 fun h => mod_lt _ (Nat.pos_of_ne_zero h), x / y,
                     mod_add_div _ _⟩⟩
 #align dioph.mod_dioph Dioph.mod_dioph
+-/
 
 -- mathport name: mod_dioph
 scoped infixl:80 " D% " => Dioph.mod_dioph
 
+#print Dioph.modEq_dioph /-
 theorem modEq_dioph {h : (α → ℕ) → ℕ} (dh : DiophFn h) : Dioph fun v => f v ≡ g v [MOD h v] :=
   df D% dh D= dg D% dh
 #align dioph.modeq_dioph Dioph.modEq_dioph
+-/
 
 -- mathport name: modeq_dioph
 scoped notation " D≡ " => Dioph.modEq_dioph
 
+#print Dioph.div_dioph /-
 theorem div_dioph : DiophFn fun v => f v / g v :=
   have :
     Dioph fun v : Vector3 ℕ 3 =>
@@ -774,6 +909,7 @@ theorem div_dioph : DiophFn fun v => f v / g v :=
                         and_congr (Nat.le_div_iff_mul_le ypos) <|
                           Iff.trans ⟨lt_succ_of_le, le_of_lt_succ⟩ (div_lt_iff_lt_mul ypos)).symm
 #align dioph.div_dioph Dioph.div_dioph
+-/
 
 -- mathport name: div_dioph
 scoped infixl:80 " D/ " => Dioph.div_dioph
@@ -782,6 +918,7 @@ omit df dg
 
 open Pell
 
+#print Dioph.pell_dioph /-
 theorem pell_dioph :
     Dioph fun v : Vector3 ℕ 4 => ∃ h : 1 < v &0, xn h (v &1) = v &2 ∧ yn h (v &1) = v &3 :=
   have :
@@ -819,7 +956,9 @@ theorem pell_dioph :
                                       D&3 D∧ D≡ (D&2) (D&7) (D&4) D∧ D≡ (D&1) (D&6) (D.4 D* D&8)
   Dioph.ext this fun v => matiyasevic.symm
 #align dioph.pell_dioph Dioph.pell_dioph
+-/
 
+#print Dioph.xn_dioph /-
 theorem xn_dioph : DiophPfun fun v : Vector3 ℕ 2 => ⟨1 < v &0, fun h => xn h (v &1)⟩ :=
   have : Dioph fun v : Vector3 ℕ 3 => ∃ y, ∃ h : 1 < v &1, xn h (v &2) = v &0 ∧ yn h (v &2) = y :=
     let D_pell := pell_dioph.reindex_dioph (Fin2 4) [&2, &3, &1, &0]
@@ -827,9 +966,11 @@ theorem xn_dioph : DiophPfun fun v : Vector3 ℕ 2 => ⟨1 < v &0, fun h => xn h
   (diophPfun_vec _).2 <|
     Dioph.ext this fun v => ⟨fun ⟨y, h, xe, ye⟩ => ⟨h, xe⟩, fun ⟨h, xe⟩ => ⟨_, h, xe, rfl⟩⟩
 #align dioph.xn_dioph Dioph.xn_dioph
+-/
 
 include df dg
 
+#print Dioph.pow_dioph /-
 /-- A version of **Matiyasevic's theorem** -/
 theorem pow_dioph : DiophFn fun v => f v ^ g v :=
   have :
@@ -878,6 +1019,7 @@ theorem pow_dioph : DiophFn fun v => f v ^ g v :=
                     ⟨fun ⟨w, a, t, z, a1, h⟩ => ⟨w, a, t, z, _, _, ⟨a1, rfl, rfl⟩, h⟩,
                       fun ⟨w, a, t, z, _, _, ⟨a1, rfl, rfl⟩, h⟩ => ⟨w, a, t, z, a1, h⟩⟩
 #align dioph.pow_dioph Dioph.pow_dioph
+-/
 
 end
 
Diff
@@ -577,7 +577,7 @@ theorem diophPfun_vec (f : Vector3 ℕ n →. ℕ) : DiophPfun f ↔ Dioph {v |
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem diophFn_compn :
     ∀ {n} {S : Set (Sum α (Fin2 n) → ℕ)} (d : Dioph S) {f : Vector3 ((α → ℕ) → ℕ) n}
-      (df : VectorAllp DiophFn f), Dioph {v : α → ℕ | (v ⊗ fun i => f i v) ∈ S}
+      (df : VectorAllP DiophFn f), Dioph {v : α → ℕ | (v ⊗ fun i => f i v) ∈ S}
   | 0, S, d, f => fun df =>
     ext (reindex_dioph _ (id ⊗ Fin2.elim0) d) fun v => by dsimp; congr; ext x;
       obtain _ | _ | _ := x; rfl
@@ -596,19 +596,19 @@ theorem diophFn_compn :
 #align dioph.dioph_fn_compn Dioph.diophFn_compn
 
 theorem dioph_comp {S : Set (Vector3 ℕ n)} (d : Dioph S) (f : Vector3 ((α → ℕ) → ℕ) n)
-    (df : VectorAllp DiophFn f) : Dioph {v | (fun i => f i v) ∈ S} :=
+    (df : VectorAllP DiophFn f) : Dioph {v | (fun i => f i v) ∈ S} :=
   diophFn_compn (reindex_dioph _ inr d) df
 #align dioph.dioph_comp Dioph.dioph_comp
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem diophFn_comp {f : Vector3 ℕ n → ℕ} (df : DiophFn f) (g : Vector3 ((α → ℕ) → ℕ) n)
-    (dg : VectorAllp DiophFn g) : DiophFn fun v => f fun i => g i v :=
+    (dg : VectorAllP DiophFn g) : DiophFn fun v => f fun i => g i v :=
   dioph_comp ((diophFn_vec _).1 df) ((fun v => v none)::fun i v => g i (v ∘ some)) <| by
     simp <;>
       exact
         ⟨proj_dioph none,
-          (vectorAllp_iff_forall _ _).2 fun i =>
-            reindex_dioph_fn _ <| (vectorAllp_iff_forall _ _).1 dg _⟩
+          (vectorAllP_iff_forall _ _).2 fun i =>
+            reindex_dioph_fn _ <| (vectorAllP_iff_forall _ _).1 dg _⟩
 #align dioph.dioph_fn_comp Dioph.diophFn_comp
 
 -- mathport name: dioph.inter
Diff
@@ -362,7 +362,7 @@ theorem inject_dummies (f : β → γ) (g : γ → Option β) (inv : ∀ x, g (f
 
 variable (β)
 
-theorem reindex_dioph (f : α → β) : ∀ d : Dioph S, Dioph { v | v ∘ f ∈ S }
+theorem reindex_dioph (f : α → β) : ∀ d : Dioph S, Dioph {v | v ∘ f ∈ S}
   | ⟨γ, p, pe⟩ =>
     ⟨γ, p.map (inl ∘ f ⊗ inr), fun v =>
       (pe _).trans <|
@@ -375,7 +375,7 @@ variable {β}
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
-    Dioph { v | l.All₂ fun S : Set (α → ℕ) => v ∈ S } :=
+    Dioph {v | l.All₂ fun S : Set (α → ℕ) => v ∈ S} :=
   by
   suffices
     ∃ (β : _) (pl : List (Poly (Sum α β))),
@@ -440,19 +440,19 @@ theorem union : ∀ (d : Dioph S) (d' : Dioph S'), Dioph (S ∪ S')
 
 /-- A partial function is Diophantine if its graph is Diophantine. -/
 def DiophPfun (f : (α → ℕ) →. ℕ) : Prop :=
-  Dioph { v : Option α → ℕ | f.graph (v ∘ some, v none) }
+  Dioph {v : Option α → ℕ | f.graph (v ∘ some, v none)}
 #align dioph.dioph_pfun Dioph.DiophPfun
 
 /-- A function is Diophantine if its graph is Diophantine. -/
 def DiophFn (f : (α → ℕ) → ℕ) : Prop :=
-  Dioph { v : Option α → ℕ | f (v ∘ some) = v none }
+  Dioph {v : Option α → ℕ | f (v ∘ some) = v none}
 #align dioph.dioph_fn Dioph.DiophFn
 
 theorem reindex_diophFn {f : (α → ℕ) → ℕ} (g : α → β) (d : DiophFn f) :
     DiophFn fun v => f (v ∘ g) := by convert reindex_dioph (Option β) (Option.map g) d
 #align dioph.reindex_dioph_fn Dioph.reindex_diophFn
 
-theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph { v | ∃ x, v ⊗ x ∈ S }
+theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph {v | ∃ x, v ⊗ x ∈ S}
   | ⟨γ, p, pe⟩ =>
     ⟨Sum β γ, p.map ((inl ⊗ inr ∘ inl) ⊗ inr ∘ inr), fun v =>
       ⟨fun ⟨x, hx⟩ =>
@@ -472,7 +472,7 @@ theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph { v | ∃ x,
                   ht ⟩⟩⟩⟩
 #align dioph.ex_dioph Dioph.ex_dioph
 
-theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph { v | ∃ x, x ::ₒ v ∈ S }
+theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x, x ::ₒ v ∈ S}
   | ⟨β, p, pe⟩ =>
     ⟨Option β, p.map (inr none ::ₒ inl ⊗ inr ∘ some), fun v =>
       ⟨fun ⟨x, hx⟩ =>
@@ -510,7 +510,7 @@ theorem proj_dioph (i : α) : DiophFn fun v => v i :=
 #align dioph.proj_dioph Dioph.proj_dioph
 
 theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : DiophPfun f) :
-    Dioph { v : α → ℕ | ∃ h : f.Dom v, f.fn v h ::ₒ v ∈ S } :=
+    Dioph {v : α → ℕ | ∃ h : f.Dom v, f.fn v h ::ₒ v ∈ S} :=
   ext (ex1_dioph (d.inter df)) fun v =>
     ⟨fun ⟨x, hS, (h : Exists _)⟩ => by
       rw [show (x ::ₒ v) ∘ some = v from funext fun s => rfl] at h  <;> cases' h with hf h <;>
@@ -524,7 +524,7 @@ theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : Di
 #align dioph.dioph_pfun_comp1 Dioph.diophPfun_comp1
 
 theorem diophFn_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f : (α → ℕ) → ℕ} (df : DiophFn f) :
-    Dioph { v | f v ::ₒ v ∈ S } :=
+    Dioph {v | f v ::ₒ v ∈ S} :=
   ext (diophPfun_comp1 d <| cast (diophFn_iff_pFun f) df) fun v =>
     ⟨fun ⟨_, h⟩ => h, fun h => ⟨trivial, h⟩⟩
 #align dioph.dioph_fn_comp1 Dioph.diophFn_comp1
@@ -544,7 +544,7 @@ attribute [local reducible] Vector3
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem diophFn_vec_comp1 {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) {f : Vector3 ℕ n → ℕ}
-    (df : DiophFn f) : Dioph { v : Vector3 ℕ n | (f v::v) ∈ S } :=
+    (df : DiophFn f) : Dioph {v : Vector3 ℕ n | (f v::v) ∈ S} :=
   ext (diophFn_comp1 (reindex_dioph _ (none::some) d) df) fun v => by dsimp; congr; ext x;
     cases x <;> rfl
 #align dioph.dioph_fn_vec_comp1 Dioph.diophFn_vec_comp1
@@ -553,7 +553,7 @@ theorem diophFn_vec_comp1 {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) {f : Ve
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem vec_ex1_dioph (n) {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) :
-    Dioph { v : Fin2 n → ℕ | ∃ x, (x::v) ∈ S } :=
+    Dioph {v : Fin2 n → ℕ | ∃ x, (x::v) ∈ S} :=
   ext (ex1_dioph <| reindex_dioph _ (none::some) d) fun v =>
     exists_congr fun x => by
       dsimp
@@ -562,12 +562,12 @@ theorem vec_ex1_dioph (n) {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) :
 #align dioph.vec_ex1_dioph Dioph.vec_ex1_dioph
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem diophFn_vec (f : Vector3 ℕ n → ℕ) : DiophFn f ↔ Dioph { v | f (v ∘ fs) = v fz } :=
+theorem diophFn_vec (f : Vector3 ℕ n → ℕ) : DiophFn f ↔ Dioph {v | f (v ∘ fs) = v fz} :=
   ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
 #align dioph.dioph_fn_vec Dioph.diophFn_vec
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem diophPfun_vec (f : Vector3 ℕ n →. ℕ) : DiophPfun f ↔ Dioph { v | f.graph (v ∘ fs, v fz) } :=
+theorem diophPfun_vec (f : Vector3 ℕ n →. ℕ) : DiophPfun f ↔ Dioph {v | f.graph (v ∘ fs, v fz)} :=
   ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
 #align dioph.dioph_pfun_vec Dioph.diophPfun_vec
 
@@ -577,7 +577,7 @@ theorem diophPfun_vec (f : Vector3 ℕ n →. ℕ) : DiophPfun f ↔ Dioph { v |
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem diophFn_compn :
     ∀ {n} {S : Set (Sum α (Fin2 n) → ℕ)} (d : Dioph S) {f : Vector3 ((α → ℕ) → ℕ) n}
-      (df : VectorAllp DiophFn f), Dioph { v : α → ℕ | (v ⊗ fun i => f i v) ∈ S }
+      (df : VectorAllp DiophFn f), Dioph {v : α → ℕ | (v ⊗ fun i => f i v) ∈ S}
   | 0, S, d, f => fun df =>
     ext (reindex_dioph _ (id ⊗ Fin2.elim0) d) fun v => by dsimp; congr; ext x;
       obtain _ | _ | _ := x; rfl
@@ -585,18 +585,18 @@ theorem diophFn_compn :
     f.consElim fun f fl => by
       simp <;>
         exact fun df dfl =>
-          have : Dioph { v | (v ∘ inl ⊗ f (v ∘ inl)::v ∘ inr) ∈ S } :=
+          have : Dioph {v | (v ∘ inl ⊗ f (v ∘ inl)::v ∘ inr) ∈ S} :=
             ext
               (dioph_fn_comp1 (reindex_dioph _ (some ∘ inl ⊗ none::some ∘ inr) d) <|
                 reindex_dioph_fn inl df)
               fun v => by dsimp; congr; ext x; obtain _ | _ | _ := x <;> rfl
-          have : Dioph { v | (v ⊗ f v::fun i : Fin2 n => fl i v) ∈ S } :=
+          have : Dioph {v | (v ⊗ f v::fun i : Fin2 n => fl i v) ∈ S} :=
             @dioph_fn_compn n (fun v => S (v ∘ inl ⊗ f (v ∘ inl)::v ∘ inr)) this _ dfl
           ext this fun v => by dsimp; congr; ext x; obtain _ | _ | _ := x <;> rfl
 #align dioph.dioph_fn_compn Dioph.diophFn_compn
 
 theorem dioph_comp {S : Set (Vector3 ℕ n)} (d : Dioph S) (f : Vector3 ((α → ℕ) → ℕ) n)
-    (df : VectorAllp DiophFn f) : Dioph { v | (fun i => f i v) ∈ S } :=
+    (df : VectorAllp DiophFn f) : Dioph {v | (fun i => f i v) ∈ S} :=
   diophFn_compn (reindex_dioph _ inr d) df
 #align dioph.dioph_comp Dioph.dioph_comp
 
@@ -674,7 +674,7 @@ theorem mul_dioph : DiophFn fun v => f v * g v :=
 -- mathport name: mul_dioph
 scoped infixl:90 " D* " => Dioph.mul_dioph
 
-theorem le_dioph : Dioph { v | f v ≤ g v } :=
+theorem le_dioph : Dioph {v | f v ≤ g v} :=
   dioph_comp2 df dg <|
     ext ((D∃) 2 <| D&1 D+ D&0 D= D&2) fun v => ⟨fun ⟨x, hx⟩ => le.intro hx, le.dest⟩
 #align dioph.le_dioph Dioph.le_dioph
@@ -682,14 +682,14 @@ theorem le_dioph : Dioph { v | f v ≤ g v } :=
 -- mathport name: le_dioph
 scoped infixl:50 " D≤ " => Dioph.le_dioph
 
-theorem lt_dioph : Dioph { v | f v < g v } :=
+theorem lt_dioph : Dioph {v | f v < g v} :=
   df D+ D.1 D≤ dg
 #align dioph.lt_dioph Dioph.lt_dioph
 
 -- mathport name: lt_dioph
 scoped infixl:50 " D< " => Dioph.lt_dioph
 
-theorem ne_dioph : Dioph { v | f v ≠ g v } :=
+theorem ne_dioph : Dioph {v | f v ≠ g v} :=
   ext (df D< dg D∨ dg D< df) fun v => by dsimp; exact lt_or_lt_iff_ne
 #align dioph.ne_dioph Dioph.ne_dioph
 
@@ -786,7 +786,7 @@ theorem pell_dioph :
     Dioph fun v : Vector3 ℕ 4 => ∃ h : 1 < v &0, xn h (v &1) = v &2 ∧ yn h (v &1) = v &3 :=
   have :
     Dioph
-      { v : Vector3 ℕ 4 |
+      {v : Vector3 ℕ 4 |
         1 < v &0 ∧
           v &1 ≤ v &3 ∧
             (v &2 = 1 ∧ v &3 = 0 ∨
@@ -798,7 +798,7 @@ theorem pell_dioph :
                         b ≡ 1 [MOD 4 * v &3] ∧
                           b ≡ v &0 [MOD u] ∧
                             0 < w ∧
-                              v &3 * v &3 ∣ w ∧ s ≡ v &2 [MOD u] ∧ t ≡ v &1 [MOD 4 * v &3]) } :=
+                              v &3 * v &3 ∣ w ∧ s ≡ v &2 [MOD u] ∧ t ≡ v &1 [MOD 4 * v &3])} :=
     D.1 D< D&0 D∧
       D&1 D≤ D&3 D∧
         (D&2 D= D.1 D∧ D&3 D= D.0) D∨
@@ -834,7 +834,7 @@ include df dg
 theorem pow_dioph : DiophFn fun v => f v ^ g v :=
   have :
     Dioph
-      { v : Vector3 ℕ 3 |
+      {v : Vector3 ℕ 3 |
         v &2 = 0 ∧ v &0 = 1 ∨
           0 < v &2 ∧
             (v &1 = 0 ∧ v &0 = 0 ∨
@@ -845,7 +845,7 @@ theorem pow_dioph : DiophFn fun v => f v ^ g v :=
                       2 * a * v &1 = t + (v &1 * v &1 + 1) ∧
                         v &0 < t ∧
                           v &1 ≤ w ∧
-                            v &2 ≤ w ∧ a * a - ((w + 1) * (w + 1) - 1) * (w * z) * (w * z) = 1) } :=
+                            v &2 ≤ w ∧ a * a - ((w + 1) * (w + 1) - 1) * (w * z) * (w * z) = 1)} :=
     let D_pell := pell_dioph.reindex_dioph (Fin2 9) [&4, &8, &1, &0]
     (D&2 D= D.0 D∧ D&0 D= D.1) D∨
       D.0 D< D&2 D∧
Diff
@@ -295,9 +295,9 @@ theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.All₂ fun a : Poly α =>
               le_antisymm
                 (by
                   rw [← h] <;> have t := add_le_add_left (sumsq_nonneg x ps) (p x * p x) <;>
-                    rwa [add_zero] at t)
+                    rwa [add_zero] at t )
                 (mul_self_nonneg _)
-          ⟨this, by simp [this] at h <;> exact h⟩,
+          ⟨this, by simp [this] at h  <;> exact h⟩,
           fun ⟨h1, h2⟩ => by rw [h1, h2] <;> rfl⟩
 #align poly.sumsq_eq_zero Poly.sumsq_eq_zero
 
@@ -326,7 +326,7 @@ end Polynomials
 /-- A set `S ⊆ ℕ^α` is Diophantine if there exists a polynomial on
   `α ⊕ β` such that `v ∈ S` iff there exists `t : ℕ^β` with `p (v, t) = 0`. -/
 def Dioph {α : Type u} (S : Set (α → ℕ)) : Prop :=
-  ∃ (β : Type u)(p : Poly (Sum α β)), ∀ v, S v ↔ ∃ t, p (v ⊗ t) = 0
+  ∃ (β : Type u) (p : Poly (Sum α β)), ∀ v, S v ↔ ∃ t, p (v ⊗ t) = 0
 #align dioph Dioph
 
 namespace Dioph
@@ -378,7 +378,7 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
     Dioph { v | l.All₂ fun S : Set (α → ℕ) => v ∈ S } :=
   by
   suffices
-    ∃ (β : _)(pl : List (Poly (Sum α β))),
+    ∃ (β : _) (pl : List (Poly (Sum α β))),
       ∀ v,
         List.All₂ (fun S : Set _ => S v) l ↔
           ∃ t, List.All₂ (fun p : Poly (Sum α β) => p (v ⊗ t) = 0) pl
@@ -387,7 +387,7 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
     ⟨β, Poly.sumsq pl, fun v => (h v).trans <| exists_congr fun t => (Poly.sumsq_eq_zero _ _).symm⟩
   induction' l with S l IH
   exact ⟨ULift Empty, [], fun v => by simp <;> exact ⟨fun ⟨t⟩ => Empty.rec _ t, trivial⟩⟩
-  simp at d
+  simp at d 
   exact
     let ⟨⟨β, p, pe⟩, dl⟩ := d
     let ⟨γ, pl, ple⟩ := IH dl
@@ -410,14 +410,14 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
               ⟨⟨t ∘ inl, by
                   rwa [show (v ⊗ t) ∘ (inl ⊗ inr ∘ inl) = v ⊗ t ∘ inl from
                       funext fun s => by cases' s with a b <;> rfl] at
-                    hl⟩,
+                    hl ⟩,
                 ⟨t ∘ inr, by
-                  refine' List.All₂.imp (fun q hq => _) hr; dsimp [(· ∘ ·)] at hq
+                  refine' List.All₂.imp (fun q hq => _) hr; dsimp [(· ∘ ·)] at hq 
                   rwa [show
                       (fun x : Sum α γ => (v ⊗ t) ((inl ⊗ fun x : γ => inr (inr x)) x)) =
                         v ⊗ t ∘ inr
                       from funext fun s => by cases' s with a b <;> rfl] at
-                    hq⟩⟩⟩⟩
+                    hq ⟩⟩⟩⟩
 #align dioph.dioph_list.all₂ Dioph.DiophList.all₂
 
 theorem inter (d : Dioph S) (d' : Dioph S') : Dioph (S ∩ S') :=
@@ -466,10 +466,10 @@ theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph { v | ∃ x,
         ⟨t ∘ inl,
           (pe _).2
             ⟨t ∘ inr, by
-              simp at ht <;>
+              simp at ht  <;>
                 rwa [show (v ⊗ t) ∘ ((inl ⊗ inr ∘ inl) ⊗ inr ∘ inr) = (v ⊗ t ∘ inl) ⊗ t ∘ inr from
                     funext fun s => by cases' s with a b <;> try cases a <;> rfl] at
-                  ht⟩⟩⟩⟩
+                  ht ⟩⟩⟩⟩
 #align dioph.ex_dioph Dioph.ex_dioph
 
 theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph { v | ∃ x, x ::ₒ v ∈ S }
@@ -486,10 +486,10 @@ theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph { v | ∃ x,
         ⟨t none,
           (pe _).2
             ⟨t ∘ some, by
-              simp at ht <;>
+              simp at ht  <;>
                 rwa [show (v ⊗ t) ∘ (inr none ::ₒ inl ⊗ inr ∘ some) = t none ::ₒ v ⊗ t ∘ some from
                     funext fun s => by cases' s with a b <;> try cases a <;> rfl] at
-                  ht⟩⟩⟩⟩
+                  ht ⟩⟩⟩⟩
 #align dioph.ex1_dioph Dioph.ex1_dioph
 
 theorem dom_dioph {f : (α → ℕ) →. ℕ} (d : DiophPfun f) : Dioph f.Dom :=
@@ -513,7 +513,7 @@ theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : Di
     Dioph { v : α → ℕ | ∃ h : f.Dom v, f.fn v h ::ₒ v ∈ S } :=
   ext (ex1_dioph (d.inter df)) fun v =>
     ⟨fun ⟨x, hS, (h : Exists _)⟩ => by
-      rw [show (x ::ₒ v) ∘ some = v from funext fun s => rfl] at h <;> cases' h with hf h <;>
+      rw [show (x ::ₒ v) ∘ some = v from funext fun s => rfl] at h  <;> cases' h with hf h <;>
             refine' ⟨hf, _⟩ <;>
           rw [PFun.fn, h] <;>
         exact hS,
@@ -545,7 +545,7 @@ attribute [local reducible] Vector3
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem diophFn_vec_comp1 {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) {f : Vector3 ℕ n → ℕ}
     (df : DiophFn f) : Dioph { v : Vector3 ℕ n | (f v::v) ∈ S } :=
-  ext (diophFn_comp1 (reindex_dioph _ (none::some) d) df) fun v => by dsimp; congr ; ext x;
+  ext (diophFn_comp1 (reindex_dioph _ (none::some) d) df) fun v => by dsimp; congr; ext x;
     cases x <;> rfl
 #align dioph.dioph_fn_vec_comp1 Dioph.diophFn_vec_comp1
 
@@ -579,7 +579,7 @@ theorem diophFn_compn :
     ∀ {n} {S : Set (Sum α (Fin2 n) → ℕ)} (d : Dioph S) {f : Vector3 ((α → ℕ) → ℕ) n}
       (df : VectorAllp DiophFn f), Dioph { v : α → ℕ | (v ⊗ fun i => f i v) ∈ S }
   | 0, S, d, f => fun df =>
-    ext (reindex_dioph _ (id ⊗ Fin2.elim0) d) fun v => by dsimp; congr ; ext x;
+    ext (reindex_dioph _ (id ⊗ Fin2.elim0) d) fun v => by dsimp; congr; ext x;
       obtain _ | _ | _ := x; rfl
   | succ n, S, d, f =>
     f.consElim fun f fl => by
@@ -589,10 +589,10 @@ theorem diophFn_compn :
             ext
               (dioph_fn_comp1 (reindex_dioph _ (some ∘ inl ⊗ none::some ∘ inr) d) <|
                 reindex_dioph_fn inl df)
-              fun v => by dsimp; congr ; ext x; obtain _ | _ | _ := x <;> rfl
+              fun v => by dsimp; congr; ext x; obtain _ | _ | _ := x <;> rfl
           have : Dioph { v | (v ⊗ f v::fun i : Fin2 n => fl i v) ∈ S } :=
             @dioph_fn_compn n (fun v => S (v ∘ inl ⊗ f (v ∘ inl)::v ∘ inr)) this _ dfl
-          ext this fun v => by dsimp; congr ; ext x; obtain _ | _ | _ := x <;> rfl
+          ext this fun v => by dsimp; congr; ext x; obtain _ | _ | _ := x <;> rfl
 #align dioph.dioph_fn_compn Dioph.diophFn_compn
 
 theorem dioph_comp {S : Set (Vector3 ℕ n)} (d : Dioph S) (f : Vector3 ((α → ℕ) → ℕ) n)
Diff
@@ -537,7 +537,7 @@ variable {α β : Type} {n : ℕ}
 
 open Vector3
 
-open Vector3
+open scoped Vector3
 
 attribute [local reducible] Vector3
 
Diff
@@ -87,16 +87,12 @@ inductive IsPoly : ((α → ℕ) → ℤ) → Prop
   | mul : ∀ {f g : (α → ℕ) → ℤ}, IsPoly f → IsPoly g → IsPoly fun x => f x * g x
 #align is_poly IsPoly
 
-theorem IsPoly.neg {f : (α → ℕ) → ℤ} : IsPoly f → IsPoly (-f) :=
-  by
-  rw [← zero_sub]
+theorem IsPoly.neg {f : (α → ℕ) → ℤ} : IsPoly f → IsPoly (-f) := by rw [← zero_sub];
   exact (IsPoly.const 0).sub
 #align is_poly.neg IsPoly.neg
 
-theorem IsPoly.add {f g : (α → ℕ) → ℤ} (hf : IsPoly f) (hg : IsPoly g) : IsPoly (f + g) :=
-  by
-  rw [← sub_neg_eq_add]
-  exact hf.sub hg.neg
+theorem IsPoly.add {f g : (α → ℕ) → ℤ} (hf : IsPoly f) (hg : IsPoly g) : IsPoly (f + g) := by
+  rw [← sub_neg_eq_add]; exact hf.sub hg.neg
 #align is_poly.add IsPoly.add
 
 /-- The type of multivariate integer polynomials -/
@@ -405,8 +401,7 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
                       funext fun s => by cases' s with a b <;> rfl] <;>
                   exact hm,
                 by
-                refine' List.All₂.imp (fun q hq => _) hn
-                dsimp [(· ∘ ·)]
+                refine' List.All₂.imp (fun q hq => _) hn; dsimp [(· ∘ ·)]
                 rw [show
                       (fun x : Sum α γ => (v ⊗ m ⊗ n) ((inl ⊗ fun x : γ => inr (inr x)) x)) = v ⊗ n
                       from funext fun s => by cases' s with a b <;> rfl] <;>
@@ -417,8 +412,7 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
                       funext fun s => by cases' s with a b <;> rfl] at
                     hl⟩,
                 ⟨t ∘ inr, by
-                  refine' List.All₂.imp (fun q hq => _) hr
-                  dsimp [(· ∘ ·)] at hq
+                  refine' List.All₂.imp (fun q hq => _) hr; dsimp [(· ∘ ·)] at hq
                   rwa [show
                       (fun x : Sum α γ => (v ⊗ t) ((inl ⊗ fun x : γ => inr (inr x)) x)) =
                         v ⊗ t ∘ inr
@@ -507,9 +501,7 @@ theorem diophFn_iff_pFun (f : (α → ℕ) → ℕ) : DiophFn f = @DiophPfun α
 #align dioph.dioph_fn_iff_pfun Dioph.diophFn_iff_pFun
 
 theorem abs_poly_dioph (p : Poly α) : DiophFn fun v => (p v).natAbs :=
-  of_no_dummies _ ((p.map some - Poly.proj none) * (p.map some + Poly.proj none)) fun v =>
-    by
-    dsimp
+  of_no_dummies _ ((p.map some - Poly.proj none) * (p.map some + Poly.proj none)) fun v => by dsimp;
     exact Int.eq_natAbs_iff_mul_eq_zero
 #align dioph.abs_poly_dioph Dioph.abs_poly_dioph
 
@@ -553,11 +545,7 @@ attribute [local reducible] Vector3
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem diophFn_vec_comp1 {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) {f : Vector3 ℕ n → ℕ}
     (df : DiophFn f) : Dioph { v : Vector3 ℕ n | (f v::v) ∈ S } :=
-  ext (diophFn_comp1 (reindex_dioph _ (none::some) d) df) fun v =>
-    by
-    dsimp
-    congr
-    ext x
+  ext (diophFn_comp1 (reindex_dioph _ (none::some) d) df) fun v => by dsimp; congr ; ext x;
     cases x <;> rfl
 #align dioph.dioph_fn_vec_comp1 Dioph.diophFn_vec_comp1
 
@@ -591,13 +579,8 @@ theorem diophFn_compn :
     ∀ {n} {S : Set (Sum α (Fin2 n) → ℕ)} (d : Dioph S) {f : Vector3 ((α → ℕ) → ℕ) n}
       (df : VectorAllp DiophFn f), Dioph { v : α → ℕ | (v ⊗ fun i => f i v) ∈ S }
   | 0, S, d, f => fun df =>
-    ext (reindex_dioph _ (id ⊗ Fin2.elim0) d) fun v =>
-      by
-      dsimp
-      congr
-      ext x
-      obtain _ | _ | _ := x
-      rfl
+    ext (reindex_dioph _ (id ⊗ Fin2.elim0) d) fun v => by dsimp; congr ; ext x;
+      obtain _ | _ | _ := x; rfl
   | succ n, S, d, f =>
     f.consElim fun f fl => by
       simp <;>
@@ -606,18 +589,10 @@ theorem diophFn_compn :
             ext
               (dioph_fn_comp1 (reindex_dioph _ (some ∘ inl ⊗ none::some ∘ inr) d) <|
                 reindex_dioph_fn inl df)
-              fun v => by
-              dsimp
-              congr
-              ext x
-              obtain _ | _ | _ := x <;> rfl
+              fun v => by dsimp; congr ; ext x; obtain _ | _ | _ := x <;> rfl
           have : Dioph { v | (v ⊗ f v::fun i : Fin2 n => fl i v) ∈ S } :=
             @dioph_fn_compn n (fun v => S (v ∘ inl ⊗ f (v ∘ inl)::v ∘ inr)) this _ dfl
-          ext this fun v => by
-            dsimp
-            congr
-            ext x
-            obtain _ | _ | _ := x <;> rfl
+          ext this fun v => by dsimp; congr ; ext x; obtain _ | _ | _ := x <;> rfl
 #align dioph.dioph_fn_compn Dioph.diophFn_compn
 
 theorem dioph_comp {S : Set (Vector3 ℕ n)} (d : Dioph S) (f : Vector3 ((α → ℕ) → ℕ) n)
@@ -715,9 +690,7 @@ theorem lt_dioph : Dioph { v | f v < g v } :=
 scoped infixl:50 " D< " => Dioph.lt_dioph
 
 theorem ne_dioph : Dioph { v | f v ≠ g v } :=
-  ext (df D< dg D∨ dg D< df) fun v => by
-    dsimp
-    exact lt_or_lt_iff_ne
+  ext (df D< dg D∨ dg D< df) fun v => by dsimp; exact lt_or_lt_iff_ne
 #align dioph.ne_dioph Dioph.ne_dioph
 
 -- mathport name: ne_dioph
Diff
@@ -4,14 +4,14 @@ 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.dioph
-! leanprover-community/mathlib commit 356447fe00e75e54777321045cdff7c9ea212e60
+! leanprover-community/mathlib commit a66d07e27d5b5b8ac1147cacfe353478e5c14002
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.Data.Fin.Fin2
 import Mathbin.Data.Pfun
 import Mathbin.Data.Vector3
-import Mathbin.NumberTheory.Pell
+import Mathbin.NumberTheory.PellMatiyasevic
 
 /-!
 # Diophantine functions and Matiyasevic's theorem

Changes in mathlib4

mathlib3
mathlib4
chore: remove mathport name: <expression> lines (#11928)

Quoting [@digama0](https://github.com/digama0):

These were actually never meant to go in the file, they are basically debugging information and only useful on significantly broken mathport files. You can safely remove all of them.

Diff
@@ -609,21 +609,18 @@ theorem eq_dioph : Dioph fun v => f v = g v :=
       exact Int.ofNat_inj.symm.trans ⟨@sub_eq_zero_of_eq ℤ _ (v &0) (v &1), eq_of_sub_eq_zero⟩
 #align dioph.eq_dioph Dioph.eq_dioph
 
--- mathport name: eq_dioph
 scoped infixl:50 " D= " => Dioph.eq_dioph
 
 theorem add_dioph : DiophFn fun v => f v + g v :=
   diophFn_comp2 df dg <| abs_poly_dioph (@Poly.proj (Fin2 2) &0 + @Poly.proj (Fin2 2) &1)
 #align dioph.add_dioph Dioph.add_dioph
 
--- mathport name: add_dioph
 scoped infixl:80 " D+ " => Dioph.add_dioph
 
 theorem mul_dioph : DiophFn fun v => f v * g v :=
   diophFn_comp2 df dg <| abs_poly_dioph (@Poly.proj (Fin2 2) &0 * @Poly.proj (Fin2 2) &1)
 #align dioph.mul_dioph Dioph.mul_dioph
 
--- mathport name: mul_dioph
 scoped infixl:90 " D* " => Dioph.mul_dioph
 
 theorem le_dioph : Dioph {v | f v ≤ g v} :=
@@ -714,7 +711,6 @@ theorem div_dioph : DiophFn fun v => f v / g v :=
                     Iff.trans ⟨lt_succ_of_le, le_of_lt_succ⟩ (div_lt_iff_lt_mul ypos)).symm
 #align dioph.div_dioph Dioph.div_dioph
 
--- mathport name: div_dioph
 scoped infixl:80 " D/ " => Dioph.div_dioph
 
 open Pell
refactor: Use nsmul in zsmul_rec (#862)

It's annoying that zsmulRec uses nsmulRec to define zsmul even when the user already set nsmul explicitly. This PR changes zsmulRec to take nsmul as an argument.

Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>

Diff
@@ -194,8 +194,9 @@ instance : AddCommGroup (Poly α) := by
             neg := (Neg.neg : Poly α → Poly α)
             sub := Sub.sub
             zero := 0
-            zsmul := @zsmulRec _ ⟨(0 : Poly α)⟩ ⟨(· + ·)⟩ ⟨Neg.neg⟩
             nsmul := @nsmulRec _ ⟨(0 : Poly α)⟩ ⟨(· + ·)⟩
+            zsmul := @zsmulRec _ ⟨(0 : Poly α)⟩ ⟨(· + ·)⟩ ⟨Neg.neg⟩
+              (@nsmulRec _ ⟨(0 : Poly α)⟩ ⟨(· + ·)⟩)
             .. }
   all_goals
     intros
chore: solve not necessary anymore porting notes (#11086)

Solves porting notes claiming

  • "not necessary anymore"
  • "not used anymore"

by simply deleting them.

Diff
@@ -102,11 +102,6 @@ instance instFunLike : FunLike (Poly α) (α → ℕ) ℤ :=
   ⟨Subtype.val, Subtype.val_injective⟩
 #align poly.fun_like Poly.instFunLike
 
--- Porting note: This instance is not necessary anymore
--- /-- Helper instance for when there are too many metavariables to apply `DFunLike.hasCoeToFun`
--- directly. -/
--- instance : CoeFun (Poly α) fun _ => (α → ℕ) → ℤ := DFunLike.hasCoeToFun
-
 /-- The underlying function of a `Poly` is a polynomial -/
 protected theorem isPoly (f : Poly α) : IsPoly f := f.2
 #align poly.is_poly Poly.isPoly
refactor(*): abbreviation for non-dependent FunLike (#9833)

This follows up from #9785, which renamed FunLike to DFunLike, by introducing a new abbreviation FunLike F α β := DFunLike F α (fun _ => β), to make the non-dependent use of FunLike easier.

I searched for the pattern DFunLike.*fun and DFunLike.*λ in all files to replace expressions of the form DFunLike F α (fun _ => β) with FunLike F α β. I did this everywhere except for extends clauses for two reasons: it would conflict with #8386, and more importantly extends must directly refer to a structure with no unfolding of defs or abbrevs.

Diff
@@ -98,9 +98,9 @@ namespace Poly
 
 section
 
-instance instDFunLike : DFunLike (Poly α) (α → ℕ) fun _ => ℤ :=
+instance instFunLike : FunLike (Poly α) (α → ℕ) ℤ :=
   ⟨Subtype.val, Subtype.val_injective⟩
-#align poly.fun_like Poly.instDFunLike
+#align poly.fun_like Poly.instFunLike
 
 -- Porting note: This instance is not necessary anymore
 -- /-- Helper instance for when there are too many metavariables to apply `DFunLike.hasCoeToFun`
chore(*): rename FunLike to DFunLike (#9785)

This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.

This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:

sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean     
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -98,14 +98,14 @@ namespace Poly
 
 section
 
-instance funLike : FunLike (Poly α) (α → ℕ) fun _ => ℤ :=
+instance instDFunLike : DFunLike (Poly α) (α → ℕ) fun _ => ℤ :=
   ⟨Subtype.val, Subtype.val_injective⟩
-#align poly.fun_like Poly.funLike
+#align poly.fun_like Poly.instDFunLike
 
 -- Porting note: This instance is not necessary anymore
--- /-- Helper instance for when there are too many metavariables to apply `fun_like.has_coe_to_fun`
+-- /-- Helper instance for when there are too many metavariables to apply `DFunLike.hasCoeToFun`
 -- directly. -/
--- instance : CoeFun (Poly α) fun _ => (α → ℕ) → ℤ := FunLike.hasCoeToFun
+-- instance : CoeFun (Poly α) fun _ => (α → ℕ) → ℤ := DFunLike.hasCoeToFun
 
 /-- The underlying function of a `Poly` is a polynomial -/
 protected theorem isPoly (f : Poly α) : IsPoly f := f.2
@@ -113,7 +113,7 @@ protected theorem isPoly (f : Poly α) : IsPoly f := f.2
 
 /-- Extensionality for `Poly α` -/
 @[ext]
-theorem ext {f g : Poly α} : (∀ x, f x = g x) → f = g := FunLike.ext _ _
+theorem ext {f g : Poly α} : (∀ x, f x = g x) → f = g := DFunLike.ext _ _
 #align poly.ext Poly.ext
 
 /-- The `i`th projection function, `x_i`. -/
chore(*): use α → β instead of ∀ _ : α, β (#9529)
Diff
@@ -341,7 +341,7 @@ theorem inject_dummies (f : β → γ) (g : γ → Option β) (inv : ∀ x, g (f
 
 variable (β)
 
-theorem reindex_dioph (f : α → β) : ∀ _ : Dioph S, Dioph {v | v ∘ f ∈ S}
+theorem reindex_dioph (f : α → β) : Dioph S → Dioph {v | v ∘ f ∈ S}
   | ⟨γ, p, pe⟩ => ⟨γ, p.map (inl ∘ f ⊗ inr), fun v =>
       (pe _).trans <|
         exists_congr fun t =>
chore(*): replace $ with <| (#9319)

See Zulip thread for the discussion.

Diff
@@ -765,7 +765,7 @@ theorem pow_dioph : DiophFn fun v => f v ^ g v := by
     let D_pell := pell_dioph.reindex_dioph (Fin2 9) [&4, &8, &1, &0]
     (D&2 D= D.0 D∧ D&0 D= D.1) D∨ (D.0 D< D&2 D∧
     ((D&1 D= D.0 D∧ D&0 D= D.0) D∨ (D.0 D< D&1 D∧
-    ((D∃) 3 <| (D∃) 4 <| (D∃) 5 <| (D∃) 6 $ (D∃) 7 <| (D∃) 8 <| D_pell D∧
+    ((D∃) 3 <| (D∃) 4 <| (D∃) 5 <| (D∃) 6 <| (D∃) 7 <| (D∃) 8 <| D_pell D∧
     (D≡ (D&1) (D&0 D* (D&4 D- D&7) D+ D&6) (D&3)) D∧
     D.2 D* D&4 D* D&7 D= D&3 D+ (D&7 D* D&7 D+ D.1) D∧
     D&6 D< D&3 D∧ D&7 D≤ D&5 D∧ D&8 D≤ D&5 D∧
chore: move to v4.5.0-rc1, and merge changes from bump/v4.5.0 branch. (#9188)

This PR:

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

Diff
@@ -360,7 +360,7 @@ theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
     ⟨β, Poly.sumsq pl, fun v => (h v).trans <| exists_congr fun t => (Poly.sumsq_eq_zero _ _).symm⟩
   induction' l with S l IH
   exact ⟨ULift Empty, [], fun _ => by simp⟩
-  simp? at d says simp only [imp_false, List.forall_cons] at d
+  simp? at d says simp only [List.forall_cons] at d
   exact
     let ⟨⟨β, p, pe⟩, dl⟩ := d
     let ⟨γ, pl, ple⟩ := IH dl
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
@@ -659,7 +659,7 @@ theorem sub_dioph : DiophFn fun v => f v - g v :=
               · rw [ae, add_tsub_cancel_right]
               · rw [x0, tsub_eq_zero_iff_le.mpr yz], by
               rintro rfl
-              cases' le_total y z with yz zy
+              rcases le_total y z with yz | zy
               · exact Or.inr ⟨yz, tsub_eq_zero_iff_le.mpr yz⟩
               · exact Or.inl (tsub_add_cancel_of_le zy).symm⟩
 #align dioph.sub_dioph Dioph.sub_dioph
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
@@ -360,7 +360,7 @@ theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
     ⟨β, Poly.sumsq pl, fun v => (h v).trans <| exists_congr fun t => (Poly.sumsq_eq_zero _ _).symm⟩
   induction' l with S l IH
   exact ⟨ULift Empty, [], fun _ => by simp⟩
-  simp at d
+  simp? at d says simp only [imp_false, List.forall_cons] at d
   exact
     let ⟨⟨β, p, pe⟩, dl⟩ := d
     let ⟨γ, pl, ple⟩ := IH dl
@@ -437,7 +437,7 @@ theorem ex_dioph {S : Set (Sum α β → ℕ)} : Dioph S → Dioph {v | ∃ x, v
         ⟨t ∘ inl,
           (pe _).2
             ⟨t ∘ inr, by
-              simp at ht
+              simp only [Poly.map_apply] at ht
               rwa [show (v ⊗ t) ∘ ((inl ⊗ inr ∘ inl) ⊗ inr ∘ inr) = (v ⊗ t ∘ inl) ⊗ t ∘ inr from
                 funext fun s => by cases' s with a b <;> try { cases a <;> rfl }; rfl] at ht⟩⟩⟩⟩
 #align dioph.ex_dioph Dioph.ex_dioph
@@ -456,7 +456,7 @@ theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x,
         ⟨t none,
           (pe _).2
             ⟨t ∘ some, by
-              simp at ht
+              simp only [Poly.map_apply] at ht
               rwa [show (v ⊗ t) ∘ (inr none ::ₒ inl ⊗ inr ∘ some) = t none ::ₒ v ⊗ t ∘ some from
                 funext fun s => by cases' s with a b <;> try { cases a <;> rfl }; rfl] at ht ⟩⟩⟩⟩
 #align dioph.ex1_dioph Dioph.ex1_dioph
chore: Nsmul -> NSMul, Zpow -> ZPow, etc (#9067)

Normalising to naming convention rule number 6.

Diff
@@ -411,9 +411,9 @@ theorem union : ∀ (_ : Dioph S) (_ : Dioph S'), Dioph (S ∪ S')
 #align dioph.union Dioph.union
 
 /-- A partial function is Diophantine if its graph is Diophantine. -/
-def DiophPfun (f : (α → ℕ) →. ℕ) : Prop :=
+def DiophPFun (f : (α → ℕ) →. ℕ) : Prop :=
   Dioph {v : Option α → ℕ | f.graph (v ∘ some, v none)}
-#align dioph.dioph_pfun Dioph.DiophPfun
+#align dioph.dioph_pfun Dioph.DiophPFun
 
 /-- A function is Diophantine if its graph is Diophantine. -/
 def DiophFn (f : (α → ℕ) → ℕ) : Prop :=
@@ -461,11 +461,11 @@ theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x,
                 funext fun s => by cases' s with a b <;> try { cases a <;> rfl }; rfl] at ht ⟩⟩⟩⟩
 #align dioph.ex1_dioph Dioph.ex1_dioph
 
-theorem dom_dioph {f : (α → ℕ) →. ℕ} (d : DiophPfun f) : Dioph f.Dom :=
+theorem dom_dioph {f : (α → ℕ) →. ℕ} (d : DiophPFun f) : Dioph f.Dom :=
   cast (congr_arg Dioph <| Set.ext fun _ => (PFun.dom_iff_graph _ _).symm) (ex1_dioph d)
 #align dioph.dom_dioph Dioph.dom_dioph
 
-theorem diophFn_iff_pFun (f : (α → ℕ) → ℕ) : DiophFn f = @DiophPfun α f := by
+theorem diophFn_iff_pFun (f : (α → ℕ) → ℕ) : DiophFn f = @DiophPFun α f := by
   refine' congr_arg Dioph (Set.ext fun v => _); exact PFun.lift_graph.symm
 #align dioph.dioph_fn_iff_pfun Dioph.diophFn_iff_pFun
 
@@ -478,7 +478,7 @@ theorem proj_dioph (i : α) : DiophFn fun v => v i :=
   abs_poly_dioph (Poly.proj i)
 #align dioph.proj_dioph Dioph.proj_dioph
 
-theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : DiophPfun f) :
+theorem diophPFun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : DiophPFun f) :
     Dioph {v : α → ℕ | ∃ h : f.Dom v, f.fn v h ::ₒ v ∈ S} :=
   ext (ex1_dioph (d.inter df)) fun v =>
     ⟨fun ⟨x, hS, (h : Exists _)⟩ => by
@@ -487,11 +487,11 @@ theorem diophPfun_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f} (df : Di
     fun ⟨x, hS⟩ =>
       ⟨f.fn v x, hS, show Exists _ by
         rw [show (f.fn v x ::ₒ v) ∘ some = v from funext fun s => rfl]; exact ⟨x, rfl⟩⟩⟩
-#align dioph.dioph_pfun_comp1 Dioph.diophPfun_comp1
+#align dioph.dioph_pfun_comp1 Dioph.diophPFun_comp1
 
 theorem diophFn_comp1 {S : Set (Option α → ℕ)} (d : Dioph S) {f : (α → ℕ) → ℕ} (df : DiophFn f) :
     Dioph {v | f v ::ₒ v ∈ S} :=
-  ext (diophPfun_comp1 d <| cast (diophFn_iff_pFun f) df)
+  ext (diophPFun_comp1 d <| cast (diophFn_iff_pFun f) df)
     fun _ => ⟨fun ⟨_, h⟩ => h, fun h => ⟨trivial, h⟩⟩
 #align dioph.dioph_fn_comp1 Dioph.diophFn_comp1
 
@@ -530,9 +530,9 @@ theorem diophFn_vec (f : Vector3 ℕ n → ℕ) : DiophFn f ↔ Dioph {v | f (v
   ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
 #align dioph.dioph_fn_vec Dioph.diophFn_vec
 
-theorem diophPfun_vec (f : Vector3 ℕ n →. ℕ) : DiophPfun f ↔ Dioph {v | f.graph (v ∘ fs, v fz)} :=
+theorem diophPFun_vec (f : Vector3 ℕ n →. ℕ) : DiophPFun f ↔ Dioph {v | f.graph (v ∘ fs, v fz)} :=
   ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
-#align dioph.dioph_pfun_vec Dioph.diophPfun_vec
+#align dioph.dioph_pfun_vec Dioph.diophPFun_vec
 
 theorem diophFn_compn :
     ∀ {n} {S : Set (Sum α (Fin2 n) → ℕ)} (_ : Dioph S) {f : Vector3 ((α → ℕ) → ℕ) n}
@@ -751,11 +751,11 @@ theorem pell_dioph :
   exact Dioph.ext this fun v => matiyasevic.symm
 #align dioph.pell_dioph Dioph.pell_dioph
 
-theorem xn_dioph : DiophPfun fun v : Vector3 ℕ 2 => ⟨1 < v &0, fun h => xn h (v &1)⟩ :=
+theorem xn_dioph : DiophPFun fun v : Vector3 ℕ 2 => ⟨1 < v &0, fun h => xn h (v &1)⟩ :=
   have : Dioph fun v : Vector3 ℕ 3 => ∃ y, ∃ h : 1 < v &1, xn h (v &2) = v &0 ∧ yn h (v &2) = y :=
     let D_pell := pell_dioph.reindex_dioph (Fin2 4) [&2, &3, &1, &0]
     (D∃) 3 D_pell
-  (diophPfun_vec _).2 <|
+  (diophPFun_vec _).2 <|
     Dioph.ext this fun _ => ⟨fun ⟨_, h, xe, _⟩ => ⟨h, xe⟩, fun ⟨h, xe⟩ => ⟨_, h, xe, rfl⟩⟩
 #align dioph.xn_dioph Dioph.xn_dioph
 
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
@@ -372,7 +372,7 @@ theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
             ⟨m ⊗ n, by
               rw [show (v ⊗ m ⊗ n) ∘ (inl ⊗ inr ∘ inl) = v ⊗ m from
                     funext fun s => by cases' s with a b <;> rfl]; exact hm, by
-              refine List.Forall.imp (fun q hq => ?_) hn; dsimp [(· ∘ ·)]
+              refine List.Forall.imp (fun q hq => ?_) hn; dsimp [Function.comp_def]
               rw [show
                     (fun x : Sum α γ => (v ⊗ m ⊗ n) ((inl ⊗ fun x : γ => inr (inr x)) x)) = v ⊗ n
                     from funext fun s => by cases' s with a b <;> rfl]; exact hq⟩,
@@ -381,7 +381,7 @@ theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
                 rwa [show (v ⊗ t) ∘ (inl ⊗ inr ∘ inl) = v ⊗ t ∘ inl from
                     funext fun s => by cases' s with a b <;> rfl] at hl⟩,
               ⟨t ∘ inr, by
-                refine List.Forall.imp (fun q hq => ?_) hr; dsimp [(· ∘ ·)] at hq
+                refine List.Forall.imp (fun q hq => ?_) hr; dsimp [Function.comp_def] at hq
                 rwa [show
                     (fun x : Sum α γ => (v ⊗ t) ((inl ⊗ fun x : γ => inr (inr x)) x)) =
                       v ⊗ t ∘ inr
refactor: List.All₂ to List.Forall (#7797)

This renames List.All₂ to List.Forall, because the is highly confusing when it usually means “two lists”, and we had users on Zulip not find List.Forall because of that (https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/Is.20there.20List.2EForall.E2.82.82.2C.20but.20for.20one.20list.3F.20.28In.20library.20Std.29/near/397551365)

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -264,10 +264,10 @@ theorem sumsq_nonneg (x : α → ℕ) : ∀ l, 0 ≤ sumsq l x
     exact add_nonneg (mul_self_nonneg _) (sumsq_nonneg _ ps)
 #align poly.sumsq_nonneg Poly.sumsq_nonneg
 
-theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.All₂ fun a : Poly α => a x = 0
+theorem sumsq_eq_zero (x) : ∀ l, sumsq l x = 0 ↔ l.Forall fun a : Poly α => a x = 0
   | [] => eq_self_iff_true _
   | p::ps => by
-    rw [List.all₂_cons, ← sumsq_eq_zero _ ps]; rw [sumsq]
+    rw [List.forall_cons, ← sumsq_eq_zero _ ps]; rw [sumsq]
     exact
       ⟨fun h : p x * p x + sumsq ps x = 0 =>
         have : p x = 0 :=
@@ -351,10 +351,10 @@ theorem reindex_dioph (f : α → β) : ∀ _ : Dioph S, Dioph {v | v ∘ f ∈
 
 variable {β}
 
-theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
-    Dioph {v | l.All₂ fun S : Set (α → ℕ) => v ∈ S} := by
-  suffices ∃ (β : _) (pl : List (Poly (Sum α β))), ∀ v, List.All₂ (fun S : Set _ => S v) l ↔
-          ∃ t, List.All₂ (fun p : Poly (Sum α β) => p (v ⊗ t) = 0) pl
+theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
+    Dioph {v | l.Forall fun S : Set (α → ℕ) => v ∈ S} := by
+  suffices ∃ (β : _) (pl : List (Poly (Sum α β))), ∀ v, List.Forall (fun S : Set _ => S v) l ↔
+          ∃ t, List.Forall (fun p : Poly (Sum α β) => p (v ⊗ t) = 0) pl
     from
     let ⟨β, pl, h⟩ := this
     ⟨β, Poly.sumsq pl, fun v => (h v).trans <| exists_congr fun t => (Poly.sumsq_eq_zero _ _).symm⟩
@@ -372,7 +372,7 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
             ⟨m ⊗ n, by
               rw [show (v ⊗ m ⊗ n) ∘ (inl ⊗ inr ∘ inl) = v ⊗ m from
                     funext fun s => by cases' s with a b <;> rfl]; exact hm, by
-              refine List.All₂.imp (fun q hq => ?_) hn; dsimp [(· ∘ ·)]
+              refine List.Forall.imp (fun q hq => ?_) hn; dsimp [(· ∘ ·)]
               rw [show
                     (fun x : Sum α γ => (v ⊗ m ⊗ n) ((inl ⊗ fun x : γ => inr (inr x)) x)) = v ⊗ n
                     from funext fun s => by cases' s with a b <;> rfl]; exact hq⟩,
@@ -381,14 +381,14 @@ theorem DiophList.all₂ (l : List (Set <| α → ℕ)) (d : l.All₂ Dioph) :
                 rwa [show (v ⊗ t) ∘ (inl ⊗ inr ∘ inl) = v ⊗ t ∘ inl from
                     funext fun s => by cases' s with a b <;> rfl] at hl⟩,
               ⟨t ∘ inr, by
-                refine List.All₂.imp (fun q hq => ?_) hr; dsimp [(· ∘ ·)] at hq
+                refine List.Forall.imp (fun q hq => ?_) hr; dsimp [(· ∘ ·)] at hq
                 rwa [show
                     (fun x : Sum α γ => (v ⊗ t) ((inl ⊗ fun x : γ => inr (inr x)) x)) =
                       v ⊗ t ∘ inr
                     from funext fun s => by cases' s with a b <;> rfl] at hq ⟩⟩⟩⟩
-#align dioph.dioph_list.all₂ Dioph.DiophList.all₂
+#align dioph.dioph_list.all₂ Dioph.DiophList.forall
 
-theorem inter (d : Dioph S) (d' : Dioph S') : Dioph (S ∩ S') := DiophList.all₂ [S, S'] ⟨d, d'⟩
+theorem inter (d : Dioph S) (d' : Dioph S') : Dioph (S ∩ S') := DiophList.forall [S, S'] ⟨d, d'⟩
 #align dioph.inter Dioph.inter
 
 theorem union : ∀ (_ : Dioph S) (_ : Dioph S'), Dioph (S ∪ S')
chore: fix nonterminal simps (#7497)

Fixes the nonterminal simps identified by #7496

Diff
@@ -448,7 +448,7 @@ theorem ex1_dioph {S : Set (Option α → ℕ)} : Dioph S → Dioph {v | ∃ x,
       ⟨fun ⟨x, hx⟩ =>
         let ⟨t, ht⟩ := (pe _).1 hx
         ⟨x ::ₒ t, by
-          simp
+          simp only [Poly.map_apply]
           rw [show (v ⊗ x ::ₒ t) ∘ (inr none ::ₒ inl ⊗ inr ∘ some) = x ::ₒ v ⊗ t from
             funext fun s => by cases' s with a b <;> try { cases a <;> rfl}; rfl]
           exact ht⟩,
@@ -545,7 +545,7 @@ theorem diophFn_compn :
       ext x; obtain _ | _ | _ := x; rfl
   | succ n, S, d, f =>
     f.consElim fun f fl => by
-        simp
+        simp only [vectorAllP_cons, and_imp]
         exact fun df dfl =>
           have : Dioph {v | (v ∘ inl ⊗ f (v ∘ inl)::v ∘ inr) ∈ S} :=
             ext (diophFn_comp1 (reindex_dioph _ (some ∘ inl ⊗ none::some ∘ inr) d) <|
@@ -572,7 +572,7 @@ theorem dioph_comp {S : Set (Vector3 ℕ n)} (d : Dioph S) (f : Vector3 ((α →
 theorem diophFn_comp {f : Vector3 ℕ n → ℕ} (df : DiophFn f) (g : Vector3 ((α → ℕ) → ℕ) n)
     (dg : VectorAllP DiophFn g) : DiophFn fun v => f fun i => g i v :=
   dioph_comp ((diophFn_vec _).1 df) ((fun v => v none)::fun i v => g i (v ∘ some)) <| by
-    simp
+    simp only [vectorAllP_cons]
     exact ⟨proj_dioph none, (vectorAllP_iff_forall _ _).2 fun i =>
           reindex_diophFn _ <| (vectorAllP_iff_forall _ _).1 dg _⟩
 #align dioph.dioph_fn_comp Dioph.diophFn_comp
perf: remove overspecified fields (#6965)

This removes redundant field values of the form add := add for smaller terms and less unfolding during unification.

A list of all files containing a structure instance of the form { a1, ... with x1 := val, ... } where some xi is a field of some aj was generated by modifying the structure instance elaboration algorithm to print such overlaps to stdout in a custom toolchain.

Using that toolchain, I went through each file on the list and attempted to remove algebraic fields that overlapped and were redundant, eg add := add and not toFun (though some other ones did creep in). If things broke (which was the case in a couple of cases), I did not push further and reverted.

It is possible that pushing harder and trying to remove all redundant overlaps will yield further improvements.

Diff
@@ -223,10 +223,7 @@ instance : AddGroupWithOne (Poly α) :=
 instance : CommRing (Poly α) := by
   refine' { (inferInstance : AddCommGroup (Poly α)),
             (inferInstance : AddGroupWithOne (Poly α)) with
-              add := ((· + ·) : Poly α → Poly α → Poly α)
-              zero := 0
               mul := (· * ·)
-              one := 1
               npow := @npowRec _ ⟨(1 : Poly α)⟩ ⟨(· * ·)⟩
               .. }
   all_goals
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -69,7 +69,7 @@ Note that this duplicates `MvPolynomial`.
 
 section Polynomials
 
-variable {α β γ : Type _}
+variable {α β γ : Type*}
 
 /-- A predicate asserting that a function is a multivariate integer polynomial.
   (We are being a bit lazy here by allowing many representations for multiplication,
@@ -192,7 +192,7 @@ theorem sub_apply (f g : Poly α) (x : α → ℕ) : (f - g) x = f x - g x := rf
 theorem mul_apply (f g : Poly α) (x : α → ℕ) : (f * g) x = f x * g x := rfl
 #align poly.mul_apply Poly.mul_apply
 
-instance (α : Type _) : Inhabited (Poly α) := ⟨0⟩
+instance (α : Type*) : Inhabited (Poly α) := ⟨0⟩
 
 instance : AddCommGroup (Poly α) := by
   refine' { add := ((· + ·) : Poly α → Poly α → Poly α)
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.dioph
-! leanprover-community/mathlib commit a66d07e27d5b5b8ac1147cacfe353478e5c14002
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Data.Fin.Fin2
 import Mathlib.Data.PFun
 import Mathlib.Data.Vector3
 import Mathlib.NumberTheory.PellMatiyasevic
 
+#align_import number_theory.dioph from "leanprover-community/mathlib"@"a66d07e27d5b5b8ac1147cacfe353478e5c14002"
+
 /-!
 # Diophantine functions and Matiyasevic's theorem
 
feat: port NumberTheory.Dioph (#4914)

Dependencies 8 + 484

485 files ported (98.4%)
200373 lines ported (98.5%)
Show graph

The unported dependencies are