l3lab/ntp-mathlib huggingface dataset:
/-- The inverse function is approximated linearly on `f '' s` by `f'.symm`. -/
theorem to_inv (hf : ApproximatesLinearOn f (f' : E →L[𝕜] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) :
    ApproximatesLinearOn (hf.toPartialEquiv hc).symm (f'.symm : F →L[𝕜] E) (f '' s)
      (N * (N⁻¹ - c)⁻¹ * c) := fun x hx y hy ↦ by
  set A := hf.toPartialEquiv hc
  have Af : ∀ z, A z = f z := fun z => rfl
  rcases (mem_image _ _ _).1 hx with ⟨x', x's, rfl⟩
  rcases (mem_image _ _ _).1 hy with ⟨y', y's, rfl⟩
  rw [← Af x', ← Af y', A.left_inv x's, A.left_inv y's]
  calc
    ‖x' - y' - f'.symm (A x' - A y')‖ ≤ N * ‖f' (x' - y' - f'.symm (A x' - A y'))‖ :=
      (f' : E →L[𝕜] F).bound_of_antilipschitz f'.antilipschitz _
    _ = N * ‖A y' - A x' - f' (y' - x')‖ := by
      congr 2
      simp only [ContinuousLinearEquiv.apply_symm_apply, ContinuousLinearEquiv.map_sub]
      abel
    _ ≤ N * (c * ‖y' - x'‖) := (mul_le_mul_of_nonneg_left (hf _ y's _ x's) (NNReal.coe_nonneg _))
    _ ≤ N * (c * (((N⁻¹ - c)⁻¹ : ℝ≥0) * ‖A y' - A x'‖)) := by
      gcongr
      rw [← dist_eq_norm, ← dist_eq_norm]
      exact (hf.antilipschitz hc).le_mul_dist ⟨y', y's⟩ ⟨x', x's⟩
    _ = (N * (N⁻¹ - c)⁻¹ * c : ℝ≥0) * ‖A x' - A y'‖ := by
      

Proof state:
𝕜 : Type u_1
inst✝⁹ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
G' : Type u_5
inst✝² : NormedAddCommGroup G'
inst✝¹ : NormedSpace 𝕜 G'
ε : ℝ
inst✝ : CompleteSpace E
f : E → F
f' : E ≃L[𝕜] F
s : Set E
c : ℝ≥0
hf : ApproximatesLinearOn f (↑f') s c
hc : Subsingleton E ∨ c < ‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹
A : PartialEquiv E F := toPartialEquiv hf hc
Af : ∀ (z : E), ↑A z = f z
x' : E
x's : x' ∈ s
hx : f x' ∈ f '' s
y' : E
y's : y' ∈ s
hy : f y' ∈ f '' s
⊢ ↑‖↑(ContinuousLinearEquiv.symm f')‖₊ * (↑c * (↑(‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹ - c)⁻¹ * ‖↑A y' - ↑A x'‖)) =
    ↑(‖↑(ContinuousLinearEquiv.symm f')‖₊ * (‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹ - c)⁻¹ * c) * ‖↑A x' - ↑A y'‖

Next tactic:
simp only [norm_sub_rev, NNReal.coe_mul]
/-- The inverse function is approximated linearly on `f '' s` by `f'.symm`. -/
theorem to_inv (hf : ApproximatesLinearOn f (f' : E →L[𝕜] F) s c) (hc : Subsingleton E ∨ c < N⁻¹) :
    ApproximatesLinearOn (hf.toPartialEquiv hc).symm (f'.symm : F →L[𝕜] E) (f '' s)
      (N * (N⁻¹ - c)⁻¹ * c) := fun x hx y hy ↦ by
  set A := hf.toPartialEquiv hc
  have Af : ∀ z, A z = f z := fun z => rfl
  rcases (mem_image _ _ _).1 hx with ⟨x', x's, rfl⟩
  rcases (mem_image _ _ _).1 hy with ⟨y', y's, rfl⟩
  rw [← Af x', ← Af y', A.left_inv x's, A.left_inv y's]
  calc
    ‖x' - y' - f'.symm (A x' - A y')‖ ≤ N * ‖f' (x' - y' - f'.symm (A x' - A y'))‖ :=
      (f' : E →L[𝕜] F).bound_of_antilipschitz f'.antilipschitz _
    _ = N * ‖A y' - A x' - f' (y' - x')‖ := by
      congr 2
      simp only [ContinuousLinearEquiv.apply_symm_apply, ContinuousLinearEquiv.map_sub]
      abel
    _ ≤ N * (c * ‖y' - x'‖) := (mul_le_mul_of_nonneg_left (hf _ y's _ x's) (NNReal.coe_nonneg _))
    _ ≤ N * (c * (((N⁻¹ - c)⁻¹ : ℝ≥0) * ‖A y' - A x'‖)) := by
      gcongr
      rw [← dist_eq_norm, ← dist_eq_norm]
      exact (hf.antilipschitz hc).le_mul_dist ⟨y', y's⟩ ⟨x', x's⟩
    _ = (N * (N⁻¹ - c)⁻¹ * c : ℝ≥0) * ‖A x' - A y'‖ := by
      simp only [norm_sub_rev, NNReal.coe_mul]; 

Proof state:
𝕜 : Type u_1
inst✝⁹ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
G' : Type u_5
inst✝² : NormedAddCommGroup G'
inst✝¹ : NormedSpace 𝕜 G'
ε : ℝ
inst✝ : CompleteSpace E
f : E → F
f' : E ≃L[𝕜] F
s : Set E
c : ℝ≥0
hf : ApproximatesLinearOn f (↑f') s c
hc : Subsingleton E ∨ c < ‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹
A : PartialEquiv E F := toPartialEquiv hf hc
Af : ∀ (z : E), ↑A z = f z
x' : E
x's : x' ∈ s
hx : f x' ∈ f '' s
y' : E
y's : y' ∈ s
hy : f y' ∈ f '' s
⊢ ↑‖↑(ContinuousLinearEquiv.symm f')‖₊ *
      (↑c *
        (↑(‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹ - c)⁻¹ * ‖↑(toPartialEquiv hf hc) x' - ↑(toPartialEquiv hf hc) y'‖)) =
    ↑‖↑(ContinuousLinearEquiv.symm f')‖₊ * ↑(‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹ - c)⁻¹ * ↑c *
      ‖↑(toPartialEquiv hf hc) x' - ↑(toPartialEquiv hf hc) y'‖

Next tactic:
ring
/-- Given a function `f` that approximates a linear equivalence on an open set `s`,
returns a local homeomorph with `toFun = f` and `source = s`. -/
def toPartialHomeomorph (hf : ApproximatesLinearOn f (f' : E →L[𝕜] F) s c)
    (hc : Subsingleton E ∨ c < N⁻¹) (hs : IsOpen s) : PartialHomeomorph E F where
  toPartialEquiv := hf.toPartialEquiv hc
  open_source := hs
  open_target := hf.open_image f'.toNonlinearRightInverse hs <| by
    

Proof state:
𝕜 : Type u_1
inst✝⁹ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
G' : Type u_5
inst✝² : NormedAddCommGroup G'
inst✝¹ : NormedSpace 𝕜 G'
ε : ℝ
inst✝ : CompleteSpace E
f : E → F
f' : E ≃L[𝕜] F
s : Set E
c : ℝ≥0
hf : ApproximatesLinearOn f (↑f') s c
hc : Subsingleton E ∨ c < ‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹
hs : IsOpen s
⊢ Subsingleton F ∨ c < (ContinuousLinearEquiv.toNonlinearRightInverse f').nnnorm⁻¹

Next tactic:
rwa [f'.toEquiv.subsingleton_congr] at hc
/-- A function `f` that approximates a linear equivalence on the whole space is a homeomorphism. -/
def toHomeomorph (hf : ApproximatesLinearOn f (f' : E →L[𝕜] F) univ c)
    (hc : Subsingleton E ∨ c < N⁻¹) : E ≃ₜ F := by
  

Proof state:
𝕜 : Type u_1
inst✝⁹ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
G' : Type u_5
inst✝² : NormedAddCommGroup G'
inst✝¹ : NormedSpace 𝕜 G'
ε : ℝ
inst✝ : CompleteSpace E
f : E → F
f' : E ≃L[𝕜] F
s : Set E
c : ℝ≥0
hf : ApproximatesLinearOn f (↑f') univ c
hc : Subsingleton E ∨ c < ‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹
⊢ E ≃ₜ F

Next tactic:
refine' (hf.toPartialHomeomorph _ _ hc isOpen_univ).toHomeomorphOfSourceEqUnivTargetEqUniv rfl _
/-- A function `f` that approximates a linear equivalence on the whole space is a homeomorphism. -/
def toHomeomorph (hf : ApproximatesLinearOn f (f' : E →L[𝕜] F) univ c)
    (hc : Subsingleton E ∨ c < N⁻¹) : E ≃ₜ F := by
  refine' (hf.toPartialHomeomorph _ _ hc isOpen_univ).toHomeomorphOfSourceEqUnivTargetEqUniv rfl _
  

Proof state:
𝕜 : Type u_1
inst✝⁹ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
G' : Type u_5
inst✝² : NormedAddCommGroup G'
inst✝¹ : NormedSpace 𝕜 G'
ε : ℝ
inst✝ : CompleteSpace E
f : E → F
f' : E ≃L[𝕜] F
s : Set E
c : ℝ≥0
hf : ApproximatesLinearOn f (↑f') univ c
hc : Subsingleton E ∨ c < ‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹
⊢ (toPartialHomeomorph f univ hf hc (_ : IsOpen univ)).toPartialEquiv.target = univ

Next tactic:
rw [toPartialHomeomorph_target, image_univ, range_iff_surjective]
/-- A function `f` that approximates a linear equivalence on the whole space is a homeomorphism. -/
def toHomeomorph (hf : ApproximatesLinearOn f (f' : E →L[𝕜] F) univ c)
    (hc : Subsingleton E ∨ c < N⁻¹) : E ≃ₜ F := by
  refine' (hf.toPartialHomeomorph _ _ hc isOpen_univ).toHomeomorphOfSourceEqUnivTargetEqUniv rfl _
  rw [toPartialHomeomorph_target, image_univ, range_iff_surjective]
  

Proof state:
𝕜 : Type u_1
inst✝⁹ : NontriviallyNormedField 𝕜
E : Type u_2
inst✝⁸ : NormedAddCommGroup E
inst✝⁷ : NormedSpace 𝕜 E
F : Type u_3
inst✝⁶ : NormedAddCommGroup F
inst✝⁵ : NormedSpace 𝕜 F
G : Type u_4
inst✝⁴ : NormedAddCommGroup G
inst✝³ : NormedSpace 𝕜 G
G' : Type u_5
inst✝² : NormedAddCommGroup G'
inst✝¹ : NormedSpace 𝕜 G'
ε : ℝ
inst✝ : CompleteSpace E
f : E → F
f' : E ≃L[𝕜] F
s : Set E
c : ℝ≥0
hf : ApproximatesLinearOn f (↑f') univ c
hc : Subsingleton E ∨ c < ‖↑(ContinuousLinearEquiv.symm f')‖₊⁻¹
⊢ Surjective f

Next tactic:
exact hf.surjective hc
theorem cardinal_mk_eq_sum : #(WType β) = sum (fun a : α => #(WType β) ^ #(β a)) := by
  

Proof state:
α : Type u
β : α → Type u
⊢ #(WType β) = sum fun a => #(WType β) ^ #(β a)

Next tactic:
simp only [Cardinal.power_def, ← Cardinal.mk_sigma]
theorem cardinal_mk_eq_sum : #(WType β) = sum (fun a : α => #(WType β) ^ #(β a)) := by
  simp only [Cardinal.power_def, ← Cardinal.mk_sigma]
  

Proof state:
α : Type u
β : α → Type u
⊢ #(WType β) = #((i : α) × (β i → WType β))

Next tactic:
exact mk_congr (equivSigma β)
/-- `#(WType β)` is the least cardinal `κ` such that `sum (λ a : α, κ ^ #(β a)) ≤ κ` -/
theorem cardinal_mk_le_of_le {κ : Cardinal.{u}} (hκ : (sum fun a : α => κ ^ #(β a)) ≤ κ) :
    #(WType β) ≤ κ := by
  

Proof state:
α : Type u
β : α → Type u
κ : Cardinal.{u}
hκ : (sum fun a => κ ^ #(β a)) ≤ κ
⊢ #(WType β) ≤ κ

Next tactic:
induction' κ using Cardinal.inductionOn with γ
/-- `#(WType β)` is the least cardinal `κ` such that `sum (λ a : α, κ ^ #(β a)) ≤ κ` -/
theorem cardinal_mk_le_of_le {κ : Cardinal.{u}} (hκ : (sum fun a : α => κ ^ #(β a)) ≤ κ) :
    #(WType β) ≤ κ := by
  induction' κ using Cardinal.inductionOn with γ
  

Proof state:
case h
α : Type u
β : α → Type u
γ : Type u
hκ : (sum fun a => #γ ^ #(β a)) ≤ #γ
⊢ #(WType β) ≤ #γ

Next tactic:
simp only [Cardinal.power_def, ← Cardinal.mk_sigma, Cardinal.le_def] at hκ
/-- `#(WType β)` is the least cardinal `κ` such that `sum (λ a : α, κ ^ #(β a)) ≤ κ` -/
theorem cardinal_mk_le_of_le {κ : Cardinal.{u}} (hκ : (sum fun a : α => κ ^ #(β a)) ≤ κ) :
    #(WType β) ≤ κ := by
  induction' κ using Cardinal.inductionOn with γ
  simp only [Cardinal.power_def, ← Cardinal.mk_sigma, Cardinal.le_def] at hκ
  

Proof state:
case h
α : Type u
β : α → Type u
γ : Type u
hκ : Nonempty ((i : α) × (β i → γ) ↪ γ)
⊢ #(WType β) ≤ #γ

Next tactic:
cases' hκ with hκ
/-- `#(WType β)` is the least cardinal `κ` such that `sum (λ a : α, κ ^ #(β a)) ≤ κ` -/
theorem cardinal_mk_le_of_le {κ : Cardinal.{u}} (hκ : (sum fun a : α => κ ^ #(β a)) ≤ κ) :
    #(WType β) ≤ κ := by
  induction' κ using Cardinal.inductionOn with γ
  simp only [Cardinal.power_def, ← Cardinal.mk_sigma, Cardinal.le_def] at hκ
  cases' hκ with hκ
  

Proof state:
case h.intro
α : Type u
β : α → Type u
γ : Type u
hκ : (i : α) × (β i → γ) ↪ γ
⊢ #(WType β) ≤ #γ

Next tactic:
exact Cardinal.mk_le_of_injective (elim_injective _ hκ.1 hκ.2)
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      

Proof state:
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
⊢ IsEmpty α → #(WType β) ≤ max #α ℵ₀

Next tactic:
intro h
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      intro h
      

Proof state:
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
h : IsEmpty α
⊢ #(WType β) ≤ max #α ℵ₀

Next tactic:
rw [Cardinal.mk_eq_zero (WType β)]
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      intro h
      rw [Cardinal.mk_eq_zero (WType β)]
      

Proof state:
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
h : IsEmpty α
⊢ 0 ≤ max #α ℵ₀

Next tactic:
exact zero_le _
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      intro h
      rw [Cardinal.mk_eq_zero (WType β)]
      exact zero_le _)
    fun hn =>
    let m := max #α ℵ₀
    cardinal_mk_le_of_le <|
      calc
        (Cardinal.sum fun a => m ^ #(β a)) ≤ #α * ⨆ a, m ^ #(β a) := Cardinal.sum_le_iSup _
        _ ≤ m * ⨆ a, m ^ #(β a) := mul_le_mul' (le_max_left _ _) le_rfl
        _ = m :=
          mul_eq_left.{u} (le_max_right _ _)
              (ciSup_le' fun i => pow_le (le_max_right _ _) (lt_aleph0_of_finite _)) <|
            pos_iff_ne_zero.1 <|
              Order.succ_le_iff.1
                (by
                  

Proof state:
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
hn : Nonempty α
m : Cardinal.{u} := max #α ℵ₀
⊢ Order.succ 0 ≤ ⨆ a, m ^ #(β a)

Next tactic:
rw [succ_zero]
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      intro h
      rw [Cardinal.mk_eq_zero (WType β)]
      exact zero_le _)
    fun hn =>
    let m := max #α ℵ₀
    cardinal_mk_le_of_le <|
      calc
        (Cardinal.sum fun a => m ^ #(β a)) ≤ #α * ⨆ a, m ^ #(β a) := Cardinal.sum_le_iSup _
        _ ≤ m * ⨆ a, m ^ #(β a) := mul_le_mul' (le_max_left _ _) le_rfl
        _ = m :=
          mul_eq_left.{u} (le_max_right _ _)
              (ciSup_le' fun i => pow_le (le_max_right _ _) (lt_aleph0_of_finite _)) <|
            pos_iff_ne_zero.1 <|
              Order.succ_le_iff.1
                (by
                  rw [succ_zero]
                  

Proof state:
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
hn : Nonempty α
m : Cardinal.{u} := max #α ℵ₀
⊢ 1 ≤ ⨆ a, m ^ #(β a)

Next tactic:
obtain ⟨a⟩ : Nonempty α := hn
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      intro h
      rw [Cardinal.mk_eq_zero (WType β)]
      exact zero_le _)
    fun hn =>
    let m := max #α ℵ₀
    cardinal_mk_le_of_le <|
      calc
        (Cardinal.sum fun a => m ^ #(β a)) ≤ #α * ⨆ a, m ^ #(β a) := Cardinal.sum_le_iSup _
        _ ≤ m * ⨆ a, m ^ #(β a) := mul_le_mul' (le_max_left _ _) le_rfl
        _ = m :=
          mul_eq_left.{u} (le_max_right _ _)
              (ciSup_le' fun i => pow_le (le_max_right _ _) (lt_aleph0_of_finite _)) <|
            pos_iff_ne_zero.1 <|
              Order.succ_le_iff.1
                (by
                  rw [succ_zero]
                  obtain ⟨a⟩ : Nonempty α := hn
                  

Proof state:
case intro
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
m : Cardinal.{u} := max #α ℵ₀
a : α
⊢ 1 ≤ ⨆ a, m ^ #(β a)

Next tactic:
refine' le_trans _ (le_ciSup (bddAbove_range.{u, u} _) a)
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      intro h
      rw [Cardinal.mk_eq_zero (WType β)]
      exact zero_le _)
    fun hn =>
    let m := max #α ℵ₀
    cardinal_mk_le_of_le <|
      calc
        (Cardinal.sum fun a => m ^ #(β a)) ≤ #α * ⨆ a, m ^ #(β a) := Cardinal.sum_le_iSup _
        _ ≤ m * ⨆ a, m ^ #(β a) := mul_le_mul' (le_max_left _ _) le_rfl
        _ = m :=
          mul_eq_left.{u} (le_max_right _ _)
              (ciSup_le' fun i => pow_le (le_max_right _ _) (lt_aleph0_of_finite _)) <|
            pos_iff_ne_zero.1 <|
              Order.succ_le_iff.1
                (by
                  rw [succ_zero]
                  obtain ⟨a⟩ : Nonempty α := hn
                  refine' le_trans _ (le_ciSup (bddAbove_range.{u, u} _) a)
                  

Proof state:
case intro
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
m : Cardinal.{u} := max #α ℵ₀
a : α
⊢ 1 ≤ m ^ #(β a)

Next tactic:
rw [← power_zero]
/-- If, for any `a : α`, `β a` is finite, then the cardinality of `WType β`
  is at most the maximum of the cardinality of `α` and `ℵ₀`  -/
theorem cardinal_mk_le_max_aleph0_of_finite [∀ a, Finite (β a)] : #(WType β) ≤ max #α ℵ₀ :=
  (isEmpty_or_nonempty α).elim
    (by
      intro h
      rw [Cardinal.mk_eq_zero (WType β)]
      exact zero_le _)
    fun hn =>
    let m := max #α ℵ₀
    cardinal_mk_le_of_le <|
      calc
        (Cardinal.sum fun a => m ^ #(β a)) ≤ #α * ⨆ a, m ^ #(β a) := Cardinal.sum_le_iSup _
        _ ≤ m * ⨆ a, m ^ #(β a) := mul_le_mul' (le_max_left _ _) le_rfl
        _ = m :=
          mul_eq_left.{u} (le_max_right _ _)
              (ciSup_le' fun i => pow_le (le_max_right _ _) (lt_aleph0_of_finite _)) <|
            pos_iff_ne_zero.1 <|
              Order.succ_le_iff.1
                (by
                  rw [succ_zero]
                  obtain ⟨a⟩ : Nonempty α := hn
                  refine' le_trans _ (le_ciSup (bddAbove_range.{u, u} _) a)
                  rw [← power_zero]
                  

Proof state:
case intro
α : Type u
β : α → Type u
inst✝ : ∀ (a : α), Finite (β a)
m : Cardinal.{u} := max #α ℵ₀
a : α
⊢ ?m.2438 ^ 0 ≤ m ^ #(β a)
α : Type u β : α → Type u inst✝ : ∀ (a : α), Finite (β a) m : Cardinal.{u} := max #α ℵ₀ a : α ⊢ Cardinal.{u}

Next tactic:
exact
                    power_le_power_left
                      (pos_iff_ne_zero.1 (aleph0_pos.trans_le (le_max_right _ _))) (zero_le _)
/-- The submodule corresponding to each grade given by the degree function `f`. -/
abbrev gradeBy (f : M → ι) (i : ι) : Submodule R R[M] where
  carrier := { a | ∀ m, m ∈ a.support → f m = i }
  zero_mem' m h := by 

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
f : M → ι
i : ι
m : M
h : m ∈ 0.support
⊢ f m = i

Next tactic:
cases h
theorem mem_gradeBy_iff (f : M → ι) (i : ι) (a : R[M]) :
    a ∈ gradeBy R f i ↔ (a.support : Set M) ⊆ f ⁻¹' {i} := by 

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
f : M → ι
i : ι
a : R[M]
⊢ a ∈ gradeBy R f i ↔ ↑a.support ⊆ f ⁻¹' {i}

Next tactic:
rfl
theorem mem_grade_iff (m : M) (a : R[M]) : a ∈ grade R m ↔ a.support ⊆ {m} := by
  

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
⊢ a ∈ grade R m ↔ a.support ⊆ {m}

Next tactic:
rw [← Finset.coe_subset, Finset.coe_singleton]
theorem mem_grade_iff (m : M) (a : R[M]) : a ∈ grade R m ↔ a.support ⊆ {m} := by
  rw [← Finset.coe_subset, Finset.coe_singleton]
  

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
⊢ a ∈ grade R m ↔ ↑a.support ⊆ {m}

Next tactic:
rfl
theorem mem_grade_iff' (m : M) (a : R[M]) :
    a ∈ grade R m ↔ a ∈ (LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :
      Submodule R R[M]) := by
  

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
⊢ a ∈ grade R m ↔ a ∈ LinearMap.range (Finsupp.lsingle m)

Next tactic:
rw [mem_grade_iff, Finsupp.support_subset_singleton']
theorem mem_grade_iff' (m : M) (a : R[M]) :
    a ∈ grade R m ↔ a ∈ (LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :
      Submodule R R[M]) := by
  rw [mem_grade_iff, Finsupp.support_subset_singleton']
  

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
⊢ (∃ b, a = fun₀ | m => b) ↔ a ∈ LinearMap.range (Finsupp.lsingle m)

Next tactic:
apply exists_congr
theorem mem_grade_iff' (m : M) (a : R[M]) :
    a ∈ grade R m ↔ a ∈ (LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :
      Submodule R R[M]) := by
  rw [mem_grade_iff, Finsupp.support_subset_singleton']
  apply exists_congr
  

Proof state:
case h
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
⊢ ∀ (a_1 : R), (a = fun₀ | m => a_1) ↔ (Finsupp.lsingle m) a_1 = a

Next tactic:
intro r
theorem mem_grade_iff' (m : M) (a : R[M]) :
    a ∈ grade R m ↔ a ∈ (LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :
      Submodule R R[M]) := by
  rw [mem_grade_iff, Finsupp.support_subset_singleton']
  apply exists_congr
  intro r
  

Proof state:
case h
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
r : R
⊢ (a = fun₀ | m => r) ↔ (Finsupp.lsingle m) r = a

Next tactic:
constructor
theorem mem_grade_iff' (m : M) (a : R[M]) :
    a ∈ grade R m ↔ a ∈ (LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :
      Submodule R R[M]) := by
  rw [mem_grade_iff, Finsupp.support_subset_singleton']
  apply exists_congr
  intro r
  constructor <;> 

Proof state:
case h.mp
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
r : R
⊢ (a = fun₀ | m => r) → (Finsupp.lsingle m) r = a

Next tactic:
exact Eq.symm
theorem mem_grade_iff' (m : M) (a : R[M]) :
    a ∈ grade R m ↔ a ∈ (LinearMap.range (Finsupp.lsingle m : R →ₗ[R] M →₀ R) :
      Submodule R R[M]) := by
  rw [mem_grade_iff, Finsupp.support_subset_singleton']
  apply exists_congr
  intro r
  constructor <;> 

Proof state:
case h.mpr
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝¹ : DecidableEq M
inst✝ : CommSemiring R
m : M
a : R[M]
r : R
⊢ (Finsupp.lsingle m) r = a → a = fun₀ | m => r

Next tactic:
exact Eq.symm
theorem single_mem_gradeBy {R} [CommSemiring R] (f : M → ι) (m : M) (r : R) :
    Finsupp.single m r ∈ gradeBy R f (f m) := by
  

Proof state:
M : Type u_1
ι : Type u_2
R✝ : Type u_3
inst✝² : DecidableEq M
inst✝¹ : CommSemiring R✝
R : Type u_4
inst✝ : CommSemiring R
f : M → ι
m : M
r : R
⊢ (fun₀ | m => r) ∈ gradeBy R f (f m)

Next tactic:
intro x hx
theorem single_mem_gradeBy {R} [CommSemiring R] (f : M → ι) (m : M) (r : R) :
    Finsupp.single m r ∈ gradeBy R f (f m) := by
  intro x hx
  

Proof state:
M : Type u_1
ι : Type u_2
R✝ : Type u_3
inst✝² : DecidableEq M
inst✝¹ : CommSemiring R✝
R : Type u_4
inst✝ : CommSemiring R
f : M → ι
m : M
r : R
x : M
hx : x ∈ (fun₀ | m => r).support
⊢ f x = f m

Next tactic:
rw [Finset.mem_singleton.mp (Finsupp.support_single_subset hx)]
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
m : M
h : m ∈ 1.support
⊢ f m = 0

Next tactic:
rw [one_def] at h
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    

Proof state:
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
m : M
h : m ∈ (single 0 1).support
⊢ f m = 0

Next tactic:
by_cases H : (1 : R) = (0 : R)
instance gradeBy.gradedMonoid [AddMonoid M] [AddMonoid ι] [CommSemiring R] (f : M →+ ι) :
    SetLike.GradedMonoid (gradeBy R f : ι → Submodule R R[M]) where
  one_mem m h := by
    rw [one_def] at h
    by_cases H : (1 : R) = (0 : R)
    · 

Proof state:
case pos
M : Type u_1
ι : Type u_2
R : Type u_3
inst✝³ : DecidableEq M
inst✝² : AddMonoid M
inst✝¹ : AddMonoid ι
inst✝ : CommSemiring R
f : M →+ ι
m : M
h : m ∈ (single 0 1).support
H : 1 = 0
⊢ f m = 0

Next tactic:
rw [H, single, Finsupp.single_zero] at h