l3lab/ntp-mathlib huggingface dataset:
theorem sign_sum {ι : Type*} {s : Finset ι} {f : ι → α} (hs : s.Nonempty) (t : SignType)
    (h : ∀ i ∈ s, sign (f i) = t) : sign (∑ i in s, f i) = t := by
  cases t
  · simp_rw [zero_eq_zero, sign_eq_zero_iff] at h ⊢
    exact Finset.sum_eq_zero h
  · simp_rw [neg_eq_neg_one, sign_eq_neg_one_iff] at h ⊢
    exact Finset.sum_neg h hs
  · simp_rw [pos_eq_one, sign_eq_one_iff] at h ⊢
    

Proof state:
case pos
α : Type u_1
inst✝ : LinearOrderedAddCommGroup α
ι : Type u_2
s : Finset ι
f : ι → α
hs : Finset.Nonempty s
h : ∀ i ∈ s, 0 < f i
⊢ 0 < ∑ i in s, f i

Next tactic:
exact Finset.sum_pos h hs
theorem sign_eq_sign (n : ℤ) : Int.sign n = SignType.sign n := by
  

Proof state:
α : Type u_1
n : ℤ
⊢ sign n = ↑(SignType.sign n)

Next tactic:
obtain (n | _) | _ := n
theorem sign_eq_sign (n : ℤ) : Int.sign n = SignType.sign n := by
  obtain (n | _) | _ := n <;> 

Proof state:
case ofNat.zero
α : Type u_1
⊢ sign (ofNat Nat.zero) = ↑(SignType.sign (ofNat Nat.zero))

Next tactic:
simp [sign, Int.sign_neg, negSucc_lt_zero]
theorem sign_eq_sign (n : ℤ) : Int.sign n = SignType.sign n := by
  obtain (n | _) | _ := n <;> 

Proof state:
case ofNat.succ
α : Type u_1
n✝ : ℕ
⊢ sign (ofNat (Nat.succ n✝)) = ↑(SignType.sign (ofNat (Nat.succ n✝)))

Next tactic:
simp [sign, Int.sign_neg, negSucc_lt_zero]
theorem sign_eq_sign (n : ℤ) : Int.sign n = SignType.sign n := by
  obtain (n | _) | _ := n <;> 

Proof state:
case negSucc
α : Type u_1
a✝ : ℕ
⊢ sign -[a✝+1] = ↑(SignType.sign -[a✝+1])

Next tactic:
simp [sign, Int.sign_neg, negSucc_lt_zero]
private theorem exists_signed_sum_aux {α : Type u_1} [DecidableEq α] (s : Finset α) (f : α → ℤ) :
    ∃ (β : Type u_1) (t : Finset β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∈ s) ∧
        (t.card = ∑ a in s, (f a).natAbs) ∧
          ∀ a ∈ s, (∑ b in t, if g b = a then (sgn b : ℤ) else 0) = f a := by
  

Proof state:
α✝ α : Type u_1
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
⊢ ∃ β t sgn g,
    (∀ (b : β), g b ∈ s) ∧
      card t = ∑ a in s, Int.natAbs (f a) ∧ ∀ a ∈ s, (∑ b in t, if g b = a then ↑(sgn b) else 0) = f a

