l3lab/ntp-mathlib huggingface dataset:
theorem IsIntegralClosure.rank [IsPrincipalIdealRing A] [NoZeroSMulDivisors A L] :
    FiniteDimensional.finrank A C = FiniteDimensional.finrank K L := by
  haveI : Module.Free A C := IsIntegralClosure.module_free A K L C
  haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L C
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsPrincipalIdealRing A
inst✝ : NoZeroSMulDivisors A L
this✝ : Module.Free A C
this : IsNoetherian A C
⊢ FiniteDimensional.finrank A C = FiniteDimensional.finrank K L

Next tactic:
haveI : IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L :=
    IsIntegralClosure.isLocalization A K L C (Algebra.IsIntegral.of_finite _ _).isAlgebraic
theorem IsIntegralClosure.rank [IsPrincipalIdealRing A] [NoZeroSMulDivisors A L] :
    FiniteDimensional.finrank A C = FiniteDimensional.finrank K L := by
  haveI : Module.Free A C := IsIntegralClosure.module_free A K L C
  haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L C
  haveI : IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L :=
    IsIntegralClosure.isLocalization A K L C (Algebra.IsIntegral.of_finite _ _).isAlgebraic
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsPrincipalIdealRing A
inst✝ : NoZeroSMulDivisors A L
this✝¹ : Module.Free A C
this✝ : IsNoetherian A C
this : IsLocalization (algebraMapSubmonoid C A⁰) L
⊢ FiniteDimensional.finrank A C = FiniteDimensional.finrank K L

Next tactic:
let b := Basis.localizationLocalization K A⁰ L (Module.Free.chooseBasis A C)
theorem IsIntegralClosure.rank [IsPrincipalIdealRing A] [NoZeroSMulDivisors A L] :
    FiniteDimensional.finrank A C = FiniteDimensional.finrank K L := by
  haveI : Module.Free A C := IsIntegralClosure.module_free A K L C
  haveI : IsNoetherian A C := IsIntegralClosure.isNoetherian A K L C
  haveI : IsLocalization (Algebra.algebraMapSubmonoid C A⁰) L :=
    IsIntegralClosure.isLocalization A K L C (Algebra.IsIntegral.of_finite _ _).isAlgebraic
  let b := Basis.localizationLocalization K A⁰ L (Module.Free.chooseBasis A C)
  

Proof state:
R : Type u_1
A : Type u_2
K : Type u_3
inst✝¹⁸ : CommRing R
inst✝¹⁷ : CommRing A
inst✝¹⁶ : Field K
inst✝¹⁵ : IsDomain A
inst✝¹⁴ : Algebra A K
inst✝¹³ : IsFractionRing A K
L : Type u_4
inst✝¹² : Field L
C : Type u_5
inst✝¹¹ : CommRing C
inst✝¹⁰ : Algebra K L
inst✝⁹ : Algebra A L
inst✝⁸ : IsScalarTower A K L
inst✝⁷ : Algebra C L
inst✝⁶ : IsIntegralClosure C A L
inst✝⁵ : Algebra A C
inst✝⁴ : IsScalarTower A C L
inst✝³ : FiniteDimensional K L
inst✝² : IsSeparable K L
inst✝¹ : IsPrincipalIdealRing A
inst✝ : NoZeroSMulDivisors A L
this✝¹ : Module.Free A C
this✝ : IsNoetherian A C
this : IsLocalization (algebraMapSubmonoid C A⁰) L
b : Basis (Module.Free.ChooseBasisIndex A C) K L := Basis.localizationLocalization K A⁰ L (Module.Free.chooseBasis A C)
⊢ FiniteDimensional.finrank A C = FiniteDimensional.finrank K L

Next tactic:
rw [FiniteDimensional.finrank_eq_card_chooseBasisIndex, FiniteDimensional.finrank_eq_card_basis b]
theorem leftInverse_nat : Function.LeftInverse ofNat toNat
  | WType.mk Natα.zero f => by
    

Proof state:
f : Natβ Natα.zero → WType Natβ
⊢ ofNat (toNat (mk Natα.zero f)) = mk Natα.zero f

Next tactic:
rw [toNat, ofNat]
theorem leftInverse_nat : Function.LeftInverse ofNat toNat
  | WType.mk Natα.zero f => by
    rw [toNat, ofNat]
    

