l3lab/ntp-mathlib huggingface dataset:
/-- Given a point in an affine subspace, a result of subtracting that point on the left is in the
direction if and only if the other point is in the subspace. -/
theorem vsub_left_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p2 : P) :
    p -ᵥ p2 ∈ s.direction ↔ p2 ∈ s := by
  rw [mem_direction_iff_eq_vsub_left hp]
  

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
p : P
hp : p ∈ s
p2 : P
⊢ (∃ p2_1 ∈ s, p -ᵥ p2 = p -ᵥ p2_1) ↔ p2 ∈ s

Next tactic:
simp
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := 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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
⊢ s1 = s2

Next tactic:
ext p
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  

Proof state:
case h
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
⊢ p ∈ s1 ↔ p ∈ s2

Next tactic:
have hq1 := Set.mem_of_mem_inter_left hn.some_mem
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  

Proof state:
case h
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
⊢ p ∈ s1 ↔ p ∈ s2

Next tactic:
have hq2 := Set.mem_of_mem_inter_right hn.some_mem
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  

Proof state:
case h
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
⊢ p ∈ s1 ↔ p ∈ s2

Next tactic:
constructor
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · 

Proof state:
case h.mp
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
⊢ p ∈ s1 → p ∈ s2

Next tactic:
intro hp
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    

Proof state:
case h.mp
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s1
⊢ p ∈ s2

Next tactic:
rw [← vsub_vadd p hn.some]
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    

Proof state:
case h.mp
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s1
⊢ p -ᵥ Set.Nonempty.some hn +ᵥ Set.Nonempty.some hn ∈ s2

Next tactic:
refine' vadd_mem_of_mem_direction _ hq2
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq2
    

Proof state:
case h.mp
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s1
⊢ p -ᵥ Set.Nonempty.some hn ∈ direction s2

Next tactic:
rw [← hd]
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq2
    rw [← hd]
    

Proof state:
case h.mp
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s1
⊢ p -ᵥ Set.Nonempty.some hn ∈ direction s1

Next tactic:
exact vsub_mem_direction hp hq1
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq2
    rw [← hd]
    exact vsub_mem_direction hp hq1
  · 

Proof state:
case h.mpr
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
⊢ p ∈ s2 → p ∈ s1

Next tactic:
intro hp
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq2
    rw [← hd]
    exact vsub_mem_direction hp hq1
  · intro hp
    

Proof state:
case h.mpr
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s2
⊢ p ∈ s1

Next tactic:
rw [← vsub_vadd p hn.some]
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq2
    rw [← hd]
    exact vsub_mem_direction hp hq1
  · intro hp
    rw [← vsub_vadd p hn.some]
    

Proof state:
case h.mpr
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s2
⊢ p -ᵥ Set.Nonempty.some hn +ᵥ Set.Nonempty.some hn ∈ s1

Next tactic:
refine' vadd_mem_of_mem_direction _ hq1
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq2
    rw [← hd]
    exact vsub_mem_direction hp hq1
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq1
    

Proof state:
case h.mpr
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s2
⊢ p -ᵥ Set.Nonempty.some hn ∈ direction s1

