[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.Asymptotics.Lemmas).

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

## Current excerpt (around `Mathlib.Analysis.Asymptotics.Lemmas.isBigO_atTop_iff_eventually_exists_pos`, L701-L705)
Open namespaces: Set, Topology, Filter, NNReal

## Surrounding context in Mathlib/Analysis/Asymptotics/Lemmas.lean
```lean
-- Mathlib.Analysis.Asymptotics.Lemmas.isBigOWith_principal (L42-L44)
theorem isBigOWith_principal {s : Set α} : IsBigOWith c (𝓟 s) f g ↔ ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖

-- Mathlib.Analysis.Asymptotics.Lemmas.isBigO_principal (L45-L47)
theorem isBigO_principal {s : Set α} : f =O[𝓟 s] g ↔ ∃ c, ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖

-- Mathlib.Analysis.Asymptotics.Lemmas.isLittleO_principal (L49-L60)
theorem isLittleO_principal {s : Set α} : f'' =o[𝓟 s] g' ↔ ∀ x ∈ s, f'' x = 0
```

```lean
theorem isBigO_atTop_iff_eventually_exists_pos {α : Type*}
    [SemilatticeSup α] [Nonempty α] {f : α → G} {g : α → G'} :
    f =O[atTop] g ↔ ∀ᶠ n₀ in atTop, ∃ c > 0, ∀ n ≥ n₀, c * ‖f n‖ ≤ ‖g n‖ := by
simp_rw [isBigO_iff'', ← exists_prop, Subtype.exists', exists_eventually_atTop]
```

## Edit instruction
Edit `isBigO_atTop_iff_eventually_exists_pos` so it still compiles and the proof is simplified where possible. Return the full updated `isBigO_atTop_iff_eventually_exists_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.Analysis.Asymptotics.Lemmas).

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

## Current excerpt (around `Mathlib.Analysis.Asymptotics.Lemmas.isBigO_atTop_iff_eventually_exists_pos`, L701-L705)
Open namespaces: Set, Topology, Filter, NNReal

## Surrounding context in Mathlib/Analysis/Asymptotics/Lemmas.lean
```lean
-- Mathlib.Analysis.Asymptotics.Lemmas.isBigOWith_principal (L42-L44)
theorem isBigOWith_principal {s : Set α} : IsBigOWith c (𝓟 s) f g ↔ ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖

-- Mathlib.Analysis.Asymptotics.Lemmas.isBigO_principal (L45-L47)
theorem isBigO_principal {s : Set α} : f =O[𝓟 s] g ↔ ∃ c, ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖

-- Mathlib.Analysis.Asymptotics.Lemmas.isLittleO_principal (L49-L60)
theorem isLittleO_principal {s : Set α} : f'' =o[𝓟 s] g' ↔ ∀ x ∈ s, f'' x = 0
```

```lean
theorem isBigO_atTop_iff_eventually_exists_pos {α : Type*}
    [SemilatticeSup α] [Nonempty α] {f : α → G} {g : α → G'} :
    f =O[atTop] g ↔ ∀ᶠ n₀ in atTop, ∃ c > 0, ∀ n ≥ n₀, c * ‖f n‖ ≤ ‖g n‖ := by
simp_rw [isBigO_iff'', ← exists_prop, Subtype.exists', exists_eventually_atTop]
```

## Edit instruction
Edit `isBigO_atTop_iff_eventually_exists_pos` so it still compiles and the proof is simplified where possible. Return the full updated `isBigO_atTop_iff_eventually_exists_pos` 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.MetricSpace.HausdorffDistance).

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

## Current excerpt (around `Mathlib.Topology.MetricSpace.HausdorffDistance.hausdorffDist_le_diam`, L853-L863)
Open namespaces: NNReal, ENNReal, Topology, Set, Filter, Pointwise, Bornology, Metric

## Surrounding context in Mathlib/Topology/MetricSpace/HausdorffDistance.lean
```lean
-- Mathlib.Topology.MetricSpace.HausdorffDistance.infEDist (L74-L76)
def infEDist (x : α) (s : Set α) : ℝ≥0∞

-- Mathlib.Topology.MetricSpace.HausdorffDistance.infEDist_empty (L78-L80)
theorem infEDist_empty : infEDist x ∅ = ∞

-- Mathlib.Topology.MetricSpace.HausdorffDistance.le_infEDist (L81-L84)
theorem le_infEDist {d} : d ≤ infEDist x s ↔ ∀ y ∈ s, d ≤ edist x y
```

Relevant lemmas available in scope: `fun`

```lean
theorem hausdorffDist_le_diam (hs : s.Nonempty) (bs : IsBounded s) (ht : t.Nonempty)
    (bt : IsBounded t) : hausdorffDist s t ≤ diam (s ∪ t) := by
rcases hs with ⟨x, xs⟩
  rcases ht with ⟨y, yt⟩
  refine hausdorffDist_le_of_mem_dist diam_nonneg ?_ ?_
  · exact fun z hz => ⟨y, yt, dist_le_diam_of_mem (bs.union bt) (subset_union_left hz)
      (subset_union_right yt)⟩
  · exact fun z hz => ⟨x, xs, dist_le_diam_of_mem (bs.union bt) (subset_union_right hz)
      (subset_union_left xs)⟩

/-- The distance to a set is controlled by the Hausdorff distance. -/
```

## Edit instruction
Edit `hausdorffDist_le_diam` so it still compiles and the proof is simplified where possible. Return the full updated `hausdorffDist_le_diam` 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.MetricSpace.HausdorffDistance).

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

## Current excerpt (around `Mathlib.Topology.MetricSpace.HausdorffDistance.hausdorffDist_le_diam`, L853-L863)
Open namespaces: NNReal, ENNReal, Topology, Set, Filter, Pointwise, Bornology, Metric

## Surrounding context in Mathlib/Topology/MetricSpace/HausdorffDistance.lean
```lean
-- Mathlib.Topology.MetricSpace.HausdorffDistance.infEDist (L74-L76)
def infEDist (x : α) (s : Set α) : ℝ≥0∞

-- Mathlib.Topology.MetricSpace.HausdorffDistance.infEDist_empty (L78-L80)
theorem infEDist_empty : infEDist x ∅ = ∞

-- Mathlib.Topology.MetricSpace.HausdorffDistance.le_infEDist (L81-L84)
theorem le_infEDist {d} : d ≤ infEDist x s ↔ ∀ y ∈ s, d ≤ edist x y
```

Relevant lemmas available in scope: `fun`

```lean
theorem hausdorffDist_le_diam (hs : s.Nonempty) (bs : IsBounded s) (ht : t.Nonempty)
    (bt : IsBounded t) : hausdorffDist s t ≤ diam (s ∪ t) := by
rcases hs with ⟨x, xs⟩
  rcases ht with ⟨y, yt⟩
  refine hausdorffDist_le_of_mem_dist diam_nonneg ?_ ?_
  · exact fun z hz => ⟨y, yt, dist_le_diam_of_mem (bs.union bt) (subset_union_left hz)
      (subset_union_right yt)⟩
  · exact fun z hz => ⟨x, xs, dist_le_diam_of_mem (bs.union bt) (subset_union_right hz)
      (subset_union_left xs)⟩

/-- The distance to a set is controlled by the Hausdorff distance. -/
```

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

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.NumberTheory.NumberField.CanonicalEmbedding.Basic).

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

## Current excerpt (around `Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.integralBasis_repr_apply`, L163-L185)
Open namespaces: Module, scoped, ComplexConjugate

## Surrounding context in Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean
```lean
-- Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.apply_at (L59-L65)
theorem apply_at (φ : K →+* ℂ) (x : K) : (NumberField.canonicalEmbedding K x) φ = φ x

-- Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.conj_apply (L66-L76)
theorem conj_apply {x : ((K →+* ℂ) → ℂ)} (φ : K →+* ℂ)
    (hx : x ∈ Submodule.span ℝ (Set.range (canonicalEmbedding K))) :
    conj (x φ) = x (ComplexEmbedding.conjugate φ)

-- Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.nnnorm_eq (L77-L80)
theorem nnnorm_eq [NumberField K] (x : K) :
    ‖canonicalEmbedding K x‖₊ = Finset.univ.sup (fun φ : K →+* ℂ => ‖φ x‖₊)
```

Relevant lemmas available in scope: `Subtype.val_injective`

```lean
theorem integralBasis_repr_apply [NumberField K] (x : K) (i : Free.ChooseBasisIndex ℤ (𝓞 K)) :
    (latticeBasis K).repr (canonicalEmbedding K x) i = (integralBasis K).repr x i := by
rw [← Basis.restrictScalars_repr_apply ℚ _ ⟨_, mem_rat_span_latticeBasis K x⟩, eq_ratCast,
    Rat.cast_inj]
  let f := (canonicalEmbedding K).toRatAlgHom.toLinearMap.codRestrict _
    (fun x ↦ mem_rat_span_latticeBasis K x)
  suffices ((latticeBasis K).restrictScalars ℚ).repr.toLinearMap ∘ₗ f =
    (integralBasis K).repr.toLinearMap from DFunLike.congr_fun (LinearMap.congr_fun this x) i
  refine Basis.ext (integralBasis K) (fun i ↦ ?_)
  have : f (integralBasis K i) = ((latticeBasis K).restrictScalars ℚ) i := by
    apply Subtype.val_injective
    rw [LinearMap.codRestrict_apply, AlgHom.toLinearMap_apply, Basis.restrictScalars_apply,
      latticeBasis_apply]
    rfl
  simp_rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, this, Basis.repr_self]

end NumberField.canonicalEmbedding

namespace NumberField.mixedEmbedding

open NumberField.InfinitePlace Module Finset

/-- The mixed space `ℝ^r₁ × ℂ^r₂` with `(r₁, r₂)` the signature of `K`. -/
```

## Edit instruction
Edit `integralBasis_repr_apply` so it still compiles and the proof is simplified where possible. Return the full updated `integralBasis_repr_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.NumberTheory.NumberField.CanonicalEmbedding.Basic).

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

## Current excerpt (around `Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.integralBasis_repr_apply`, L163-L185)
Open namespaces: Module, scoped, ComplexConjugate

## Surrounding context in Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean
```lean
-- Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.apply_at (L59-L65)
theorem apply_at (φ : K →+* ℂ) (x : K) : (NumberField.canonicalEmbedding K x) φ = φ x

-- Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.conj_apply (L66-L76)
theorem conj_apply {x : ((K →+* ℂ) → ℂ)} (φ : K →+* ℂ)
    (hx : x ∈ Submodule.span ℝ (Set.range (canonicalEmbedding K))) :
    conj (x φ) = x (ComplexEmbedding.conjugate φ)

-- Mathlib.NumberTheory.NumberField.CanonicalEmbedding.Basic.nnnorm_eq (L77-L80)
theorem nnnorm_eq [NumberField K] (x : K) :
    ‖canonicalEmbedding K x‖₊ = Finset.univ.sup (fun φ : K →+* ℂ => ‖φ x‖₊)
```

Relevant lemmas available in scope: `Subtype.val_injective`

```lean
theorem integralBasis_repr_apply [NumberField K] (x : K) (i : Free.ChooseBasisIndex ℤ (𝓞 K)) :
    (latticeBasis K).repr (canonicalEmbedding K x) i = (integralBasis K).repr x i := by
rw [← Basis.restrictScalars_repr_apply ℚ _ ⟨_, mem_rat_span_latticeBasis K x⟩, eq_ratCast,
    Rat.cast_inj]
  let f := (canonicalEmbedding K).toRatAlgHom.toLinearMap.codRestrict _
    (fun x ↦ mem_rat_span_latticeBasis K x)
  suffices ((latticeBasis K).restrictScalars ℚ).repr.toLinearMap ∘ₗ f =
    (integralBasis K).repr.toLinearMap from DFunLike.congr_fun (LinearMap.congr_fun this x) i
  refine Basis.ext (integralBasis K) (fun i ↦ ?_)
  have : f (integralBasis K i) = ((latticeBasis K).restrictScalars ℚ) i := by
    apply Subtype.val_injective
    rw [LinearMap.codRestrict_apply, AlgHom.toLinearMap_apply, Basis.restrictScalars_apply,
      latticeBasis_apply]
    rfl
  simp_rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, this, Basis.repr_self]

end NumberField.canonicalEmbedding

namespace NumberField.mixedEmbedding

open NumberField.InfinitePlace Module Finset

/-- The mixed space `ℝ^r₁ × ℂ^r₂` with `(r₁, r₂)` the signature of `K`. -/
```

