l3lab/ntp-mathlib huggingface dataset:
/--
Given `HomotopyWith f₀ f₁ P` and `HomotopyWith f₁ f₂ P`, we can define a `HomotopyWith f₀ f₂ P`
by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.
-/
def trans {f₀ f₁ f₂ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) (G : HomotopyWith f₁ f₂ P) :
    HomotopyWith f₀ f₂ P :=
  { F.toHomotopy.trans G.toHomotopy with
    prop' := fun t => by
      simp only [Homotopy.trans]
      change P ⟨fun _ => ite ((t : ℝ) ≤ _) _ _, _⟩
      split_ifs
      · 

Proof state:
case pos
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
P : C(X, Y) → Prop
f₀ f₁ f₂ : C(X, Y)
F : HomotopyWith f₀ f₁ P
G : HomotopyWith f₁ f₂ P
src✝ : Homotopy f₀ f₂ := Homotopy.trans F.toHomotopy G.toHomotopy
t : ↑I
h✝ : ↑t ≤ 1 / 2
⊢ P (ContinuousMap.mk fun x => ((Homotopy.extend F.toHomotopy) (2 * ↑t)) x)

Next tactic:
exact F.extendProp _
/--
Given `HomotopyWith f₀ f₁ P` and `HomotopyWith f₁ f₂ P`, we can define a `HomotopyWith f₀ f₂ P`
by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.
-/
def trans {f₀ f₁ f₂ : C(X, Y)} (F : HomotopyWith f₀ f₁ P) (G : HomotopyWith f₁ f₂ P) :
    HomotopyWith f₀ f₂ P :=
  { F.toHomotopy.trans G.toHomotopy with
    prop' := fun t => by
      simp only [Homotopy.trans]
      change P ⟨fun _ => ite ((t : ℝ) ≤ _) _ _, _⟩
      split_ifs
      · exact F.extendProp _
      · 

Proof state:
case neg
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
P : C(X, Y) → Prop
f₀ f₁ f₂ : C(X, Y)
F : HomotopyWith f₀ f₁ P
G : HomotopyWith f₁ f₂ P
src✝ : Homotopy f₀ f₂ := Homotopy.trans F.toHomotopy G.toHomotopy
t : ↑I
h✝ : ¬↑t ≤ 1 / 2
⊢ P (ContinuousMap.mk fun x => ((Homotopy.extend G.toHomotopy) (2 * ↑t - 1)) x)

Next tactic:
exact G.extendProp _
theorem eq_snd (F : HomotopyRel f₀ f₁ S) (t : I) {x : X} (hx : x ∈ S) : F (t, x) = f₁ x := by
  

Proof state:
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
f₀ f₁ : C(X, Y)
S : Set X
F : HomotopyRel f₀ f₁ S
t : ↑I
x : X
hx : x ∈ S
⊢ F (t, x) = f₁ x

Next tactic:
rw [F.eq_fst t hx, ← F.eq_fst 1 hx, F.apply_one]
/-- Given `HomotopyRel f₀ f₁ S` and `HomotopyRel f₁ f₂ S`, we can define a `HomotopyRel f₀ f₂ S`
by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.
-/
def trans (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel f₁ f₂ S) : HomotopyRel f₀ f₂ S where
  toHomotopy := F.toHomotopy.trans G.toHomotopy
  prop' t x hx := by
    

Proof state:
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
f₀ f₁ f₂ : C(X, Y)
S : Set X
F : HomotopyRel f₀ f₁ S
G : HomotopyRel f₁ f₂ S
t : ↑I
x : X
hx : x ∈ S
⊢ (mk fun x => ContinuousMap.toFun (Homotopy.trans F.toHomotopy G.toHomotopy).toContinuousMap (t, x)) x = f₀ x

Next tactic:
simp only [Homotopy.trans]
/-- Given `HomotopyRel f₀ f₁ S` and `HomotopyRel f₁ f₂ S`, we can define a `HomotopyRel f₀ f₂ S`
by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.
-/
def trans (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel f₁ f₂ S) : HomotopyRel f₀ f₂ S where
  toHomotopy := F.toHomotopy.trans G.toHomotopy
  prop' t x hx := by
    simp only [Homotopy.trans]
    

Proof state:
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
f₀ f₁ f₂ : C(X, Y)
S : Set X
F : HomotopyRel f₀ f₁ S
G : HomotopyRel f₁ f₂ S
t : ↑I
x : X
hx : x ∈ S
⊢ (mk fun x =>
        if ↑t ≤ 1 / 2 then ((Homotopy.extend F.toHomotopy) (2 * ↑t)) x
        else ((Homotopy.extend G.toHomotopy) (2 * ↑t - 1)) x)
      x =
    f₀ x

Next tactic:
split_ifs
/-- Given `HomotopyRel f₀ f₁ S` and `HomotopyRel f₁ f₂ S`, we can define a `HomotopyRel f₀ f₂ S`
by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.
-/
def trans (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel f₁ f₂ S) : HomotopyRel f₀ f₂ S where
  toHomotopy := F.toHomotopy.trans G.toHomotopy
  prop' t x hx := by
    simp only [Homotopy.trans]
    split_ifs
    · 

Proof state:
case pos
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
f₀ f₁ f₂ : C(X, Y)
S : Set X
F : HomotopyRel f₀ f₁ S
G : HomotopyRel f₁ f₂ S
t : ↑I
x : X
hx : x ∈ S
h✝ : ↑t ≤ 1 / 2
⊢ (mk fun x => ((Homotopy.extend F.toHomotopy) (2 * ↑t)) x) x = f₀ x

Next tactic:
simp [HomotopyWith.extendProp F (2 * t) x hx, F.fst_eq_snd hx, G.fst_eq_snd hx]
/-- Given `HomotopyRel f₀ f₁ S` and `HomotopyRel f₁ f₂ S`, we can define a `HomotopyRel f₀ f₂ S`
by putting the first homotopy on `[0, 1/2]` and the second on `[1/2, 1]`.
-/
def trans (F : HomotopyRel f₀ f₁ S) (G : HomotopyRel f₁ f₂ S) : HomotopyRel f₀ f₂ S where
  toHomotopy := F.toHomotopy.trans G.toHomotopy
  prop' t x hx := by
    simp only [Homotopy.trans]
    split_ifs
    · simp [HomotopyWith.extendProp F (2 * t) x hx, F.fst_eq_snd hx, G.fst_eq_snd hx]
    · 

Proof state:
case neg
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
f₀ f₁ f₂ : C(X, Y)
S : Set X
F : HomotopyRel f₀ f₁ S
G : HomotopyRel f₁ f₂ S
t : ↑I
x : X
hx : x ∈ S
h✝ : ¬↑t ≤ 1 / 2
⊢ (mk fun x => ((Homotopy.extend G.toHomotopy) (2 * ↑t - 1)) x) x = f₀ x

Next tactic:
simp [HomotopyWith.extendProp G (2 * t - 1) x hx, F.fst_eq_snd hx, G.fst_eq_snd hx]
/-- Casting a `HomotopyRel f₀ f₁ S` to a `HomotopyRel g₀ g₁ S` where `f₀ = g₀` and `f₁ = g₁`.
-/
@[simps!]
def cast {f₀ f₁ g₀ g₁ : C(X, Y)} (F : HomotopyRel f₀ f₁ S) (h₀ : f₀ = g₀) (h₁ : f₁ = g₁) :
    HomotopyRel g₀ g₁ S where
  toHomotopy := Homotopy.cast F.toHomotopy h₀ h₁
  prop' t x hx := by 

Proof state:
F✝ : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
f₀✝ f₁✝ f₂ : C(X, Y)
S : Set X
f₀ f₁ g₀ g₁ : C(X, Y)
F : HomotopyRel f₀ f₁ S
h₀ : f₀ = g₀
h₁ : f₁ = g₁
t : ↑I
x : X
hx : x ∈ S
⊢ (mk fun x => ContinuousMap.toFun (Homotopy.cast F.toHomotopy h₀ h₁).toContinuousMap (t, x)) x = g₀ x

Next tactic:
simpa only [← h₀, ← h₁] using F.prop t x hx
theorem equivalence : Equivalence fun f g : C(X, Y) => HomotopicRel f g S :=
  ⟨refl, by 

Proof state:
F : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
S : Set X
⊢ ∀ {x y : C(X, Y)}, HomotopicRel x y S → HomotopicRel y x S

Next tactic:
apply symm
theorem equivalence : Equivalence fun f g : C(X, Y) => HomotopicRel f g S :=
  ⟨refl, by apply symm, by 

Proof state:
F : Type u_1
X : Type u
Y : Type v
Z : Type w
Z' : Type x
inst✝³ : TopologicalSpace X
inst✝² : TopologicalSpace Y
inst✝¹ : TopologicalSpace Z
inst✝ : TopologicalSpace Z'
S : Set X
⊢ ∀ {x y z : C(X, Y)}, HomotopicRel x y S → HomotopicRel y z S → HomotopicRel x z S

Next tactic:
apply trans
theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) :
    map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := by
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
x : M
p p' : Submodule R M
inst✝⁴ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝³ : AddCommMonoid M₂
inst✝² : Module R₂ M₂
F : Type u_8
inst✝¹ : SemilinearMapClass F σ₁₂ M M₂
s✝ t : Set M
inst✝ : RingHomSurjective σ₁₂
f : F
s : Set M
N : Submodule R₂ M₂
⊢ map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N

Next tactic:
rw [map_span, span_le, Set.image_subset_iff]
theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) :
    map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := by
  rw [map_span, span_le, Set.image_subset_iff]
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁷ : Semiring R
inst✝⁶ : AddCommMonoid M
inst✝⁵ : Module R M
x : M
p p' : Submodule R M
inst✝⁴ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝³ : AddCommMonoid M₂
inst✝² : Module R₂ M₂
F : Type u_8
inst✝¹ : SemilinearMapClass F σ₁₂ M M₂
s✝ t : Set M
inst✝ : RingHomSurjective σ₁₂
f : F
s : Set M
N : Submodule R₂ M₂
⊢ s ⊆ ⇑f ⁻¹' ↑N ↔ ∀ m ∈ s, f m ∈ N

