summaryrefslogtreecommitdiffstats
path: root/subgroupladder.g
blob: 748c1dbabf915e76096690432eb999c3a9e4647c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
YoungGroupFromPartition := function(part)
	local
		i,
		P,
		G,
		grps,
		olds,
		news,
		perms,
		info,
		generators;

	grps := [];
	olds := [];
	news := [];
	perms := [];
	generators := [];

	for i in part do
		G := SymmetricGroup(i);
		Append(generators, GeneratorsOfGroup(G));
		Add(grps, G);
		Add(olds, i);
		Add(news, i);
		Add(perms, ());
	od;

	P := Group(generators);
	info := rec( groups := grps,
	             olds := olds,
				 news := news,
				 perms := perms,
				 embeddings := [],
				 projections := [] );
	SetDirectProductInfo(P, info);

	return P;
end;

FindPos := function(list, x)
	local n, i;
	n := Length(list);
	for i in [1..n] do
		if x in list[i] then
			return i;
		fi;
	od;
end;

SubgroupLadder := function(G)
	local
		orb,
		i,
		k,
		n,
		pair,
		ladder,
		directfactors,
		generators,
		mapping,
		output,
		partition;


	if (not IsPermGroup(G)) then
		ErrorNoReturn("the argument must be a permutation group!\n");
	fi;

	n := LargestMovedPoint(G);

	orb := List(Orbits(G, [1..n]), x -> x);
	SortBy(orb, x->-Length(x));

	output := [];

	partition := List(orb, Length);
	mapping := List([1..n], x -> FindPos(orb, x));
	ladder := [[List(partition), List(mapping)]];


	while (Length(partition) <> 1 or partition[1] < n) do
		if (Length(partition) = 1 and partition[1] < n) then
			mapping[Position(mapping, 0)] := 1;
			partition[1] := partition[1] + 1;
			Add(ladder, [List(partition), List(mapping)]);
		else
			if (partition[2] = 1) then
				Remove(partition, 2);
				for i in [1..n] do
					if (mapping[i]) > 1 then
						mapping[i] := mapping[i] - 1;
					fi;
				od;
				partition[1] := partition[1] + 1;
				Add(ladder, [List(partition), List(mapping)]);
			else
				mapping[Position(mapping, 2)] := Length(partition)+1;
				partition[2] := partition[2] - 1;
				Add(partition, 1);
				Add(ladder, [List(partition), List(mapping)]);

				mapping[Position(mapping, Length(partition))] := 1;
				Remove(partition);
				partition[1] := partition[1] + 1;
				Add(ladder, [List(partition), List(mapping)]);
			fi;
		fi;
	od;

	for pair in ladder do
		k := Length(pair[1]);
		mapping := pair[2];
		Add(output, YoungGroupFromPartition(List([1..k], i -> Filtered([1..n], x -> i = mapping[x]))));
	od;

	return output;
end;

# vim: set noet ts=4: