Skip to content

Commit

Permalink
Use more mathlib-friendly definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
gdahia committed Oct 6, 2024
1 parent 0766fe2 commit caf2479
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions FurstenbergSarkozy/Basic.lean
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import Mathlib

open Finset
open Finset Function

def mrange (n : ℕ) := map ⟨fun x => x + 1, add_left_injective 1⟩ (range n)
def range' (n : ℕ) : Finset ℕ := Ioc 0 n

noncomputable def upperBoundOnr (n : ℕ) := ⌈(n ^ (1/4 : ℝ) : ℝ)⌉₊
noncomputable def upperBoundOny (n : ℕ) := ⌈(n ^ (1/3 : ℝ) : ℝ)⌉₊

noncomputable def upperBoundOnh (n : ℕ) := ⌈(n ^ (1/100 : ℝ) : ℝ)⌉₊
noncomputable def upperBoundOnz (n : ℕ) := ⌈(n ^ (1/100 : ℝ) : ℝ)⌉₊

noncomputable def generalizedCountOfSquares (n : ℕ) (f₁ f₂ : ℕ → ℝ) : ℝ :=
∑ x ∈ (mrange n),
rmrange (upperBoundOnr n),
hmrange (upperBoundOnh n), (f₁ x) * (f₂ (x + (r + h)^2))
∑ x ∈ range' n,
yrange' (upperBoundOny n),
zrange' (upperBoundOnz n), (f₁ x) * (f₂ (x + (y + z)^2))

noncomputable def countOfSquares (n : ℕ) (f : ℕ → ℝ) : ℝ :=
generalizedCountOfSquares n f f

def Finset.containsSquareDifference (S : Finset ℕ) : Prop := ∃ d : ℕ, ∃ a ∈ S, a + d ^ 2 ∈ S

def id' {α : Type} (x : ℝ) : α → ℝ := fun _ => x
def Finset.indicator {α : Type} [DecidableEq α] (S : Finset α) : α → ℝ :=
S.piecewise (id' 1) (id' 0)
noncomputable def Finset.indicator {α : Type} [DecidableEq α] (S : Finset α) : α → ℝ :=
S.toSet.indicator (const α 1)

lemma non_zero_countOfSquares_implies_squareDifference (n : ℕ) (S : Finset ℕ)
: countOfSquares n S.indicator ≠ 0 → S.containsSquareDifference := by
Expand All @@ -29,7 +28,7 @@ lemma non_zero_countOfSquares_implies_squareDifference (n : ℕ) (S : Finset ℕ

unfold containsSquareDifference at squareDifferenceFree
push_neg at squareDifferenceFree
unfold countOfSquares generalizedCountOfSquares
unfold countOfSquares generalizedCountOfSquares range'

apply sum_eq_zero
intros x _
Expand All @@ -51,9 +50,9 @@ lemma non_zero_countOfSquares_implies_squareDifference (n : ℕ) (S : Finset ℕ
exact if_neg (squareDifferenceFree (r + h) x xInS)

noncomputable def maxOfGeneralizedCountOfSquares (n₁ n₂ n₃ : ℕ) :=
n₁ * (upperBoundOnr n₂) * (upperBoundOnh n₃)
n₁ * (upperBoundOny n₂) * (upperBoundOnz n₃)
noncomputable def maxOfCountOfSquares (n : ℕ) := maxOfGeneralizedCountOfSquares n n n
noncomputable def almostN (n : ℕ) := n - (upperBoundOnr n + upperBoundOnh n)^2
noncomputable def almostN (n : ℕ) := n - (upperBoundOny n + upperBoundOnz n)^2
noncomputable def almostMaxOfCountOfSquares (n : ℕ) :=
maxOfGeneralizedCountOfSquares (almostN n) n n

Expand Down Expand Up @@ -148,7 +147,7 @@ lemma uniform_δ_indicator_at_least_sqr_δ_density_of_countOfSquares_minus_error
noncomputable def unitInterval' := (Set.Ioc (0 : ℝ) (1 : ℝ))

theorem furstenberg_sarkozy :
∀ δ : unitInterval', ∃ n₀ : ℕ, ∀ n : ℕ, n ≥ n₀ →
∀ S ⊆ (mrange n), (δ : ℝ) * n ≤ S.card →
∀ δ unitInterval', ∃ n₀ : ℕ, ∀ n : ℕ, n ≥ n₀ →
∀ S ⊆ (range' n), δ * n ≤ S.card →
S.containsSquareDifference :=
sorry

0 comments on commit caf2479

Please sign in to comment.