Next tactic:
rw [hd]
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
    (hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
  ext p
  have hq1 := Set.mem_of_mem_inter_left hn.some_mem
  have hq2 := Set.mem_of_mem_inter_right hn.some_mem
  constructor
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq2
    rw [← hd]
    exact vsub_mem_direction hp hq1
  · intro hp
    rw [← vsub_vadd p hn.some]
    refine' vadd_mem_of_mem_direction _ hq1
    rw [hd]
    

Proof state:
case h.mpr
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
s1 s2 : AffineSubspace k P
hd : direction s1 = direction s2
hn : Set.Nonempty (↑s1 ∩ ↑s2)
p : P
hq1 : Set.Nonempty.some hn ∈ ↑s1
hq2 : Set.Nonempty.some hn ∈ ↑s2
hp : p ∈ s2
⊢ p -ᵥ Set.Nonempty.some hn ∈ direction s2

Next tactic:
exact vsub_mem_direction hp hq2
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => 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
inst✝ : Nonempty ↥s
a : ↥s
⊢ 0 +ᵥ a = a

Next tactic:
ext
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => by
    ext
    

Proof state:
case a
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
inst✝ : Nonempty ↥s
a : ↥s
⊢ ↑(0 +ᵥ a) = ↑a

Next tactic:
exact zero_vadd _ _
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := 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
inst✝ : Nonempty ↥s
a b : ↥(direction s)
c : ↥s
⊢ a + b +ᵥ c = a +ᵥ (b +ᵥ c)

Next tactic:
ext
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := by
    ext
    

Proof state:
case a
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
inst✝ : Nonempty ↥s
a b : ↥(direction s)
c : ↥s
⊢ ↑(a + b +ᵥ c) = ↑(a +ᵥ (b +ᵥ c))

Next tactic:
apply add_vadd
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := by
    ext
    apply add_vadd
  vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩
  vsub_vadd' a b := 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
inst✝ : Nonempty ↥s
a b : ↥s
⊢ a -ᵥ b +ᵥ b = a

Next tactic:
ext
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := by
    ext
    apply add_vadd
  vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩
  vsub_vadd' a b := by
    ext
    

Proof state:
case a
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
inst✝ : Nonempty ↥s
a b : ↥s
⊢ ↑(a -ᵥ b +ᵥ b) = ↑a

Next tactic:
apply AddTorsor.vsub_vadd'
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := by
    ext
    apply add_vadd
  vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩
  vsub_vadd' a b := by
    ext
    apply AddTorsor.vsub_vadd'
  vadd_vsub' a b := 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
inst✝ : Nonempty ↥s
a : ↥(direction s)
b : ↥s
⊢ a +ᵥ b -ᵥ b = a

Next tactic:
ext
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
@[reducible]
def toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
  vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
  zero_vadd := fun a => by
    ext
    exact zero_vadd _ _
  add_vadd a b c := by
    ext
    apply add_vadd
  vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩
  vsub_vadd' a b := by
    ext
    apply AddTorsor.vsub_vadd'
  vadd_vsub' a b := by
    ext
    

Proof state:
case a
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
inst✝ : Nonempty ↥s
a : ↥(direction s)
b : ↥s
⊢ ↑(a +ᵥ b -ᵥ b) = ↑a

Next tactic:
apply AddTorsor.vadd_vsub'
/-- Construct an affine subspace from a point and a direction. -/
def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where
  carrier := { q | ∃ v ∈ direction, q = v +ᵥ p }
  smul_vsub_vadd_mem c p1 p2 p3 hp1 hp2 hp3 := 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 : P
direction : Submodule k V
c : k
p1 p2 p3 : P
hp1 : p1 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}
hp2 : p2 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}
hp3 : p3 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}
⊢ c • (p1 -ᵥ p2) +ᵥ p3 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}

Next tactic:
rcases hp1 with ⟨v1, hv1, hp1⟩
/-- Construct an affine subspace from a point and a direction. -/
def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where
  carrier := { q | ∃ v ∈ direction, q = v +ᵥ p }
  smul_vsub_vadd_mem c p1 p2 p3 hp1 hp2 hp3 := by
    rcases hp1 with ⟨v1, hv1, hp1⟩
    

Proof state:
case 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
p : P
direction : Submodule k V
c : k
p1 p2 p3 : P
hp2 : p2 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}
hp3 : p3 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}
v1 : V
hv1 : v1 ∈ direction
hp1 : p1 = v1 +ᵥ p
⊢ c • (p1 -ᵥ p2) +ᵥ p3 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}

Next tactic:
rcases hp2 with ⟨v2, hv2, hp2⟩
/-- Construct an affine subspace from a point and a direction. -/
def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where
  carrier := { q | ∃ v ∈ direction, q = v +ᵥ p }
  smul_vsub_vadd_mem c p1 p2 p3 hp1 hp2 hp3 := by
    rcases hp1 with ⟨v1, hv1, hp1⟩
    rcases hp2 with ⟨v2, hv2, hp2⟩
    

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
p : P
direction : Submodule k V
c : k
p1 p2 p3 : P
hp3 : p3 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}
v1 : V
hv1 : v1 ∈ direction
hp1 : p1 = v1 +ᵥ p
v2 : V
hv2 : v2 ∈ direction
hp2 : p2 = v2 +ᵥ p
⊢ c • (p1 -ᵥ p2) +ᵥ p3 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}

Next tactic:
rcases hp3 with ⟨v3, hv3, hp3⟩
/-- Construct an affine subspace from a point and a direction. -/
def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where
  carrier := { q | ∃ v ∈ direction, q = v +ᵥ p }
  smul_vsub_vadd_mem c p1 p2 p3 hp1 hp2 hp3 := by
    rcases hp1 with ⟨v1, hv1, hp1⟩
    rcases hp2 with ⟨v2, hv2, hp2⟩
    rcases hp3 with ⟨v3, hv3, hp3⟩
    

