Subset of a group that forms a group itself
In group theory, a branch of mathematics, a subset of a group G is a subgroup of G if the members of that subset form a group with respect to the group operation in G. 
Formally, given a group G under a binary operation ∗, a subset H of G is called a subgroup of G if H also forms a group under the operation ∗. More precisely, H is a subgroup of G if the restriction of ∗ to "H" × "H" is a group operation on H. This is often denoted "H" ≤ "G", read as "H is a subgroup of G".
The trivial subgroup of any group is the subgroup {"e"} consisting of just the identity element.
A proper subgroup of a group G is a subgroup H which is a proper subset of G (that is, "H" ≠ "G"). This is often represented notationally by "H" ; "G", read as "H is a proper subgroup of G". Some authors also exclude the trivial group from being proper (that is, "H" ≠ {"e"}​).
If H is a subgroup of G, then G is sometimes called an overgroup of H.
The same definitions apply more generally when G is an arbitrary semigroup, but this article will only deal with subgroups of groups.
Subgroup tests.
Suppose that G is a group, and H is a subset of G. For now, assume that the group operation of G is written multiplicatively, denoted by juxtaposition.
If the group operation is instead denoted by addition, then "closed under products" should be replaced by "closed under addition", which is the condition that for every a and b in H, the sum "a" + "b" is in H, and "closed under inverses" should be edited to say that for every a in H, the inverse −"a" is in H.
Cosets and Lagrange's theorem.
Given a subgroup H and some a in G, we define the left coset "aH" = {"ah" : "h" in "H"}. Because a is invertible, the map φ : "H" → "aH" given by φ("h") = "ah" is a bijection. Furthermore, every element of G is contained in precisely one left coset of H; the left cosets are the equivalence classes corresponding to the equivalence relation "a"1 ~ "a"2 if and only if &amp;NoBreak;&amp;NoBreak; is in H. The number of left cosets of H is called the index of H in G and is denoted by ["G" : "H"].
Lagrange's theorem states that for a finite group G and a subgroup H, 
 formula_1
where and denote the orders of G and H, respectively. In particular, the order of every subgroup of G (and the order of every element of G) must be a divisor of .
Right cosets are defined analogously: "Ha" = {"ha" : "h" in "H"}. They are also the equivalence classes for a suitable equivalence relation and their number is equal to ["G" : "H"].
If "aH" = "Ha" for every a in G, then H is said to be a normal subgroup. Every subgroup of index 2 is normal: the left cosets, and also the right cosets, are simply the subgroup and its complement. More generally, if p is the lowest prime dividing the order of a finite group G, then any subgroup of index p (if such exists) is normal.
Example: Subgroups of Z8.
Let G be the cyclic group Z8 whose elements are
formula_2
and whose group operation is addition modulo 8. Its Cayley table is
This group has two nontrivial subgroups: and , where J is also a subgroup of H. The Cayley table for H is the top-left quadrant of the Cayley table for G; The Cayley table for J is the top-left quadrant of the Cayley table for H. The group G is cyclic, and so are its subgroups. In general, subgroups of cyclic groups are also cyclic.
Example: Subgroups of S4.
S4 is the symmetric group whose elements correspond to the permutations of 4 elements. ;br ;
Below are all its subgroups, ordered by cardinality. ;br ;
Each group is represented by its Cayley table.
24 elements.
Like each group, S4 is a subgroup of itself.
12 elements.
The alternating group contains only the even permutations. ;br ;
It is one of the two nontrivial proper normal subgroups of S4. 
2 elements.
Each permutation p of order 2 generates a subgroup {1, "p"}.
These are the permutations that have only 2-cycles: ;br ;
1 element.
The trivial subgroup is the unique subgroup of order 1.