l3lab/ntp-mathlib huggingface dataset:
theorem addSalemSpencer_image_sphere :
    AddSalemSpencer ((sphere n d k).image (map (2 * d - 1)) : Set ℕ) := by
  rw [coe_image]
  refine' @AddSalemSpencer.image _ (Fin n → ℕ) ℕ _ _ (sphere n d k) _ (map (2 * d - 1))
    (map_injOn.mono _) addSalemSpencer_sphere
  · exact x
  rw [Set.add_subset_iff]
  rintro a ha b hb i
  have hai := mem_box.1 (sphere_subset_box ha) i
  have hbi := mem_box.1 (sphere_subset_box hb) i
  rw [lt_tsub_iff_right, ← succ_le_iff, two_mul]
  

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
n d k N : ℕ
x a : Fin n → ℕ
ha : a ∈ ↑(sphere n d k)
b : Fin n → ℕ
hb : b ∈ ↑(sphere n d k)
i : Fin n
hai : a i < d
hbi : b i < d
⊢ succ ((a + b) i + 1) ≤ d + d

Next tactic:
exact (add_add_add_comm _ _ 1 1).trans_le (_root_.add_le_add hai hbi)
theorem sum_sq_le_of_mem_box (hx : x ∈ box n d) : ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2 := by
  

Proof state:
α : Type u_1
β : Type u_2
n d k N : ℕ
x : Fin n → ℕ
hx : x ∈ box n d
⊢ ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2

Next tactic:
rw [mem_box] at hx
theorem sum_sq_le_of_mem_box (hx : x ∈ box n d) : ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2 := by
  rw [mem_box] at hx
  

Proof state:
α : Type u_1
β : Type u_2
n d k N : ℕ
x : Fin n → ℕ
hx : ∀ (i : Fin n), x i < d
⊢ ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2

Next tactic:
have : ∀ i, x i ^ 2 ≤ (d - 1) ^ 2 := fun i =>
    Nat.pow_le_pow_left (Nat.le_sub_one_of_lt (hx i)) _
theorem sum_sq_le_of_mem_box (hx : x ∈ box n d) : ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2 := by
  rw [mem_box] at hx
  have : ∀ i, x i ^ 2 ≤ (d - 1) ^ 2 := fun i =>
    Nat.pow_le_pow_left (Nat.le_sub_one_of_lt (hx i)) _
  

Proof state:
α : Type u_1
β : Type u_2
n d k N : ℕ
x : Fin n → ℕ
hx : ∀ (i : Fin n), x i < d
this : ∀ (i : Fin n), x i ^ 2 ≤ (d - 1) ^ 2
⊢ ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2

Next tactic:
exact (sum_le_card_nsmul univ _ _ fun i _ => this i).trans (by rw [card_fin, smul_eq_mul])
theorem sum_sq_le_of_mem_box (hx : x ∈ box n d) : ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2 := by
  rw [mem_box] at hx
  have : ∀ i, x i ^ 2 ≤ (d - 1) ^ 2 := fun i =>
    Nat.pow_le_pow_left (Nat.le_sub_one_of_lt (hx i)) _
  exact (sum_le_card_nsmul univ _ _ fun i _ => this i).trans (by 

Proof state:
α : Type u_1
β : Type u_2
n d k N : ℕ
x : Fin n → ℕ
hx : ∀ (i : Fin n), x i < d
this : ∀ (i : Fin n), x i ^ 2 ≤ (d - 1) ^ 2
⊢ card univ • (d - 1) ^ 2 ≤ n * (d - 1) ^ 2

Next tactic:
rw [card_fin, smul_eq_mul]
theorem sum_eq : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) = ((2 * d + 1) ^ n - 1) / 2 := by
  

Proof state:
α : Type u_1
β : Type u_2
n d k N : ℕ
x : Fin n → ℕ
⊢ ∑ i : Fin n, d * (2 * d + 1) ^ ↑i = ((2 * d + 1) ^ n - 1) / 2

Next tactic:
refine' (Nat.div_eq_of_eq_mul_left zero_lt_two _).symm
theorem sum_eq : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) = ((2 * d + 1) ^ n - 1) / 2 := by
  refine' (Nat.div_eq_of_eq_mul_left zero_lt_two _).symm
  

Proof state:
α : Type u_1
β : Type u_2
n d k N : ℕ
x : Fin n → ℕ
⊢ (2 * d + 1) ^ n - 1 = (∑ i : Fin n, d * (2 * d + 1) ^ ↑i) * 2

Next tactic:
rw [← sum_range fun i => d * (2 * d + 1) ^ (i : ℕ), ← mul_sum, mul_right_comm, mul_comm d, ←
    geom_sum_mul_add, add_tsub_cancel_right, mul_comm]
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  

Proof state:
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
⊢ card (sphere n d k) ≤ rothNumberNat ((2 * d - 1) ^ n)

Next tactic:
cases n
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · 

Proof state:
case zero
α : Type u_1
β : Type u_2
n d✝ k✝ N : ℕ
x : Fin n → ℕ
d k : ℕ
⊢ card (sphere zero d k) ≤ rothNumberNat ((2 * d - 1) ^ zero)

Next tactic:
dsimp
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; 

Proof state:
case zero
α : Type u_1
β : Type u_2
n d✝ k✝ N : ℕ
x : Fin n → ℕ
d k : ℕ
⊢ card (sphere 0 d k) ≤ rothNumberNat 1

Next tactic:
refine' (card_le_univ _).trans_eq _
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; 

Proof state:
case zero
α : Type u_1
β : Type u_2
n d✝ k✝ N : ℕ
x : Fin n → ℕ
d k : ℕ
⊢ Fintype.card (Fin 0 → ℕ) = rothNumberNat 1

Next tactic:
rfl
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  

Proof state:
case succ
α : Type u_1
β : Type u_2
n d✝ k✝ N : ℕ
x : Fin n → ℕ
d k n✝ : ℕ
⊢ card (sphere (succ n✝) d k) ≤ rothNumberNat ((2 * d - 1) ^ succ n✝)

Next tactic:
cases d
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · 

Proof state:
case succ.zero
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝ : ℕ
⊢ card (sphere (succ n✝) zero k) ≤ rothNumberNat ((2 * zero - 1) ^ succ n✝)

Next tactic:
simp
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  

Proof state:
case succ.succ
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
⊢ card (sphere (succ n✝¹) (succ n✝) k) ≤ rothNumberNat ((2 * succ n✝ - 1) ^ succ n✝¹)

Next tactic:
refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · 

Proof state:
case succ.succ.refine'_1
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
⊢ Fin (succ n✝¹) → ℕ

Next tactic:
intro
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; 

Proof state:
case succ.succ.refine'_1
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
a✝ : Fin (succ n✝¹)
⊢ ℕ

Next tactic:
assumption
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · 

Proof state:
case succ.succ.refine'_2
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
⊢ ∀ x ∈ image (⇑(map (2 * succ n✝ - 1))) (sphere (succ n✝¹) (succ n✝) k), x < (2 * succ n✝ - 1) ^ succ n✝¹

Next tactic:
simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
    

Proof state:
case succ.succ.refine'_2
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
⊢ ∀ (x : ℕ),
    ∀ x_1 ∈ box (succ n✝¹) (succ n✝),
      ∑ i : Fin (succ n✝¹), x_1 i ^ 2 = k → (map (2 * succ n✝ - 1)) x_1 = x → x < (2 * succ n✝ - 1) ^ succ n✝¹

Next tactic:
rintro _ x hx _ rfl
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
    rintro _ x hx _ rfl
    

Proof state:
case succ.succ.refine'_2
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x✝ : Fin n → ℕ
k n✝¹ n✝ : ℕ
x : Fin (succ n✝¹) → ℕ
hx : x ∈ box (succ n✝¹) (succ n✝)
a✝ : ∑ i : Fin (succ n✝¹), x i ^ 2 = k
⊢ (map (2 * succ n✝ - 1)) x < (2 * succ n✝ - 1) ^ succ n✝¹

