[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.Projection).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
theorem commute_iff_of_isUnit (hT : IsUnit T) (hf : IsIdempotentElem f) :
    Commute f T ↔ (range f).map T = range f ∧ (ker f).map T = ker f
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.LinearAlgebra.Projection.ker_id_sub_eq_of_proj (L46-L51)
theorem ker_id_sub_eq_of_proj {f : E →ₗ[R] p} (hf : ∀ x : p, f x = x) :
    ker (id - p.subtype.comp f) = p := by
ext x
  simp only [comp_apply, mem_ker, subtype_apply, sub_apply, id_apply, sub_eq_zero]
  exact ⟨fun h => h.symm ▸ Submodule.coe_mem _, fun hx => by rw [hf ⟨x, hx⟩, Subtype.coe_mk]⟩
```

-- snippet 2
```lean
-- Mathlib.LinearAlgebra.Projection.range_eq_of_proj (L52-L54)
theorem range_eq_of_proj {f : E →ₗ[R] p} (hf : ∀ x : p, f x = x) : range f = ⊤ :=
range_eq_top.2 fun x => ⟨x, hf x⟩
```

-- snippet 3
```lean
-- Mathlib.LinearAlgebra.Projection.isCompl_of_proj (L55-L73)
theorem isCompl_of_proj {f : E →ₗ[R] p} (hf : ∀ x : p, f x = x) : IsCompl p (ker f) := by
constructor
  · rw [disjoint_iff_inf_le]
    rintro x ⟨hpx, hfx⟩
    rw [SetLike.mem_coe, mem_ker, hf ⟨x, hpx⟩, mk_eq_zero] at hfx
    simp only [hfx, zero_mem]
  · rw [codisjoint_iff_le_sup]
    intro x _
    rw [mem_sup']
    refine ⟨f x, ⟨x - f x, ?_⟩, add_sub_cancel _ _⟩
    rw [mem_ker, map_sub, hf, sub_self]

end LinearMap

namespace Submodule

open LinearMap

/-- If `q` is a complement of `p`, then `M/p ≃ q`. -/
```

-- snippet 4
```lean
-- Mathlib.LinearAlgebra.Projection.quotientEquivOfIsCompl (L74-L79)
def quotientEquivOfIsCompl (h : IsCompl p q) : (E ⧸ p) ≃ₗ[R] q :=
LinearEquiv.symm <|
    LinearEquiv.ofBijective (p.mkQ.comp q.subtype)
      ⟨by rw [← ker_eq_bot, ker_comp, ker_mkQ, disjoint_iff_comap_eq_bot.1 h.symm.disjoint], by
        rw [← range_eq_top, range_comp, range_subtype, map_mkQ_eq_top, h.sup_eq_top]⟩
```

-- snippet 5
```lean
-- Mathlib.LinearAlgebra.Projection.quotientEquivOfIsCompl_symm_apply (L81-L84)
theorem quotientEquivOfIsCompl_symm_apply (h : IsCompl p q) (x : q) :
    -- Porting note: type ascriptions needed on the RHS
    (quotientEquivOfIsCompl p q h).symm x = (Quotient.mk x : E ⧸ p) := rfl
```

-- snippet 6
```lean
-- Mathlib.LinearAlgebra.Projection.quotientEquivOfIsCompl_apply_mk_coe (L86-L89)
theorem quotientEquivOfIsCompl_apply_mk_coe (h : IsCompl p q) (x : q) :
    quotientEquivOfIsCompl p q h (Quotient.mk x) = x :=
(quotientEquivOfIsCompl p q h).apply_symm_apply x
```

-- snippet 7
```lean
-- Mathlib.LinearAlgebra.Projection.mk_quotientEquivOfIsCompl_apply (L91-L95)
theorem mk_quotientEquivOfIsCompl_apply (h : IsCompl p q) (x : E ⧸ p) :
    (Quotient.mk (quotientEquivOfIsCompl p q h x) : E ⧸ p) = x :=
(quotientEquivOfIsCompl p q h).symm_apply_apply x

/-- If `q` is a complement of `p`, then `p × q` is isomorphic to `E`. -/
```

-- snippet 8
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl (L96-L103)
def prodEquivOfIsCompl (h : IsCompl p q) : (p × q) ≃ₗ[R] E := by
apply LinearEquiv.ofBijective (p.subtype.coprod q.subtype)
  constructor
  · rw [← ker_eq_bot, ker_coprod_of_disjoint_range, ker_subtype, ker_subtype, prod_bot]
    rw [range_subtype, range_subtype]
    exact h.1
  · rw [← range_eq_top, ← sup_eq_range, h.sup_eq_top]
```

-- snippet 9
```lean
-- Mathlib.LinearAlgebra.Projection.coe_prodEquivOfIsCompl (L105-L107)
theorem coe_prodEquivOfIsCompl (h : IsCompl p q) :
    (prodEquivOfIsCompl p q h : p × q →ₗ[R] E) = p.subtype.coprod q.subtype := rfl
```

-- snippet 10
```lean
-- Mathlib.LinearAlgebra.Projection.coe_prodEquivOfIsCompl' (L109-L111)
theorem coe_prodEquivOfIsCompl' (h : IsCompl p q) (x : p × q) :
    prodEquivOfIsCompl p q h x = x.1 + x.2 := rfl
```

-- snippet 11
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_left (L112-L115)
theorem prodEquivOfIsCompl_symm_apply_left (h : IsCompl p q) (x : p) :
    (prodEquivOfIsCompl p q h).symm x = (x, 0) :=
(prodEquivOfIsCompl p q h).symm_apply_eq.2 <| by simp
```

-- snippet 12
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_right (L116-L119)
theorem prodEquivOfIsCompl_symm_apply_right (h : IsCompl p q) (x : q) :
    (prodEquivOfIsCompl p q h).symm x = (0, x) :=
(prodEquivOfIsCompl p q h).symm_apply_eq.2 <| by simp
```

-- snippet 13
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_fst_eq_zero (L120-L125)
theorem prodEquivOfIsCompl_symm_apply_fst_eq_zero (h : IsCompl p q) {x : E} :
    ((prodEquivOfIsCompl p q h).symm x).1 = 0 ↔ x ∈ q := by
conv_rhs => rw [← (prodEquivOfIsCompl p q h).apply_symm_apply x]
  rw [coe_prodEquivOfIsCompl', Submodule.add_mem_iff_left _ (Submodule.coe_mem _),
    mem_right_iff_eq_zero_of_disjoint h.disjoint]
```

-- snippet 14
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_snd_eq_zero (L126-L131)
theorem prodEquivOfIsCompl_symm_apply_snd_eq_zero (h : IsCompl p q) {x : E} :
    ((prodEquivOfIsCompl p q h).symm x).2 = 0 ↔ x ∈ p := by
conv_rhs => rw [← (prodEquivOfIsCompl p q h).apply_symm_apply x]
  rw [coe_prodEquivOfIsCompl', Submodule.add_mem_iff_right _ (Submodule.coe_mem _),
    mem_left_iff_eq_zero_of_disjoint h.disjoint]
```

-- snippet 15
```lean
-- Mathlib.LinearAlgebra.Projection.prodComm_trans_prodEquivOfIsCompl (L133-L140)
theorem prodComm_trans_prodEquivOfIsCompl (h : IsCompl p q) :
    LinearEquiv.prodComm R q p ≪≫ₗ prodEquivOfIsCompl p q h = prodEquivOfIsCompl q p h.symm :=
LinearEquiv.ext fun _ => add_comm _ _

/-- Projection to a submodule along a complement. It is the unique
linear map `f : E → p` such that `f x = x` for `x ∈ p` and `f x = 0` for `x ∈ q`.

See also `LinearMap.linearProjOfIsCompl`. -/
```

-- snippet 16
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl (L141-L154)
def linearProjOfIsCompl (h : IsCompl p q) : E →ₗ[R] p :=
LinearMap.fst R p q ∘ₗ ↑(prodEquivOfIsCompl p q h).symm

variable {p q}

/-- The linear projection onto a subspace along its complement
as a map from the full space to itself, as opposed to `Submodule.linearProjOfIsCompl`,
which maps into the subtype.
This version is important as it satisfies `IsIdempotentElem`. -/
noncomputable def IsCompl.projection (hpq : IsCompl p q) :=
  p.subtype ∘ₗ p.linearProjOfIsCompl q hpq

open Submodule
```

-- snippet 17
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L155-L158)
theorem IsCompl.projection_apply (hpq : IsCompl p q) (x : E) :
    hpq.projection x = p.linearProjOfIsCompl q hpq x :=
rfl
```

-- snippet 18
```lean
-- Mathlib.LinearAlgebra.Projection.coe_linearProjOfIsCompl_apply (L160-L163)
theorem coe_linearProjOfIsCompl_apply (hpq : IsCompl p q) (x : E) :
    (p.linearProjOfIsCompl q hpq x : E) = hpq.projection x :=
rfl
```

-- snippet 19
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L165-L168)
theorem IsCompl.projection_apply_mem (hpq : IsCompl p q) (x : E) :
    hpq.projection x ∈ p :=
SetLike.coe_mem _
```

-- snippet 20
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_apply_left (L170-L173)
theorem linearProjOfIsCompl_apply_left (h : IsCompl p q) (x : p) :
    linearProjOfIsCompl p q h x = x := by
simp [linearProjOfIsCompl, prodEquivOfIsCompl_symm_apply_left]
```

-- snippet 21
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L175-L177)
theorem IsCompl.projection_apply_left (hpq : IsCompl p q) (x : p) :
    hpq.projection x = x := by simp [projection]
```

-- snippet 22
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_range (L179-L181)
theorem linearProjOfIsCompl_range (h : IsCompl p q) : range (linearProjOfIsCompl p q h) = ⊤ :=
range_eq_of_proj (linearProjOfIsCompl_apply_left h)
```

-- snippet 23
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L183-L185)
theorem IsCompl.projection_range (hpq : IsCompl p q) : range hpq.projection = p := by
simp [projection, range_comp]
```

-- snippet 24
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_surjective (L186-L189)
theorem linearProjOfIsCompl_surjective (h : IsCompl p q) :
    Function.Surjective (linearProjOfIsCompl p q h) :=
range_eq_top.mp (linearProjOfIsCompl_range h)
```

-- snippet 25
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_apply_eq_zero_iff (L191-L194)
theorem linearProjOfIsCompl_apply_eq_zero_iff (h : IsCompl p q) {x : E} :
    linearProjOfIsCompl p q h x = 0 ↔ x ∈ q := by
simp [linearProjOfIsCompl, prodEquivOfIsCompl_symm_apply_fst_eq_zero]
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.Projection).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem commute_iff_of_isUnit (hT : IsUnit T) (hf : IsIdempotentElem f) :
    Commute f T ↔ (range f).map T = range f ∧ (ker f).map T = ker f
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.LinearAlgebra.Projection.ker_id_sub_eq_of_proj (L46-L51)
theorem ker_id_sub_eq_of_proj {f : E →ₗ[R] p} (hf : ∀ x : p, f x = x) :
    ker (id - p.subtype.comp f) = p := by
ext x
  simp only [comp_apply, mem_ker, subtype_apply, sub_apply, id_apply, sub_eq_zero]
  exact ⟨fun h => h.symm ▸ Submodule.coe_mem _, fun hx => by rw [hf ⟨x, hx⟩, Subtype.coe_mk]⟩
