1-- Left and right cosets of a subgroup: each coset is generated by any of2-- its members, two cosets that share a point coincide, membership through3-- the difference of representatives, and the set of all left cosets4-- Part of Cumulus, the Grace17 mathematics library.5-- Copyright (c) 2026 Grant Passmore.6-- Released under the Apache License 2.0. See LICENSE in the repository root.7-- Authors: Grant Passmore89module Grace.Cumulus.Algebra.Group.Coset10import Subgroup1112-- The left coset g * H and the right coset H * g of a subset H of G.13def leftCoset (G g H : Set) : Set:= { y ∈ G.carrier |∃ h ∈ H, y = G.mul(g, h) }14def rightCoset (G g H : Set) : Set:= { y ∈ G.carrier |∃ h ∈ H, y = G.mul(h, g) }1516-- The set of all left cosets of H.17def leftCosets (G H : Set) : Set:=18 { C ∈𝒫(G.carrier) |∃ g ∈ G.carrier, C = leftCoset(G, g, H) }1920-- The left coset leftCoset(G, g, H) is written g • H wherever a hypothesis21-- in scope supplies the group.22notationinfixr73"•"=> leftCoset(G, _, _) viahypothesis Group(G) for G.carrier23notationinfixr73"•"=> leftCoset(G, _, _) viahypothesis Subgroup(H, G) for G.carrier2425theorem leftCoset.subset (G g H : Set)26shows leftCoset(G, g, H) ⊆ G.carrier27proof28intros y hy29have parts := leftCoset.membership.forward with hy30exact parts.left3132theorem rightCoset.subset (G g H : Set)33shows rightCoset(G, g, H) ⊆ G.carrier34proof35intros y hy36have parts := rightCoset.membership.forward with hy37exact parts.left3839theorem leftCosets.subset_powerset (G H : Set)40shows leftCosets(G, H) ⊆𝒫(G.carrier)41proof42intros C hC43have parts := leftCosets.membership.forward with hC44exact parts.left4546theorem leftCosets.coset_member (G H g : Set)47requires hg : g ∈ G.carrier48shows leftCoset(G, g, H) ∈ leftCosets(G, H)49proof50have subset := leftCoset.subset at G, g, H51have bounded := powerset.membership_iff.backward with subset52exact leftCosets.membership.backward with⟨bounded, g, hg, rfl⟩5354section Cosets55variable (G H : Set)56hypothesis group : Group(G)57hypothesis subgroup : Subgroup(H, G)5859theorem leftCoset.mul_mem (g : G) (h : H)60shows g * h ∈ g • H61proof62have product : g * h ∈ G bytypecheck63have hIn : h ∈ H byassumption64exact leftCoset.membership.backward with⟨product, h, hIn, rfl⟩6566theorem rightCoset.mul_mem (g : G) (h : H)67shows h * g ∈ rightCoset(G, g, H)68proof69have product : h * g ∈ G bytypecheck70have hIn : h ∈ H byassumption71exact rightCoset.membership.backward with⟨product, h, hIn, rfl⟩7273theorem leftCoset.self (g : G)74shows g ∈ g • H75proof76have product : g * G.one ∈ g • H := leftCoset.mul_mem with*77 rwa mul_one at product7879theorem rightCoset.self (g : G)80shows g ∈ rightCoset(G, g, H)81proof82have product : G.one * g ∈ rightCoset(G, g, H) := rightCoset.mul_mem with*83 rwa one_mul at product8485-- Membership in a coset through the difference of representatives.86theorem leftCoset.mem_iff (x y : G)87shows y ∈ x • H ↔ x⁻¹ * y ∈ H88proof89constructor90 . intro member91obtain⟨yIn, h, hH, yEq⟩:= leftCoset.membership.forward with member92rw [yEq, inv_mul_cancel_left]93exact hH94 . intro member95have cancel : x * (x⁻¹ * y) = y := mul_inv_cancel_left with*96have yIn : y ∈ G byassumption97apply leftCoset.membership.backward98refine⟨yIn, x⁻¹ * y, member, ?_⟩99 symm100exact cancel101102theorem rightCoset.mem_iff (x y : G)103shows y ∈ rightCoset(G, x, H) ↔ y * x⁻¹ ∈ H104proof105constructor106 . intro member107obtain⟨yIn, h, hH, yEq⟩:= rightCoset.membership.forward with member108rw [yEq, mul_inv_cancel_right]109exact hH110 . intro member111have cancel : y * x⁻¹ * x = y := inv_mul_cancel_right with*112have yIn : y ∈ G byassumption113apply rightCoset.membership.backward114refine⟨yIn, y * x⁻¹, member, ?_⟩115 symm116exact cancel117118-- Any member of a coset generates it.119theorem leftCoset.of_member (g : G) (y : Set)120requires hy : y ∈ g • H121shows y • H = g • H122proof123obtain⟨yIn, h0, h0In, yEq⟩:= leftCoset.membership.forward with hy124ext z125constructor126 . intro hz127obtain⟨zIn, h, hH, zEq⟩:= leftCoset.membership.forward with hz128have product : h0 * h ∈ H := Subgroup.mul_mem with*129apply leftCoset.membership.backward130refine⟨zIn, h0 * h, product, ?_⟩131rw [zEq, yEq, mul_assoc]132rfl133 . intro hz134obtain⟨zIn, h, hH, zEq⟩:= leftCoset.membership.forward with hz135have product : h0⁻¹ * h ∈ H := Subgroup.mul_mem with*136apply leftCoset.membership.backward137refine⟨zIn, h0⁻¹ * h, product, ?_⟩138rw [zEq, yEq, mul_assoc, mul_inv_cancel_left]139rfl140141theorem leftCoset.eq_of_common (g k : G) (z : Set)142requires hz : z ∈ g • H143requires hz2 : z ∈ k • H144shows g • H = k • H145proof146have first : z • H = g • H := leftCoset.of_member with*147have second : z • H = k • H := leftCoset.of_member with*148 rwa first at second149150theorem leftCoset.eq_iff (x y : G)151shows x • H = y • H ↔ x⁻¹ * y ∈ H152proof153have criterion : y ∈ x • H ↔ x⁻¹ * y ∈ H := leftCoset.mem_iff with*154have selfY : y ∈ y • H := leftCoset.self with*155constructor156 . intro equal157have member : y ∈ x • H by rwa equal158exact criterion.forward with member159 . intro member160have inside := criterion.backward with member161have equal : y • H = x • H := leftCoset.of_member with*162 symm163exact equal164165theorem leftCoset.one166shows G.one • H = H167proof168ext y169constructor170 . intro hy171obtain⟨yIn, h, hH, yEq⟩:= leftCoset.membership.forward with hy172rw [yEq, one_mul]173exact hH174 . intro hy175have yIn : y ∈ G := Subgroup.mem_carrier with*176have identity : G.one * y = y := one_mul with*177apply leftCoset.membership.backward178refine⟨yIn, y, hy, ?_⟩179 symm180exact identity181182theorem leftCoset.eq_self_iff (x : G)183shows x • H = H ↔ x ∈ H184proof185have criterion : x • H = G.one • H ↔ x⁻¹ * G.one ∈ H :=186 leftCoset.eq_iff with*187have inverseCriterion : x⁻¹ ∈ H ↔ x ∈ H := Subgroup.inv_mem_iff with*188rw [leftCoset.one, mul_one] at criterion189constructor190 . intro equal191have member := criterion.forward with equal192exact inverseCriterion.forward with member193 . intro member194have inverse := inverseCriterion.backward with member195exact criterion.backward with inverse196197theorem leftCosets.representative (C : Set)198requires hC : C ∈ leftCosets(G, H)199shows∃ g ∈ G, g ∈ C200proof201obtain⟨bound, g, hg, same⟩:= leftCosets.membership.forward with hC202haveself : g ∈ g • H := leftCoset.self with*203witness g204constructor205 . exact hg206 . rw same207exactself208209end Cosets210