diff --git "a/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_AddTorsor.jsonl" "b/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_AddTorsor.jsonl" deleted file mode 100644--- "a/Extracted/Mathlib/TacticPrediction/Mathlib_Algebra_AddTorsor.jsonl" +++ /dev/null @@ -1,72 +0,0 @@ -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng1 g2 : G\np : P\nh : g1 +ᵥ p = g2 +ᵥ p\n⊢ g1 = g2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n ","nextTactic":"rw [← vadd_vsub g1 p]","declUpToTactic":"/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.98_0.7pEfyZSRLS9mYPD","decl":"/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng1 g2 : G\np : P\nh : g1 +ᵥ p = g2 +ᵥ p\n⊢ g1 +ᵥ p -ᵥ p = g2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n ","nextTactic":"rw [h]","declUpToTactic":"/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.98_0.7pEfyZSRLS9mYPD","decl":"/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng1 g2 : G\np : P\nh : g1 +ᵥ p = g2 +ᵥ p\n⊢ g2 +ᵥ p -ᵥ p = g2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n ","nextTactic":"rw [vadd_vsub]","declUpToTactic":"/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.98_0.7pEfyZSRLS9mYPD","decl":"/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng : G\np1 p2 : P\n⊢ g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n ","nextTactic":"apply vadd_right_cancel p2","declUpToTactic":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.118_0.7pEfyZSRLS9mYPD","decl":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng : G\np1 p2 : P\n⊢ g +ᵥ p1 -ᵥ p2 +ᵥ p2 = g + (p1 -ᵥ p2) +ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.118_0.7pEfyZSRLS9mYPD","decl":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng : G\np1 p2 : P\n⊢ g +ᵥ p1 = g + (p1 -ᵥ p2) +ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n ","nextTactic":"rw [add_vadd]","declUpToTactic":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.118_0.7pEfyZSRLS9mYPD","decl":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng : G\np1 p2 : P\n⊢ g +ᵥ p1 = g +ᵥ (p1 -ᵥ p2 +ᵥ p2)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.118_0.7pEfyZSRLS9mYPD","decl":"/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np : P\n⊢ p -ᵥ p = 0","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n ","nextTactic":"rw [← zero_add (p -ᵥ p)]","declUpToTactic":"/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.128_0.7pEfyZSRLS9mYPD","decl":"/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np : P\n⊢ 0 + (p -ᵥ p) = 0","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n ","nextTactic":"rw [← vadd_vsub_assoc]","declUpToTactic":"/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.128_0.7pEfyZSRLS9mYPD","decl":"/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np : P\n⊢ 0 +ᵥ p -ᵥ p = 0","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n ","nextTactic":"rw [vadd_vsub]","declUpToTactic":"/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.128_0.7pEfyZSRLS9mYPD","decl":"/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 : P\nh : p1 -ᵥ p2 = 0\n⊢ p1 = p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n ","nextTactic":"rw [← vsub_vadd p1 p2]","declUpToTactic":"/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.136_0.7pEfyZSRLS9mYPD","decl":"/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 : P\nh : p1 -ᵥ p2 = 0\n⊢ p1 -ᵥ p2 +ᵥ p2 = p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -��� p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n ","nextTactic":"rw [h]","declUpToTactic":"/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.136_0.7pEfyZSRLS9mYPD","decl":"/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 : P\nh : p1 -ᵥ p2 = 0\n⊢ 0 +ᵥ p2 = p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n ","nextTactic":"rw [zero_vadd]","declUpToTactic":"/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.136_0.7pEfyZSRLS9mYPD","decl":"/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n ","nextTactic":"apply vadd_right_cancel p3","declUpToTactic":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.154_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 + (p2 -ᵥ p3) +ᵥ p3 = p1 -ᵥ p3 +ᵥ p3","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n ","nextTactic":"rw [add_vadd]","declUpToTactic":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.154_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 +ᵥ (p2 -ᵥ p3 +ᵥ p3) = p1 -ᵥ p3 +ᵥ p3","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.154_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 +ᵥ p2 = p1 -ᵥ p3 +ᵥ p3","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.154_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 = p1 -ᵥ p3 +ᵥ p3","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.154_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 : P\n⊢ -(p1 -ᵥ p2) = p2 -ᵥ p1","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n ","nextTactic":"refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)","declUpToTactic":"/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.164_0.7pEfyZSRLS9mYPD","decl":"/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 : P\n⊢ p1 -ᵥ p2 + (p2 -ᵥ p1) +ᵥ p1 = 0 +ᵥ p1","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n ","nextTactic":"rw [vsub_add_vsub_cancel]","declUpToTactic":"/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.164_0.7pEfyZSRLS9mYPD","decl":"/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 : P\n⊢ p1 -ᵥ p1 +ᵥ p1 = 0 +ᵥ p1","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n ","nextTactic":"rw [vsub_self]","declUpToTactic":"/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.164_0.7pEfyZSRLS9mYPD","decl":"/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng : G\np q : P\n⊢ g +ᵥ p -ᵥ q = g - (q -ᵥ p)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n ","nextTactic":"rw [vadd_vsub_assoc]","declUpToTactic":"theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.173_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng : G\np q : P\n⊢ g + (p -ᵥ q) = g - (q -ᵥ p)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n ","nextTactic":"rw [sub_eq_add_neg]","declUpToTactic":"theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.173_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\ng : G\np q : P\n⊢ g + (p -ᵥ q) = g + -(q -ᵥ p)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n ","nextTactic":"rw [neg_vsub_eq_vsub_rev]","declUpToTactic":"theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.173_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 : P\ng : G\n⊢ p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n ","nextTactic":"rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]","declUpToTactic":"/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.179_0.7pEfyZSRLS9mYPD","decl":"/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n ","nextTactic":"rw [← vsub_vadd_eq_vsub_sub]","declUpToTactic":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.186_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ (p2 -ᵥ p3 +ᵥ p3) = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.186_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np₁ p₂ : P\n⊢ v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n ","nextTactic":"rw [eq_vadd_iff_vsub_eq]","declUpToTactic":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.200_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np₁ p₂ : P\n⊢ v₁ +ᵥ p₁ -ᵥ p₂ = v₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n ","nextTactic":"rw [vadd_vsub_assoc]","declUpToTactic":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.200_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np₁ p₂ : P\n⊢ v₁ + (p₁ -ᵥ p₂) = v₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n ","nextTactic":"rw [← add_right_inj (-v₁)]","declUpToTactic":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.200_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np₁ p₂ : P\n⊢ -v₁ + (v₁ + (p₁ -ᵥ p₂)) = -v₁ + v₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n ","nextTactic":"rw [neg_add_cancel_left]","declUpToTactic":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.200_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np₁ p₂ : P\n⊢ p₁ -ᵥ p₂ = -v₁ + v₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n ","nextTactic":"rw [eq_comm]","declUpToTactic":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.200_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np : P\n⊢ {p} -ᵥ {p} = {0}","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n ","nextTactic":"rw [Set.singleton_vsub_singleton]","declUpToTactic":"theorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.215_0.7pEfyZSRLS9mYPD","decl":"theorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np : P\n⊢ {p -ᵥ p} = {0}","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n ","nextTactic":"rw [vsub_self]","declUpToTactic":"theorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.215_0.7pEfyZSRLS9mYPD","decl":"theorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np : P\n⊢ v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n ","nextTactic":"rw [vsub_vadd_eq_vsub_sub]","declUpToTactic":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.222_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np : P\n⊢ v₁ +ᵥ p -ᵥ p - v₂ = v₁ - v₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n ","nextTactic":"rw [vadd_vsub_assoc]","declUpToTactic":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.222_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np : P\n⊢ v₁ + (p -ᵥ p) - v₂ = v₁ - v₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n ","nextTactic":"rw [vsub_self]","declUpToTactic":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.222_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\nv₁ v₂ : G\np : P\n⊢ v₁ + 0 - v₂ = v₁ - v₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n ","nextTactic":"rw [add_zero]","declUpToTactic":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.222_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p : P\nh : p1 -ᵥ p = p2 -ᵥ p\n⊢ p1 = p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n ","nextTactic":"rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h","declUpToTactic":"/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.230_0.7pEfyZSRLS9mYPD","decl":"/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p : P\nh : p -ᵥ p1 = p -ᵥ p2\n⊢ p1 = p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n ","nextTactic":"refine' vadd_left_cancel (p -ᵥ p2) _","declUpToTactic":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.248_0.7pEfyZSRLS9mYPD","decl":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p : P\nh : p -ᵥ p1 = p -ᵥ p2\n⊢ p -ᵥ p2 +ᵥ p1 = p -ᵥ p2 +ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.248_0.7pEfyZSRLS9mYPD","decl":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p : P\nh : p -ᵥ p1 = p -ᵥ p2\n⊢ p -ᵥ p2 +ᵥ p1 = p","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n ","nextTactic":"rw [← h]","declUpToTactic":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.248_0.7pEfyZSRLS9mYPD","decl":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝ : AddGroup G\nT : AddTorsor G P\np1 p2 p : P\nh : p -ᵥ p1 = p -ᵥ p2\n⊢ p -ᵥ p1 +ᵥ p1 = p","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n ","nextTactic":"rw [vsub_vadd]","declUpToTactic":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.248_0.7pEfyZSRLS9mYPD","decl":"/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n ","nextTactic":"rw [sub_eq_add_neg]","declUpToTactic":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.279_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p3 -ᵥ p2 + -(p3 -ᵥ p1) = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n ","nextTactic":"rw [neg_vsub_eq_vsub_rev]","declUpToTactic":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.279_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p3 -ᵥ p2 + (p1 -ᵥ p3) = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n ","nextTactic":"rw [add_comm]","declUpToTactic":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.279_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p3 + (p3 -ᵥ p2) = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n ","nextTactic":"rw [vsub_add_vsub_cancel]","declUpToTactic":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.279_0.7pEfyZSRLS9mYPD","decl":"/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\nv : G\np1 p2 : P\n⊢ v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -�� (v +ᵥ p2) = p1 -ᵥ p2 := by\n ","nextTactic":"rw [vsub_vadd_eq_vsub_sub]","declUpToTactic":"@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.288_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\nv : G\np1 p2 : P\n⊢ v +ᵥ p1 -ᵥ p2 - v = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n ","nextTactic":"rw [vadd_vsub_assoc]","declUpToTactic":"@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.288_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\nv : G\np1 p2 : P\n⊢ v + (p1 -ᵥ p2) - v = p1 -ᵥ p2","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n ","nextTactic":"rw [add_sub_cancel']","declUpToTactic":"@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.288_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n ","nextTactic":"rw [← @vsub_eq_zero_iff_eq G]","declUpToTactic":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.295_0.7pEfyZSRLS9mYPD","decl":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 +ᵥ p3 -ᵥ (p3 -ᵥ p2 +ᵥ p1) = 0","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n ","nextTactic":"rw [vadd_vsub_assoc]","declUpToTactic":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.295_0.7pEfyZSRLS9mYPD","decl":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 + (p3 -ᵥ (p3 -ᵥ p2 +ᵥ p1)) = 0","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n ","nextTactic":"rw [vsub_vadd_eq_vsub_sub]","declUpToTactic":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.295_0.7pEfyZSRLS9mYPD","decl":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np1 p2 p3 : P\n⊢ p1 -ᵥ p2 + (p3 -ᵥ p1 - (p3 -ᵥ p2)) = 0","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n ","nextTactic":"simp","declUpToTactic":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.295_0.7pEfyZSRLS9mYPD","decl":"theorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\nv₁ v₂ : G\np₁ p₂ : P\n⊢ v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ��� (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n ","nextTactic":"rw [vadd_eq_vadd_iff_neg_add_eq_vsub]","declUpToTactic":"theorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.302_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\nv₁ v₂ : G\np₁ p₂ : P\n⊢ -v₁ + v₂ = p₁ -ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n ","nextTactic":"rw [neg_add_eq_sub]","declUpToTactic":"theorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.302_0.7pEfyZSRLS9mYPD","decl":"theorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np₁ p₂ p₃ p₄ : P\n⊢ p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n ","nextTactic":"rw [← vsub_vadd_eq_vsub_sub]","declUpToTactic":"theorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.308_0.7pEfyZSRLS9mYPD","decl":"theorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np₁ p₂ p₃ p₄ : P\n⊢ p₁ -ᵥ (p₃ -ᵥ p₄ +ᵥ p₂) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n ","nextTactic":"rw [vsub_vadd_comm]","declUpToTactic":"theorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.308_0.7pEfyZSRLS9mYPD","decl":"theorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\np₁ p₂ p₃ p₄ : P\n⊢ p₁ -ᵥ (p₂ -ᵥ p₄ +ᵥ p₃) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n ","nextTactic":"rw [vsub_vadd_eq_vsub_sub]","declUpToTactic":"theorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.308_0.7pEfyZSRLS9mYPD","decl":"theorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\np p' : P\n⊢ (fun x => -x +ᵥ p) ((fun x => p -ᵥ x) p') = p'","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by ","nextTactic":"simp","declUpToTactic":"/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.415_0.7pEfyZSRLS9mYPD","decl":"/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\np : P\nv : G\n⊢ (fun x => p -ᵥ x) ((fun x => -x +ᵥ p) v) = v","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by ","nextTactic":"simp [vsub_vadd_eq_vsub_sub]","declUpToTactic":"/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.415_0.7pEfyZSRLS9mYPD","decl":"/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nv : G\np : P\n⊢ (fun x => -v +ᵥ x) ((fun x => v +ᵥ x) p) = p","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by ","nextTactic":"simp [vadd_vadd]","declUpToTactic":"/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.433_0.7pEfyZSRLS9mYPD","decl":"/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nv : G\np : P\n⊢ (fun x => v +ᵥ x) ((fun x => -v +ᵥ x) p) = p","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by ","nextTactic":"simp [vadd_vadd]","declUpToTactic":"/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.433_0.7pEfyZSRLS9mYPD","decl":"/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nx y : P\n⊢ -(x -ᵥ (pointReflection x) y) = -(y -ᵥ x)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by ","nextTactic":"simp","declUpToTactic":"@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.484_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nx y : P\n⊢ (pointReflection x) y -ᵥ y = 2 • (x -ᵥ y)","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n ","nextTactic":"simp [pointReflection, two_nsmul, vadd_vsub_assoc]","declUpToTactic":"@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.488_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nx y : P\n⊢ -(y -ᵥ (pointReflection x) y) = -(2 • (y -ᵥ x))","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n simp [pointReflection, two_nsmul, vadd_vsub_assoc]\n\n@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by ","nextTactic":"simp [← neg_nsmul]","declUpToTactic":"@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.492_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nx : P\n⊢ ∀ (x_1 : P), (pointReflection x).symm x_1 = (pointReflection x) x_1","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n simp [pointReflection, two_nsmul, vadd_vsub_assoc]\n\n@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by simp [← neg_nsmul]\n\n@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=\n ext <| by ","nextTactic":"simp [pointReflection]","declUpToTactic":"@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=\n ext <| by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.496_0.7pEfyZSRLS9mYPD","decl":"@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nx y : P\n⊢ (pointReflection x) y = (pointReflection x).symm y","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n simp [pointReflection, two_nsmul, vadd_vsub_assoc]\n\n@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by simp [← neg_nsmul]\n\n@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=\n ext <| by simp [pointReflection]\n#align equiv.point_reflection_symm Equiv.pointReflection_symm\n\n@[simp]\ntheorem pointReflection_self (x : P) : pointReflection x x = x :=\n vsub_vadd _ _\n#align equiv.point_reflection_self Equiv.pointReflection_self\n\ntheorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) := fun y =>\n (Equiv.apply_eq_iff_eq_symm_apply _).2 <| by ","nextTactic":"rw [pointReflection_symm]","declUpToTactic":"theorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) := fun y =>\n (Equiv.apply_eq_iff_eq_symm_apply _).2 <| by ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.506_0.7pEfyZSRLS9mYPD","decl":"theorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\nx y : P\nh : Injective bit0\n⊢ (pointReflection x) y = y ↔ y = x","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n simp [pointReflection, two_nsmul, vadd_vsub_assoc]\n\n@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by simp [← neg_nsmul]\n\n@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=\n ext <| by simp [pointReflection]\n#align equiv.point_reflection_symm Equiv.pointReflection_symm\n\n@[simp]\ntheorem pointReflection_self (x : P) : pointReflection x x = x :=\n vsub_vadd _ _\n#align equiv.point_reflection_self Equiv.pointReflection_self\n\ntheorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) := fun y =>\n (Equiv.apply_eq_iff_eq_symm_apply _).2 <| by rw [pointReflection_symm]\n#align equiv.point_reflection_involutive Equiv.pointReflection_involutive\n\nset_option linter.deprecated false\n/-- `x` is the only fixed point of `pointReflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (bit0 : G → G)) :\n pointReflection x y = y ↔ y = x := by\n ","nextTactic":"rw [pointReflection_apply, eq_comm, eq_vadd_iff_vsub_eq, ← neg_vsub_eq_vsub_rev,\n neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero, h.eq_iff, vsub_eq_zero_iff_eq, eq_comm]","declUpToTactic":"/-- `x` is the only fixed point of `pointReflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (bit0 : G → G)) :\n pointReflection x y = y ↔ y = x := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.511_0.7pEfyZSRLS9mYPD","decl":"/-- `x` is the only fixed point of `pointReflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (bit0 : G → G)) :\n pointReflection x y = y ↔ y = x "} -{"state":"G✝ : Type u_1\nP✝ : Type u_2\ninst✝³ : AddGroup G✝\ninst✝² : AddTorsor G✝ P✝\nG : Type u_3\nP : Type u_4\ninst✝¹ : AddCommGroup G\ninst✝ : AddTorsor G P\nh : Injective bit0\ny x₁ x₂ : P\nhy : (pointReflection x₁) y = (pointReflection x₂) y\n⊢ x₁ = x₂","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n simp [pointReflection, two_nsmul, vadd_vsub_assoc]\n\n@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by simp [← neg_nsmul]\n\n@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=\n ext <| by simp [pointReflection]\n#align equiv.point_reflection_symm Equiv.pointReflection_symm\n\n@[simp]\ntheorem pointReflection_self (x : P) : pointReflection x x = x :=\n vsub_vadd _ _\n#align equiv.point_reflection_self Equiv.pointReflection_self\n\ntheorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) := fun y =>\n (Equiv.apply_eq_iff_eq_symm_apply _).2 <| by rw [pointReflection_symm]\n#align equiv.point_reflection_involutive Equiv.pointReflection_involutive\n\nset_option linter.deprecated false\n/-- `x` is the only fixed point of `pointReflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (bit0 : G → G)) :\n pointReflection x y = y ↔ y = x := by\n rw [pointReflection_apply, eq_comm, eq_vadd_iff_vsub_eq, ← neg_vsub_eq_vsub_rev,\n neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero, h.eq_iff, vsub_eq_zero_iff_eq, eq_comm]\n#align equiv.point_reflection_fixed_iff_of_injective_bit0 Equiv.pointReflection_fixed_iff_of_injective_bit0\n\n-- Porting note: Removed:\n-- omit G\n\n-- Porting note: need this to calm down CI\ntheorem injective_pointReflection_left_of_injective_bit0 {G P : Type*} [AddCommGroup G]\n [AddTorsor G P] (h : Injective (bit0 : G → G)) (y : P) :\n Injective fun x : P => pointReflection x y :=\n fun x₁ x₂ (hy : pointReflection x₁ y = pointReflection x₂ y) => by\n ","nextTactic":"rwa [pointReflection_apply, pointReflection_apply, vadd_eq_vadd_iff_sub_eq_vsub,\n vsub_sub_vsub_cancel_right, ← neg_vsub_eq_vsub_rev, neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero,\n h.eq_iff, vsub_eq_zero_iff_eq] at hy","declUpToTactic":"theorem injective_pointReflection_left_of_injective_bit0 {G P : Type*} [AddCommGroup G]\n [AddTorsor G P] (h : Injective (bit0 : G → G)) (y : P) :\n Injective fun x : P => pointReflection x y :=\n fun x₁ x₂ (hy : pointReflection x₁ y = pointReflection x₂ y) => by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.523_0.7pEfyZSRLS9mYPD","decl":"theorem injective_pointReflection_left_of_injective_bit0 {G P : Type*} [AddCommGroup G]\n [AddTorsor G P] (h : Injective (bit0 : G → G)) (y : P) :\n Injective fun x : P => pointReflection x y "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\n⊢ Subsingleton G ↔ Subsingleton P","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n simp [pointReflection, two_nsmul, vadd_vsub_assoc]\n\n@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by simp [← neg_nsmul]\n\n@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=\n ext <| by simp [pointReflection]\n#align equiv.point_reflection_symm Equiv.pointReflection_symm\n\n@[simp]\ntheorem pointReflection_self (x : P) : pointReflection x x = x :=\n vsub_vadd _ _\n#align equiv.point_reflection_self Equiv.pointReflection_self\n\ntheorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) := fun y =>\n (Equiv.apply_eq_iff_eq_symm_apply _).2 <| by rw [pointReflection_symm]\n#align equiv.point_reflection_involutive Equiv.pointReflection_involutive\n\nset_option linter.deprecated false\n/-- `x` is the only fixed point of `pointReflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (bit0 : G → G)) :\n pointReflection x y = y ↔ y = x := by\n rw [pointReflection_apply, eq_comm, eq_vadd_iff_vsub_eq, ← neg_vsub_eq_vsub_rev,\n neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero, h.eq_iff, vsub_eq_zero_iff_eq, eq_comm]\n#align equiv.point_reflection_fixed_iff_of_injective_bit0 Equiv.pointReflection_fixed_iff_of_injective_bit0\n\n-- Porting note: Removed:\n-- omit G\n\n-- Porting note: need this to calm down CI\ntheorem injective_pointReflection_left_of_injective_bit0 {G P : Type*} [AddCommGroup G]\n [AddTorsor G P] (h : Injective (bit0 : G → G)) (y : P) :\n Injective fun x : P => pointReflection x y :=\n fun x₁ x₂ (hy : pointReflection x₁ y = pointReflection x₂ y) => by\n rwa [pointReflection_apply, pointReflection_apply, vadd_eq_vadd_iff_sub_eq_vsub,\n vsub_sub_vsub_cancel_right, ← neg_vsub_eq_vsub_rev, neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero,\n h.eq_iff, vsub_eq_zero_iff_eq] at hy\n#align equiv.injective_point_reflection_left_of_injective_bit0 Equiv.injective_pointReflection_left_of_injective_bit0\n\nend Equiv\n\ntheorem AddTorsor.subsingleton_iff (G P : Type*) [AddGroup G] [AddTorsor G P] :\n Subsingleton G ↔ Subsingleton P := by\n ","nextTactic":"inhabit P","declUpToTactic":"theorem AddTorsor.subsingleton_iff (G P : Type*) [AddGroup G] [AddTorsor G P] :\n Subsingleton G ↔ Subsingleton P := by\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.534_0.7pEfyZSRLS9mYPD","decl":"theorem AddTorsor.subsingleton_iff (G P : Type*) [AddGroup G] [AddTorsor G P] :\n Subsingleton G ↔ Subsingleton P "} -{"state":"G : Type u_1\nP : Type u_2\ninst✝¹ : AddGroup G\ninst✝ : AddTorsor G P\ninhabited_h : Inhabited P\n⊢ Subsingleton G ↔ Subsingleton P","srcUpToTactic":"/-\nCopyright (c) 2020 Joseph Myers. All rights reserved.\nReleased under Apache 2.0 license as described in the file LICENSE.\nAuthors: Joseph Myers, Yury Kudryashov\n-/\nimport Mathlib.Data.Set.Pointwise.SMul\n\n#align_import algebra.add_torsor from \"leanprover-community/mathlib\"@\"9003f28797c0664a49e4179487267c494477d853\"\n\n/-!\n# Torsors of additive group actions\n\nThis file defines torsors of additive group actions.\n\n## Notations\n\nThe group elements are referred to as acting on points. This file\ndefines the notation `+ᵥ` for adding a group element to a point and\n`-ᵥ` for subtracting two points to produce a group element.\n\n## Implementation notes\n\nAffine spaces are the motivating example of torsors of additive group actions. It may be appropriate\nto refactor in terms of the general definition of group actions, via `to_additive`, when there is a\nuse for multiplicative torsors (currently mathlib only develops the theory of group actions for\nmultiplicative group actions).\n\n## Notations\n\n* `v +ᵥ p` is a notation for `VAdd.vadd`, the left action of an additive monoid;\n\n* `p₁ -ᵥ p₂` is a notation for `VSub.vsub`, difference between two points in an additive torsor\n as an element of the corresponding additive group;\n\n## References\n\n* https://en.wikipedia.org/wiki/Principal_homogeneous_space\n* https://en.wikipedia.org/wiki/Affine_space\n\n-/\n\nset_option autoImplicit true\n\n\n/-- An `AddTorsor G P` gives a structure to the nonempty type `P`,\nacted on by an `AddGroup G` with a transitive and free action given\nby the `+ᵥ` operation and a corresponding subtraction given by the\n`-ᵥ` operation. In the case of a vector space, it is an affine\nspace. -/\nclass AddTorsor (G : outParam (Type*)) (P : Type*) [outParam <| AddGroup G] extends AddAction G P,\n VSub G P where\n [nonempty : Nonempty P]\n /-- Torsor subtraction and addition with the same element cancels out. -/\n vsub_vadd' : ∀ p1 p2 : P, (p1 -ᵥ p2 : G) +ᵥ p2 = p1\n /-- Torsor addition and subtraction with the same element cancels out. -/\n vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g\n#align add_torsor AddTorsor\n\nattribute [instance 100] AddTorsor.nonempty -- porting note: removers `nolint instance_priority`\n\n--Porting note: removed\n--attribute [nolint dangerous_instance] AddTorsor.toVSub\n\n/-- An `AddGroup G` is a torsor for itself. -/\n--@[nolint instance_priority] Porting note: linter does not exist\ninstance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G\n where\n vsub := Sub.sub\n vsub_vadd' := sub_add_cancel\n vadd_vsub' := add_sub_cancel\n#align add_group_is_add_torsor addGroupIsAddTorsor\n\n/-- Simplify subtraction for a torsor for an `AddGroup G` over\nitself. -/\n@[simp]\ntheorem vsub_eq_sub {G : Type*} [AddGroup G] (g1 g2 : G) : g1 -ᵥ g2 = g1 - g2 :=\n rfl\n#align vsub_eq_sub vsub_eq_sub\n\nsection General\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P]\n\n/-- Adding the result of subtracting from another point produces that\npoint. -/\n@[simp]\ntheorem vsub_vadd (p1 p2 : P) : p1 -ᵥ p2 +ᵥ p2 = p1 :=\n AddTorsor.vsub_vadd' p1 p2\n#align vsub_vadd vsub_vadd\n\n/-- Adding a group element then subtracting the original point\nproduces that group element. -/\n@[simp]\ntheorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g :=\n AddTorsor.vadd_vsub' g p\n#align vadd_vsub vadd_vsub\n\n/-- If the same point added to two group elements produces equal\nresults, those group elements are equal. -/\ntheorem vadd_right_cancel {g1 g2 : G} (p : P) (h : g1 +ᵥ p = g2 +ᵥ p) : g1 = g2 := by\n-- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p\n rw [← vadd_vsub g1 p]\n rw [h]\n rw [vadd_vsub]\n#align vadd_right_cancel vadd_right_cancel\n\n@[simp]\ntheorem vadd_right_cancel_iff {g1 g2 : G} (p : P) : g1 +ᵥ p = g2 +ᵥ p ↔ g1 = g2 :=\n ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩\n#align vadd_right_cancel_iff vadd_right_cancel_iff\n\n/-- Adding a group element to the point `p` is an injective\nfunction. -/\ntheorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ =>\n vadd_right_cancel p\n#align vadd_right_injective vadd_right_injective\n\n/-- Adding a group element to a point, then subtracting another point,\nproduces the same result as subtracting the points then adding the\ngroup element. -/\ntheorem vadd_vsub_assoc (g : G) (p1 p2 : P) : g +ᵥ p1 -ᵥ p2 = g + (p1 -ᵥ p2) := by\n apply vadd_right_cancel p2\n rw [vsub_vadd]\n rw [add_vadd]\n rw [vsub_vadd]\n#align vadd_vsub_assoc vadd_vsub_assoc\n\n/-- Subtracting a point from itself produces 0. -/\n@[simp]\ntheorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by\n rw [← zero_add (p -ᵥ p)]\n rw [← vadd_vsub_assoc]\n rw [vadd_vsub]\n#align vsub_self vsub_self\n\n/-- If subtracting two points produces 0, they are equal. -/\ntheorem eq_of_vsub_eq_zero {p1 p2 : P} (h : p1 -ᵥ p2 = (0 : G)) : p1 = p2 := by\n rw [← vsub_vadd p1 p2]\n rw [h]\n rw [zero_vadd]\n#align eq_of_vsub_eq_zero eq_of_vsub_eq_zero\n\n/-- Subtracting two points produces 0 if and only if they are\nequal. -/\n@[simp]\ntheorem vsub_eq_zero_iff_eq {p1 p2 : P} : p1 -ᵥ p2 = (0 : G) ↔ p1 = p2 :=\n Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _\n#align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq\n\ntheorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q :=\n not_congr vsub_eq_zero_iff_eq\n#align vsub_ne_zero vsub_ne_zero\n\n/-- Cancellation adding the results of two subtractions. -/\n@[simp]\ntheorem vsub_add_vsub_cancel (p1 p2 p3 : P) : p1 -ᵥ p2 + (p2 -ᵥ p3) = p1 -ᵥ p3 := by\n apply vadd_right_cancel p3\n rw [add_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n rw [vsub_vadd]\n#align vsub_add_vsub_cancel vsub_add_vsub_cancel\n\n/-- Subtracting two points in the reverse order produces the negation\nof subtracting them. -/\n@[simp]\ntheorem neg_vsub_eq_vsub_rev (p1 p2 : P) : -(p1 -ᵥ p2) = p2 -ᵥ p1 := by\n refine' neg_eq_of_add_eq_zero_right (vadd_right_cancel p1 _)\n rw [vsub_add_vsub_cancel]\n rw [vsub_self]\n#align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev\n\ntheorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by\n rw [vadd_vsub_assoc]\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n#align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub\n\n/-- Subtracting the result of adding a group element produces the same result\nas subtracting the points and subtracting that group element. -/\ntheorem vsub_vadd_eq_vsub_sub (p1 p2 : P) (g : G) : p1 -ᵥ (g +ᵥ p2) = p1 -ᵥ p2 - g := by\n rw [← add_right_inj (p2 -ᵥ p1 : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ←\n add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]\n#align vsub_vadd_eq_vsub_sub vsub_vadd_eq_vsub_sub\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_right (p1 p2 p3 : P) : p1 -ᵥ p3 - (p2 -ᵥ p3) = p1 -ᵥ p2 := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd]\n#align vsub_sub_vsub_cancel_right vsub_sub_vsub_cancel_right\n\n/-- Convert between an equality with adding a group element to a point\nand an equality of a subtraction of two points with a group\nelement. -/\ntheorem eq_vadd_iff_vsub_eq (p1 : P) (g : G) (p2 : P) : p1 = g +ᵥ p2 ↔ p1 -ᵥ p2 = g :=\n ⟨fun h => h.symm ▸ vadd_vsub _ _, fun h => h ▸ (vsub_vadd _ _).symm⟩\n#align eq_vadd_iff_vsub_eq eq_vadd_iff_vsub_eq\n\ntheorem vadd_eq_vadd_iff_neg_add_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ -v₁ + v₂ = p₁ -ᵥ p₂ := by\n rw [eq_vadd_iff_vsub_eq]\n rw [vadd_vsub_assoc]\n rw [← add_right_inj (-v₁)]\n rw [neg_add_cancel_left]\n rw [eq_comm]\n#align vadd_eq_vadd_iff_neg_add_eq_vsub vadd_eq_vadd_iff_neg_add_eq_vsub\n\nnamespace Set\n\nopen Pointwise\n\n-- Porting note: simp can prove this\n--@[simp]\ntheorem singleton_vsub_self (p : P) : ({p} : Set P) -ᵥ {p} = {(0 : G)} := by\n rw [Set.singleton_vsub_singleton]\n rw [vsub_self]\n#align set.singleton_vsub_self Set.singleton_vsub_self\n\nend Set\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_right (v₁ v₂ : G) (p : P) : v₁ +ᵥ p -ᵥ (v₂ +ᵥ p) = v₁ - v₂ := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [vsub_self]\n rw [add_zero]\n#align vadd_vsub_vadd_cancel_right vadd_vsub_vadd_cancel_right\n\n/-- If the same point subtracted from two points produces equal\nresults, those points are equal. -/\ntheorem vsub_left_cancel {p1 p2 p : P} (h : p1 -ᵥ p = p2 -ᵥ p) : p1 = p2 := by\n rwa [← sub_eq_zero, vsub_sub_vsub_cancel_right, vsub_eq_zero_iff_eq] at h\n#align vsub_left_cancel vsub_left_cancel\n\n/-- The same point subtracted from two points produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_left_cancel_iff {p1 p2 p : P} : p1 -ᵥ p = p2 -ᵥ p ↔ p1 = p2 :=\n ⟨vsub_left_cancel, fun h => h ▸ rfl⟩\n#align vsub_left_cancel_iff vsub_left_cancel_iff\n\n/-- Subtracting the point `p` is an injective function. -/\ntheorem vsub_left_injective (p : P) : Function.Injective ((· -ᵥ p) : P → G) := fun _ _ =>\n vsub_left_cancel\n#align vsub_left_injective vsub_left_injective\n\n/-- If subtracting two points from the same point produces equal\nresults, those points are equal. -/\ntheorem vsub_right_cancel {p1 p2 p : P} (h : p -ᵥ p1 = p -ᵥ p2) : p1 = p2 := by\n refine' vadd_left_cancel (p -ᵥ p2) _\n rw [vsub_vadd]\n rw [← h]\n rw [vsub_vadd]\n#align vsub_right_cancel vsub_right_cancel\n\n/-- Subtracting two points from the same point produces equal results\nif and only if those points are equal. -/\n@[simp]\ntheorem vsub_right_cancel_iff {p1 p2 p : P} : p -ᵥ p1 = p -ᵥ p2 ↔ p1 = p2 :=\n ⟨vsub_right_cancel, fun h => h ▸ rfl⟩\n#align vsub_right_cancel_iff vsub_right_cancel_iff\n\n/-- Subtracting a point from the point `p` is an injective\nfunction. -/\ntheorem vsub_right_injective (p : P) : Function.Injective ((p -ᵥ ·) : P → G) := fun _ _ =>\n vsub_right_cancel\n#align vsub_right_injective vsub_right_injective\n\nend General\n\nsection comm\n\nvariable {G : Type*} {P : Type*} [AddCommGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- Cancellation subtracting the results of two subtractions. -/\n@[simp]\ntheorem vsub_sub_vsub_cancel_left (p1 p2 p3 : P) : p3 -ᵥ p2 - (p3 -ᵥ p1) = p1 -ᵥ p2 := by\n rw [sub_eq_add_neg]\n rw [neg_vsub_eq_vsub_rev]\n rw [add_comm]\n rw [vsub_add_vsub_cancel]\n#align vsub_sub_vsub_cancel_left vsub_sub_vsub_cancel_left\n\n@[simp]\ntheorem vadd_vsub_vadd_cancel_left (v : G) (p1 p2 : P) : v +ᵥ p1 -ᵥ (v +ᵥ p2) = p1 -ᵥ p2 := by\n rw [vsub_vadd_eq_vsub_sub]\n rw [vadd_vsub_assoc]\n rw [add_sub_cancel']\n#align vadd_vsub_vadd_cancel_left vadd_vsub_vadd_cancel_left\n\ntheorem vsub_vadd_comm (p1 p2 p3 : P) : (p1 -ᵥ p2 : G) +ᵥ p3 = p3 -ᵥ p2 +ᵥ p1 := by\n rw [← @vsub_eq_zero_iff_eq G]\n rw [vadd_vsub_assoc]\n rw [vsub_vadd_eq_vsub_sub]\n simp\n#align vsub_vadd_comm vsub_vadd_comm\n\ntheorem vadd_eq_vadd_iff_sub_eq_vsub {v₁ v₂ : G} {p₁ p₂ : P} :\n v₁ +ᵥ p₁ = v₂ +ᵥ p₂ ↔ v₂ - v₁ = p₁ -ᵥ p₂ := by\n rw [vadd_eq_vadd_iff_neg_add_eq_vsub]\n rw [neg_add_eq_sub]\n#align vadd_eq_vadd_iff_sub_eq_vsub vadd_eq_vadd_iff_sub_eq_vsub\n\ntheorem vsub_sub_vsub_comm (p₁ p₂ p₃ p₄ : P) : p₁ -ᵥ p₂ - (p₃ -ᵥ p₄) = p₁ -ᵥ p₃ - (p₂ -ᵥ p₄) := by\n rw [← vsub_vadd_eq_vsub_sub]\n rw [vsub_vadd_comm]\n rw [vsub_vadd_eq_vsub_sub]\n#align vsub_sub_vsub_comm vsub_sub_vsub_comm\n\nend comm\n\nnamespace Prod\n\nvariable {G : Type*} [AddGroup G] [AddGroup G'] [AddTorsor G P] [AddTorsor G' P']\n\ninstance instAddTorsor : AddTorsor (G × G') (P × P') where\n vadd v p := (v.1 +ᵥ p.1, v.2 +ᵥ p.2)\n zero_vadd _ := Prod.ext (zero_vadd _ _) (zero_vadd _ _)\n add_vadd _ _ _ := Prod.ext (add_vadd _ _ _) (add_vadd _ _ _)\n vsub p₁ p₂ := (p₁.1 -ᵥ p₂.1, p₁.2 -ᵥ p₂.2)\n nonempty := Prod.Nonempty\n vsub_vadd' _ _ := Prod.ext (vsub_vadd _ _) (vsub_vadd _ _)\n vadd_vsub' _ _ := Prod.ext (vadd_vsub _ _) (vadd_vsub _ _)\n\n-- Porting note: The proofs above used to be shorter:\n-- zero_vadd p := by simp ⊢ 0 +ᵥ p = p\n-- add_vadd := by simp [add_vadd] ⊢ ∀ (a : G) (b : G') (a_1 : G) (b_1 : G') (a_2 : P) (b_2 : P'),\n-- (a + a_1, b + b_1) +ᵥ (a_2, b_2) = (a, b) +ᵥ ((a_1, b_1) +ᵥ (a_2, b_2))\n-- vsub_vadd' p₁ p₂ := show (p₁.1 -ᵥ p₂.1 +ᵥ p₂.1, _) = p₁ by simp\n-- ⊢ (p₁.fst -ᵥ p₂.fst +ᵥ p₂.fst, ((p₁.fst -ᵥ p₂.fst, p₁.snd -ᵥ p₂.snd) +ᵥ p₂).snd) = p₁\n-- vadd_vsub' v p := show (v.1 +ᵥ p.1 -ᵥ p.1, v.2 +ᵥ p.2 -ᵥ p.2) = v by simp\n-- ⊢ (v.fst +ᵥ p.fst -ᵥ p.fst, v.snd) = v\n\n@[simp]\ntheorem fst_vadd (v : G × G') (p : P × P') : (v +ᵥ p).1 = v.1 +ᵥ p.1 :=\n rfl\n#align prod.fst_vadd Prod.fst_vadd\n\n@[simp]\ntheorem snd_vadd (v : G × G') (p : P × P') : (v +ᵥ p).2 = v.2 +ᵥ p.2 :=\n rfl\n#align prod.snd_vadd Prod.snd_vadd\n\n@[simp]\ntheorem mk_vadd_mk (v : G) (v' : G') (p : P) (p' : P') : (v, v') +ᵥ (p, p') = (v +ᵥ p, v' +ᵥ p') :=\n rfl\n#align prod.mk_vadd_mk Prod.mk_vadd_mk\n\n@[simp]\ntheorem fst_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').1 = p₁.1 -ᵥ p₂.1 :=\n rfl\n#align prod.fst_vsub Prod.fst_vsub\n\n@[simp]\ntheorem snd_vsub (p₁ p₂ : P × P') : (p₁ -ᵥ p₂ : G × G').2 = p₁.2 -ᵥ p₂.2 :=\n rfl\n#align prod.snd_vsub Prod.snd_vsub\n\n@[simp]\ntheorem mk_vsub_mk (p₁ p₂ : P) (p₁' p₂' : P') :\n ((p₁, p₁') -ᵥ (p₂, p₂') : G × G') = (p₁ -ᵥ p₂, p₁' -ᵥ p₂') :=\n rfl\n#align prod.mk_vsub_mk Prod.mk_vsub_mk\n\nend Prod\n\nnamespace Pi\n\nuniverse u v w\n\nvariable {I : Type u} {fg : I → Type v} [∀ i, AddGroup (fg i)] {fp : I → Type w}\n\nopen AddAction AddTorsor\n\n/-- A product of `AddTorsor`s is an `AddTorsor`. -/\ninstance instAddTorsor [∀ i, AddTorsor (fg i) (fp i)] : AddTorsor (∀ i, fg i) (∀ i, fp i) where\n vadd g p i := g i +ᵥ p i\n zero_vadd p := funext fun i => zero_vadd (fg i) (p i)\n add_vadd g₁ g₂ p := funext fun i => add_vadd (g₁ i) (g₂ i) (p i)\n vsub p₁ p₂ i := p₁ i -ᵥ p₂ i\n vsub_vadd' p₁ p₂ := funext fun i => vsub_vadd (p₁ i) (p₂ i)\n vadd_vsub' g p := funext fun i => vadd_vsub (g i) (p i)\n\nend Pi\n\nnamespace Equiv\n\nvariable {G : Type*} {P : Type*} [AddGroup G] [AddTorsor G P]\n\n-- Porting note: Removed:\n-- include G\n\n/-- `v ↦ v +ᵥ p` as an equivalence. -/\ndef vaddConst (p : P) : G ≃ P where\n toFun v := v +ᵥ p\n invFun p' := p' -ᵥ p\n left_inv _ := vadd_vsub _ _\n right_inv _ := vsub_vadd _ _\n#align equiv.vadd_const Equiv.vaddConst\n\n@[simp]\ntheorem coe_vaddConst (p : P) : ⇑(vaddConst p) = fun v => v +ᵥ p :=\n rfl\n#align equiv.coe_vadd_const Equiv.coe_vaddConst\n\n@[simp]\ntheorem coe_vaddConst_symm (p : P) : ⇑(vaddConst p).symm = fun p' => p' -ᵥ p :=\n rfl\n#align equiv.coe_vadd_const_symm Equiv.coe_vaddConst_symm\n\n/-- `p' ↦ p -ᵥ p'` as an equivalence. -/\ndef constVSub (p : P) : P ≃ G where\n toFun := (p -ᵥ ·)\n invFun := (-· +ᵥ p)\n left_inv p' := by simp\n right_inv v := by simp [vsub_vadd_eq_vsub_sub]\n#align equiv.const_vsub Equiv.constVSub\n\n@[simp] lemma coe_constVSub (p : P) : ⇑(constVSub p) = (p -ᵥ ·) := rfl\n#align equiv.coe_const_vsub Equiv.coe_constVSub\n\n@[simp]\ntheorem coe_constVSub_symm (p : P) : ⇑(constVSub p).symm = fun (v : G) => -v +ᵥ p :=\n rfl\n#align equiv.coe_const_vsub_symm Equiv.coe_constVSub_symm\n\nvariable (P)\n\n/-- The permutation given by `p ↦ v +ᵥ p`. -/\ndef constVAdd (v : G) : Equiv.Perm P where\n toFun := (v +ᵥ ·)\n invFun := (-v +ᵥ ·)\n left_inv p := by simp [vadd_vadd]\n right_inv p := by simp [vadd_vadd]\n#align equiv.const_vadd Equiv.constVAdd\n\n@[simp] lemma coe_constVAdd (v : G) : ⇑(constVAdd P v) = (v +ᵥ ·) := rfl\n#align equiv.coe_const_vadd Equiv.coe_constVAdd\n\nvariable (G)\n\n@[simp]\ntheorem constVAdd_zero : constVAdd P (0 : G) = 1 :=\n ext <| zero_vadd G\n#align equiv.const_vadd_zero Equiv.constVAdd_zero\n\nvariable {G}\n\n@[simp]\ntheorem constVAdd_add (v₁ v₂ : G) : constVAdd P (v₁ + v₂) = constVAdd P v₁ * constVAdd P v₂ :=\n ext <| add_vadd v₁ v₂\n#align equiv.const_vadd_add Equiv.constVAdd_add\n\n/-- `Equiv.constVAdd` as a homomorphism from `Multiplicative G` to `Equiv.perm P` -/\ndef constVAddHom : Multiplicative G →* Equiv.Perm P where\n toFun v := constVAdd P (Multiplicative.toAdd v)\n map_one' := constVAdd_zero G P\n map_mul' := constVAdd_add P\n#align equiv.const_vadd_hom Equiv.constVAddHom\n\nvariable {P}\n\n-- Porting note: Previous code was:\n-- open _Root_.Function\nopen Function\n\n/-- Point reflection in `x` as a permutation. -/\ndef pointReflection (x : P) : Perm P :=\n (constVSub x).trans (vaddConst x)\n#align equiv.point_reflection Equiv.pointReflection\n\ntheorem pointReflection_apply (x y : P) : pointReflection x y = x -ᵥ y +ᵥ x :=\n rfl\n#align equiv.point_reflection_apply Equiv.pointReflection_apply\n\n@[simp]\ntheorem pointReflection_vsub_left (x y : P) : pointReflection x y -ᵥ x = x -ᵥ y :=\n vadd_vsub ..\n\n@[simp]\ntheorem left_vsub_pointReflection (x y : P) : x -ᵥ pointReflection x y = y -ᵥ x :=\n neg_injective <| by simp\n\n@[simp]\ntheorem pointReflection_vsub_right (x y : P) : pointReflection x y -ᵥ y = 2 • (x -ᵥ y) := by\n simp [pointReflection, two_nsmul, vadd_vsub_assoc]\n\n@[simp]\ntheorem right_vsub_pointReflection (x y : P) : y -ᵥ pointReflection x y = 2 • (y -ᵥ x) :=\n neg_injective <| by simp [← neg_nsmul]\n\n@[simp]\ntheorem pointReflection_symm (x : P) : (pointReflection x).symm = pointReflection x :=\n ext <| by simp [pointReflection]\n#align equiv.point_reflection_symm Equiv.pointReflection_symm\n\n@[simp]\ntheorem pointReflection_self (x : P) : pointReflection x x = x :=\n vsub_vadd _ _\n#align equiv.point_reflection_self Equiv.pointReflection_self\n\ntheorem pointReflection_involutive (x : P) : Involutive (pointReflection x : P → P) := fun y =>\n (Equiv.apply_eq_iff_eq_symm_apply _).2 <| by rw [pointReflection_symm]\n#align equiv.point_reflection_involutive Equiv.pointReflection_involutive\n\nset_option linter.deprecated false\n/-- `x` is the only fixed point of `pointReflection x`. This lemma requires\n`x + x = y + y ↔ x = y`. There is no typeclass to use here, so we add it as an explicit argument. -/\ntheorem pointReflection_fixed_iff_of_injective_bit0 {x y : P} (h : Injective (bit0 : G → G)) :\n pointReflection x y = y ↔ y = x := by\n rw [pointReflection_apply, eq_comm, eq_vadd_iff_vsub_eq, ← neg_vsub_eq_vsub_rev,\n neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero, h.eq_iff, vsub_eq_zero_iff_eq, eq_comm]\n#align equiv.point_reflection_fixed_iff_of_injective_bit0 Equiv.pointReflection_fixed_iff_of_injective_bit0\n\n-- Porting note: Removed:\n-- omit G\n\n-- Porting note: need this to calm down CI\ntheorem injective_pointReflection_left_of_injective_bit0 {G P : Type*} [AddCommGroup G]\n [AddTorsor G P] (h : Injective (bit0 : G → G)) (y : P) :\n Injective fun x : P => pointReflection x y :=\n fun x₁ x₂ (hy : pointReflection x₁ y = pointReflection x₂ y) => by\n rwa [pointReflection_apply, pointReflection_apply, vadd_eq_vadd_iff_sub_eq_vsub,\n vsub_sub_vsub_cancel_right, ← neg_vsub_eq_vsub_rev, neg_eq_iff_add_eq_zero, ← bit0, ← bit0_zero,\n h.eq_iff, vsub_eq_zero_iff_eq] at hy\n#align equiv.injective_point_reflection_left_of_injective_bit0 Equiv.injective_pointReflection_left_of_injective_bit0\n\nend Equiv\n\ntheorem AddTorsor.subsingleton_iff (G P : Type*) [AddGroup G] [AddTorsor G P] :\n Subsingleton G ↔ Subsingleton P := by\n inhabit P\n ","nextTactic":"exact (Equiv.vaddConst default).subsingleton_congr","declUpToTactic":"theorem AddTorsor.subsingleton_iff (G P : Type*) [AddGroup G] [AddTorsor G P] :\n Subsingleton G ↔ Subsingleton P := by\n inhabit P\n ","declId":"Examples.Mathlib.SplitRw.Mathlib_Algebra_AddTorsor.534_0.7pEfyZSRLS9mYPD","decl":"theorem AddTorsor.subsingleton_iff (G P : Type*) [AddGroup G] [AddTorsor G P] :\n Subsingleton G ↔ Subsingleton P "}