[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.MeasureTheory.Measure.Restrict).

[User]
Complete the following proof.

```lean
theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s')
    (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s'
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.MeasureTheory.Measure.Restrict).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Complete the following proof.

```lean
theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s')
    (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s'
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.[/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.LinearAlgebra.AffineSpace.AffineSubspace.Basic).

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

```lean
theorem AffineMap.map_vectorSpan {s : Set P₁} :
    Submodule.map f.linear (vectorSpan k s) = vectorSpan k (f '' s)
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.vsub_right_mem_direction_iff_mem (L56-L62)
theorem vsub_right_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p₂ : P) :
    p₂ -ᵥ p ∈ s.direction ↔ p₂ ∈ s := by
rw [mem_direction_iff_eq_vsub_right hp]
  simp

/-- Given a point in an affine subspace, a result of subtracting that point on the left is in the
direction if and only if the other point is in the subspace. -/
```

-- snippet 2
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.vsub_left_mem_direction_iff_mem (L63-L67)
theorem vsub_left_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p₂ : P) :
    p -ᵥ p₂ ∈ s.direction ↔ p₂ ∈ s := by
rw [mem_direction_iff_eq_vsub_left hp]
  simp
```

-- snippet 3
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.toAddTorsor (L68-L83)
instance toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := by
    ext
    apply add_vadd
  vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩
  vsub_vadd' a b := by
    ext
    apply AddTorsor.vsub_vadd'
  vadd_vsub' a b := by
    ext
    apply AddTorsor.vadd_vsub'
```

-- snippet 4
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_vsub (L85-L87)
theorem coe_vsub (s : AffineSubspace k P) [Nonempty s] (a b : s) : ↑(a -ᵥ b) = (a : P) -ᵥ (b : P) :=
rfl
```

-- snippet 5
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_vadd (L89-L98)
theorem coe_vadd (s : AffineSubspace k P) [Nonempty s] (a : s.direction) (b : s) :
    ↑(a +ᵥ b) = (a : V) +ᵥ (b : P) :=
rfl

/-- Embedding of an affine subspace to the ambient space, as an affine map. -/
protected def subtype (s : AffineSubspace k P) [Nonempty s] : s →ᵃ[k] P where
  toFun := (↑)
  linear := s.direction.subtype
  map_vadd' _ _ := rfl
```

-- snippet 6
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subtype_linear (L100-L102)
theorem subtype_linear (s : AffineSubspace k P) [Nonempty s] :
    s.subtype.linear = s.direction.subtype := rfl
```

-- snippet 7
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subtype_apply (L104-L106)
theorem subtype_apply {s : AffineSubspace k P} [Nonempty s] (p : s) : s.subtype p = p :=
rfl
```

-- snippet 8
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subtype_injective (L107-L109)
theorem subtype_injective (s : AffineSubspace k P) [Nonempty s] : Function.Injective s.subtype :=
Subtype.coe_injective
```

-- snippet 9
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_subtype (L111-L115)
theorem coe_subtype (s : AffineSubspace k P) [Nonempty s] : (s.subtype : s → P) = ((↑) : s → P) :=
rfl

end AffineSubspace
```

-- snippet 10
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_affineSpan_singleton (L137-L143)
theorem coe_affineSpan_singleton (p : P) : (affineSpan k ({p} : Set P) : Set P) = {p} := by
ext x
  rw [mem_coe, ← vsub_right_mem_direction_iff_mem (mem_affineSpan k (Set.mem_singleton p)) _,
    direction_affineSpan]
  simp

/-- A point is in the affine span of a single point if and only if they are equal. -/
```

-- snippet 11
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.mem_affineSpan_singleton (L145-L147)
theorem mem_affineSpan_singleton : p₁ ∈ affineSpan k ({p₂} : Set P) ↔ p₁ = p₂ := by
simp [← mem_coe]
```

-- snippet 12
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.unique_affineSpan_singleton (L148-L151)
instance unique_affineSpan_singleton (p : P) : Unique (affineSpan k {p}) where
  default := ⟨p, mem_affineSpan _ (Set.mem_singleton _)⟩
uniq := fun x ↦ Subtype.ext ((mem_affineSpan_singleton _ _).1 x.property)
```

-- snippet 13
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.preimage_coe_affineSpan_singleton (L153-L160)
theorem preimage_coe_affineSpan_singleton (x : P) :
    ((↑) : affineSpan k ({x} : Set P) → P) ⁻¹' {x} = univ :=
eq_univ_of_forall fun y => (AffineSubspace.mem_affineSpan_singleton _ _).1 y.2

variable (P)

/-- The top affine subspace is linearly equivalent to the affine space.
This is the affine version of `Submodule.topEquiv`. -/
```

-- snippet 14
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.topEquiv (L162-L168)
def topEquiv : (⊤ : AffineSubspace k P) ≃ᵃ[k] P where
  toEquiv := Equiv.Set.univ P
linear := .ofEq _ _ (direction_top _ _ _) ≪≫ₗ Submodule.topEquiv
  map_vadd' _ _ := rfl

variable {k V P}
```

-- snippet 15
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subsingleton_of_subsingleton_span_eq_top (L169-L176)
theorem subsingleton_of_subsingleton_span_eq_top {s : Set P} (h₁ : s.Subsingleton)
    (h₂ : affineSpan k s = ⊤) : Subsingleton P := by
obtain ⟨p, hp⟩ := AffineSubspace.nonempty_of_affineSpan_eq_top k V P h₂
  have : s = {p} := Subset.antisymm (fun q hq => h₁ hq hp) (by simp [hp])
  rw [this, AffineSubspace.ext_iff, AffineSubspace.coe_affineSpan_singleton,
    AffineSubspace.top_coe, eq_comm, ← subsingleton_iff_singleton (mem_univ _)] at h₂
  exact subsingleton_of_univ_subsingleton h₂
```

-- snippet 16
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_mk' (L153-L155)
theorem coe_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : ⇑(mk' e e' p h) = e :=
rfl
```

-- snippet 17
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toEquiv_inj (L132-L134)
theorem toEquiv_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.toEquiv = e'.toEquiv ↔ e = e' :=
toEquiv_injective.eq_iff
```

-- snippet 18
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.map_vadd (L96-L98)
theorem map_vadd (e : P₁ ≃ᵃ[k] P₂) (p : P₁) (v : V₁) : e (v +ᵥ p) = e.linear v +ᵥ e p :=
e.map_vadd' p v
```

-- snippet 19
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.linear_toAffineMap (L74-L76)
theorem linear_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : e.toAffineMap.linear = e.linear :=
rfl
```

-- snippet 20
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coeFn_injective (L122-L124)
theorem coeFn_injective : @Injective (P₁ ≃ᵃ[k] P₂) (P₁ → P₂) (⇑) :=
DFunLike.coe_injective
```

-- snippet 21
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_coe (L111-L113)
theorem coe_coe (e : P₁ ≃ᵃ[k] P₂) : ((e : P₁ →ᵃ[k] P₂) : P₁ → P₂) = e :=
rfl
```

-- snippet 22
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_symm_toEquiv (L175-L177)
theorem coe_symm_toEquiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.toEquiv.symm = e.symm :=
rfl
```

-- snippet 23
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_toAffineMap (L107-L109)
theorem coe_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : (e.toAffineMap : P₁ → P₂) = (e : P₁ → P₂) :=
rfl
```

-- snippet 24
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.mk' (L143-L151)
def mk' (e : P₁ → P₂) (e' : V₁ ≃ₗ[k] V₂) (p : P₁) (h : ∀ p' : P₁, e p' = e' (p' -ᵥ p) +ᵥ e p) :
    P₁ ≃ᵃ[k] P₂ where
  toFun := e
invFun := fun q' : P₂ => e'.symm (q' -ᵥ e p) +ᵥ p
  left_inv p' := by simp [h p', vadd_vsub, vsub_vadd]
  right_inv q' := by simp [h (e'.symm (q' -ᵥ e p) +ᵥ p), vadd_vsub, vsub_vadd]
  linear := e'
  map_vadd' p' v := by simp [h p', h (v +ᵥ p'), vadd_vsub_assoc, vadd_vadd]
```

-- snippet 25
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_linear (L115-L117)
theorem coe_linear (e : P₁ ≃ᵃ[k] P₂) : (e : P₁ →ᵃ[k] P₂).linear = e.linear :=
rfl
```