Next tactic:
refine'
    ⟨(Σ _ : { x // x ∈ s }, ℕ), Finset.univ.sigma fun a => range (f a).natAbs,
      fun a => sign (f a.1), fun a => a.1, fun a => a.1.2, _, _⟩
private theorem exists_signed_sum_aux {α : Type u_1} [DecidableEq α] (s : Finset α) (f : α → ℤ) :
    ∃ (β : Type u_1) (t : Finset β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∈ s) ∧
        (t.card = ∑ a in s, (f a).natAbs) ∧
          ∀ a ∈ s, (∑ b in t, if g b = a then (sgn b : ℤ) else 0) = f a := by
  refine'
    ⟨(Σ _ : { x // x ∈ s }, ℕ), Finset.univ.sigma fun a => range (f a).natAbs,
      fun a => sign (f a.1), fun a => a.1, fun a => a.1.2, _, _⟩
  · 

Proof state:
case refine'_1
α✝ α : Type u_1
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
⊢ card (Finset.sigma univ fun a => range (Int.natAbs (f ↑a))) = ∑ a in s, Int.natAbs (f a)

Next tactic:
simp [sum_attach (f := fun a => (f a).natAbs)]
private theorem exists_signed_sum_aux {α : Type u_1} [DecidableEq α] (s : Finset α) (f : α → ℤ) :
    ∃ (β : Type u_1) (t : Finset β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∈ s) ∧
        (t.card = ∑ a in s, (f a).natAbs) ∧
          ∀ a ∈ s, (∑ b in t, if g b = a then (sgn b : ℤ) else 0) = f a := by
  refine'
    ⟨(Σ _ : { x // x ∈ s }, ℕ), Finset.univ.sigma fun a => range (f a).natAbs,
      fun a => sign (f a.1), fun a => a.1, fun a => a.1.2, _, _⟩
  · simp [sum_attach (f := fun a => (f a).natAbs)]
  · 

Proof state:
case refine'_2
α✝ α : Type u_1
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
⊢ ∀ a ∈ s,
    (∑ b in Finset.sigma univ fun a => range (Int.natAbs (f ↑a)),
        if (fun a => ↑a.fst) b = a then ↑((fun a => sign (f ↑a.fst)) b) else 0) =
      f a

Next tactic:
intro x hx
private theorem exists_signed_sum_aux {α : Type u_1} [DecidableEq α] (s : Finset α) (f : α → ℤ) :
    ∃ (β : Type u_1) (t : Finset β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∈ s) ∧
        (t.card = ∑ a in s, (f a).natAbs) ∧
          ∀ a ∈ s, (∑ b in t, if g b = a then (sgn b : ℤ) else 0) = f a := by
  refine'
    ⟨(Σ _ : { x // x ∈ s }, ℕ), Finset.univ.sigma fun a => range (f a).natAbs,
      fun a => sign (f a.1), fun a => a.1, fun a => a.1.2, _, _⟩
  · simp [sum_attach (f := fun a => (f a).natAbs)]
  · intro x hx
    

Proof state:
case refine'_2
α✝ α : Type u_1
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
x : α
hx : x ∈ s
⊢ (∑ b in Finset.sigma univ fun a => range (Int.natAbs (f ↑a)),
      if (fun a => ↑a.fst) b = x then ↑((fun a => sign (f ↑a.fst)) b) else 0) =
    f x

Next tactic:
simp [sum_sigma, hx, ← Int.sign_eq_sign, Int.sign_mul_abs, mul_comm |f _|,
      sum_attach (s := s) (f := fun y => if y = x then f y else 0)]
/-- We can decompose a sum of absolute value `n` into a sum of `n` signs. -/
theorem exists_signed_sum {α : Type u_1} [DecidableEq α] (s : Finset α) (f : α → ℤ) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∈ s) ∧
        (Fintype.card β = ∑ a in s, (f a).natAbs) ∧
          ∀ a ∈ s, (∑ b, if g b = a then (sgn b : ℤ) else 0) = f a :=
  let ⟨β, t, sgn, g, hg, ht, hf⟩ := exists_signed_sum_aux s f
  ⟨t, inferInstance, fun b => sgn b, fun b => g b, fun b => hg b, by 

Proof state:
α✝ α : Type u_1
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
β : Type u_1
t : Finset β
sgn : β → SignType
g : β → α
hg : ∀ (b : β), g b ∈ s
ht : card t = ∑ a in s, Int.natAbs (f a)
hf : ∀ a ∈ s, (∑ b in t, if g b = a then ↑(sgn b) else 0) = f a
⊢ Fintype.card { x // x ∈ t } = ∑ a in s, Int.natAbs (f a)

Next tactic:
simp [ht]
/-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i in s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a := by
  

Proof state:
α✝ α : Type u_1
inst✝¹ : Nonempty α
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
n : ℕ
h : ∑ i in s, Int.natAbs (f i) ≤ n
⊢ ∃ β x sgn g,
    (∀ (b : β), g b ∉ s → sgn b = 0) ∧ Fintype.card β = n ∧ ∀ a ∈ s, (∑ i : β, if g i = a then ↑(sgn i) else 0) = f a

Next tactic:
obtain ⟨β, _, sgn, g, hg, hβ, hf⟩ := exists_signed_sum s f
/-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i in s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a := by
  obtain ⟨β, _, sgn, g, hg, hβ, hf⟩ := exists_signed_sum s f
  

Proof state:
case intro.intro.intro.intro.intro.intro
α✝ α : Type u_1
inst✝¹ : Nonempty α
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
n : ℕ
h : ∑ i in s, Int.natAbs (f i) ≤ n
β : Type u_1
w✝ : Fintype β
sgn : β → SignType
g : β → α
hg : ∀ (b : β), g b ∈ s
hβ : Fintype.card β = ∑ a in s, Int.natAbs (f a)
hf : ∀ a ∈ s, (∑ b : β, if g b = a then ↑(sgn b) else 0) = f a
⊢ ∃ β x sgn g,
    (∀ (b : β), g b ∉ s → sgn b = 0) ∧ Fintype.card β = n ∧ ∀ a ∈ s, (∑ i : β, if g i = a then ↑(sgn i) else 0) = f a

Next tactic:
refine'
    ⟨Sum β (Fin (n - ∑ i in s, (f i).natAbs)), inferInstance, Sum.elim sgn 0,
      Sum.elim g (Classical.arbitrary (Fin (n - Finset.sum s fun i => Int.natAbs (f i)) → α)),
        _, by simp [hβ, h], fun a ha => by simp [hf _ ha]⟩
/-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i in s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a := by
  obtain ⟨β, _, sgn, g, hg, hβ, hf⟩ := exists_signed_sum s f
  refine'
    ⟨Sum β (Fin (n - ∑ i in s, (f i).natAbs)), inferInstance, Sum.elim sgn 0,
      Sum.elim g (Classical.arbitrary (Fin (n - Finset.sum s fun i => Int.natAbs (f i)) → α)),
        _, by 

Proof state:
α✝ α : Type u_1
inst✝¹ : Nonempty α
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
n : ℕ
h : ∑ i in s, Int.natAbs (f i) ≤ n
β : Type u_1
w✝ : Fintype β
sgn : β → SignType
g : β → α
hg : ∀ (b : β), g b ∈ s
hβ : Fintype.card β = ∑ a in s, Int.natAbs (f a)
hf : ∀ a ∈ s, (∑ b : β, if g b = a then ↑(sgn b) else 0) = f a
⊢ Fintype.card (β ⊕ Fin (n - ∑ i in s, Int.natAbs (f i))) = n

Next tactic:
simp [hβ, h]
/-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i in s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a := by
  obtain ⟨β, _, sgn, g, hg, hβ, hf⟩ := exists_signed_sum s f
  refine'
    ⟨Sum β (Fin (n - ∑ i in s, (f i).natAbs)), inferInstance, Sum.elim sgn 0,
      Sum.elim g (Classical.arbitrary (Fin (n - Finset.sum s fun i => Int.natAbs (f i)) → α)),
        _, by simp [hβ, h], fun a ha => by 

Proof state:
α✝ α : Type u_1
inst✝¹ : Nonempty α
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
n : ℕ
h : ∑ i in s, Int.natAbs (f i) ≤ n
β : Type u_1
w✝ : Fintype β
sgn : β → SignType
g : β → α
hg : ∀ (b : β), g b ∈ s
hβ : Fintype.card β = ∑ a in s, Int.natAbs (f a)
hf : ∀ a ∈ s, (∑ b : β, if g b = a then ↑(sgn b) else 0) = f a
a : α
ha : a ∈ s
⊢ (∑ i : β ⊕ Fin (n - ∑ i in s, Int.natAbs (f i)),
      if Sum.elim g (Classical.arbitrary (Fin (n - ∑ i in s, Int.natAbs (f i)) → α)) i = a then ↑(Sum.elim sgn 0 i)
      else 0) =
    f a

Next tactic:
simp [hf _ ha]
/-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i in s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a := by
  obtain ⟨β, _, sgn, g, hg, hβ, hf⟩ := exists_signed_sum s f
  refine'
    ⟨Sum β (Fin (n - ∑ i in s, (f i).natAbs)), inferInstance, Sum.elim sgn 0,
      Sum.elim g (Classical.arbitrary (Fin (n - Finset.sum s fun i => Int.natAbs (f i)) → α)),
        _, by simp [hβ, h], fun a ha => by simp [hf _ ha]⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro
α✝ α : Type u_1
inst✝¹ : Nonempty α
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
n : ℕ
h : ∑ i in s, Int.natAbs (f i) ≤ n
β : Type u_1
w✝ : Fintype β
sgn : β → SignType
g : β → α
hg : ∀ (b : β), g b ∈ s
hβ : Fintype.card β = ∑ a in s, Int.natAbs (f a)
hf : ∀ a ∈ s, (∑ b : β, if g b = a then ↑(sgn b) else 0) = f a
⊢ ∀ (b : β ⊕ Fin (n - ∑ i in s, Int.natAbs (f i))),
    Sum.elim g (Classical.arbitrary (Fin (n - ∑ i in s, Int.natAbs (f i)) → α)) b ∉ s → Sum.elim sgn 0 b = 0

Next tactic:
rintro (b | b) hb
/-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i in s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a := by
  obtain ⟨β, _, sgn, g, hg, hβ, hf⟩ := exists_signed_sum s f
  refine'
    ⟨Sum β (Fin (n - ∑ i in s, (f i).natAbs)), inferInstance, Sum.elim sgn 0,
      Sum.elim g (Classical.arbitrary (Fin (n - Finset.sum s fun i => Int.natAbs (f i)) → α)),
        _, by simp [hβ, h], fun a ha => by simp [hf _ ha]⟩
  rintro (b | b) hb
  · 

Proof state:
case intro.intro.intro.intro.intro.intro.inl
α✝ α : Type u_1
inst✝¹ : Nonempty α
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
n : ℕ
h : ∑ i in s, Int.natAbs (f i) ≤ n
β : Type u_1
w✝ : Fintype β
sgn : β → SignType
g : β → α
hg : ∀ (b : β), g b ∈ s
hβ : Fintype.card β = ∑ a in s, Int.natAbs (f a)
hf : ∀ a ∈ s, (∑ b : β, if g b = a then ↑(sgn b) else 0) = f a
b : β
hb : Sum.elim g (Classical.arbitrary (Fin (n - ∑ i in s, Int.natAbs (f i)) → α)) (Sum.inl b) ∉ s
⊢ Sum.elim sgn 0 (Sum.inl b) = 0

Next tactic:
cases hb (hg _)
/-- We can decompose a sum of absolute value less than `n` into a sum of at most `n` signs. -/
theorem exists_signed_sum' {α : Type u_1} [Nonempty α] [DecidableEq α] (s : Finset α) (f : α → ℤ)
    (n : ℕ) (h : (∑ i in s, (f i).natAbs) ≤ n) :
    ∃ (β : Type u_1) (_ : Fintype β) (sgn : β → SignType) (g : β → α),
      (∀ b, g b ∉ s → sgn b = 0) ∧
        Fintype.card β = n ∧ ∀ a ∈ s, (∑ i, if g i = a then (sgn i : ℤ) else 0) = f a := by
  obtain ⟨β, _, sgn, g, hg, hβ, hf⟩ := exists_signed_sum s f
  refine'
    ⟨Sum β (Fin (n - ∑ i in s, (f i).natAbs)), inferInstance, Sum.elim sgn 0,
      Sum.elim g (Classical.arbitrary (Fin (n - Finset.sum s fun i => Int.natAbs (f i)) → α)),
        _, by simp [hβ, h], fun a ha => by simp [hf _ ha]⟩
  rintro (b | b) hb
  · cases hb (hg _)
  · 

Proof state:
case intro.intro.intro.intro.intro.intro.inr
α✝ α : Type u_1
inst✝¹ : Nonempty α
inst✝ : DecidableEq α
s : Finset α
f : α → ℤ
n : ℕ
h : ∑ i in s, Int.natAbs (f i) ≤ n
β : Type u_1
w✝ : Fintype β
sgn : β → SignType
g : β → α
hg : ∀ (b : β), g b ∈ s
hβ : Fintype.card β = ∑ a in s, Int.natAbs (f a)
hf : ∀ a ∈ s, (∑ b : β, if g b = a then ↑(sgn b) else 0) = f a
b : Fin (n - ∑ i in s, Int.natAbs (f i))
hb : Sum.elim g (Classical.arbitrary (Fin (n - ∑ i in s, Int.natAbs (f i)) → α)) (Sum.inr b) ∉ s
⊢ Sum.elim sgn 0 (Sum.inr b) = 0

Next tactic:
rfl
instance : Algebra R (LocallyConstant X Y) where
  toRingHom := constRingHom.comp <| algebraMap R Y
  commutes' := by
    

Proof state:
X : Type u_1
Y : Type u_2
inst✝³ : TopologicalSpace X
R : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring Y
inst✝ : Algebra R Y
⊢ ∀ (r : R) (x : LocallyConstant X Y),
    (RingHom.comp constRingHom (algebraMap R Y)) r * x = x * (RingHom.comp constRingHom (algebraMap R Y)) r

Next tactic:
intros
instance : Algebra R (LocallyConstant X Y) where
  toRingHom := constRingHom.comp <| algebraMap R Y
  commutes' := by
    intros
    

Proof state:
X : Type u_1
Y : Type u_2
inst✝³ : TopologicalSpace X
R : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring Y
inst✝ : Algebra R Y
r✝ : R
x✝ : LocallyConstant X Y
⊢ (RingHom.comp constRingHom (algebraMap R Y)) r✝ * x✝ = x✝ * (RingHom.comp constRingHom (algebraMap R Y)) r✝

Next tactic:
ext
instance : Algebra R (LocallyConstant X Y) where
  toRingHom := constRingHom.comp <| algebraMap R Y
  commutes' := by
    intros
    ext
    

Proof state:
case h
X : Type u_1
Y : Type u_2
inst✝³ : TopologicalSpace X
R : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring Y
inst✝ : Algebra R Y
r✝ : R
x✝¹ : LocallyConstant X Y
x✝ : X
⊢ ((RingHom.comp constRingHom (algebraMap R Y)) r✝ * x✝¹) x✝ =
    (x✝¹ * (RingHom.comp constRingHom (algebraMap R Y)) r✝) x✝

Next tactic:
exact Algebra.commutes' _ _
instance : Algebra R (LocallyConstant X Y) where
  toRingHom := constRingHom.comp <| algebraMap R Y
  commutes' := by
    intros
    ext
    exact Algebra.commutes' _ _
  smul_def' := by
    

Proof state:
X : Type u_1
Y : Type u_2
inst✝³ : TopologicalSpace X
R : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring Y
inst✝ : Algebra R Y
⊢ ∀ (r : R) (x : LocallyConstant X Y), r • x = (RingHom.comp constRingHom (algebraMap R Y)) r * x

Next tactic:
intros
instance : Algebra R (LocallyConstant X Y) where
  toRingHom := constRingHom.comp <| algebraMap R Y
  commutes' := by
    intros
    ext
    exact Algebra.commutes' _ _
  smul_def' := by
    intros
    

Proof state:
X : Type u_1
Y : Type u_2
inst✝³ : TopologicalSpace X
R : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring Y
inst✝ : Algebra R Y
r✝ : R
x✝ : LocallyConstant X Y
⊢ r✝ • x✝ = (RingHom.comp constRingHom (algebraMap R Y)) r✝ * x✝

Next tactic:
ext
instance : Algebra R (LocallyConstant X Y) where
  toRingHom := constRingHom.comp <| algebraMap R Y
  commutes' := by
    intros
    ext
    exact Algebra.commutes' _ _
  smul_def' := by
    intros
    ext
    

Proof state:
case h
X : Type u_1
Y : Type u_2
inst✝³ : TopologicalSpace X
R : Type u_3
inst✝² : CommSemiring R
inst✝¹ : Semiring Y
inst✝ : Algebra R Y
r✝ : R
x✝¹ : LocallyConstant X Y
x✝ : X
⊢ (r✝ • x✝¹) x✝ = ((RingHom.comp constRingHom (algebraMap R Y)) r✝ * x✝¹) x✝

Next tactic:
exact Algebra.smul_def' _ _
/-- `LocallyConstant.comap` as a `MulHom`. -/
@[to_additive (attr := simps) "`LocallyConstant.comap` as an `AddHom`."]
noncomputable
def comapMulHom [Mul Z] (f : X → Y) (hf : Continuous f) :
    LocallyConstant Y Z →ₙ* LocallyConstant X Z where
  toFun := comap f
  map_mul' r s := by 

Proof state:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
R : Type u_3
inst✝¹ : TopologicalSpace Y
Z : Type ?u.108282
inst✝ : Mul Z
f : X → Y
hf : Continuous f
r s : LocallyConstant Y Z
⊢ comap f (r * s) = comap f r * comap f s

Next tactic:
ext x
/-- `LocallyConstant.comap` as a `MulHom`. -/
@[to_additive (attr := simps) "`LocallyConstant.comap` as an `AddHom`."]
noncomputable
def comapMulHom [Mul Z] (f : X → Y) (hf : Continuous f) :
    LocallyConstant Y Z →ₙ* LocallyConstant X Z where
  toFun := comap f
  map_mul' r s := by ext x; 

Proof state:
case h
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
R : Type u_3
inst✝¹ : TopologicalSpace Y
Z : Type ?u.108282
inst✝ : Mul Z
f : X → Y
hf : Continuous f
r s : LocallyConstant Y Z
x : X
⊢ (comap f (r * s)) x = (comap f r * comap f s) x

Next tactic:
simp [hf]
/-- `LocallyConstant.comap` as a `MonoidHom`. -/
@[to_additive (attr := simps) "`LocallyConstant.comap` as an `AddMonoidHom`."]
noncomputable
def comapMonoidHom [MulOneClass Z] (f : X → Y) (hf : Continuous f) :
    LocallyConstant Y Z →* LocallyConstant X Z where
  toFun := comap f
  map_one' := by 

Proof state:
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
R : Type u_3
inst✝¹ : TopologicalSpace Y
Z : Type ?u.110337
inst✝ : MulOneClass Z
f : X → Y
hf : Continuous f
⊢ comap f 1 = 1

Next tactic:
ext x
/-- `LocallyConstant.comap` as a `MonoidHom`. -/
@[to_additive (attr := simps) "`LocallyConstant.comap` as an `AddMonoidHom`."]
noncomputable
def comapMonoidHom [MulOneClass Z] (f : X → Y) (hf : Continuous f) :
    LocallyConstant Y Z →* LocallyConstant X Z where
  toFun := comap f
  map_one' := by ext x; 

Proof state:
case h
X : Type u_1
Y : Type u_2
inst✝² : TopologicalSpace X
R : Type u_3
inst✝¹ : TopologicalSpace Y
Z : Type ?u.110337
inst✝ : MulOneClass Z
f : X → Y
hf : Continuous f
x : X
⊢ (comap f 1) x = 1 x

Next tactic:
simp [hf]
/-- `LocallyConstant.comap` as a linear map. -/
@[simps!]
noncomputable
def comapₗ (R : Type*) [Semiring R] [AddCommMonoid Z] [Module R Z] (f : X → Y)
    (hf : Continuous f) : LocallyConstant Y Z →ₗ[R] LocallyConstant X Z where
  toFun := comap f
  map_add' := map_add (comapAddMonoidHom f hf)
  map_smul' r s := by 

Proof state:
X : Type u_1
Y : Type u_2
inst✝⁴ : TopologicalSpace X
R✝ : Type u_3
inst✝³ : TopologicalSpace Y
Z : Type ?u.116015
R : Type u_4
inst✝² : Semiring R
inst✝¹ : AddCommMonoid Z
inst✝ : Module R Z
f : X → Y
hf : Continuous f
r : R
s : LocallyConstant Y Z
⊢ AddHom.toFun
      { toFun := comap f,
        map_add' :=
          (_ :
            ∀ (x y : LocallyConstant Y Z),
              (comapAddMonoidHom f hf) (x + y) = (comapAddMonoidHom f hf) x + (comapAddMonoidHom f hf) y) }
      (r • s) =
    (RingHom.id R) r •
      AddHom.toFun
        { toFun := comap f,
          map_add' :=
            (_ :
              ∀ (x y : LocallyConstant Y Z),
                (comapAddMonoidHom f hf) (x + y) = (comapAddMonoidHom f hf) x + (comapAddMonoidHom f hf) y) }
        s

Next tactic:
ext x
/-- `LocallyConstant.comap` as a linear map. -/
@[simps!]
noncomputable
def comapₗ (R : Type*) [Semiring R] [AddCommMonoid Z] [Module R Z] (f : X → Y)
    (hf : Continuous f) : LocallyConstant Y Z →ₗ[R] LocallyConstant X Z where
  toFun := comap f
  map_add' := map_add (comapAddMonoidHom f hf)
  map_smul' r s := by ext x; 

Proof state:
case h
X : Type u_1
Y : Type u_2
inst✝⁴ : TopologicalSpace X
R✝ : Type u_3
inst✝³ : TopologicalSpace Y
Z : Type ?u.116015
R : Type u_4
inst✝² : Semiring R
inst✝¹ : AddCommMonoid Z
inst✝ : Module R Z
f : X → Y
hf : Continuous f
r : R
s : LocallyConstant Y Z
x : X
⊢ (AddHom.toFun
        { toFun := comap f,
          map_add' :=
            (_ :
              ∀ (x y : LocallyConstant Y Z),
                (comapAddMonoidHom f hf) (x + y) = (comapAddMonoidHom f hf) x + (comapAddMonoidHom f hf) y) }
        (r • s))
      x =
    ((RingHom.id R) r •
        AddHom.toFun
          { toFun := comap f,
            map_add' :=
              (_ :
                ∀ (x y : LocallyConstant Y Z),
                  (comapAddMonoidHom f hf) (x + y) = (comapAddMonoidHom f hf) x + (comapAddMonoidHom f hf) y) }
          s)
      x

Next tactic:
simp [hf]
/-- `LocallyConstant.comap` as an `AlgHom` -/
@[simps!]
noncomputable
def comapₐ (R : Type*) [CommSemiring R] [Semiring Z] [Algebra R Z]
    (f : X → Y) (hf : Continuous f) : LocallyConstant Y Z →ₐ[R] LocallyConstant X Z where
  toRingHom := comapRingHom f hf
  commutes' r := by 

Proof state:
X : Type u_1
Y : Type u_2
inst✝⁴ : TopologicalSpace X
R✝ : Type u_3
inst✝³ : TopologicalSpace Y
Z : Type ?u.124182
R : Type u_4
inst✝² : CommSemiring R
inst✝¹ : Semiring Z
inst✝ : Algebra R Z
f : X → Y
hf : Continuous f
r : R
⊢ OneHom.toFun (↑↑(comapRingHom f hf)) ((algebraMap R (LocallyConstant Y Z)) r) = (algebraMap R (LocallyConstant X Z)) r

Next tactic:
ext x
/-- `LocallyConstant.comap` as an `AlgHom` -/
@[simps!]
noncomputable
def comapₐ (R : Type*) [CommSemiring R] [Semiring Z] [Algebra R Z]
    (f : X → Y) (hf : Continuous f) : LocallyConstant Y Z →ₐ[R] LocallyConstant X Z where
  toRingHom := comapRingHom f hf
  commutes' r := by ext x; 

Proof state:
case h
X : Type u_1
Y : Type u_2
inst✝⁴ : TopologicalSpace X
R✝ : Type u_3
inst✝³ : TopologicalSpace Y
Z : Type ?u.124182
R : Type u_4
inst✝² : CommSemiring R
inst✝¹ : Semiring Z
inst✝ : Algebra R Z
f : X → Y
hf : Continuous f
r : R
x : X
⊢ (OneHom.toFun (↑↑(comapRingHom f hf)) ((algebraMap R (LocallyConstant Y Z)) r)) x =
    ((algebraMap R (LocallyConstant X Z)) r) x

Next tactic:
simp [hf]
@[to_additive]
theorem mem_iSup_of_directed {S : ι → Subsemigroup M} (hS : Directed (· ≤ ·) S) {x : M} :
    (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by
  

Proof state:
ι : Sort u_1
M : Type u_2
A : Type u_3
B : Type u_4
inst✝ : Mul M
S : ι → Subsemigroup M
hS : Directed (fun x x_1 => x ≤ x_1) S
x : M
⊢ x ∈ ⨆ i, S i ↔ ∃ i, x ∈ S i

Next tactic:
refine ⟨?_, fun ⟨i, hi⟩ ↦ le_iSup S i hi⟩
@[to_additive]
theorem mem_iSup_of_directed {S : ι → Subsemigroup M} (hS : Directed (· ≤ ·) S) {x : M} :
    (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by
  refine ⟨?_, fun ⟨i, hi⟩ ↦ le_iSup S i hi⟩
  

Proof state:
ι : Sort u_1
M : Type u_2
A : Type u_3
B : Type u_4
inst✝ : Mul M
S : ι → Subsemigroup M
hS : Directed (fun x x_1 => x ≤ x_1) S
x : M
⊢ x ∈ ⨆ i, S i → ∃ i, x ∈ S i

Next tactic:
suffices x ∈ closure (⋃ i, (S i : Set M)) → ∃ i, x ∈ S i by
    simpa only [closure_iUnion, closure_eq (S _)] using this
@[to_additive]
theorem mem_iSup_of_directed {S : ι → Subsemigroup M} (hS : Directed (· ≤ ·) S) {x : M} :
    (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by
  refine ⟨?_, fun ⟨i, hi⟩ ↦ le_iSup S i hi⟩
  suffices x ∈ closure (⋃ i, (S i : Set M)) → ∃ i, x ∈ S i by
    

Proof state:
ι : Sort u_1
M : Type u_2
A : Type u_3
B : Type u_4
inst✝ : Mul M
S : ι → Subsemigroup M
hS : Directed (fun x x_1 => x ≤ x_1) S
x : M
this : x ∈ closure (⋃ i, ↑(S i)) → ∃ i, x ∈ S i
⊢ x ∈ ⨆ i, S i → ∃ i, x ∈ S i

Next tactic:
simpa only [closure_iUnion, closure_eq (S _)] using this