```

-- snippet 2
```lean
-- Mathlib.LinearAlgebra.Projection.range_eq_of_proj (L52-L54)
theorem range_eq_of_proj {f : E →ₗ[R] p} (hf : ∀ x : p, f x = x) : range f = ⊤ :=
range_eq_top.2 fun x => ⟨x, hf x⟩
```

-- snippet 3
```lean
-- Mathlib.LinearAlgebra.Projection.isCompl_of_proj (L55-L73)
theorem isCompl_of_proj {f : E →ₗ[R] p} (hf : ∀ x : p, f x = x) : IsCompl p (ker f) := by
constructor
  · rw [disjoint_iff_inf_le]
    rintro x ⟨hpx, hfx⟩
    rw [SetLike.mem_coe, mem_ker, hf ⟨x, hpx⟩, mk_eq_zero] at hfx
    simp only [hfx, zero_mem]
  · rw [codisjoint_iff_le_sup]
    intro x _
    rw [mem_sup']
    refine ⟨f x, ⟨x - f x, ?_⟩, add_sub_cancel _ _⟩
    rw [mem_ker, map_sub, hf, sub_self]

end LinearMap

namespace Submodule

open LinearMap

/-- If `q` is a complement of `p`, then `M/p ≃ q`. -/
```

-- snippet 4
```lean
-- Mathlib.LinearAlgebra.Projection.quotientEquivOfIsCompl (L74-L79)
def quotientEquivOfIsCompl (h : IsCompl p q) : (E ⧸ p) ≃ₗ[R] q :=
LinearEquiv.symm <|
    LinearEquiv.ofBijective (p.mkQ.comp q.subtype)
      ⟨by rw [← ker_eq_bot, ker_comp, ker_mkQ, disjoint_iff_comap_eq_bot.1 h.symm.disjoint], by
        rw [← range_eq_top, range_comp, range_subtype, map_mkQ_eq_top, h.sup_eq_top]⟩
```

-- snippet 5
```lean
-- Mathlib.LinearAlgebra.Projection.quotientEquivOfIsCompl_symm_apply (L81-L84)
theorem quotientEquivOfIsCompl_symm_apply (h : IsCompl p q) (x : q) :
    -- Porting note: type ascriptions needed on the RHS
    (quotientEquivOfIsCompl p q h).symm x = (Quotient.mk x : E ⧸ p) := rfl
```

-- snippet 6
```lean
-- Mathlib.LinearAlgebra.Projection.quotientEquivOfIsCompl_apply_mk_coe (L86-L89)
theorem quotientEquivOfIsCompl_apply_mk_coe (h : IsCompl p q) (x : q) :
    quotientEquivOfIsCompl p q h (Quotient.mk x) = x :=
(quotientEquivOfIsCompl p q h).apply_symm_apply x
```

-- snippet 7
```lean
-- Mathlib.LinearAlgebra.Projection.mk_quotientEquivOfIsCompl_apply (L91-L95)
theorem mk_quotientEquivOfIsCompl_apply (h : IsCompl p q) (x : E ⧸ p) :
    (Quotient.mk (quotientEquivOfIsCompl p q h x) : E ⧸ p) = x :=
(quotientEquivOfIsCompl p q h).symm_apply_apply x

/-- If `q` is a complement of `p`, then `p × q` is isomorphic to `E`. -/
```

-- snippet 8
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl (L96-L103)
def prodEquivOfIsCompl (h : IsCompl p q) : (p × q) ≃ₗ[R] E := by
apply LinearEquiv.ofBijective (p.subtype.coprod q.subtype)
  constructor
  · rw [← ker_eq_bot, ker_coprod_of_disjoint_range, ker_subtype, ker_subtype, prod_bot]
    rw [range_subtype, range_subtype]
    exact h.1
  · rw [← range_eq_top, ← sup_eq_range, h.sup_eq_top]
```

-- snippet 9
```lean
-- Mathlib.LinearAlgebra.Projection.coe_prodEquivOfIsCompl (L105-L107)
theorem coe_prodEquivOfIsCompl (h : IsCompl p q) :
    (prodEquivOfIsCompl p q h : p × q →ₗ[R] E) = p.subtype.coprod q.subtype := rfl
```

-- snippet 10
```lean
-- Mathlib.LinearAlgebra.Projection.coe_prodEquivOfIsCompl' (L109-L111)
theorem coe_prodEquivOfIsCompl' (h : IsCompl p q) (x : p × q) :
    prodEquivOfIsCompl p q h x = x.1 + x.2 := rfl
```

-- snippet 11
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_left (L112-L115)
theorem prodEquivOfIsCompl_symm_apply_left (h : IsCompl p q) (x : p) :
    (prodEquivOfIsCompl p q h).symm x = (x, 0) :=
(prodEquivOfIsCompl p q h).symm_apply_eq.2 <| by simp
```

-- snippet 12
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_right (L116-L119)
theorem prodEquivOfIsCompl_symm_apply_right (h : IsCompl p q) (x : q) :
    (prodEquivOfIsCompl p q h).symm x = (0, x) :=
(prodEquivOfIsCompl p q h).symm_apply_eq.2 <| by simp
```

-- snippet 13
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_fst_eq_zero (L120-L125)
theorem prodEquivOfIsCompl_symm_apply_fst_eq_zero (h : IsCompl p q) {x : E} :
    ((prodEquivOfIsCompl p q h).symm x).1 = 0 ↔ x ∈ q := by
conv_rhs => rw [← (prodEquivOfIsCompl p q h).apply_symm_apply x]
  rw [coe_prodEquivOfIsCompl', Submodule.add_mem_iff_left _ (Submodule.coe_mem _),
    mem_right_iff_eq_zero_of_disjoint h.disjoint]
```

-- snippet 14
```lean
-- Mathlib.LinearAlgebra.Projection.prodEquivOfIsCompl_symm_apply_snd_eq_zero (L126-L131)
theorem prodEquivOfIsCompl_symm_apply_snd_eq_zero (h : IsCompl p q) {x : E} :
    ((prodEquivOfIsCompl p q h).symm x).2 = 0 ↔ x ∈ p := by
conv_rhs => rw [← (prodEquivOfIsCompl p q h).apply_symm_apply x]
  rw [coe_prodEquivOfIsCompl', Submodule.add_mem_iff_right _ (Submodule.coe_mem _),
    mem_left_iff_eq_zero_of_disjoint h.disjoint]
```

-- snippet 15
```lean
-- Mathlib.LinearAlgebra.Projection.prodComm_trans_prodEquivOfIsCompl (L133-L140)
theorem prodComm_trans_prodEquivOfIsCompl (h : IsCompl p q) :
    LinearEquiv.prodComm R q p ≪≫ₗ prodEquivOfIsCompl p q h = prodEquivOfIsCompl q p h.symm :=
LinearEquiv.ext fun _ => add_comm _ _

/-- Projection to a submodule along a complement. It is the unique
linear map `f : E → p` such that `f x = x` for `x ∈ p` and `f x = 0` for `x ∈ q`.

See also `LinearMap.linearProjOfIsCompl`. -/
```

-- snippet 16
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl (L141-L154)
def linearProjOfIsCompl (h : IsCompl p q) : E →ₗ[R] p :=
LinearMap.fst R p q ∘ₗ ↑(prodEquivOfIsCompl p q h).symm

variable {p q}

/-- The linear projection onto a subspace along its complement
as a map from the full space to itself, as opposed to `Submodule.linearProjOfIsCompl`,
which maps into the subtype.
This version is important as it satisfies `IsIdempotentElem`. -/
noncomputable def IsCompl.projection (hpq : IsCompl p q) :=
  p.subtype ∘ₗ p.linearProjOfIsCompl q hpq

open Submodule
```

-- snippet 17
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L155-L158)
theorem IsCompl.projection_apply (hpq : IsCompl p q) (x : E) :
    hpq.projection x = p.linearProjOfIsCompl q hpq x :=
rfl
```

-- snippet 18
```lean
-- Mathlib.LinearAlgebra.Projection.coe_linearProjOfIsCompl_apply (L160-L163)
theorem coe_linearProjOfIsCompl_apply (hpq : IsCompl p q) (x : E) :
    (p.linearProjOfIsCompl q hpq x : E) = hpq.projection x :=
rfl
```

-- snippet 19
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L165-L168)
theorem IsCompl.projection_apply_mem (hpq : IsCompl p q) (x : E) :
    hpq.projection x ∈ p :=
SetLike.coe_mem _
```

-- snippet 20
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_apply_left (L170-L173)
theorem linearProjOfIsCompl_apply_left (h : IsCompl p q) (x : p) :
    linearProjOfIsCompl p q h x = x := by
simp [linearProjOfIsCompl, prodEquivOfIsCompl_symm_apply_left]
```

-- snippet 21
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L175-L177)
theorem IsCompl.projection_apply_left (hpq : IsCompl p q) (x : p) :
    hpq.projection x = x := by simp [projection]
```

-- snippet 22
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_range (L179-L181)
theorem linearProjOfIsCompl_range (h : IsCompl p q) : range (linearProjOfIsCompl p q h) = ⊤ :=
range_eq_of_proj (linearProjOfIsCompl_apply_left h)
```

-- snippet 23
```lean
-- Mathlib.LinearAlgebra.Projection.IsCompl (L183-L185)
theorem IsCompl.projection_range (hpq : IsCompl p q) : range hpq.projection = p := by
simp [projection, range_comp]
```

-- snippet 24
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_surjective (L186-L189)
theorem linearProjOfIsCompl_surjective (h : IsCompl p q) :
    Function.Surjective (linearProjOfIsCompl p q h) :=
range_eq_top.mp (linearProjOfIsCompl_range h)
```

-- snippet 25
```lean
-- Mathlib.LinearAlgebra.Projection.linearProjOfIsCompl_apply_eq_zero_iff (L191-L194)
theorem linearProjOfIsCompl_apply_eq_zero_iff (h : IsCompl p q) {x : E} :
    linearProjOfIsCompl p q h x = 0 ↔ x ∈ q := by
simp [linearProjOfIsCompl, prodEquivOfIsCompl_symm_apply_fst_eq_zero]
```
[/INST]

mistral-common:Tekken v15 (Mistral chat template, [INST]/[SYSTEM_PROMPT])


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.GroupTheory.GroupAction.ConjAct).

[User]
You are editing a file in `Mathlib/GroupTheory/GroupAction/ConjAct.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.GroupTheory.GroupAction.ConjAct.toConjAct_inv`, L117-L119)
Open namespaces: MulAction, Subgroup

## Surrounding context in Mathlib/GroupTheory/GroupAction/ConjAct.lean
```lean
-- Mathlib.GroupTheory.GroupAction.ConjAct.ConjAct (L43-L51)
def ConjAct : Type _

-- Mathlib.GroupTheory.GroupAction.ConjAct.card (L59-L65)
theorem card [Fintype G] : Fintype.card (ConjAct G) = Fintype.card G

-- Mathlib.GroupTheory.GroupAction.ConjAct.ofConjAct (L70-L75)
def ofConjAct : ConjAct G ≃* G where
  toFun
```

```lean
theorem toConjAct_inv (x : G) : toConjAct x⁻¹ = (toConjAct x)⁻¹ := rfl
```

## Edit instruction
Edit `toConjAct_inv` so it still compiles and the proof is simplified where possible. Return the full updated `toConjAct_inv` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.GroupTheory.GroupAction.ConjAct).

You are editing a file in `Mathlib/GroupTheory/GroupAction/ConjAct.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.GroupTheory.GroupAction.ConjAct.toConjAct_inv`, L117-L119)
Open namespaces: MulAction, Subgroup

## Surrounding context in Mathlib/GroupTheory/GroupAction/ConjAct.lean
```lean
-- Mathlib.GroupTheory.GroupAction.ConjAct.ConjAct (L43-L51)
def ConjAct : Type _

-- Mathlib.GroupTheory.GroupAction.ConjAct.card (L59-L65)
theorem card [Fintype G] : Fintype.card (ConjAct G) = Fintype.card G

-- Mathlib.GroupTheory.GroupAction.ConjAct.ofConjAct (L70-L75)
def ofConjAct : ConjAct G ≃* G where
  toFun
```

```lean
theorem toConjAct_inv (x : G) : toConjAct x⁻¹ = (toConjAct x)⁻¹ := rfl
```

## Edit instruction
Edit `toConjAct_inv` so it still compiles and the proof is simplified where possible. Return the full updated `toConjAct_inv` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal).

[User]
You are editing a file in `Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.node_eq_neg_one`, L56-L59)
Open namespaces: Polynomial, Real

## Surrounding context in Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.node_eq_one (L54-L55)
lemma node_eq_one {n : ℕ} : node n 0 = 1

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.node_mem_Icc (L60-L62)
lemma node_mem_Icc {n i : ℕ} : node n i ∈ Set.Icc (-1) 1

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.eval_T_real_node (L63-L69)
lemma eval_T_real_node {n i : ℕ} (hi : i ∈ Finset.Iic n) :
    (T ℝ n).eval (node n i) = (-1) ^ i
```

```lean
lemma node_eq_neg_one {n : ℕ} (hn : n ≠ 0) : node n n = -1 := by
have : n * π / n = π := by aesop
  simp [node, this]
```

## Edit instruction
Edit `node_eq_neg_one` so it still compiles and the proof is simplified where possible. Return the full updated `node_eq_neg_one` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal).

You are editing a file in `Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.node_eq_neg_one`, L56-L59)
Open namespaces: Polynomial, Real

## Surrounding context in Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.node_eq_one (L54-L55)
lemma node_eq_one {n : ℕ} : node n 0 = 1

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.node_mem_Icc (L60-L62)
lemma node_mem_Icc {n i : ℕ} : node n i ∈ Set.Icc (-1) 1

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Extremal.eval_T_real_node (L63-L69)
lemma eval_T_real_node {n i : ℕ} (hi : i ∈ Finset.Iic n) :
    (T ℝ n).eval (node n i) = (-1) ^ i
```

```lean
lemma node_eq_neg_one {n : ℕ} (hn : n ≠ 0) : node n n = -1 := by
have : n * π / n = π := by aesop
  simp [node, this]
```

## Edit instruction
Edit `node_eq_neg_one` so it still compiles and the proof is simplified where possible. Return the full updated `node_eq_neg_one` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Set.Basic).

[User]
You are editing a file in `Mathlib/Data/Set/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Set.Basic.setOf_or`, L216-L221)
Open namespaces: Function

