@@ -50,8 +50,20 @@ set_option linter.unusedVariables false in
5050def RayVector (R M : Type *) [Zero M] :=
5151 { v : M // v ≠ 0 }
5252
53+ /-- Equivalence between `RayVector` and non-zero vectors. -/
54+ def RayVector.equiv (R M : Type *) [Zero M] : RayVector R M ≃ { v : M // v ≠ 0 } :=
55+ Equiv.refl _
56+
5357instance RayVector.coe {R M : Type *} [Zero M] : CoeOut (RayVector R M) M where
54- coe := Subtype.val
58+ coe x := (equiv R M x).val
59+
60+ @[simp]
61+ theorem RayVector.coe_equiv_symm {R M : Type *} [Zero M] {v : M} (h : v ≠ 0 ) :
62+ (RayVector.equiv R M).symm ⟨v, h⟩ = v := rfl
63+
64+ @[ext]
65+ theorem RayVector.ext {R M : Type *} [Zero M] {x y : RayVector R M} (h : (x : M) = (y : M)) :
66+ x = y := Subtype.ext h
5567
5668instance {R M : Type*} [Zero M] [Nontrivial M] : Nonempty (RayVector R M) :=
5769 ⟨Classical.indefiniteDescription _ <| exists_ne (0 : M)⟩
@@ -225,7 +237,7 @@ variable (R)
225237
226238/-- The ray given by a nonzero vector. -/
227239def rayOfNeZero (v : M) (h : v ≠ 0 ) : Module.Ray R M :=
228- ⟦⟨v, h⟩⟧
240+ ⟦(RayVector.equiv R M).symm ⟨v, h⟩⟧
229241
230242/-- An induction principle for `Module.Ray`, used as `induction x using Module.Ray.ind`. -/
231243theorem Module.Ray.ind {C : Module.Ray R M → Prop } (h : ∀ (v) (hv : v ≠ 0 ), C (rayOfNeZero R v hv))
@@ -371,17 +383,16 @@ namespace RayVector
371383
372384/-- Negating a nonzero vector. -/
373385instance {R : Type*} : Neg (RayVector R M) :=
374- ⟨fun v => ⟨-v, neg_ne_zero.2 v.prop⟩⟩
386+ ⟨fun v => (equiv R M).symm ⟨-v, neg_ne_zero.2 v.prop⟩⟩
375387
376388/-- Negating a nonzero vector commutes with coercion to the underlying module. -/
377389@ [simp, norm_cast]
378390theorem coe_neg {R : Type *} (v : RayVector R M) : ↑(-v) = -(v : M) :=
379391 rfl
380392
381- set_option backward.isDefEq.respectTransparency false in
382393/-- Negating a nonzero vector twice produces the original vector. -/
383394instance {R : Type*} : InvolutiveNeg (RayVector R M) where
384- neg_neg v := by rw [Subtype .ext_iff, coe_neg, coe_neg, neg_neg]
395+ neg_neg v := by rw [RayVector .ext_iff, coe_neg, coe_neg, neg_neg]
385396
386397/-- If two nonzero vectors are equivalent, so are their negations. -/
387398@[simp]
0 commit comments