Proof state:
f : Natβ Natα.zero → WType Natβ
⊢ mk Natα.zero Empty.elim = mk Natα.zero f

Next tactic:
congr
theorem leftInverse_nat : Function.LeftInverse ofNat toNat
  | WType.mk Natα.zero f => by
    rw [toNat, ofNat]
    congr
    

Proof state:
case e_f
f : Natβ Natα.zero → WType Natβ
⊢ Empty.elim = f

Next tactic:
ext x
theorem leftInverse_nat : Function.LeftInverse ofNat toNat
  | WType.mk Natα.zero f => by
    rw [toNat, ofNat]
    congr
    ext x
    

Proof state:
case e_f.h
f : Natβ Natα.zero → WType Natβ
x : Empty
⊢ Empty.elim x = f x

Next tactic:
cases x
theorem leftInverse_nat : Function.LeftInverse ofNat toNat
  | WType.mk Natα.zero f => by
    rw [toNat, ofNat]
    congr
    ext x
    cases x
  | WType.mk Natα.succ f => by
    

Proof state:
f : Natβ Natα.succ → WType Natβ
⊢ ofNat (toNat (mk Natα.succ f)) = mk Natα.succ f

Next tactic:
simp only [toNat, ofNat, leftInverse_nat (f ()), mk.injEq, heq_eq_eq, true_and]
theorem leftInverse_nat : Function.LeftInverse ofNat toNat
  | WType.mk Natα.zero f => by
    rw [toNat, ofNat]
    congr
    ext x
    cases x
  | WType.mk Natα.succ f => by
    simp only [toNat, ofNat, leftInverse_nat (f ()), mk.injEq, heq_eq_eq, true_and]
    

Proof state:
f : Natβ Natα.succ → WType Natβ
⊢ (fun x => f ()) = f

Next tactic:
rfl
theorem rightInverse_nat : Function.RightInverse ofNat toNat
  | Nat.zero => rfl
  | Nat.succ n => by 

Proof state:
n : ℕ
⊢ toNat (ofNat (Nat.succ n)) = Nat.succ n

Next tactic:
rw [ofNat, toNat, rightInverse_nat n]
theorem leftInverse_list : Function.LeftInverse (ofList γ) (toList _)
  | WType.mk Listα.nil f => by
    

Proof state:
γ : Type u
f : Listβ γ Listα.nil → WType (Listβ γ)
⊢ ofList γ (toList γ (mk Listα.nil f)) = mk Listα.nil f

Next tactic:
simp only [toList, ofList, mk.injEq, heq_eq_eq, true_and]
theorem leftInverse_list : Function.LeftInverse (ofList γ) (toList _)
  | WType.mk Listα.nil f => by
    simp only [toList, ofList, mk.injEq, heq_eq_eq, true_and]
    

Proof state:
γ : Type u
f : Listβ γ Listα.nil → WType (Listβ γ)
⊢ PEmpty.elim = f

Next tactic:
ext x
theorem leftInverse_list : Function.LeftInverse (ofList γ) (toList _)
  | WType.mk Listα.nil f => by
    simp only [toList, ofList, mk.injEq, heq_eq_eq, true_and]
    ext x
    

Proof state:
case h
γ : Type u
f : Listβ γ Listα.nil → WType (Listβ γ)
x : PEmpty.{u + 1}
⊢ PEmpty.elim x = f x

Next tactic:
cases x
theorem leftInverse_list : Function.LeftInverse (ofList γ) (toList _)
  | WType.mk Listα.nil f => by
    simp only [toList, ofList, mk.injEq, heq_eq_eq, true_and]
    ext x
    cases x
  | WType.mk (Listα.cons x) f => by
    

Proof state:
γ : Type u
x : γ
f : Listβ γ (Listα.cons x) → WType (Listβ γ)
⊢ ofList γ (toList γ (mk (Listα.cons x) f)) = mk (Listα.cons x) f

Next tactic:
simp only [ofList, leftInverse_list (f PUnit.unit), mk.injEq, heq_eq_eq, true_and]
theorem leftInverse_list : Function.LeftInverse (ofList γ) (toList _)
  | WType.mk Listα.nil f => by
    simp only [toList, ofList, mk.injEq, heq_eq_eq, true_and]
    ext x
    cases x
  | WType.mk (Listα.cons x) f => by
    simp only [ofList, leftInverse_list (f PUnit.unit), mk.injEq, heq_eq_eq, true_and]
    