## Surrounding context in Mathlib/Data/Set/Basic.lean
```lean
-- Mathlib.Data.Set.Basic.instDistribLattice (L76-L82)
instance instDistribLattice : DistribLattice (Set α) where
  __ : DistribLattice (α → Prop)

-- Mathlib.Data.Set.Basic.instBoundedOrder (L83-L87)
instance instBoundedOrder : BoundedOrder (Set α) where
  __ : BoundedOrder (α → Prop)

-- Mathlib.Data.Set.Basic.top_eq_univ (L92-L94)
theorem top_eq_univ : (⊤ : Set α) = univ
```

```lean
theorem setOf_or {p q : α → Prop} : { a | p a ∨ q a } = { a | p a } ∪ { a | q a } := rfl

/-! ### Subset and strict subset relations -/
```

## Edit instruction
Edit `setOf_or` so it still compiles and the proof is simplified where possible. Return the full updated `setOf_or` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Set.Basic).

You are editing a file in `Mathlib/Data/Set/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Set.Basic.setOf_or`, L216-L221)
Open namespaces: Function

## Surrounding context in Mathlib/Data/Set/Basic.lean
```lean
-- Mathlib.Data.Set.Basic.instDistribLattice (L76-L82)
instance instDistribLattice : DistribLattice (Set α) where
  __ : DistribLattice (α → Prop)

-- Mathlib.Data.Set.Basic.instBoundedOrder (L83-L87)
instance instBoundedOrder : BoundedOrder (Set α) where
  __ : BoundedOrder (α → Prop)

-- Mathlib.Data.Set.Basic.top_eq_univ (L92-L94)
theorem top_eq_univ : (⊤ : Set α) = univ
```

```lean
theorem setOf_or {p q : α → Prop} : { a | p a ∨ q a } = { a | p a } ∪ { a | q a } := rfl

/-! ### Subset and strict subset relations -/
```

## Edit instruction
Edit `setOf_or` so it still compiles and the proof is simplified where possible. Return the full updated `setOf_or` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Finset.Lattice.Lemmas).

[User]
You are editing a file in `Mathlib/Data/Finset/Lattice/Lemmas.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Finset.Lattice.Lemmas.singleton_inter_of_notMem`, L158-L161)
Open namespaces: Multiset, Subtype, Function

## Surrounding context in Mathlib/Data/Finset/Lattice/Lemmas.lean
```lean
-- Mathlib.Data.Finset.Lattice.Lemmas.disjoint_iff_inter_eq_empty (L47-L51)
theorem disjoint_iff_inter_eq_empty : Disjoint s t ↔ s ∩ t = ∅

-- Mathlib.Data.Finset.Lattice.Lemmas.union_empty (L53-L55)
theorem union_empty (s : Finset α) : s ∪ ∅ = s

-- Mathlib.Data.Finset.Lattice.Lemmas.empty_union (L57-L59)
theorem empty_union (s : Finset α) : ∅ ∪ s = s
```

Relevant lemmas available in scope: `H`

```lean
theorem singleton_inter_of_notMem {a : α} {s : Finset α} (H : a ∉ s) : {a} ∩ s = ∅ := eq_empty_of_forall_notMem <| by
    simp only [mem_inter, mem_singleton]; rintro x ⟨rfl, h⟩; exact H h
```

## Edit instruction
Edit `singleton_inter_of_notMem` so it still compiles and the proof is simplified where possible. Return the full updated `singleton_inter_of_notMem` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Finset.Lattice.Lemmas).

You are editing a file in `Mathlib/Data/Finset/Lattice/Lemmas.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Finset.Lattice.Lemmas.singleton_inter_of_notMem`, L158-L161)
Open namespaces: Multiset, Subtype, Function

## Surrounding context in Mathlib/Data/Finset/Lattice/Lemmas.lean
```lean
-- Mathlib.Data.Finset.Lattice.Lemmas.disjoint_iff_inter_eq_empty (L47-L51)
theorem disjoint_iff_inter_eq_empty : Disjoint s t ↔ s ∩ t = ∅

-- Mathlib.Data.Finset.Lattice.Lemmas.union_empty (L53-L55)
theorem union_empty (s : Finset α) : s ∪ ∅ = s

-- Mathlib.Data.Finset.Lattice.Lemmas.empty_union (L57-L59)
theorem empty_union (s : Finset α) : ∅ ∪ s = s
```

Relevant lemmas available in scope: `H`

```lean
theorem singleton_inter_of_notMem {a : α} {s : Finset α} (H : a ∉ s) : {a} ∩ s = ∅ := eq_empty_of_forall_notMem <| by
    simp only [mem_inter, mem_singleton]; rintro x ⟨rfl, h⟩; exact H h
```

## Edit instruction
Edit `singleton_inter_of_notMem` so it still compiles and the proof is simplified where possible. Return the full updated `singleton_inter_of_notMem` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.Constructions).

[User]
You are editing a file in `Mathlib/Topology/Constructions.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Topology.Constructions.instTopologicalSpaceSigma`, L61-L64)
Open namespaces: Topology, TopologicalSpace, Set, Filter, Function, scoped, Set.Notation

## Surrounding context in Mathlib/Topology/Constructions.lean
```lean
-- Mathlib.Topology.Constructions.instTopologicalSpaceQuotient (L57-L60)
instance instTopologicalSpaceQuotient {s : Setoid X} [t : TopologicalSpace X] :
    TopologicalSpace (Quotient s)

-- Mathlib.Topology.Constructions.Pi (L65-L68)
instance Pi.topologicalSpace {ι : Type*} {Y : ι → Type v} [t₂ : (i : ι) → TopologicalSpace (Y i)] :
    TopologicalSpace ((i : ι) → Y i)

-- Mathlib.Topology.Constructions.ULift (L69-L77)
instance ULift.topologicalSpace [t : TopologicalSpace X] : TopologicalSpace (ULift.{v, u} X)
```

```lean
instance instTopologicalSpaceSigma {ι : Type*} {X : ι → Type v} [t₂ : ∀ i, TopologicalSpace (X i)] :
    TopologicalSpace (Sigma X) := ⨆ i, coinduced (Sigma.mk i) (t₂ i)
```

## Edit instruction
Edit `instTopologicalSpaceSigma` so it still compiles and the proof is simplified where possible. Return the full updated `instTopologicalSpaceSigma` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.Constructions).

You are editing a file in `Mathlib/Topology/Constructions.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Topology.Constructions.instTopologicalSpaceSigma`, L61-L64)
Open namespaces: Topology, TopologicalSpace, Set, Filter, Function, scoped, Set.Notation

## Surrounding context in Mathlib/Topology/Constructions.lean
```lean
-- Mathlib.Topology.Constructions.instTopologicalSpaceQuotient (L57-L60)
instance instTopologicalSpaceQuotient {s : Setoid X} [t : TopologicalSpace X] :
    TopologicalSpace (Quotient s)

-- Mathlib.Topology.Constructions.Pi (L65-L68)
instance Pi.topologicalSpace {ι : Type*} {Y : ι → Type v} [t₂ : (i : ι) → TopologicalSpace (Y i)] :
    TopologicalSpace ((i : ι) → Y i)

-- Mathlib.Topology.Constructions.ULift (L69-L77)
instance ULift.topologicalSpace [t : TopologicalSpace X] : TopologicalSpace (ULift.{v, u} X)
```

```lean
instance instTopologicalSpaceSigma {ι : Type*} {X : ι → Type v} [t₂ : ∀ i, TopologicalSpace (X i)] :
    TopologicalSpace (Sigma X) := ⨆ i, coinduced (Sigma.mk i) (t₂ i)
```

## Edit instruction
Edit `instTopologicalSpaceSigma` so it still compiles and the proof is simplified where possible. Return the full updated `instTopologicalSpaceSigma` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.MvPolynomial.Eval).

[User]
You are editing a file in `Mathlib/Algebra/MvPolynomial/Eval.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.MvPolynomial.Eval.eval_monomial`, L262-L264)
Open namespaces: Set, Function, Finsupp, AddMonoidAlgebra, scoped, Pointwise

## Surrounding context in Mathlib/Algebra/MvPolynomial/Eval.lean
```lean
-- Mathlib.Algebra.MvPolynomial.Eval.eval₂ (L69-L71)
def eval₂ (p : MvPolynomial σ R) : S₁

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq (L72-L75)
theorem eval₂_eq (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i ∈ d.support, X i ^ d i

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq' (L76-L80)
theorem eval₂_eq' [Fintype σ] (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i, X i ^ d i
```

```lean
theorem eval_monomial : eval f (monomial s a) = a * s.prod fun n e => f n ^ e := eval₂_monomial _ _
```

## Edit instruction
Edit `eval_monomial` so it still compiles and the proof is simplified where possible. Return the full updated `eval_monomial` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.MvPolynomial.Eval).

You are editing a file in `Mathlib/Algebra/MvPolynomial/Eval.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.MvPolynomial.Eval.eval_monomial`, L262-L264)
Open namespaces: Set, Function, Finsupp, AddMonoidAlgebra, scoped, Pointwise

## Surrounding context in Mathlib/Algebra/MvPolynomial/Eval.lean
```lean
-- Mathlib.Algebra.MvPolynomial.Eval.eval₂ (L69-L71)
def eval₂ (p : MvPolynomial σ R) : S₁

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq (L72-L75)
theorem eval₂_eq (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i ∈ d.support, X i ^ d i

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq' (L76-L80)
theorem eval₂_eq' [Fintype σ] (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i, X i ^ d i
```

```lean
theorem eval_monomial : eval f (monomial s a) = a * s.prod fun n e => f n ^ e := eval₂_monomial _ _
```

## Edit instruction
Edit `eval_monomial` so it still compiles and the proof is simplified where possible. Return the full updated `eval_monomial` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.Interval.Finset.Basic).

[User]
You are editing a file in `Mathlib/Order/Interval/Finset/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.Interval.Finset.Basic.uIcc_subset_uIcc_iff_le'`, L972-L975)
Open namespaces: Function, OrderDual, FinsetInterval

## Surrounding context in Mathlib/Order/Interval/Finset/Basic.lean
```lean
-- Mathlib.Order.Interval.Finset.Basic.nonempty_Icc (L59-L61)
theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b

-- Mathlib.Order.Interval.Finset.Basic.nonempty_Ico (L66-L68)
theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b

-- Mathlib.Order.Interval.Finset.Basic.nonempty_Ioc (L73-L75)
theorem nonempty_Ioc : (Ioc a b).Nonempty ↔ a < b
```

```lean
theorem uIcc_subset_uIcc_iff_le' :
    [[a₁, b₁]] ⊆ [[a₂, b₂]] ↔ a₂ ⊓ b₂ ≤ a₁ ⊓ b₁ ∧ a₁ ⊔ b₁ ≤ a₂ ⊔ b₂ := Icc_subset_Icc_iff inf_le_sup
```

## Edit instruction
Edit `uIcc_subset_uIcc_iff_le'` so it still compiles and the proof is simplified where possible. Return the full updated `uIcc_subset_uIcc_iff_le'` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.Interval.Finset.Basic).

You are editing a file in `Mathlib/Order/Interval/Finset/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.Interval.Finset.Basic.uIcc_subset_uIcc_iff_le'`, L972-L975)
Open namespaces: Function, OrderDual, FinsetInterval

## Surrounding context in Mathlib/Order/Interval/Finset/Basic.lean
```lean
-- Mathlib.Order.Interval.Finset.Basic.nonempty_Icc (L59-L61)
theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b

-- Mathlib.Order.Interval.Finset.Basic.nonempty_Ico (L66-L68)
theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b

-- Mathlib.Order.Interval.Finset.Basic.nonempty_Ioc (L73-L75)
theorem nonempty_Ioc : (Ioc a b).Nonempty ↔ a < b
```

```lean
theorem uIcc_subset_uIcc_iff_le' :
    [[a₁, b₁]] ⊆ [[a₂, b₂]] ↔ a₂ ⊓ b₂ ≤ a₁ ⊓ b₁ ∧ a₁ ⊔ b₁ ≤ a₂ ⊔ b₂ := Icc_subset_Icc_iff inf_le_sup
```

## Edit instruction
Edit `uIcc_subset_uIcc_iff_le'` so it still compiles and the proof is simplified where possible. Return the full updated `uIcc_subset_uIcc_iff_le'` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.Order.Nonneg.Basic).

[User]
You are editing a file in `Mathlib/Algebra/Order/Nonneg/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Order.Nonneg.Basic.mk_sub_mk`, L283-L291)
Open namespaces: Set

