Full source
/-- Two vectors are in the same ray, or the first is in the same ray as the negation of the
second, if and only if they are not linearly independent. -/
theorem sameRay_or_sameRay_neg_iff_not_linearIndependent {x y : M} :
SameRaySameRay R x y ∨ SameRay R x (-y)SameRay R x y ∨ SameRay R x (-y) ↔ ¬LinearIndependent R ![x, y] := by
by_cases hx : x = 0; · simpa [hx] using fun h : LinearIndependent R ![0, y] => h.ne_zero 0 rfl
by_cases hy : y = 0; · simpa [hy] using fun h : LinearIndependent R ![x, 0] => h.ne_zero 1 rfl
simp_rw [Fintype.not_linearIndependent_iff]
refine ⟨fun h => ?_, fun h => ?_⟩
· rcases h with ((hx0 | hy0 | ⟨r₁, r₂, hr₁, _, h⟩) | (hx0 | hy0 | ⟨r₁, r₂, hr₁, _, h⟩))
· exact False.elim (hx hx0)
· exact False.elim (hy hy0)
· refine ⟨![r₁, -r₂], ?_⟩
rw [Fin.sum_univ_two, Fin.exists_fin_two]
simp [h, hr₁.ne.symm]
· exact False.elim (hx hx0)
· exact False.elim (hy (neg_eq_zero.1 hy0))
· refine ⟨![r₁, r₂], ?_⟩
rw [Fin.sum_univ_two, Fin.exists_fin_two]
simp [h, hr₁.ne.symm]
· rcases h with ⟨m, hm, hmne⟩
rw [Fin.sum_univ_two, add_eq_zero_iff_eq_neg] at hm
dsimp only [Matrix.cons_val] at hm
rcases lt_trichotomy (m 0) 0 with (hm0 | hm0 | hm0) <;>
rcases lt_trichotomy (m 1) 0 with (hm1 | hm1 | hm1)
· refine
Or.inr (Or.inr (Or.inr ⟨-m 0, -m 1, Left.neg_pos_iff.2 hm0, Left.neg_pos_iff.2 hm1, ?_⟩))
linear_combination (norm := module) -hm
· exfalso
simp [hm1, hx, hm0.ne] at hm
· refine Or.inl (Or.inr (Or.inr ⟨-m 0, m 1, Left.neg_pos_iff.2 hm0, hm1, ?_⟩))
linear_combination (norm := module) -hm
· exfalso
simp [hm0, hy, hm1.ne] at hm
· rw [Fin.exists_fin_two] at hmne
exact False.elim (not_and_or.2 hmne ⟨hm0, hm1⟩)
· exfalso
simp [hm0, hy, hm1.ne.symm] at hm
· refine Or.inl (Or.inr (Or.inr ⟨m 0, -m 1, hm0, Left.neg_pos_iff.2 hm1, ?_⟩))
rwa [neg_smul]
· exfalso
simp [hm1, hx, hm0.ne.symm] at hm
· refine Or.inr (Or.inr (Or.inr ⟨m 0, m 1, hm0, hm1, ?_⟩))
rwa [smul_neg]