Proof state:
case 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
p : P
direction : Submodule k V
c : k
p1 p2 p3 : P
v1 : V
hv1 : v1 ∈ direction
hp1 : p1 = v1 +ᵥ p
v2 : V
hv2 : v2 ∈ direction
hp2 : p2 = v2 +ᵥ p
v3 : V
hv3 : v3 ∈ direction
hp3 : p3 = v3 +ᵥ p
⊢ c • (p1 -ᵥ p2) +ᵥ p3 ∈ {q | ∃ v ∈ direction, q = v +ᵥ p}

Next tactic:
use c • (v1 - v2) + v3, direction.add_mem (direction.smul_mem c (direction.sub_mem hv1 hv2)) hv3
/-- Construct an affine subspace from a point and a direction. -/
def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where
  carrier := { q | ∃ v ∈ direction, q = v +ᵥ p }
  smul_vsub_vadd_mem c p1 p2 p3 hp1 hp2 hp3 := by
    rcases hp1 with ⟨v1, hv1, hp1⟩
    rcases hp2 with ⟨v2, hv2, hp2⟩
    rcases hp3 with ⟨v3, hv3, hp3⟩
    use c • (v1 - v2) + v3, direction.add_mem (direction.smul_mem c (direction.sub_mem hv1 hv2)) hv3
    

Proof state:
case right
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 : P
direction : Submodule k V
c : k
p1 p2 p3 : P
v1 : V
hv1 : v1 ∈ direction
hp1 : p1 = v1 +ᵥ p
v2 : V
hv2 : v2 ∈ direction
hp2 : p2 = v2 +ᵥ p
v3 : V
hv3 : v3 ∈ direction
hp3 : p3 = v3 +ᵥ p
⊢ c • (p1 -ᵥ p2) +ᵥ p3 = c • (v1 - v2) + v3 +ᵥ p

Next tactic:
simp [hp1, hp2, hp3, vadd_vadd]
/-- The direction of an affine subspace constructed from a point and a direction. -/
@[simp]
theorem direction_mk' (p : P) (direction : Submodule k V) :
    (mk' p direction).direction = direction := 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 : P
direction : Submodule k V
⊢ AffineSubspace.direction (mk' p direction) = direction

Next tactic:
ext v
/-- The direction of an affine subspace constructed from a point and a direction. -/
@[simp]
theorem direction_mk' (p : P) (direction : Submodule k V) :
    (mk' p direction).direction = direction := by
  ext v
  

Proof state:
case h
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 : P
direction : Submodule k V
v : V
⊢ v ∈ AffineSubspace.direction (mk' p direction) ↔ v ∈ direction

Next tactic:
rw [mem_direction_iff_eq_vsub (mk'_nonempty _ _)]
/-- The direction of an affine subspace constructed from a point and a direction. -/
@[simp]
theorem direction_mk' (p : P) (direction : Submodule k V) :
    (mk' p direction).direction = direction := by
  ext v
  rw [mem_direction_iff_eq_vsub (mk'_nonempty _ _)]
  

Proof state:
case h
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 : P
direction : Submodule k V
v : V
⊢ (∃ p1 ∈ mk' p direction, ∃ p2 ∈ mk' p direction, v = p1 -ᵥ p2) ↔ v ∈ direction

Next tactic:
constructor
/-- The direction of an affine subspace constructed from a point and a direction. -/
@[simp]
theorem direction_mk' (p : P) (direction : Submodule k V) :
    (mk' p direction).direction = direction := by
  ext v
  rw [mem_direction_iff_eq_vsub (mk'_nonempty _ _)]
  constructor
  · 

Proof state:
case h.mp
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 : P
direction : Submodule k V
v : V
⊢ (∃ p1 ∈ mk' p direction, ∃ p2 ∈ mk' p direction, v = p1 -ᵥ p2) → v ∈ direction

Next tactic:
rintro ⟨p1, ⟨v1, hv1, hp1⟩, p2, ⟨v2, hv2, hp2⟩, hv⟩
/-- The direction of an affine subspace constructed from a point and a direction. -/
@[simp]
theorem direction_mk' (p : P) (direction : Submodule k V) :
    (mk' p direction).direction = direction := by
  ext v
  rw [mem_direction_iff_eq_vsub (mk'_nonempty _ _)]
  constructor
  · rintro ⟨p1, ⟨v1, hv1, hp1⟩, p2, ⟨v2, hv2, hp2⟩, hv⟩
    

Proof state:
case h.mp.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
p : P
direction : Submodule k V
v : V
p1 : P
v1 : V
hv1 : v1 ∈ direction
hp1 : p1 = v1 +ᵥ p
p2 : P
hv : v = p1 -ᵥ p2
v2 : V
hv2 : v2 ∈ direction
hp2 : p2 = v2 +ᵥ p
⊢ v ∈ direction

Next tactic:
rw [hv, hp1, hp2, vadd_vsub_vadd_cancel_right]