## Surrounding context in Mathlib/Algebra/Order/Nonneg/Basic.lean
```lean
-- Mathlib.Algebra.Order.Nonneg.Basic.inhabited (L48-L50)
instance inhabited [Preorder α] {a : α} : Inhabited { x : α // a ≤ x }

-- Mathlib.Algebra.Order.Nonneg.Basic.zero (L51-L53)
instance zero [Zero α] [Preorder α] : Zero { x : α // 0 ≤ x }

-- Mathlib.Algebra.Order.Nonneg.Basic.mk_eq_zero (L59-L62)
theorem mk_eq_zero [Zero α] [Preorder α] {x : α} (hx : 0 ≤ x) :
    (⟨x, hx⟩ : { x : α // 0 ≤ x }) = 0 ↔ x = 0
```

```lean
theorem mk_sub_mk [Sub α] {x y : α} (hx : 0 ≤ x) (hy : 0 ≤ y) :
    (⟨x, hx⟩ : { x : α // 0 ≤ x }) - ⟨y, hy⟩ = toNonneg (x - y) := rfl

end SemilatticeSup

section LinearOrder
variable [Zero α] [LinearOrder α]
```

## Edit instruction
Edit `mk_sub_mk` so it still compiles and the proof is simplified where possible. Return the full updated `mk_sub_mk` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.Order.Nonneg.Basic).

You are editing a file in `Mathlib/Algebra/Order/Nonneg/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Order.Nonneg.Basic.mk_sub_mk`, L283-L291)
Open namespaces: Set

## Surrounding context in Mathlib/Algebra/Order/Nonneg/Basic.lean
```lean
-- Mathlib.Algebra.Order.Nonneg.Basic.inhabited (L48-L50)
instance inhabited [Preorder α] {a : α} : Inhabited { x : α // a ≤ x }

-- Mathlib.Algebra.Order.Nonneg.Basic.zero (L51-L53)
instance zero [Zero α] [Preorder α] : Zero { x : α // 0 ≤ x }

-- Mathlib.Algebra.Order.Nonneg.Basic.mk_eq_zero (L59-L62)
theorem mk_eq_zero [Zero α] [Preorder α] {x : α} (hx : 0 ≤ x) :
    (⟨x, hx⟩ : { x : α // 0 ≤ x }) = 0 ↔ x = 0
```

```lean
theorem mk_sub_mk [Sub α] {x y : α} (hx : 0 ≤ x) (hy : 0 ≤ y) :
    (⟨x, hx⟩ : { x : α // 0 ≤ x }) - ⟨y, hy⟩ = toNonneg (x - y) := rfl

end SemilatticeSup

section LinearOrder
variable [Zero α] [LinearOrder α]
```

## Edit instruction
Edit `mk_sub_mk` so it still compiles and the proof is simplified where possible. Return the full updated `mk_sub_mk` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.List.TFAE).

[User]
You are editing a file in `Mathlib/Data/List/TFAE.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.List.TFAE.tfae_of_cycle`, L58-L67)
```lean
theorem tfae_of_cycle {a b} {l : List Prop} (h_chain : List.IsChain (· → ·) (a :: b :: l))
    (h_last : getLastD l b → a) : TFAE (a :: b :: l) := by
induction l generalizing a b with
  | nil => simp_all [tfae_cons_cons, iff_def]
  | cons c l IH =>
    simp only [tfae_cons_cons, getLastD_cons, isChain_cons_cons] at *
    rcases h_chain with ⟨ab, ⟨bc, ch⟩⟩
    have := IH ⟨bc, ch⟩ (ab ∘ h_last)
    exact ⟨⟨ab, h_last ∘ (this.2 c (.head _) _ getLastD_mem_cons).1 ∘ bc⟩, this⟩
```

## Edit instruction
Edit `tfae_of_cycle` so it still compiles and the proof is simplified where possible. Return the full updated `tfae_of_cycle` block.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.List.TFAE).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]You are editing a file in `Mathlib/Data/List/TFAE.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.List.TFAE.tfae_of_cycle`, L58-L67)
```lean
theorem tfae_of_cycle {a b} {l : List Prop} (h_chain : List.IsChain (· → ·) (a :: b :: l))
    (h_last : getLastD l b → a) : TFAE (a :: b :: l) := by
induction l generalizing a b with
  | nil => simp_all [tfae_cons_cons, iff_def]
  | cons c l IH =>
    simp only [tfae_cons_cons, getLastD_cons, isChain_cons_cons] at *
    rcases h_chain with ⟨ab, ⟨bc, ch⟩⟩
    have := IH ⟨bc, ch⟩ (ab ∘ h_last)
    exact ⟨⟨ab, h_last ∘ (this.2 c (.head _) _ getLastD_mem_cons).1 ∘ bc⟩, this⟩
```

## Edit instruction
Edit `tfae_of_cycle` so it still compiles and the proof is simplified where possible. Return the full updated `tfae_of_cycle` block.
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.RingTheory.TwoSidedIdeal.Lattice).

[User]
You are editing a file in `Mathlib/RingTheory/TwoSidedIdeal/Lattice.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.RingTheory.TwoSidedIdeal.Lattice.iInf_ringCon`, L93-L96)
```lean
lemma iInf_ringCon {ι : Type*} (I : ι → TwoSidedIdeal R) :
    (⨅ i, I i).ringCon = ⨅ i, (I i).ringCon := by
simp only [iInf, sInf_ringCon]; congr!; ext; simp
```

## Edit instruction
Edit `iInf_ringCon` so it still compiles and the proof is simplified where possible. Return the full updated `iInf_ringCon` block.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.RingTheory.TwoSidedIdeal.Lattice).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]You are editing a file in `Mathlib/RingTheory/TwoSidedIdeal/Lattice.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.RingTheory.TwoSidedIdeal.Lattice.iInf_ringCon`, L93-L96)
```lean
lemma iInf_ringCon {ι : Type*} (I : ι → TwoSidedIdeal R) :
    (⨅ i, I i).ringCon = ⨅ i, (I i).ringCon := by
simp only [iInf, sInf_ringCon]; congr!; ext; simp
```

## Edit instruction
Edit `iInf_ringCon` so it still compiles and the proof is simplified where possible. Return the full updated `iInf_ringCon` block.
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.Category.Preord).

[User]
You are editing a file in `Mathlib/Order/Category/Preord.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.Category.Preord.inv_hom_apply`, L140-L142)
Open namespaces: CategoryTheory

## Surrounding context in Mathlib/Order/Category/Preord.lean
```lean
-- Mathlib.Order.Category.Preord.Hom (L68-L71)
abbrev Hom.hom {X Y : Preord.{u}} (f : Hom X Y)

-- Mathlib.Order.Category.Preord.ofHom (L72-L76)
abbrev ofHom {X Y : Type u} [Preorder X] [Preorder Y] (f : X →o Y) : of X ⟶ of Y

-- Mathlib.Order.Category.Preord.Hom (L77-L85)
def Hom.Simps.hom (X Y : Preord.{u}) (f : Hom X Y)
```

```lean
lemma inv_hom_apply {X Y : Preord} (e : X ≅ Y) (x : X) : e.inv (e.hom x) = x := by
simp
```

## Edit instruction
Edit `inv_hom_apply` so it still compiles and the proof is simplified where possible. Return the full updated `inv_hom_apply` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.Category.Preord).

You are editing a file in `Mathlib/Order/Category/Preord.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.Category.Preord.inv_hom_apply`, L140-L142)
Open namespaces: CategoryTheory

## Surrounding context in Mathlib/Order/Category/Preord.lean
```lean
-- Mathlib.Order.Category.Preord.Hom (L68-L71)
abbrev Hom.hom {X Y : Preord.{u}} (f : Hom X Y)

-- Mathlib.Order.Category.Preord.ofHom (L72-L76)
abbrev ofHom {X Y : Type u} [Preorder X] [Preorder Y] (f : X →o Y) : of X ⟶ of Y

-- Mathlib.Order.Category.Preord.Hom (L77-L85)
def Hom.Simps.hom (X Y : Preord.{u}) (f : Hom X Y)
```

```lean
lemma inv_hom_apply {X Y : Preord} (e : X ≅ Y) (x : X) : e.inv (e.hom x) = x := by
simp
```

## Edit instruction
Edit `inv_hom_apply` so it still compiles and the proof is simplified where possible. Return the full updated `inv_hom_apply` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Set.Lattice.Image).

[User]
You are editing a file in `Mathlib/Data/Set/Lattice/Image.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Set.Lattice.Image.prod_eq_biUnion_left`, L573-L575)
Open namespaces: Function, Set

## Surrounding context in Mathlib/Data/Set/Lattice/Image.lean
```lean
-- Mathlib.Data.Set.Lattice.Image.kernImage_mono (L66-L68)
lemma kernImage_mono : Monotone (kernImage f)

-- Mathlib.Data.Set.Lattice.Image.kernImage_eq_compl (L69-L72)
lemma kernImage_eq_compl {s : Set α} : kernImage f s = (f '' sᶜ)ᶜ

-- Mathlib.Data.Set.Lattice.Image.kernImage_compl (L73-L75)
lemma kernImage_compl {s : Set α} : kernImage f (sᶜ) = (f '' s)ᶜ
```

```lean
theorem prod_eq_biUnion_left : s ×ˢ t = ⋃ a ∈ s, (fun b => (a, b)) '' t := by
rw [iUnion_image_left, image2_mk_eq_prod]
```

## Edit instruction
Edit `prod_eq_biUnion_left` so it still compiles and the proof is simplified where possible. Return the full updated `prod_eq_biUnion_left` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Set.Lattice.Image).

You are editing a file in `Mathlib/Data/Set/Lattice/Image.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Set.Lattice.Image.prod_eq_biUnion_left`, L573-L575)
Open namespaces: Function, Set

## Surrounding context in Mathlib/Data/Set/Lattice/Image.lean
```lean
-- Mathlib.Data.Set.Lattice.Image.kernImage_mono (L66-L68)
lemma kernImage_mono : Monotone (kernImage f)

-- Mathlib.Data.Set.Lattice.Image.kernImage_eq_compl (L69-L72)
lemma kernImage_eq_compl {s : Set α} : kernImage f s = (f '' sᶜ)ᶜ

-- Mathlib.Data.Set.Lattice.Image.kernImage_compl (L73-L75)
lemma kernImage_compl {s : Set α} : kernImage f (sᶜ) = (f '' s)ᶜ
```

```lean
theorem prod_eq_biUnion_left : s ×ˢ t = ⋃ a ∈ s, (fun b => (a, b)) '' t := by
rw [iUnion_image_left, image2_mk_eq_prod]
```

## Edit instruction
Edit `prod_eq_biUnion_left` so it still compiles and the proof is simplified where possible. Return the full updated `prod_eq_biUnion_left` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.DFinsupp.WellFounded).

[User]
You are editing a file in `Mathlib/Data/DFinsupp/WellFounded.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.DFinsupp.WellFounded.Pi`, L187-L195)
Open namespaces: Relation, Prod, DFinsupp

## Surrounding context in Mathlib/Data/DFinsupp/WellFounded.lean
```lean
-- Mathlib.Data.DFinsupp.WellFounded.lex_fibration (L71-L103)
theorem lex_fibration [∀ (i) (s : Set ι), Decidable (i ∈ s)] :
    Fibration (InvImage (GameAdd (DFinsupp.Lex r s) (DFinsupp.Lex r s)) snd) (DFinsupp.Lex r s)
      fun x => piecewise x.2.1 x.2.2 x.1

-- Mathlib.Data.DFinsupp.WellFounded.Lex (L104-L111)
theorem Lex.acc_of_single_erase [DecidableEq ι] {x : Π₀ i, α i} (i : ι)
    (hs : Acc (DFinsupp.Lex r s) <| single i (x i)) (hu : Acc (DFinsupp.Lex r s) <| x.erase i) :
    Acc (DFinsupp.Lex r s) x

-- Mathlib.Data.DFinsupp.WellFounded.Lex (L112-L114)
theorem Lex.acc_zero (hbot : ∀ ⦃i a⦄, ¬s i a 0) : Acc (DFinsupp.Lex r s) 0
```

```lean
theorem Pi.Lex.wellFounded [IsStrictTotalOrder ι r] [Finite ι] (hs : ∀ i, WellFounded (s i)) :
    WellFounded (Pi.Lex r (fun {i} ↦ s i)) := by
obtain h | ⟨⟨x⟩⟩ := isEmpty_or_nonempty (∀ i, α i)
  · convert emptyWf.wf
  letI : ∀ i, Zero (α i) := fun i => ⟨(hs i).min ⊤ ⟨x i, trivial⟩⟩
  haveI := IsTrans.swap r; haveI := Std.Irrefl.swap r; haveI := Fintype.ofFinite ι
  refine InvImage.wf equivFunOnFintype.symm (Lex.wellFounded' (fun i a => ?_) hs ?_)
  exacts [(hs i).not_lt_min ⊤ trivial, Finite.wellFounded_of_trans_of_irrefl (Function.swap r)]
```

## Edit instruction
Edit `Pi` so it still compiles and the proof is simplified where possible. Return the full updated `Pi` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.DFinsupp.WellFounded).

You are editing a file in `Mathlib/Data/DFinsupp/WellFounded.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.DFinsupp.WellFounded.Pi`, L187-L195)
Open namespaces: Relation, Prod, DFinsupp

