l3lab/ntp-mathlib huggingface dataset:
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P}
    (hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by
  rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩
  rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
  rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc]
  have hv1v2 : v1 - v2 ∈ vectorSpan k s := by
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : Set P
p1 p2 p1a : P
hp1a : p1a ∈ s
v1 : V
hv1 : v1 ∈ vectorSpan k s
hv1p : p1 = v1 +ᵥ p1a
p2a : P
hp2a : p2a ∈ s
v2 : V
hv2 : v2 ∈ vectorSpan k s
hv2p : p2 = v2 +ᵥ p2a
⊢ v1 - v2 ∈ vectorSpan k s

Next tactic:
rw [sub_eq_add_neg]
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P}
    (hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by
  rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩
  rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
  rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc]
  have hv1v2 : v1 - v2 ∈ vectorSpan k s := by
    rw [sub_eq_add_neg]
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : Set P
p1 p2 p1a : P
hp1a : p1a ∈ s
v1 : V
hv1 : v1 ∈ vectorSpan k s
hv1p : p1 = v1 +ᵥ p1a
p2a : P
hp2a : p2a ∈ s
v2 : V
hv2 : v2 ∈ vectorSpan k s
hv2p : p2 = v2 +ᵥ p2a
⊢ v1 + -v2 ∈ vectorSpan k s

Next tactic:
apply (vectorSpan k s).add_mem hv1
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P}
    (hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by
  rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩
  rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
  rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc]
  have hv1v2 : v1 - v2 ∈ vectorSpan k s := by
    rw [sub_eq_add_neg]
    apply (vectorSpan k s).add_mem hv1
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : Set P
p1 p2 p1a : P
hp1a : p1a ∈ s
v1 : V
hv1 : v1 ∈ vectorSpan k s
hv1p : p1 = v1 +ᵥ p1a
p2a : P
hp2a : p2a ∈ s
v2 : V
hv2 : v2 ∈ vectorSpan k s
hv2p : p2 = v2 +ᵥ p2a
⊢ -v2 ∈ vectorSpan k s

Next tactic:
rw [← neg_one_smul k v2]
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P}
    (hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by
  rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩
  rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
  rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc]
  have hv1v2 : v1 - v2 ∈ vectorSpan k s := by
    rw [sub_eq_add_neg]
    apply (vectorSpan k s).add_mem hv1
    rw [← neg_one_smul k v2]
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : Set P
p1 p2 p1a : P
hp1a : p1a ∈ s
v1 : V
hv1 : v1 ∈ vectorSpan k s
hv1p : p1 = v1 +ᵥ p1a
p2a : P
hp2a : p2a ∈ s
v2 : V
hv2 : v2 ∈ vectorSpan k s
hv2p : p2 = v2 +ᵥ p2a
⊢ -1 • v2 ∈ vectorSpan k s

Next tactic:
exact (vectorSpan k s).smul_mem (-1 : k) hv2
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P}
    (hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by
  rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩
  rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
  rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc]
  have hv1v2 : v1 - v2 ∈ vectorSpan k s := by
    rw [sub_eq_add_neg]
    apply (vectorSpan k s).add_mem hv1
    rw [← neg_one_smul k v2]
    exact (vectorSpan k s).smul_mem (-1 : k) hv2
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : Set P
p1 p2 p1a : P
hp1a : p1a ∈ s
v1 : V
hv1 : v1 ∈ vectorSpan k s
hv1p : p1 = v1 +ᵥ p1a
p2a : P
hp2a : p2a ∈ s
v2 : V
hv2 : v2 ∈ vectorSpan k s
hv2p : p2 = v2 +ᵥ p2a
hv1v2 : v1 - v2 ∈ vectorSpan k s
⊢ p1a -ᵥ p2a + (v1 - v2) ∈ vectorSpan k s

Next tactic:
refine' (vectorSpan k s).add_mem _ hv1v2
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P}
    (hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by
  rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩
  rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
  rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc]
  have hv1v2 : v1 - v2 ∈ vectorSpan k s := by
    rw [sub_eq_add_neg]
    apply (vectorSpan k s).add_mem hv1
    rw [← neg_one_smul k v2]
    exact (vectorSpan k s).smul_mem (-1 : k) hv2
  refine' (vectorSpan k s).add_mem _ hv1v2
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : Set P
p1 p2 p1a : P
hp1a : p1a ∈ s
v1 : V
hv1 : v1 ∈ vectorSpan k s
hv1p : p1 = v1 +ᵥ p1a
p2a : P
hp2a : p2a ∈ s
v2 : V
hv2 : v2 ∈ vectorSpan k s
hv2p : p2 = v2 +ᵥ p2a
hv1v2 : v1 - v2 ∈ vectorSpan k s
⊢ p1a -ᵥ p2a ∈ vectorSpan k s

Next tactic:
exact vsub_mem_vectorSpan k hp1a hp2a
instance : SetLike (AffineSubspace k P) P where
  coe := carrier
  coe_injective' p q _ := by 

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
p q : AffineSubspace k P
x✝ : p.carrier = q.carrier
⊢ p = q