## Edit instruction
Edit `integralBasis_repr_apply` so it still compiles and the proof is simplified where possible. Return the full updated `integralBasis_repr_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.Algebra.Polynomial.Derivative).

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

## Current excerpt (around `Mathlib.Algebra.Polynomial.Derivative.derivative_X`, L117-L119)
Open namespaces: Finset, Polynomial, scoped, Nat

## Surrounding context in Mathlib/Algebra/Polynomial/Derivative.lean
```lean
-- Mathlib.Algebra.Polynomial.Derivative.derivative (L46-L54)
def derivative : R[X] →ₗ[R] R[X] where
  toFun p

-- Mathlib.Algebra.Polynomial.Derivative.derivative_apply (L55-L57)
theorem derivative_apply (p : R[X]) : derivative p = p.sum fun n a => C (a * n) * X ^ (n - 1)

-- Mathlib.Algebra.Polynomial.Derivative.coeff_derivative (L58-L71)
theorem coeff_derivative (p : R[X]) (n : ℕ) :
    coeff (derivative p) n = coeff p (n + 1) * (n + 1)
```

```lean
theorem derivative_X : derivative (X : R[X]) = 1 := (derivative_monomial _ _).trans <| by simp
```

## Edit instruction
Edit `derivative_X` so it still compiles and the proof is simplified where possible. Return the full updated `derivative_X` 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.Polynomial.Derivative).

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

## Current excerpt (around `Mathlib.Algebra.Polynomial.Derivative.derivative_X`, L117-L119)
Open namespaces: Finset, Polynomial, scoped, Nat

## Surrounding context in Mathlib/Algebra/Polynomial/Derivative.lean
```lean
-- Mathlib.Algebra.Polynomial.Derivative.derivative (L46-L54)
def derivative : R[X] →ₗ[R] R[X] where
  toFun p

-- Mathlib.Algebra.Polynomial.Derivative.derivative_apply (L55-L57)
theorem derivative_apply (p : R[X]) : derivative p = p.sum fun n a => C (a * n) * X ^ (n - 1)

-- Mathlib.Algebra.Polynomial.Derivative.coeff_derivative (L58-L71)
theorem coeff_derivative (p : R[X]) (n : ℕ) :
    coeff (derivative p) n = coeff p (n + 1) * (n + 1)
```

```lean
theorem derivative_X : derivative (X : R[X]) = 1 := (derivative_monomial _ _).trans <| by simp
```

## Edit instruction
Edit `derivative_X` so it still compiles and the proof is simplified where possible. Return the full updated `derivative_X` 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.nonempty_of_ssubset`, L370-L372)
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 nonempty_of_ssubset (ht : s ⊂ t) : (t \ s).Nonempty := nonempty_of_not_subset ht.2
```

## Edit instruction
Edit `nonempty_of_ssubset` so it still compiles and the proof is simplified where possible. Return the full updated `nonempty_of_ssubset` 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.nonempty_of_ssubset`, L370-L372)
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 nonempty_of_ssubset (ht : s ⊂ t) : (t \ s).Nonempty := nonempty_of_not_subset ht.2
```

## Edit instruction
Edit `nonempty_of_ssubset` so it still compiles and the proof is simplified where possible. Return the full updated `nonempty_of_ssubset` 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.Nat.Factorization.Basic).

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

## Current excerpt (around `Mathlib.Data.Nat.Factorization.Basic.ordCompl_div_of_dvd`, L257-L261)
Open namespaces: Finset, List, Finsupp

## Surrounding context in Mathlib/Data/Nat/Factorization/Basic.lean
```lean
-- Mathlib.Data.Nat.Factorization.Basic.factorization_eq_zero_of_lt (L28-L30)
theorem factorization_eq_zero_of_lt {n p : ℕ} (h : n < p) : n.factorization p = 0

-- Mathlib.Data.Nat.Factorization.Basic.dvd_of_factorization_pos (L31-L33)
theorem dvd_of_factorization_pos {n p : ℕ} (hn : n.factorization p ≠ 0) : p ∣ n

-- Mathlib.Data.Nat.Factorization.Basic.factorization_eq_zero_iff_remainder (L34-L44)
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0
```

```lean
theorem ordCompl_div_of_dvd {x : ℕ} {p : ℕ} (hp : p.Prime) (hx : p ∣ x) :
    ordCompl[p] (x / p) = ordCompl[p] x := by
simpa [pow_one] using ordCompl_div_pow_of_dvd 1 hp (show p ^ 1 ∣ x by simpa)

-- `ordCompl[p] n` is the largest divisor of `n` not divisible by `p`.
```

## Edit instruction
Edit `ordCompl_div_of_dvd` so it still compiles and the proof is simplified where possible. Return the full updated `ordCompl_div_of_dvd` 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.Nat.Factorization.Basic).

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

## Current excerpt (around `Mathlib.Data.Nat.Factorization.Basic.ordCompl_div_of_dvd`, L257-L261)
Open namespaces: Finset, List, Finsupp

## Surrounding context in Mathlib/Data/Nat/Factorization/Basic.lean
```lean
-- Mathlib.Data.Nat.Factorization.Basic.factorization_eq_zero_of_lt (L28-L30)
theorem factorization_eq_zero_of_lt {n p : ℕ} (h : n < p) : n.factorization p = 0

-- Mathlib.Data.Nat.Factorization.Basic.dvd_of_factorization_pos (L31-L33)
theorem dvd_of_factorization_pos {n p : ℕ} (hn : n.factorization p ≠ 0) : p ∣ n

-- Mathlib.Data.Nat.Factorization.Basic.factorization_eq_zero_iff_remainder (L34-L44)
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0
```

```lean
theorem ordCompl_div_of_dvd {x : ℕ} {p : ℕ} (hp : p.Prime) (hx : p ∣ x) :
    ordCompl[p] (x / p) = ordCompl[p] x := by
simpa [pow_one] using ordCompl_div_pow_of_dvd 1 hp (show p ^ 1 ∣ x by simpa)

-- `ordCompl[p] n` is the largest divisor of `n` not divisible by `p`.
```

## Edit instruction
Edit `ordCompl_div_of_dvd` so it still compiles and the proof is simplified where possible. Return the full updated `ordCompl_div_of_dvd` 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.Combinatorics.SimpleGraph.Metric).

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

## Current excerpt (around `Mathlib.Combinatorics.SimpleGraph.Metric.edist_anti`, L189-L209)
## Surrounding context in Mathlib/Combinatorics/SimpleGraph/Metric.lean
```lean
-- Mathlib.Combinatorics.SimpleGraph.Metric.edist_eq_sInf (L58-L67)
theorem edist_eq_sInf : G.edist u v = sInf (Set.range fun w : G.Walk u v ↦ (w.length : ℕ∞))

-- Mathlib.Combinatorics.SimpleGraph.Metric.edist_le (L68-L72)
theorem edist_le (p : G.Walk u v) :
    G.edist u v ≤ p.length

-- Mathlib.Combinatorics.SimpleGraph.Metric.edist_eq_zero_iff (L74-L77)
theorem edist_eq_zero_iff :
    G.edist u v = 0 ↔ u = v
```

Relevant lemmas available in scope: `edist_le`, `edist_eq_top_of_not_reachable`

```lean
theorem edist_anti {G' : SimpleGraph V} (h : G ≤ G') :
    G'.edist u v ≤ G.edist u v := by
by_cases hr : G.Reachable u v
  · obtain ⟨_, hw⟩ := hr.exists_walk_length_eq_edist
    rw [← hw, ← Walk.length_map (.ofLE h)]
    apply edist_le
  · exact edist_eq_top_of_not_reachable hr ▸ le_top

end edist

section dist

/--
The distance between two vertices is the length of the shortest walk between them.
If no such walk exists, this uses the junk value of `0`.
-/
noncomputable def dist (u v : V) : ℕ :=
  (G.edist u v).toNat

variable {G} {u v w : V}
```

## Edit instruction
Edit `edist_anti` so it still compiles and the proof is simplified where possible. Return the full updated `edist_anti` 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.Combinatorics.SimpleGraph.Metric).

You are editing a file in `Mathlib/Combinatorics/SimpleGraph/Metric.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Combinatorics.SimpleGraph.Metric.edist_anti`, L189-L209)
## Surrounding context in Mathlib/Combinatorics/SimpleGraph/Metric.lean
```lean
-- Mathlib.Combinatorics.SimpleGraph.Metric.edist_eq_sInf (L58-L67)
theorem edist_eq_sInf : G.edist u v = sInf (Set.range fun w : G.Walk u v ↦ (w.length : ℕ∞))

-- Mathlib.Combinatorics.SimpleGraph.Metric.edist_le (L68-L72)
theorem edist_le (p : G.Walk u v) :
    G.edist u v ≤ p.length

-- Mathlib.Combinatorics.SimpleGraph.Metric.edist_eq_zero_iff (L74-L77)
theorem edist_eq_zero_iff :
    G.edist u v = 0 ↔ u = v
```

Relevant lemmas available in scope: `edist_le`, `edist_eq_top_of_not_reachable`

```lean
theorem edist_anti {G' : SimpleGraph V} (h : G ≤ G') :
    G'.edist u v ≤ G.edist u v := by
by_cases hr : G.Reachable u v
  · obtain ⟨_, hw⟩ := hr.exists_walk_length_eq_edist
    rw [← hw, ← Walk.length_map (.ofLE h)]
    apply edist_le
  · exact edist_eq_top_of_not_reachable hr ▸ le_top

end edist

section dist

/--
The distance between two vertices is the length of the shortest walk between them.
If no such walk exists, this uses the junk value of `0`.
-/
noncomputable def dist (u v : V) : ℕ :=
  (G.edist u v).toNat

variable {G} {u v w : V}
```

## Edit instruction
Edit `edist_anti` so it still compiles and the proof is simplified where possible. Return the full updated `edist_anti` 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.LSeries.HurwitzZetaOdd).

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

## Current excerpt (around `Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.hasSum_nat_hurwitzZetaOdd_of_mem_Icc`, L501-L514)
Open namespaces: Complex, CharZero, Filter, Topology, Asymptotics, Real, Set, MeasureTheory

## Surrounding context in Mathlib/NumberTheory/LSeries/HurwitzZetaOdd.lean
```lean
-- Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.jacobiTheta₂'' (L61-L63)
def jacobiTheta₂'' (z τ : ℂ) : ℂ

-- Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.jacobiTheta₂''_conj (L64-L69)
lemma jacobiTheta₂''_conj (z τ : ℂ) :
    conj (jacobiTheta₂'' z τ) = jacobiTheta₂'' (conj z) (-conj τ)

-- Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.jacobiTheta₂''_add_left (L70-L81)
lemma jacobiTheta₂''_add_left (z τ : ℂ) : jacobiTheta₂'' (z + 1) τ = jacobiTheta₂'' z τ
```

Relevant lemmas available in scope: `b`

```lean
lemma hasSum_nat_hurwitzZetaOdd_of_mem_Icc {a : ℝ} (ha : a ∈ Icc 0 1) {s : ℂ} (hs : 1 < re s) :
    HasSum (fun n : ℕ ↦ (1 / (n + a : ℂ) ^ s - 1 / (n + 1 - a : ℂ) ^ s) / 2)
    (hurwitzZetaOdd a s) := by
refine (hasSum_nat_hurwitzZetaOdd a hs).congr_fun fun n ↦ ?_
  suffices ∀ b : ℝ, 0 ≤ b → SignType.sign (n + b) / (↑|n + b| : ℂ) ^ s = 1 / (n + b) ^ s by
    simp only [add_sub_assoc, this a ha.1, this (1 - a) (sub_nonneg.mpr ha.2), push_cast]
  intro b hb
  rw [abs_of_nonneg (by positivity), (by simp : (n : ℂ) + b = ↑(n + b))]
  rcases lt_or_eq_of_le (by positivity : 0 ≤ n + b) with hb | hb
  · simp [sign_pos hb]
  · rw [← hb, ofReal_zero, zero_cpow ((not_lt.mpr zero_le_one) ∘ (zero_re ▸ · ▸ hs)),
      div_zero, div_zero]