## Surrounding context in Mathlib/Data/DFinsupp/WellFounded.lean
```lean
-- Mathlib.Data.DFinsupp.WellFounded.lex_fibration (L71-L103)
theorem lex_fibration [∀ (i) (s : Set ι), Decidable (i ∈ s)] :
    Fibration (InvImage (GameAdd (DFinsupp.Lex r s) (DFinsupp.Lex r s)) snd) (DFinsupp.Lex r s)
      fun x => piecewise x.2.1 x.2.2 x.1

-- Mathlib.Data.DFinsupp.WellFounded.Lex (L104-L111)
theorem Lex.acc_of_single_erase [DecidableEq ι] {x : Π₀ i, α i} (i : ι)
    (hs : Acc (DFinsupp.Lex r s) <| single i (x i)) (hu : Acc (DFinsupp.Lex r s) <| x.erase i) :
    Acc (DFinsupp.Lex r s) x

-- Mathlib.Data.DFinsupp.WellFounded.Lex (L112-L114)
theorem Lex.acc_zero (hbot : ∀ ⦃i a⦄, ¬s i a 0) : Acc (DFinsupp.Lex r s) 0
```

```lean
theorem Pi.Lex.wellFounded [IsStrictTotalOrder ι r] [Finite ι] (hs : ∀ i, WellFounded (s i)) :
    WellFounded (Pi.Lex r (fun {i} ↦ s i)) := by
obtain h | ⟨⟨x⟩⟩ := isEmpty_or_nonempty (∀ i, α i)
  · convert emptyWf.wf
  letI : ∀ i, Zero (α i) := fun i => ⟨(hs i).min ⊤ ⟨x i, trivial⟩⟩
  haveI := IsTrans.swap r; haveI := Std.Irrefl.swap r; haveI := Fintype.ofFinite ι
  refine InvImage.wf equivFunOnFintype.symm (Lex.wellFounded' (fun i a => ?_) hs ?_)
  exacts [(hs i).not_lt_min ⊤ trivial, Finite.wellFounded_of_trans_of_irrefl (Function.swap r)]
```

## Edit instruction
Edit `Pi` so it still compiles and the proof is simplified where possible. Return the full updated `Pi` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.SupClosed).

[User]
You are editing a file in `Mathlib/Order/SupClosed.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.SupClosed.latticeClosure_min`, L437-L439)
Open namespaces: Set, Finset, OrderDual

## Surrounding context in Mathlib/Order/SupClosed.lean
```lean
-- Mathlib.Order.SupClosed.SupClosed (L47-L48)
def SupClosed (s : Set α) : Prop

-- Mathlib.Order.SupClosed.SupClosed (L53-L55)
lemma SupClosed.inter (hs : SupClosed s) (ht : SupClosed t) : SupClosed (s ∩ t)

-- Mathlib.Order.SupClosed.supClosed_sInter (L56-L58)
lemma supClosed_sInter (hS : ∀ s ∈ S, SupClosed s) : SupClosed (⋂₀ S)
```

```lean
lemma latticeClosure_min : s ⊆ t → IsSublattice t → latticeClosure s ⊆ t := latticeClosure.closure_min
```

## Edit instruction
Edit `latticeClosure_min` so it still compiles and the proof is simplified where possible. Return the full updated `latticeClosure_min` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.SupClosed).

You are editing a file in `Mathlib/Order/SupClosed.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.SupClosed.latticeClosure_min`, L437-L439)
Open namespaces: Set, Finset, OrderDual

## Surrounding context in Mathlib/Order/SupClosed.lean
```lean
-- Mathlib.Order.SupClosed.SupClosed (L47-L48)
def SupClosed (s : Set α) : Prop

-- Mathlib.Order.SupClosed.SupClosed (L53-L55)
lemma SupClosed.inter (hs : SupClosed s) (ht : SupClosed t) : SupClosed (s ∩ t)

-- Mathlib.Order.SupClosed.supClosed_sInter (L56-L58)
lemma supClosed_sInter (hS : ∀ s ∈ S, SupClosed s) : SupClosed (⋂₀ S)
```

```lean
lemma latticeClosure_min : s ⊆ t → IsSublattice t → latticeClosure s ⊆ t := latticeClosure.closure_min
```

## Edit instruction
Edit `latticeClosure_min` so it still compiles and the proof is simplified where possible. Return the full updated `latticeClosure_min` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Finset.Max).

[User]
You are editing a file in `Mathlib/Data/Finset/Max.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Finset.Max.exists_next_left`, L409-L413)
Open namespaces: Function, Multiset, OrderDual

## Surrounding context in Mathlib/Data/Finset/Max.lean
```lean
-- Mathlib.Data.Finset.Max.max_eq_sup_coe (L37-L39)
theorem max_eq_sup_coe {s : Finset α} : s.max = s.sup (↑)

-- Mathlib.Data.Finset.Max.max_eq_sup_withBot (L40-L42)
theorem max_eq_sup_withBot (s : Finset α) : s.max = sup s (↑)

-- Mathlib.Data.Finset.Max.max_empty (L44-L46)
theorem max_empty : (∅ : Finset α).max = ⊥
```

```lean
theorem exists_next_left {x : α} {s : Finset α} (h : ∃ y ∈ s, y < x) :
    ∃ y ∈ s, y < x ∧ ∀ z ∈ s, z < x → z ≤ y := @exists_next_right αᵒᵈ _ x s h

/-- If finsets `s` and `t` are interleaved, then `Finset.card s ≤ Finset.card t + 1`. -/
```

## Edit instruction
Edit `exists_next_left` so it still compiles and the proof is simplified where possible. Return the full updated `exists_next_left` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Finset.Max).

You are editing a file in `Mathlib/Data/Finset/Max.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Finset.Max.exists_next_left`, L409-L413)
Open namespaces: Function, Multiset, OrderDual

## Surrounding context in Mathlib/Data/Finset/Max.lean
```lean
-- Mathlib.Data.Finset.Max.max_eq_sup_coe (L37-L39)
theorem max_eq_sup_coe {s : Finset α} : s.max = s.sup (↑)

-- Mathlib.Data.Finset.Max.max_eq_sup_withBot (L40-L42)
theorem max_eq_sup_withBot (s : Finset α) : s.max = sup s (↑)

-- Mathlib.Data.Finset.Max.max_empty (L44-L46)
theorem max_empty : (∅ : Finset α).max = ⊥
```

```lean
theorem exists_next_left {x : α} {s : Finset α} (h : ∃ y ∈ s, y < x) :
    ∃ y ∈ s, y < x ∧ ∀ z ∈ s, z < x → z ≤ y := @exists_next_right αᵒᵈ _ x s h

/-- If finsets `s` and `t` are interleaved, then `Finset.card s ≤ Finset.card t + 1`. -/
```

## Edit instruction
Edit `exists_next_left` so it still compiles and the proof is simplified where possible. Return the full updated `exists_next_left` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.Group.Pointwise.Finset.Basic).

[User]
You are editing a file in `Mathlib/Algebra/Group/Pointwise/Finset/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Group.Pointwise.Finset.Basic.image_one`, L110-L112)
Open namespaces: Function, MulOpposite, scoped, Pointwise

## Surrounding context in Mathlib/Algebra/Group/Pointwise/Finset/Basic.lean
```lean
-- Mathlib.Algebra.Group.Pointwise.Finset.Basic.mem_one (L77-L79)
theorem mem_one : a ∈ (1 : Finset α) ↔ a = 1

-- Mathlib.Algebra.Group.Pointwise.Finset.Basic.coe_one (L81-L83)
theorem coe_one : ↑(1 : Finset α) = (1 : Set α)

-- Mathlib.Algebra.Group.Pointwise.Finset.Basic.coe_eq_one (L85-L86)
lemma coe_eq_one : (s : Set α) = 1 ↔ s = 1
```

```lean
theorem image_one [DecidableEq β] {f : α → β} : image f 1 = {f 1} := image_singleton _ _
```

## Edit instruction
Edit `image_one` so it still compiles and the proof is simplified where possible. Return the full updated `image_one` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.Group.Pointwise.Finset.Basic).

You are editing a file in `Mathlib/Algebra/Group/Pointwise/Finset/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Group.Pointwise.Finset.Basic.image_one`, L110-L112)
Open namespaces: Function, MulOpposite, scoped, Pointwise

## Surrounding context in Mathlib/Algebra/Group/Pointwise/Finset/Basic.lean
```lean
-- Mathlib.Algebra.Group.Pointwise.Finset.Basic.mem_one (L77-L79)
theorem mem_one : a ∈ (1 : Finset α) ↔ a = 1

-- Mathlib.Algebra.Group.Pointwise.Finset.Basic.coe_one (L81-L83)
theorem coe_one : ↑(1 : Finset α) = (1 : Set α)

-- Mathlib.Algebra.Group.Pointwise.Finset.Basic.coe_eq_one (L85-L86)
lemma coe_eq_one : (s : Set α) = 1 ↔ s = 1
```

```lean
theorem image_one [DecidableEq β] {f : α → β} : image f 1 = {f 1} := image_singleton _ _
```

## Edit instruction
Edit `image_one` so it still compiles and the proof is simplified where possible. Return the full updated `image_one` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.EMetricSpace.Lipschitz).

[User]
You are editing a file in `Mathlib/Topology/EMetricSpace/Lipschitz.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Topology.EMetricSpace.Lipschitz.continuousOn_prod_of_continuousOn_lipschitzOnWith'`, L510-L517)
Open namespaces: Filter, Function, Set, Topology, NNReal, ENNReal, Bornology, Metric

## Surrounding context in Mathlib/Topology/EMetricSpace/Lipschitz.lean
```lean
-- Mathlib.Topology.EMetricSpace.Lipschitz.LipschitzWith (L58-L61)
def LipschitzWith (K : ℝ≥0) (f : α → β)

-- Mathlib.Topology.EMetricSpace.Lipschitz.LipschitzOnWith (L62-L66)
def LipschitzOnWith (K : ℝ≥0) (f : α → β) (s : Set α)

-- Mathlib.Topology.EMetricSpace.Lipschitz.LocallyLipschitz (L67-L70)
def LocallyLipschitz (f : α → β) : Prop
```

```lean
theorem continuousOn_prod_of_continuousOn_lipschitzOnWith' [TopologicalSpace α]
    [PseudoEMetricSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) {s : Set α} {t : Set β} (K : ℝ≥0)
    (ha : ∀ a ∈ s, LipschitzOnWith K (fun y => f (a, y)) t)
    (hb : ∀ b ∈ t, ContinuousOn (fun x => f (x, b)) s) : ContinuousOn f (s ×ˢ t) := have : ContinuousOn (f ∘ Prod.swap) (t ×ˢ s) :=
    continuousOn_prod_of_continuousOn_lipschitzOnWith _ K hb ha
  this.comp continuous_swap.continuousOn (mapsTo_swap_prod _ _)
```

## Edit instruction
Edit `continuousOn_prod_of_continuousOn_lipschitzOnWith'` so it still compiles and the proof is simplified where possible. Return the full updated `continuousOn_prod_of_continuousOn_lipschitzOnWith'` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.EMetricSpace.Lipschitz).

You are editing a file in `Mathlib/Topology/EMetricSpace/Lipschitz.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Topology.EMetricSpace.Lipschitz.continuousOn_prod_of_continuousOn_lipschitzOnWith'`, L510-L517)
Open namespaces: Filter, Function, Set, Topology, NNReal, ENNReal, Bornology, Metric

## Surrounding context in Mathlib/Topology/EMetricSpace/Lipschitz.lean
```lean
-- Mathlib.Topology.EMetricSpace.Lipschitz.LipschitzWith (L58-L61)
def LipschitzWith (K : ℝ≥0) (f : α → β)

-- Mathlib.Topology.EMetricSpace.Lipschitz.LipschitzOnWith (L62-L66)
def LipschitzOnWith (K : ℝ≥0) (f : α → β) (s : Set α)

-- Mathlib.Topology.EMetricSpace.Lipschitz.LocallyLipschitz (L67-L70)
def LocallyLipschitz (f : α → β) : Prop
```

```lean
theorem continuousOn_prod_of_continuousOn_lipschitzOnWith' [TopologicalSpace α]
    [PseudoEMetricSpace β] [PseudoEMetricSpace γ] (f : α × β → γ) {s : Set α} {t : Set β} (K : ℝ≥0)
    (ha : ∀ a ∈ s, LipschitzOnWith K (fun y => f (a, y)) t)
    (hb : ∀ b ∈ t, ContinuousOn (fun x => f (x, b)) s) : ContinuousOn f (s ×ˢ t) := have : ContinuousOn (f ∘ Prod.swap) (t ×ˢ s) :=
    continuousOn_prod_of_continuousOn_lipschitzOnWith _ K hb ha
  this.comp continuous_swap.continuousOn (mapsTo_swap_prod _ _)
```