Proof state:
γ : Type u
x : γ
f : Listβ γ (Listα.cons x) → WType (Listβ γ)
⊢ (fun x => f PUnit.unit) = f

Next tactic:
rfl
theorem rightInverse_list : Function.RightInverse (ofList γ) (toList _)
  | List.nil => rfl
  | List.cons hd tl => by 

Proof state:
γ : Type u
hd : γ
tl : List γ
⊢ toList γ (ofList γ (hd :: tl)) = hd :: tl

Next tactic:
simp only [toList, rightInverse_list tl]
@[simp]
theorem stdBasis_apply' (i i' : ι) : (stdBasis R (fun _x : ι => R) i) 1 i' = ite (i = i') 1 0 := by
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
i i' : ι
⊢ (stdBasis R (fun _x => R) i) 1 i' = if i = i' then 1 else 0

Next tactic:
rw [LinearMap.stdBasis_apply, Function.update_apply, Pi.zero_apply]
@[simp]
theorem stdBasis_apply' (i i' : ι) : (stdBasis R (fun _x : ι => R) i) 1 i' = ite (i = i') 1 0 := by
  rw [LinearMap.stdBasis_apply, Function.update_apply, Pi.zero_apply]
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
i i' : ι
⊢ (if i' = i then 1 else 0) = if i = i' then 1 else 0

Next tactic:
congr 1
@[simp]
theorem stdBasis_apply' (i i' : ι) : (stdBasis R (fun _x : ι => R) i) 1 i' = ite (i = i') 1 0 := by
  rw [LinearMap.stdBasis_apply, Function.update_apply, Pi.zero_apply]
  congr 1; 

Proof state:
case e_c
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
i i' : ι
⊢ (i' = i) = (i = i')

Next tactic:
rw [eq_iff_iff, eq_comm]
theorem stdBasis_eq_pi_diag (i : ι) : stdBasis R φ i = pi (diag i) := by
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
i : ι
⊢ stdBasis R φ i = pi (diag i)

Next tactic:
ext x j
theorem stdBasis_eq_pi_diag (i : ι) : stdBasis R φ i = pi (diag i) := by
  ext x j
  -- Porting note: made types explicit
  

Proof state:
case h.h
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
i : ι
x : φ i
j : ι
⊢ (stdBasis R φ i) x j = (pi (diag i)) x j

Next tactic:
convert (update_apply (R := R) (φ := φ) (ι := ι) 0 x i j _).symm
theorem stdBasis_eq_pi_diag (i : ι) : stdBasis R φ i = pi (diag i) := by
  ext x j
  -- Porting note: made types explicit
  convert (update_apply (R := R) (φ := φ) (ι := ι) 0 x i j _).symm
  

Proof state:
case h.e'_2.h.e'_1
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
i : ι
x : φ i
j : ι
⊢ x = id x

Next tactic:
rfl
theorem proj_comp_stdBasis (i j : ι) : (proj i).comp (stdBasis R φ j) = diag j i := by
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
i j : ι
⊢ proj i ∘ₗ stdBasis R φ j = diag j i

Next tactic:
rw [stdBasis_eq_pi_diag, proj_pi]
theorem iSup_range_stdBasis_le_iInf_ker_proj (I J : Set ι) (h : Disjoint I J) :
    ⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
h : Disjoint I J
⊢ ⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i)

Next tactic:
refine' iSup_le fun i => iSup_le fun hi => range_le_iff_comap.2 _
theorem iSup_range_stdBasis_le_iInf_ker_proj (I J : Set ι) (h : Disjoint I J) :
    ⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  refine' iSup_le fun i => iSup_le fun hi => range_le_iff_comap.2 _
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
h : Disjoint I J
i : ι
hi : i ∈ I
⊢ comap (stdBasis R φ i) (⨅ i ∈ J, ker (proj i)) = ⊤