/-- Formula for `sinZeta` as a Dirichlet series in the convergence range, with sum over `ℤ`. -/
```

## Edit instruction
Edit `hasSum_nat_hurwitzZetaOdd_of_mem_Icc` so it still compiles and the proof is simplified where possible. Return the full updated `hasSum_nat_hurwitzZetaOdd_of_mem_Icc` 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.LSeries.HurwitzZetaOdd).

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

## Current excerpt (around `Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.hasSum_nat_hurwitzZetaOdd_of_mem_Icc`, L501-L514)
Open namespaces: Complex, CharZero, Filter, Topology, Asymptotics, Real, Set, MeasureTheory

## Surrounding context in Mathlib/NumberTheory/LSeries/HurwitzZetaOdd.lean
```lean
-- Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.jacobiTheta₂'' (L61-L63)
def jacobiTheta₂'' (z τ : ℂ) : ℂ

-- Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.jacobiTheta₂''_conj (L64-L69)
lemma jacobiTheta₂''_conj (z τ : ℂ) :
    conj (jacobiTheta₂'' z τ) = jacobiTheta₂'' (conj z) (-conj τ)

-- Mathlib.NumberTheory.LSeries.HurwitzZetaOdd.jacobiTheta₂''_add_left (L70-L81)
lemma jacobiTheta₂''_add_left (z τ : ℂ) : jacobiTheta₂'' (z + 1) τ = jacobiTheta₂'' z τ
```

Relevant lemmas available in scope: `b`

```lean
lemma hasSum_nat_hurwitzZetaOdd_of_mem_Icc {a : ℝ} (ha : a ∈ Icc 0 1) {s : ℂ} (hs : 1 < re s) :
    HasSum (fun n : ℕ ↦ (1 / (n + a : ℂ) ^ s - 1 / (n + 1 - a : ℂ) ^ s) / 2)
    (hurwitzZetaOdd a s) := by
refine (hasSum_nat_hurwitzZetaOdd a hs).congr_fun fun n ↦ ?_
  suffices ∀ b : ℝ, 0 ≤ b → SignType.sign (n + b) / (↑|n + b| : ℂ) ^ s = 1 / (n + b) ^ s by
    simp only [add_sub_assoc, this a ha.1, this (1 - a) (sub_nonneg.mpr ha.2), push_cast]
  intro b hb
  rw [abs_of_nonneg (by positivity), (by simp : (n : ℂ) + b = ↑(n + b))]
  rcases lt_or_eq_of_le (by positivity : 0 ≤ n + b) with hb | hb
  · simp [sign_pos hb]
  · rw [← hb, ofReal_zero, zero_cpow ((not_lt.mpr zero_le_one) ∘ (zero_re ▸ · ▸ hs)),
      div_zero, div_zero]

/-- Formula for `sinZeta` as a Dirichlet series in the convergence range, with sum over `ℤ`. -/
```

## Edit instruction
Edit `hasSum_nat_hurwitzZetaOdd_of_mem_Icc` so it still compiles and the proof is simplified where possible. Return the full updated `hasSum_nat_hurwitzZetaOdd_of_mem_Icc` 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.RingTheory.Polynomial.UniversalFactorizationRing).

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

## Current excerpt (around `Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.universalFactorizationMap_freeMonic`, L143-L150)
Open namespaces: scoped, Polynomial, TensorProduct, RingHomClass, (toRingHom), (MonicDegreeEq)

## Surrounding context in Mathlib/RingTheory/Polynomial/UniversalFactorizationRing.lean
```lean
-- Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.freeMonic (L48-L50)
def freeMonic : (MvPolynomial (Fin n) R)[X]

-- Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.coeff_freeMonic (L51-L59)
lemma coeff_freeMonic :
    (freeMonic R n).coeff k = if h : k < n then .X ⟨k, h⟩ else if k = n then 1 else 0

-- Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.degree_freeMonic (L60-L64)
lemma degree_freeMonic [Nontrivial R] : (freeMonic R n).degree = n
```

```lean
lemma universalFactorizationMap_freeMonic :
    (freeMonic R n).map (toRingHom <| universalFactorizationMap R n m k hn) =
      (freeMonic R m).map (algebraMap _ _) *
        (freeMonic R k).map (toRingHom <| Algebra.TensorProduct.includeRight) := by
change (mapEquivMonic _ _ _ (universalFactorizationMap R n m k hn)).1 = _
  simp [universalFactorizationMap]
  rfl
```

## Edit instruction
Edit `universalFactorizationMap_freeMonic` so it still compiles and the proof is simplified where possible. Return the full updated `universalFactorizationMap_freeMonic` 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.RingTheory.Polynomial.UniversalFactorizationRing).

You are editing a file in `Mathlib/RingTheory/Polynomial/UniversalFactorizationRing.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.universalFactorizationMap_freeMonic`, L143-L150)
Open namespaces: scoped, Polynomial, TensorProduct, RingHomClass, (toRingHom), (MonicDegreeEq)

## Surrounding context in Mathlib/RingTheory/Polynomial/UniversalFactorizationRing.lean
```lean
-- Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.freeMonic (L48-L50)
def freeMonic : (MvPolynomial (Fin n) R)[X]

-- Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.coeff_freeMonic (L51-L59)
lemma coeff_freeMonic :
    (freeMonic R n).coeff k = if h : k < n then .X ⟨k, h⟩ else if k = n then 1 else 0

-- Mathlib.RingTheory.Polynomial.UniversalFactorizationRing.degree_freeMonic (L60-L64)
lemma degree_freeMonic [Nontrivial R] : (freeMonic R n).degree = n
```

```lean
lemma universalFactorizationMap_freeMonic :
    (freeMonic R n).map (toRingHom <| universalFactorizationMap R n m k hn) =
      (freeMonic R m).map (algebraMap _ _) *
        (freeMonic R k).map (toRingHom <| Algebra.TensorProduct.includeRight) := by
change (mapEquivMonic _ _ _ (universalFactorizationMap R n m k hn)).1 = _
  simp [universalFactorizationMap]
  rfl