## Edit instruction
Edit `continuousOn_prod_of_continuousOn_lipschitzOnWith'` so it still compiles and the proof is simplified where possible. Return the full updated `continuousOn_prod_of_continuousOn_lipschitzOnWith'` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.KrullDimension).

[User]
You are editing a file in `Mathlib/Order/KrullDimension.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.KrullDimension.krullDim_eq_iSup_height_add_coheight_of_nonempty`, L800-L827)
## Surrounding context in Mathlib/Order/KrullDimension.lean
```lean
-- Mathlib.Order.KrullDimension.coheight_eq (L126-L131)
lemma coheight_eq (a : α) :
    coheight a = ⨆ (p : LTSeries α) (_ : a ≤ p.head), (p.length : ℕ∞)

-- Mathlib.Order.KrullDimension.height_le_iff (L132-L135)
lemma height_le_iff {a : α} {n : ℕ∞} :
    height a ≤ n ↔ ∀ ⦃p : LTSeries α⦄, p.last ≤ a → p.length ≤ n

-- Mathlib.Order.KrullDimension.coheight_le_iff (L136-L139)
lemma coheight_le_iff {a : α} {n : ℕ∞} :
    coheight a ≤ n ↔ ∀ ⦃p : LTSeries α⦄, a ≤ p.head → p.length ≤ n
```

Relevant lemmas available in scope: `le_antisymm`, `ciSup_mono`, `iSup_le`, `a`, `le_iSup_of_le`

```lean
lemma krullDim_eq_iSup_height_add_coheight_of_nonempty [Nonempty α] :
    krullDim α = ↑(⨆ (a : α), height a + coheight a) := by
apply le_antisymm
  · rw [krullDim_eq_iSup_height_of_nonempty, WithBot.coe_le_coe]
    apply ciSup_mono (by bddDefault) (by simp)
  · wlog hnottop : krullDim α < ⊤
    · simp_all
    rw [krullDim_eq_iSup_length, WithBot.coe_le_coe]
    apply iSup_le
    intro a
    have : height a < ⊤ := WithBot.coe_lt_coe.mp (lt_of_le_of_lt (height_le_krullDim a) hnottop)
    have : coheight a < ⊤ := WithBot.coe_lt_coe.mp (lt_of_le_of_lt (coheight_le_krullDim a) hnottop)
    cases hh : height a with
    | top => simp_all
    | coe n =>
      cases hch : coheight a with
      | top => simp_all
      | coe m =>
        obtain ⟨p₁, hlast, hlen₁⟩ := exists_series_of_height_eq_coe a hh
        obtain ⟨p₂, hhead, hlen₂⟩ := exists_series_of_coheight_eq_coe a hch
        apply le_iSup_of_le ((p₁.smash p₂) (by simp [*])) (by simp [*])

/--
The Krull dimension is the supremum of the elements' heights.

If `α` is `Nonempty`, then `krullDim_eq_iSup_height_of_nonempty`, with the coercion from
`ℕ∞` to `WithBot ℕ∞` outside the supremum, can be more convenient.
-/
```

## Edit instruction
Edit `krullDim_eq_iSup_height_add_coheight_of_nonempty` so it still compiles and the proof is simplified where possible. Return the full updated `krullDim_eq_iSup_height_add_coheight_of_nonempty` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Order.KrullDimension).

You are editing a file in `Mathlib/Order/KrullDimension.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Order.KrullDimension.krullDim_eq_iSup_height_add_coheight_of_nonempty`, L800-L827)
## Surrounding context in Mathlib/Order/KrullDimension.lean
```lean
-- Mathlib.Order.KrullDimension.coheight_eq (L126-L131)
lemma coheight_eq (a : α) :
    coheight a = ⨆ (p : LTSeries α) (_ : a ≤ p.head), (p.length : ℕ∞)

-- Mathlib.Order.KrullDimension.height_le_iff (L132-L135)
lemma height_le_iff {a : α} {n : ℕ∞} :
    height a ≤ n ↔ ∀ ⦃p : LTSeries α⦄, p.last ≤ a → p.length ≤ n

-- Mathlib.Order.KrullDimension.coheight_le_iff (L136-L139)
lemma coheight_le_iff {a : α} {n : ℕ∞} :
    coheight a ≤ n ↔ ∀ ⦃p : LTSeries α⦄, a ≤ p.head → p.length ≤ n
```

Relevant lemmas available in scope: `le_antisymm`, `ciSup_mono`, `iSup_le`, `a`, `le_iSup_of_le`

```lean
lemma krullDim_eq_iSup_height_add_coheight_of_nonempty [Nonempty α] :
    krullDim α = ↑(⨆ (a : α), height a + coheight a) := by
apply le_antisymm
  · rw [krullDim_eq_iSup_height_of_nonempty, WithBot.coe_le_coe]
    apply ciSup_mono (by bddDefault) (by simp)
  · wlog hnottop : krullDim α < ⊤
    · simp_all
    rw [krullDim_eq_iSup_length, WithBot.coe_le_coe]
    apply iSup_le
    intro a
    have : height a < ⊤ := WithBot.coe_lt_coe.mp (lt_of_le_of_lt (height_le_krullDim a) hnottop)
    have : coheight a < ⊤ := WithBot.coe_lt_coe.mp (lt_of_le_of_lt (coheight_le_krullDim a) hnottop)
    cases hh : height a with
    | top => simp_all
    | coe n =>
      cases hch : coheight a with
      | top => simp_all
      | coe m =>
        obtain ⟨p₁, hlast, hlen₁⟩ := exists_series_of_height_eq_coe a hh
        obtain ⟨p₂, hhead, hlen₂⟩ := exists_series_of_coheight_eq_coe a hch
        apply le_iSup_of_le ((p₁.smash p₂) (by simp [*])) (by simp [*])

/--
The Krull dimension is the supremum of the elements' heights.

If `α` is `Nonempty`, then `krullDim_eq_iSup_height_of_nonempty`, with the coercion from
`ℕ∞` to `WithBot ℕ∞` outside the supremum, can be more convenient.
-/
```

## Edit instruction
Edit `krullDim_eq_iSup_height_add_coheight_of_nonempty` so it still compiles and the proof is simplified where possible. Return the full updated `krullDim_eq_iSup_height_add_coheight_of_nonempty` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.NumberTheory.NumberField.Basic).

[User]
You are editing a file in `Mathlib/NumberTheory/NumberField/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.NumberTheory.NumberField.Basic.minpoly_coe`, L265-L268)
Open namespaces: Function, Module, scoped, nonZeroDivisors

## Surrounding context in Mathlib/NumberTheory/NumberField/Basic.lean
```lean
-- Mathlib.NumberTheory.NumberField.Basic.Int (L51-L59)
theorem Int.not_isField : ¬IsField ℤ

-- Mathlib.NumberTheory.NumberField.Basic.of_module_finite (L69-L75)
theorem of_module_finite [NumberField K] [Algebra K L] [Module.Finite K L] : NumberField L where
  to_charZero

-- Mathlib.NumberTheory.NumberField.Basic.of_intermediateField (L76-L80)
instance of_intermediateField [NumberField K] [NumberField L] [Algebra K L]
    (E : IntermediateField K L) : NumberField E
```

```lean
theorem minpoly_coe (x : 𝓞 K) :
    minpoly ℤ (x : K) = minpoly ℤ x := minpoly.algebraMap_eq RingOfIntegers.coe_injective x
```

## Edit instruction
Edit `minpoly_coe` so it still compiles and the proof is simplified where possible. Return the full updated `minpoly_coe` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.NumberTheory.NumberField.Basic).

You are editing a file in `Mathlib/NumberTheory/NumberField/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.NumberTheory.NumberField.Basic.minpoly_coe`, L265-L268)
Open namespaces: Function, Module, scoped, nonZeroDivisors

## Surrounding context in Mathlib/NumberTheory/NumberField/Basic.lean
```lean
-- Mathlib.NumberTheory.NumberField.Basic.Int (L51-L59)
theorem Int.not_isField : ¬IsField ℤ

-- Mathlib.NumberTheory.NumberField.Basic.of_module_finite (L69-L75)
theorem of_module_finite [NumberField K] [Algebra K L] [Module.Finite K L] : NumberField L where
  to_charZero

-- Mathlib.NumberTheory.NumberField.Basic.of_intermediateField (L76-L80)
instance of_intermediateField [NumberField K] [NumberField L] [Algebra K L]
    (E : IntermediateField K L) : NumberField E
```

```lean
theorem minpoly_coe (x : 𝓞 K) :
    minpoly ℤ (x : K) = minpoly ℤ x := minpoly.algebraMap_eq RingOfIntegers.coe_injective x
```

## Edit instruction
Edit `minpoly_coe` so it still compiles and the proof is simplified where possible. Return the full updated `minpoly_coe` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.Analytic.CPolynomialDef).

[User]
You are editing a file in `Mathlib/Analysis/Analytic/CPolynomialDef.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesOnBall`, L437-L453)
Open namespaces: scoped, Topology, Set, Filter, Asymptotics, NNReal, ENNReal

## Surrounding context in Mathlib/Analysis/Analytic/CPolynomialDef.lean
```lean
-- Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesAt (L79-L81)
def HasFiniteFPowerSeriesAt (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E) (n : ℕ)

-- Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesAt (L82-L86)
theorem HasFiniteFPowerSeriesAt.hasFPowerSeriesAt
    (hf : HasFiniteFPowerSeriesAt f p x n) : HasFPowerSeriesAt f p x

-- Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesAt (L87-L93)
theorem HasFiniteFPowerSeriesAt.finite (hf : HasFiniteFPowerSeriesAt f p x n) :
    ∀ m : ℕ, n ≤ m → p m = 0
```

```lean
theorem HasFiniteFPowerSeriesOnBall.changeOrigin (hf : HasFiniteFPowerSeriesOnBall f p x n r)
    (h : (‖y‖₊ : ℝ≥0∞) < r) :
    HasFiniteFPowerSeriesOnBall f (p.changeOrigin y) (x + y) n (r - ‖y‖₊) where
  r_le := (tsub_le_tsub_right hf.r_le _).trans p.changeOrigin_radius
r_pos := by simp [h]
  finite _ hm := p.changeOrigin_finite_of_finite hf.finite hm
  hasSum {z} hz := by
    have : f (x + y + z) =
        FormalMultilinearSeries.sum (FormalMultilinearSeries.changeOrigin p y) z := by
      rw [mem_eball_zero_iff, lt_tsub_iff_right, add_comm] at hz
      rw [p.changeOrigin_eval_of_finite hf.finite, add_assoc, hf.sum]
      exact mem_eball_zero_iff.2 ((enorm_add_le _ _).trans_lt hz)
    rw [this]
    apply (p.changeOrigin y).hasSum_of_finite fun _ => p.changeOrigin_finite_of_finite hf.finite

/-- If a function admits a finite power series expansion `p` on an open ball `B (x, r)`, then
it is continuously polynomial at every point of this ball. -/
```

## Edit instruction
Edit `HasFiniteFPowerSeriesOnBall` so it still compiles and the proof is simplified where possible. Return the full updated `HasFiniteFPowerSeriesOnBall` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.Analytic.CPolynomialDef).

You are editing a file in `Mathlib/Analysis/Analytic/CPolynomialDef.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesOnBall`, L437-L453)
Open namespaces: scoped, Topology, Set, Filter, Asymptotics, NNReal, ENNReal

## Surrounding context in Mathlib/Analysis/Analytic/CPolynomialDef.lean
```lean
-- Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesAt (L79-L81)
def HasFiniteFPowerSeriesAt (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E) (n : ℕ)

-- Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesAt (L82-L86)
theorem HasFiniteFPowerSeriesAt.hasFPowerSeriesAt
    (hf : HasFiniteFPowerSeriesAt f p x n) : HasFPowerSeriesAt f p x

-- Mathlib.Analysis.Analytic.CPolynomialDef.HasFiniteFPowerSeriesAt (L87-L93)
theorem HasFiniteFPowerSeriesAt.finite (hf : HasFiniteFPowerSeriesAt f p x n) :
    ∀ m : ℕ, n ≤ m → p m = 0
```

```lean
theorem HasFiniteFPowerSeriesOnBall.changeOrigin (hf : HasFiniteFPowerSeriesOnBall f p x n r)
    (h : (‖y‖₊ : ℝ≥0∞) < r) :
    HasFiniteFPowerSeriesOnBall f (p.changeOrigin y) (x + y) n (r - ‖y‖₊) where
  r_le := (tsub_le_tsub_right hf.r_le _).trans p.changeOrigin_radius
r_pos := by simp [h]
  finite _ hm := p.changeOrigin_finite_of_finite hf.finite hm
  hasSum {z} hz := by
    have : f (x + y + z) =
        FormalMultilinearSeries.sum (FormalMultilinearSeries.changeOrigin p y) z := by
      rw [mem_eball_zero_iff, lt_tsub_iff_right, add_comm] at hz
      rw [p.changeOrigin_eval_of_finite hf.finite, add_assoc, hf.sum]
      exact mem_eball_zero_iff.2 ((enorm_add_le _ _).trans_lt hz)
    rw [this]
    apply (p.changeOrigin y).hasSum_of_finite fun _ => p.changeOrigin_finite_of_finite hf.finite

/-- If a function admits a finite power series expansion `p` on an open ball `B (x, r)`, then
it is continuously polynomial at every point of this ball. -/
```