-- snippet 26
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_mk (L136-L142)
theorem coe_mk (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (h) : ((⟨e, e', h⟩ : P₁ ≃ᵃ[k] P₂) : P₁ → P₂) = e :=
rfl

/-- Construct an affine equivalence by verifying the relation between the map and its linear part at
one base point. Namely, this function takes a map `e : P₁ → P₂`, a linear equivalence
`e' : V₁ ≃ₗ[k] V₂`, and a point `p` such that for any other point `p'` we have
`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/
```

-- snippet 27
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.equivLike (L85-L91)
instance equivLike : EquivLike (P₁ ≃ᵃ[k] P₂) P₁ P₂ where
  coe f := f.toFun
inv f := f.invFun
  left_inv f := f.left_inv
  right_inv f := f.right_inv
  coe_injective' _ _ h _ := toAffineMap_injective (DFunLike.coe_injective h)
```

-- snippet 28
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toEquiv_symm (L171-L173)
theorem toEquiv_symm (e : P₁ ≃ᵃ[k] P₂) : e.symm.toEquiv = e.toEquiv.symm :=
rfl
```

-- snippet 29
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.symm (L162-L169)
def symm (e : P₁ ≃ᵃ[k] P₂) : P₂ ≃ᵃ[k] P₁ where
  toEquiv := e.toEquiv.symm
linear := e.linear.symm
  map_vadd' p v :=
    e.toEquiv.symm.apply_eq_iff_eq_symm_apply.2 <| by
      rw [Equiv.symm_symm, e.map_vadd' ((Equiv.symm e.toEquiv) p) ((LinearEquiv.symm e.linear) v),
        LinearEquiv.apply_symm_apply, Equiv.apply_symm_apply]
```

-- snippet 30
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap (L65-L67)
def toAffineMap (e : P₁ ≃ᵃ[k] P₂) : P₁ →ᵃ[k] P₂ :=
{ e with }
```

-- snippet 31
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_toEquiv (L100-L102)
theorem coe_toEquiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.toEquiv = e :=
rfl
```

-- snippet 32
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.Simps (L183-L186)
def Simps.apply (e : P₁ ≃ᵃ[k] P₂) : P₁ → P₂ :=
e

/-- See Note [custom simps projection] -/
```

-- snippet 33
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.linear_symm (L179-L182)
theorem linear_symm (e : P₁ ≃ᵃ[k] P₂) : e.symm.linear = e.linear.symm :=
rfl

/-- See Note [custom simps projection] -/
```

-- snippet 34
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap_injective (L77-L80)
theorem toAffineMap_injective : Injective (toAffineMap : (P₁ ≃ᵃ[k] P₂) → P₁ →ᵃ[k] P₂) := by
rintro ⟨e, el, h⟩ ⟨e', el', h'⟩ H
  simp_all
```

-- snippet 35
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap_mk (L69-L72)
theorem toAffineMap_mk (f : P₁ ≃ P₂) (f' : V₁ ≃ₗ[k] V₂) (h) :
    toAffineMap (mk f f' h) = ⟨f, f', h⟩ :=
rfl
```

-- snippet 36
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toEquiv_injective (L128-L130)
theorem toEquiv_injective : Injective (toEquiv : (P₁ ≃ᵃ[k] P₂) → P₁ ≃ P₂) := fun _ _ H =>
ext <| Equiv.ext_iff.1 H
```

-- snippet 37
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap_inj (L82-L84)
theorem toAffineMap_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.toAffineMap = e'.toAffineMap ↔ e = e' :=
toAffineMap_injective.eq_iff
```

-- snippet 38
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coeFn_inj (L126-L127)
theorem coeFn_inj {e e' : P₁ ≃ᵃ[k] P₂} : (e : P₁ → P₂) = e' ↔ e = e' := by simp
```

-- snippet 39
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.ext (L119-L121)
theorem ext {e e' : P₁ ≃ᵃ[k] P₂} (h : ∀ x, e x = e' x) : e = e' :=
DFunLike.ext _ _ h
```

-- snippet 40
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.linear_mk' (L157-L160)
theorem linear_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : (mk' e e' p h).linear = e' :=
rfl

/-- Inverse of an affine equivalence as an affine equivalence. -/
```

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

```lean
theorem AffineMap.map_vectorSpan {s : Set P₁} :
    Submodule.map f.linear (vectorSpan k s) = vectorSpan k (f '' s)
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.vsub_right_mem_direction_iff_mem (L56-L62)
theorem vsub_right_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p₂ : P) :
    p₂ -ᵥ p ∈ s.direction ↔ p₂ ∈ s := by
rw [mem_direction_iff_eq_vsub_right hp]
  simp

/-- Given a point in an affine subspace, a result of subtracting that point on the left is in the
direction if and only if the other point is in the subspace. -/
```

-- snippet 2
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.vsub_left_mem_direction_iff_mem (L63-L67)
theorem vsub_left_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p₂ : P) :
    p -ᵥ p₂ ∈ s.direction ↔ p₂ ∈ s := by
rw [mem_direction_iff_eq_vsub_left hp]
  simp
```

-- snippet 3
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.toAddTorsor (L68-L83)
instance toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := by
    ext
    apply add_vadd
  vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩
  vsub_vadd' a b := by
    ext
    apply AddTorsor.vsub_vadd'
  vadd_vsub' a b := by
    ext
    apply AddTorsor.vadd_vsub'
```

-- snippet 4
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_vsub (L85-L87)
theorem coe_vsub (s : AffineSubspace k P) [Nonempty s] (a b : s) : ↑(a -ᵥ b) = (a : P) -ᵥ (b : P) :=
rfl
```

-- snippet 5
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_vadd (L89-L98)
theorem coe_vadd (s : AffineSubspace k P) [Nonempty s] (a : s.direction) (b : s) :
    ↑(a +ᵥ b) = (a : V) +ᵥ (b : P) :=
rfl

/-- Embedding of an affine subspace to the ambient space, as an affine map. -/
protected def subtype (s : AffineSubspace k P) [Nonempty s] : s →ᵃ[k] P where
  toFun := (↑)
  linear := s.direction.subtype
  map_vadd' _ _ := rfl
```

-- snippet 6
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subtype_linear (L100-L102)
theorem subtype_linear (s : AffineSubspace k P) [Nonempty s] :
    s.subtype.linear = s.direction.subtype := rfl
```

-- snippet 7
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subtype_apply (L104-L106)
theorem subtype_apply {s : AffineSubspace k P} [Nonempty s] (p : s) : s.subtype p = p :=
rfl
```

-- snippet 8
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subtype_injective (L107-L109)
theorem subtype_injective (s : AffineSubspace k P) [Nonempty s] : Function.Injective s.subtype :=
Subtype.coe_injective
```

-- snippet 9
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_subtype (L111-L115)
theorem coe_subtype (s : AffineSubspace k P) [Nonempty s] : (s.subtype : s → P) = ((↑) : s → P) :=
rfl

end AffineSubspace
```

-- snippet 10
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.coe_affineSpan_singleton (L137-L143)
theorem coe_affineSpan_singleton (p : P) : (affineSpan k ({p} : Set P) : Set P) = {p} := by
ext x
  rw [mem_coe, ← vsub_right_mem_direction_iff_mem (mem_affineSpan k (Set.mem_singleton p)) _,
    direction_affineSpan]
  simp

/-- A point is in the affine span of a single point if and only if they are equal. -/
```

-- snippet 11
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.mem_affineSpan_singleton (L145-L147)
theorem mem_affineSpan_singleton : p₁ ∈ affineSpan k ({p₂} : Set P) ↔ p₁ = p₂ := by
simp [← mem_coe]
```

-- snippet 12
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.unique_affineSpan_singleton (L148-L151)
instance unique_affineSpan_singleton (p : P) : Unique (affineSpan k {p}) where
  default := ⟨p, mem_affineSpan _ (Set.mem_singleton _)⟩
uniq := fun x ↦ Subtype.ext ((mem_affineSpan_singleton _ _).1 x.property)
```

-- snippet 13
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.preimage_coe_affineSpan_singleton (L153-L160)
theorem preimage_coe_affineSpan_singleton (x : P) :
    ((↑) : affineSpan k ({x} : Set P) → P) ⁻¹' {x} = univ :=
eq_univ_of_forall fun y => (AffineSubspace.mem_affineSpan_singleton _ _).1 y.2

variable (P)

/-- The top affine subspace is linearly equivalent to the affine space.
This is the affine version of `Submodule.topEquiv`. -/
```

-- snippet 14
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.topEquiv (L162-L168)
def topEquiv : (⊤ : AffineSubspace k P) ≃ᵃ[k] P where
  toEquiv := Equiv.Set.univ P
linear := .ofEq _ _ (direction_top _ _ _) ≪≫ₗ Submodule.topEquiv
  map_vadd' _ _ := rfl

variable {k V P}
```

-- snippet 15
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic.subsingleton_of_subsingleton_span_eq_top (L169-L176)
theorem subsingleton_of_subsingleton_span_eq_top {s : Set P} (h₁ : s.Subsingleton)
    (h₂ : affineSpan k s = ⊤) : Subsingleton P := by
obtain ⟨p, hp⟩ := AffineSubspace.nonempty_of_affineSpan_eq_top k V P h₂
  have : s = {p} := Subset.antisymm (fun q hq => h₁ hq hp) (by simp [hp])
  rw [this, AffineSubspace.ext_iff, AffineSubspace.coe_affineSpan_singleton,
    AffineSubspace.top_coe, eq_comm, ← subsingleton_iff_singleton (mem_univ _)] at h₂
  exact subsingleton_of_univ_subsingleton h₂
```

-- snippet 16
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_mk' (L153-L155)
theorem coe_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : ⇑(mk' e e' p h) = e :=
rfl
```

-- snippet 17
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toEquiv_inj (L132-L134)
theorem toEquiv_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.toEquiv = e'.toEquiv ↔ e = e' :=
toEquiv_injective.eq_iff
```

-- snippet 18
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.map_vadd (L96-L98)
theorem map_vadd (e : P₁ ≃ᵃ[k] P₂) (p : P₁) (v : V₁) : e (v +ᵥ p) = e.linear v +ᵥ e p :=
e.map_vadd' p v
```

-- snippet 19
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.linear_toAffineMap (L74-L76)
theorem linear_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : e.toAffineMap.linear = e.linear :=
rfl
```

-- snippet 20
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coeFn_injective (L122-L124)
theorem coeFn_injective : @Injective (P₁ ≃ᵃ[k] P₂) (P₁ → P₂) (⇑) :=
DFunLike.coe_injective
```

-- snippet 21
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_coe (L111-L113)
theorem coe_coe (e : P₁ ≃ᵃ[k] P₂) : ((e : P₁ →ᵃ[k] P₂) : P₁ → P₂) = e :=
rfl
```

-- snippet 22
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_symm_toEquiv (L175-L177)
theorem coe_symm_toEquiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.toEquiv.symm = e.symm :=
rfl
```

-- snippet 23
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_toAffineMap (L107-L109)
theorem coe_toAffineMap (e : P₁ ≃ᵃ[k] P₂) : (e.toAffineMap : P₁ → P₂) = (e : P₁ → P₂) :=
rfl
```

-- snippet 24
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.mk' (L143-L151)
def mk' (e : P₁ → P₂) (e' : V₁ ≃ₗ[k] V₂) (p : P₁) (h : ∀ p' : P₁, e p' = e' (p' -ᵥ p) +ᵥ e p) :
    P₁ ≃ᵃ[k] P₂ where
  toFun := e
invFun := fun q' : P₂ => e'.symm (q' -ᵥ e p) +ᵥ p
  left_inv p' := by simp [h p', vadd_vsub, vsub_vadd]
  right_inv q' := by simp [h (e'.symm (q' -ᵥ e p) +ᵥ p), vadd_vsub, vsub_vadd]
  linear := e'
  map_vadd' p' v := by simp [h p', h (v +ᵥ p'), vadd_vsub_assoc, vadd_vadd]
```

-- snippet 25
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_linear (L115-L117)
theorem coe_linear (e : P₁ ≃ᵃ[k] P₂) : (e : P₁ →ᵃ[k] P₂).linear = e.linear :=
rfl
```

-- snippet 26
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_mk (L136-L142)
theorem coe_mk (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (h) : ((⟨e, e', h⟩ : P₁ ≃ᵃ[k] P₂) : P₁ → P₂) = e :=
rfl

/-- Construct an affine equivalence by verifying the relation between the map and its linear part at
one base point. Namely, this function takes a map `e : P₁ → P₂`, a linear equivalence
`e' : V₁ ≃ₗ[k] V₂`, and a point `p` such that for any other point `p'` we have
`e p' = e' (p' -ᵥ p) +ᵥ e p`. -/
```

-- snippet 27
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.equivLike (L85-L91)
instance equivLike : EquivLike (P₁ ≃ᵃ[k] P₂) P₁ P₂ where
  coe f := f.toFun
inv f := f.invFun
  left_inv f := f.left_inv
  right_inv f := f.right_inv
  coe_injective' _ _ h _ := toAffineMap_injective (DFunLike.coe_injective h)
```

-- snippet 28
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toEquiv_symm (L171-L173)
theorem toEquiv_symm (e : P₁ ≃ᵃ[k] P₂) : e.symm.toEquiv = e.toEquiv.symm :=
rfl
```

-- snippet 29
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.symm (L162-L169)
def symm (e : P₁ ≃ᵃ[k] P₂) : P₂ ≃ᵃ[k] P₁ where
  toEquiv := e.toEquiv.symm
linear := e.linear.symm
  map_vadd' p v :=
    e.toEquiv.symm.apply_eq_iff_eq_symm_apply.2 <| by
      rw [Equiv.symm_symm, e.map_vadd' ((Equiv.symm e.toEquiv) p) ((LinearEquiv.symm e.linear) v),
        LinearEquiv.apply_symm_apply, Equiv.apply_symm_apply]
```

-- snippet 30
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap (L65-L67)
def toAffineMap (e : P₁ ≃ᵃ[k] P₂) : P₁ →ᵃ[k] P₂ :=
{ e with }
```

-- snippet 31
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coe_toEquiv (L100-L102)
theorem coe_toEquiv (e : P₁ ≃ᵃ[k] P₂) : ⇑e.toEquiv = e :=
rfl
```

-- snippet 32
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.Simps (L183-L186)
def Simps.apply (e : P₁ ≃ᵃ[k] P₂) : P₁ → P₂ :=
e

/-- See Note [custom simps projection] -/
```

-- snippet 33
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.linear_symm (L179-L182)
theorem linear_symm (e : P₁ ≃ᵃ[k] P₂) : e.symm.linear = e.linear.symm :=
rfl

/-- See Note [custom simps projection] -/
```

-- snippet 34
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap_injective (L77-L80)
theorem toAffineMap_injective : Injective (toAffineMap : (P₁ ≃ᵃ[k] P₂) → P₁ →ᵃ[k] P₂) := by
rintro ⟨e, el, h⟩ ⟨e', el', h'⟩ H
  simp_all
```

-- snippet 35
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap_mk (L69-L72)
theorem toAffineMap_mk (f : P₁ ≃ P₂) (f' : V₁ ≃ₗ[k] V₂) (h) :
    toAffineMap (mk f f' h) = ⟨f, f', h⟩ :=
rfl
```

-- snippet 36
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toEquiv_injective (L128-L130)
theorem toEquiv_injective : Injective (toEquiv : (P₁ ≃ᵃ[k] P₂) → P₁ ≃ P₂) := fun _ _ H =>
ext <| Equiv.ext_iff.1 H
```

-- snippet 37
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.toAffineMap_inj (L82-L84)
theorem toAffineMap_inj {e e' : P₁ ≃ᵃ[k] P₂} : e.toAffineMap = e'.toAffineMap ↔ e = e' :=
toAffineMap_injective.eq_iff
```

-- snippet 38
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.coeFn_inj (L126-L127)
theorem coeFn_inj {e e' : P₁ ≃ᵃ[k] P₂} : (e : P₁ → P₂) = e' ↔ e = e' := by simp
```

-- snippet 39
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.ext (L119-L121)
theorem ext {e e' : P₁ ≃ᵃ[k] P₂} (h : ∀ x, e x = e' x) : e = e' :=
DFunLike.ext _ _ h
```

-- snippet 40
```lean
-- Mathlib.LinearAlgebra.AffineSpace.AffineEquiv.linear_mk' (L157-L160)
theorem linear_mk' (e : P₁ ≃ P₂) (e' : V₁ ≃ₗ[k] V₂) (p h) : (mk' e e' p h).linear = e' :=
rfl

/-- Inverse of an affine equivalence as an affine equivalence. -/
```
[/INST]


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

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

```lean
theorem cos_arcsin_nonneg (x : ℝ) : 0 ≤ cos (arcsin x)
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_mem_Icc (L36-L39)
theorem arcsin_mem_Icc (x : ℝ) : arcsin x ∈ Icc (-(π / 2)) (π / 2) :=
Subtype.coe_prop _

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 2
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.range_arcsin (L41-L44)
theorem range_arcsin : range arcsin = Icc (-(π / 2)) (π / 2) := by
rw [arcsin, range_comp Subtype.val]
  simp [Icc]
```

-- snippet 3
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_le_pi_div_two (L45-L47)
theorem arcsin_le_pi_div_two (x : ℝ) : arcsin x ≤ π / 2 :=
(arcsin_mem_Icc x).2
```

-- snippet 4
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.neg_pi_div_two_le_arcsin (L48-L50)
theorem neg_pi_div_two_le_arcsin (x : ℝ) : -(π / 2) ≤ arcsin x :=
(arcsin_mem_Icc x).1
```

-- snippet 5
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_projIcc (L51-L55)
theorem arcsin_projIcc (x : ℝ) :
    arcsin (projIcc (-1) 1 (neg_le_self zero_le_one) x) = arcsin x := by
rw [arcsin, Function.comp_apply, IccExtend_val, Function.comp_apply, IccExtend,
        Function.comp_apply]
```

-- snippet 6
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.sin_arcsin' (L56-L59)
theorem sin_arcsin' {x : ℝ} (hx : x ∈ Icc (-1 : ℝ) 1) : sin (arcsin x) = x := by
simpa [arcsin, IccExtend_of_mem _ _ hx, -OrderIso.apply_symm_apply] using
    Subtype.ext_iff.1 (sinOrderIso.apply_symm_apply ⟨x, hx⟩)
```

-- snippet 7
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.sin_arcsin (L60-L62)
theorem sin_arcsin {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : sin (arcsin x) = x :=
sin_arcsin' ⟨hx₁, hx₂⟩
```

-- snippet 8
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_sin' (L63-L65)
theorem arcsin_sin' {x : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) : arcsin (sin x) = x :=
injOn_sin (arcsin_mem_Icc _) hx <| by rw [sin_arcsin (neg_one_le_sin _) (sin_le_one _)]
```

-- snippet 9
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_sin (L66-L68)
theorem arcsin_sin {x : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) : arcsin (sin x) = x :=
arcsin_sin' ⟨hx₁, hx₂⟩
```

-- snippet 10
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.strictMonoOn_arcsin (L69-L72)
theorem strictMonoOn_arcsin : StrictMonoOn arcsin (Icc (-1) 1) :=
(Subtype.strictMono_coe _).comp_strictMonoOn <|
    sinOrderIso.symm.strictMono.strictMonoOn_IccExtend _
```

-- snippet 11
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_lt_arcsin (L74-L77)
theorem arcsin_lt_arcsin {x y : ℝ} (hx : -1 ≤ x) (hlt : x < y) (hy : y ≤ 1) :
    arcsin x < arcsin y :=
strictMonoOn_arcsin ⟨hx, hlt.le.trans hy⟩ ⟨hx.trans hlt.le, hy⟩ hlt
```

-- snippet 12
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.monotone_arcsin (L78-L80)
theorem monotone_arcsin : Monotone arcsin :=
(Subtype.mono_coe _).comp <| sinOrderIso.symm.monotone.IccExtend _
```

-- snippet 13
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_le_arcsin (L82-L83)
theorem arcsin_le_arcsin {x y : ℝ} (h : x ≤ y) : arcsin x ≤ arcsin y := monotone_arcsin h
```

-- snippet 14
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.injOn_arcsin (L84-L86)
theorem injOn_arcsin : InjOn arcsin (Icc (-1) 1) :=
strictMonoOn_arcsin.injOn
```

-- snippet 15
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_inj (L87-L90)
theorem arcsin_inj {x y : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) (hy₁ : -1 ≤ y) (hy₂ : y ≤ 1) :
    arcsin x = arcsin y ↔ x = y :=
injOn_arcsin.eq_iff ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩
```

-- snippet 16
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.tanh_arcosh (L89-L92)
theorem tanh_arcosh {x : ℝ} (hx : 1 ≤ x) : tanh (arcosh x) = √(x ^ 2 - 1) / x := by
rw [tanh_eq_sinh_div_cosh, sinh_arcosh hx, cosh_arcosh hx]

/-- `arcosh` is the left inverse of `cosh` over $[0, ∞)$. -/
```

-- snippet 17
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.hasStrictDerivAt_arcosh (L153-L159)
theorem hasStrictDerivAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) :
    HasStrictDerivAt arcosh (√(x ^ 2 - 1))⁻¹ x := by
rw [← sinh_arcosh (le_of_lt hx)]
  refine coshOpenPartialHomeomorph.hasStrictDerivAt_symm hx ?_ (hasStrictDerivAt_cosh _)
  rw [ne_eq, sinh_eq_zero]
  exact ne_of_gt (arcosh_pos hx)
```

-- snippet 18
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_lt_arcosh (L119-L122)
theorem arcosh_lt_arcosh {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : arcosh x < arcosh y ↔ x < y :=
strictMonoOn_arcosh.lt_iff_lt hx hy

/-- `Real.cosh` as a `PartialEquiv` from $[0, ∞)$ to $[1, ∞)$. -/
```

-- snippet 19
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.hasDerivAt_arcosh (L160-L162)
theorem hasDerivAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) : HasDerivAt arcosh (√(x ^ 2 - 1))⁻¹ x :=
(hasStrictDerivAt_arcosh hx).hasDerivAt
```

-- snippet 20
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.contDiffOn_arcosh (L175-L178)
theorem contDiffOn_arcosh {n : WithTop ℕ∞} : ContDiffOn ℝ n arcosh (Ioi 1) := fun _ hx =>
(contDiffAt_arcosh hx).contDiffWithinAt

/-- The function `Real.arcosh` is real analytic. -/
```

-- snippet 21
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.continuousOn_arcosh (L133-L138)
theorem continuousOn_arcosh : ContinuousOn arcosh (Ici 1) :=
have {x : ℝ} (hx : x ∈ Ici 1) : 0 < x + √(x ^ 2 - 1) :=
    add_pos_of_pos_of_nonneg (show 0 < x by grind) (sqrt_nonneg _)
  continuousOn_log.comp (by fun_prop) (by grind [MapsTo])

/-- `Real.cosh` as an `OpenPartialHomeomorph` from $(0, ∞)$ to $(1, ∞)$. -/
```

-- snippet 22
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_eq_zero_iff (L81-L84)
theorem arcosh_eq_zero_iff {x : ℝ} (hx : 1 ≤ x) : arcosh x = 0 ↔ x = 1 := by
rw [← exp_injective.eq_iff, exp_arcosh hx, exp_zero]
  grind
```

-- snippet 23
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_le_arcosh (L115-L118)
theorem arcosh_le_arcosh {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : arcosh x ≤ arcosh y ↔ x ≤ y :=
strictMonoOn_arcosh.le_iff_le hx hy

/-- This holds for `0 < x, y ≤ 1` due to junk values. -/
```

-- snippet 24
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.differentiableOn_arcosh (L166-L168)
theorem differentiableOn_arcosh : DifferentiableOn ℝ arcosh (Ioi 1) := fun _ hx =>
(differentiableAt_arcosh hx).differentiableWithinAt
```

-- snippet 25
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.analyticWithinAt_arcosh (L184-L188)
lemma analyticWithinAt_arcosh {s : Set ℝ} {x : ℝ} (hx : x ∈ Ioi 1) :
    AnalyticWithinAt ℝ arcosh s x :=
(contDiffAt_arcosh hx).contDiffWithinAt.analyticWithinAt

/-- The function `Real.arcosh` is real analytic. -/
```

-- snippet 26
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_zero (L69-L70)
theorem arcosh_zero : arcosh 1 = 0 := by simp [arcosh]
```

-- snippet 27
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.sinh_arcosh (L85-L88)
theorem sinh_arcosh {x : ℝ} (hx : 1 ≤ x) : sinh (arcosh x) = √(x ^ 2 - 1) := by
rw [arcosh, sinh_eq, exp_neg, exp_log (by positivity), add_sqrt_self_sq_sub_one_inv hx]
  ring
```

-- snippet 28
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.exp_arcosh (L64-L67)
theorem exp_arcosh {x : ℝ} (hx : 1 ≤ x) : exp (arcosh x) = x + √(x ^ 2 - 1) := by
apply exp_log
  positivity
```

-- snippet 29
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.strictMonoOn_arcosh (L110-L114)
theorem strictMonoOn_arcosh : StrictMonoOn arcosh (Ioi 0) := by
refine strictMonoOn_log.comp ?_ fun x (hx : 0 < x) ↦ show 0 < x + √(x ^ 2 - 1) by positivity
  exact strictMonoOn_id.add_monotone fun x (hx : 0 < x) y (hy : 0 < y) hxy ↦ by gcongr

/-- This holds for `0 < x, y ≤ 1` due to junk values. -/
```

-- snippet 30
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.coshOpenPartialHomeomorph (L139-L152)
def coshOpenPartialHomeomorph : OpenPartialHomeomorph ℝ ℝ where
  toFun := cosh
invFun := arcosh
  source := Ioi 0
  target := Ioi 1
  map_source' _ hr := one_lt_cosh.mpr (ne_of_lt hr).symm
  map_target' _ hr := arcosh_pos hr
  left_inv' _ hr := arcosh_cosh (le_of_lt hr)
  right_inv' _ hr := cosh_arcosh (le_of_lt hr)
  open_source := isOpen_Ioi
  open_target := isOpen_Ioi
  continuousOn_toFun := by fun_prop
  continuousOn_invFun := continuousOn_arcosh.mono Ioi_subset_Ici_self
```

-- snippet 31
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_pos (L103-L109)
theorem arcosh_pos {x : ℝ} (hx : 1 < x) : 0 < arcosh x := by
apply log_pos
  calc
    1 < x + 0 := by simpa
    _ ≤ x + √(x ^ 2 - 1) := by gcongr; positivity

/-- This holds for `Ioi 0` instead of only `Ici 1` due to junk values. -/
```

-- snippet 32
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.add_sqrt_self_sq_sub_one_inv (L71-L76)
lemma add_sqrt_self_sq_sub_one_inv {x : ℝ} (hx : 1 ≤ x) :
    (x + √(x ^ 2 - 1))⁻¹ = x - √(x ^ 2 - 1) := by
apply inv_eq_of_mul_eq_one_right
  rw [← pow_two_sub_pow_two, sq_sqrt (sub_nonneg_of_le (one_le_pow₀ hx)), sub_sub_cancel]

/-- `arcosh` is the right inverse of `cosh` over $[1, ∞)$. -/
```

-- snippet 33
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_nonneg (L97-L102)
theorem arcosh_nonneg {x : ℝ} (hx : 1 ≤ x) : 0 ≤ arcosh x := by
apply log_nonneg
  calc
    1 ≤ x + 0 := by simpa
    _ ≤ x + √(x ^ 2 - 1) := by gcongr; positivity
```

-- snippet 34
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.contDiffAt_arcosh (L169-L174)
theorem contDiffAt_arcosh {n : WithTop ℕ∞} {x : ℝ} (hx : x ∈ Ioi 1) : ContDiffAt ℝ n arcosh x := by
refine coshOpenPartialHomeomorph.contDiffAt_symm_deriv ?_ hx (hasDerivAt_cosh _)
    contDiff_cosh.contDiffAt
  rw [ne_eq, sinh_eq_zero]
  exact (arcosh_pos hx).ne'
```

-- snippet 35
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_cosh (L93-L96)
theorem arcosh_cosh {x : ℝ} (hx : 0 ≤ x) : arcosh (cosh x) = x := by
rw [arcosh, ← exp_eq_exp, exp_log (by positivity), ← eq_sub_iff_add_eq', exp_sub_cosh,
    ← sq_eq_sq₀ (sqrt_nonneg _) (sinh_nonneg_iff.mpr hx), ← sinh_sq, sq_sqrt (pow_two_nonneg _)]
```

-- snippet 36
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.cosh_arcosh (L77-L80)
theorem cosh_arcosh {x : ℝ} (hx : 1 ≤ x) : cosh (arcosh x) = x := by
rw [arcosh, cosh_eq, exp_neg, exp_log (by positivity), add_sqrt_self_sq_sub_one_inv hx]
  ring
```

-- snippet 37
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh (L61-L63)
def arcosh (x : ℝ) :=
log (x + √(x ^ 2 - 1))
```

-- snippet 38
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.differentiableAt_arcosh (L163-L165)
theorem differentiableAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) : DifferentiableAt ℝ arcosh x :=
(hasDerivAt_arcosh hx).differentiableAt
```

-- snippet 39
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.analyticAt_arcosh (L180-L183)
lemma analyticAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) : AnalyticAt ℝ arcosh x :=
(contDiffAt_arcosh hx).analyticAt

/-- The function `Real.arcosh` is real analytic. -/
```

-- snippet 40
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.coshPartialEquiv (L123-L132)
def coshPartialEquiv : PartialEquiv ℝ ℝ where
  toFun := cosh
invFun := arcosh
  source := Ici 0
  target := Ici 1
  map_source' r _ := one_le_cosh r
  map_target' _ hr := arcosh_nonneg hr
  left_inv' _ hr := arcosh_cosh hr
  right_inv' _ hr := cosh_arcosh hr
```

<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.Analysis.SpecialFunctions.Trigonometric.Inverse).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem cos_arcsin_nonneg (x : ℝ) : 0 ≤ cos (arcsin x)
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_mem_Icc (L36-L39)
theorem arcsin_mem_Icc (x : ℝ) : arcsin x ∈ Icc (-(π / 2)) (π / 2) :=
Subtype.coe_prop _

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 2
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.range_arcsin (L41-L44)
theorem range_arcsin : range arcsin = Icc (-(π / 2)) (π / 2) := by
rw [arcsin, range_comp Subtype.val]
  simp [Icc]
```

-- snippet 3
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_le_pi_div_two (L45-L47)
theorem arcsin_le_pi_div_two (x : ℝ) : arcsin x ≤ π / 2 :=
(arcsin_mem_Icc x).2
```

-- snippet 4
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.neg_pi_div_two_le_arcsin (L48-L50)
theorem neg_pi_div_two_le_arcsin (x : ℝ) : -(π / 2) ≤ arcsin x :=
(arcsin_mem_Icc x).1
```

-- snippet 5
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_projIcc (L51-L55)
theorem arcsin_projIcc (x : ℝ) :
    arcsin (projIcc (-1) 1 (neg_le_self zero_le_one) x) = arcsin x := by
rw [arcsin, Function.comp_apply, IccExtend_val, Function.comp_apply, IccExtend,
        Function.comp_apply]
```

-- snippet 6
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.sin_arcsin' (L56-L59)
theorem sin_arcsin' {x : ℝ} (hx : x ∈ Icc (-1 : ℝ) 1) : sin (arcsin x) = x := by
simpa [arcsin, IccExtend_of_mem _ _ hx, -OrderIso.apply_symm_apply] using
    Subtype.ext_iff.1 (sinOrderIso.apply_symm_apply ⟨x, hx⟩)
```

-- snippet 7
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.sin_arcsin (L60-L62)
theorem sin_arcsin {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : sin (arcsin x) = x :=
sin_arcsin' ⟨hx₁, hx₂⟩
```

-- snippet 8
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_sin' (L63-L65)
theorem arcsin_sin' {x : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) : arcsin (sin x) = x :=
injOn_sin (arcsin_mem_Icc _) hx <| by rw [sin_arcsin (neg_one_le_sin _) (sin_le_one _)]
```

-- snippet 9
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_sin (L66-L68)
theorem arcsin_sin {x : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) : arcsin (sin x) = x :=
arcsin_sin' ⟨hx₁, hx₂⟩
```

-- snippet 10
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.strictMonoOn_arcsin (L69-L72)
theorem strictMonoOn_arcsin : StrictMonoOn arcsin (Icc (-1) 1) :=
(Subtype.strictMono_coe _).comp_strictMonoOn <|
    sinOrderIso.symm.strictMono.strictMonoOn_IccExtend _
```

-- snippet 11
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_lt_arcsin (L74-L77)
theorem arcsin_lt_arcsin {x y : ℝ} (hx : -1 ≤ x) (hlt : x < y) (hy : y ≤ 1) :
    arcsin x < arcsin y :=
strictMonoOn_arcsin ⟨hx, hlt.le.trans hy⟩ ⟨hx.trans hlt.le, hy⟩ hlt
```

-- snippet 12
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.monotone_arcsin (L78-L80)
theorem monotone_arcsin : Monotone arcsin :=
(Subtype.mono_coe _).comp <| sinOrderIso.symm.monotone.IccExtend _
```

-- snippet 13
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_le_arcsin (L82-L83)
theorem arcsin_le_arcsin {x y : ℝ} (h : x ≤ y) : arcsin x ≤ arcsin y := monotone_arcsin h
```

-- snippet 14
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.injOn_arcsin (L84-L86)
theorem injOn_arcsin : InjOn arcsin (Icc (-1) 1) :=
strictMonoOn_arcsin.injOn
```

-- snippet 15
```lean
-- Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse.arcsin_inj (L87-L90)
theorem arcsin_inj {x y : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) (hy₁ : -1 ≤ y) (hy₂ : y ≤ 1) :
    arcsin x = arcsin y ↔ x = y :=
injOn_arcsin.eq_iff ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩
```

-- snippet 16
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.tanh_arcosh (L89-L92)
theorem tanh_arcosh {x : ℝ} (hx : 1 ≤ x) : tanh (arcosh x) = √(x ^ 2 - 1) / x := by
rw [tanh_eq_sinh_div_cosh, sinh_arcosh hx, cosh_arcosh hx]

/-- `arcosh` is the left inverse of `cosh` over $[0, ∞)$. -/
```

-- snippet 17
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.hasStrictDerivAt_arcosh (L153-L159)
theorem hasStrictDerivAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) :
    HasStrictDerivAt arcosh (√(x ^ 2 - 1))⁻¹ x := by
rw [← sinh_arcosh (le_of_lt hx)]
  refine coshOpenPartialHomeomorph.hasStrictDerivAt_symm hx ?_ (hasStrictDerivAt_cosh _)
  rw [ne_eq, sinh_eq_zero]
  exact ne_of_gt (arcosh_pos hx)
```

-- snippet 18
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_lt_arcosh (L119-L122)
theorem arcosh_lt_arcosh {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : arcosh x < arcosh y ↔ x < y :=
strictMonoOn_arcosh.lt_iff_lt hx hy

/-- `Real.cosh` as a `PartialEquiv` from $[0, ∞)$ to $[1, ∞)$. -/
```

-- snippet 19
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.hasDerivAt_arcosh (L160-L162)
theorem hasDerivAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) : HasDerivAt arcosh (√(x ^ 2 - 1))⁻¹ x :=
(hasStrictDerivAt_arcosh hx).hasDerivAt
```

-- snippet 20
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.contDiffOn_arcosh (L175-L178)
theorem contDiffOn_arcosh {n : WithTop ℕ∞} : ContDiffOn ℝ n arcosh (Ioi 1) := fun _ hx =>
(contDiffAt_arcosh hx).contDiffWithinAt

/-- The function `Real.arcosh` is real analytic. -/
```

-- snippet 21
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.continuousOn_arcosh (L133-L138)
theorem continuousOn_arcosh : ContinuousOn arcosh (Ici 1) :=
have {x : ℝ} (hx : x ∈ Ici 1) : 0 < x + √(x ^ 2 - 1) :=
    add_pos_of_pos_of_nonneg (show 0 < x by grind) (sqrt_nonneg _)
  continuousOn_log.comp (by fun_prop) (by grind [MapsTo])

/-- `Real.cosh` as an `OpenPartialHomeomorph` from $(0, ∞)$ to $(1, ∞)$. -/
```

-- snippet 22
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_eq_zero_iff (L81-L84)
theorem arcosh_eq_zero_iff {x : ℝ} (hx : 1 ≤ x) : arcosh x = 0 ↔ x = 1 := by
rw [← exp_injective.eq_iff, exp_arcosh hx, exp_zero]
  grind
```

-- snippet 23
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_le_arcosh (L115-L118)
theorem arcosh_le_arcosh {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : arcosh x ≤ arcosh y ↔ x ≤ y :=
strictMonoOn_arcosh.le_iff_le hx hy

/-- This holds for `0 < x, y ≤ 1` due to junk values. -/
```

-- snippet 24
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.differentiableOn_arcosh (L166-L168)
theorem differentiableOn_arcosh : DifferentiableOn ℝ arcosh (Ioi 1) := fun _ hx =>
(differentiableAt_arcosh hx).differentiableWithinAt
```

-- snippet 25
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.analyticWithinAt_arcosh (L184-L188)
lemma analyticWithinAt_arcosh {s : Set ℝ} {x : ℝ} (hx : x ∈ Ioi 1) :
    AnalyticWithinAt ℝ arcosh s x :=
(contDiffAt_arcosh hx).contDiffWithinAt.analyticWithinAt

/-- The function `Real.arcosh` is real analytic. -/
```

-- snippet 26
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_zero (L69-L70)
theorem arcosh_zero : arcosh 1 = 0 := by simp [arcosh]
```

-- snippet 27
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.sinh_arcosh (L85-L88)
theorem sinh_arcosh {x : ℝ} (hx : 1 ≤ x) : sinh (arcosh x) = √(x ^ 2 - 1) := by
rw [arcosh, sinh_eq, exp_neg, exp_log (by positivity), add_sqrt_self_sq_sub_one_inv hx]
  ring
```

-- snippet 28
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.exp_arcosh (L64-L67)
theorem exp_arcosh {x : ℝ} (hx : 1 ≤ x) : exp (arcosh x) = x + √(x ^ 2 - 1) := by
apply exp_log
  positivity
```

-- snippet 29
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.strictMonoOn_arcosh (L110-L114)
theorem strictMonoOn_arcosh : StrictMonoOn arcosh (Ioi 0) := by
refine strictMonoOn_log.comp ?_ fun x (hx : 0 < x) ↦ show 0 < x + √(x ^ 2 - 1) by positivity
  exact strictMonoOn_id.add_monotone fun x (hx : 0 < x) y (hy : 0 < y) hxy ↦ by gcongr

/-- This holds for `0 < x, y ≤ 1` due to junk values. -/
```

-- snippet 30
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.coshOpenPartialHomeomorph (L139-L152)
def coshOpenPartialHomeomorph : OpenPartialHomeomorph ℝ ℝ where
  toFun := cosh
invFun := arcosh
  source := Ioi 0
  target := Ioi 1
  map_source' _ hr := one_lt_cosh.mpr (ne_of_lt hr).symm
  map_target' _ hr := arcosh_pos hr
  left_inv' _ hr := arcosh_cosh (le_of_lt hr)
  right_inv' _ hr := cosh_arcosh (le_of_lt hr)
  open_source := isOpen_Ioi
  open_target := isOpen_Ioi
  continuousOn_toFun := by fun_prop
  continuousOn_invFun := continuousOn_arcosh.mono Ioi_subset_Ici_self
```

-- snippet 31
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_pos (L103-L109)
theorem arcosh_pos {x : ℝ} (hx : 1 < x) : 0 < arcosh x := by
apply log_pos
  calc
    1 < x + 0 := by simpa
    _ ≤ x + √(x ^ 2 - 1) := by gcongr; positivity

/-- This holds for `Ioi 0` instead of only `Ici 1` due to junk values. -/
```

-- snippet 32
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.add_sqrt_self_sq_sub_one_inv (L71-L76)
lemma add_sqrt_self_sq_sub_one_inv {x : ℝ} (hx : 1 ≤ x) :
    (x + √(x ^ 2 - 1))⁻¹ = x - √(x ^ 2 - 1) := by
apply inv_eq_of_mul_eq_one_right
  rw [← pow_two_sub_pow_two, sq_sqrt (sub_nonneg_of_le (one_le_pow₀ hx)), sub_sub_cancel]

/-- `arcosh` is the right inverse of `cosh` over $[1, ∞)$. -/
```

-- snippet 33
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_nonneg (L97-L102)
theorem arcosh_nonneg {x : ℝ} (hx : 1 ≤ x) : 0 ≤ arcosh x := by
apply log_nonneg
  calc
    1 ≤ x + 0 := by simpa
    _ ≤ x + √(x ^ 2 - 1) := by gcongr; positivity
```

-- snippet 34
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.contDiffAt_arcosh (L169-L174)
theorem contDiffAt_arcosh {n : WithTop ℕ∞} {x : ℝ} (hx : x ∈ Ioi 1) : ContDiffAt ℝ n arcosh x := by
refine coshOpenPartialHomeomorph.contDiffAt_symm_deriv ?_ hx (hasDerivAt_cosh _)
    contDiff_cosh.contDiffAt
  rw [ne_eq, sinh_eq_zero]
  exact (arcosh_pos hx).ne'
```

-- snippet 35
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh_cosh (L93-L96)
theorem arcosh_cosh {x : ℝ} (hx : 0 ≤ x) : arcosh (cosh x) = x := by
rw [arcosh, ← exp_eq_exp, exp_log (by positivity), ← eq_sub_iff_add_eq', exp_sub_cosh,
    ← sq_eq_sq₀ (sqrt_nonneg _) (sinh_nonneg_iff.mpr hx), ← sinh_sq, sq_sqrt (pow_two_nonneg _)]
```

-- snippet 36
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.cosh_arcosh (L77-L80)
theorem cosh_arcosh {x : ℝ} (hx : 1 ≤ x) : cosh (arcosh x) = x := by
rw [arcosh, cosh_eq, exp_neg, exp_log (by positivity), add_sqrt_self_sq_sub_one_inv hx]
  ring
```

-- snippet 37
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.arcosh (L61-L63)
def arcosh (x : ℝ) :=
log (x + √(x ^ 2 - 1))
```

-- snippet 38
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.differentiableAt_arcosh (L163-L165)
theorem differentiableAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) : DifferentiableAt ℝ arcosh x :=
(hasDerivAt_arcosh hx).differentiableAt
```

-- snippet 39
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.analyticAt_arcosh (L180-L183)
lemma analyticAt_arcosh {x : ℝ} (hx : x ∈ Ioi 1) : AnalyticAt ℝ arcosh x :=
(contDiffAt_arcosh hx).analyticAt

/-- The function `Real.arcosh` is real analytic. -/
```

-- snippet 40
```lean
-- Mathlib.Analysis.SpecialFunctions.Arcosh.coshPartialEquiv (L123-L132)
def coshPartialEquiv : PartialEquiv ℝ ℝ where
  toFun := cosh
invFun := arcosh
  source := Ici 0
  target := Ici 1
  map_source' r _ := one_le_cosh r
  map_target' _ hr := arcosh_nonneg hr
  left_inv' _ hr := arcosh_cosh hr
  right_inv' _ hr := cosh_arcosh hr
```
[/INST]


Instruction: Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.CharP.Lemmas).

[User]
Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
lemma add_pow_char_of_commute (h : Commute x y) : (x + y) ^ p = x ^ p + y ^ p
```

Declaration: `Mathlib.Algebra.CharP.Lemmas.add_pow_char_of_commute` (module Mathlib.Algebra.CharP.Lemmas).

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Algebra.CharP.Lemmas).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
lemma add_pow_char_of_commute (h : Commute x y) : (x + y) ^ p = x ^ p + y ^ p
```

Declaration: `Mathlib.Algebra.CharP.Lemmas.add_pow_char_of_commute` (module Mathlib.Algebra.CharP.Lemmas).[/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.ModelTheory.Skolem).

[User]
The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.ModelTheory.Skolem.exists_elementarySubstructure_card_eq`:
State 0: ⊢ theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ
Tactic: obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
State 1: ⊢ <goal after obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4>
Tactic: rw [← aleph0_le_lift.{_, w}] at h1
State 2: ⊢ <goal after rw [← aleph0_le_lift.{_, w}] at h1>
Tactic: rw [← hs'] at h1 h2 ⊢
State 3: ⊢ <goal after rw [← hs'] at h1 h2 ⊢>
Tactic: refine  ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),  (s.subset_union_left).trans subset_closure, ?_⟩
State 4: ⊢ <goal after refine>
Tactic: have h := mk_image_eq_lift _ s' Equiv.ulift.injective
State 5: ⊢ <goal after have h := mk_image_eq_lift _ s' Equiv.ulift.injective>
Tactic: rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h
State 6: ⊢ <goal after rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h>
Tactic: rw [coeSort_elementarySkolem₁Reduct, ← h, lift_inj]
State 7: ⊢ <goal after rw [coeSort_elementarySkolem₁Reduct, ← h, lift_inj]>
Tactic: refine  le_antisymm (lift_le.1 (lift_card_closure_le.trans ?_))  (mk_le_mk_of_subset ((s.subset_union_right).trans subset_closure))
State 8: ⊢ <goal after refine>
Tactic: rw [max_le_iff, aleph0_le_lift, ← aleph0_le_lift.{_, w'}, h, add_eq_max, max_le_iff, lift_le]  · refine ⟨h1, (mk_union_le _ _).trans ?_, (lift_le.2 card_functions_sum_skolem₁_le).trans ?_⟩  · rw [← lift_le, lift_add, h, add_comm, add_eq_max h1]
State 9: ⊢ <goal after rw [max_le_iff, aleph0_le_lift, ← aleph0_le_lift.{_, w'}, h, add_eq_max, max_le_iff, lift_le]>
Tactic: exact max_le le_rfl h2  · rw [lift_max, lift_aleph0, max_le_iff, aleph0_le_lift, and_comm, ← lift_le.{w'},  lift_lift, lift_lift, ← aleph0_le_lift, h]
State 10: ⊢ <goal after exact max_le le_rfl h2>
Tactic: refine ⟨?_, h1⟩
State 11: ⊢ <goal after refine ⟨?_, h1⟩>
Tactic: rw [← lift_lift.{w', w}]
State 12: ⊢ <goal after rw [← lift_lift.{w', w}]>
Tactic: refine _root_.trans (lift_le.{w}.2 h3) ?_
State 13: ⊢ <goal after refine _root_.trans (lift_le.{w}.2 h3) ?_>
Tactic: rw [lift_lift, ← lift_lift.{w, max u v}, ← hs', ← h, lift_lift]  · refine _root_.trans ?_ (lift_le.2 (mk_le_mk_of_subset Set.subset_union_right))
State 14: ⊢ <goal after rw [lift_lift, ← lift_lift.{w, max u v}, ← hs', ← h, lift_lift]>
Tactic: rw [aleph0_le_lift, ← aleph0_le_lift, h]
State 15: ⊢ <goal after rw [aleph0_le_lift, ← aleph0_le_lift, h]>
Tactic: exact h1  end Language  end FirstOrder
```

Question: what is the next tactic after the last recorded state, and why?

<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.ModelTheory.Skolem).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.ModelTheory.Skolem.exists_elementarySubstructure_card_eq`:
State 0: ⊢ theorem exists_elementarySubstructure_card_eq (s : Set M) (κ : Cardinal.{w'}) (h1 : ℵ₀ ≤ κ)
    (h2 : Cardinal.lift.{w'} #s ≤ Cardinal.lift.{w} κ)
    (h3 : Cardinal.lift.{w'} L.card ≤ Cardinal.lift.{max u v} κ)
    (h4 : Cardinal.lift.{w} κ ≤ Cardinal.lift.{w'} #M) :
    ∃ S : L.ElementarySubstructure M, s ⊆ S ∧ Cardinal.lift.{w'} #S = Cardinal.lift.{w} κ
Tactic: obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4
State 1: ⊢ <goal after obtain ⟨s', hs'⟩ := Cardinal.le_mk_iff_exists_set.1 h4>
Tactic: rw [← aleph0_le_lift.{_, w}] at h1
State 2: ⊢ <goal after rw [← aleph0_le_lift.{_, w}] at h1>
Tactic: rw [← hs'] at h1 h2 ⊢
State 3: ⊢ <goal after rw [← hs'] at h1 h2 ⊢>
Tactic: refine  ⟨elementarySkolem₁Reduct (closure (L.sum L.skolem₁) (s ∪ Equiv.ulift '' s')),  (s.subset_union_left).trans subset_closure, ?_⟩
State 4: ⊢ <goal after refine>
Tactic: have h := mk_image_eq_lift _ s' Equiv.ulift.injective
State 5: ⊢ <goal after have h := mk_image_eq_lift _ s' Equiv.ulift.injective>
Tactic: rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h
State 6: ⊢ <goal after rw [lift_umax.{w, w'}, lift_id'.{w, w'}] at h>
Tactic: rw [coeSort_elementarySkolem₁Reduct, ← h, lift_inj]
State 7: ⊢ <goal after rw [coeSort_elementarySkolem₁Reduct, ← h, lift_inj]>
Tactic: refine  le_antisymm (lift_le.1 (lift_card_closure_le.trans ?_))  (mk_le_mk_of_subset ((s.subset_union_right).trans subset_closure))
State 8: ⊢ <goal after refine>
Tactic: rw [max_le_iff, aleph0_le_lift, ← aleph0_le_lift.{_, w'}, h, add_eq_max, max_le_iff, lift_le]  · refine ⟨h1, (mk_union_le _ _).trans ?_, (lift_le.2 card_functions_sum_skolem₁_le).trans ?_⟩  · rw [← lift_le, lift_add, h, add_comm, add_eq_max h1]
State 9: ⊢ <goal after rw [max_le_iff, aleph0_le_lift, ← aleph0_le_lift.{_, w'}, h, add_eq_max, max_le_iff, lift_le]>
Tactic: exact max_le le_rfl h2  · rw [lift_max, lift_aleph0, max_le_iff, aleph0_le_lift, and_comm, ← lift_le.{w'},  lift_lift, lift_lift, ← aleph0_le_lift, h]
State 10: ⊢ <goal after exact max_le le_rfl h2>
Tactic: refine ⟨?_, h1⟩
State 11: ⊢ <goal after refine ⟨?_, h1⟩>
Tactic: rw [← lift_lift.{w', w}]
State 12: ⊢ <goal after rw [← lift_lift.{w', w}]>
Tactic: refine _root_.trans (lift_le.{w}.2 h3) ?_
State 13: ⊢ <goal after refine _root_.trans (lift_le.{w}.2 h3) ?_>
Tactic: rw [lift_lift, ← lift_lift.{w, max u v}, ← hs', ← h, lift_lift]  · refine _root_.trans ?_ (lift_le.2 (mk_le_mk_of_subset Set.subset_union_right))
State 14: ⊢ <goal after rw [lift_lift, ← lift_lift.{w, max u v}, ← hs', ← h, lift_lift]>
Tactic: rw [aleph0_le_lift, ← aleph0_le_lift, h]
State 15: ⊢ <goal after rw [aleph0_le_lift, ← aleph0_le_lift, h]>
Tactic: exact h1  end Language  end FirstOrder
```

Question: what is the next tactic after the last recorded state, and why?[/INST]


Instruction: Edit `condition` so it still compiles and the proof is simplified where possible. Return the full updated `condition` 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.CategoryTheory.Limits.Shapes.Pullback.PullbackCone).

[User]
You are editing a file in `Mathlib/CategoryTheory/Limits/Shapes/Pullback/PullbackCone.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.CategoryTheory.Limits.Shapes.Pullback.PullbackCone.condition`, L359-L364)
```lean
theorem condition (t : PushoutCocone f g) : f ≫ inl t = g ≫ inr t := (t.w fst).trans (t.w snd).symm

set_option backward.isDefEq.respectTransparency false in
/-- To check whether a morphism is coequalized by the maps of a pushout cocone, it suffices to check
  it for `inl t` and `inr t` -/
```

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

## Current excerpt (around `Mathlib.CategoryTheory.Limits.Shapes.Pullback.PullbackCone.condition`, L359-L364)
```lean
theorem condition (t : PushoutCocone f g) : f ≫ inl t = g ≫ inr t := (t.w fst).trans (t.w snd).symm

set_option backward.isDefEq.respectTransparency false in
/-- To check whether a morphism is coequalized by the maps of a pushout cocone, it suffices to check
  it for `inl t` and `inr t` -/
```

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

[User]
The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.RepresentationTheory.Homological.GroupCohomology.Basic.d`:
State 0: ⊢ def d [Monoid G] (A : Rep k G) (n : ℕ) :
    ModuleCat.of k ((Fin n → G) → A) ⟶ ModuleCat.of k ((Fin (n + 1) → G) → A)
Tactic: ext
State 1: ⊢ <goal after ext>
Tactic: simp [Finset.sum_add_distrib, add_add_add_comm]  map_smul' r f := by
State 2: ⊢ <goal after simp [Finset.sum_add_distrib, add_add_add_comm]>
Tactic: ext
State 3: ⊢ <goal after ext>
Tactic: simp [Finset.smul_sum, ← smul_assoc, mul_comm r] }  variable [Group G] (A : Rep k G) (n : ℕ)  set_option backward.isDefEq.respectTransparency false in
```

Question: what is the next tactic after the last recorded state, and why?

<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.RepresentationTheory.Homological.GroupCohomology.Basic).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.RepresentationTheory.Homological.GroupCohomology.Basic.d`:
State 0: ⊢ def d [Monoid G] (A : Rep k G) (n : ℕ) :
    ModuleCat.of k ((Fin n → G) → A) ⟶ ModuleCat.of k ((Fin (n + 1) → G) → A)
Tactic: ext
State 1: ⊢ <goal after ext>
Tactic: simp [Finset.sum_add_distrib, add_add_add_comm]  map_smul' r f := by
State 2: ⊢ <goal after simp [Finset.sum_add_distrib, add_add_add_comm]>
Tactic: ext
State 3: ⊢ <goal after ext>
Tactic: simp [Finset.smul_sum, ← smul_assoc, mul_comm r] }  variable [Group G] (A : Rep k G) (n : ℕ)  set_option backward.isDefEq.respectTransparency false in
```

Question: what is the next tactic after the last recorded state, and why?[/INST]


Instruction: Edit `IntegrableOn` so it still compiles and the proof is simplified where possible. Return the full updated `IntegrableOn` 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.MeasureTheory.Integral.IntegrableOn).

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

## Current excerpt (around `Mathlib.MeasureTheory.Integral.IntegrableOn.IntegrableOn`, L147-L150)
```lean
theorem IntegrableOn.congr_fun_ae (h : IntegrableOn f s μ) (hst : f =ᵐ[μ.restrict s] g) :
    IntegrableOn g s μ := Integrable.congr h hst
```

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

## Current excerpt (around `Mathlib.MeasureTheory.Integral.IntegrableOn.IntegrableOn`, L147-L150)
```lean
theorem IntegrableOn.congr_fun_ae (h : IntegrableOn f s μ) (hst : f =ᵐ[μ.restrict s] g) :
    IntegrableOn g s μ := Integrable.congr h hst
```

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

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

```lean
theorem zero_product : (0 : Multiset α) ×ˢ t = 0
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Data.Multiset.Bind.join (L38-L40)
def join : Multiset (Multiset α) → Multiset α :=
sum
```

-- snippet 2
```lean
-- Mathlib.Data.Multiset.Bind.coe_join (L41-L46)
theorem coe_join : ∀ L : List (List α), join (L.map ((↑) : List α → Multiset α) :
    Multiset (Multiset α)) = L.flatten
  | [] => rfl
  | l :: L => by
      exact congr_arg (fun s : Multiset α => ↑l + s) (coe_join L)
```

-- snippet 3
```lean
-- Mathlib.Data.Multiset.Bind.join_zero (L48-L50)
theorem join_zero : @join α 0 = 0 :=
rfl
```

-- snippet 4
```lean
-- Mathlib.Data.Multiset.Bind.join_cons (L52-L54)
theorem join_cons (s S) : @join α (s ::ₘ S) = s + join S :=
sum_cons _ _
```

-- snippet 5
```lean
-- Mathlib.Data.Multiset.Bind.join_add (L56-L58)
theorem join_add (S T) : @join α (S + T) = join S + join T :=
sum_add _ _
```

-- snippet 6
```lean
-- Mathlib.Data.Multiset.Bind.singleton_join (L60-L62)
theorem singleton_join (a) : join ({a} : Multiset (Multiset α)) = a :=
sum_singleton _
```

-- snippet 7
```lean
-- Mathlib.Data.Multiset.Bind.mem_join (L64-L67)
theorem mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s :=
Multiset.induction_on S (by simp) <| by
    simp +contextual [or_and_right, exists_or]
```

-- snippet 8
```lean
-- Mathlib.Data.Multiset.Bind.card_join (L69-L71)
theorem card_join (S) : card (@join α S) = sum (map card S) :=
Multiset.induction_on S (by simp) (by simp)
```

-- snippet 9
```lean
-- Mathlib.Data.Multiset.Bind.map_join (L73-L78)
theorem map_join (f : α → β) (S : Multiset (Multiset α)) :
    map f (join S) = join (map (map f) S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]
```

-- snippet 10
```lean
-- Mathlib.Data.Multiset.Bind.prod_join (L80-L85)
theorem prod_join [CommMonoid α] {S : Multiset (Multiset α)} :
    prod (join S) = prod (map prod S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]
```

-- snippet 11
```lean
-- Mathlib.Data.Multiset.Bind.rel_join (L86-L90)
theorem rel_join {r : α → β → Prop} {s t} (h : Rel (Rel r) s t) : Rel r s.join t.join := by
induction h with
  | zero => simp
  | cons hab hst ih => simpa using hab.add ih
```

-- snippet 12
```lean
-- Mathlib.Data.Multiset.Bind.filter_join (L91-L96)
theorem filter_join (S : Multiset (Multiset α)) (p : α → Prop) [DecidablePred p] :
    filter p (join S) = join (map (filter p) S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]
```

-- snippet 13
```lean
-- Mathlib.Data.Multiset.Bind.filterMap_join (L97-L111)
theorem filterMap_join (S : Multiset (Multiset α)) (f : α → Option β) :
    filterMap f (join S) = join (map (filterMap f) S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]

/-! ### Bind -/

section Bind

variable (a : α) (s t : Multiset α) (f g : α → Multiset β)

/-- `s.bind f` is the monad bind operation, defined as `(s.map f).join`. It is the union of `f a` as
`a` ranges over `s`. -/
```

-- snippet 14
```lean
-- Mathlib.Data.Multiset.Bind.bind (L112-L114)
def bind (s : Multiset α) (f : α → Multiset β) : Multiset β :=
(s.map f).join
```

-- snippet 15
```lean
-- Mathlib.Data.Multiset.Bind.coe_bind (L116-L119)
theorem coe_bind (l : List α) (f : α → List β) : (@bind α β l fun a => f a) = l.flatMap f := by
rw [List.flatMap, ← coe_join, List.map_map]
  rfl
```

-- snippet 16
```lean
-- Mathlib.Data.Multiset.AddSub.le_add_right (L87-L89)
lemma le_add_right (s t : Multiset α) : s ≤ s + t := by
simpa using Multiset.add_le_add_left (zero_le t)
```

-- snippet 17
```lean
-- Mathlib.Data.Multiset.AddSub.erase_of_notMem (L169-L171)
theorem erase_of_notMem {a : α} {s : Multiset α} : a ∉ s → s.erase a = s :=
Quot.inductionOn s fun _l h => congr_arg _ <| List.erase_of_not_mem h
```

-- snippet 18
```lean
-- Mathlib.Data.Multiset.AddSub.erase_zero (L152-L154)
theorem erase_zero (a : α) : (0 : Multiset α).erase a = 0 :=
rfl
```

-- snippet 19
```lean
-- Mathlib.Data.Multiset.AddSub.le_iff_exists_add (L97-L103)
theorem le_iff_exists_add {s t : Multiset α} : s ≤ t ↔ ∃ u, t = s + u :=
⟨fun h =>
    leInductionOn h fun s =>
      let ⟨l, p⟩ := s.exists_perm_append
      ⟨l, Quot.sound p⟩,
    fun ⟨_u, e⟩ => e.symm ▸ le_add_right _ _⟩
```

-- snippet 20
```lean
-- Mathlib.Data.Multiset.AddSub.add_singleton_eq_iff (L186-L193)
theorem add_singleton_eq_iff {s t : Multiset α} {a : α} : s + {a} = t ↔ a ∈ t ∧ s = t.erase a := by
rw [Multiset.add_comm, singleton_add]
  constructor
  · rintro rfl
    exact ⟨s.mem_cons_self a, (s.erase_cons_head a).symm⟩
  · rintro ⟨h, rfl⟩
    exact cons_erase h
```

-- snippet 21
```lean
-- Mathlib.Data.Multiset.AddSub.le_add_left (L90-L92)
lemma le_add_left (s t : Multiset α) : s ≤ t + s := by
simpa using Multiset.add_le_add_right (zero_le t)
```

-- snippet 22
```lean
-- Mathlib.Data.Multiset.AddSub.le_cons_erase (L182-L185)
theorem le_cons_erase (s : Multiset α) (a : α) : s ≤ a ::ₘ s.erase a :=
if h : a ∈ s then le_of_eq (cons_erase h).symm
  else by rw [erase_of_notMem h]; apply le_cons_self
```

-- snippet 23
```lean
-- Mathlib.Data.Multiset.AddSub.erase_singleton (L165-L167)
theorem erase_singleton (a : α) : ({a} : Multiset α).erase a = 0 :=
erase_cons_head a 0
```

-- snippet 24
```lean
-- Mathlib.Data.Multiset.AddSub.card_add (L132-L143)
theorem card_add (s t : Multiset α) : card (s + t) = card s + card t :=
Quotient.inductionOn₂ s t fun _ _ => length_append

end add

/-! ### Erasing one copy of an element -/

section Erase

variable [DecidableEq α] {s t : Multiset α} {a b : α}

/-- `erase s a` is the multiset that subtracts 1 from the multiplicity of `a`. -/
```

-- snippet 25
```lean
-- Mathlib.Data.Multiset.AddSub.erase_cons_head (L156-L158)
theorem erase_cons_head (a : α) (s : Multiset α) : (a ::ₘ s).erase a = s :=
Quot.inductionOn s fun l => congr_arg _ <| List.erase_cons_head a l
```

-- snippet 26
```lean
-- Mathlib.Data.Multiset.AddSub.erase_add_left_pos (L194-L196)
theorem erase_add_left_pos {a : α} {s : Multiset α} (t) : a ∈ s → (s + t).erase a = s.erase a + t :=
Quotient.inductionOn₂ s t fun _l₁ l₂ h => congr_arg _ <| erase_append_left l₂ h
```

-- snippet 27
```lean
-- Mathlib.Data.Multiset.AddSub.count_add (L124-L130)
theorem count_add (a : α) : ∀ s t, count a (s + t) = count a s + count a t :=
countP_add _

protected lemma add_left_inj : s + u = t + u ↔ s = t := by classical simp [Multiset.ext]

protected lemma add_right_inj : s + t = s + u ↔ t = u := by classical simp [Multiset.ext]
```

-- snippet 28
```lean
-- Mathlib.Data.Multiset.AddSub.erase_cons_tail_of_mem (L176-L181)
theorem erase_cons_tail_of_mem (h : a ∈ s) :
    (b ::ₘ s).erase a = b ::ₘ s.erase a := by
rcases eq_or_ne a b with rfl | hab
  · simp [cons_erase h]
  · exact s.erase_cons_tail hab.symm
```

-- snippet 29
```lean
-- Mathlib.Data.Multiset.AddSub.coe_erase (L148-L150)
theorem coe_erase (l : List α) (a : α) : erase (l : Multiset α) a = l.erase a :=
rfl
```

-- snippet 30
```lean
-- Mathlib.Data.Multiset.AddSub.erase (L144-L146)
def erase (s : Multiset α) (a : α) : Multiset α :=
Quot.liftOn s (fun l => (l.erase a : Multiset α)) fun _l₁ _l₂ p => Quot.sound (p.erase a)
```

-- snippet 31
```lean
-- Mathlib.Data.Multiset.AddSub.coe_add (L58-L60)
theorem coe_add (s t : List α) : (s + t : Multiset α) = (s ++ t : List α) :=
rfl
```

-- snippet 32
```lean
-- Mathlib.Data.Multiset.AddSub.cons_add (L105-L107)
theorem cons_add (a : α) (s t : Multiset α) : a ::ₘ s + t = a ::ₘ (s + t) := by
rw [← singleton_add, ← singleton_add, Multiset.add_assoc]
```

-- snippet 33
```lean
-- Mathlib.Data.Multiset.AddSub.erase_cons_tail (L160-L163)
theorem erase_cons_tail {a b : α} (s : Multiset α) (h : b ≠ a) :
    (b ::ₘ s).erase a = b ::ₘ s.erase a :=
Quot.inductionOn s fun _ => congr_arg _ <| List.erase_cons_tail (not_beq_of_ne h)
```

-- snippet 34
```lean
-- Mathlib.Data.Multiset.AddSub.subset_add_right (L95-L96)
lemma subset_add_right {s t : Multiset α} : s ⊆ t + s := subset_of_le <| le_add_left s t
```

-- snippet 35
```lean
-- Mathlib.Data.Multiset.AddSub.subset_add_left (L93-L94)
lemma subset_add_left {s t : Multiset α} : s ⊆ s + t := subset_of_le <| le_add_right s t
```

-- snippet 36
```lean
-- Mathlib.Data.Multiset.AddSub.countP_add (L119-L122)
theorem countP_add (s t) : countP p (s + t) = countP p s + countP p t :=
Quotient.inductionOn₂ s t fun _ _ => countP_append

variable [DecidableEq α] in
```

-- snippet 37
```lean
-- Mathlib.Data.Multiset.AddSub.add_cons (L109-L111)
theorem add_cons (a : α) (s t : Multiset α) : s + a ::ₘ t = a ::ₘ (s + t) := by
rw [Multiset.add_comm, cons_add, Multiset.add_comm]
```

-- snippet 38
```lean
-- Mathlib.Data.Multiset.AddSub.mem_add (L113-L117)
theorem mem_add {a : α} {s t : Multiset α} : a ∈ s + t ↔ a ∈ s ∨ a ∈ t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => mem_append

variable (p : α → Prop) [DecidablePred p]
```

-- snippet 39
```lean
-- Mathlib.Data.Multiset.AddSub.singleton_add (L62-L79)
theorem singleton_add (a : α) (s : Multiset α) : {a} + s = a ::ₘ s :=
rfl

protected lemma add_le_add_iff_left : s + t ≤ s + u ↔ t ≤ u :=
  Quotient.inductionOn₃ s t u fun _ _ _ => subperm_append_left _

protected lemma add_le_add_iff_right : s + u ≤ t + u ↔ s ≤ t :=
  Quotient.inductionOn₃ s t u fun _ _ _ => subperm_append_right _

protected alias ⟨le_of_add_le_add_left, add_le_add_left⟩ := Multiset.add_le_add_iff_left
protected alias ⟨le_of_add_le_add_right, add_le_add_right⟩ := Multiset.add_le_add_iff_right

protected lemma add_comm (s t : Multiset α) : s + t = t + s :=
  Quotient.inductionOn₂ s t fun _ _ ↦ Quot.sound perm_append_comm

protected lemma add_assoc (s t u : Multiset α) : s + t + u = s + (t + u) :=
  Quotient.inductionOn₃ s t u fun _ _ _ ↦ congr_arg _ <| append_assoc ..
```

-- snippet 40
```lean
-- Mathlib.Data.Multiset.AddSub.cons_erase (L173-L175)
theorem cons_erase {s : Multiset α} {a : α} : a ∈ s → a ::ₘ s.erase a = s :=
Quot.inductionOn s fun _l h => Quot.sound (perm_cons_erase h).symm
```

<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.Multiset.Bind).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem zero_product : (0 : Multiset α) ×ˢ t = 0
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Data.Multiset.Bind.join (L38-L40)
def join : Multiset (Multiset α) → Multiset α :=
sum
```

-- snippet 2
```lean
-- Mathlib.Data.Multiset.Bind.coe_join (L41-L46)
theorem coe_join : ∀ L : List (List α), join (L.map ((↑) : List α → Multiset α) :
    Multiset (Multiset α)) = L.flatten
  | [] => rfl
  | l :: L => by
      exact congr_arg (fun s : Multiset α => ↑l + s) (coe_join L)
```

-- snippet 3
```lean
-- Mathlib.Data.Multiset.Bind.join_zero (L48-L50)
theorem join_zero : @join α 0 = 0 :=
rfl
```

-- snippet 4
```lean
-- Mathlib.Data.Multiset.Bind.join_cons (L52-L54)
theorem join_cons (s S) : @join α (s ::ₘ S) = s + join S :=
sum_cons _ _
```

-- snippet 5
```lean
-- Mathlib.Data.Multiset.Bind.join_add (L56-L58)
theorem join_add (S T) : @join α (S + T) = join S + join T :=
sum_add _ _
```

-- snippet 6
```lean
-- Mathlib.Data.Multiset.Bind.singleton_join (L60-L62)
theorem singleton_join (a) : join ({a} : Multiset (Multiset α)) = a :=
sum_singleton _
```

-- snippet 7
```lean
-- Mathlib.Data.Multiset.Bind.mem_join (L64-L67)
theorem mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s :=
Multiset.induction_on S (by simp) <| by
    simp +contextual [or_and_right, exists_or]
```

-- snippet 8
```lean
-- Mathlib.Data.Multiset.Bind.card_join (L69-L71)
theorem card_join (S) : card (@join α S) = sum (map card S) :=
Multiset.induction_on S (by simp) (by simp)
```

-- snippet 9
```lean
-- Mathlib.Data.Multiset.Bind.map_join (L73-L78)
theorem map_join (f : α → β) (S : Multiset (Multiset α)) :
    map f (join S) = join (map (map f) S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]
```

-- snippet 10
```lean
-- Mathlib.Data.Multiset.Bind.prod_join (L80-L85)
theorem prod_join [CommMonoid α] {S : Multiset (Multiset α)} :
    prod (join S) = prod (map prod S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]
```

-- snippet 11
```lean
-- Mathlib.Data.Multiset.Bind.rel_join (L86-L90)
theorem rel_join {r : α → β → Prop} {s t} (h : Rel (Rel r) s t) : Rel r s.join t.join := by
induction h with
  | zero => simp
  | cons hab hst ih => simpa using hab.add ih
```

-- snippet 12
```lean
-- Mathlib.Data.Multiset.Bind.filter_join (L91-L96)
theorem filter_join (S : Multiset (Multiset α)) (p : α → Prop) [DecidablePred p] :
    filter p (join S) = join (map (filter p) S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]
```

-- snippet 13
```lean
-- Mathlib.Data.Multiset.Bind.filterMap_join (L97-L111)
theorem filterMap_join (S : Multiset (Multiset α)) (f : α → Option β) :
    filterMap f (join S) = join (map (filterMap f) S) := by
induction S using Multiset.induction with
  | empty => simp
  | cons _ _ ih => simp [ih]

/-! ### Bind -/

section Bind

variable (a : α) (s t : Multiset α) (f g : α → Multiset β)

/-- `s.bind f` is the monad bind operation, defined as `(s.map f).join`. It is the union of `f a` as
`a` ranges over `s`. -/
```

-- snippet 14
```lean
-- Mathlib.Data.Multiset.Bind.bind (L112-L114)
def bind (s : Multiset α) (f : α → Multiset β) : Multiset β :=
(s.map f).join
```

-- snippet 15
```lean
-- Mathlib.Data.Multiset.Bind.coe_bind (L116-L119)
theorem coe_bind (l : List α) (f : α → List β) : (@bind α β l fun a => f a) = l.flatMap f := by
rw [List.flatMap, ← coe_join, List.map_map]
  rfl
```

-- snippet 16
```lean
-- Mathlib.Data.Multiset.AddSub.le_add_right (L87-L89)
lemma le_add_right (s t : Multiset α) : s ≤ s + t := by
simpa using Multiset.add_le_add_left (zero_le t)
```

-- snippet 17
```lean
-- Mathlib.Data.Multiset.AddSub.erase_of_notMem (L169-L171)
theorem erase_of_notMem {a : α} {s : Multiset α} : a ∉ s → s.erase a = s :=
Quot.inductionOn s fun _l h => congr_arg _ <| List.erase_of_not_mem h
```

-- snippet 18
```lean
-- Mathlib.Data.Multiset.AddSub.erase_zero (L152-L154)
theorem erase_zero (a : α) : (0 : Multiset α).erase a = 0 :=
rfl
```

-- snippet 19
```lean
-- Mathlib.Data.Multiset.AddSub.le_iff_exists_add (L97-L103)
theorem le_iff_exists_add {s t : Multiset α} : s ≤ t ↔ ∃ u, t = s + u :=
⟨fun h =>
    leInductionOn h fun s =>
      let ⟨l, p⟩ := s.exists_perm_append
      ⟨l, Quot.sound p⟩,
    fun ⟨_u, e⟩ => e.symm ▸ le_add_right _ _⟩
```

-- snippet 20
```lean
-- Mathlib.Data.Multiset.AddSub.add_singleton_eq_iff (L186-L193)
theorem add_singleton_eq_iff {s t : Multiset α} {a : α} : s + {a} = t ↔ a ∈ t ∧ s = t.erase a := by
rw [Multiset.add_comm, singleton_add]
  constructor
  · rintro rfl
    exact ⟨s.mem_cons_self a, (s.erase_cons_head a).symm⟩
  · rintro ⟨h, rfl⟩
    exact cons_erase h
```

-- snippet 21
```lean
-- Mathlib.Data.Multiset.AddSub.le_add_left (L90-L92)
lemma le_add_left (s t : Multiset α) : s ≤ t + s := by
simpa using Multiset.add_le_add_right (zero_le t)
```

-- snippet 22
```lean
-- Mathlib.Data.Multiset.AddSub.le_cons_erase (L182-L185)
theorem le_cons_erase (s : Multiset α) (a : α) : s ≤ a ::ₘ s.erase a :=
if h : a ∈ s then le_of_eq (cons_erase h).symm
  else by rw [erase_of_notMem h]; apply le_cons_self
```

-- snippet 23
```lean
-- Mathlib.Data.Multiset.AddSub.erase_singleton (L165-L167)
theorem erase_singleton (a : α) : ({a} : Multiset α).erase a = 0 :=
erase_cons_head a 0
```

-- snippet 24
```lean
-- Mathlib.Data.Multiset.AddSub.card_add (L132-L143)
theorem card_add (s t : Multiset α) : card (s + t) = card s + card t :=
Quotient.inductionOn₂ s t fun _ _ => length_append

end add

/-! ### Erasing one copy of an element -/

section Erase

variable [DecidableEq α] {s t : Multiset α} {a b : α}

/-- `erase s a` is the multiset that subtracts 1 from the multiplicity of `a`. -/
```

-- snippet 25
```lean
-- Mathlib.Data.Multiset.AddSub.erase_cons_head (L156-L158)
theorem erase_cons_head (a : α) (s : Multiset α) : (a ::ₘ s).erase a = s :=
Quot.inductionOn s fun l => congr_arg _ <| List.erase_cons_head a l
```

-- snippet 26
```lean
-- Mathlib.Data.Multiset.AddSub.erase_add_left_pos (L194-L196)
theorem erase_add_left_pos {a : α} {s : Multiset α} (t) : a ∈ s → (s + t).erase a = s.erase a + t :=
Quotient.inductionOn₂ s t fun _l₁ l₂ h => congr_arg _ <| erase_append_left l₂ h
```

-- snippet 27
```lean
-- Mathlib.Data.Multiset.AddSub.count_add (L124-L130)
theorem count_add (a : α) : ∀ s t, count a (s + t) = count a s + count a t :=
countP_add _

protected lemma add_left_inj : s + u = t + u ↔ s = t := by classical simp [Multiset.ext]

protected lemma add_right_inj : s + t = s + u ↔ t = u := by classical simp [Multiset.ext]
```

-- snippet 28
```lean
-- Mathlib.Data.Multiset.AddSub.erase_cons_tail_of_mem (L176-L181)
theorem erase_cons_tail_of_mem (h : a ∈ s) :
    (b ::ₘ s).erase a = b ::ₘ s.erase a := by
rcases eq_or_ne a b with rfl | hab
  · simp [cons_erase h]
  · exact s.erase_cons_tail hab.symm
```

-- snippet 29
```lean
-- Mathlib.Data.Multiset.AddSub.coe_erase (L148-L150)
theorem coe_erase (l : List α) (a : α) : erase (l : Multiset α) a = l.erase a :=
rfl
```

-- snippet 30
```lean
-- Mathlib.Data.Multiset.AddSub.erase (L144-L146)
def erase (s : Multiset α) (a : α) : Multiset α :=
Quot.liftOn s (fun l => (l.erase a : Multiset α)) fun _l₁ _l₂ p => Quot.sound (p.erase a)
```

-- snippet 31
```lean
-- Mathlib.Data.Multiset.AddSub.coe_add (L58-L60)
theorem coe_add (s t : List α) : (s + t : Multiset α) = (s ++ t : List α) :=
rfl
```

-- snippet 32
```lean
-- Mathlib.Data.Multiset.AddSub.cons_add (L105-L107)
theorem cons_add (a : α) (s t : Multiset α) : a ::ₘ s + t = a ::ₘ (s + t) := by
rw [← singleton_add, ← singleton_add, Multiset.add_assoc]
```

-- snippet 33
```lean
-- Mathlib.Data.Multiset.AddSub.erase_cons_tail (L160-L163)
theorem erase_cons_tail {a b : α} (s : Multiset α) (h : b ≠ a) :
    (b ::ₘ s).erase a = b ::ₘ s.erase a :=
Quot.inductionOn s fun _ => congr_arg _ <| List.erase_cons_tail (not_beq_of_ne h)
```

-- snippet 34
```lean
-- Mathlib.Data.Multiset.AddSub.subset_add_right (L95-L96)
lemma subset_add_right {s t : Multiset α} : s ⊆ t + s := subset_of_le <| le_add_left s t
```

-- snippet 35
```lean
-- Mathlib.Data.Multiset.AddSub.subset_add_left (L93-L94)
lemma subset_add_left {s t : Multiset α} : s ⊆ s + t := subset_of_le <| le_add_right s t
```

-- snippet 36
```lean
-- Mathlib.Data.Multiset.AddSub.countP_add (L119-L122)
theorem countP_add (s t) : countP p (s + t) = countP p s + countP p t :=
Quotient.inductionOn₂ s t fun _ _ => countP_append

variable [DecidableEq α] in
```

-- snippet 37
```lean
-- Mathlib.Data.Multiset.AddSub.add_cons (L109-L111)
theorem add_cons (a : α) (s t : Multiset α) : s + a ::ₘ t = a ::ₘ (s + t) := by
rw [Multiset.add_comm, cons_add, Multiset.add_comm]
```

-- snippet 38
```lean
-- Mathlib.Data.Multiset.AddSub.mem_add (L113-L117)
theorem mem_add {a : α} {s t : Multiset α} : a ∈ s + t ↔ a ∈ s ∨ a ∈ t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => mem_append

variable (p : α → Prop) [DecidablePred p]
```

-- snippet 39
```lean
-- Mathlib.Data.Multiset.AddSub.singleton_add (L62-L79)
theorem singleton_add (a : α) (s : Multiset α) : {a} + s = a ::ₘ s :=
rfl

protected lemma add_le_add_iff_left : s + t ≤ s + u ↔ t ≤ u :=
  Quotient.inductionOn₃ s t u fun _ _ _ => subperm_append_left _

protected lemma add_le_add_iff_right : s + u ≤ t + u ↔ s ≤ t :=
  Quotient.inductionOn₃ s t u fun _ _ _ => subperm_append_right _

protected alias ⟨le_of_add_le_add_left, add_le_add_left⟩ := Multiset.add_le_add_iff_left
protected alias ⟨le_of_add_le_add_right, add_le_add_right⟩ := Multiset.add_le_add_iff_right

protected lemma add_comm (s t : Multiset α) : s + t = t + s :=
  Quotient.inductionOn₂ s t fun _ _ ↦ Quot.sound perm_append_comm

protected lemma add_assoc (s t u : Multiset α) : s + t + u = s + (t + u) :=
  Quotient.inductionOn₃ s t u fun _ _ _ ↦ congr_arg _ <| append_assoc ..
```

-- snippet 40
```lean
-- Mathlib.Data.Multiset.AddSub.cons_erase (L173-L175)
theorem cons_erase {s : Multiset α} {a : α} : a ∈ s → a ::ₘ s.erase a = s :=
Quot.inductionOn s fun _l h => Quot.sound (perm_cons_erase h).symm
```
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.Matrix.SesquilinearForm).

[User]
Complete the following proof.

```lean
theorem SeparatingLeft.toMatrix₂' (h : B.SeparatingLeft) : (toMatrix₂' R B).SeparatingLeft
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.Matrix.SesquilinearForm).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Complete the following proof.

```lean
theorem SeparatingLeft.toMatrix₂' (h : B.SeparatingLeft) : (toMatrix₂' R B).SeparatingLeft
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.[/INST]


Instruction: Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Control.Random).

[User]
Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
def rand (α : Type u) [Random m α] [RandomGen g] : RandGT g m α
```

Declaration: `Mathlib.Control.Random.rand` (module Mathlib.Control.Random).

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Control.Random).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
def rand (α : Type u) [Random m α] [RandomGen g] : RandGT g m α
```

Declaration: `Mathlib.Control.Random.rand` (module Mathlib.Control.Random).[/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.Control.Fold).

[User]
The following Lean code fails to compile. Fix it.

```lean
def toList : t α → List α
:= thisIsWrongLemmaNameXYZ
List.reverse ∘ foldl (flip List.cons) []
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=99, messages=[Message(data="Function expected at\n  t\nbut this term has type\n  ?m.1\n\nNote: Expected a function because this term is being applied to the argument\n  α\n\nHint: The identifier `t` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=1, column=13), pos_end=Position(line=1, column=16), severity=<Severity.ERROR: 3>, kind=None), Message(data='Unknown identifier `thisIsWrongLemmaNameXYZ`', pos=Position(line=2, column=3), pos_end=Position(line=2, column=26), severity=<Severity.ERROR: 3>, kind='lean.unknownIdentifier._namedError'), Message(data='Unknown identifier `foldl`', pos=Position(line=3, column=15), pos_end=Position(line=3, column=20), severity=<Severity.ERROR: 3>, kind='lean.unknownIdentifier._namedError')], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.

<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.Control.Fold).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following Lean code fails to compile. Fix it.

```lean
def toList : t α → List α
:= thisIsWrongLemmaNameXYZ
List.reverse ∘ foldl (flip List.cons) []
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=99, messages=[Message(data="Function expected at\n  t\nbut this term has type\n  ?m.1\n\nNote: Expected a function because this term is being applied to the argument\n  α\n\nHint: The identifier `t` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=1, column=13), pos_end=Position(line=1, column=16), severity=<Severity.ERROR: 3>, kind=None), Message(data='Unknown identifier `thisIsWrongLemmaNameXYZ`', pos=Position(line=2, column=3), pos_end=Position(line=2, column=26), severity=<Severity.ERROR: 3>, kind='lean.unknownIdentifier._namedError'), Message(data='Unknown identifier `foldl`', pos=Position(line=3, column=15), pos_end=Position(line=3, column=20), severity=<Severity.ERROR: 3>, kind='lean.unknownIdentifier._namedError')], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.MeasureTheory.Function.L1Space.Integrable).

[User]
Complete the following proof.

```lean
lemma Integrable.of_finite [Finite α] [MeasurableSingletonClass α] [IsFiniteMeasure μ] {f : α → β} :
    Integrable f μ
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.MeasureTheory.Function.L1Space.Integrable).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Complete the following proof.

```lean
lemma Integrable.of_finite [Finite α] [MeasurableSingletonClass α] [IsFiniteMeasure μ] {f : α → β} :
    Integrable f μ
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.[/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.SetTheory.ZFC.Basic).

[User]
The following Lean code fails to compile. Fix it.

```lean
theorem mem_sUnion_of_mem {x y z : ZFSet} (hy : y ∈ z) (hz : z ∈ x) : y ∈ ⋃₀ x
:= .someMissingNamespaceXYZ
mem_sUnion.2 ⟨z, hz, hy⟩
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=145, messages=[Message(data='overloaded, errors \n  1:77 Application type mismatch: The argument\n    x\n  has type\n    ZFSet.{?u.409}\n  but is expected to have type\n    PSet.{?u.409}\n  in the application\n    ⋃₀ x\n  \n  1:77 Application type mismatch: The argument\n    x\n  has type\n    ZFSet.{?u.2}\n  but is expected to have type\n    Set (Set ?m.10)\n  in the application\n    ⋃₀ x', pos=Position(line=1, column=74), pos_end=Position(line=1, column=78), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.

<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.SetTheory.ZFC.Basic).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following Lean code fails to compile. Fix it.

```lean
theorem mem_sUnion_of_mem {x y z : ZFSet} (hy : y ∈ z) (hz : z ∈ x) : y ∈ ⋃₀ x
:= .someMissingNamespaceXYZ
mem_sUnion.2 ⟨z, hz, hy⟩
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=145, messages=[Message(data='overloaded, errors \n  1:77 Application type mismatch: The argument\n    x\n  has type\n    ZFSet.{?u.409}\n  but is expected to have type\n    PSet.{?u.409}\n  in the application\n    ⋃₀ x\n  \n  1:77 Application type mismatch: The argument\n    x\n  has type\n    ZFSet.{?u.2}\n  but is expected to have type\n    Set (Set ?m.10)\n  in the application\n    ⋃₀ x', pos=Position(line=1, column=74), pos_end=Position(line=1, column=78), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.[/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.LinearAlgebra.Matrix.GeneralLinearGroup.Projective).

[User]
The following Lean code fails to compile. Fix it.

```lean
def ProjGenLinGroup (n : Type*) [Fintype n] [DecidableEq n] (R : Type*) [CommRing R] : Type _
:= .someMissingNamespaceXYZ
GL n R ⧸ Subgroup.center (GL n R)
  deriving Group
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=174, messages=[Message(data='Invalid dotted identifier notation: Not supported on type universe\n  Type ?u.31', pos=Position(line=2, column=3), pos_end=Position(line=2, column=27), severity=<Severity.ERROR: 3>, kind='lean.invalidDottedIdent._namedError'), Message(data='Failed to delta derive `Group` instance for `ProjGenLinGroup`.\n\nNote: Delta deriving tries the following strategies: (1) inserting the definition into each explicit non-out-param parameter of a class and (2) unfolding definitions further.', pos=Position(line=4, column=11), pos_end=Position(line=4, column=16), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.Projective).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following Lean code fails to compile. Fix it.

```lean
def ProjGenLinGroup (n : Type*) [Fintype n] [DecidableEq n] (R : Type*) [CommRing R] : Type _
:= .someMissingNamespaceXYZ
GL n R ⧸ Subgroup.center (GL n R)
  deriving Group
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=174, messages=[Message(data='Invalid dotted identifier notation: Not supported on type universe\n  Type ?u.31', pos=Position(line=2, column=3), pos_end=Position(line=2, column=27), severity=<Severity.ERROR: 3>, kind='lean.invalidDottedIdent._namedError'), Message(data='Failed to delta derive `Group` instance for `ProjGenLinGroup`.\n\nNote: Delta deriving tries the following strategies: (1) inserting the definition into each explicit non-out-param parameter of a class and (2) unfolding definitions further.', pos=Position(line=4, column=11), pos_end=Position(line=4, column=16), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.[/INST]