```

## Edit instruction
Edit `universalFactorizationMap_freeMonic` so it still compiles and the proof is simplified where possible. Return the full updated `universalFactorizationMap_freeMonic` 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.Homology.ShortComplex.RightHomology).

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

## Current excerpt (around `Mathlib.Algebra.Homology.ShortComplex.RightHomology.leftHomologyMap_op`, L1082-L1088)
Open namespaces: Category, Limits

## Surrounding context in Mathlib/Algebra/Homology/ShortComplex/RightHomology.lean
```lean
-- Mathlib.Algebra.Homology.ShortComplex.RightHomology.descQ (L93-L95)
def descQ (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.Q ⟶ A

-- Mathlib.Algebra.Homology.ShortComplex.RightHomology.p_descQ (L97-L101)
lemma p_descQ (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.p ≫ h.descQ k hk = k

-- Mathlib.Algebra.Homology.ShortComplex.RightHomology.descH (L103-L107)
def descH (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.H ⟶ A
```

```lean
lemma leftHomologyMap_op (φ : S₁ ⟶ S₂) [S₁.HasLeftHomology] [S₂.HasLeftHomology] :
    (leftHomologyMap φ).op = S₂.rightHomologyOpIso.inv ≫ rightHomologyMap (opMap φ) ≫
      S₁.rightHomologyOpIso.hom := by
dsimp [rightHomologyOpIso, RightHomologyData.rightHomologyIso, rightHomologyMap,
    leftHomologyMap]
  simp only [← rightHomologyMap'_comp, comp_id, id_comp, leftHomologyMap'_op]
```

## Edit instruction
Edit `leftHomologyMap_op` so it still compiles and the proof is simplified where possible. Return the full updated `leftHomologyMap_op` 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.Homology.ShortComplex.RightHomology).

You are editing a file in `Mathlib/Algebra/Homology/ShortComplex/RightHomology.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Homology.ShortComplex.RightHomology.leftHomologyMap_op`, L1082-L1088)
Open namespaces: Category, Limits

## Surrounding context in Mathlib/Algebra/Homology/ShortComplex/RightHomology.lean
```lean
-- Mathlib.Algebra.Homology.ShortComplex.RightHomology.descQ (L93-L95)
def descQ (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.Q ⟶ A

-- Mathlib.Algebra.Homology.ShortComplex.RightHomology.p_descQ (L97-L101)
lemma p_descQ (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.p ≫ h.descQ k hk = k

-- Mathlib.Algebra.Homology.ShortComplex.RightHomology.descH (L103-L107)
def descH (k : S.X₂ ⟶ A) (hk : S.f ≫ k = 0) : h.H ⟶ A
```

```lean
lemma leftHomologyMap_op (φ : S₁ ⟶ S₂) [S₁.HasLeftHomology] [S₂.HasLeftHomology] :
    (leftHomologyMap φ).op = S₂.rightHomologyOpIso.inv ≫ rightHomologyMap (opMap φ) ≫
      S₁.rightHomologyOpIso.hom := by
dsimp [rightHomologyOpIso, RightHomologyData.rightHomologyIso, rightHomologyMap,
    leftHomologyMap]
  simp only [← rightHomologyMap'_comp, comp_id, id_comp, leftHomologyMap'_op]
```

## Edit instruction
Edit `leftHomologyMap_op` so it still compiles and the proof is simplified where possible. Return the full updated `leftHomologyMap_op` 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.CStarAlgebra.ContinuousFunctionalCalculus.Unital).

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

## Current excerpt (around `Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.cfcUnits_pow`, L771-L779)
Open namespaces: scoped, Ring, Topology, ContinuousMap, ContinuousFunctionalCalculus, in, Classical, Finset

## Surrounding context in Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean
```lean
-- Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.is (L50-L142)
theorem is nearly impossible to state nicely in terms of `cfcHom` (see `cfcHom_comp`). An
additional advantage of the unbundled approach is that expressions like `fun x : R ↦ x⁻¹` are valid
arguments to `cfc`, and a bundled continuous counterpart can only make sense when the spectrum of
`a` does not contain zero and when we have an `⁻¹` operation on the domain.

A reader familiar with C⋆-algebra theory may be somewhat surprised at the level of abstraction here.
For instance, why not require `A` to be an actual C⋆-algebra? Why define separate continuous
functional calculi for `R

-- Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.ContinuousFunctionalCalculus (L210-L213)
lemma ContinuousFunctionalCalculus.isCompact_spectrum (a : A) :
    IsCompact (spectrum R a)

-- Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.StarAlgHom (L214-L241)
lemma StarAlgHom.ext_continuousMap [UniqueHom R A]
    (a : A) [CompactSpace (spectrum R a)] (φ ψ : C(spectrum R a, R) →⋆ₐ[R] A)
    (hφ : Continuous φ) (hψ : Continuous ψ)
    (h : φ (.restrict (spectrum R a) <| .id R) = ψ (.restrict (spectrum R a) <| .id R)) :
    φ = ψ
```

```lean
lemma cfcUnits_pow (hf' : ∀ x ∈ spectrum R a, f x ≠ 0) (n : ℕ)
    (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) :
(cfcUnits f a hf') ^ n =
      cfcUnits _ _ (forall₂_imp (fun _ _ ↦ pow_ne_zero n) hf') (hf := hf.pow n) := by
  ext
  cases n with
  | zero => simp [cfc_const_one R a]
  | succ n => simp [cfc_pow f _ a]
```

## Edit instruction
Edit `cfcUnits_pow` so it still compiles and the proof is simplified where possible. Return the full updated `cfcUnits_pow` 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.CStarAlgebra.ContinuousFunctionalCalculus.Unital).

You are editing a file in `Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.cfcUnits_pow`, L771-L779)
Open namespaces: scoped, Ring, Topology, ContinuousMap, ContinuousFunctionalCalculus, in, Classical, Finset

## Surrounding context in Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean
```lean
-- Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.is (L50-L142)
theorem is nearly impossible to state nicely in terms of `cfcHom` (see `cfcHom_comp`). An
additional advantage of the unbundled approach is that expressions like `fun x : R ↦ x⁻¹` are valid
arguments to `cfc`, and a bundled continuous counterpart can only make sense when the spectrum of
`a` does not contain zero and when we have an `⁻¹` operation on the domain.

A reader familiar with C⋆-algebra theory may be somewhat surprised at the level of abstraction here.
For instance, why not require `A` to be an actual C⋆-algebra? Why define separate continuous
functional calculi for `R

-- Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.ContinuousFunctionalCalculus (L210-L213)
lemma ContinuousFunctionalCalculus.isCompact_spectrum (a : A) :
    IsCompact (spectrum R a)

-- Mathlib.Analysis.CStarAlgebra.ContinuousFunctionalCalculus.Unital.StarAlgHom (L214-L241)
lemma StarAlgHom.ext_continuousMap [UniqueHom R A]
    (a : A) [CompactSpace (spectrum R a)] (φ ψ : C(spectrum R a, R) →⋆ₐ[R] A)
    (hφ : Continuous φ) (hψ : Continuous ψ)
    (h : φ (.restrict (spectrum R a) <| .id R) = ψ (.restrict (spectrum R a) <| .id R)) :
    φ = ψ
```

```lean
lemma cfcUnits_pow (hf' : ∀ x ∈ spectrum R a, f x ≠ 0) (n : ℕ)
    (hf : ContinuousOn f (spectrum R a) := by cfc_cont_tac) (ha : p a := by cfc_tac) :
(cfcUnits f a hf') ^ n =
      cfcUnits _ _ (forall₂_imp (fun _ _ ↦ pow_ne_zero n) hf') (hf := hf.pow n) := by
  ext
  cases n with
  | zero => simp [cfc_const_one R a]
  | succ n => simp [cfc_pow f _ a]
```

## Edit instruction
Edit `cfcUnits_pow` so it still compiles and the proof is simplified where possible. Return the full updated `cfcUnits_pow` 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.Calculus.VectorField).

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

## Current excerpt (around `Mathlib.Analysis.Calculus.VectorField.pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt`, L619-L654)
Open namespaces: Set, scoped, Topology, Filter

## Surrounding context in Mathlib/Analysis/Calculus/VectorField.lean
```lean
-- Mathlib.Analysis.Calculus.VectorField.lieBracket (L59-L64)
def lieBracket (V W : E → E) (x : E) : E

-- Mathlib.Analysis.Calculus.VectorField.lieBracketWithin (L65-L67)
def lieBracketWithin (V W : E → E) (s : Set E) (x : E) : E

-- Mathlib.Analysis.Calculus.VectorField.lieBracket_eq (L68-L70)
lemma lieBracket_eq :
    lieBracket 𝕜 V W = fun x ↦ fderiv 𝕜 W x (V x) - fderiv 𝕜 V x (W x)
```

Relevant lemmas available in scope: `hMx`, `AV`, `Filter.EventuallyEq.fderivWithin_eq_of_mem`, `AW`, `Af`, `hu`, `M_symm_smooth.differentiableWithinAt`, `hV.comp`

```lean
lemma pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt
    {f : E → F} {V W : F → F} {x : E} {t : Set F}
    (hf : IsSymmSndFDerivWithinAt 𝕜 f s x) (h'f : ContDiffWithinAt 𝕜 2 f s x)
    (hV : DifferentiableWithinAt 𝕜 V t (f x)) (hW : DifferentiableWithinAt 𝕜 W t (f x))
    (hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
    pullbackWithin 𝕜 f (lieBracketWithin 𝕜 V W t) s x
      = lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V s) (pullbackWithin 𝕜 f W s) s x := by
by_cases h : (fderivWithin 𝕜 f s x).IsInvertible; swap
  · simp [pullbackWithin_eq_of_not_isInvertible h, lieBracketWithin_eq]
  rcases exists_continuousLinearEquiv_fderivWithin_symm_eq h'f h hu hx
    with ⟨M, -, M_symm_smooth, hM, M_diff⟩
  have hMx : M x = fderivWithin 𝕜 f s x := (mem_of_mem_nhdsWithin hx hM :)
  have AV : fderivWithin 𝕜 (pullbackWithin 𝕜 f V s) s x =
      fderivWithin 𝕜 (fun y ↦ ((M y).symm : F →L[𝕜] E) (V (f y))) s x := by
    apply Filter.EventuallyEq.fderivWithin_eq_of_mem _ hx
    filter_upwards [hM] with y hy using pullbackWithin_eq_of_fderivWithin_eq hy _
  have AW : fderivWithin 𝕜 (pullbackWithin 𝕜 f W s) s x =
      fderivWithin 𝕜 (fun y ↦ ((M y).symm : F →L[𝕜] E) (W (f y))) s x := by
    apply Filter.EventuallyEq.fderivWithin_eq_of_mem _ hx
    filter_upwards [hM] with y hy using pullbackWithin_eq_of_fderivWithin_eq hy _
  have Af : DifferentiableWithinAt 𝕜 f s x := h'f.differentiableWithinAt two_ne_zero
  simp only [lieBracketWithin_eq, pullbackWithin_eq_of_fderivWithin_eq hMx, map_sub, AV, AW]
  rw [fderivWithin_clm_apply, fderivWithin_clm_apply]
  · simp [fderivWithin_comp' x hW Af hst (hu x hx), ← hMx,
      fderivWithin_comp' x hV Af hst (hu x hx), M_diff, hf.eq]
  · exact hu x hx
  · exact M_symm_smooth.differentiableWithinAt one_ne_zero
  · exact hV.comp x Af hst
  · exact hu x hx
  · exact M_symm_smooth.differentiableWithinAt one_ne_zero
  · exact hW.comp x Af hst

/-- The Lie bracket commutes with taking pullbacks. This requires the function to have symmetric
second derivative. Version in a complete space. One could also give a version avoiding
completeness but requiring that `f` is a local diffeomorphism. Variant where unique
differentiability and the invariance property are only required in a smaller set `u`. -/
```

## Edit instruction
Edit `pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt` so it still compiles and the proof is simplified where possible. Return the full updated `pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt` 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.VectorField).

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

## Current excerpt (around `Mathlib.Analysis.Calculus.VectorField.pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt`, L619-L654)
Open namespaces: Set, scoped, Topology, Filter

## Surrounding context in Mathlib/Analysis/Calculus/VectorField.lean
```lean
-- Mathlib.Analysis.Calculus.VectorField.lieBracket (L59-L64)
def lieBracket (V W : E → E) (x : E) : E

-- Mathlib.Analysis.Calculus.VectorField.lieBracketWithin (L65-L67)
def lieBracketWithin (V W : E → E) (s : Set E) (x : E) : E

-- Mathlib.Analysis.Calculus.VectorField.lieBracket_eq (L68-L70)
lemma lieBracket_eq :
    lieBracket 𝕜 V W = fun x ↦ fderiv 𝕜 W x (V x) - fderiv 𝕜 V x (W x)
```

Relevant lemmas available in scope: `hMx`, `AV`, `Filter.EventuallyEq.fderivWithin_eq_of_mem`, `AW`, `Af`, `hu`, `M_symm_smooth.differentiableWithinAt`, `hV.comp`

```lean
lemma pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt
    {f : E → F} {V W : F → F} {x : E} {t : Set F}
    (hf : IsSymmSndFDerivWithinAt 𝕜 f s x) (h'f : ContDiffWithinAt 𝕜 2 f s x)
    (hV : DifferentiableWithinAt 𝕜 V t (f x)) (hW : DifferentiableWithinAt 𝕜 W t (f x))
    (hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (hst : MapsTo f s t) :
    pullbackWithin 𝕜 f (lieBracketWithin 𝕜 V W t) s x
      = lieBracketWithin 𝕜 (pullbackWithin 𝕜 f V s) (pullbackWithin 𝕜 f W s) s x := by
by_cases h : (fderivWithin 𝕜 f s x).IsInvertible; swap
  · simp [pullbackWithin_eq_of_not_isInvertible h, lieBracketWithin_eq]
  rcases exists_continuousLinearEquiv_fderivWithin_symm_eq h'f h hu hx
    with ⟨M, -, M_symm_smooth, hM, M_diff⟩
  have hMx : M x = fderivWithin 𝕜 f s x := (mem_of_mem_nhdsWithin hx hM :)
  have AV : fderivWithin 𝕜 (pullbackWithin 𝕜 f V s) s x =
      fderivWithin 𝕜 (fun y ↦ ((M y).symm : F →L[𝕜] E) (V (f y))) s x := by
    apply Filter.EventuallyEq.fderivWithin_eq_of_mem _ hx
    filter_upwards [hM] with y hy using pullbackWithin_eq_of_fderivWithin_eq hy _
  have AW : fderivWithin 𝕜 (pullbackWithin 𝕜 f W s) s x =
      fderivWithin 𝕜 (fun y ↦ ((M y).symm : F →L[𝕜] E) (W (f y))) s x := by
    apply Filter.EventuallyEq.fderivWithin_eq_of_mem _ hx
    filter_upwards [hM] with y hy using pullbackWithin_eq_of_fderivWithin_eq hy _
  have Af : DifferentiableWithinAt 𝕜 f s x := h'f.differentiableWithinAt two_ne_zero
  simp only [lieBracketWithin_eq, pullbackWithin_eq_of_fderivWithin_eq hMx, map_sub, AV, AW]
  rw [fderivWithin_clm_apply, fderivWithin_clm_apply]
  · simp [fderivWithin_comp' x hW Af hst (hu x hx), ← hMx,
      fderivWithin_comp' x hV Af hst (hu x hx), M_diff, hf.eq]
  · exact hu x hx
  · exact M_symm_smooth.differentiableWithinAt one_ne_zero
  · exact hV.comp x Af hst
  · exact hu x hx
  · exact M_symm_smooth.differentiableWithinAt one_ne_zero
  · exact hW.comp x Af hst

/-- The Lie bracket commutes with taking pullbacks. This requires the function to have symmetric
second derivative. Version in a complete space. One could also give a version avoiding
completeness but requiring that `f` is a local diffeomorphism. Variant where unique
differentiability and the invariance property are only required in a smaller set `u`. -/
```

## Edit instruction
Edit `pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt` so it still compiles and the proof is simplified where possible. Return the full updated `pullbackWithin_lieBracketWithin_of_isSymmSndFDerivWithinAt` 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.ModularForms.Cusps).

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

## Current excerpt (around `Mathlib.NumberTheory.ModularForms.Cusps.IsRegularAtInfty`, L246-L248)
Open namespaces: Matrix, SpecialLinearGroup, GeneralLinearGroup, Filter, Polynomial, OnePoint, scoped, MatrixGroups

## Surrounding context in Mathlib/NumberTheory/ModularForms/Cusps.lean
```lean
-- Mathlib.NumberTheory.ModularForms.Cusps.exists_mem_SL2 (L33-L48)
lemma exists_mem_SL2 (A : Type*) [CommRing A] [IsDomain A] [Algebra A K] [IsFractionRing A K]
    [IsPrincipalIdealRing A] (c : OnePoint K) :
    ∃ g : SL(2, A), (mapGL K g) • ∞ = c

-- Mathlib.NumberTheory.ModularForms.Cusps.isParabolic_iff_of_upperTriangular (L49-L57)
lemma isParabolic_iff_of_upperTriangular {g} (hg : g ∈ 𝒢) (hg10 : g 1 0 = 0) :
    g.IsParabolic ↔ (∃ x ≠ 0, g = upperRightHom x) ∨ (∃ x ≠ 0, g = -upperRightHom x)

-- Mathlib.NumberTheory.ModularForms.Cusps.IsCusp (L58-L61)
def IsCusp (c : OnePoint ℝ) (𝒢 : Subgroup (GL (Fin 2) ℝ)) : Prop
```

```lean
def IsRegularAtInfty : Prop := 𝒢.strictPeriods = 𝒢.periods
```

## Edit instruction
Edit `IsRegularAtInfty` so it still compiles and the proof is simplified where possible. Return the full updated `IsRegularAtInfty` 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.ModularForms.Cusps).

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

## Current excerpt (around `Mathlib.NumberTheory.ModularForms.Cusps.IsRegularAtInfty`, L246-L248)
Open namespaces: Matrix, SpecialLinearGroup, GeneralLinearGroup, Filter, Polynomial, OnePoint, scoped, MatrixGroups

## Surrounding context in Mathlib/NumberTheory/ModularForms/Cusps.lean
```lean
-- Mathlib.NumberTheory.ModularForms.Cusps.exists_mem_SL2 (L33-L48)
lemma exists_mem_SL2 (A : Type*) [CommRing A] [IsDomain A] [Algebra A K] [IsFractionRing A K]
    [IsPrincipalIdealRing A] (c : OnePoint K) :
    ∃ g : SL(2, A), (mapGL K g) • ∞ = c

-- Mathlib.NumberTheory.ModularForms.Cusps.isParabolic_iff_of_upperTriangular (L49-L57)
lemma isParabolic_iff_of_upperTriangular {g} (hg : g ∈ 𝒢) (hg10 : g 1 0 = 0) :
    g.IsParabolic ↔ (∃ x ≠ 0, g = upperRightHom x) ∨ (∃ x ≠ 0, g = -upperRightHom x)

-- Mathlib.NumberTheory.ModularForms.Cusps.IsCusp (L58-L61)
def IsCusp (c : OnePoint ℝ) (𝒢 : Subgroup (GL (Fin 2) ℝ)) : Prop
```

```lean
def IsRegularAtInfty : Prop := 𝒢.strictPeriods = 𝒢.periods
```

## Edit instruction
Edit `IsRegularAtInfty` so it still compiles and the proof is simplified where possible. Return the full updated `IsRegularAtInfty` 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.Padics.PadicVal.Basic).

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

## Current excerpt (around `Mathlib.NumberTheory.Padics.PadicVal.Basic.pow_succ_padicValNat_not_dvd`, L435-L439)
Open namespaces: Nat, Rat, scoped, Finset

## Surrounding context in Mathlib/NumberTheory/Padics/PadicVal/Basic.lean
```lean
-- Mathlib.NumberTheory.Padics.PadicVal.Basic.eq_zero_of_not_dvd (L80-L86)
theorem eq_zero_of_not_dvd {n : ℕ} (h : ¬p ∣ n) : padicValNat p n = 0

-- Mathlib.NumberTheory.Padics.PadicVal.Basic.padicValInt (L87-L93)
def padicValInt (p : ℕ) (z : ℤ) : ℕ

-- Mathlib.NumberTheory.Padics.PadicVal.Basic.of_ne_one_ne_zero (L94-L99)
theorem of_ne_one_ne_zero {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) :
    padicValInt p z = multiplicity (p : ℤ) z
```

Relevant lemmas available in scope: `Nat.lt_succ_self`

```lean
theorem pow_succ_padicValNat_not_dvd {n : ℕ} [hp : Fact p.Prime] (hn : n ≠ 0) :
    ¬p ^ (padicValNat p n + 1) ∣ n := by
rw [padicValNat_dvd_iff_le hn, not_le]
  exact Nat.lt_succ_self _
```

## Edit instruction
Edit `pow_succ_padicValNat_not_dvd` so it still compiles and the proof is simplified where possible. Return the full updated `pow_succ_padicValNat_not_dvd` 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.Padics.PadicVal.Basic).

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

## Current excerpt (around `Mathlib.NumberTheory.Padics.PadicVal.Basic.pow_succ_padicValNat_not_dvd`, L435-L439)
Open namespaces: Nat, Rat, scoped, Finset

## Surrounding context in Mathlib/NumberTheory/Padics/PadicVal/Basic.lean
```lean
-- Mathlib.NumberTheory.Padics.PadicVal.Basic.eq_zero_of_not_dvd (L80-L86)
theorem eq_zero_of_not_dvd {n : ℕ} (h : ¬p ∣ n) : padicValNat p n = 0

-- Mathlib.NumberTheory.Padics.PadicVal.Basic.padicValInt (L87-L93)
def padicValInt (p : ℕ) (z : ℤ) : ℕ

-- Mathlib.NumberTheory.Padics.PadicVal.Basic.of_ne_one_ne_zero (L94-L99)
theorem of_ne_one_ne_zero {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) :
    padicValInt p z = multiplicity (p : ℤ) z
```

Relevant lemmas available in scope: `Nat.lt_succ_self`

```lean
theorem pow_succ_padicValNat_not_dvd {n : ℕ} [hp : Fact p.Prime] (hn : n ≠ 0) :
    ¬p ^ (padicValNat p n + 1) ∣ n := by
rw [padicValNat_dvd_iff_le hn, not_le]
  exact Nat.lt_succ_self _
```

## Edit instruction
Edit `pow_succ_padicValNat_not_dvd` so it still compiles and the proof is simplified where possible. Return the full updated `pow_succ_padicValNat_not_dvd` 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.Category.Ring.FilteredColimits).

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

## Current excerpt (around `Mathlib.Algebra.Category.Ring.FilteredColimits.forget₂Ring_preservesFilteredColimits`, L352-L359)
Open namespaces: CategoryTheory, Limits, IsFiltered, renaming, max, →, max', --

## Surrounding context in Mathlib/Algebra/Category/Ring/FilteredColimits.lean
```lean
-- Mathlib.Algebra.Category.Ring.FilteredColimits.semiringObj (L52-L60)
instance semiringObj (j : J) :
    Semiring (((F ⋙ forget₂ SemiRingCat.{max v u} MonCat) ⋙ forget MonCat).obj j)

-- Mathlib.Algebra.Category.Ring.FilteredColimits.R (L61-L64)
abbrev R : MonCat.{max v u}

-- Mathlib.Algebra.Category.Ring.FilteredColimits.colimitSemiring (L65-L112)
instance colimitSemiring : Semiring.{max v u} <| R.{v, u} F
```

```lean
instance forget₂Ring_preservesFilteredColimits :
    PreservesFilteredColimits (forget₂ CommRingCat RingCat.{u}) where
  preserves_filtered_colimits {J hJ1 _} := letI : Category J := hJ1
    { preservesColimit := fun {F} =>
        preservesColimit_of_preserves_colimit_cocone (colimitCoconeIsColimit.{u, u} F)
          (RingCat.FilteredColimits.colimitCoconeIsColimit (F ⋙ forget₂ CommRingCat RingCat.{u})) }
```

## Edit instruction
Edit `forget₂Ring_preservesFilteredColimits` so it still compiles and the proof is simplified where possible. Return the full updated `forget₂Ring_preservesFilteredColimits` 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.Category.Ring.FilteredColimits).

You are editing a file in `Mathlib/Algebra/Category/Ring/FilteredColimits.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Category.Ring.FilteredColimits.forget₂Ring_preservesFilteredColimits`, L352-L359)
Open namespaces: CategoryTheory, Limits, IsFiltered, renaming, max, →, max', --

## Surrounding context in Mathlib/Algebra/Category/Ring/FilteredColimits.lean
```lean
-- Mathlib.Algebra.Category.Ring.FilteredColimits.semiringObj (L52-L60)
instance semiringObj (j : J) :
    Semiring (((F ⋙ forget₂ SemiRingCat.{max v u} MonCat) ⋙ forget MonCat).obj j)

-- Mathlib.Algebra.Category.Ring.FilteredColimits.R (L61-L64)
abbrev R : MonCat.{max v u}

-- Mathlib.Algebra.Category.Ring.FilteredColimits.colimitSemiring (L65-L112)
instance colimitSemiring : Semiring.{max v u} <| R.{v, u} F
```

```lean
instance forget₂Ring_preservesFilteredColimits :
    PreservesFilteredColimits (forget₂ CommRingCat RingCat.{u}) where
  preserves_filtered_colimits {J hJ1 _} := letI : Category J := hJ1
    { preservesColimit := fun {F} =>
        preservesColimit_of_preserves_colimit_cocone (colimitCoconeIsColimit.{u, u} F)
          (RingCat.FilteredColimits.colimitCoconeIsColimit (F ⋙ forget₂ CommRingCat RingCat.{u})) }
```

## Edit instruction
Edit `forget₂Ring_preservesFilteredColimits` so it still compiles and the proof is simplified where possible. Return the full updated `forget₂Ring_preservesFilteredColimits` 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.RingTheory.Valuation.Basic).

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

## Current excerpt (around `Mathlib.RingTheory.Valuation.Basic.ne_zero_of_unit`, L218-L220)
Open namespaces: Function, Ideal

## Surrounding context in Mathlib/RingTheory/Valuation/Basic.lean
```lean
-- Mathlib.RingTheory.Valuation.Basic.coe_mk (L131-L132)
theorem coe_mk (f : R →*₀ Γ₀) (h) : ⇑(Valuation.mk f h) = f

-- Mathlib.RingTheory.Valuation.Basic.toFun_eq_coe (L133-L134)
theorem toFun_eq_coe (v : Valuation R Γ₀) : v.toFun = v

-- Mathlib.RingTheory.Valuation.Basic.toMonoidWithZeroHom_coe_eq_coe (L136-L138)
theorem toMonoidWithZeroHom_coe_eq_coe (v : Valuation R Γ₀) :
    (v.toMonoidWithZeroHom : R → Γ₀) = v
```

```lean
theorem ne_zero_of_unit [Nontrivial Γ₀] (v : Valuation K Γ₀) (x : Kˣ) : v x ≠ (0 : Γ₀) := by
simp only [ne_eq, Valuation.zero_iff, Units.ne_zero x, not_false_iff]
```

## Edit instruction
Edit `ne_zero_of_unit` so it still compiles and the proof is simplified where possible. Return the full updated `ne_zero_of_unit` 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.RingTheory.Valuation.Basic).

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

## Current excerpt (around `Mathlib.RingTheory.Valuation.Basic.ne_zero_of_unit`, L218-L220)
Open namespaces: Function, Ideal

## Surrounding context in Mathlib/RingTheory/Valuation/Basic.lean
```lean
-- Mathlib.RingTheory.Valuation.Basic.coe_mk (L131-L132)
theorem coe_mk (f : R →*₀ Γ₀) (h) : ⇑(Valuation.mk f h) = f

-- Mathlib.RingTheory.Valuation.Basic.toFun_eq_coe (L133-L134)
theorem toFun_eq_coe (v : Valuation R Γ₀) : v.toFun = v

-- Mathlib.RingTheory.Valuation.Basic.toMonoidWithZeroHom_coe_eq_coe (L136-L138)
theorem toMonoidWithZeroHom_coe_eq_coe (v : Valuation R Γ₀) :
    (v.toMonoidWithZeroHom : R → Γ₀) = v
```

```lean
theorem ne_zero_of_unit [Nontrivial Γ₀] (v : Valuation K Γ₀) (x : Kˣ) : v x ≠ (0 : Γ₀) := by
simp only [ne_eq, Valuation.zero_iff, Units.ne_zero x, not_false_iff]
```

## Edit instruction
Edit `ne_zero_of_unit` so it still compiles and the proof is simplified where possible. Return the full updated `ne_zero_of_unit` 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.Combinatorics.SimpleGraph.Walks.Decomp).

[User]
You are editing a file in `Mathlib/Combinatorics/SimpleGraph/Walks/Decomp.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Combinatorics.SimpleGraph.Walks.Decomp.rotate`, L300-L302)
```lean
def rotate (c : G.Walk v v) (u : V) (h : u ∈ c.support) : G.Walk u u := (c.dropUntil u h).append (c.takeUntil u h)
```

## Edit instruction
Edit `rotate` so it still compiles and the proof is simplified where possible. Return the full updated `rotate` 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.Combinatorics.SimpleGraph.Walks.Decomp).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]You are editing a file in `Mathlib/Combinatorics/SimpleGraph/Walks/Decomp.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Combinatorics.SimpleGraph.Walks.Decomp.rotate`, L300-L302)
```lean
def rotate (c : G.Walk v v) (u : V) (h : u ∈ c.support) : G.Walk u u := (c.dropUntil u h).append (c.takeUntil u h)
```

## Edit instruction
Edit `rotate` so it still compiles and the proof is simplified where possible. Return the full updated `rotate` 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.NumberTheory.NumberField.CMField).

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

## Current excerpt (around `Mathlib.NumberTheory.NumberField.CMField.regulator_div_regulator_eq_two_pow_mul_indexRealUnits_inv`, L443-L460)
Open namespaces: NumberField, ComplexEmbedding, InfinitePlace, Algebra, scoped, ComplexConjugate, Units, dirichletUnitTheorem

## Surrounding context in Mathlib/NumberTheory/NumberField/CMField.lean
```lean
-- Mathlib.NumberTheory.NumberField.CMField.isQuadraticExtension (L83-L85)
instance isQuadraticExtension : IsQuadraticExtension K⁺ K

-- Mathlib.NumberTheory.NumberField.CMField.isTotallyComplex (L86-L89)
instance isTotallyComplex : IsTotallyComplex K

-- Mathlib.NumberTheory.NumberField.CMField.card_infinitePlace_eq_card_infinitePlace (L90-L106)
theorem card_infinitePlace_eq_card_infinitePlace [NumberField K] :
    Fintype.card (InfinitePlace K⁺) = Fintype.card (InfinitePlace K)
```

```lean
theorem regulator_div_regulator_eq_two_pow_mul_indexRealUnits_inv :
    regulator K / regulator K⁺ = 2 ^ rank K * (indexRealUnits K : ℝ)⁻¹ := by
rw [indexRealUnits, ← closure_realFundSystem_sup_torsion, ← regOfFamily_div_regulator
    (realFundSystem K), regOfFamily_realFunSystem, inv_div, ← mul_div_assoc, mul_div_mul_comm,
    div_self (by positivity), one_mul]

end units

end IsCMField

end maximalRealSubfield

namespace CMExtension

variable (F K : Type*) [Field F] [IsTotallyReal F] [Field K] [CharZero K] [Algebra.IsIntegral ℚ K]
  [IsTotallyComplex K] [Algebra F K] [IsQuadraticExtension F K]

set_option backward.isDefEq.respectTransparency false in
```

## Edit instruction
Edit `regulator_div_regulator_eq_two_pow_mul_indexRealUnits_inv` so it still compiles and the proof is simplified where possible. Return the full updated `regulator_div_regulator_eq_two_pow_mul_indexRealUnits_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.NumberTheory.NumberField.CMField).

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

## Current excerpt (around `Mathlib.NumberTheory.NumberField.CMField.regulator_div_regulator_eq_two_pow_mul_indexRealUnits_inv`, L443-L460)
Open namespaces: NumberField, ComplexEmbedding, InfinitePlace, Algebra, scoped, ComplexConjugate, Units, dirichletUnitTheorem

## Surrounding context in Mathlib/NumberTheory/NumberField/CMField.lean
```lean
-- Mathlib.NumberTheory.NumberField.CMField.isQuadraticExtension (L83-L85)
instance isQuadraticExtension : IsQuadraticExtension K⁺ K

-- Mathlib.NumberTheory.NumberField.CMField.isTotallyComplex (L86-L89)
instance isTotallyComplex : IsTotallyComplex K

-- Mathlib.NumberTheory.NumberField.CMField.card_infinitePlace_eq_card_infinitePlace (L90-L106)
theorem card_infinitePlace_eq_card_infinitePlace [NumberField K] :
    Fintype.card (InfinitePlace K⁺) = Fintype.card (InfinitePlace K)
```

```lean
theorem regulator_div_regulator_eq_two_pow_mul_indexRealUnits_inv :
    regulator K / regulator K⁺ = 2 ^ rank K * (indexRealUnits K : ℝ)⁻¹ := by
rw [indexRealUnits, ← closure_realFundSystem_sup_torsion, ← regOfFamily_div_regulator
    (realFundSystem K), regOfFamily_realFunSystem, inv_div, ← mul_div_assoc, mul_div_mul_comm,
    div_self (by positivity), one_mul]

end units

end IsCMField

end maximalRealSubfield

namespace CMExtension

variable (F K : Type*) [Field F] [IsTotallyReal F] [Field K] [CharZero K] [Algebra.IsIntegral ℚ K]
  [IsTotallyComplex K] [Algebra F K] [IsQuadraticExtension F K]

set_option backward.isDefEq.respectTransparency false in
```

## Edit instruction
Edit `regulator_div_regulator_eq_two_pow_mul_indexRealUnits_inv` so it still compiles and the proof is simplified where possible. Return the full updated `regulator_div_regulator_eq_two_pow_mul_indexRealUnits_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.LinearAlgebra.Multilinear.Basic).

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

## Current excerpt (around `Mathlib.LinearAlgebra.Multilinear.Basic.map_nonempty`, L1432-L1436)
Open namespaces: Fin, Function, Finset, Set, Fintype, Classical, in

## Surrounding context in Mathlib/LinearAlgebra/Multilinear/Basic.lean
```lean
-- Mathlib.LinearAlgebra.Multilinear.Basic.mk' (L117-L126)
def mk' [DecidableEq ι] (f : (∀ i, M₁ i) → M₂)
    (h₁ : ∀ (m : ∀ i, M₁ i) (i : ι) (x y : M₁ i),
      f (update m i (x + y)) = f (update m i x) + f (update m i y)

-- Mathlib.LinearAlgebra.Multilinear.Basic.toFun_eq_coe (L128-L130)
theorem toFun_eq_coe : f.toFun = ⇑f

-- Mathlib.LinearAlgebra.Multilinear.Basic.coe_mk (L132-L134)
theorem coe_mk (f : (∀ i, M₁ i) → M₂) (h₁ h₂) : ⇑(⟨f, h₁, h₂⟩ : MultilinearMap R M₁ M₂) = f
```

```lean
theorem map_nonempty [Nonempty ι] (f : MultilinearMap R M₁ M₂) (p : ∀ i, Submodule R (M₁ i)) :
    (map f p : Set M₂).Nonempty := ⟨f 0, 0, fun i => (p i).zero_mem, rfl⟩

/-- The range of a multilinear map, closed under scalar multiplication. -/
```

## Edit instruction
Edit `map_nonempty` so it still compiles and the proof is simplified where possible. Return the full updated `map_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.LinearAlgebra.Multilinear.Basic).

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

## Current excerpt (around `Mathlib.LinearAlgebra.Multilinear.Basic.map_nonempty`, L1432-L1436)
Open namespaces: Fin, Function, Finset, Set, Fintype, Classical, in

## Surrounding context in Mathlib/LinearAlgebra/Multilinear/Basic.lean
```lean
-- Mathlib.LinearAlgebra.Multilinear.Basic.mk' (L117-L126)
def mk' [DecidableEq ι] (f : (∀ i, M₁ i) → M₂)
    (h₁ : ∀ (m : ∀ i, M₁ i) (i : ι) (x y : M₁ i),
      f (update m i (x + y)) = f (update m i x) + f (update m i y)

-- Mathlib.LinearAlgebra.Multilinear.Basic.toFun_eq_coe (L128-L130)
theorem toFun_eq_coe : f.toFun = ⇑f

-- Mathlib.LinearAlgebra.Multilinear.Basic.coe_mk (L132-L134)
theorem coe_mk (f : (∀ i, M₁ i) → M₂) (h₁ h₂) : ⇑(⟨f, h₁, h₂⟩ : MultilinearMap R M₁ M₂) = f
```

```lean
theorem map_nonempty [Nonempty ι] (f : MultilinearMap R M₁ M₂) (p : ∀ i, Submodule R (M₁ i)) :
    (map f p : Set M₂).Nonempty := ⟨f 0, 0, fun i => (p i).zero_mem, rfl⟩

/-- The range of a multilinear map, closed under scalar multiplication. -/
```

## Edit instruction
Edit `map_nonempty` so it still compiles and the proof is simplified where possible. Return the full updated `map_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.RingTheory.MvPowerSeries.PiTopology).

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

## Current excerpt (around `Mathlib.RingTheory.MvPowerSeries.PiTopology.tendsto_iff_coeff_tendsto`, L131-L137)
Open namespaces: Function, Filter, scoped, Topology

## Surrounding context in Mathlib/RingTheory/MvPowerSeries/PiTopology.lean
```lean
-- Mathlib.RingTheory.MvPowerSeries.PiTopology.instTopologicalSpace_mono (L103-L109)
theorem instTopologicalSpace_mono (σ : Type*) {R : Type*} {t u : TopologicalSpace R} (htu : t ≤ u) :
    @instTopologicalSpace σ R t ≤ @instTopologicalSpace σ R u

-- Mathlib.RingTheory.MvPowerSeries.PiTopology.instT0Space (L111-L113)
theorem instT0Space [T0Space R] : T0Space (MvPowerSeries σ R)

-- Mathlib.RingTheory.MvPowerSeries.PiTopology.instT2Space (L115-L118)
theorem instT2Space [T2Space R] : T2Space (MvPowerSeries σ R)
```

Relevant lemmas available in scope: `forall_congr'`

```lean
theorem tendsto_iff_coeff_tendsto [Semiring R] {ι : Type*}
    (f : ι → MvPowerSeries σ R) (u : Filter ι) (g : MvPowerSeries σ R) :
    Tendsto f u (nhds g) ↔
    ∀ d : σ →₀ ℕ, Tendsto (fun i => coeff d (f i)) u (nhds (coeff d g)) := by
rw [nhds_pi, tendsto_pi]
  exact forall_congr' (fun d => Iff.rfl)
```

## Edit instruction
Edit `tendsto_iff_coeff_tendsto` so it still compiles and the proof is simplified where possible. Return the full updated `tendsto_iff_coeff_tendsto` 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.RingTheory.MvPowerSeries.PiTopology).

You are editing a file in `Mathlib/RingTheory/MvPowerSeries/PiTopology.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.RingTheory.MvPowerSeries.PiTopology.tendsto_iff_coeff_tendsto`, L131-L137)
Open namespaces: Function, Filter, scoped, Topology

## Surrounding context in Mathlib/RingTheory/MvPowerSeries/PiTopology.lean
```lean
-- Mathlib.RingTheory.MvPowerSeries.PiTopology.instTopologicalSpace_mono (L103-L109)
theorem instTopologicalSpace_mono (σ : Type*) {R : Type*} {t u : TopologicalSpace R} (htu : t ≤ u) :
    @instTopologicalSpace σ R t ≤ @instTopologicalSpace σ R u

-- Mathlib.RingTheory.MvPowerSeries.PiTopology.instT0Space (L111-L113)
theorem instT0Space [T0Space R] : T0Space (MvPowerSeries σ R)

-- Mathlib.RingTheory.MvPowerSeries.PiTopology.instT2Space (L115-L118)
theorem instT2Space [T2Space R] : T2Space (MvPowerSeries σ R)
```

Relevant lemmas available in scope: `forall_congr'`

```lean
theorem tendsto_iff_coeff_tendsto [Semiring R] {ι : Type*}
    (f : ι → MvPowerSeries σ R) (u : Filter ι) (g : MvPowerSeries σ R) :
    Tendsto f u (nhds g) ↔
    ∀ d : σ →₀ ℕ, Tendsto (fun i => coeff d (f i)) u (nhds (coeff d g)) := by
rw [nhds_pi, tendsto_pi]
  exact forall_congr' (fun d => Iff.rfl)
```

## Edit instruction
Edit `tendsto_iff_coeff_tendsto` so it still compiles and the proof is simplified where possible. Return the full updated `tendsto_iff_coeff_tendsto` 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.Sheaves.Stalks).

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

## Current excerpt (around `Mathlib.Topology.Sheaves.Stalks.stalkFunctor_map_germ`, L145-L149)
Open namespaces: CategoryTheory, TopCat, CategoryTheory.Limits, CategoryTheory.Functor, TopologicalSpace, Topology, Opposite, scoped

## Surrounding context in Mathlib/Topology/Sheaves/Stalks.lean
```lean
-- Mathlib.Topology.Sheaves.Stalks.stalkFunctor (L75-L80)
def stalkFunctor (x : X) : X.Presheaf C ⥤ C

-- Mathlib.Topology.Sheaves.Stalks.stalk (L81-L84)
def stalk (ℱ : X.Presheaf C) (x : X) : C

-- Mathlib.Topology.Sheaves.Stalks.stalkFunctor_obj (L86-L90)
theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x
```

```lean
theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : X) (hx : x ∈ U) (f : F ⟶ G) :
    F.germ U x hx ≫ (stalkFunctor C x).map f = f.app (op U) ≫ G.germ U x hx := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x).op f) (op ⟨U, hx⟩)

set_option backward.isDefEq.respectTransparency false in
```

## Edit instruction
Edit `stalkFunctor_map_germ` so it still compiles and the proof is simplified where possible. Return the full updated `stalkFunctor_map_germ` 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.Sheaves.Stalks).

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

## Current excerpt (around `Mathlib.Topology.Sheaves.Stalks.stalkFunctor_map_germ`, L145-L149)
Open namespaces: CategoryTheory, TopCat, CategoryTheory.Limits, CategoryTheory.Functor, TopologicalSpace, Topology, Opposite, scoped

## Surrounding context in Mathlib/Topology/Sheaves/Stalks.lean
```lean
-- Mathlib.Topology.Sheaves.Stalks.stalkFunctor (L75-L80)
def stalkFunctor (x : X) : X.Presheaf C ⥤ C

-- Mathlib.Topology.Sheaves.Stalks.stalk (L81-L84)
def stalk (ℱ : X.Presheaf C) (x : X) : C

-- Mathlib.Topology.Sheaves.Stalks.stalkFunctor_obj (L86-L90)
theorem stalkFunctor_obj (ℱ : X.Presheaf C) (x : X) : (stalkFunctor C x).obj ℱ = ℱ.stalk x
```

```lean
theorem stalkFunctor_map_germ {F G : X.Presheaf C} (U : Opens X) (x : X) (hx : x ∈ U) (f : F ⟶ G) :
    F.germ U x hx ≫ (stalkFunctor C x).map f = f.app (op U) ≫ G.germ U x hx := colimit.ι_map (whiskerLeft (OpenNhds.inclusion x).op f) (op ⟨U, hx⟩)

set_option backward.isDefEq.respectTransparency false in
```

## Edit instruction
Edit `stalkFunctor_map_germ` so it still compiles and the proof is simplified where possible. Return the full updated `stalkFunctor_map_germ` 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.Preorder.Chain).

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

## Current excerpt (around `Mathlib.Order.Preorder.Chain.IsChain`, L77-L79)
Open namespaces: Set, Set.Notation

## Surrounding context in Mathlib/Order/Preorder/Chain.lean
```lean
-- Mathlib.Order.Preorder.Chain.SuperChain (L54-L57)
def SuperChain (s t : Set α) : Prop

-- Mathlib.Order.Preorder.Chain.IsMaxChain (L58-L62)
def IsMaxChain (s : Set α) : Prop

-- Mathlib.Order.Preorder.Chain.Set (L66-L68)
theorem Set.Subsingleton.isChain (hs : s.Subsingleton) : IsChain r s
```

```lean
theorem IsChain.symm (h : IsChain r s) : IsChain (flip r) s := h.mono' fun _ _ => Or.symm
```

## Edit instruction
Edit `IsChain` so it still compiles and the proof is simplified where possible. Return the full updated `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.Order.Preorder.Chain).

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

## Current excerpt (around `Mathlib.Order.Preorder.Chain.IsChain`, L77-L79)
Open namespaces: Set, Set.Notation

## Surrounding context in Mathlib/Order/Preorder/Chain.lean
```lean
-- Mathlib.Order.Preorder.Chain.SuperChain (L54-L57)
def SuperChain (s t : Set α) : Prop

-- Mathlib.Order.Preorder.Chain.IsMaxChain (L58-L62)
def IsMaxChain (s : Set α) : Prop

-- Mathlib.Order.Preorder.Chain.Set (L66-L68)
theorem Set.Subsingleton.isChain (hs : s.Subsingleton) : IsChain r s
```

```lean
theorem IsChain.symm (h : IsChain r s) : IsChain (flip r) s := h.mono' fun _ _ => Or.symm
```

## Edit instruction
Edit `IsChain` so it still compiles and the proof is simplified where possible. Return the full updated `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.Ring.Parity).

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

## Current excerpt (around `Mathlib.Algebra.Ring.Parity.Even`, L84-L86)
Open namespaces: MulOpposite

## Surrounding context in Mathlib/Algebra/Ring/Parity.lean
```lean
-- Mathlib.Algebra.Ring.Parity.even_iff_exists_two_mul (L78-L79)
lemma even_iff_exists_two_mul : Even a ↔ ∃ b, a = 2 * b

-- Mathlib.Algebra.Ring.Parity.even_iff_two_dvd (L80-L83)
lemma even_iff_two_dvd : Even a ↔ 2 ∣ a

-- Mathlib.Algebra.Ring.Parity.Dvd (L87-L88)
lemma Dvd.dvd.even (hab : a ∣ b) (ha : Even a) : Even b
```

```lean
lemma Even.trans_dvd (ha : Even a) (hab : a ∣ b) : Even b := even_iff_two_dvd.2 <| ha.two_dvd.trans hab
```

## Edit instruction
Edit `Even` so it still compiles and the proof is simplified where possible. Return the full updated `Even` 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.Ring.Parity).

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

## Current excerpt (around `Mathlib.Algebra.Ring.Parity.Even`, L84-L86)
Open namespaces: MulOpposite

## Surrounding context in Mathlib/Algebra/Ring/Parity.lean
```lean
-- Mathlib.Algebra.Ring.Parity.even_iff_exists_two_mul (L78-L79)
lemma even_iff_exists_two_mul : Even a ↔ ∃ b, a = 2 * b

-- Mathlib.Algebra.Ring.Parity.even_iff_two_dvd (L80-L83)
lemma even_iff_two_dvd : Even a ↔ 2 ∣ a

-- Mathlib.Algebra.Ring.Parity.Dvd (L87-L88)
lemma Dvd.dvd.even (hab : a ∣ b) (ha : Even a) : Even b
```

```lean
lemma Even.trans_dvd (ha : Even a) (hab : a ∣ b) : Even b := even_iff_two_dvd.2 <| ha.two_dvd.trans hab
```

## Edit instruction
Edit `Even` so it still compiles and the proof is simplified where possible. Return the full updated `Even` 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.Basis).

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

## Current excerpt (around `Mathlib.LinearAlgebra.Matrix.Basis.toMatrix_transpose_apply`, L58-L60)
Open namespaces: Function, LinearMap, Matrix, Module, Set, Submodule

## Surrounding context in Mathlib/LinearAlgebra/Matrix/Basis.lean
```lean
-- Mathlib.LinearAlgebra.Matrix.Basis.toMatrix (L51-L54)
def toMatrix (e : Basis ι R M) (v : ι' → M) : Matrix ι ι' R

-- Mathlib.LinearAlgebra.Matrix.Basis.toMatrix_apply (L55-L57)
theorem toMatrix_apply : e.toMatrix v i j = e.repr (v j) i

-- Mathlib.LinearAlgebra.Matrix.Basis.toMatrix_eq_toMatrix_constr (L61-L66)
theorem toMatrix_eq_toMatrix_constr [Fintype ι] [DecidableEq ι] (v : ι → M) :
    e.toMatrix v = LinearMap.toMatrix e e (e.constr ℕ v)
```

```lean
theorem toMatrix_transpose_apply : (e.toMatrix v)ᵀ j = e.repr (v j) := funext fun _ => rfl
```

## Edit instruction
Edit `toMatrix_transpose_apply` so it still compiles and the proof is simplified where possible. Return the full updated `toMatrix_transpose_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.LinearAlgebra.Matrix.Basis).

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

## Current excerpt (around `Mathlib.LinearAlgebra.Matrix.Basis.toMatrix_transpose_apply`, L58-L60)
Open namespaces: Function, LinearMap, Matrix, Module, Set, Submodule

## Surrounding context in Mathlib/LinearAlgebra/Matrix/Basis.lean
```lean
-- Mathlib.LinearAlgebra.Matrix.Basis.toMatrix (L51-L54)
def toMatrix (e : Basis ι R M) (v : ι' → M) : Matrix ι ι' R

-- Mathlib.LinearAlgebra.Matrix.Basis.toMatrix_apply (L55-L57)
theorem toMatrix_apply : e.toMatrix v i j = e.repr (v j) i

-- Mathlib.LinearAlgebra.Matrix.Basis.toMatrix_eq_toMatrix_constr (L61-L66)
theorem toMatrix_eq_toMatrix_constr [Fintype ι] [DecidableEq ι] (v : ι → M) :
    e.toMatrix v = LinearMap.toMatrix e e (e.constr ℕ v)
```

```lean
theorem toMatrix_transpose_apply : (e.toMatrix v)ᵀ j = e.repr (v j) := funext fun _ => rfl
```

## Edit instruction
Edit `toMatrix_transpose_apply` so it still compiles and the proof is simplified where possible. Return the full updated `toMatrix_transpose_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.Combinatorics.SimpleGraph.Matching).

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

## Current excerpt (around `Mathlib.Combinatorics.SimpleGraph.Matching.IsMatching`, L79-L82)
Open namespaces: Function

## Surrounding context in Mathlib/Combinatorics/SimpleGraph/Matching.lean
```lean
-- Mathlib.Combinatorics.SimpleGraph.Matching.Iso (L201-L209)
lemma Iso.isMatching_map {G' : SimpleGraph W} {M : Subgraph G} (f : G ≃g G') :
    (M.map f.toHom).IsMatching ↔ M.IsMatching where
  mp h

-- Mathlib.Combinatorics.SimpleGraph.Matching.IsPerfectMatching (L210-L211)
def IsPerfectMatching (M : G.Subgraph) : Prop

-- Mathlib.Combinatorics.SimpleGraph.Matching.isMatching_iff_forall_degree (L217-L220)
theorem isMatching_iff_forall_degree [∀ v, Fintype (M.neighborSet v)] :
    M.IsMatching ↔ ∀ v : V, v ∈ M.verts → M.degree v = 1
```

```lean
theorem IsMatching.toEdge.surjective (h : M.IsMatching) : Surjective h.toEdge := by
rintro ⟨⟨x, y⟩, he⟩
  exact ⟨⟨x, M.edge_vert he⟩, h.toEdge_eq_of_adj _ he⟩
```

## Edit instruction
Edit `IsMatching` so it still compiles and the proof is simplified where possible. Return the full updated `IsMatching` 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.Combinatorics.SimpleGraph.Matching).

You are editing a file in `Mathlib/Combinatorics/SimpleGraph/Matching.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Combinatorics.SimpleGraph.Matching.IsMatching`, L79-L82)
Open namespaces: Function