Next tactic:
cases p
instance : SetLike (AffineSubspace k P) P where
  coe := carrier
  coe_injective' p q _ := by cases p; 

Proof state:
case mk
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
q : AffineSubspace k P
carrier✝ : Set P
smul_vsub_vadd_mem✝ :
  ∀ (c : k) {p1 p2 p3 : P}, p1 ∈ carrier✝ → p2 ∈ carrier✝ → p3 ∈ carrier✝ → c • (p1 -ᵥ p2) +ᵥ p3 ∈ carrier✝
x✝ : { carrier := carrier✝, smul_vsub_vadd_mem := smul_vsub_vadd_mem✝ }.carrier = q.carrier
⊢ { carrier := carrier✝, smul_vsub_vadd_mem := smul_vsub_vadd_mem✝ } = q

Next tactic:
cases q
instance : SetLike (AffineSubspace k P) P where
  coe := carrier
  coe_injective' p q _ := by cases p; cases q; 

Proof state:
case mk.mk
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
carrier✝¹ : Set P
smul_vsub_vadd_mem✝¹ :
  ∀ (c : k) {p1 p2 p3 : P}, p1 ∈ carrier✝¹ → p2 ∈ carrier✝¹ → p3 ∈ carrier✝¹ → c • (p1 -ᵥ p2) +ᵥ p3 ∈ carrier✝¹
carrier✝ : Set P
smul_vsub_vadd_mem✝ :
  ∀ (c : k) {p1 p2 p3 : P}, p1 ∈ carrier✝ → p2 ∈ carrier✝ → p3 ∈ carrier✝ → c • (p1 -ᵥ p2) +ᵥ p3 ∈ carrier✝
x✝ :
  { carrier := carrier✝¹, smul_vsub_vadd_mem := smul_vsub_vadd_mem✝¹ }.carrier =
    { carrier := carrier✝, smul_vsub_vadd_mem := smul_vsub_vadd_mem✝ }.carrier
⊢ { carrier := carrier✝¹, smul_vsub_vadd_mem := smul_vsub_vadd_mem✝¹ } =
    { carrier := carrier✝, smul_vsub_vadd_mem := smul_vsub_vadd_mem✝ }

Next tactic:
congr
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
⊢ ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s

Next tactic:
intro a b ha hb
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
a b : V
ha : a ∈ ↑s -ᵥ ↑s
hb : b ∈ ↑s -ᵥ ↑s
⊢ a + b ∈ ↑s -ᵥ ↑s

Next tactic:
rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    

Proof state:
case intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
b : V
hb : b ∈ ↑s -ᵥ ↑s
p1 p2 : P
hp1 : p1 ∈ ↑s
hp2 : p2 ∈ ↑s
⊢ (fun x x_1 => x -ᵥ x_1) p1 p2 + b ∈ ↑s -ᵥ ↑s

Next tactic:
rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
p1 p2 : P
hp1 : p1 ∈ ↑s
hp2 : p2 ∈ ↑s
p3 p4 : P
hp3 : p3 ∈ ↑s
hp4 : p4 ∈ ↑s
⊢ (fun x x_1 => x -ᵥ x_1) p1 p2 + (fun x x_1 => x -ᵥ x_1) p3 p4 ∈ ↑s -ᵥ ↑s

Next tactic:
rw [← vadd_vsub_assoc]
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    rw [← vadd_vsub_assoc]
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
p1 p2 : P
hp1 : p1 ∈ ↑s
hp2 : p2 ∈ ↑s
p3 p4 : P
hp3 : p3 ∈ ↑s
hp4 : p4 ∈ ↑s
⊢ (fun x x_1 => x -ᵥ x_1) p1 p2 +ᵥ p3 -ᵥ p4 ∈ ↑s -ᵥ ↑s

Next tactic:
refine' vsub_mem_vsub _ hp4
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    rw [← vadd_vsub_assoc]
    refine' vsub_mem_vsub _ hp4
    

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
p1 p2 : P
hp1 : p1 ∈ ↑s
hp2 : p2 ∈ ↑s
p3 p4 : P
hp3 : p3 ∈ ↑s
hp4 : p4 ∈ ↑s
⊢ (fun x x_1 => x -ᵥ x_1) p1 p2 +ᵥ p3 ∈ ↑s

Next tactic:
convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    rw [← vadd_vsub_assoc]
    refine' vsub_mem_vsub _ hp4
    convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3
    

Proof state:
case h.e'_4.h.e'_5
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
p1 p2 : P
hp1 : p1 ∈ ↑s
hp2 : p2 ∈ ↑s
p3 p4 : P
hp3 : p3 ∈ ↑s
hp4 : p4 ∈ ↑s
⊢ (fun x x_1 => x -ᵥ x_1) p1 p2 = 1 • (p1 -ᵥ p2)