## Edit instruction
Edit `HasFiniteFPowerSeriesOnBall` so it still compiles and the proof is simplified where possible. Return the full updated `HasFiniteFPowerSeriesOnBall` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.QuadraticForm.Basic).

[User]
You are editing a file in `Mathlib/LinearAlgebra/QuadraticForm/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.LinearAlgebra.QuadraticForm.Basic.isOrtho_comm`, L1060-L1063)
Open namespaces: LinearMap, (BilinMap, BilinForm), QuadraticMap, (BilinMap), in

## Surrounding context in Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
```lean
-- Mathlib.LinearAlgebra.QuadraticForm.Basic.polar (L99-L106)
def polar (f : M → N) (x y : M)

-- Mathlib.LinearAlgebra.QuadraticForm.Basic.polar_add (L107-L110)
theorem polar_add (f g : M → N) (x y : M) : polar (f + g) x y = polar f x y + polar g x y

-- Mathlib.LinearAlgebra.QuadraticForm.Basic.polar_neg (L111-L113)
theorem polar_neg (f : M → N) (x y : M) : polar (-f) x y = -polar f x y
```

```lean
theorem isOrtho_comm {x y : M} : IsOrtho Q x y ↔ IsOrtho Q y x := by simp_rw [isOrtho_def, add_comm]
alias ⟨IsOrtho.symm, _⟩ := isOrtho_comm
```

## Edit instruction
Edit `isOrtho_comm` so it still compiles and the proof is simplified where possible. Return the full updated `isOrtho_comm` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.QuadraticForm.Basic).

You are editing a file in `Mathlib/LinearAlgebra/QuadraticForm/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.LinearAlgebra.QuadraticForm.Basic.isOrtho_comm`, L1060-L1063)
Open namespaces: LinearMap, (BilinMap, BilinForm), QuadraticMap, (BilinMap), in

## Surrounding context in Mathlib/LinearAlgebra/QuadraticForm/Basic.lean
```lean
-- Mathlib.LinearAlgebra.QuadraticForm.Basic.polar (L99-L106)
def polar (f : M → N) (x y : M)

-- Mathlib.LinearAlgebra.QuadraticForm.Basic.polar_add (L107-L110)
theorem polar_add (f g : M → N) (x y : M) : polar (f + g) x y = polar f x y + polar g x y

-- Mathlib.LinearAlgebra.QuadraticForm.Basic.polar_neg (L111-L113)
theorem polar_neg (f : M → N) (x y : M) : polar (-f) x y = -polar f x y
```

```lean
theorem isOrtho_comm {x y : M} : IsOrtho Q x y ↔ IsOrtho Q y x := by simp_rw [isOrtho_def, add_comm]
alias ⟨IsOrtho.symm, _⟩ := isOrtho_comm
```

## Edit instruction
Edit `isOrtho_comm` so it still compiles and the proof is simplified where possible. Return the full updated `isOrtho_comm` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.CliffordAlgebra.Even).

[User]
You are editing a file in `Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.LinearAlgebra.CliffordAlgebra.Even.even_toSubmodule`, L59-L64)
Open namespaces: scoped, DirectSum

## Surrounding context in Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean
```lean
-- Mathlib.LinearAlgebra.CliffordAlgebra.Even.even (L54-L57)
def even : Subalgebra R (CliffordAlgebra Q)

-- Mathlib.LinearAlgebra.CliffordAlgebra.Even.EvenHom (L75-L98)
def EvenHom.compr₂ (g : EvenHom Q A) (f : A →ₐ[R] B) : EvenHom Q B where
  bilin

-- Mathlib.LinearAlgebra.CliffordAlgebra.Even.even (L108-L163)
theorem even.algHom_ext ⦃f g : even Q →ₐ[R] A⦄ (h : (even.ι Q).compr₂ f = (even.ι Q).compr₂ g) :
    f = g
```

```lean
theorem even_toSubmodule : Subalgebra.toSubmodule (even Q) = evenOdd Q 0 := rfl

variable (A)

/-- The type of bilinear maps which are accepted by `CliffordAlgebra.even.lift`. -/
```

## Edit instruction
Edit `even_toSubmodule` so it still compiles and the proof is simplified where possible. Return the full updated `even_toSubmodule` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.CliffordAlgebra.Even).

You are editing a file in `Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.LinearAlgebra.CliffordAlgebra.Even.even_toSubmodule`, L59-L64)
Open namespaces: scoped, DirectSum

## Surrounding context in Mathlib/LinearAlgebra/CliffordAlgebra/Even.lean
```lean
-- Mathlib.LinearAlgebra.CliffordAlgebra.Even.even (L54-L57)
def even : Subalgebra R (CliffordAlgebra Q)

-- Mathlib.LinearAlgebra.CliffordAlgebra.Even.EvenHom (L75-L98)
def EvenHom.compr₂ (g : EvenHom Q A) (f : A →ₐ[R] B) : EvenHom Q B where
  bilin

-- Mathlib.LinearAlgebra.CliffordAlgebra.Even.even (L108-L163)
theorem even.algHom_ext ⦃f g : even Q →ₐ[R] A⦄ (h : (even.ι Q).compr₂ f = (even.ι Q).compr₂ g) :
    f = g
```

```lean
theorem even_toSubmodule : Subalgebra.toSubmodule (even Q) = evenOdd Q 0 := rfl

variable (A)

/-- The type of bilinear maps which are accepted by `CliffordAlgebra.even.lift`. -/
```

## Edit instruction
Edit `even_toSubmodule` so it still compiles and the proof is simplified where possible. Return the full updated `even_toSubmodule` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.List.Sort).

[User]
You are editing a file in `Mathlib/Data/List/Sort.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.List.Sort.sortedGT_iff_isChain`, L461-L470)
## Imports
```lean
import all Init.Data.List.Sort.Basic  -- for exposing `mergeSort`
```

## Surrounding context in Mathlib/Data/List/Sort.lean
```lean
-- Mathlib.Data.List.Sort.orderedInsert (L45-L48)
def orderedInsert (a : α) : List α → List α
  | [] => [a]
  | b :: l => if a ≼ b then a :: b :: l else b :: orderedInsert a l

-- Mathlib.Data.List.Sort.orderedInsert_cons_of_le (L55-L58)
theorem orderedInsert_cons_of_le {a b : α} (l : List α) (h : a ≼ b) :
    orderedInsert r a (b :: l) = a :: b :: l

-- Mathlib.Data.List.Sort.orderedInsert_of_not_le (L61-L64)
theorem orderedInsert_of_not_le {a b : α} (l : List α) (h : ¬ a ≼ b) :
    orderedInsert r a (b :: l) = b :: orderedInsert r a l
```

```lean
theorem sortedGT_iff_isChain : l.SortedGT ↔ IsChain (· > ·) l := sortedGT_iff_pairwise.trans isChain_iff_pairwise.symm

protected alias ⟨SortedLE.isChain, IsChain.sortedLE⟩ := sortedLE_iff_isChain
protected alias ⟨SortedGE.isChain, IsChain.sortedGE⟩ := sortedGE_iff_isChain
protected alias ⟨SortedLT.isChain, IsChain.sortedLT⟩ := sortedLT_iff_isChain
protected alias ⟨SortedGT.isChain, IsChain.sortedGT⟩ := sortedGT_iff_isChain

section Decidable
```

## Edit instruction
Edit `sortedGT_iff_isChain` so it still compiles and the proof is simplified where possible. Return the full updated `sortedGT_iff_isChain` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.List.Sort).

You are editing a file in `Mathlib/Data/List/Sort.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.List.Sort.sortedGT_iff_isChain`, L461-L470)
## Imports
```lean
import all Init.Data.List.Sort.Basic  -- for exposing `mergeSort`
```

## Surrounding context in Mathlib/Data/List/Sort.lean
```lean
-- Mathlib.Data.List.Sort.orderedInsert (L45-L48)
def orderedInsert (a : α) : List α → List α
  | [] => [a]
  | b :: l => if a ≼ b then a :: b :: l else b :: orderedInsert a l

-- Mathlib.Data.List.Sort.orderedInsert_cons_of_le (L55-L58)
theorem orderedInsert_cons_of_le {a b : α} (l : List α) (h : a ≼ b) :
    orderedInsert r a (b :: l) = a :: b :: l

-- Mathlib.Data.List.Sort.orderedInsert_of_not_le (L61-L64)
theorem orderedInsert_of_not_le {a b : α} (l : List α) (h : ¬ a ≼ b) :
    orderedInsert r a (b :: l) = b :: orderedInsert r a l
```

```lean
theorem sortedGT_iff_isChain : l.SortedGT ↔ IsChain (· > ·) l := sortedGT_iff_pairwise.trans isChain_iff_pairwise.symm

protected alias ⟨SortedLE.isChain, IsChain.sortedLE⟩ := sortedLE_iff_isChain
protected alias ⟨SortedGE.isChain, IsChain.sortedGE⟩ := sortedGE_iff_isChain
protected alias ⟨SortedLT.isChain, IsChain.sortedLT⟩ := sortedLT_iff_isChain
protected alias ⟨SortedGT.isChain, IsChain.sortedGT⟩ := sortedGT_iff_isChain

section Decidable
```

## Edit instruction
Edit `sortedGT_iff_isChain` so it still compiles and the proof is simplified where possible. Return the full updated `sortedGT_iff_isChain` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.MvPolynomial.Eval).

[User]
You are editing a file in `Mathlib/Algebra/MvPolynomial/Eval.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.MvPolynomial.Eval.aeval_X_left_apply`, L634-L636)
Open namespaces: Set, Function, Finsupp, AddMonoidAlgebra, scoped, Pointwise

## Surrounding context in Mathlib/Algebra/MvPolynomial/Eval.lean
```lean
-- Mathlib.Algebra.MvPolynomial.Eval.eval₂ (L69-L71)
def eval₂ (p : MvPolynomial σ R) : S₁

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq (L72-L75)
theorem eval₂_eq (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i ∈ d.support, X i ^ d i

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq' (L76-L80)
theorem eval₂_eq' [Fintype σ] (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i, X i ^ d i
```

```lean
theorem aeval_X_left_apply (p : MvPolynomial σ R) : aeval X p = p := AlgHom.congr_fun aeval_X_left p
```

## Edit instruction
Edit `aeval_X_left_apply` so it still compiles and the proof is simplified where possible. Return the full updated `aeval_X_left_apply` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.MvPolynomial.Eval).

You are editing a file in `Mathlib/Algebra/MvPolynomial/Eval.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.MvPolynomial.Eval.aeval_X_left_apply`, L634-L636)
Open namespaces: Set, Function, Finsupp, AddMonoidAlgebra, scoped, Pointwise

## Surrounding context in Mathlib/Algebra/MvPolynomial/Eval.lean
```lean
-- Mathlib.Algebra.MvPolynomial.Eval.eval₂ (L69-L71)
def eval₂ (p : MvPolynomial σ R) : S₁

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq (L72-L75)
theorem eval₂_eq (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i ∈ d.support, X i ^ d i

-- Mathlib.Algebra.MvPolynomial.Eval.eval₂_eq' (L76-L80)
theorem eval₂_eq' [Fintype σ] (g : R →+* S₁) (X : σ → S₁) (f : MvPolynomial σ R) :
    f.eval₂ g X = ∑ d ∈ f.support, g (f.coeff d) * ∏ i, X i ^ d i
```

```lean
theorem aeval_X_left_apply (p : MvPolynomial σ R) : aeval X p = p := AlgHom.congr_fun aeval_X_left p
```

## Edit instruction
Edit `aeval_X_left_apply` so it still compiles and the proof is simplified where possible. Return the full updated `aeval_X_left_apply` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.Matrix.PosDef).

[User]
You are editing a file in `Mathlib/LinearAlgebra/Matrix/PosDef.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.LinearAlgebra.Matrix.PosDef.of_dotProduct_mulVec_nonneg`, L301-L305)
Open namespaces: Matrix

## Surrounding context in Mathlib/LinearAlgebra/Matrix/PosDef.lean
```lean
-- Mathlib.LinearAlgebra.Matrix.PosDef.PosSemidef (L58-L69)
def PosSemidef (M : Matrix n n R) : Prop

-- Mathlib.LinearAlgebra.Matrix.PosDef.isHermitian (L76-L78)
theorem isHermitian {M : Matrix n n R} (hM : M.PosSemidef) : M.IsHermitian

-- Mathlib.LinearAlgebra.Matrix.PosDef.submatrix (L79-L83)
theorem submatrix {M : Matrix n n R} (hM : M.PosSemidef) (e : m → n) :
    (M.submatrix e e).PosSemidef
```

