1-- Subgroups: subsets of a group containing the unit and closed under the2-- operation and inverses, the subgroups every group has, intersections,3-- and the one-step criterion4-- 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.Subgroup10import Basic11import Set.Core1213-- Subgroup(H, G): H is a subgroup of the group G. Under this hypothesis a14-- binder (h : H) is a set variable with h ∈ H, and h * k and h⁻¹ are the15-- operation and inverse of G.16predicate Subgroup (H G : Set) :=17 Group(G) ∧ H ⊆ G.carrier ∧ G.one ∈ H ∧18 (∀ x y ∈ H, x * y ∈ H) ∧ (∀ x ∈ H, x⁻¹ ∈ H)1920notationinfixl70"*"=> call2(G.mul, _, _) viahypothesis Subgroup(H, G) for H21notationpostfix90"⁻¹"=>apply(G.inv, _) viahypothesis Subgroup(H, G) for H2223theorem Subgroup.group (H G : Set)24requires subgroup : Subgroup(H, G)25shows Group(G)26proof27obtain⟨group, rest⟩:= subgroup28exact group2930section SubgroupLaws31variable (G H : Set)32hypothesis subgroup : Subgroup(H, G)3334theorem Subgroup.subset35shows H ⊆ G.carrier36proof37obtain⟨g, bounded, rest⟩:= subgroup38exact bounded3940-- Closure: the carrier membership of a subgroup element is a typing rule,41-- and the subgroup membership of a product, the unit, and an inverse are42-- instances, so each is synthesized.43theorem Subgroup.mem_carrier (h : H)44shows h ∈ G.carrier45proof46have bounded := Subgroup.subset with subgroup47have hIn : h ∈ H byassumption48exact bounded with h, hIn4950instance Subgroup.one_mem51shows G.one ∈ H52proof53obtain⟨g, bounded, unitIn, rest⟩:= subgroup54exact unitIn5556instance Subgroup.mul_mem (h k : H)57shows h * k ∈ H58proof59obtain⟨g, bounded, unitIn, closed, inverses⟩:= subgroup60have hIn : h ∈ H byassumption61have kIn : k ∈ H byassumption62exact closed with h, hIn, k, kIn6364instance Subgroup.inv_mem (h : H)65shows h⁻¹ ∈ H66proof67obtain⟨g, bounded, unitIn, closed, inverses⟩:= subgroup68have hIn : h ∈ H byassumption69exact inverses with h, hIn7071theorem Subgroup.nonempty72shows Nonempty(H)73proof74have unitIn : G.one ∈ H := Subgroup.one_mem with*75exact⟨G.one, unitIn⟩7677theorem Subgroup.trivial_subset78shows {G.one} ⊆ H79proof80intros x hx81have equal := singleton.membership.forward with hx82rw equal83exact Subgroup.one_mem with*8485theorem Subgroup.eq_trivial_iff86shows H = {G.one} ↔∀ x ∈ H, x = G.one87proof88have trivialSubset := Subgroup.trivial_subset with subgroup89constructor90 . intros equal x hx91rw equal at hx92exact singleton.membership.forward with hx93 . intro trivial94apply Subset.antisymmetric95 . intros x hx96have equal := trivial with x, hx97rw equal98exact singleton.self99 . exact trivialSubset100101end SubgroupLaws102103section SubgroupCancellation104variable (G H : Set)105hypothesis group : Group(G)106hypothesis subgroup : Subgroup(H, G)107108-- Membership in a subgroup is unchanged by a factor from the subgroup.109theorem Subgroup.mul_mem_cancel_left (h : H) (x : G)110shows h * x ∈ H ↔ x ∈ H111proof112constructor113 . intro member114have product : h⁻¹ * (h * x) ∈ H := Subgroup.mul_mem with*115 rwa inv_mul_cancel_left at product116 . intro member117exact Subgroup.mul_mem with*118119theorem Subgroup.mul_mem_cancel_right (h : H) (x : G)120shows x * h ∈ H ↔ x ∈ H121proof122constructor123 . intro member124have product : x * h * h⁻¹ ∈ H := Subgroup.mul_mem with*125 rwa mul_inv_cancel_right at product126 . intro member127exact Subgroup.mul_mem with*128129theorem Subgroup.inv_mem_iff (x : G)130shows x⁻¹ ∈ H ↔ x ∈ H131proof132constructor133 . intro member134have twice : (x⁻¹)⁻¹ ∈ H := Subgroup.inv_mem with*135 rwa inv_inv at twice136 . intro member137exact Subgroup.inv_mem with*138139end SubgroupCancellation140141section SubgroupConstructions142variable (G : Set)143hypothesis group : Group(G)144145-- The constructor.146theorem Subgroup.mk (H : Set)147requires bounded : H ⊆ G148requires unitIn : G.one ∈ H149requires closed : ∀ x y ∈ H, x * y ∈ H150requires inverses : ∀ x ∈ H, x⁻¹ ∈ H151shows Subgroup(H, G)152proof153unfold Subgroup154refine⟨group, bounded, unitIn, closed, inverses⟩155156-- The subgroups every group has.157theorem Subgroup.whole158shows Subgroup(G.carrier, G)159proof160have reflexive := Subset.reflexive at G.carrier161have unitIn : G.one ∈ G := Group.one_mem with*162apply Subgroup.mk with group, reflexive, unitIn163 . intros x hx y hy164exact Group.mul_mem with*165 . intros x hx166exact Group.inv_mem with*167168theorem Subgroup.trivial169shows Subgroup({G.one}, G)170proof171have unitIn : G.one ∈ G := Group.one_mem with*172have selfIn := singleton.self at G.one173have bounded : {G.one} ⊆ G174intros x hx175have equal := singleton.membership.forward with hx176 rwa equal177apply Subgroup.mk with group, bounded, selfIn178 . intros x hx y hy179have ex := singleton.membership.forward with hx180have ey := singleton.membership.forward with hy181rw [ex, ey, one_mul]182exact selfIn183 . intros x hx184have ex := singleton.membership.forward with hx185rw [ex, inv_one]186exact selfIn187188theorem Subgroup.intersection (H K : Set)189requires subgroupH : Subgroup(H, G)190requires subgroupK : Subgroup(K, G)191shows Subgroup(H ∩ K, G)192proof193have bounded := Subset.transitive with (intersection.subset_left at H, K), (Subgroup.subset with subgroupH)194have unitIn : G.one ∈ H ∩ K := intersection.membership.backward with⟨(Subgroup.one_mem with subgroupH), (Subgroup.one_mem with subgroupK)⟩195apply Subgroup.mk with group, bounded, unitIn196 . intros x hx y hy197obtain⟨xH, xK⟩:= intersection.membership.forward with hx198obtain⟨yH, yK⟩:= intersection.membership.forward with hy199exact intersection.membership.backward with⟨(Subgroup.mul_mem with*), (Subgroup.mul_mem with*)⟩200 . intros x hx201obtain⟨xH, xK⟩:= intersection.membership.forward with hx202exact intersection.membership.backward with⟨(Subgroup.inv_mem with*), (Subgroup.inv_mem with*)⟩203204-- The one-step subgroup criterion: a nonempty subset closed under205-- x, y ↦ x * y⁻¹ is a subgroup.206theorem Subgroup.of_mul_inv (H : Set)207requires bounded : H ⊆ G208requires inhabited : Nonempty(H)209requires closed : ∀ x y ∈ H, x * y⁻¹ ∈ H210shows Subgroup(H, G)211proof212obtain⟨h, hH⟩:= inhabited213have hIn := bounded with h, hH214have unitIn : G.one ∈ H215have product := closed with h, hH, h, hH216 rwa Group.mul_inv at product217have inverses : ∀ x ∈ H, x⁻¹ ∈ H218intros x hx219have xIn := bounded with x, hx220have product := closed with G.one, unitIn, x, hx221 rwa one_mul at product222apply Subgroup.mk with group, bounded, unitIn223 . intros x hx y hy224have yIn := bounded with y, hy225have invY := inverses with y, hy226have product := closed with x, hx, y⁻¹, invY227 rwa inv_inv at product228 . exact inverses229230end SubgroupConstructions231