l3lab/ntp-mathlib huggingface dataset:
theorem map.isMaximal {I : Ideal R} (H : IsMaximal I) : IsMaximal (map f I) := by
  refine'
    or_iff_not_imp_left.1 (map_eq_top_or_isMaximal_of_surjective f hf.right H) fun h => H.1.1 _
  calc
    I = comap f (map f I) := ((relIsoOfBijective f hf).right_inv I).symm
    _ = comap f ⊤ := by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝² : Ring R
inst✝¹ : Ring S
inst✝ : RingHomClass F R S
f : F
I✝ : Ideal R
hf : Function.Bijective ⇑f
I : Ideal R
H : IsMaximal I
h : map f I = ⊤
⊢ comap f (map f I) = comap f ⊤

Next tactic:
rw [h]
theorem map.isMaximal {I : Ideal R} (H : IsMaximal I) : IsMaximal (map f I) := by
  refine'
    or_iff_not_imp_left.1 (map_eq_top_or_isMaximal_of_surjective f hf.right H) fun h => H.1.1 _
  calc
    I = comap f (map f I) := ((relIsoOfBijective f hf).right_inv I).symm
    _ = comap f ⊤ := by rw [h]
    _ = ⊤ := by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝² : Ring R
inst✝¹ : Ring S
inst✝ : RingHomClass F R S
f : F
I✝ : Ideal R
hf : Function.Bijective ⇑f
I : Ideal R
H : IsMaximal I
h : map f I = ⊤
⊢ comap f ⊤ = ⊤

