Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        public void GapPerm_Compose_Identity()
        {
            var f = new GapPerm();
            var g = new GapPerm(0, 2, 1);

            Assert.AreEqual(g.Compose(f), g);
        }
Exemplo n.º 4
0
        public void GapPerm_Identity_Compose()
        {
            var f = new GapPerm();
            var g = new GapPerm(0, 2, 1);

            Assert.AreEqual(f.Compose(g), g);
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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)");
            }
        }
Exemplo n.º 7
0
 [Fact] public static void GapPerm_Compose_000() => Assert.Equal("(135)(246)", a.Compose(a).ToString());