## Surrounding context in Mathlib/Combinatorics/SimpleGraph/Matching.lean
```lean
-- Mathlib.Combinatorics.SimpleGraph.Matching.Iso (L201-L209)
lemma Iso.isMatching_map {G' : SimpleGraph W} {M : Subgraph G} (f : G ≃g G') :
    (M.map f.toHom).IsMatching ↔ M.IsMatching where
  mp h

-- Mathlib.Combinatorics.SimpleGraph.Matching.IsPerfectMatching (L210-L211)
def IsPerfectMatching (M : G.Subgraph) : Prop

-- Mathlib.Combinatorics.SimpleGraph.Matching.isMatching_iff_forall_degree (L217-L220)
theorem isMatching_iff_forall_degree [∀ v, Fintype (M.neighborSet v)] :
    M.IsMatching ↔ ∀ v : V, v ∈ M.verts → M.degree v = 1
```

```lean
theorem IsMatching.toEdge.surjective (h : M.IsMatching) : Surjective h.toEdge := by
rintro ⟨⟨x, y⟩, he⟩
  exact ⟨⟨x, M.edge_vert he⟩, h.toEdge_eq_of_adj _ he⟩
```

## Edit instruction
Edit `IsMatching` so it still compiles and the proof is simplified where possible. Return the full updated `IsMatching` 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.RingTheory.Spectrum.Prime.Topology).

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