Next tactic:
rw [comap_top]
theorem map_mul : map f (I * J) = map f I * map f J :=
  le_antisymm
    (map_le_iff_le_comap.2 <|
      mul_le.2 fun r hri s hsj =>
        show (f (r * s)) ∈ map f I * map f J by
          

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
r : R
hri : r ∈ I
s : R
hsj : s ∈ J
⊢ f (r * s) ∈ map f I * map f J

Next tactic:
rw [_root_.map_mul]
theorem map_mul : map f (I * J) = map f I * map f J :=
  le_antisymm
    (map_le_iff_le_comap.2 <|
      mul_le.2 fun r hri s hsj =>
        show (f (r * s)) ∈ map f I * map f J by
          rw [_root_.map_mul]; 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
r : R
hri : r ∈ I
s : R
hsj : s ∈ J
⊢ f r * f s ∈ map f I * map f J

Next tactic:
exact mul_mem_mul (mem_map_of_mem f hri) (mem_map_of_mem f hsj)
theorem map_mul : map f (I * J) = map f I * map f J :=
  le_antisymm
    (map_le_iff_le_comap.2 <|
      mul_le.2 fun r hri s hsj =>
        show (f (r * s)) ∈ map f I * map f J by
          rw [_root_.map_mul]; exact mul_mem_mul (mem_map_of_mem f hri) (mem_map_of_mem f hsj))
    (span_mul_span (↑f '' ↑I) (↑f '' ↑J) ▸ (span_le.2 <|
      Set.iUnion₂_subset fun i ⟨r, hri, hfri⟩ =>
        Set.iUnion₂_subset fun j ⟨s, hsj, hfsj⟩ =>
          Set.singleton_subset_iff.2 <|
            hfri ▸ hfsj ▸ by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
i : S
x✝¹ : i ∈ ⇑f '' ↑I
r : R
hri : r ∈ ↑I
hfri : f r = i
j : S
x✝ : j ∈ ⇑f '' ↑J
s : R
hsj : s ∈ ↑J
hfsj : f s = j
⊢ f r * f s ∈ ↑(map f (I * J))

Next tactic:
rw [← _root_.map_mul]
theorem map_mul : map f (I * J) = map f I * map f J :=
  le_antisymm
    (map_le_iff_le_comap.2 <|
      mul_le.2 fun r hri s hsj =>
        show (f (r * s)) ∈ map f I * map f J by
          rw [_root_.map_mul]; exact mul_mem_mul (mem_map_of_mem f hri) (mem_map_of_mem f hsj))
    (span_mul_span (↑f '' ↑I) (↑f '' ↑J) ▸ (span_le.2 <|
      Set.iUnion₂_subset fun i ⟨r, hri, hfri⟩ =>
        Set.iUnion₂_subset fun j ⟨s, hsj, hfsj⟩ =>
          Set.singleton_subset_iff.2 <|
            hfri ▸ hfsj ▸ by rw [← _root_.map_mul]; 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
i : S
x✝¹ : i ∈ ⇑f '' ↑I
r : R
hri : r ∈ ↑I
hfri : f r = i
j : S
x✝ : j ∈ ⇑f '' ↑J
s : R
hsj : s ∈ ↑J
hfsj : f s = j
⊢ f (r * s) ∈ ↑(map f (I * J))

Next tactic:
exact mem_map_of_mem f (mul_mem_mul hri hsj)
/-- The pushforward `Ideal.map` as a monoid-with-zero homomorphism. -/
@[simps]
def mapHom : Ideal R →*₀ Ideal S where
  toFun := map f
  map_mul' I J := Ideal.map_mul f I J
  map_one' := by 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
⊢ ZeroHom.toFun { toFun := map f, map_zero' := (_ : map f ⊥ = ⊥) } 1 = 1

Next tactic:
simp only [one_eq_top]
/-- The pushforward `Ideal.map` as a monoid-with-zero homomorphism. -/
@[simps]
def mapHom : Ideal R →*₀ Ideal S where
  toFun := map f
  map_mul' I J := Ideal.map_mul f I J
  map_one' := by simp only [one_eq_top]; 

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
⊢ map f ⊤ = ⊤

Next tactic:
exact Ideal.map_top f
theorem comap_radical : comap f (radical K) = radical (comap f K) := by
  

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
⊢ comap f (radical K) = radical (comap f K)

Next tactic:
ext
theorem comap_radical : comap f (radical K) = radical (comap f K) := by
  ext
  

Proof state:
case h
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
x✝ : R
⊢ x✝ ∈ comap f (radical K) ↔ x✝ ∈ radical (comap f K)

Next tactic:
simp [radical]
theorem IsRadical.comap (hK : K.IsRadical) : (comap f K).IsRadical := by
  

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
hK : IsRadical K
⊢ IsRadical (Ideal.comap f K)

Next tactic:
rw [← hK.radical, comap_radical]
theorem IsRadical.comap (hK : K.IsRadical) : (comap f K).IsRadical := by
  rw [← hK.radical, comap_radical]
  

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
hK : IsRadical K
⊢ IsRadical (Ideal.radical (Ideal.comap f K))

Next tactic:
apply radical_isRadical
theorem le_comap_pow (n : ℕ) : K.comap f ^ n ≤ (K ^ n).comap f := by
  

Proof state:
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
n : ℕ
⊢ comap f K ^ n ≤ comap f (K ^ n)

Next tactic:
induction' n with n n_ih
theorem le_comap_pow (n : ℕ) : K.comap f ^ n ≤ (K ^ n).comap f := by
  induction' n with n n_ih
  · 

Proof state:
case zero
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
⊢ comap f K ^ Nat.zero ≤ comap f (K ^ Nat.zero)

Next tactic:
rw [pow_zero, pow_zero, Ideal.one_eq_top, Ideal.one_eq_top]
theorem le_comap_pow (n : ℕ) : K.comap f ^ n ≤ (K ^ n).comap f := by
  induction' n with n n_ih
  · rw [pow_zero, pow_zero, Ideal.one_eq_top, Ideal.one_eq_top]
    

Proof state:
case zero
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
⊢ ⊤ ≤ comap f ⊤

Next tactic:
exact rfl.le
theorem le_comap_pow (n : ℕ) : K.comap f ^ n ≤ (K ^ n).comap f := by
  induction' n with n n_ih
  · rw [pow_zero, pow_zero, Ideal.one_eq_top, Ideal.one_eq_top]
    exact rfl.le
  · 

Proof state:
case succ
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
n : ℕ
n_ih : comap f K ^ n ≤ comap f (K ^ n)
⊢ comap f K ^ Nat.succ n ≤ comap f (K ^ Nat.succ n)

Next tactic:
rw [pow_succ, pow_succ]
theorem le_comap_pow (n : ℕ) : K.comap f ^ n ≤ (K ^ n).comap f := by
  induction' n with n n_ih
  · rw [pow_zero, pow_zero, Ideal.one_eq_top, Ideal.one_eq_top]
    exact rfl.le
  · rw [pow_succ, pow_succ]
    

Proof state:
case succ
R : Type u
S : Type v
F : Type u_1
inst✝¹ : CommRing R
inst✝ : CommRing S
rc : RingHomClass F R S
f : F
I J : Ideal R
K L : Ideal S
n : ℕ
n_ih : comap f K ^ n ≤ comap f (K ^ n)
⊢ comap f K * comap f K ^ n ≤ comap f (K * K ^ n)

Next tactic:
exact (Ideal.mul_mono_right n_ih).trans (Ideal.le_comap_mul f)
theorem isPrime_radical {I : Ideal R} (hi : IsPrimary I) : IsPrime (radical I) :=
  ⟨mt radical_eq_top.1 hi.1,
   fun {x y} ⟨m, hxy⟩ => by
    

Proof state:
R : Type u
inst✝ : CommSemiring R
I : Ideal R
hi : IsPrimary I
x y : R
x✝ : x * y ∈ radical I
m : ℕ
hxy : (x * y) ^ m ∈ I
⊢ x ∈ radical I ∨ y ∈ radical I

Next tactic:
rw [mul_pow] at hxy
theorem isPrime_radical {I : Ideal R} (hi : IsPrimary I) : IsPrime (radical I) :=
  ⟨mt radical_eq_top.1 hi.1,
   fun {x y} ⟨m, hxy⟩ => by
    rw [mul_pow] at hxy; 

Proof state:
R : Type u
inst✝ : CommSemiring R
I : Ideal R
hi : IsPrimary I
x y : R
x✝ : x * y ∈ radical I
m : ℕ
hxy : x ^ m * y ^ m ∈ I
⊢ x ∈ radical I ∨ y ∈ radical I

Next tactic:
cases' hi.2 hxy with h h
theorem isPrime_radical {I : Ideal R} (hi : IsPrimary I) : IsPrime (radical I) :=
  ⟨mt radical_eq_top.1 hi.1,
   fun {x y} ⟨m, hxy⟩ => by
    rw [mul_pow] at hxy; cases' hi.2 hxy with h h
    · 

Proof state:
case inl
R : Type u
inst✝ : CommSemiring R
I : Ideal R
hi : IsPrimary I
x y : R
x✝ : x * y ∈ radical I
m : ℕ
hxy : x ^ m * y ^ m ∈ I
h : x ^ m ∈ I
⊢ x ∈ radical I ∨ y ∈ radical I

Next tactic:
exact Or.inl ⟨m, h⟩
theorem isPrime_radical {I : Ideal R} (hi : IsPrimary I) : IsPrime (radical I) :=
  ⟨mt radical_eq_top.1 hi.1,
   fun {x y} ⟨m, hxy⟩ => by
    rw [mul_pow] at hxy; cases' hi.2 hxy with h h
    · exact Or.inl ⟨m, h⟩
    · 

Proof state:
case inr
R : Type u
inst✝ : CommSemiring R
I : Ideal R
hi : IsPrimary I
x y : R
x✝ : x * y ∈ radical I
m : ℕ
hxy : x ^ m * y ^ m ∈ I
h : y ^ m ∈ radical I
⊢ x ∈ radical I ∨ y ∈ radical I

Next tactic:
exact Or.inr (mem_radical_of_pow_mem h)
theorem isPrimary_inf {I J : Ideal R} (hi : IsPrimary I) (hj : IsPrimary J)
    (hij : radical I = radical J) : IsPrimary (I ⊓ J) :=
  ⟨ne_of_lt <| lt_of_le_of_lt inf_le_left (lt_top_iff_ne_top.2 hi.1),
   fun {x y} ⟨hxyi, hxyj⟩ => by
    

Proof state:
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
⊢ x ∈ I ⊓ J ∨ y ∈ radical (I ⊓ J)

Next tactic:
rw [radical_inf, hij, inf_idem]
theorem isPrimary_inf {I J : Ideal R} (hi : IsPrimary I) (hj : IsPrimary J)
    (hij : radical I = radical J) : IsPrimary (I ⊓ J) :=
  ⟨ne_of_lt <| lt_of_le_of_lt inf_le_left (lt_top_iff_ne_top.2 hi.1),
   fun {x y} ⟨hxyi, hxyj⟩ => by
    rw [radical_inf, hij, inf_idem]
    

Proof state:
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
⊢ x ∈ I ⊓ J ∨ y ∈ radical J

Next tactic:
cases' hi.2 hxyi with hxi hyi
theorem isPrimary_inf {I J : Ideal R} (hi : IsPrimary I) (hj : IsPrimary J)
    (hij : radical I = radical J) : IsPrimary (I ⊓ J) :=
  ⟨ne_of_lt <| lt_of_le_of_lt inf_le_left (lt_top_iff_ne_top.2 hi.1),
   fun {x y} ⟨hxyi, hxyj⟩ => by
    rw [radical_inf, hij, inf_idem]
    cases' hi.2 hxyi with hxi hyi; 

Proof state:
case inl
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
hxi : x ∈ I
⊢ x ∈ I ⊓ J ∨ y ∈ radical J
case inr
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
hyi : y ∈ radical I
⊢ x ∈ I ⊓ J ∨ y ∈ radical J

Next tactic:
cases' hj.2 hxyj with hxj hyj
theorem isPrimary_inf {I J : Ideal R} (hi : IsPrimary I) (hj : IsPrimary J)
    (hij : radical I = radical J) : IsPrimary (I ⊓ J) :=
  ⟨ne_of_lt <| lt_of_le_of_lt inf_le_left (lt_top_iff_ne_top.2 hi.1),
   fun {x y} ⟨hxyi, hxyj⟩ => by
    rw [radical_inf, hij, inf_idem]
    cases' hi.2 hxyi with hxi hyi; cases' hj.2 hxyj with hxj hyj
    · 

Proof state:
case inl.inl
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
hxi : x ∈ I
hxj : x ∈ J
⊢ x ∈ I ⊓ J ∨ y ∈ radical J

Next tactic:
exact Or.inl ⟨hxi, hxj⟩
theorem isPrimary_inf {I J : Ideal R} (hi : IsPrimary I) (hj : IsPrimary J)
    (hij : radical I = radical J) : IsPrimary (I ⊓ J) :=
  ⟨ne_of_lt <| lt_of_le_of_lt inf_le_left (lt_top_iff_ne_top.2 hi.1),
   fun {x y} ⟨hxyi, hxyj⟩ => by
    rw [radical_inf, hij, inf_idem]
    cases' hi.2 hxyi with hxi hyi; cases' hj.2 hxyj with hxj hyj
    · exact Or.inl ⟨hxi, hxj⟩
    · 

Proof state:
case inl.inr
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
hxi : x ∈ I
hyj : y ∈ radical J
⊢ x ∈ I ⊓ J ∨ y ∈ radical J

Next tactic:
exact Or.inr hyj
theorem isPrimary_inf {I J : Ideal R} (hi : IsPrimary I) (hj : IsPrimary J)
    (hij : radical I = radical J) : IsPrimary (I ⊓ J) :=
  ⟨ne_of_lt <| lt_of_le_of_lt inf_le_left (lt_top_iff_ne_top.2 hi.1),
   fun {x y} ⟨hxyi, hxyj⟩ => by
    rw [radical_inf, hij, inf_idem]
    cases' hi.2 hxyi with hxi hyi; cases' hj.2 hxyj with hxj hyj
    · exact Or.inl ⟨hxi, hxj⟩
    · exact Or.inr hyj
    · 

Proof state:
case inr
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
hyi : y ∈ radical I
⊢ x ∈ I ⊓ J ∨ y ∈ radical J

Next tactic:
rw [hij] at hyi
theorem isPrimary_inf {I J : Ideal R} (hi : IsPrimary I) (hj : IsPrimary J)
    (hij : radical I = radical J) : IsPrimary (I ⊓ J) :=
  ⟨ne_of_lt <| lt_of_le_of_lt inf_le_left (lt_top_iff_ne_top.2 hi.1),
   fun {x y} ⟨hxyi, hxyj⟩ => by
    rw [radical_inf, hij, inf_idem]
    cases' hi.2 hxyi with hxi hyi; cases' hj.2 hxyj with hxj hyj
    · exact Or.inl ⟨hxi, hxj⟩
    · exact Or.inr hyj
    · rw [hij] at hyi
      

Proof state:
case inr
R : Type u
inst✝ : CommSemiring R
I J : Ideal R
hi : IsPrimary I
hj : IsPrimary J
hij : radical I = radical J
x y : R
x✝ : x * y ∈ I ⊓ J
hxyi : x * y ∈ ↑I
hxyj : x * y ∈ ↑J
hyi : y ∈ radical J
⊢ x ∈ I ⊓ J ∨ y ∈ radical J

Next tactic:
exact Or.inr hyi
theorem finsuppTotal_apply (f : ι →₀ I) :
    finsuppTotal ι M I v f = f.sum fun i x => (x : R) • v i := by
  

Proof state:
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
f : ι →₀ ↥I
⊢ (finsuppTotal ι M I v) f = Finsupp.sum f fun i x => ↑x • v i

Next tactic:
dsimp [finsuppTotal]
theorem finsuppTotal_apply (f : ι →₀ I) :
    finsuppTotal ι M I v f = f.sum fun i x => (x : R) • v i := by
  dsimp [finsuppTotal]
  

Proof state:
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
f : ι →₀ ↥I
⊢ (Finsupp.total ι M R v) (Finsupp.mapRange Subtype.val (_ : (Submodule.subtype I) 0 = 0) f) =
    Finsupp.sum f fun i x => ↑x • v i

Next tactic:
rw [Finsupp.total_apply, Finsupp.sum_mapRange_index]
theorem finsuppTotal_apply (f : ι →₀ I) :
    finsuppTotal ι M I v f = f.sum fun i x => (x : R) • v i := by
  dsimp [finsuppTotal]
  rw [Finsupp.total_apply, Finsupp.sum_mapRange_index]
  

Proof state:
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
f : ι →₀ ↥I
⊢ ∀ (a : ι), 0 • v a = 0

Next tactic:
exact fun _ => zero_smul _ _
theorem finsuppTotal_apply_eq_of_fintype [Fintype ι] (f : ι →₀ I) :
    finsuppTotal ι M I v f = ∑ i, (f i : R) • v i := by
  

Proof state:
ι : Type u_1
M : Type u_2
inst✝³ : AddCommGroup M
R : Type u_3
inst✝² : CommRing R
inst✝¹ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
inst✝ : Fintype ι
f : ι →₀ ↥I
⊢ (finsuppTotal ι M I v) f = ∑ i : ι, ↑(f i) • v i

Next tactic:
rw [finsuppTotal_apply, Finsupp.sum_fintype]
theorem finsuppTotal_apply_eq_of_fintype [Fintype ι] (f : ι →₀ I) :
    finsuppTotal ι M I v f = ∑ i, (f i : R) • v i := by
  rw [finsuppTotal_apply, Finsupp.sum_fintype]
  

Proof state:
case h
ι : Type u_1
M : Type u_2
inst✝³ : AddCommGroup M
R : Type u_3
inst✝² : CommRing R
inst✝¹ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
inst✝ : Fintype ι
f : ι →₀ ↥I
⊢ ∀ (i : ι), ↑0 • v i = 0

Next tactic:
exact fun _ => zero_smul _ _
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  

Proof state:
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
⊢ LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v)

Next tactic:
ext
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  

Proof state:
case h
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
x✝ : M
⊢ x✝ ∈ LinearMap.range (finsuppTotal ι M I v) ↔ x✝ ∈ I • Submodule.span R (Set.range v)

Next tactic:
rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  

Proof state:
case h
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
x✝ : M
⊢ x✝ ∈ LinearMap.range (finsuppTotal ι M I v) ↔ ∃ a, ∃ (_ : ∀ (i : ι), a i ∈ I), (Finsupp.sum a fun i c => c • v i) = x✝

Next tactic:
refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  

Proof state:
case h
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
x✝ : M
⊢ (∃ a, ∃ (_ : ∀ (i : ι), a i ∈ I), (Finsupp.sum a fun i c => c • v i) = x✝) →
    x✝ ∈ LinearMap.range (finsuppTotal ι M I v)

Next tactic:
rintro ⟨a, ha, rfl⟩
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  rintro ⟨a, ha, rfl⟩
  

Proof state:
case h.intro.intro
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
a : ι →₀ R
ha : ∀ (i : ι), a i ∈ I
⊢ (Finsupp.sum a fun i c => c • v i) ∈ LinearMap.range (finsuppTotal ι M I v)

Next tactic:
classical
    refine' ⟨a.mapRange (fun r => if h : r ∈ I then ⟨r, h⟩ else 0) (by simp), _⟩
    rw [finsuppTotal_apply, Finsupp.sum_mapRange_index]
    · apply Finsupp.sum_congr
      intro i _
      rw [dif_pos (ha i)]
    · exact fun _ => zero_smul _ _
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  rintro ⟨a, ha, rfl⟩
  classical
    

Proof state:
case h.intro.intro
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
a : ι →₀ R
ha : ∀ (i : ι), a i ∈ I
⊢ (Finsupp.sum a fun i c => c • v i) ∈ LinearMap.range (finsuppTotal ι M I v)

Next tactic:
refine' ⟨a.mapRange (fun r => if h : r ∈ I then ⟨r, h⟩ else 0) (by simp), _⟩
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  rintro ⟨a, ha, rfl⟩
  classical
    refine' ⟨a.mapRange (fun r => if h : r ∈ I then ⟨r, h⟩ else 0) (by 

Proof state:
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
a : ι →₀ R
ha : ∀ (i : ι), a i ∈ I
⊢ (fun r => if h : r ∈ I then { val := r, property := h } else 0) 0 = 0

Next tactic:
simp
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  rintro ⟨a, ha, rfl⟩
  classical
    refine' ⟨a.mapRange (fun r => if h : r ∈ I then ⟨r, h⟩ else 0) (by simp), _⟩
    

Proof state:
case h.intro.intro
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
a : ι →₀ R
ha : ∀ (i : ι), a i ∈ I
⊢ (finsuppTotal ι M I v)
      (Finsupp.mapRange (fun r => if h : r ∈ I then { val := r, property := h } else 0)
        (_ : (if h : 0 ∈ I then { val := 0, property := h } else 0) = 0) a) =
    Finsupp.sum a fun i c => c • v i

Next tactic:
rw [finsuppTotal_apply, Finsupp.sum_mapRange_index]
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  rintro ⟨a, ha, rfl⟩
  classical
    refine' ⟨a.mapRange (fun r => if h : r ∈ I then ⟨r, h⟩ else 0) (by simp), _⟩
    rw [finsuppTotal_apply, Finsupp.sum_mapRange_index]
    · 

Proof state:
case h.intro.intro
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
a : ι →₀ R
ha : ∀ (i : ι), a i ∈ I
⊢ (Finsupp.sum a fun a b => ↑(if h : b ∈ I then { val := b, property := h } else 0) • v a) =
    Finsupp.sum a fun i c => c • v i

Next tactic:
apply Finsupp.sum_congr
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  rintro ⟨a, ha, rfl⟩
  classical
    refine' ⟨a.mapRange (fun r => if h : r ∈ I then ⟨r, h⟩ else 0) (by simp), _⟩
    rw [finsuppTotal_apply, Finsupp.sum_mapRange_index]
    · apply Finsupp.sum_congr
      

Proof state:
case h.intro.intro.h
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
a : ι →₀ R
ha : ∀ (i : ι), a i ∈ I
⊢ ∀ x ∈ a.support, ↑(if h : a x ∈ I then { val := a x, property := h } else 0) • v x = a x • v x

Next tactic:
intro i _
theorem range_finsuppTotal :
    LinearMap.range (finsuppTotal ι M I v) = I • Submodule.span R (Set.range v) := by
  ext
  rw [Submodule.mem_ideal_smul_span_iff_exists_sum]
  refine' ⟨fun ⟨f, h⟩ => ⟨Finsupp.mapRange.linearMap I.subtype f, fun i => (f i).2, h⟩, _⟩
  rintro ⟨a, ha, rfl⟩
  classical
    refine' ⟨a.mapRange (fun r => if h : r ∈ I then ⟨r, h⟩ else 0) (by simp), _⟩
    rw [finsuppTotal_apply, Finsupp.sum_mapRange_index]
    · apply Finsupp.sum_congr
      intro i _
      

Proof state:
case h.intro.intro.h
ι : Type u_1
M : Type u_2
inst✝² : AddCommGroup M
R : Type u_3
inst✝¹ : CommRing R
inst✝ : Module R M
I : Ideal R
v : ι → M
hv : Submodule.span R (Set.range v) = ⊤
a : ι →₀ R
ha : ∀ (i : ι), a i ∈ I
i : ι
a✝ : i ∈ a.support
⊢ ↑(if h : a i ∈ I then { val := a i, property := h } else 0) • v i = a i • v i

Next tactic:
rw [dif_pos (ha i)]