l3lab/ntp-mathlib huggingface dataset:
/-- Restrict a non-unital ring homomorphism with a left inverse to a ring isomorphism to its
`NonUnitalRingHom.srange`. -/
def sofLeftInverse' {g : S → R} {f : F} (h : Function.LeftInverse g f) : R ≃+* srange f :=
  { srangeRestrict f with
    toFun := srangeRestrict f
    invFun := fun x => g (subtype (srange f) x)
    left_inv := h
    right_inv := fun x =>
      Subtype.ext <|
        let ⟨x', hx'⟩ := NonUnitalRingHom.mem_srange.mp x.prop
        show f (g x) = x by 

Proof state:
R : Type u
S : Type v
T : Type w
inst✝³ : NonUnitalNonAssocSemiring R
M : Subsemigroup R
inst✝² : NonUnitalNonAssocSemiring S
inst✝¹ : NonUnitalNonAssocSemiring T
s t : NonUnitalSubsemiring R
F : Type u_1
inst✝ : NonUnitalRingHomClass F R S
g : S → R
f : F
h : Function.LeftInverse g ⇑f
src✝ : R →ₙ+* ↥(srange f) := srangeRestrict f
x : ↥(srange f)
x' : R
hx' : f x' = ↑x
⊢ f (g ↑x) = ↑x

Next tactic:
rw [← hx', h x']
theorem isArtinian_of_range_eq_ker [IsArtinian R M] [IsArtinian R P] (f : M →ₗ[R] N) (g : N →ₗ[R] P)
    (hf : Function.Injective f) (hg : Function.Surjective g)
    (h : LinearMap.range f = LinearMap.ker g) : IsArtinian R N :=
  ⟨wellFounded_lt_exact_sequence (IsArtinian.wellFounded_submodule_lt R M)
    (IsArtinian.wellFounded_submodule_lt R P) (LinearMap.range f) (Submodule.map f)
    (Submodule.comap f) (Submodule.comap g) (Submodule.map g) (Submodule.gciMapComap hf)
    (Submodule.giMapComap hg)
    (by 

Proof state:
R : Type u_1
M : Type u_2
P : Type u_3
N : Type u_4
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup P
inst✝⁵ : AddCommGroup N
inst✝⁴ : Module R M
inst✝³ : Module R P
inst✝² : Module R N
inst✝¹ : IsArtinian R M
inst✝ : IsArtinian R P
f : M →ₗ[R] N
g : N →ₗ[R] P
hf : Function.Injective ⇑f
hg : Function.Surjective ⇑g
h : LinearMap.range f = LinearMap.ker g
⊢ ∀ (a : Submodule R N), Submodule.map f (Submodule.comap f a) = a ⊓ LinearMap.range f

Next tactic:
simp [Submodule.map_comap_eq, inf_comm]
theorem isArtinian_of_range_eq_ker [IsArtinian R M] [IsArtinian R P] (f : M →ₗ[R] N) (g : N →ₗ[R] P)
    (hf : Function.Injective f) (hg : Function.Surjective g)
    (h : LinearMap.range f = LinearMap.ker g) : IsArtinian R N :=
  ⟨wellFounded_lt_exact_sequence (IsArtinian.wellFounded_submodule_lt R M)
    (IsArtinian.wellFounded_submodule_lt R P) (LinearMap.range f) (Submodule.map f)
    (Submodule.comap f) (Submodule.comap g) (Submodule.map g) (Submodule.gciMapComap hf)
    (Submodule.giMapComap hg)
    (by simp [Submodule.map_comap_eq, inf_comm]) (by 

Proof state:
R : Type u_1
M : Type u_2
P : Type u_3
N : Type u_4
inst✝⁸ : Ring R
inst✝⁷ : AddCommGroup M
inst✝⁶ : AddCommGroup P
inst✝⁵ : AddCommGroup N
inst✝⁴ : Module R M
inst✝³ : Module R P
inst✝² : Module R N
inst✝¹ : IsArtinian R M
inst✝ : IsArtinian R P
f : M →ₗ[R] N
g : N →ₗ[R] P
hf : Function.Injective ⇑f
hg : Function.Surjective ⇑g
h : LinearMap.range f = LinearMap.ker g
⊢ ∀ (a : Submodule R N), Submodule.comap g (Submodule.map g a) = a ⊔ LinearMap.range f

Next tactic:
simp [Submodule.comap_map_eq, h]
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  

Proof state:
R✝ : Type u_1
M : Type u_2
P : Type u_3
N : Type u_4
inst✝⁷ : Ring R✝
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup P
inst✝⁴ : AddCommGroup N
inst✝³ : Module R✝ M
inst✝² : Module R✝ P
inst✝¹ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝ : Finite ι
⊢ ∀ {M : ι → Type u_7} [inst : Ring R] [inst_1 : (i : ι) → AddCommGroup (M i)] [inst_2 : (i : ι) → Module R (M i)]
    [inst_3 : ∀ (i : ι), IsArtinian R (M i)], IsArtinian R ((i : ι) → M i)

Next tactic:
apply Finite.induction_empty_option _ _ _ ι
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · 

Proof state:
R✝ : Type u_1
M : Type u_2
P : Type u_3
N : Type u_4
inst✝⁷ : Ring R✝
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup P
inst✝⁴ : AddCommGroup N
inst✝³ : Module R✝ M
inst✝² : Module R✝ P
inst✝¹ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝ : Finite ι
⊢ ∀ {α β : Type u_6},
    α ≃ β →
      (∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
          [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)) →
        ∀ {M : β → Type u_7} [inst : Ring R] [inst_1 : (i : β) → AddCommGroup (M i)] [inst_2 : (i : β) → Module R (M i)]
          [inst_3 : ∀ (i : β), IsArtinian R (M i)], IsArtinian R ((i : β) → M i)

Next tactic:
intro α β e hα M _ _ _ _
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · intro α β e hα M _ _ _ _
    

Proof state:
R✝ : Type u_1
M✝ : Type u_2
P : Type u_3
N : Type u_4
inst✝¹¹ : Ring R✝
inst✝¹⁰ : AddCommGroup M✝
inst✝⁹ : AddCommGroup P
inst✝⁸ : AddCommGroup N
inst✝⁷ : Module R✝ M✝
inst✝⁶ : Module R✝ P
inst✝⁵ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝⁴ : Finite ι
α β : Type u_6
e : α ≃ β
hα :
  ∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
    [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)
M : β → Type u_7
inst✝³ : Ring R
inst✝² : (i : β) → AddCommGroup (M i)
inst✝¹ : (i : β) → Module R (M i)
inst✝ : ∀ (i : β), IsArtinian R (M i)
⊢ IsArtinian R ((i : β) → M i)

Next tactic:
have := @hα
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · intro α β e hα M _ _ _ _
    have := @hα
    

Proof state:
R✝ : Type u_1
M✝ : Type u_2
P : Type u_3
N : Type u_4
inst✝¹¹ : Ring R✝
inst✝¹⁰ : AddCommGroup M✝
inst✝⁹ : AddCommGroup P
inst✝⁸ : AddCommGroup N
inst✝⁷ : Module R✝ M✝
inst✝⁶ : Module R✝ P
inst✝⁵ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝⁴ : Finite ι
α β : Type u_6
e : α ≃ β
hα :
  ∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
    [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)
M : β → Type u_7
inst✝³ : Ring R
inst✝² : (i : β) → AddCommGroup (M i)
inst✝¹ : (i : β) → Module R (M i)
inst✝ : ∀ (i : β), IsArtinian R (M i)
this :
  ∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
    [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)
⊢ IsArtinian R ((i : β) → M i)

Next tactic:
exact isArtinian_of_linearEquiv (LinearEquiv.piCongrLeft R M e)
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · intro α β e hα M _ _ _ _
    have := @hα
    exact isArtinian_of_linearEquiv (LinearEquiv.piCongrLeft R M e)
  · 

Proof state:
R✝ : Type u_1
M : Type u_2
P : Type u_3
N : Type u_4
inst✝⁷ : Ring R✝
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup P
inst✝⁴ : AddCommGroup N
inst✝³ : Module R✝ M
inst✝² : Module R✝ P
inst✝¹ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝ : Finite ι
⊢ ∀ {M : PEmpty.{u_6 + 1} → Type u_7} [inst : Ring R] [inst_1 : (i : PEmpty.{u_6 + 1}) → AddCommGroup (M i)]
    [inst_2 : (i : PEmpty.{u_6 + 1}) → Module R (M i)] [inst_3 : ∀ (i : PEmpty.{u_6 + 1}), IsArtinian R (M i)],
    IsArtinian R ((i : PEmpty.{u_6 + 1}) → M i)

Next tactic:
intro M _ _ _ _
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · intro α β e hα M _ _ _ _
    have := @hα
    exact isArtinian_of_linearEquiv (LinearEquiv.piCongrLeft R M e)
  · intro M _ _ _ _
    

Proof state:
R✝ : Type u_1
M✝ : Type u_2
P : Type u_3
N : Type u_4
inst✝¹¹ : Ring R✝
inst✝¹⁰ : AddCommGroup M✝
inst✝⁹ : AddCommGroup P
inst✝⁸ : AddCommGroup N
inst✝⁷ : Module R✝ M✝
inst✝⁶ : Module R✝ P
inst✝⁵ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝⁴ : Finite ι
M : PEmpty.{u_6 + 1} → Type u_7
inst✝³ : Ring R
inst✝² : (i : PEmpty.{u_6 + 1}) → AddCommGroup (M i)
inst✝¹ : (i : PEmpty.{u_6 + 1}) → Module R (M i)
inst✝ : ∀ (i : PEmpty.{u_6 + 1}), IsArtinian R (M i)
⊢ IsArtinian R ((i : PEmpty.{u_6 + 1}) → M i)

Next tactic:
infer_instance
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · intro α β e hα M _ _ _ _
    have := @hα
    exact isArtinian_of_linearEquiv (LinearEquiv.piCongrLeft R M e)
  · intro M _ _ _ _
    infer_instance
  · 

Proof state:
R✝ : Type u_1
M : Type u_2
P : Type u_3
N : Type u_4
inst✝⁷ : Ring R✝
inst✝⁶ : AddCommGroup M
inst✝⁵ : AddCommGroup P
inst✝⁴ : AddCommGroup N
inst✝³ : Module R✝ M
inst✝² : Module R✝ P
inst✝¹ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝ : Finite ι
⊢ ∀ {α : Type u_6} [inst : Fintype α],
    (∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
        [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)) →
      ∀ {M : Option α → Type u_7} [inst : Ring R] [inst_1 : (i : Option α) → AddCommGroup (M i)]
        [inst_2 : (i : Option α) → Module R (M i)] [inst_3 : ∀ (i : Option α), IsArtinian R (M i)],
        IsArtinian R ((i : Option α) → M i)

Next tactic:
intro α _ ih M _ _ _ _
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · intro α β e hα M _ _ _ _
    have := @hα
    exact isArtinian_of_linearEquiv (LinearEquiv.piCongrLeft R M e)
  · intro M _ _ _ _
    infer_instance
  · intro α _ ih M _ _ _ _
    

Proof state:
R✝ : Type u_1
M✝ : Type u_2
P : Type u_3
N : Type u_4
inst✝¹² : Ring R✝
inst✝¹¹ : AddCommGroup M✝
inst✝¹⁰ : AddCommGroup P
inst✝⁹ : AddCommGroup N
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ P
inst✝⁶ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝⁵ : Finite ι
α : Type u_6
inst✝⁴ : Fintype α
ih :
  ∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
    [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)
M : Option α → Type u_7
inst✝³ : Ring R
inst✝² : (i : Option α) → AddCommGroup (M i)
inst✝¹ : (i : Option α) → Module R (M i)
inst✝ : ∀ (i : Option α), IsArtinian R (M i)
⊢ IsArtinian R ((i : Option α) → M i)

Next tactic:
have := @ih
instance isArtinian_pi {R ι : Type*} [Finite ι] :
    ∀ {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)],
      ∀ [∀ i, Module R (M i)], ∀ [∀ i, IsArtinian R (M i)], IsArtinian R (∀ i, M i) := by
  apply Finite.induction_empty_option _ _ _ ι
  · intro α β e hα M _ _ _ _
    have := @hα
    exact isArtinian_of_linearEquiv (LinearEquiv.piCongrLeft R M e)
  · intro M _ _ _ _
    infer_instance
  · intro α _ ih M _ _ _ _
    have := @ih
    

Proof state:
R✝ : Type u_1
M✝ : Type u_2
P : Type u_3
N : Type u_4
inst✝¹² : Ring R✝
inst✝¹¹ : AddCommGroup M✝
inst✝¹⁰ : AddCommGroup P
inst✝⁹ : AddCommGroup N
inst✝⁸ : Module R✝ M✝
inst✝⁷ : Module R✝ P
inst✝⁶ : Module R✝ N
R : Type u_5
ι : Type u_6
inst✝⁵ : Finite ι
α : Type u_6
inst✝⁴ : Fintype α
ih :
  ∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
    [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)
M : Option α → Type u_7
inst✝³ : Ring R
inst✝² : (i : Option α) → AddCommGroup (M i)
inst✝¹ : (i : Option α) → Module R (M i)
inst✝ : ∀ (i : Option α), IsArtinian R (M i)
this :
  ∀ {M : α → Type u_7} [inst : Ring R] [inst_1 : (i : α) → AddCommGroup (M i)] [inst_2 : (i : α) → Module R (M i)]
    [inst_3 : ∀ (i : α), IsArtinian R (M i)], IsArtinian R ((i : α) → M i)
⊢ IsArtinian R ((i : Option α) → M i)

Next tactic:
exact isArtinian_of_linearEquiv (LinearEquiv.piOptionEquivProd R).symm
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
⊢ Set.Finite s

Next tactic:
refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
⊢ (fun x x_1 => x > x_1) ↪r fun x x_1 => x < x_1

Next tactic:
have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
⊢ (fun x x_1 => x > x_1) ↪r fun x x_1 => x < x_1

Next tactic:
have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    exact (f y).2
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
⊢ ∀ (n : ℕ), Subtype.val ∘ ⇑f '' {m | n ≤ m} ⊆ s

Next tactic:
rintro n x ⟨y, _, rfl⟩
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    

Proof state:
case intro.intro
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
n y : ℕ
left✝ : y ∈ {m | n ≤ m}
⊢ (Subtype.val ∘ ⇑f) y ∈ s

Next tactic:
exact (f y).2
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    exact (f y).2
  

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
this : ∀ (n : ℕ), Subtype.val ∘ ⇑f '' {m | n ≤ m} ⊆ s
⊢ (fun x x_1 => x > x_1) ↪r fun x x_1 => x < x_1

Next tactic:
have : ∀ a b : ℕ, a ≤ b ↔
      span R (Subtype.val ∘ f '' { m | b ≤ m }) ≤ span R (Subtype.val ∘ f '' { m | a ≤ m }) := by
    intro a b
    rw [span_le_span_iff hs (this b) (this a),
      Set.image_subset_image_iff (Subtype.coe_injective.comp f.injective), Set.subset_def]
    simp only [Set.mem_setOf_eq]
    exact ⟨fun hab x => le_trans hab, fun h => h _ le_rfl⟩
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    exact (f y).2
  have : ∀ a b : ℕ, a ≤ b ↔
      span R (Subtype.val ∘ f '' { m | b ≤ m }) ≤ span R (Subtype.val ∘ f '' { m | a ≤ m }) := by
    

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
this : ∀ (n : ℕ), Subtype.val ∘ ⇑f '' {m | n ≤ m} ⊆ s
⊢ ∀ (a b : ℕ), a ≤ b ↔ span R (Subtype.val ∘ ⇑f '' {m | b ≤ m}) ≤ span R (Subtype.val ∘ ⇑f '' {m | a ≤ m})

Next tactic:
intro a b
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    exact (f y).2
  have : ∀ a b : ℕ, a ≤ b ↔
      span R (Subtype.val ∘ f '' { m | b ≤ m }) ≤ span R (Subtype.val ∘ f '' { m | a ≤ m }) := by
    intro a b
    

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
this : ∀ (n : ℕ), Subtype.val ∘ ⇑f '' {m | n ≤ m} ⊆ s
a b : ℕ
⊢ a ≤ b ↔ span R (Subtype.val ∘ ⇑f '' {m | b ≤ m}) ≤ span R (Subtype.val ∘ ⇑f '' {m | a ≤ m})

Next tactic:
rw [span_le_span_iff hs (this b) (this a),
      Set.image_subset_image_iff (Subtype.coe_injective.comp f.injective), Set.subset_def]
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    exact (f y).2
  have : ∀ a b : ℕ, a ≤ b ↔
      span R (Subtype.val ∘ f '' { m | b ≤ m }) ≤ span R (Subtype.val ∘ f '' { m | a ≤ m }) := by
    intro a b
    rw [span_le_span_iff hs (this b) (this a),
      Set.image_subset_image_iff (Subtype.coe_injective.comp f.injective), Set.subset_def]
    

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
this : ∀ (n : ℕ), Subtype.val ∘ ⇑f '' {m | n ≤ m} ⊆ s
a b : ℕ
⊢ a ≤ b ↔ ∀ x ∈ {m | b ≤ m}, x ∈ {m | a ≤ m}

Next tactic:
simp only [Set.mem_setOf_eq]
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    exact (f y).2
  have : ∀ a b : ℕ, a ≤ b ↔
      span R (Subtype.val ∘ f '' { m | b ≤ m }) ≤ span R (Subtype.val ∘ f '' { m | a ≤ m }) := by
    intro a b
    rw [span_le_span_iff hs (this b) (this a),
      Set.image_subset_image_iff (Subtype.coe_injective.comp f.injective), Set.subset_def]
    simp only [Set.mem_setOf_eq]
    

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
this : ∀ (n : ℕ), Subtype.val ∘ ⇑f '' {m | n ≤ m} ⊆ s
a b : ℕ
⊢ a ≤ b ↔ ∀ (x : ℕ), b ≤ x → a ≤ x

Next tactic:
exact ⟨fun hab x => le_trans hab, fun h => h _ le_rfl⟩
theorem IsArtinian.finite_of_linearIndependent [Nontrivial R] [IsArtinian R M] {s : Set M}
    (hs : LinearIndependent R ((↑) : s → M)) : s.Finite := by
  refine' by_contradiction fun hf => (RelEmbedding.wellFounded_iff_no_descending_seq.1
    (wellFounded_submodule_lt (R := R) (M := M))).elim' _
  have f : ℕ ↪ s := Set.Infinite.natEmbedding s hf
  have : ∀ n, (↑) ∘ f '' { m | n ≤ m } ⊆ s := by
    rintro n x ⟨y, _, rfl⟩
    exact (f y).2
  have : ∀ a b : ℕ, a ≤ b ↔
      span R (Subtype.val ∘ f '' { m | b ≤ m }) ≤ span R (Subtype.val ∘ f '' { m | a ≤ m }) := by
    intro a b
    rw [span_le_span_iff hs (this b) (this a),
      Set.image_subset_image_iff (Subtype.coe_injective.comp f.injective), Set.subset_def]
    simp only [Set.mem_setOf_eq]
    exact ⟨fun hab x => le_trans hab, fun h => h _ le_rfl⟩
  

Proof state:
R : Type u_1
M : Type u_2
inst✝⁴ : Ring R
inst✝³ : AddCommGroup M
inst✝² : Module R M
inst✝¹ : Nontrivial R
inst✝ : IsArtinian R M
s : Set M
hs : LinearIndependent (ι := { x // x ∈ s }) R Subtype.val
hf : ¬Set.Finite s
f : ℕ ↪ ↑s
this✝ : ∀ (n : ℕ), Subtype.val ∘ ⇑f '' {m | n ≤ m} ⊆ s
this : ∀ (a b : ℕ), a ≤ b ↔ span R (Subtype.val ∘ ⇑f '' {m | b ≤ m}) ≤ span R (Subtype.val ∘ ⇑f '' {m | a ≤ m})
⊢ (fun x x_1 => x > x_1) ↪r fun x x_1 => x < x_1

Next tactic:
exact ⟨⟨fun n => span R (Subtype.val ∘ f '' { m | n ≤ m }), fun x y => by
    rw [le_antisymm_iff, ← this y x, ← this x y]
    exact fun ⟨h₁, h₂⟩ => le_antisymm_iff.2 ⟨h₂, h₁⟩⟩, by
    intro a b
    conv_rhs => rw [GT.gt, lt_iff_le_not_le, this, this, ← lt_iff_le_not_le]⟩