## Current excerpt (around `Mathlib.RingTheory.Spectrum.Prime.Topology.discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical`, L308-L322)
Open namespaces: Topology

## Surrounding context in Mathlib/RingTheory/Spectrum/Prime/Topology.lean
```lean
-- Mathlib.RingTheory.Spectrum.Prime.Topology.zariskiTopology (L127-L138)
instance zariskiTopology : TopologicalSpace (PrimeSpectrum R)

-- Mathlib.RingTheory.Spectrum.Prime.Topology.isOpen_iff (L139-L141)
theorem isOpen_iff (U : Set (PrimeSpectrum R)) : IsOpen U ↔ ∃ s, Uᶜ = zeroLocus s

-- Mathlib.RingTheory.Spectrum.Prime.Topology.isClosed_iff_zeroLocus (L142-L144)
theorem isClosed_iff_zeroLocus (Z : Set (PrimeSpectrum R)) : IsClosed Z ↔ ∃ s, Z = zeroLocus s
```

Relevant lemmas available in scope: `hpm`

```lean
theorem discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical :
    letI s := {I : Ideal R | I.IsMaximal}
DiscreteTopology (PrimeSpectrum R) ↔ Finite s ∧ sInf s ≤ nilradical R := by
  rw [discreteTopology_iff_finite_and_krullDimLE_zero, Ring.krullDimLE_zero_iff,
    (equivSubtype R).finite_iff, ← Set.coe_setOf, Set.finite_coe_iff, Set.finite_coe_iff]
  refine ⟨fun h ↦ ⟨h.1.subset fun _ h ↦ h.isPrime, nilradical_eq_sInf R ▸ sInf_le_sInf h.2⟩,
    fun ⟨fin, le⟩ ↦ ?_⟩
  have hpm (I : Ideal R) (hI : I.IsPrime) : I.IsMaximal := by
    replace le := le.trans (nilradical_le_prime I)
    rw [← fin.coe_toFinset, ← Finset.inf_id_eq_sInf, hI.inf_le'] at le
    have ⟨M, hM, hMI⟩ := le
    rw [fin.mem_toFinset] at hM
    rwa [← hM.eq_of_le hI.1 hMI]
  exact ⟨fin.subset hpm, hpm⟩
```