Next tactic:
exact (map_le_of_mem_box hx).trans_lt sum_lt
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
    rintro _ x hx _ rfl
    exact (map_le_of_mem_box hx).trans_lt sum_lt
  

Proof state:
case succ.succ.refine'_3
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
⊢ Set.InjOn ⇑(map (2 * succ n✝ - 1)) ↑(sphere (succ n✝¹) (succ n✝) k)

Next tactic:
refine' map_injOn.mono fun x => _
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
    rintro _ x hx _ rfl
    exact (map_le_of_mem_box hx).trans_lt sum_lt
  refine' map_injOn.mono fun x => _
  · 

Proof state:
case succ.succ.refine'_3.refine'_1
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
⊢ Fin (succ n✝¹) → ℕ

Next tactic:
intro
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
    rintro _ x hx _ rfl
    exact (map_le_of_mem_box hx).trans_lt sum_lt
  refine' map_injOn.mono fun x => _
  · intro; 

Proof state:
case succ.succ.refine'_3.refine'_1
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x : Fin n → ℕ
k n✝¹ n✝ : ℕ
a✝ : Fin (succ n✝¹)
⊢ ℕ

Next tactic:
assumption
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
    rintro _ x hx _ rfl
    exact (map_le_of_mem_box hx).trans_lt sum_lt
  refine' map_injOn.mono fun x => _
  · intro; assumption
  

Proof state:
case succ.succ.refine'_3.refine'_2
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x✝ : Fin n → ℕ
k n✝¹ n✝ : ℕ
x : Fin (succ n✝¹) → ℕ
⊢ x ∈ ↑(sphere (succ n✝¹) (succ n✝) k) → x ∈ {x | ∀ (i : Fin (succ n✝¹)), x i < 2 * succ n✝ - 1}

Next tactic:
simp only [mem_coe, sphere, mem_filter, mem_box, and_imp, two_mul]
theorem card_sphere_le_rothNumberNat (n d k : ℕ) :
    (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by
  cases n
  · dsimp; refine' (card_le_univ _).trans_eq _; rfl
  cases d
  · simp
  refine' addSalemSpencer_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _)
  · intro; assumption
  · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range,
      forall_apply_eq_imp_iff₂, sphere, mem_filter]
    rintro _ x hx _ rfl
    exact (map_le_of_mem_box hx).trans_lt sum_lt
  refine' map_injOn.mono fun x => _
  · intro; assumption
  simp only [mem_coe, sphere, mem_filter, mem_box, and_imp, two_mul]
  

Proof state:
case succ.succ.refine'_3.refine'_2
α : Type u_1
β : Type u_2
n d k✝ N : ℕ
x✝ : Fin n → ℕ
k n✝¹ n✝ : ℕ
x : Fin (succ n✝¹) → ℕ
⊢ (∀ (i : Fin (succ n✝¹)), x i < succ n✝) →
    ∑ i : Fin (succ n✝¹), x i ^ 2 = k → x ∈ {x | ∀ (i : Fin (succ n✝¹)), x i < succ n✝ + succ n✝ - 1}

Next tactic:
exact fun h _ i => (h i).trans_le le_self_add
theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1),
    (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by
  

Proof state:
α : Type u_1
β : Type u_2
n✝ d✝ k N : ℕ
x : Fin n✝ → ℕ
n d : ℕ
⊢ ∃ k ∈ range (n * (d - 1) ^ 2 + 1), ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))

