# Library mathcomp.solvable.extremal

(* (c) Copyright 2006-2016 Microsoft Corporation and Inria.
Distributed under the terms of CeCILL-B.                                  *)

From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq div.
From mathcomp Require Import choice fintype bigop finset prime binomial.
From mathcomp Require Import fingroup morphism perm automorphism presentation.
From mathcomp Require Import quotient action commutator gproduct gfunctor.
From mathcomp Require Import ssralg finalg zmodp cyclic pgroup center gseries.
From mathcomp Require Import nilpotent sylow abelian finmodule matrix maximal.

This file contains the definition and properties of extremal p-groups; it covers and is mostly based on the beginning of Aschbacher, section 23, as well as several exercises of this section. We define canonical representatives for the group classes that cover the extremal p-groups (non-abelian p-groups with a cyclic maximal subgroup): 'Mod_m == the modular group of order m, for m = p ^ n, p prime and n >= 3. 'D_m == the dihedral group of order m, for m = 2n >= 4. 'Q_m == the generalized quaternion group of order m, for m = 2 ^ n >= 8. 'SD_m == the semi-dihedral group of order m, for m = 2 ^ n >= 16. In each case the notation is defined in the %type, %g and %G scopes, where it denotes a finGroupType, a full gset and the full group for that type. However each notation is only meaningful under the given conditions, in 'D_m is only an extremal group for m = 2 ^ n >= 8, and 'D_8 = 'Mod_8 (they are, in fact, beta-convertible). We also define extremal_generators G p n (x, y) <-> G has order p ^ n, x in G has order p ^ n.-1, and y is in G \ < [x]>: thus < [x]> has index p in G, so if p is prime, < [x]> is maximal in G, G is generated by x and y, and G is extremal or abelian. extremal_class G == the class of extremal groups G belongs to: one of ModularGroup, Dihedral, Quaternion, SemiDihedral or NotExtremal. extremal2 G <=> extremal_class G is one of Dihedral, Quaternion, or SemiDihedral; this allows 'D_4 and 'D_8, but excludes 'Mod(2^n) for n > 3. modular_group_generators p n (x, y) <-> y has order p and acts on x via x ^ y = x ^+ (p ^ n.-2).+1. This is the complement to extremal_generators G p n (x, y) for modular groups. We provide cardinality, presentation, generator and structure theorems for each class of extremal group. The extremal_generators predicate is used to supply structure theorems with all the required data about G; this is completed by an isomorphism assumption (e.g., G \isog 'D(2 ^ n)), and sometimes other properties (e.g., # [y] == 2 in the semidihedral case). The generators assumption can be deduced generically from the isomorphism assumption, or it can be proved manually for a specific choice of x and y. The extremal_class function is used to formulate synthetic theorems that cover several classes of extremal groups (e.g., Aschbacher ex. 8.3).

Set Implicit Arguments.

Import GroupScope GRing.Theory.

Reserved Notation "''Mod_' m" (at level 8, m at level 2, format "''Mod_' m").
Reserved Notation "''D_' m" (at level 8, m at level 2, format "''D_' m").
Reserved Notation "''SD_' m" (at level 8, m at level 2, format "''SD_' m").
Reserved Notation "''Q_' m" (at level 8, m at level 2, format "''Q_' m").

Module Extremal.

Section Construction.

Variables q p e : nat.
Construct the semi-direct product of 'Z_q by 'Z_p with 1%R ^ 1%R = e%R, if possible, i.e., if p, q > 1 and there is s \in Aut 'Z_p such that # [s] %| p and s 1%R = 1%R ^+ e.

Let a : 'Z_p := Zp1.
Let b : 'Z_q := Zp1.

Definition aut_of :=
odflt 1 [pick s in Aut B | p > 1 & (#[s] %| p) && (s b == b ^+ e)].

Lemma aut_dvdn : #[aut_of] %| #[a].

Definition act_morphism := eltm_morphism aut_dvdn.

Definition base_act := ([Aut B] \o act_morphism)%gact.

Lemma act_dom : <[a]> \subset act_dom base_act.

Definition gact := (base_act \ act_dom)%gact.
Fact gtype_key : unit.
Definition gtype := locked_with gtype_key (sdprod_groupType gact).

Hypotheses (p_gt1 : p > 1) (q_gt1 : q > 1).

Lemma card : #|[set: gtype]| = (p × q)%N.

Lemma Grp : ( s, [/\ s \in Aut B, #[s] %| p & s b = b ^+ e])
[set: gtype] \isog Grp (x : y : (x ^+ q, y ^+ p, x ^ y = x ^+ e)).

End Construction.

End Extremal.

Section SpecializeExtremals.

Import Extremal.

Variable m : nat.
Let p := pdiv m.
Let q := m %/ p.

Definition modular_gtype := gtype q p (q %/ p).+1.
Definition dihedral_gtype := gtype q 2 q.-1.
Definition semidihedral_gtype := gtype q 2 (q %/ p).-1.
Definition quaternion_kernel :=
<<[set u | u ^+ 2 == 1] :\: [set u ^+ 2 | u in [set: gtype q 4 q.-1]]>>.
Definition quaternion_gtype :=
locked_with gtype_key (coset_groupType quaternion_kernel).

End SpecializeExtremals.

Notation "''Mod_' m" := (modular_gtype m) : type_scope.
Notation "''Mod_' m" := [set: gsort 'Mod_m] : group_scope.
Notation "''Mod_' m" := [set: gsort 'Mod_m]%G : Group_scope.

Notation "''D_' m" := (dihedral_gtype m) : type_scope.
Notation "''D_' m" := [set: gsort 'D_m] : group_scope.
Notation "''D_' m" := [set: gsort 'D_m]%G : Group_scope.

Notation "''SD_' m" := (semidihedral_gtype m) : type_scope.
Notation "''SD_' m" := [set: gsort 'SD_m] : group_scope.
Notation "''SD_' m" := [set: gsort 'SD_m]%G : Group_scope.

Notation "''Q_' m" := (quaternion_gtype m) : type_scope.
Notation "''Q_' m" := [set: gsort 'Q_m] : group_scope.
Notation "''Q_' m" := [set: gsort 'Q_m]%G : Group_scope.

Section ExtremalTheory.

Implicit Types (gT : finGroupType) (p q m n : nat).

This is Aschbacher (23.3), with the isomorphism made explicit, and a slightly reworked case analysis on the prime and exponent; in particular the inverting involution is available for all non-trivial p-cycles.
Lemma cyclic_pgroup_Aut_structure gT p (G : {group gT}) :
p.-group G cyclic G G :!=: 1
let q := #|G| in let n := (logn p q).-1 in
let A := Aut G in let P := 'O_p(A) in let F := 'O_p^'(A) in
m : {perm gT} 'Z_q,
[/\ [/\ {in A & G, a x, x ^+ m a = a x},
m 1 = 1%R {in A &, {morph m : a b / a × b >-> (a × b)%R}},
{in A &, injective m} image m A =i GRing.unit,
k, {in A, {morph m : a / a ^+ k >-> (a ^+ k)%R}}
& {in A, {morph m : a / a^-1 >-> (a^-1)%R}}],
[/\ abelian A, cyclic F, #|F| = p.-1
& [faithful F, on 'Ohm_1(G) | [Aut G]]]
& if n == 0 then A = F else
t, [/\ t \in A, #[t] = 2, m t = (- 1)%R
& if odd p then
[/\ cyclic A cyclic P,
s, [/\ s \in A, #[s] = (p ^ n)%N, m s = p.+1%:R & P = <[s]>]
& s0, [/\ s0 \in A, #[s0] = p, m s0 = (p ^ n).+1%:R
& 'Ohm_1(P) = <[s0]>]]
else if n == 1%N then A = <[t]>
else s,
[/\ s \in A, #[s] = (2 ^ n.-1)%N, m s = 5%:R, <[s]> \x <[t]> = A
& s0, [/\ s0 \in A, #[s0] = 2, m s0 = (2 ^ n).+1%:R,
m (s0 × t) = (2 ^ n).-1%:R & 'Ohm_1(<[s]>) = <[s0]>]]]].

Definition extremal_generators gT (A : {set gT}) p n xy :=
let: (x, y) := xy in
[/\ #|A| = (p ^ n)%N, x \in A, #[x] = (p ^ n.-1)%N & y \in A :\: <[x]>].

Lemma extremal_generators_facts gT (G : {group gT}) p n x y :
prime p extremal_generators G p n (x, y)
[/\ p.-group G, maximal <[x]> G, <[x]> <| G,
<[x]> × <[y]> = G & <[y]> \subset 'N(<[x]>)].

Section ModularGroup.

Variables p n : nat.
Let m := (p ^ n)%N.
Let q := (p ^ n.-1)%N.
Let r := (p ^ n.-2)%N.

Hypotheses (p_pr : prime p) (n_gt2 : n > 2).
Let p_gt1 := prime_gt1 p_pr.
Let p_gt0 := ltnW p_gt1.
Let def_n := esym (subnKC n_gt2).
Let def_p : pdiv m = p.
Let def_q : m %/ p = q.
Let def_r : q %/ p = r.
Let ltqm : q < m.
Let ltrq : r < q.
Let r_gt0 : 0 < r.
Let q_gt1 : q > 1.

Lemma card_modular_group : #|'Mod_(p ^ n)| = (p ^ n)%N.

Lemma Grp_modular_group :
'Mod_(p ^ n) \isog Grp (x : y : (x ^+ q, y ^+ p, x ^ y = x ^+ r.+1)).

Definition modular_group_generators gT (xy : gT × gT) :=
let: (x, y) := xy in #[y] = p x ^ y = x ^+ r.+1.

Lemma generators_modular_group gT (G : {group gT}) :
G \isog 'Mod_m
exists2 xy, extremal_generators G p n xy & modular_group_generators xy.

This is an adaptation of Aschbacher, exercise 8.2:
• We allow an alternative to the # [x] = p ^ n.-1 condition that meshes better with the modular_Grp lemma above.
• We state explicitly some "obvious" properties of G, namely that G is the non-abelian semi-direct product < [x]> ><| < [y]> and that y ^+ j acts on < [x]> via z |-> z ^+ (j * p ^ n.-2).+1
• We also give the values of the 'Mho^k(G).
• We corrected a pair of typos.
Basic properties of dihedral groups; these will be refined for dihedral 2-groups in the section on extremal 2-groups.
This is Aschbacher (23.4).
This is Aschbacher (23.5)
This is Aschbacher, exercise (8.4)
Replacement for Section 4 proof.
This is the second part of Aschbacher, exercise (8.4).
This is Aschbacher (23.9)