## Edit instruction
Edit `discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical` so it still compiles and the proof is simplified where possible. Return the full updated `discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical` 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.RingTheory.Spectrum.Prime.Topology).

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

## Current excerpt (around `Mathlib.RingTheory.Spectrum.Prime.Topology.discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical`, L308-L322)
Open namespaces: Topology

## Surrounding context in Mathlib/RingTheory/Spectrum/Prime/Topology.lean
```lean
-- Mathlib.RingTheory.Spectrum.Prime.Topology.zariskiTopology (L127-L138)
instance zariskiTopology : TopologicalSpace (PrimeSpectrum R)

-- Mathlib.RingTheory.Spectrum.Prime.Topology.isOpen_iff (L139-L141)
theorem isOpen_iff (U : Set (PrimeSpectrum R)) : IsOpen U ↔ ∃ s, Uᶜ = zeroLocus s

-- Mathlib.RingTheory.Spectrum.Prime.Topology.isClosed_iff_zeroLocus (L142-L144)
theorem isClosed_iff_zeroLocus (Z : Set (PrimeSpectrum R)) : IsClosed Z ↔ ∃ s, Z = zeroLocus s
```

Relevant lemmas available in scope: `hpm`

```lean
theorem discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical :
    letI s := {I : Ideal R | I.IsMaximal}
DiscreteTopology (PrimeSpectrum R) ↔ Finite s ∧ sInf s ≤ nilradical R := by
  rw [discreteTopology_iff_finite_and_krullDimLE_zero, Ring.krullDimLE_zero_iff,
    (equivSubtype R).finite_iff, ← Set.coe_setOf, Set.finite_coe_iff, Set.finite_coe_iff]
  refine ⟨fun h ↦ ⟨h.1.subset fun _ h ↦ h.isPrime, nilradical_eq_sInf R ▸ sInf_le_sInf h.2⟩,
    fun ⟨fin, le⟩ ↦ ?_⟩
  have hpm (I : Ideal R) (hI : I.IsPrime) : I.IsMaximal := by
    replace le := le.trans (nilradical_le_prime I)
    rw [← fin.coe_toFinset, ← Finset.inf_id_eq_sInf, hI.inf_le'] at le
    have ⟨M, hM, hMI⟩ := le
    rw [fin.mem_toFinset] at hM
    rwa [← hM.eq_of_le hI.1 hMI]
  exact ⟨fin.subset hpm, hpm⟩
```