Next tactic:
refine' exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => _) nonempty_range_succ _
theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1),
    (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by
  refine' exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => _) nonempty_range_succ _
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
n✝ d✝ k N : ℕ
x✝ : Fin n✝ → ℕ
n d : ℕ
x : Fin n → ℕ
hx : x ∈ box n d
⊢ ∑ i : Fin n, x i ^ 2 ∈ range (n * (d - 1) ^ 2 + 1)

Next tactic:
rw [mem_range, lt_succ_iff]
theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1),
    (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by
  refine' exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => _) nonempty_range_succ _
  · rw [mem_range, lt_succ_iff]
    

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
n✝ d✝ k N : ℕ
x✝ : Fin n✝ → ℕ
n d : ℕ
x : Fin n → ℕ
hx : x ∈ box n d
⊢ ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2

Next tactic:
exact sum_sq_le_of_mem_box hx
theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1),
    (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by
  refine' exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => _) nonempty_range_succ _
  · rw [mem_range, lt_succ_iff]
    exact sum_sq_le_of_mem_box hx
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
n✝ d✝ k N : ℕ
x : Fin n✝ → ℕ
n d : ℕ
⊢ card (range (n * (d - 1) ^ 2 + 1)) • (↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1)) ≤ ↑(card (box n d))

Next tactic:
rw [card_range, _root_.nsmul_eq_mul, mul_div_assoc', cast_add_one, mul_div_cancel_left,
      card_box]
theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1),
    (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by
  refine' exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => _) nonempty_range_succ _
  · rw [mem_range, lt_succ_iff]
    exact sum_sq_le_of_mem_box hx
  · rw [card_range, _root_.nsmul_eq_mul, mul_div_assoc', cast_add_one, mul_div_cancel_left,
      card_box]
    

Proof state:
case refine'_2.ha
α : Type u_1
β : Type u_2
n✝ d✝ k N : ℕ
x : Fin n✝ → ℕ
n d : ℕ
⊢ ↑(n * (d - 1) ^ 2) + 1 ≠ 0

Next tactic:
exact (cast_add_one_pos _).ne'
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  

Proof state:
α : Type u_1
β : Type u_2
n✝ d✝ k N : ℕ
x : Fin n✝ → ℕ
n d : ℕ
⊢ ∃ k, ↑(d ^ n) / ↑(n * d ^ 2) ≤ ↑(card (sphere n d k))

Next tactic:
obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
⊢ ∃ k, ↑(d ^ n) / ↑(n * d ^ 2) ≤ ↑(card (sphere n d k))

Next tactic:
refine' ⟨k, _⟩
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  

Proof state:
case intro.intro
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
⊢ ↑(d ^ n) / ↑(n * d ^ 2) ≤ ↑(card (sphere n d k))

Next tactic:
obtain rfl | hn := n.eq_zero_or_pos
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · 

Proof state:
case intro.intro.inl
α : Type u_1
β : Type u_2
n d✝ k✝ N : ℕ
x : Fin n → ℕ
d k : ℕ
hk : ↑(d ^ 0) / (↑(0 * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere 0 d k))
⊢ ↑(d ^ 0) / ↑(0 * d ^ 2) ≤ ↑(card (sphere 0 d k))

Next tactic:
simp
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  

Proof state:
case intro.intro.inr
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
⊢ ↑(d ^ n) / ↑(n * d ^ 2) ≤ ↑(card (sphere n d k))

Next tactic:
obtain rfl | hd := d.eq_zero_or_pos
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · 

Proof state:
case intro.intro.inr.inl
α : Type u_1
β : Type u_2
n✝ d k✝ N : ℕ
x : Fin n✝ → ℕ
n k : ℕ
hn : n > 0
hk : ↑(0 ^ n) / (↑(n * (0 - 1) ^ 2) + 1) ≤ ↑(card (sphere n 0 k))
⊢ ↑(0 ^ n) / ↑(n * 0 ^ 2) ≤ ↑(card (sphere n 0 k))

Next tactic:
simp
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  

Proof state:
case intro.intro.inr.inr
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ ↑(d ^ n) / ↑(n * d ^ 2) ≤ ↑(card (sphere n d k))

Next tactic:
refine' (div_le_div_of_le_left _ _ _).trans hk
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  refine' (div_le_div_of_le_left _ _ _).trans hk
  · 

Proof state:
case intro.intro.inr.inr.refine'_1
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ 0 ≤ ↑(d ^ n)

Next tactic:
exact cast_nonneg _
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  refine' (div_le_div_of_le_left _ _ _).trans hk
  · exact cast_nonneg _
  · 

Proof state:
case intro.intro.inr.inr.refine'_2
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ 0 < ↑(n * (d - 1) ^ 2) + 1

Next tactic:
exact cast_add_one_pos _
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  refine' (div_le_div_of_le_left _ _ _).trans hk
  · exact cast_nonneg _
  · exact cast_add_one_pos _
  

Proof state:
case intro.intro.inr.inr.refine'_3
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ ↑(n * (d - 1) ^ 2) + 1 ≤ ↑(n * d ^ 2)

Next tactic:
simp only [← le_sub_iff_add_le', cast_mul, ← mul_sub, cast_pow, cast_sub hd, sub_sq, one_pow,
    cast_one, mul_one, sub_add, sub_sub_self]
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  refine' (div_le_div_of_le_left _ _ _).trans hk
  · exact cast_nonneg _
  · exact cast_add_one_pos _
  simp only [← le_sub_iff_add_le', cast_mul, ← mul_sub, cast_pow, cast_sub hd, sub_sq, one_pow,
    cast_one, mul_one, sub_add, sub_sub_self]
  

Proof state:
case intro.intro.inr.inr.refine'_3
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ 1 ≤ ↑n * (2 * ↑d - 1)

Next tactic:
apply one_le_mul_of_one_le_of_one_le
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  refine' (div_le_div_of_le_left _ _ _).trans hk
  · exact cast_nonneg _
  · exact cast_add_one_pos _
  simp only [← le_sub_iff_add_le', cast_mul, ← mul_sub, cast_pow, cast_sub hd, sub_sq, one_pow,
    cast_one, mul_one, sub_add, sub_sub_self]
  apply one_le_mul_of_one_le_of_one_le
  · 

Proof state:
case intro.intro.inr.inr.refine'_3.ha
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ 1 ≤ ↑n

Next tactic:
rwa [one_le_cast]
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  refine' (div_le_div_of_le_left _ _ _).trans hk
  · exact cast_nonneg _
  · exact cast_add_one_pos _
  simp only [← le_sub_iff_add_le', cast_mul, ← mul_sub, cast_pow, cast_sub hd, sub_sq, one_pow,
    cast_one, mul_one, sub_add, sub_sub_self]
  apply one_le_mul_of_one_le_of_one_le
  · rwa [one_le_cast]
  

Proof state:
case intro.intro.inr.inr.refine'_3.hb
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ 1 ≤ 2 * ↑d - 1

Next tactic:
rw [_root_.le_sub_iff_add_le]
theorem exists_large_sphere (n d : ℕ) :
    ∃ k, ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ (sphere n d k).card := by
  obtain ⟨k, -, hk⟩ := exists_large_sphere_aux n d
  refine' ⟨k, _⟩
  obtain rfl | hn := n.eq_zero_or_pos
  · simp
  obtain rfl | hd := d.eq_zero_or_pos
  · simp
  refine' (div_le_div_of_le_left _ _ _).trans hk
  · exact cast_nonneg _
  · exact cast_add_one_pos _
  simp only [← le_sub_iff_add_le', cast_mul, ← mul_sub, cast_pow, cast_sub hd, sub_sq, one_pow,
    cast_one, mul_one, sub_add, sub_sub_self]
  apply one_le_mul_of_one_le_of_one_le
  · rwa [one_le_cast]
  rw [_root_.le_sub_iff_add_le]
  

Proof state:
case intro.intro.inr.inr.refine'_3.hb
α : Type u_1
β : Type u_2
n✝ d✝ k✝ N : ℕ
x : Fin n✝ → ℕ
n d k : ℕ
hk : ↑(d ^ n) / (↑(n * (d - 1) ^ 2) + 1) ≤ ↑(card (sphere n d k))
hn : n > 0
hd : d > 0
⊢ 1 + 1 ≤ 2 * ↑d

Next tactic:
norm_num