```lean
lemma of_dotProduct_mulVec_nonneg {M : Matrix n n R} (hM1 : M.IsHermitian)
    (hM2 : ∀ x, 0 ≤ star x ⬝ᵥ (M *ᵥ x)) : M.PosSemidef := posSemidef_iff_dotProduct_mulVec.mpr ⟨hM1, hM2⟩

omit [Fintype m] in variable [Finite m] in
```

## Edit instruction
Edit `of_dotProduct_mulVec_nonneg` so it still compiles and the proof is simplified where possible. Return the full updated `of_dotProduct_mulVec_nonneg` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.Matrix.PosDef).

You are editing a file in `Mathlib/LinearAlgebra/Matrix/PosDef.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.LinearAlgebra.Matrix.PosDef.of_dotProduct_mulVec_nonneg`, L301-L305)
Open namespaces: Matrix

## Surrounding context in Mathlib/LinearAlgebra/Matrix/PosDef.lean
```lean
-- Mathlib.LinearAlgebra.Matrix.PosDef.PosSemidef (L58-L69)
def PosSemidef (M : Matrix n n R) : Prop

-- Mathlib.LinearAlgebra.Matrix.PosDef.isHermitian (L76-L78)
theorem isHermitian {M : Matrix n n R} (hM : M.PosSemidef) : M.IsHermitian

-- Mathlib.LinearAlgebra.Matrix.PosDef.submatrix (L79-L83)
theorem submatrix {M : Matrix n n R} (hM : M.PosSemidef) (e : m → n) :
    (M.submatrix e e).PosSemidef
```

```lean
lemma of_dotProduct_mulVec_nonneg {M : Matrix n n R} (hM1 : M.IsHermitian)
    (hM2 : ∀ x, 0 ≤ star x ⬝ᵥ (M *ᵥ x)) : M.PosSemidef := posSemidef_iff_dotProduct_mulVec.mpr ⟨hM1, hM2⟩

omit [Fintype m] in variable [Finite m] in
```

## Edit instruction
Edit `of_dotProduct_mulVec_nonneg` so it still compiles and the proof is simplified where possible. Return the full updated `of_dotProduct_mulVec_nonneg` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.Field.IsField).

[User]
You are editing a file in `Mathlib/Algebra/Field/IsField.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Field.IsField.IsField`, L51-L53)
```lean
theorem IsField.nontrivial {R : Type u} [Semiring R] (h : IsField R) : Nontrivial R := ⟨h.exists_pair_ne⟩
```

## Edit instruction
Edit `IsField` so it still compiles and the proof is simplified where possible. Return the full updated `IsField` block.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.Field.IsField).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]You are editing a file in `Mathlib/Algebra/Field/IsField.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Field.IsField.IsField`, L51-L53)
```lean
theorem IsField.nontrivial {R : Type u} [Semiring R] (h : IsField R) : Nontrivial R := ⟨h.exists_pair_ne⟩
```

## Edit instruction
Edit `IsField` so it still compiles and the proof is simplified where possible. Return the full updated `IsField` block.
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.Calculus.UniformLimitsDeriv).

[User]
You are editing a file in `Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Analysis.Calculus.UniformLimitsDeriv.hasFDerivAt_of_tendstoUniformly`, L429-L451)
Open namespaces: Filter, scoped, uniformity, Topology

## Surrounding context in Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean
```lean
-- Mathlib.Analysis.Calculus.UniformLimitsDeriv.uniformCauchySeqOnFilter_of_fderiv (L115-L178)
theorem uniformCauchySeqOnFilter_of_fderiv (hf' : UniformCauchySeqOnFilter f' l (𝓝 x))
    (hf : ∀ᶠ n : ι × E in l ×ˢ 𝓝 x, HasFDerivAt (f n.1) (f' n.1 n.2) n.2)
    (hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOnFilter f l (𝓝 x)

-- Mathlib.Analysis.Calculus.UniformLimitsDeriv.uniformCauchySeqOn_ball_of_fderiv (L179-L228)
theorem uniformCauchySeqOn_ball_of_fderiv {r : ℝ} (hf' : UniformCauchySeqOn f' l (Metric.ball x r))
    (hf : ∀ n : ι, ∀ y : E, y ∈ Metric.ball x r → HasFDerivAt (f n) (f' n y) y)
    (hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOn f l (Metric.ball x r)

-- Mathlib.Analysis.Calculus.UniformLimitsDeriv.cauchy_map_of_uniformCauchySeqOn_fderiv (L229-L258)
theorem cauchy_map_of_uniformCauchySeqOn_fderiv {s : Set E} (hs : IsOpen s) (h's : IsPreconnected s)
    (hf' : UniformCauchySeqOn f' l s) (hf : ∀ n : ι, ∀ y : E, y ∈ s → HasFDerivAt (f n) (f' n y) y)
    {x₀ x : E} (hx₀ : x₀ ∈ s) (hx : x ∈ s) (hfg : Cauchy (map (fun n => f n x₀) l)) :
    Cauchy (map (fun n => f n x) l)
```

Relevant lemmas available in scope: `hf`, `hfg`, `hf'`, `hasFDerivAt_of_tendstoUniformlyOn`

```lean
theorem hasFDerivAt_of_tendstoUniformly [NeBot l] (hf' : TendstoUniformly f' g' l)
    (hf : ∀ n : ι, ∀ x : E, HasFDerivAt (f n) (f' n x) x)
    (hfg : ∀ x : E, Tendsto (fun n => f n x) l (𝓝 (g x))) (x : E) : HasFDerivAt g (g' x) x := by
have hf : ∀ n : ι, ∀ x : E, x ∈ Set.univ → HasFDerivAt (f n) (f' n x) x := by simp [hf]
  have hfg : ∀ x : E, x ∈ Set.univ → Tendsto (fun n => f n x) l (𝓝 (g x)) := by simp [hfg]
  have hf' : TendstoUniformlyOn f' g' l Set.univ := by rwa [tendstoUniformlyOn_univ]
  exact hasFDerivAt_of_tendstoUniformlyOn isOpen_univ hf' hf hfg (Set.mem_univ x)

end LimitsOfDerivatives

section deriv

/-! ### `deriv` versions of above theorems

In this section, we provide `deriv` equivalents of the `fderiv` lemmas in the previous section.
-/

variable {ι : Type*} {l : Filter ι} {𝕜 : Type*} [NontriviallyNormedField 𝕜]
  {G : Type*} [NormedAddCommGroup G]
  [NormedSpace 𝕜 G] {f : ι → 𝕜 → G} {g : 𝕜 → G} {f' : ι → 𝕜 → G} {g' : 𝕜 → G} {x : 𝕜}

/-- If our derivatives converge uniformly, then the Fréchet derivatives converge uniformly -/
```

## Edit instruction
Edit `hasFDerivAt_of_tendstoUniformly` so it still compiles and the proof is simplified where possible. Return the full updated `hasFDerivAt_of_tendstoUniformly` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Analysis.Calculus.UniformLimitsDeriv).

You are editing a file in `Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Analysis.Calculus.UniformLimitsDeriv.hasFDerivAt_of_tendstoUniformly`, L429-L451)
Open namespaces: Filter, scoped, uniformity, Topology

## Surrounding context in Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean
```lean
-- Mathlib.Analysis.Calculus.UniformLimitsDeriv.uniformCauchySeqOnFilter_of_fderiv (L115-L178)
theorem uniformCauchySeqOnFilter_of_fderiv (hf' : UniformCauchySeqOnFilter f' l (𝓝 x))
    (hf : ∀ᶠ n : ι × E in l ×ˢ 𝓝 x, HasFDerivAt (f n.1) (f' n.1 n.2) n.2)
    (hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOnFilter f l (𝓝 x)

-- Mathlib.Analysis.Calculus.UniformLimitsDeriv.uniformCauchySeqOn_ball_of_fderiv (L179-L228)
theorem uniformCauchySeqOn_ball_of_fderiv {r : ℝ} (hf' : UniformCauchySeqOn f' l (Metric.ball x r))
    (hf : ∀ n : ι, ∀ y : E, y ∈ Metric.ball x r → HasFDerivAt (f n) (f' n y) y)
    (hfg : Cauchy (map (fun n => f n x) l)) : UniformCauchySeqOn f l (Metric.ball x r)

-- Mathlib.Analysis.Calculus.UniformLimitsDeriv.cauchy_map_of_uniformCauchySeqOn_fderiv (L229-L258)
theorem cauchy_map_of_uniformCauchySeqOn_fderiv {s : Set E} (hs : IsOpen s) (h's : IsPreconnected s)
    (hf' : UniformCauchySeqOn f' l s) (hf : ∀ n : ι, ∀ y : E, y ∈ s → HasFDerivAt (f n) (f' n y) y)
    {x₀ x : E} (hx₀ : x₀ ∈ s) (hx : x ∈ s) (hfg : Cauchy (map (fun n => f n x₀) l)) :
    Cauchy (map (fun n => f n x) l)
```

Relevant lemmas available in scope: `hf`, `hfg`, `hf'`, `hasFDerivAt_of_tendstoUniformlyOn`

```lean
theorem hasFDerivAt_of_tendstoUniformly [NeBot l] (hf' : TendstoUniformly f' g' l)
    (hf : ∀ n : ι, ∀ x : E, HasFDerivAt (f n) (f' n x) x)
    (hfg : ∀ x : E, Tendsto (fun n => f n x) l (𝓝 (g x))) (x : E) : HasFDerivAt g (g' x) x := by
have hf : ∀ n : ι, ∀ x : E, x ∈ Set.univ → HasFDerivAt (f n) (f' n x) x := by simp [hf]
  have hfg : ∀ x : E, x ∈ Set.univ → Tendsto (fun n => f n x) l (𝓝 (g x)) := by simp [hfg]
  have hf' : TendstoUniformlyOn f' g' l Set.univ := by rwa [tendstoUniformlyOn_univ]
  exact hasFDerivAt_of_tendstoUniformlyOn isOpen_univ hf' hf hfg (Set.mem_univ x)

end LimitsOfDerivatives

section deriv

/-! ### `deriv` versions of above theorems

In this section, we provide `deriv` equivalents of the `fderiv` lemmas in the previous section.
-/

variable {ι : Type*} {l : Filter ι} {𝕜 : Type*} [NontriviallyNormedField 𝕜]
  {G : Type*} [NormedAddCommGroup G]
  [NormedSpace 𝕜 G] {f : ι → 𝕜 → G} {g : 𝕜 → G} {f' : ι → 𝕜 → G} {g' : 𝕜 → G} {x : 𝕜}

/-- If our derivatives converge uniformly, then the Fréchet derivatives converge uniformly -/
```

## Edit instruction
Edit `hasFDerivAt_of_tendstoUniformly` so it still compiles and the proof is simplified where possible. Return the full updated `hasFDerivAt_of_tendstoUniformly` block.


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Multiset.Count).

[User]
You are editing a file in `Mathlib/Data/Multiset/Count.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Multiset.Count.countP_pos`, L90-L92)
Open namespaces: List, Subtype, Nat, Function

## Surrounding context in Mathlib/Data/Multiset/Count.lean
```lean
-- Mathlib.Data.Multiset.Count.countP (L39-L41)
def countP (s : Multiset α) : ℕ

-- Mathlib.Data.Multiset.Count.coe_countP (L43-L45)
theorem coe_countP (l : List α) : countP p l = l.countP p

-- Mathlib.Data.Multiset.Count.countP_zero (L47-L51)
theorem countP_zero : countP p 0 = 0
```

```lean
theorem countP_pos {s} : 0 < countP p s ↔ ∃ a ∈ s, p a := Quot.inductionOn s fun _l => by simp
```

## Edit instruction
Edit `countP_pos` so it still compiles and the proof is simplified where possible. Return the full updated `countP_pos` block.

You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Data.Multiset.Count).

You are editing a file in `Mathlib/Data/Multiset/Count.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Multiset.Count.countP_pos`, L90-L92)
Open namespaces: List, Subtype, Nat, Function

## Surrounding context in Mathlib/Data/Multiset/Count.lean
```lean
-- Mathlib.Data.Multiset.Count.countP (L39-L41)
def countP (s : Multiset α) : ℕ

-- Mathlib.Data.Multiset.Count.coe_countP (L43-L45)
theorem coe_countP (l : List α) : countP p l = l.countP p

-- Mathlib.Data.Multiset.Count.countP_zero (L47-L51)
theorem countP_zero : countP p 0 = 0
```

```lean
theorem countP_pos {s} : 0 < countP p s ↔ ∃ a ∈ s, p a := Quot.inductionOn s fun _l => by simp
```

## Edit instruction
Edit `countP_pos` so it still compiles and the proof is simplified where possible. Return the full updated `countP_pos` block.