awhecmu/canonical-drafter-extract-mathlib huggingface dataset:
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
⊢ ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N

Tactic:
have ϕ_max := this.choose_spec
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
⊢ a ∈ ϕ.submoduleImage N

Tactic:
have a_mem : a ∈ ϕ.submoduleImage N := generator_mem _
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : a = 0
⊢ N = ⊥

Tactic:
have := eq_bot_of_generator_maximal_submoduleImage_eq_zero b'M N_le_M ϕ_max a_zero
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this_1 :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this_1.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this_1.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : a = 0
this : N = ⊥
⊢ ∃ y ∈ M,
    ∃ (a : R),
      a • y ∈ N ∧
        ∃ M' ≤ M,
          ∃ N' ≤ N,
            N' ≤ M' ∧
              (∀ (c : R), ∀ z ∈ M', c • y + z = 0 → c = 0) ∧
                (∀ (c : R), ∀ z ∈ N', c • a • y + z = 0 → c = 0) ∧
                  ∀ (n' : ℕ) (bN' : Basis.{0, u_2, u_4} (Fin n') R ↥N'),
                    ∃ (bN : Basis.{0, u_2, u_4} (Fin (n' + 1)) R ↥N),
                      ∀ (m' : ℕ) (hn'm' : n' ≤ m') (bM' : Basis.{0, u_2, u_4} (Fin m') R ↥M'),
                        ∃ (hnm : n' + 1 ≤ m' + 1) (bM : Basis.{0, u_2, u_4} (Fin (m' + 1)) R ↥M),
                          ∀ (as : Fin n' → R),
                            (∀ (i : Fin n'),
                                (↑((bN' : (a : Fin n') → ↥N') i) : O) =
                                  HSMul.hSMul (β := O) (as i)
                                    (↑((bM' : (a : Fin m') → ↥M') (Fin.castLE hn'm' i)) : O)) →
                              ∃ (as' : Fin (n' + 1) → R),
                                ∀ (i : Fin (n' + 1)),
                                  (↑((bN : (a : Fin (n' + 1)) → ↥N) i) : O) =
                                    HSMul.hSMul (β := O) (as' i)
                                      (↑((bM : (a : Fin (m' + 1)) → ↥M) (Fin.castLE hnm i)) : O)

Tactic:
contradiction
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
⊢ ∀ (i : ι), a ∣ (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯)

Tactic:
have hdvd : ∀ i, a ∣ b'M.coord i ⟨y, N_le_M yN⟩ := fun i ↦
    generator_maximal_submoduleImage_dvd N_le_M ϕ_max y yN ϕy_eq (b'M.coord i)
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
⊢ y' ∈ M

Tactic:
have y'M : y' ∈ M := M.sum_mem fun i _ ↦ M.smul_mem (c i) (b'M i).2
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
y'M : y' ∈ M
simp : y' = ∑ x : ι, HSMul.hSMul (β := O) (c x) ((M.subtype : (a : ↥M) → O) ((b'M : (a : ι) → ↥M) x : ↥M) : O)
⊢ y' = (M.subtype : (a : ↥M) → O) (∑ i : ι, HSMul.hSMul (β := ↥M) (c i) ((b'M : (a : ι) → ↥M) i : ↥M))

Tactic:
simp only [map_sum, map_smul]

Premises used: map_sum, map_smul
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
y'M : y' ∈ M
⊢ y' = ∑ x : ι, HSMul.hSMul (β := O) (c x) ((M.subtype : (a : ↥M) → O) ((b'M : (a : ι) → ↥M) x : ↥M) : O)

Tactic:
rfl
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
y'M : y' ∈ M
⊢ Subtype.mk (p := fun (x : O) ↦ x ∈ M) y' y'M = ∑ i : ι, HSMul.hSMul (β := ↥M) (c i) ((b'M : (a : ι) → ↥M) i : ↥M)

Tactic:
have mk_y' : (⟨y', y'M⟩ : M) = ∑ i, c i • b'M i :=
    Subtype.ext
      (show y' = M.subtype _ by
        simp only [map_sum, map_smul]
        rfl)
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
y'M : y' ∈ M
mk_y' :
  Subtype.mk (p := fun (x : O) ↦ x ∈ M) y' y'M = ∑ i : ι, HSMul.hSMul (β := ↥M) (c i) ((b'M : (a : ι) → ↥M) i : ↥M)
⊢ a • y' = y

Tactic:
Subtype.mk_eq_mk.mp (show (a • ⟨y', y'M⟩ : M) = ⟨y, N_le_M yN⟩ from ?_)

Premises used: Subtype.mk_eq_mk, Iff.mp
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
y'M : y' ∈ M
mk_y' :
  Subtype.mk (p := fun (x : O) ↦ x ∈ M) y' y'M = ∑ i : ι, HSMul.hSMul (β := ↥M) (c i) ((b'M : (a : ι) → ↥M) i : ↥M)
refine : a • Subtype.mk (p := fun (x : O) ↦ x ∈ M) y' y'M = Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯
⊢ a • y' = y

Tactic:
refine Subtype.mk_eq_mk.mp (show (a • ⟨y', y'M⟩ : M) = ⟨y, N_le_M yN⟩ from ?_)

Premises used: Subtype.mk_eq_mk, Iff.mp
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
y'M : y' ∈ M
mk_y' :
  Subtype.mk (p := fun (x : O) ↦ x ∈ M) y' y'M = ∑ i : ι, HSMul.hSMul (β := ↥M) (c i) ((b'M : (a : ι) → ↥M) i : ↥M)
rw :
  Eq.{u_4 + 1} (α := ↥M) (∑ x : ι, a • HSMul.hSMul (β := ↥M) (c x) ((b'M : (a : ι) → ↥M) x : ↥M))
    (∑ i : ι,
      HSMul.hSMul.{u_2, u_4, u_4} (α := R) (β := ↥M)
        ((((b'M.repr : (a : ↥M) → ι →₀ R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) : ι →₀ R) : (a : ι) → R) i : R)
        ((b'M : (a : ι) → ↥M) i : ↥M))
⊢ a • Subtype.mk (p := fun (x : O) ↦ x ∈ M) y' y'M = Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯

Tactic:
rw [← b'M.sum_repr ⟨y, N_le_M yN⟩, mk_y', Finset.smul_sum]

Premises used: Subtype.mk, Finset.smul_sum, Module.Basis.sum_repr
-- Module: Mathlib.LinearAlgebra.FreeModule.PID
Goal:
ι : Type u_1
R : Type u_2
inst : CommRing R
inst_1 : IsPrincipalIdealRing R
inst_2 : IsDomain R
inst_3 : Finite ι
O : Type u_4
inst_4 : AddCommGroup O
inst_5 : Module R O
M N : Submodule R O
b'M : Basis.{u_1, u_2, u_4} ι R ↥M
N_bot : N ≠ ⊥
N_le_M : N ≤ M
this :
  ∃ (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N
ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R :=
  this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
    ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R), ¬ϕ.submoduleImage N < ψ.submoduleImage N)
ϕ_max :
  ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
    ¬this.choose (p := fun (ϕ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R) ↦
              ∀ (ψ : LinearMap.{u_2, u_2, u_4, u_2} (RingHom.id R) (↥M) R),
                ¬ϕ.submoduleImage N < ψ.submoduleImage N).submoduleImage
          N <
        ψ.submoduleImage N
a : R := generator (ϕ.submoduleImage N)
a_mem : a ∈ ϕ.submoduleImage N
a_zero : ¬a = 0
y : O
yN : y ∈ N
ϕy_eq : (ϕ : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a
c : (i : ι) → R
hc : ∀ (i : ι), (b'M.coord i : (a : ↥M) → R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) = a * c i
val : Fintype ι
y' : O := ∑ i : ι, HSMul.hSMul (β := O) (c i) (↑((b'M : (a : ι) → ↥M) i) : O)
y'M : y' ∈ M
mk_y' :
  Subtype.mk (p := fun (x : O) ↦ x ∈ M) y' y'M = ∑ i : ι, HSMul.hSMul (β := ↥M) (c i) ((b'M : (a : ι) → ↥M) i : ↥M)
⊢ Eq.{u_4 + 1} (α := ↥M) (∑ x : ι, a • HSMul.hSMul (β := ↥M) (c x) ((b'M : (a : ι) → ↥M) x : ↥M))
    (∑ i : ι,
      HSMul.hSMul.{u_2, u_4, u_4} (α := R) (β := ↥M)
        ((((b'M.repr : (a : ↥M) → ι →₀ R) (Subtype.mk (p := fun (x : O) ↦ x ∈ M) y ⋯) : ι →₀ R) : (a : ι) → R) i : R)
        ((b'M : (a : ι) → ↥M) i : ↥M))

Tactic:
Finset.sum_congr rfl fun i _ ↦ ?_

Premises used: Finset.sum_congr, rfl