1-- The subgroup generated by a subset: the intersection of all subgroups2-- containing it, with its universal property3-- Part of Cumulus, the Grace17 mathematics library.4-- Copyright (c) 2026 Grant Passmore.5-- Released under the Apache License 2.0. See LICENSE in the repository root.6-- Authors: Grant Passmore78module Grace.Cumulus.Algebra.Group.Generated9import Normal1011def generatedSubgroup (G S : Set) : Set:=12 { x ∈ G.carrier |∀ H, Subgroup(H, G) → S ⊆ H → x ∈ H }1314theorem generatedSubgroup.subset (G S : Set)15shows generatedSubgroup(G, S) ⊆ G.carrier16proof17intros x hx18have parts := generatedSubgroup.membership.forward with hx19exact parts.left2021theorem generatedSubgroup.contains (G S : Set)22requires bounded : S ⊆ G.carrier23shows S ⊆ generatedSubgroup(G, S)24proof25intros x hx26apply generatedSubgroup.membership.backward27constructor28 . exact bounded with x, hx29 . intros H subgroup included30exact included with x, hx3132theorem generatedSubgroup.least (G S H : Set)33requires subgroup : Subgroup(H, G)34requires included : S ⊆ H35shows generatedSubgroup(G, S) ⊆ H36proof37intros x hx38have parts := generatedSubgroup.membership.forward with hx39exact parts.right with H, subgroup, included4041theorem generatedSubgroup.mono (G S T : Set)42requires included : S ⊆ T43shows generatedSubgroup(G, S) ⊆ generatedSubgroup(G, T)44proof45intros x hx46have parts := generatedSubgroup.membership.forward with hx47apply generatedSubgroup.membership.backward48refine⟨parts.left, ?_⟩49intros H subgroup containsT50have containsS := Subset.transitive with included, containsT51exact parts.right with H, subgroup, containsS5253theorem generatedSubgroup.eq_of_subgroup (G H : Set)54requires subgroup : Subgroup(H, G)55shows generatedSubgroup(G, H) = H56proof57have bounded := Subgroup.subset with subgroup58have includes := generatedSubgroup.contains at G, H with bounded59have least := generatedSubgroup.least with subgroup, (Subset.reflexive at H)60exact Subset.antisymmetric with least, includes6162theorem generatedSubgroup.singleton_mem (G g : Set)63requires bounded : g ∈ G.carrier64shows g ∈ generatedSubgroup(G, {g})65proof66have subset : {g} ⊆ G.carrier67intros x hx68have equal := singleton.membership.forward with hx69 rwa equal70have contains := generatedSubgroup.contains at G, {g} with subset71exact contains with g, singleton.self at g7273section GeneratedLaws74variable (G : Set)75hypothesis group : Group(G)7677theorem generatedSubgroup.subgroup (S : Set)78shows Subgroup(generatedSubgroup(G, S), G)79proof80have unitIn : G.one ∈ generatedSubgroup(G, S)81apply generatedSubgroup.membership.backward82refine⟨(Group.one_mem with group), ?_⟩83intros H subgroup included84exact Subgroup.one_mem with subgroup85apply Subgroup.mk with group, (generatedSubgroup.subset at G, S), unitIn86 . intros x hx y hy87have px := generatedSubgroup.membership.forward with hx88have py := generatedSubgroup.membership.forward with hy89have xIn := px.left90have yIn := py.left91apply generatedSubgroup.membership.backward92refine⟨(Group.mul_mem with*), ?_⟩93intros H subgroup included94have xH := px.right with H, subgroup, included95have yH := py.right with H, subgroup, included96exact Subgroup.mul_mem with*97 . intros x hx98have px := generatedSubgroup.membership.forward with hx99have xIn := px.left100apply generatedSubgroup.membership.backward101refine⟨(Group.inv_mem with*), ?_⟩102intros H subgroup included103have xH := px.right with H, subgroup, included104exact Subgroup.inv_mem with*105106theorem generatedSubgroup.idempotent (S : Set)107shows generatedSubgroup(G, generatedSubgroup(G, S)) = generatedSubgroup(G, S)108proof109have subgroup := generatedSubgroup.subgroup at G, S with group110exact generatedSubgroup.eq_of_subgroup with subgroup111112theorem generatedSubgroup.empty113shows generatedSubgroup(G, ∅) = {G.one}114proof115have trivial := Subgroup.trivial with group116have least := generatedSubgroup.least with trivial, (empty.subset at {G.one})117have subgroup := generatedSubgroup.subgroup at G, ∅with group118have includes := Subgroup.trivial_subset with subgroup119exact Subset.antisymmetric with least, includes120121theorem generatedSubgroup.whole122shows generatedSubgroup(G, G.carrier) = G.carrier123proof124have whole := Subgroup.whole with group125exact generatedSubgroup.eq_of_subgroup with whole126127theorem generatedSubgroup.one_mem (S : Set)128shows G.one ∈ generatedSubgroup(G, S)129proof130have subgroup := generatedSubgroup.subgroup at G, S with group131exact Subgroup.one_mem with subgroup132133theorem generatedSubgroup.pow_mem (g : G) (n : Nat)134shows g ^ n ∈ generatedSubgroup(G, {g})135proof136have subgroup := generatedSubgroup.subgroup at G, {g} with group137have member : g ∈ generatedSubgroup(G, {g}) := generatedSubgroup.singleton_mem with*138exact Subgroup.pow_mem with*139140-- The join of two subgroups is generated by their union.141theorem generatedSubgroup.union_left (H K : Set)142requires subgroupH : Subgroup(H, G)143shows H ⊆ generatedSubgroup(G, H ∪ K)144proof145have mono := generatedSubgroup.mono at G, H, H ∪ K with (union2.subset_left at H, K)146have same := generatedSubgroup.eq_of_subgroup with subgroupH147 rwa same at mono148149theorem generatedSubgroup.union_right (H K : Set)150requires subgroupK : Subgroup(K, G)151shows K ⊆ generatedSubgroup(G, H ∪ K)152proof153have mono := generatedSubgroup.mono at G, K, H ∪ K with (union2.subset_right at H, K)154have same := generatedSubgroup.eq_of_subgroup with subgroupK155 rwa same at mono156157theorem generatedSubgroup.union_least (H K L : Set)158requires subgroupL : Subgroup(L, G)159requires includesH : H ⊆ L160requires includesK : K ⊆ L161shows generatedSubgroup(G, H ∪ K) ⊆ L162proof163have included := union2.subset with includesH, includesK164exact generatedSubgroup.least with subgroupL, included165166end GeneratedLaws167168-- The image of a generated subgroup is generated by the image.169theorem generatedSubgroup.image_subset (f G H S : Set)170requires hom : f : G →* H171requires bounded : S ⊆ G.carrier172shows functionImage(f, generatedSubgroup(G, S), H.carrier) ⊆173 generatedSubgroup(H, functionImage(f, S, H.carrier))174proof175have group := GroupHom.source with hom176have target := GroupHom.target with hom177have targetSubgroup := generatedSubgroup.subgroup at H, functionImage(f, S, H.carrier) with target178have preimage := GroupHom.preimage_subgroup with hom, targetSubgroup179have contains : S ⊆ functionPreimage(f, G.carrier, generatedSubgroup(H, functionImage(f, S, H.carrier)))180intros x hx181have xIn := bounded with x, hx182have fx : f(x) ∈ H.carrier bytypecheck183have imageIn : f(x) ∈ functionImage(f, S, H.carrier)184apply functionImage.membership.backward185refine⟨fx, x, hx, rfl⟩186have generated := generatedSubgroup.contains at H, functionImage(f, S, H.carrier) with (functionImage.subset at f, S, H.carrier)187have value := generated with f(x), imageIn188exact functionPreimage.of_apply with xIn, value189have least := generatedSubgroup.least with preimage, contains190intros y hy191obtain⟨yIn, x, hx, yEq⟩:= functionImage.membership.forward with hy192have inPreimage := least with x, hx193have parts := functionPreimage.membership.forward with inPreimage194rw yEq195exact parts.right196