Next tactic:
rw [one_smul]
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
⊢ 0 ∈ { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier

Next tactic:
cases' h with p hp
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    

Proof state:
case intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
p : P
hp : p ∈ ↑s
⊢ 0 ∈ { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier

Next tactic:
exact vsub_self p ▸ vsub_mem_vsub hp hp
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    rw [← vadd_vsub_assoc]
    refine' vsub_mem_vsub _ hp4
    convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3
    rw [one_smul]
  smul_mem' := by
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
⊢ ∀ (c : k) {x : V},
    x ∈
        {
              toAddSubsemigroup :=
                { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) },
              zero_mem' :=
                (_ :
                  0 ∈
                    { carrier := ↑s -ᵥ ↑s,
                        add_mem' :=
                          (_ :
                            ∀ {a b : V},
                              a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier) }.toAddSubsemigroup.carrier →
      c • x ∈
        {
              toAddSubsemigroup :=
                { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) },
              zero_mem' :=
                (_ :
                  0 ∈
                    { carrier := ↑s -ᵥ ↑s,
                        add_mem' :=
                          (_ :
                            ∀ {a b : V},
                              a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier) }.toAddSubsemigroup.carrier

Next tactic:
intro c v hv
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    rw [← vadd_vsub_assoc]
    refine' vsub_mem_vsub _ hp4
    convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3
    rw [one_smul]
  smul_mem' := by
    intro c v hv
    

Proof state:
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
c : k
v : V
hv :
  v ∈
    {
          toAddSubsemigroup :=
            { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) },
          zero_mem' :=
            (_ :
              0 ∈
                { carrier := ↑s -ᵥ ↑s,
                    add_mem' :=
                      (_ :
                        ∀ {a b : V},
                          a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier) }.toAddSubsemigroup.carrier
⊢ c • v ∈
    {
          toAddSubsemigroup :=
            { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) },
          zero_mem' :=
            (_ :
              0 ∈
                { carrier := ↑s -ᵥ ↑s,
                    add_mem' :=
                      (_ :
                        ∀ {a b : V},
                          a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier) }.toAddSubsemigroup.carrier

Next tactic:
rcases hv with ⟨p1, p2, hp1, hp2, rfl⟩
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    rw [← vadd_vsub_assoc]
    refine' vsub_mem_vsub _ hp4
    convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3
    rw [one_smul]
  smul_mem' := by
    intro c v hv
    rcases hv with ⟨p1, p2, hp1, hp2, rfl⟩
    

Proof state:
case intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
c : k
p1 p2 : P
hp1 : p1 ∈ ↑s
hp2 : p2 ∈ ↑s
⊢ c • (fun x x_1 => x -ᵥ x_1) p1 p2 ∈
    {
          toAddSubsemigroup :=
            { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) },
          zero_mem' :=
            (_ :
              0 ∈
                { carrier := ↑s -ᵥ ↑s,
                    add_mem' :=
                      (_ :
                        ∀ {a b : V},
                          a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier) }.toAddSubsemigroup.carrier

Next tactic:
rw [← vadd_vsub (c • (p1 -ᵥ p2)) p2]
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
  carrier := (s : Set P) -ᵥ s
  zero_mem' := by
    cases' h with p hp
    exact vsub_self p ▸ vsub_mem_vsub hp hp
  add_mem' := by
    intro a b ha hb
    rcases ha with ⟨p1, p2, hp1, hp2, rfl⟩
    rcases hb with ⟨p3, p4, hp3, hp4, rfl⟩
    rw [← vadd_vsub_assoc]
    refine' vsub_mem_vsub _ hp4
    convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3
    rw [one_smul]
  smul_mem' := by
    intro c v hv
    rcases hv with ⟨p1, p2, hp1, hp2, rfl⟩
    rw [← vadd_vsub (c • (p1 -ᵥ p2)) p2]
    

Proof state:
case intro.intro.intro.intro
k : Type u_1
V : Type u_2
P : Type u_3
inst✝³ : Ring k
inst✝² : AddCommGroup V
inst✝¹ : Module k V
inst✝ : AffineSpace V P
s : AffineSubspace k P
h : Set.Nonempty ↑s
c : k
p1 p2 : P
hp1 : p1 ∈ ↑s
hp2 : p2 ∈ ↑s
⊢ c • (p1 -ᵥ p2) +ᵥ p2 -ᵥ p2 ∈
    {
          toAddSubsemigroup :=
            { carrier := ↑s -ᵥ ↑s, add_mem' := (_ : ∀ {a b : V}, a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) },
          zero_mem' :=
            (_ :
              0 ∈
                { carrier := ↑s -ᵥ ↑s,
                    add_mem' :=
                      (_ :
                        ∀ {a b : V},
                          a ∈ ↑s -ᵥ ↑s → b ∈ ↑s -ᵥ ↑s → a + b ∈ ↑s -ᵥ ↑s) }.carrier) }.toAddSubsemigroup.carrier

Next tactic:
refine' vsub_mem_vsub _ hp2