public void GapPerm_Compose_Identity() { var f = new GapPerm(); var g = new GapPerm(0, 2, 1); Assert.AreEqual(g.Compose(f), g); }
static void Main(string[] args) { // Find the order of each of the following permutations int proc(GapPerm a) { var result = new GapPerm(); foreach (var n in Enumerable.Range(1, 100)) { result = result.Compose(a); WriteLine("a^{0} = {1}", n, result); if (result == new GapPerm(0)) { return(n); } } throw new Exception(); } proc(new GapPerm("(12)(345)")).Display(); WriteLine(); proc(new GapPerm("(12)(3456)")).Display(); WriteLine(); proc(new GapPerm("(1234)(56789)")).Display(); WriteLine(); }
public void GapPerm_Identity_Compose() { var f = new GapPerm(); var g = new GapPerm(0, 2, 1); Assert.AreEqual(f.Compose(g), g); }
static void Main(string[] args) { var ε = new GapPerm(0); var α = new GapPerm("(12)(34)(56)"); var β = new GapPerm("(23)"); var αβ = α.Compose(β); var βα = β.Compose(α); var αβα = α.Compose(β.Compose(α)); var βαβ = β.Compose(α.Compose(β)); var αβαβ = α.Compose(β.Compose(α.Compose(β))); string lookup(GapPerm f) { var items = new[] { (ε, "ε"), (α, "α"), (β, "β"), (αβ, "αβ"), (βα, "βα"), (αβα, "αβα"), (βαβ, "βαβ"), (αβαβ, "αβαβ") }; return(items.First(elt => f == elt.Item1).Item2); } var G = new Group <GapPerm> { Identity = ε, Set = new MathSet <GapPerm>(new[] { ε, α, β, αβ, βα, αβα, βαβ, αβαβ }), Op = (a, b) => a.Compose(b), Lookup = lookup }; foreach (var elt in G.Set) { WriteLine("{0,-4}: {1}", lookup(elt), elt); } WriteLine(); G.ShowInverses(); G.ShowOperationTableColored(); WriteLine(); MathSet <int> orbit(Group <GapPerm> grp, int u) => grp.Set.ConvertAll(elt => elt.Apply(u)); WriteLine("orbit of 1: {0}", orbit(G, 1)); WriteLine("orbit of 2: {0}", orbit(G, 2)); WriteLine("orbit of 3: {0}", orbit(G, 3)); WriteLine("orbit of 5: {0}", orbit(G, 5)); WriteLine(); MathSet <GapPerm> stabilizer(Group <GapPerm> grp, int u) => grp.Set.Where(elt => elt.Apply(u) == u).ToMathSet(); WriteLine("stabilizer of 1: {0}", stabilizer(G, 1).Select(lookup).ToMathSet()); WriteLine("stabilizer of 2: {0}", stabilizer(G, 2).Select(lookup).ToMathSet()); WriteLine("stabilizer of 4: {0}", stabilizer(G, 4).Select(lookup).ToMathSet()); WriteLine("stabilizer of 5: {0}", stabilizer(G, 5).Select(lookup).ToMathSet()); }
static int order(GapPerm a) { var result = new GapPerm(); foreach (var n in Enumerable.Range(1, 100)) { result = result.Compose(a); if (result == new GapPerm(0)) { return(n); } } throw new Exception(); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; var ε = new GapPerm(0); // new FunctionIntInt((1, 1), (2, 2), (3, 3)); var α = new GapPerm("(23)"); // new FunctionIntInt((1, 1), (2, 3), (3, 2)); var β = new GapPerm("(132)"); // new FunctionIntInt((1, 3), (2, 1), (3, 2)); var γ = new GapPerm("(12)"); // new FunctionIntInt((1, 2), (2, 1), (3, 3)); var σ = new GapPerm("(123)"); // new FunctionIntInt((1, 2), (2, 3), (3, 1)); var κ = new GapPerm("(13)"); // new FunctionIntInt((1, 3), (2, 2), (3, 1)); string lookup(GapPerm f) { var items = new[] { (ε, "ε"), (α, "α"), (β, "β"), (γ, "γ"), (σ, "σ"), (κ, "κ") }; return(items.First(elt => f == elt.Item1).Item2); } var S3 = new Group <GapPerm> { Identity = ε, Set = new[] { ε, α, β, γ, σ, κ }.ToMathSet(), Op = (a, b) => a.Compose(b), Lookup = lookup }; // var S3 = new Group(new[] { ε, α, β, γ, σ, κ }, (a, b) => a.Compose(b), lookup) Write("S3 "); S3.ShowOperationTableColored(); WriteLine(); // consider - G.IsSubgroup(elts) var H = S3.Subgroup(new[] { ε, β, σ }); WriteLine($"H: { H.Set.ConvertAll(lookup) }\n"); foreach (var elt in S3.CosetGrouping(H, "H")) { WriteLine("{0} {1}", elt.ToMathSet(), elt.Key.ConvertAll(lookup)); } WriteLine(); Write("Z10/{ ε, β, σ } "); S3.QuotientGroup(H, coset => new[] { ε, α, β, γ, σ, κ }.ToList().IndexOf(coset.Element).ToString()).ShowOperationTableColored(); }
static void Main(string[] args) { var R0 = new GapPerm(0); // R0 var R1 = new GapPerm("(123456)"); // R60 var R2 = new GapPerm("(135)(246)"); // R120 var R3 = new GapPerm("(14)(25)(36)"); // R180 var R4 = new GapPerm("(153)(264)"); // R240 var R5 = new GapPerm("(165432)"); // R300 var R6 = new GapPerm("(15)(24)"); // FA var R7 = new GapPerm("(16)(25)(34)"); // FB var R8 = new GapPerm("(26)(35)"); // FC var R9 = new GapPerm("(12)(36)(45)"); // FD var R10 = new GapPerm("(13)(46)"); // FE var R11 = new GapPerm("(14)(23)(56)"); // FF string lookup(GapPerm f) { var items = new[] { (R0, "R0"), (R1, "R1"), (R2, "R2"), (R3, "R3"), (R4, "R4"), (R5, "R5"), (R6, "R6"), (R7, "R7"), (R8, "R8"), (R9, "R9"), (R10, "R10"), (R11, "R11") }; return(items.First(elt => f == elt.Item1).Item2); } var D6 = new Group <GapPerm> { Identity = R0, Set = new MathSet <GapPerm>(new[] { R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11 }), Op = (a, b) => a.Compose(b), Lookup = lookup }; D6.ShowOperationTableColored(); }
static void Main(string[] args) { // A C B // \ | / // 1---2 // | | - D // 4---3 var R0 = new GapPerm(0); // R0 var R1 = new GapPerm("(1234)"); // R90 var R2 = new GapPerm("(13)(24)"); // R180 var R3 = new GapPerm("(4321)"); // R270 var R4 = new GapPerm("(24)"); // FA var R5 = new GapPerm("(13)"); // FB var R6 = new GapPerm("(12)(34)"); // FC var R7 = new GapPerm("(14)(23)"); // FD string lookup(GapPerm f) { var items = new[] { (R0, "R0"), (R1, "R1"), (R2, "R2"), (R3, "R3"), (R4, "R4"), (R5, "R5"), (R6, "R6"), (R7, "R7") }; return(items.First(elt => f == elt.Item1).Item2); } var D4 = new Group <GapPerm> { Identity = R0, Set = new MathSet <GapPerm>(new[] { R0, R1, R2, R3, R4, R5, R6, R7 }), Op = (a, b) => a.Compose(b), Lookup = lookup }; WriteLine("subgroups : {0}", D4.Subgroups()); WriteLine("normal subgroups: {0}", D4.NormalSubgroups()); }
static void Main(string[] args) { { var permutation = new GapPerm(0, 4, 9, 2, 5, 1, 7, 6, 8, 3); permutation.DisplayAsFunction(); permutation.ToDisjointCycles().Display(); WriteLine(); } { var permutation = new GapPerm(0, 7, 4, 9, 2, 3, 8, 1, 6, 5); permutation.DisplayAsFunction(); permutation.ToDisjointCycles().Display(); WriteLine(); } { var permutation = new GapPerm(0, 7, 9, 5, 3, 1, 2, 4, 8, 6); permutation.DisplayAsFunction(); permutation.ToDisjointCycles().Display(); WriteLine(); } { var permutation = new GapPerm(0, 9, 8, 7, 4, 3, 6, 5, 1, 2); permutation.DisplayAsFunction(); permutation.ToDisjointCycles().Display(); WriteLine(); } }
static void Main(string[] args) { var perm = new GapPerm("(123)"); { var f = new GapPerm("(23)"); var g = new GapPerm("(56)"); var h = f.Compose(g); } { var f = new GapPerm("(234)"); var g = new GapPerm("(345)"); var h = f.Compose(g); } { var f = new GapPerm("(12)(34)"); } { var f = new GapPerm("(123)"); var result = new[] { f.Apply(0), f.Apply(1), f.Apply(3), f.Apply(4) }; } { var f = new GapPerm("(12)"); var g = new GapPerm(0, 2, 1); WriteLine(f.Equals(g)); WriteLine(f == g); WriteLine(f.GetHashCode()); WriteLine(g.GetHashCode()); } { var f = new GapPerm("(1234)"); var result = f.Inverse(); } { var f = new GapPerm(10, 20, 30, 40, 4).Simplify(); } { var f = new GapPerm(); var g = new GapPerm(0, 2, 1); var result_a = f.Apply(10); var result_b = f.Inverse(); var result_c = f.Compose(g); var result_d = g.Compose(f); // var result_e = f. } { var f = new GapPerm(3, 1, 2, 0); var g = f.Inverse(); } { var f = new GapPerm(0, 2, 1, 3); var g = f.Inverse(); } { var f = new GapPerm("(123)(234)(456)").ToDisjointCycles(); var g = new GapPerm("(12)(3456)").ToDisjointCycles(); var h = new GapPerm("(123)(234)(456)"); } }
public static GapPerm κ = new GapPerm("(13)"); // new FunctionIntInt((1, 3), (2, 2), (3, 1)); static string lookup(GapPerm f) { var items = new[] { (ε, "ε"), (α, "α"), (β, "β"), (γ, "γ"), (σ, "σ"), (κ, "κ") };
static void Main(string[] args) { // A C B // \ | / // 1---2 // | | - D // 4---3 var R0 = new GapPerm(0); // R0 var R1 = new GapPerm("(1234)"); // R90 var R2 = new GapPerm("(13)(24)"); // R180 var R3 = new GapPerm("(4321)"); // R270 var R4 = new GapPerm("(24)"); // FA var R5 = new GapPerm("(13)"); // FB var R6 = new GapPerm("(12)(34)"); // FC var R7 = new GapPerm("(14)(23)"); // FD string lookup(GapPerm f) { var items = new[] { (R0, "R0"), (R1, "R1"), (R2, "R2"), (R3, "R3"), (R4, "R4"), (R5, "R5"), (R6, "R6"), (R7, "R7") }; return(items.First(elt => f == elt.Item1).Item2); } var D4 = new Group <GapPerm> { Identity = R0, Set = new MathSet <GapPerm>(new[] { R0, R1, R2, R3, R4, R5, R6, R7 }), Op = (a, b) => a.Compose(b), Lookup = lookup, OpString = "·" }; Write("D4 "); D4.ShowOperationTableColored(); WriteLine(); var H = D4.Subgroup(new[] { R0, R2, R4, R5 }); WriteLine("Elements of H: {0}\n", H.Set.ConvertAll(H.Lookup)); WriteLine("Elements of quotient group D4/H:\n"); foreach (var elt in D4.CosetGrouping(H, "H")) { WriteLine($"{ elt.ToMathSet() } { elt.Key.ConvertAll(lookup) }"); } WriteLine(); Write("D4/{R0 R2 R4 R5} "); D4.QuotientGroup(H).ShowOperationTableColored(); }
static void Main(string[] args) { // A C B // \ | / // 1---2 // | | - D // 4---3 var R0 = new GapPerm(0); // R0 var R1 = new GapPerm("(1234)"); // R90 var R2 = new GapPerm("(13)(24)"); // R180 var R3 = new GapPerm("(4321)"); // R270 var R4 = new GapPerm("(24)"); // FA var R5 = new GapPerm("(13)"); // FB var R6 = new GapPerm("(12)(34)"); // FC var R7 = new GapPerm("(14)(23)"); // FD string lookup(GapPerm f) { var items = new[] { (R0, "R0"), (R1, "R1"), (R2, "R2"), (R3, "R3"), (R4, "R4"), (R5, "R5"), (R6, "R6"), (R7, "R7") }; return(items.First(elt => f == elt.Item1).Item2); } var D4 = new Group <GapPerm> { Identity = R0, Set = new MathSet <GapPerm>(new[] { R0, R1, R2, R3, R4, R5, R6, R7 }), Op = (a, b) => a.Compose(b), Lookup = lookup, OpString = "·" }; Write("D4 "); D4.ShowOperationTableColored(); WriteLine(); foreach (var a in D4.Set) { foreach (var b in D4.Set) { WriteLine("{0}·{1}·{2}·{3} -> {4}", lookup(a), lookup(b), lookup(D4.Inverse(a)), lookup(D4.Inverse(b)), lookup(D4.Op_(a, b, D4.Inverse(a), D4.Inverse(b)))); } WriteLine(); } WriteLine(); void ShowCommutators <T>(Group <T> G) { WriteLine("commutators:\n"); var width = G.Set.Select(elt => G.Lookup(elt).Count()).Max(); var color_thunks = new List <Action>() { () => { ForegroundColor = ConsoleColor.White; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Red; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Yellow; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Green; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Blue; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Cyan; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Magenta; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkRed; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkBlue; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkGreen; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkMagenta; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkYellow; BackgroundColor = ConsoleColor.Black; } }; void pick_color(T elt) { var i = G.Set.ToList().IndexOf(elt); color_thunks[i % color_thunks.Count()](); } Write("{0}|", "".PadLeft(width)); foreach (var elt in G.Set) { pick_color(elt); Write("{0} ", G.Lookup(elt).PadLeft(width)); } WriteLine(); color_thunks[0](); WriteLine(new String('-', (G.Set.Count() + 1) * (width + 1))); foreach (var x in G.Set) { pick_color(x); Write("{0}", G.Lookup(x).PadLeft(width)); color_thunks[0](); Write("|"); foreach (var y in G.Set) { // var elt = G.Op(x, y); var elt = G.Op_(x, y, G.Inverse(x), G.Inverse(y)); pick_color(elt); Write("{0} ", G.Lookup(elt).PadLeft(width)); } WriteLine(); } ForegroundColor = ConsoleColor.White; BackgroundColor = ConsoleColor.Black; } ShowCommutators(D4); WriteLine(); var H = D4.Subgroup(new[] { R0, R2 }); foreach (var elt in D4.CosetGrouping(H, "H")) { WriteLine("{0} {1}", String.Join(" ", elt.Select(item => String.Format("{0} =", item.ToString()))), elt.Key.ConvertAll(D4.Lookup)); } WriteLine(); Write("D4/H "); D4.QuotientGroup(H, "H").ShowOperationTableColored(); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; //MathSet<int> center(Group<int> G) //{ // return G.Set.Where(a => G.Set.All(b => G.Op(a, b) == G.Op(b, a))).ToMathSet(); //} // G.Set.Where(elt => G.Set.All(b => Commute(a,b))) // G.Set.Where(elt => G.Set.All(CommutesWith(a))) //MathSet<GapPerm> center_GapPerm(Group<GapPerm> G) //{ // return G.Set.Where(a => G.Set.All(b => G.Op(a, b) == G.Op(b, a))).ToMathSet(); //} var group_table_gap_perm = new List <(Group <GapPerm>, string)>(); var group_table_int = new List <(Group <int>, string)>(); var group_table_mathset_int = new List <(Group <MathSet <int> >, string)>(); { var ε = new GapPerm(0); // new FunctionIntInt((1, 1), (2, 2), (3, 3)); var α = new GapPerm("(23)"); // new FunctionIntInt((1, 1), (2, 3), (3, 2)); var β = new GapPerm("(132)"); // new FunctionIntInt((1, 3), (2, 1), (3, 2)); var γ = new GapPerm("(12)"); // new FunctionIntInt((1, 2), (2, 1), (3, 3)); var σ = new GapPerm("(123)"); // new FunctionIntInt((1, 2), (2, 3), (3, 1)); var κ = new GapPerm("(13)"); // new FunctionIntInt((1, 3), (2, 2), (3, 1)); string lookup(GapPerm f) { var items = new[] { (ε, "ε"), (α, "α"), (β, "β"), (γ, "γ"), (σ, "σ"), (κ, "κ") }; return(items.First(elt => f == elt.Item1).Item2); } var S3 = new Group <GapPerm> { Identity = ε, Set = new[] { ε, α, β, γ, σ, κ }.ToMathSet(), Op = (a, b) => a.Compose(b), Lookup = lookup }; // (S3, "S3") // WriteLine(center_GapPerm(S3)); WriteLine("S3 center : {0}", S3.Center()); group_table_gap_perm.Add((S3, "S3")); } { // A C B // \ | / // 1---2 // | | - D // 4---3 var R0 = new GapPerm(0); // R0 var R1 = new GapPerm("(1234)"); // R90 var R2 = new GapPerm("(13)(24)"); // R180 var R3 = new GapPerm("(4321)"); // R270 var R4 = new GapPerm("(24)"); // FA var R5 = new GapPerm("(13)"); // FB var R6 = new GapPerm("(12)(34)"); // FC var R7 = new GapPerm("(14)(23)"); // FD string lookup(GapPerm f) { var items = new[] { (R0, "R0"), (R1, "R1"), (R2, "R2"), (R3, "R3"), (R4, "R4"), (R5, "R5"), (R6, "R6"), (R7, "R7") }; return(items.First(elt => f == elt.Item1).Item2); } var D4 = new Group <GapPerm> { Identity = R0, Set = new MathSet <GapPerm>(new[] { R0, R1, R2, R3, R4, R5, R6, R7 }), Op = (a, b) => a.Compose(b), Lookup = lookup, OpString = "·" }; Write("D4 "); D4.ShowOperationTableColored(); WriteLine("D4 center : {0}\n", D4.Center()); // D4/C // D4.QuotientGroup(D4.Center()) { var C = D4.Subgroup(D4.Center()); Write("D4/C "); D4.QuotientGroup(C).ShowOperationTableColored(); } WriteLine(); group_table_gap_perm.Add((D4, "D4")); } { var R0 = new GapPerm(0); // R0 var R1 = new GapPerm("(123456)"); // R60 var R2 = new GapPerm("(135)(246)"); // R120 var R3 = new GapPerm("(14)(25)(36)"); // R180 var R4 = new GapPerm("(153)(264)"); // R240 var R5 = new GapPerm("(165432)"); // R300 var R6 = new GapPerm("(15)(24)"); // FA var R7 = new GapPerm("(16)(25)(34)"); // FB var R8 = new GapPerm("(26)(35)"); // FC var R9 = new GapPerm("(12)(36)(45)"); // FD var R10 = new GapPerm("(13)(46)"); // FE var R11 = new GapPerm("(14)(23)(56)"); // FF string lookup(GapPerm f) { var items = new[] { (R0, "R0"), (R1, "R1"), (R2, "R2"), (R3, "R3"), (R4, "R4"), (R5, "R5"), (R6, "R6"), (R7, "R7"), (R8, "R8"), (R9, "R9"), (R10, "R10"), (R11, "R11") }; return(items.First(elt => f == elt.Item1).Item2); } var D6 = new Group <GapPerm> { Identity = R0, Set = new MathSet <GapPerm>(new[] { R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11 }), Op = (a, b) => a.Compose(b), Lookup = lookup, OpString = "·" }; Write("D6 "); D6.ShowOperationTableColored(); WriteLine(); WriteLine("D6 center : {0}", D6.Center()); // D6/C { var C = D6.Subgroup(D6.Center()); Write("D6/C "); D6.QuotientGroup(C).ShowOperationTableColored(); } WriteLine(); group_table_gap_perm.Add((D6, "D6")); } { var Z8 = new Group <int> { Identity = 0, Set = Enumerable.Range(0, 8).ToMathSet(), Op = (a, b) => (a + b) % 8, OpString = "+" }; WriteLine("Z8 center : {0}", Z8.Center()); group_table_int.Add((Z8, "Z8")); } { var Z10 = new Group <int> { Identity = 0, Set = Enumerable.Range(0, 10).ToMathSet(), Op = (a, b) => (a + b) % 10, OpString = "+" }; WriteLine("Z10 center : {0}", Z10.Center()); group_table_int.Add((Z10, "Z10")); } { IEnumerable <T> SymmetricDifference <T>(IEnumerable <T> a, IEnumerable <T> b) => a.Except(b).Union(b.Except(a)); var P3 = new Group <MathSet <int> > { Identity = new MathSet <int> { }, Set = new[] { 1, 2, 3 }.PowerSet().Select(elt => elt.ToMathSet()).ToMathSet(), Op = (a, b) => SymmetricDifference(a, b).ToMathSet() }; WriteLine("P3 center : {0}", P3.Center()); group_table_mathset_int.Add((P3, "P3")); } { var a = new List <int> { 10, 20, 30 }; var b = new List <string> { "abc", "bcd", "cde" }; var c = new List <double> { 1.2, 2.3, 3.4 }; var ls = new List <System.Collections.IList> { a, b, c }; //foreach (var elt in ls) // Console.WriteLine(elt.Count); // var ls = new List<List<object>> { a, b, c }; // Group interface - IGroup // new List<IGroup> } // S3 D4 D6 Z8 Z10 P3 foreach (var tup in group_table_gap_perm) { WriteLine("{0,-4} size : {1,3} center size : {2,3}", tup.Item2, tup.Item1.Set.Count, tup.Item1.Center().Count); } foreach (var tup in group_table_int) { WriteLine("{0,-4} size : {1,3} center size : {2,3}", tup.Item2, tup.Item1.Set.Count, tup.Item1.Center().Count); } foreach (var tup in group_table_mathset_int) { WriteLine("{0,-4} size : {1,3} center size : {2,3}", tup.Item2, tup.Item1.Set.Count, tup.Item1.Center().Count); } }
public static GapPerm R7 = new GapPerm("(14)(23)"); // FD static string lookup(GapPerm f) { var items = new[] {
static void Main(string[] args) { var R0 = new GapPerm(0); // R0 var R1 = new GapPerm("(123456)"); // R60 var R2 = new GapPerm("(135)(246)"); // R120 var R3 = new GapPerm("(14)(25)(36)"); // R180 var R4 = new GapPerm("(153)(264)"); // R240 var R5 = new GapPerm("(165432)"); // R300 var R6 = new GapPerm("(15)(24)"); // FA var R7 = new GapPerm("(16)(25)(34)"); // FB var R8 = new GapPerm("(26)(35)"); // FC var R9 = new GapPerm("(12)(36)(45)"); // FD var R10 = new GapPerm("(13)(46)"); // FE var R11 = new GapPerm("(14)(23)(56)"); // FF string lookup(GapPerm f) { var items = new[] { (R0, "R0"), (R1, "R1"), (R2, "R2"), (R3, "R3"), (R4, "R4"), (R5, "R5"), (R6, "R6"), (R7, "R7"), (R8, "R8"), (R9, "R9"), (R10, "R10"), (R11, "R11") }; return(items.First(elt => f == elt.Item1).Item2); } var D6 = new Group <GapPerm> { Identity = R0, Set = new MathSet <GapPerm>(new[] { R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11 }), Op = (a, b) => a.Compose(b), Lookup = lookup, OpString = "·" }; Write("D6 "); D6.ShowOperationTableColored(); WriteLine(); foreach (var a in D6.Set) { foreach (var b in D6.Set) { WriteLine("{0,3}·{1,3}·{2,3}·{3,3} -> {4,3}", lookup(a), lookup(b), lookup(D6.Inverse(a)), lookup(D6.Inverse(b)), lookup(D6.Op_(a, b, D6.Inverse(a), D6.Inverse(b)))); } WriteLine(); } WriteLine(); void ShowCommutators <T>(Group <T> G) { WriteLine("commutators:\n"); var width = G.Set.Select(elt => G.Lookup(elt).Count()).Max(); var color_thunks = new List <Action>() { () => { ForegroundColor = ConsoleColor.White; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Red; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Yellow; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Green; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Blue; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Cyan; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.Magenta; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkRed; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkBlue; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkGreen; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkMagenta; BackgroundColor = ConsoleColor.Black; }, () => { ForegroundColor = ConsoleColor.DarkYellow; BackgroundColor = ConsoleColor.Black; } }; void pick_color(T elt) { var i = G.Set.ToList().IndexOf(elt); color_thunks[i % color_thunks.Count()](); } Write("{0}|", "".PadLeft(width)); foreach (var elt in G.Set) { pick_color(elt); Write("{0} ", G.Lookup(elt).PadLeft(width)); } WriteLine(); color_thunks[0](); WriteLine(new String('-', (G.Set.Count() + 1) * (width + 1))); foreach (var x in G.Set) { pick_color(x); Write("{0}", G.Lookup(x).PadLeft(width)); color_thunks[0](); Write("|"); foreach (var y in G.Set) { // var elt = G.Op(x, y); var elt = G.Op_(x, y, G.Inverse(x), G.Inverse(y)); pick_color(elt); Write("{0} ", G.Lookup(elt).PadLeft(width)); } WriteLine(); } ForegroundColor = ConsoleColor.White; BackgroundColor = ConsoleColor.Black; } Write("D6 "); ShowCommutators(D6); WriteLine(); var H = D6.Subgroup(new[] { R0, R2, R4 }); // D6 is size 12. H is size 3. 12/3 -> 4 cosets foreach (var elt in D6.CosetGrouping(H, "H")) { WriteLine("{0} {1}", String.Join(" ", elt.Select(item => String.Format("{0} =", item.ToString()))), elt.Key.ConvertAll(D6.Lookup)); } WriteLine(); Write("D6/H "); D6.QuotientGroup(H, "H").ShowOperationTableColored(); }
static string even_or_odd(GapPerm obj) => obj.ToDisjointCycles().to_transpositions().ls.Count % 2 == 0 ? "even" : "odd";