## Edit instruction
Edit `discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical` so it still compiles and the proof is simplified where possible. Return the full updated `discreteTopology_iff_finite_isMaximal_and_sInf_le_nilradical` 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.Angle).

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

## Current excerpt (around `Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.abs_toReal_coe_eq_self_iff`, L542-L546)
## Imports
```lean
import Mathlib.Algebra.Order.Ring.Interval
```

Open namespaces: Real

## Surrounding context in Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.Angle (L31-L37)
def Angle : Type

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.continuous_coe (L47-L50)
theorem continuous_coe : Continuous ((↑) : ℝ → Angle)

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.coeHom (L51-L53)
def coeHom : ℝ →+ Angle
```

```lean
theorem abs_toReal_coe_eq_self_iff {θ : ℝ} : |(θ : Angle).toReal| = θ ↔ 0 ≤ θ ∧ θ ≤ π := ⟨fun h => h ▸ ⟨abs_nonneg _, abs_toReal_le_pi _⟩, fun h =>
    (toReal_coe_eq_self_iff.2 ⟨(Left.neg_neg_iff.2 Real.pi_pos).trans_le h.1, h.2⟩).symm ▸
      abs_eq_self.2 h.1⟩
```

## Edit instruction
Edit `abs_toReal_coe_eq_self_iff` so it still compiles and the proof is simplified where possible. Return the full updated `abs_toReal_coe_eq_self_iff` 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.Angle).

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

## Current excerpt (around `Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.abs_toReal_coe_eq_self_iff`, L542-L546)
## Imports
```lean
import Mathlib.Algebra.Order.Ring.Interval
```

Open namespaces: Real

## Surrounding context in Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.Angle (L31-L37)
def Angle : Type

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.continuous_coe (L47-L50)
theorem continuous_coe : Continuous ((↑) : ℝ → Angle)

-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle.coeHom (L51-L53)
def coeHom : ℝ →+ Angle
```

```lean
theorem abs_toReal_coe_eq_self_iff {θ : ℝ} : |(θ : Angle).toReal| = θ ↔ 0 ≤ θ ∧ θ ≤ π := ⟨fun h => h ▸ ⟨abs_nonneg _, abs_toReal_le_pi _⟩, fun h =>
    (toReal_coe_eq_self_iff.2 ⟨(Left.neg_neg_iff.2 Real.pi_pos).trans_le h.1, h.2⟩).symm ▸
      abs_eq_self.2 h.1⟩
```

## Edit instruction
Edit `abs_toReal_coe_eq_self_iff` so it still compiles and the proof is simplified where possible. Return the full updated `abs_toReal_coe_eq_self_iff` 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.Option.Basic).

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

## Current excerpt (around `Mathlib.Data.Option.Basic.elim_apply`, L225-L228)
```lean
theorem elim_apply {f : γ → α → β} {x : α → β} {i : Option γ} {y : α} :
    i.elim x f y = i.elim (x y) fun j => f j y := by rw [elim_comp fun f : α → β => f y]
open Function in
```

## Edit instruction
Edit `elim_apply` so it still compiles and the proof is simplified where possible. Return the full updated `elim_apply` 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.Option.Basic).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]You are editing a file in `Mathlib/Data/Option/Basic.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Data.Option.Basic.elim_apply`, L225-L228)
```lean
theorem elim_apply {f : γ → α → β} {x : α → β} {i : Option γ} {y : α} :
    i.elim x f y = i.elim (x y) fun j => f j y := by rw [elim_comp fun f : α → β => f y]
open Function in
```

## Edit instruction
Edit `elim_apply` so it still compiles and the proof is simplified where possible. Return the full updated `elim_apply` 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.Algebra.Homology.DerivedCategory.Ext.ExactSequences).

[User]
You are editing a file in `Mathlib/Algebra/Homology/DerivedCategory/Ext/ExactSequences.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.covariantSequence_exact`, L131-L137)
Open namespaces: Opposite, DerivedCategory, Pretriangulated, Pretriangulated.Opposite, ComposableArrows

## Surrounding context in Mathlib/Algebra/Homology/DerivedCategory/Ext/ExactSequences.lean
```lean
-- Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.hom_comp_singleFunctor_map_shift (L40-L47)
lemma hom_comp_singleFunctor_map_shift [HasDerivedCategory.{w'} C]
    {X Y Z : C} {n : ℕ} (x : Ext X Y n) (f : Y ⟶ Z) :
    x.hom ≫ ((DerivedCategory.singleFunctor C 0).map f)⟦(n : ℤ)⟧' =
      (x.comp (mk₀ f) (add_zero n)).hom

-- Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.preadditiveCoyoneda_homologySequenceδ_singleTriangle_apply (L48-L61)
lemma preadditiveCoyoneda_homologySequenceδ_singleTriangle_apply
    [HasDerivedCategory.{w'} C] {X : C} {n₀ : ℕ} (x : Ext X S.X₃ n₀)
    {n₁ : ℕ} (h : n₀ + 1 = n₁) :
    (preadditiveCoyoneda.obj (op ((singleFunctor C 0).obj X))).homologySequenceδ
      hS.singleTriangle n₀ n₁ (by lia) x.hom =
        (x.comp hS.extClass h).hom

-- Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.covariant_sequence_exact₂' (L62-L76)
lemma covariant_sequence_exact₂' (n : ℕ) :
    (ShortComplex.mk (AddCommGrpCat.ofHom ((mk₀ S.f).postcomp X (add_zero n)))
      (AddCommGrpCat.ofHom ((mk₀ S.g).postcomp X (add_zero n))) (by
        ext x
        dsimp
        simp only [comp_assoc_of_third_deg_zero, mk₀_comp_mk₀, ShortComplex.zero, mk₀_zero,
          comp_zero])).Exact
```

```lean
lemma covariantSequence_exact :
    (covariantSequence X hS n₀ n₁ h).Exact := exact_of_δ₀ (covariant_sequence_exact₂' X hS n₀).exact_toComposableArrows
    (exact_of_δ₀ (covariant_sequence_exact₃' X hS n₀ n₁ h).exact_toComposableArrows
      (exact_of_δ₀ (covariant_sequence_exact₁' X hS n₀ n₁ h).exact_toComposableArrows
        (covariant_sequence_exact₂' X hS n₁).exact_toComposableArrows))
```

## Edit instruction
Edit `covariantSequence_exact` so it still compiles and the proof is simplified where possible. Return the full updated `covariantSequence_exact` 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.Homology.DerivedCategory.Ext.ExactSequences).

You are editing a file in `Mathlib/Algebra/Homology/DerivedCategory/Ext/ExactSequences.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.covariantSequence_exact`, L131-L137)
Open namespaces: Opposite, DerivedCategory, Pretriangulated, Pretriangulated.Opposite, ComposableArrows

## Surrounding context in Mathlib/Algebra/Homology/DerivedCategory/Ext/ExactSequences.lean
```lean
-- Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.hom_comp_singleFunctor_map_shift (L40-L47)
lemma hom_comp_singleFunctor_map_shift [HasDerivedCategory.{w'} C]
    {X Y Z : C} {n : ℕ} (x : Ext X Y n) (f : Y ⟶ Z) :
    x.hom ≫ ((DerivedCategory.singleFunctor C 0).map f)⟦(n : ℤ)⟧' =
      (x.comp (mk₀ f) (add_zero n)).hom

-- Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.preadditiveCoyoneda_homologySequenceδ_singleTriangle_apply (L48-L61)
lemma preadditiveCoyoneda_homologySequenceδ_singleTriangle_apply
    [HasDerivedCategory.{w'} C] {X : C} {n₀ : ℕ} (x : Ext X S.X₃ n₀)
    {n₁ : ℕ} (h : n₀ + 1 = n₁) :
    (preadditiveCoyoneda.obj (op ((singleFunctor C 0).obj X))).homologySequenceδ
      hS.singleTriangle n₀ n₁ (by lia) x.hom =
        (x.comp hS.extClass h).hom

-- Mathlib.Algebra.Homology.DerivedCategory.Ext.ExactSequences.covariant_sequence_exact₂' (L62-L76)
lemma covariant_sequence_exact₂' (n : ℕ) :
    (ShortComplex.mk (AddCommGrpCat.ofHom ((mk₀ S.f).postcomp X (add_zero n)))
      (AddCommGrpCat.ofHom ((mk₀ S.g).postcomp X (add_zero n))) (by
        ext x
        dsimp
        simp only [comp_assoc_of_third_deg_zero, mk₀_comp_mk₀, ShortComplex.zero, mk₀_zero,
          comp_zero])).Exact
```

```lean
lemma covariantSequence_exact :
    (covariantSequence X hS n₀ n₁ h).Exact := exact_of_δ₀ (covariant_sequence_exact₂' X hS n₀).exact_toComposableArrows
    (exact_of_δ₀ (covariant_sequence_exact₃' X hS n₀ n₁ h).exact_toComposableArrows
      (exact_of_δ₀ (covariant_sequence_exact₁' X hS n₀ n₁ h).exact_toComposableArrows
        (covariant_sequence_exact₂' X hS n₁).exact_toComposableArrows))
```

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