Theorem: Behrend.addSalemSpencer_sphere
File: Mathlib/Combinatorics/Additive/Behrend.lean

tactic: set f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) :=
  { toFun := fun f => ((↑) : ℕ → ℝ) ∘ f
    map_zero' := funext fun _ => cast_zero
    map_add' := fun _ _ => funext fun _ => cast_add _ _ }
state_before: α : Type ?u.454879
β : Type ?u.454882
n d k N : ℕ
x : Fin n → ℕ
⊢ AddSalemSpencer ↑(sphere n d k)

tactic: refine' AddSalemSpencer.of_image (f.toAddFreimanHom (sphere n d k : Set (Fin n → ℕ)) 2) _ _
state_before: α : Type ?u.454879
β : Type ?u.454882
n d k N : ℕ
x : Fin n → ℕ
f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) :=
  { toZeroHom := { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) },
    map_add' :=
      (_ :
        ∀ (x x_1 : Fin n → ℕ),
          ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } (x + x_1) =
            ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x +
              ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x_1) }
⊢ AddSalemSpencer ↑(sphere n d k)

tactic: refine' (addSalemSpencer_sphere 0 <| Real.sqrt k).mono (Set.image_subset_iff.2 fun x => _)
state_before: case refine'_2
α : Type ?u.454879
β : Type ?u.454882
n d k N : ℕ
x : Fin n → ℕ
f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) :=
  { toZeroHom := { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) },
    map_add' :=
      (_ :
        ∀ (x x_1 : Fin n → ℕ),
          ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } (x + x_1) =
            ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x +
              ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x_1) }
⊢ AddSalemSpencer (↑(AddMonoidHom.toAddFreimanHom (↑(sphere n d k)) 2 f) '' ↑(sphere n d k))

tactic: rw [Set.mem_preimage, mem_sphere_zero_iff_norm]
state_before: case refine'_2
α : Type ?u.454879
β : Type ?u.454882
n d k N : ℕ
x✝ : Fin n → ℕ
f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) :=
  { toZeroHom := { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) },
    map_add' :=
      (_ :
        ∀ (x x_1 : Fin n → ℕ),
          ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } (x + x_1) =
            ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x +
              ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x_1) }
x : Fin n → ℕ
⊢ x ∈ ↑(sphere n d k) → x ∈ ↑(AddMonoidHom.toAddFreimanHom (↑(sphere n d k)) 2 f) ⁻¹' Metric.sphere 0 (Real.sqrt ↑k)

tactic: exact norm_of_mem_sphere
state_before: case refine'_2
α : Type ?u.454879
β : Type ?u.454882
n d k N : ℕ
x✝ : Fin n → ℕ
f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) :=
  { toZeroHom := { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) },
    map_add' :=
      (_ :
        ∀ (x x_1 : Fin n → ℕ),
          ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } (x + x_1) =
            ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x +
              ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x_1) }
x : Fin n → ℕ
⊢ x ∈ ↑(sphere n d k) → ‖↑(AddMonoidHom.toAddFreimanHom (↑(sphere n d k)) 2 f) x‖ = Real.sqrt ↑k

tactic: exact cast_injective.comp_left.injOn _
state_before: case refine'_1
α : Type ?u.454879
β : Type ?u.454882
n d k N : ℕ
x : Fin n → ℕ
f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) :=
  { toZeroHom := { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) },
    map_add' :=
      (_ :
        ∀ (x x_1 : Fin n → ℕ),
          ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } (x + x_1) =
            ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x +
              ZeroHom.toFun { toFun := fun f => Nat.cast ∘ f, map_zero' := (_ : (fun f => Nat.cast ∘ f) 0 = 0) } x_1) }
⊢ Set.InjOn ↑(AddMonoidHom.toAddFreimanHom (↑(sphere n d k)) 2 f) ↑(sphere n d k)