Next tactic:
exact Iff.rfl
@[simp]
theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
⊢ span R (insert 0 s) = span R s

Next tactic:
refine' le_antisymm _ (Submodule.span_mono (Set.subset_insert 0 s))
@[simp]
theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by
  refine' le_antisymm _ (Submodule.span_mono (Set.subset_insert 0 s))
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
⊢ span R (insert 0 s) ≤ span R s

Next tactic:
rw [span_le, Set.insert_subset_iff]
@[simp]
theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by
  refine' le_antisymm _ (Submodule.span_mono (Set.subset_insert 0 s))
  rw [span_le, Set.insert_subset_iff]
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
⊢ 0 ∈ ↑(span R s) ∧ s ⊆ ↑(span R s)

Next tactic:
exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩
@[simp]
theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by
  refine' le_antisymm _ (Submodule.span_mono (Set.subset_insert 0 s))
  rw [span_le, Set.insert_subset_iff]
  exact ⟨by 

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
⊢ 0 ∈ ↑(span R s)

Next tactic:
simp only [SetLike.mem_coe, Submodule.zero_mem]
theorem span_preimage_le (f : F) (s : Set M₂) :
    span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t : Set M
f : F
s : Set M₂
⊢ span R (⇑f ⁻¹' s) ≤ comap f (span R₂ s)

Next tactic:
rw [span_le, comap_coe]
theorem span_preimage_le (f : F) (s : Set M₂) :
    span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by
  rw [span_le, comap_coe]
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t : Set M
f : F
s : Set M₂
⊢ ⇑f ⁻¹' s ⊆ ⇑f ⁻¹' ↑(span R₂ s)

Next tactic:
exact preimage_mono subset_span
/-- An induction principle for span membership. If `p` holds for 0 and all elements of `s`, and is
preserved under addition and scalar multiplication, then `p` holds for all elements of the span of
`s`. -/
@[elab_as_elim]
theorem span_induction {p : M → Prop} (h : x ∈ span R s) (Hs : ∀ x ∈ s, p x) (H0 : p 0)
    (H1 : ∀ x y, p x → p y → p (x + y)) (H2 : ∀ (a : R) (x), p x → p (a • x)) : p x :=
  ((@span_le (p := ⟨ ⟨⟨p, by 

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p✝ p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t : Set M
p : M → Prop
h : x ∈ span R s✝
Hs : ∀ x ∈ s✝, p x
H0 : p 0
H1 : ∀ (x y : M), p x → p y → p (x + y)
H2 : ∀ (a : R) (x : M), p x → p (a • x)
s : Set M
⊢ ∀ {a b : M}, a ∈ p → b ∈ p → a + b ∈ p

Next tactic:
intros x y
/-- An induction principle for span membership. If `p` holds for 0 and all elements of `s`, and is
preserved under addition and scalar multiplication, then `p` holds for all elements of the span of
`s`. -/
@[elab_as_elim]
theorem span_induction {p : M → Prop} (h : x ∈ span R s) (Hs : ∀ x ∈ s, p x) (H0 : p 0)
    (H1 : ∀ x y, p x → p y → p (x + y)) (H2 : ∀ (a : R) (x), p x → p (a • x)) : p x :=
  ((@span_le (p := ⟨ ⟨⟨p, by intros x y; 

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x✝ : M
p✝ p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t : Set M
p : M → Prop
h : x✝ ∈ span R s✝
Hs : ∀ x ∈ s✝, p x
H0 : p 0
H1 : ∀ (x y : M), p x → p y → p (x + y)
H2 : ∀ (a : R) (x : M), p x → p (a • x)
s : Set M
x y : M
⊢ x ∈ p → y ∈ p → x + y ∈ p

Next tactic:
exact H1 x y
/-- A dependent version of `Submodule.span_induction`. -/
theorem span_induction' {p : ∀ x, x ∈ span R s → Prop}
    (Hs : ∀ (x) (h : x ∈ s), p x (subset_span h))
    (H0 : p 0 (Submodule.zero_mem _))
    (H1 : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›))
    (H2 : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x}
    (hx : x ∈ span R s) : p x hx := by
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x✝ : M
p✝ p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
p : (x : M) → x ∈ span R s → Prop
Hs : ∀ (x : M) (h : x ∈ s), p x (_ : x ∈ ↑(span R s))
H0 : p 0 (_ : 0 ∈ span R s)
H1 : ∀ (x : M) (hx : x ∈ span R s) (y : M) (hy : y ∈ span R s), p x hx → p y hy → p (x + y) (_ : x + y ∈ span R s)
H2 : ∀ (a : R) (x : M) (hx : x ∈ span R s), p x hx → p (a • x) (_ : a • x ∈ span R s)
x : M
hx : x ∈ span R s
⊢ p x hx

Next tactic:
refine' Exists.elim _ fun (hx : x ∈ span R s) (hc : p x hx) => hc
/-- A dependent version of `Submodule.span_induction`. -/
theorem span_induction' {p : ∀ x, x ∈ span R s → Prop}
    (Hs : ∀ (x) (h : x ∈ s), p x (subset_span h))
    (H0 : p 0 (Submodule.zero_mem _))
    (H1 : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›))
    (H2 : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x}
    (hx : x ∈ span R s) : p x hx := by
  refine' Exists.elim _ fun (hx : x ∈ span R s) (hc : p x hx) => hc
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x✝ : M
p✝ p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
p : (x : M) → x ∈ span R s → Prop
Hs : ∀ (x : M) (h : x ∈ s), p x (_ : x ∈ ↑(span R s))
H0 : p 0 (_ : 0 ∈ span R s)
H1 : ∀ (x : M) (hx : x ∈ span R s) (y : M) (hy : y ∈ span R s), p x hx → p y hy → p (x + y) (_ : x + y ∈ span R s)
H2 : ∀ (a : R) (x : M) (hx : x ∈ span R s), p x hx → p (a • x) (_ : a • x ∈ span R s)
x : M
hx : x ∈ span R s
⊢ ∃ (x_1 : x ∈ span R s), p x x_1

Next tactic:
refine'
    span_induction hx (fun m hm => ⟨subset_span hm, Hs m hm⟩) ⟨zero_mem _, H0⟩
      (fun x y hx hy =>
        Exists.elim hx fun hx' hx =>
          Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', H1 _ _ _ _ hx hy⟩)
      fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', H2 r _ _ hx⟩
@[simp]
theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ :=
  eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by
    

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x✝² : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
x✝¹ : { x // x ∈ ↑(span R s) }
x : M
hx : x ∈ ↑(span R s)
x✝ : { val := x, property := hx } ∈ ⊤
⊢ { val := x, property := hx } ∈ span R (Subtype.val ⁻¹' s)

Next tactic:
refine' span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s))
      (fun x' hx' ↦ subset_span hx') _ (fun x _ y _ ↦ _) (fun r x _ ↦ _) hx
@[simp]
theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ :=
  eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by
    refine' span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s))
      (fun x' hx' ↦ subset_span hx') _ (fun x _ y _ ↦ _) (fun r x _ ↦ _) hx
    · 

Proof state:
case refine'_1
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x✝² : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
x✝¹ : { x // x ∈ ↑(span R s) }
x : M
hx : x ∈ ↑(span R s)
x✝ : { val := x, property := hx } ∈ ⊤
⊢ (fun x hx => { val := x, property := hx } ∈ span R (Subtype.val ⁻¹' s)) 0 (_ : 0 ∈ span R s)

Next tactic:
exact zero_mem _
@[simp]
theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ :=
  eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by
    refine' span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s))
      (fun x' hx' ↦ subset_span hx') _ (fun x _ y _ ↦ _) (fun r x _ ↦ _) hx
    · exact zero_mem _
    · 

Proof state:
case refine'_2
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x✝⁵ : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
x✝⁴ : { x // x ∈ ↑(span R s) }
x✝³ : M
hx : x✝³ ∈ ↑(span R s)
x✝² : { val := x✝³, property := hx } ∈ ⊤
x : M
x✝¹ : x ∈ span R s
y : M
x✝ : y ∈ span R s
⊢ (fun x hx => { val := x, property := hx } ∈ span R (Subtype.val ⁻¹' s)) x x✝¹ →
    (fun x hx => { val := x, property := hx } ∈ span R (Subtype.val ⁻¹' s)) y x✝ →
      (fun x hx => { val := x, property := hx } ∈ span R (Subtype.val ⁻¹' s)) (x + y) (_ : x + y ∈ span R s)

Next tactic:
exact add_mem
@[simp]
theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ :=
  eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by
    refine' span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s))
      (fun x' hx' ↦ subset_span hx') _ (fun x _ y _ ↦ _) (fun r x _ ↦ _) hx
    · exact zero_mem _
    · exact add_mem
    · 

Proof state:
case refine'_3
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x✝⁴ : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s t : Set M
x✝³ : { x // x ∈ ↑(span R s) }
x✝² : M
hx : x✝² ∈ ↑(span R s)
x✝¹ : { val := x✝², property := hx } ∈ ⊤
r : R
x : M
x✝ : x ∈ span R s
⊢ (fun x hx => { val := x, property := hx } ∈ span R (Subtype.val ⁻¹' s)) x x✝ →
    (fun x hx => { val := x, property := hx } ∈ span R (Subtype.val ⁻¹' s)) (r • x) (_ : r • x ∈ span R s)

Next tactic:
exact smul_mem _ _
theorem span_nat_eq_addSubmonoid_closure (s : Set M) :
    (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t s : Set M
⊢ (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s

Next tactic:
refine' Eq.symm (AddSubmonoid.closure_eq_of_le subset_span _)
theorem span_nat_eq_addSubmonoid_closure (s : Set M) :
    (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by
  refine' Eq.symm (AddSubmonoid.closure_eq_of_le subset_span _)
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t s : Set M
⊢ (span ℕ s).toAddSubmonoid ≤ AddSubmonoid.closure s

Next tactic:
apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le
     (a := span ℕ s) (b := AddSubmonoid.closure s)
theorem span_nat_eq_addSubmonoid_closure (s : Set M) :
    (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by
  refine' Eq.symm (AddSubmonoid.closure_eq_of_le subset_span _)
  apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le
     (a := span ℕ s) (b := AddSubmonoid.closure s)
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t s : Set M
⊢ span ℕ s ≤ (OrderIso.symm (OrderIso.symm AddSubmonoid.toNatSubmodule)) (AddSubmonoid.closure s)

Next tactic:
rw [span_le]
theorem span_nat_eq_addSubmonoid_closure (s : Set M) :
    (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by
  refine' Eq.symm (AddSubmonoid.closure_eq_of_le subset_span _)
  apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le
     (a := span ℕ s) (b := AddSubmonoid.closure s)
  rw [span_le]
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t s : Set M
⊢ s ⊆ ↑((OrderIso.symm (OrderIso.symm AddSubmonoid.toNatSubmodule)) (AddSubmonoid.closure s))

Next tactic:
exact AddSubmonoid.subset_closure
@[simp]
theorem span_nat_eq (s : AddSubmonoid M) : (span ℕ (s : Set M)).toAddSubmonoid = s := by
  

Proof state:
R : Type u_1
R₂ : Type u_2
K : Type u_3
M : Type u_4
M₂ : Type u_5
V : Type u_6
S : Type u_7
inst✝⁶ : Semiring R
inst✝⁵ : AddCommMonoid M
inst✝⁴ : Module R M
x : M
p p' : Submodule R M
inst✝³ : Semiring R₂
σ₁₂ : R →+* R₂
inst✝² : AddCommMonoid M₂
inst✝¹ : Module R₂ M₂
F : Type u_8
inst✝ : SemilinearMapClass F σ₁₂ M M₂
s✝ t : Set M
s : AddSubmonoid M
⊢ (span ℕ ↑s).toAddSubmonoid = s

Next tactic:
rw [span_nat_eq_addSubmonoid_closure, s.closure_eq]