Example #1
0
        public void CreateWithNamedIdentityAndOneElement()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity , aelement}, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            table.SetValue(aelement, aelement, identity);

            Assert.IsTrue(table.HasIdentity);
            Assert.IsTrue(table.IsAssociative);
            Assert.IsTrue(table.IsClosed);
            Assert.IsTrue(table.IsCommutative);

            Assert.AreEqual(2, table.Elements.Count);

            Assert.AreEqual(identity, table.GetValue(identity, identity));
            Assert.AreEqual(aelement, table.GetValue(aelement, identity));
            Assert.AreEqual(aelement, table.GetValue(identity, aelement));
            Assert.AreEqual(identity, table.GetValue(aelement, aelement));

            Assert.AreEqual(1, identity.Order);
            Assert.AreEqual(2, aelement.Order);
        }
Example #2
0
        public void SameNameAreEqual()
        {
            NamedElement element1 = new NamedElement('a');
            NamedElement element2 = new NamedElement('a');

            Assert.AreEqual(element1, element2);
            Assert.AreEqual(element1.GetHashCode(), element2.GetHashCode());
        }
Example #3
0
        public void DifferentNameAreNotEqual()
        {
            NamedElement element1 = new NamedElement('a');
            NamedElement element2 = new NamedElement('b');

            Assert.AreNotEqual(element1, element2);
            Assert.AreNotEqual(element1.GetHashCode(), element2.GetHashCode());
        }
Example #4
0
        public void GetCompatibleOperationTable()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            OperationTable table2 = table.GetCompatibleTable(aelement, aelement, identity);
            Assert.IsNotNull(table2);
            Assert.AreNotSame(table2, table);
        }
Example #5
0
        public void CreateWithNamedIdentity()
        {
            NamedElement identity = new NamedElement('e');
            OperationTable table = new OperationTable(new List<IElement>() { identity }, true);

            identity.OperationTable = table;

            Assert.IsTrue(table.HasIdentity);
            Assert.IsTrue(table.IsAssociative);
            Assert.IsTrue(table.IsClosed);
            Assert.IsTrue(table.IsCommutative);

            Assert.AreEqual(identity, table.GetValue(identity, identity));

            Assert.AreEqual(1, identity.Order);
        }
Example #6
0
 /// <summary>
 /// Implements the constructor: NamedElement()
 /// </summary>
 public virtual void NamedElement(NamedElement @this)
 {
 }
Example #7
0
        public void GetCompatibleOperationTableUsingAssociationExpansion()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            NamedElement belement = new NamedElement('b');
            NamedElement celement = new NamedElement('c');

            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement, belement, celement }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;
            belement.OperationTable = table;
            celement.OperationTable = table;

            table = table.GetCompatibleTable(aelement, belement, celement);
            Assert.IsNotNull(table);

            table = table.GetCompatibleTable(belement, aelement, celement);
            Assert.IsNotNull(table);

            // bc undefined
            Assert.IsNull(table.GetValue(belement, celement));

            table = table.GetCompatibleTable(belement, celement, identity);

            Assert.IsNotNull(table);

            // bc = e, ba = c = ab -> cb = e
            Assert.AreEqual(identity, table.GetValue(celement, belement));

            // but is not complete, yet
            Assert.IsFalse(table.IsClosed);

            IList<OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(1, solutions.Count);
            Assert.IsTrue(solutions[0].IsClosed);
        }
Example #8
0
        public void GetIncompatibleOperationTableIfValueIsAlreadyInRowOrColumn()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement }, true);

            identity.OperationTable = table;
            aelement.OperationTable = table;

            Assert.IsNull(table.GetCompatibleTable(aelement, aelement, aelement));
        }
Example #9
0
        public void GetGroupsOfOrderTwo()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement }, true);

            IList<OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(1, solutions.Count);
            Assert.IsTrue(solutions[0].IsClosed);
            Assert.IsTrue(solutions[0].IsAssociative);
        }
Example #10
0
        public void GetGroupsOfOrderFour()
        {
            NamedElement identity = new NamedElement('e');
            NamedElement aelement = new NamedElement('a');
            NamedElement belement = new NamedElement('b');
            NamedElement celement = new NamedElement('c');
            OperationTable table = new OperationTable(new List<IElement>() { identity, aelement, belement, celement }, true);

            IList<OperationTable> solutions = table.GetSolutions().ToList();

            Assert.IsNotNull(solutions);
            Assert.AreEqual(4, solutions.Count);

            foreach (OperationTable solution in solutions)
            {
                Assert.IsTrue(solution.IsClosed);
                Assert.IsTrue(solution.IsCommutative);
            }

            IList<IGroup> groups = new List<IGroup>();

            foreach (OperationTable ot in solutions)
                groups.Add(new TableGroup(ot));

            IList<IGroup> dgroups = GroupUtilities.GetNonIsomorphic(groups);

            Assert.IsNotNull(dgroups);
            Assert.AreEqual(2, dgroups.Count);
        }
Example #11
0
		internal NamedElement (string name, NamedElement parent) {
			this.Name = name;
			this.QualifiedName = parent != null ? (parent.QualifiedName + NamespaceSeparator + name) : name;
		}