@@ -243,7 +243,7 @@ end Polynomials
243243/-- A set `S ⊆ ℕ^α` is Diophantine if there exists a polynomial on
244244 `α ⊕ β` such that `v ∈ S` iff there exists `t : ℕ^β` with `p (v, t) = 0`. -/
245245def Dioph {α : Type u} (S : Set (α → ℕ)) : Prop :=
246- ∃ (β : Type u) (p : Poly (α ⊕ β)), ∀ v, S v ↔ ∃ t, p (v ⊗ t) = 0
246+ ∃ (β : Type u) (p : Poly (α ⊕ β)), ∀ v, v ∈ S ↔ ∃ t, p (v ⊗ t) = 0
247247
248248namespace Dioph
249249
@@ -253,7 +253,7 @@ variable {α β γ : Type u} {S S' : Set (α → ℕ)}
253253
254254theorem ext (d : Dioph S) (H : ∀ v, v ∈ S ↔ v ∈ S') : Dioph S' := by rwa [← Set.ext H]
255255
256- theorem of_no_dummies (S : Set (α → ℕ)) (p : Poly α) (h : ∀ v, S v ↔ p v = 0 ) : Dioph S :=
256+ theorem of_no_dummies (S : Set (α → ℕ)) (p : Poly α) (h : ∀ v, v ∈ S ↔ p v = 0 ) : Dioph S :=
257257 ⟨PEmpty, ⟨p.map inl, fun v => (h v).trans ⟨fun h => ⟨PEmpty.elim, h⟩, fun ⟨_, ht⟩ => ht⟩⟩⟩
258258
259259theorem inject_dummies_lem (f : β → γ) (g : γ → Option β) (inv : ∀ x, g (f x) = some x)
@@ -267,8 +267,8 @@ theorem inject_dummies_lem (f : β → γ) (g : γ → Option β) (inv : ∀ x,
267267 exact ⟨t ∘ f, by rwa [this]⟩
268268
269269theorem inject_dummies (f : β → γ) (g : γ → Option β) (inv : ∀ x, g (f x) = some x)
270- (p : Poly (α ⊕ β)) (h : ∀ v, S v ↔ ∃ t, p (v ⊗ t) = 0 ) :
271- ∃ q : Poly (α ⊕ γ), ∀ v, S v ↔ ∃ t, q (v ⊗ t) = 0 :=
270+ (p : Poly (α ⊕ β)) (h : ∀ v, v ∈ S ↔ ∃ t, p (v ⊗ t) = 0 ) :
271+ ∃ q : Poly (α ⊕ γ), ∀ v, v ∈ S ↔ ∃ t, q (v ⊗ t) = 0 :=
272272 ⟨p.map (inl ⊗ inr ∘ f), fun v => (h v).trans <| inject_dummies_lem f g inv _ _⟩
273273
274274variable (β) in
@@ -281,7 +281,7 @@ theorem reindex_dioph (f : α → β) : Dioph S → Dioph {v | v ∘ f ∈ S}
281281
282282theorem DiophList.forall (l : List (Set <| α → ℕ)) (d : l.Forall Dioph) :
283283 Dioph {v | l.Forall fun S : Set (α → ℕ) => v ∈ S} := by
284- suffices ∃ (β : _) (pl : List (Poly (α ⊕ β))), ∀ v, List.Forall (fun S : Set _ => S v ) l ↔
284+ suffices ∃ (β : _) (pl : List (Poly (α ⊕ β))), ∀ v, List.Forall (fun S : Set _ => v ∈ S ) l ↔
285285 ∃ t, List.Forall (fun p : Poly (α ⊕ β) => p (v ⊗ t) = 0 ) pl
286286 from
287287 let ⟨β, pl, h⟩ := this
@@ -335,7 +335,7 @@ theorem union : ∀ (_ : Dioph S) (_ : Dioph S'), Dioph (S ∪ S')
335335
336336/-- A partial function is Diophantine if its graph is Diophantine. -/
337337def DiophPFun (f : (α → ℕ) →. ℕ) : Prop :=
338- Dioph {v : Option α → ℕ | f.graph (v ∘ some, v none)}
338+ Dioph {v : Option α → ℕ | (v ∘ some, v none) ∈ f.graph }
339339
340340/-- A function is Diophantine if its graph is Diophantine. -/
341341def DiophFn (f : (α → ℕ) → ℕ) : Prop :=
@@ -419,7 +419,7 @@ open Vector3
419419open scoped Vector3
420420
421421theorem diophFn_vec_comp1 {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) {f : Vector3 ℕ n → ℕ}
422- (df : DiophFn f) : Dioph {v : Vector3 ℕ n | (f v:: v) ∈ S} :=
422+ (df : DiophFn f) : Dioph {v : Vector3 ℕ n | (f v :: v) ∈ S} :=
423423 Dioph.ext (diophFn_comp1 (reindex_dioph _ (none :: some) d) df) (fun v => by
424424 dsimp
425425 -- TODO: `apply iff_of_eq` is required here, even though `congr!` works on iff below.
@@ -430,7 +430,7 @@ theorem diophFn_vec_comp1 {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) {f : Ve
430430set_option backward.isDefEq.respectTransparency false in
431431/-- Deleting the first component preserves the Diophantine property. -/
432432theorem vec_ex1_dioph (n) {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) :
433- Dioph {v : Fin2 n → ℕ | ∃ x, (x:: v) ∈ S} :=
433+ Dioph {v : Fin2 n → ℕ | ∃ x, (x :: v) ∈ S} :=
434434 ext (ex1_dioph <| reindex_dioph _ (none :: some) d) fun v =>
435435 exists_congr fun x => by
436436 dsimp
@@ -440,7 +440,7 @@ theorem vec_ex1_dioph (n) {S : Set (Vector3 ℕ (succ n))} (d : Dioph S) :
440440theorem diophFn_vec (f : Vector3 ℕ n → ℕ) : DiophFn f ↔ Dioph {v | f (v ∘ fs) = v fz} :=
441441 ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
442442
443- theorem diophPFun_vec (f : Vector3 ℕ n →. ℕ) : DiophPFun f ↔ Dioph {v | f.graph (v ∘ fs, v fz)} :=
443+ theorem diophPFun_vec (f : Vector3 ℕ n →. ℕ) : DiophPFun f ↔ Dioph {v | (v ∘ fs, v fz) ∈ f.graph } :=
444444 ⟨reindex_dioph _ (fz ::ₒ fs), reindex_dioph _ (none::some)⟩
445445
446446theorem diophFn_compn :
@@ -466,7 +466,7 @@ theorem diophFn_compn :
466466 congr! 1
467467 ext x; obtain _ | _ | _ := x <;> rfl
468468 have : Dioph {v | (v ⊗ f v::fun i : Fin2 n => fl i v) ∈ S} :=
469- @diophFn_compn n (fun v => S (v ∘ inl ⊗ f (v ∘ inl) :: v ∘ inr)) this _ dfl
469+ @diophFn_compn n (fun v => (v ∘ inl ⊗ f (v ∘ inl) :: v ∘ inr) ∈ S ) this _ dfl
470470 ext this fun v => by
471471 dsimp
472472 congr! 3 with x
@@ -511,14 +511,14 @@ section
511511variable {f g : (α → ℕ) → ℕ} (df : DiophFn f) (dg : DiophFn g)
512512include df dg
513513
514- theorem dioph_comp2 {S : ℕ → ℕ → Prop } (d : Dioph fun v : Vector3 ℕ 2 => S (v &0 ) (v &1 )) :
515- Dioph fun v => S (f v) (g v) := dioph_comp d [f, g] ⟨df, dg⟩
514+ theorem dioph_comp2 {S : ℕ → ℕ → Prop } (d : Dioph { v : Vector3 ℕ 2 | S (v &0 ) (v &1 )} ) :
515+ Dioph {v | S (f v) (g v)} := dioph_comp d [f, g] ⟨df, dg⟩
516516
517517theorem diophFn_comp2 {h : ℕ → ℕ → ℕ} (d : DiophFn fun v : Vector3 ℕ 2 => h (v &0 ) (v &1 )) :
518518 DiophFn fun v => h (f v) (g v) := diophFn_comp d [f, g] ⟨df, dg⟩
519519
520520/-- The set of places where two Diophantine functions are equal is Diophantine. -/
521- theorem eq_dioph : Dioph fun v => f v = g v :=
521+ theorem eq_dioph : Dioph {v | f v = g v} :=
522522 dioph_comp2 df dg <|
523523 of_no_dummies _ (Poly.proj &0 - Poly.proj &1 ) fun v => by
524524 exact Int.ofNat_inj.symm.trans ⟨@sub_eq_zero_of_eq ℤ _ (v &0 ) (v &1 ), eq_of_sub_eq_zero⟩
@@ -573,15 +573,15 @@ theorem sub_dioph : DiophFn fun v ↦ f v - g v :=
573573scoped infixl :80 " D- " => Dioph.sub_dioph
574574
575575/-- The set of places where one Diophantine function divides another is Diophantine. -/
576- theorem dvd_dioph : Dioph fun v => f v ∣ g v :=
576+ theorem dvd_dioph : Dioph {v | f v ∣ g v} :=
577577 dioph_comp ((D∃) 2 <| D&2 D= D&1 D* D&0 ) [f, g] ⟨df, dg⟩
578578
579579@[inherit_doc]
580580scoped infixl :50 " D∣ " => Dioph.dvd_dioph
581581
582582/-- Diophantine functions are closed under the modulo operation. -/
583583theorem mod_dioph : DiophFn fun v => f v % g v :=
584- have : Dioph fun v : Vector3 ℕ 3 => (v &2 = 0 ∨ v &0 < v &2 ) ∧ ∃ x : ℕ, v &0 + v &2 * x = v &1 :=
584+ have : Dioph { v : Vector3 ℕ 3 | (v &2 = 0 ∨ v &0 < v &2 ) ∧ ∃ x : ℕ, v &0 + v &2 * x = v &1 } :=
585585 (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
586586 diophFn_comp2 df dg <|
587587 (diophFn_vec _).2 <|
@@ -601,7 +601,7 @@ scoped infixl:80 " D% " => Dioph.mod_dioph
601601
602602/-- The set of places where two Diophantine functions are congruent modulo a third
603603is Diophantine. -/
604- theorem modEq_dioph {h : (α → ℕ) → ℕ} (dh : DiophFn h) : Dioph fun v => f v ≡ g v [MOD h v] :=
604+ theorem modEq_dioph {h : (α → ℕ) → ℕ} (dh : DiophFn h) : Dioph {v | f v ≡ g v [MOD h v]} :=
605605 df D% dh D= dg D% dh
606606
607607@[inherit_doc]
@@ -610,8 +610,7 @@ scoped notation "D≡ " => Dioph.modEq_dioph
610610/-- Diophantine functions are closed under integer division. -/
611611theorem div_dioph : DiophFn fun v => f v / g v :=
612612 have :
613- Dioph fun v : Vector3 ℕ 3 =>
614- v &2 = 0 ∧ v &0 = 0 ∨ v &0 * v &2 ≤ v &1 ∧ v &1 < (v &0 + 1 ) * v &2 :=
613+ Dioph {v : Vector3 ℕ 3 | v &2 = 0 ∧ v &0 = 0 ∨ v &0 * v &2 ≤ v &1 ∧ v &1 < (v &0 + 1 ) * v &2 } :=
615614 (D&2 D= D.0 D∧ D&0 D= D.0 ) D∨ D&0 D* D&2 D≤ D&1 D∧ D&1 D< (D&0 D+ D.1 ) D* D&2
616615 diophFn_comp2 df dg <|
617616 (diophFn_vec _).2 <|
@@ -631,7 +630,7 @@ scoped infixl:80 " D/ " => Dioph.div_dioph
631630open Pell
632631
633632theorem pell_dioph :
634- Dioph fun v : Vector3 ℕ 4 => ∃ h : 1 < v &0 , xn h (v &1 ) = v &2 ∧ yn h (v &1 ) = v &3 := by
633+ Dioph { v : Vector3 ℕ 4 | ∃ h : 1 < v &0 , xn h (v &1 ) = v &2 ∧ yn h (v &1 ) = v &3 } := by
635634 have : Dioph {v : Vector3 ℕ 4 |
636635 1 < v &0 ∧ v &1 ≤ v &3 ∧
637636 (v &2 = 1 ∧ v &3 = 0 ∨
@@ -656,7 +655,7 @@ theorem pell_dioph :
656655 exact Dioph.ext this fun v => matiyasevic.symm
657656
658657theorem xn_dioph : DiophPFun fun v : Vector3 ℕ 2 => ⟨1 < v &0 , fun h => xn h (v &1 )⟩ :=
659- have : Dioph fun v : Vector3 ℕ 3 => ∃ y, ∃ h : 1 < v &1 , xn h (v &2 ) = v &0 ∧ yn h (v &2 ) = y :=
658+ have : Dioph { v : Vector3 ℕ 3 | ∃ y, ∃ h : 1 < v &1 , xn h (v &2 ) = v &0 ∧ yn h (v &2 ) = y} :=
660659 let D_pell := pell_dioph.reindex_dioph (Fin2 4 ) [&2 , &3 , &1 , &0 ]
661660 (D∃) 3 D_pell
662661 (diophPFun_vec _).2 <|
0 commit comments