Next tactic:
simp only [← ker_comp, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
theorem iSup_range_stdBasis_le_iInf_ker_proj (I J : Set ι) (h : Disjoint I J) :
    ⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  refine' iSup_le fun i => iSup_le fun hi => range_le_iff_comap.2 _
  simp only [← ker_comp, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
h : Disjoint I J
i : ι
hi : i ∈ I
⊢ ∀ ⦃x : φ i⦄, x ∈ ⊤ → ∀ i_1 ∈ J, (proj i_1 ∘ₗ stdBasis R φ i) x = 0

Next tactic:
rintro b - j hj
theorem iSup_range_stdBasis_le_iInf_ker_proj (I J : Set ι) (h : Disjoint I J) :
    ⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  refine' iSup_le fun i => iSup_le fun hi => range_le_iff_comap.2 _
  simp only [← ker_comp, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
  rintro b - j hj
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
h : Disjoint I J
i : ι
hi : i ∈ I
b : φ i
j : ι
hj : j ∈ J
⊢ (proj j ∘ₗ stdBasis R φ i) b = 0

Next tactic:
rw [proj_stdBasis_ne R φ j i, zero_apply]
theorem iSup_range_stdBasis_le_iInf_ker_proj (I J : Set ι) (h : Disjoint I J) :
    ⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  refine' iSup_le fun i => iSup_le fun hi => range_le_iff_comap.2 _
  simp only [← ker_comp, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
  rintro b - j hj
  rw [proj_stdBasis_ne R φ j i, zero_apply]
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
h : Disjoint I J
i : ι
hi : i ∈ I
b : φ i
j : ι
hj : j ∈ J
⊢ j ≠ i

Next tactic:
rintro rfl
theorem iSup_range_stdBasis_le_iInf_ker_proj (I J : Set ι) (h : Disjoint I J) :
    ⨆ i ∈ I, range (stdBasis R φ i) ≤ ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  refine' iSup_le fun i => iSup_le fun hi => range_le_iff_comap.2 _
  simp only [← ker_comp, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
  rintro b - j hj
  rw [proj_stdBasis_ne R φ j i, zero_apply]
  rintro rfl
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
h : Disjoint I J
j : ι
hj : j ∈ J
hi : j ∈ I
b : φ j
⊢ False

Next tactic:
exact h.le_bot ⟨hi, hj⟩
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
⊢ ∀ ⦃x : (i : ι) → φ i⦄, x ∈ ⨅ i ∈ J, ker (proj i) → x ∈ ⨆ i ∈ I, range (stdBasis R φ i)

Next tactic:
intro b hb
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : b ∈ ⨅ i ∈ J, ker (proj i)
⊢ b ∈ ⨆ i ∈ I, range (stdBasis R φ i)

Next tactic:
simp only [mem_iInf, mem_ker, proj_apply] at hb
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
⊢ b ∈ ⨆ i ∈ I, range (stdBasis R φ i)

Next tactic:
rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          ext i
          rw [Finset.sum_apply, ← stdBasis_same R φ i (b i)]
          refine Finset.sum_eq_single i (fun j _ ne => stdBasis_ne _ _ _ _ ne.symm _) ?_
          intro hiI
          rw [stdBasis_same]
          exact hb _ ((hu trivial).resolve_left hiI)]
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
⊢ ∑ i in I, (stdBasis R φ i) (b i) = b

Next tactic:
ext i
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          ext i
          

Proof state:
case h
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
i : ι
⊢ Finset.sum I (fun i => (stdBasis R φ i) (b i)) i = b i

Next tactic:
rw [Finset.sum_apply, ← stdBasis_same R φ i (b i)]
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          ext i
          rw [Finset.sum_apply, ← stdBasis_same R φ i (b i)]
          

Proof state:
case h
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
i : ι
⊢ ∑ c in I, (stdBasis R φ c) (b c) i = (stdBasis R φ i) (b i) i

Next tactic:
refine Finset.sum_eq_single i (fun j _ ne => stdBasis_ne _ _ _ _ ne.symm _) ?_
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          ext i
          rw [Finset.sum_apply, ← stdBasis_same R φ i (b i)]
          refine Finset.sum_eq_single i (fun j _ ne => stdBasis_ne _ _ _ _ ne.symm _) ?_
          

Proof state:
case h
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
i : ι
⊢ i ∉ I → (stdBasis R φ i) (b i) i = 0

Next tactic:
intro hiI
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          ext i
          rw [Finset.sum_apply, ← stdBasis_same R φ i (b i)]
          refine Finset.sum_eq_single i (fun j _ ne => stdBasis_ne _ _ _ _ ne.symm _) ?_
          intro hiI
          

Proof state:
case h
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
i : ι
hiI : i ∉ I
⊢ (stdBasis R φ i) (b i) i = 0

Next tactic:
rw [stdBasis_same]
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          ext i
          rw [Finset.sum_apply, ← stdBasis_same R φ i (b i)]
          refine Finset.sum_eq_single i (fun j _ ne => stdBasis_ne _ _ _ _ ne.symm _) ?_
          intro hiI
          rw [stdBasis_same]
          

Proof state:
case h
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
i : ι
hiI : i ∉ I
⊢ b i = 0

Next tactic:
exact hb _ ((hu trivial).resolve_left hiI)
theorem iInf_ker_proj_le_iSup_range_stdBasis {I : Finset ι} {J : Set ι} (hu : Set.univ ⊆ ↑I ∪ J) :
    ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) ≤ ⨆ i ∈ I, range (stdBasis R φ i) :=
  SetLike.le_def.2
    (by
      intro b hb
      simp only [mem_iInf, mem_ker, proj_apply] at hb
      rw [←
        show (∑ i in I, stdBasis R φ i (b i)) = b by
          ext i
          rw [Finset.sum_apply, ← stdBasis_same R φ i (b i)]
          refine Finset.sum_eq_single i (fun j _ ne => stdBasis_ne _ _ _ _ ne.symm _) ?_
          intro hiI
          rw [stdBasis_same]
          exact hb _ ((hu trivial).resolve_left hiI)]
      

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I : Finset ι
J : Set ι
hu : univ ⊆ ↑I ∪ J
b : (i : ι) → φ i
hb : ∀ i ∈ J, b i = 0
⊢ ∑ i in I, (stdBasis R φ i) (b i) ∈ ⨆ i ∈ I, range (stdBasis R φ i)

Next tactic:
exact sum_mem_biSup fun i _ => mem_range_self (stdBasis R φ i) (b i)
theorem iSup_range_stdBasis_eq_iInf_ker_proj {I J : Set ι} (hd : Disjoint I J)
    (hu : Set.univ ⊆ I ∪ J) (hI : Set.Finite I) :
    ⨆ i ∈ I, range (stdBasis R φ i) = ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
hd : Disjoint I J
hu : univ ⊆ I ∪ J
hI : Set.Finite I
⊢ ⨆ i ∈ I, range (stdBasis R φ i) = ⨅ i ∈ J, ker (proj i)

Next tactic:
refine' le_antisymm (iSup_range_stdBasis_le_iInf_ker_proj _ _ _ _ hd) _
theorem iSup_range_stdBasis_eq_iInf_ker_proj {I J : Set ι} (hd : Disjoint I J)
    (hu : Set.univ ⊆ I ∪ J) (hI : Set.Finite I) :
    ⨆ i ∈ I, range (stdBasis R φ i) = ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  refine' le_antisymm (iSup_range_stdBasis_le_iInf_ker_proj _ _ _ _ hd) _
  

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
hd : Disjoint I J
hu : univ ⊆ I ∪ J
hI : Set.Finite I
⊢ ⨅ i ∈ J, ker (proj i) ≤ ⨆ i ∈ I, range (stdBasis R φ i)

Next tactic:
have : Set.univ ⊆ ↑hI.toFinset ∪ J := by rwa [hI.coe_toFinset]
theorem iSup_range_stdBasis_eq_iInf_ker_proj {I J : Set ι} (hd : Disjoint I J)
    (hu : Set.univ ⊆ I ∪ J) (hI : Set.Finite I) :
    ⨆ i ∈ I, range (stdBasis R φ i) = ⨅ i ∈ J, ker (proj i : (∀ i, φ i) →ₗ[R] φ i) := by
  refine' le_antisymm (iSup_range_stdBasis_le_iInf_ker_proj _ _ _ _ hd) _
  have : Set.univ ⊆ ↑hI.toFinset ∪ J := by 

Proof state:
R : Type u_1
ι : Type u_2
inst✝³ : Semiring R
φ : ι → Type u_3
inst✝² : (i : ι) → AddCommMonoid (φ i)
inst✝¹ : (i : ι) → Module R (φ i)
inst✝ : DecidableEq ι
I J : Set ι
hd : Disjoint I J
hu : univ ⊆ I ∪ J
hI : Set.Finite I
⊢ univ ⊆ ↑(Finite.toFinset hI) ∪ J

Next tactic:
rwa [hI.coe_toFinset]