public void Compiled1a()
        {
            Facts.Clear();
            Tbool result = AllAreMale(new Tset(new List <Thing>()));

            Assert.AreEqual(true, result.Out);
        }
        public void Filter3()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Tbool tb1 = new Tbool(false);

            tb1.AddState(new DateTime(2005, 12, 20), true);

            Tbool tb2 = new Tbool(false);

            tb2.AddState(new DateTime(2008, 3, 8), true);

            Facts.Assert(P1, "IsParentOf", P3, tb1);
            Facts.Assert(P1, "IsParentOf", P4, tb2);
            Facts.Assert(P1, "IsParentOf", P1, false);  // An absurd thing to have to assert

            Tset people = new Tset(P1, P3, P4);
            Tset result = people.Filter(_ => IsParentOf(P1, _));

            Assert.AreEqual("{Dawn: ; 12/20/2005: P3; 3/8/2008: P3, P4}", result.Out);
        }
Beispiel #3
0
        public void Either_Result_3()
        {
            Facts.Clear();
            Tbool result = Fam.IsBiologicalParentOf(p1, p2);

            Assert.AreEqual("Unstated", result.Out);
        }
        // Set up a new test
        private static void NewTest()
        {
            Tnum valA = new Tnum(1);

            Tnum valB = new Tnum(2);

            Tnum valC = new Tnum(3);

            valC.AddState(new DateTime(2011, 1, 14), 4);

            Tbool ownA = new Tbool(true);

            Tbool ownB = new Tbool(true);

            ownB.AddState(new DateTime(2008, 1, 1), false);

            Tbool ownC = new Tbool(false);

            ownC.AddState(new DateTime(2005, 1, 1), true);

            Facts.Clear();
            Facts.Assert(A, "ValueOf", valA);
            Facts.Assert(B, "ValueOf", valB);
            Facts.Assert(C, "ValueOf", valC);
            Facts.Assert(M, "Owns", A, ownA);
            Facts.Assert(M, "Owns", B, ownB);
            Facts.Assert(M, "Owns", C, ownC);
        }
Beispiel #5
0
        public void SymUU()
        {
            Facts.Clear();
            Tbool result = Facts.Sym(p1, "IsMarriedTo", p2);

            Assert.AreEqual("Unstated", result.Out);
        }
        public void AllKnownPeople2()
        {
            Facts.Clear();
            Tset result = Facts.AllKnownPeople();

            Assert.AreEqual("", result.Out);
        }
Beispiel #7
0
        public void SymFU()
        {
            Facts.Clear();
            Facts.Assert(p1, "IsMarriedTo", p2, false);
            Tbool result = Facts.Sym(p1, "IsMarriedTo", p2);

            Assert.AreEqual(false, result.Out);
        }
Beispiel #8
0
        public void Either_Result_2()
        {
            Facts.Clear();
            Facts.Assert(p2, "Fam.FamilyRelationship", p1, "Biological child");
            Tbool result = Fam.IsBiologicalParentOf(p1, p2);

            Assert.AreEqual(true, result.Out);
        }
        public void HasBeenAsserted2()
        {
            Facts.Clear();
            Facts.Assert(p2, "FamilyRelationship", p1, "Biological child");
            bool result = Facts.HasBeenAsserted("FamilyRelationship", p1, p2);

            Assert.AreEqual(false, result);
        }
        public void Compiled2a()
        {
            Facts.Clear();
            Thing c      = new Thing("corp");
            Tbool result = SomeoneWorksAt(c, new Tset(new List <Thing>()));

            Assert.AreEqual(false, result.Out);
        }
Beispiel #11
0
        public void SymTF()
        {
            Facts.Clear();
            Facts.Assert(p1, "IsMarriedTo", p2, true);
            Facts.Assert(p2, "IsMarriedTo", p1, false);                         // contradictory assertion
            Tbool result = Facts.Sym(p1, "IsMarriedTo", p2);

            Assert.AreEqual(true, result.Out);    // what is desired here? (or forbid contradictions)
        }
        public void Filter5a()
        {
            Facts.Clear();
            Thing P1     = new Thing("P1");
            Tset  people = new Tset(P1);
            Tset  result = people.Filter(_ => IsParentOf(_, P1));

            Assert.AreEqual("Unstated", result.Out); // Compare with the test Filter5b below
        }
Beispiel #13
0
        public void SymTT()
        {
            Facts.Clear();
            Facts.Assert(p1, "IsMarriedTo", p2, true);
            Facts.Assert(p2, "IsMarriedTo", p1, true);
            Tbool result = Facts.Sym(p1, "IsMarriedTo", p2);

            Assert.AreEqual(true, result.Out);
        }
        public void Compiled1b()
        {
            Facts.Clear();
            Thing p = new Thing("p");

            Facts.Assert(p, "Gender", "Male");
            Tbool result = AllAreMale(new Tset(p));

            Assert.AreEqual(true, result.Out);
        }
Beispiel #15
0
        /// <summary>
        /// Sets/resets data structures for new interview session.
        /// </summary>
        public static void InitializeSession()
        {
            // Clear fact base and assert any assumed facts
            Facts.Clear();
            AssertPreliminaryFacts();

            // Initialize the .akk unit test text string
            AkkTest.testStr = "";
            AkkTest.InitializeUnitTest();
        }
        public void Compiled2b()
        {
            // What conclusion to draw when no relationship is expressed? "Unstated"
            Facts.Clear();
            Thing c      = new Thing("corp");
            Thing p      = new Thing("p");
            Tbool result = SomeoneWorksAt(c, new Tset(p));

            Assert.AreEqual("Unstated", result.Out);
        }
        public void AllKnownPeople4()
        {
            Facts.Clear();
            Thing P1 = new Thing("P1");

            Facts.Assert(P1, "Gender", "Male");
            Tset result = Facts.AllKnownPeople();

            Assert.AreEqual("P1", result.Out);
        }
        public void Compiled2d()
        {
            Facts.Clear();
            Thing c = new Thing("corp");
            Thing p = new Thing("p");

            Facts.Assert(p, "Econ.EmploymentRelationship", c, "Intern");
            Tbool result = SomeoneWorksAt(c, new Tset(p));

            Assert.AreEqual(false, result.Out);
        }
        public void Filter5b()
        {
            Facts.Clear();
            Thing P1     = new Thing("P1");
            Tset  people = new Tset(P1);

            Facts.Assert(P1, "IsParentOf", P1, false);
            Tset result = people.Filter(_ => IsParentOf(_, P1));

            Assert.AreEqual("", result.Out);
        }
Beispiel #20
0
        public void UnknownExistenceDueToUnknownFact()
        {
            Facts.Clear();
            Thing p  = new Thing("p");
            Thing c  = new Thing("c");
            Thing c2 = new Thing("c2");

            Facts.Assert(p, "EmploymentRelationship", c2, "Employee");
            Tbool result = SomeoneWorksAt(c, new Tset(p));  // returns Unknown b/c it's unknown whether IsEmployedBy(p,c)

            Assert.AreEqual(false, result.Out);
        }
        public void Compiled2g()
        {
            Facts.Clear();
            Thing p  = new Thing("p");
            Thing c  = new Thing("c");
            Thing c2 = new Thing("c2");

            Facts.Assert(p, "Econ.EmploymentRelationship", c2, "Employee");
            Tbool result = Econ.IsEmployedBy(p, c2);

            Assert.AreEqual(true, result.Out);
        }
        public void Compiled1d()
        {
            Facts.Clear();
            Thing p1 = new Thing("p1");
            Thing p2 = new Thing("p2");

            Facts.Assert(p1, "Gender", "Male");
            Facts.Assert(p2, "Gender", "Female");
            Tbool result = AllAreMale(new Tset(p1, p2));

            Assert.AreEqual(false, result.Out);
        }
        public void Test_TsetMax5()
        {
            Facts.Clear();
            Thing a = new Thing("a");
            Thing b = new Thing("b");

            Facts.Assert(a, "Tests.TestSet", new Tset(new List <Thing>()
            {
                a, b
            }));
            Facts.Assert(b, "Tests.Quant", new Tnum(Hstate.Uncertain));
            Assert.AreEqual("Uncertain", MaxVal(a).Out);
        }
        public void Test_TsetMin4()
        {
            Facts.Clear();
            Thing a = new Thing("a");
            Thing b = new Thing("b");

            Facts.Assert(a, "Tests.TestSet", new Tset(new List <Thing>()
            {
                a, b
            }));
            Facts.Assert(b, "Tests.Quant", 99);
            Assert.AreEqual("Unstated", MinVal(a).Out);
        }
        public void AllKnownPeople1()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Facts.Assert(P1, "IsParentOf", P3, new Tbool(true));
            Facts.Assert(P1, "IsParentOf", P4, new Tbool(true));

            Assert.AreEqual("P1, P3, P4", Facts.AllKnownPeople().Out);
        }
        public void Test_TsetMax2()
        {
            Facts.Clear();
            Thing a = new Thing("a");
            Thing b = new Thing("b");

            Facts.Assert(a, "Tests.TestSet", new Tset(new List <Thing>()
            {
                a, b
            }));
            Facts.Assert(a, "Tests.Quant", 100);
            Facts.Assert(b, "Tests.Quant", -100);
            Assert.AreEqual(100, MaxVal(a).Out);
        }
        public void AllKnownPeople3()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P2 = new Thing("P2");
            Thing P3 = new Thing("P3");

            Facts.Assert(P1, "IsMarriedTo", P2, true);
            Facts.Assert(P3, "IsPermanentlyAndTotallyDisabled", new Tbool(false));
            Tset result = Facts.AllKnownPeople();

            Assert.AreEqual("P1, P2, P3", result.Out);
        }
        public void FactOrder1a()
        {
            // Tell system to list unknown facts when a rule is invoked
            Facts.GetUnknowns = true;

            // Clear the lists of known and unknown facts
            Facts.Clear();
            Facts.Unknowns.Clear();

            // Invoke a rule
            Tbool theRule = A() & B() & C();

            // Check the order in which the unknown facts are added to the list
            Assert.AreEqual("A B C", ShowUnknownTest());
        }
        public void Filter2()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Facts.Assert(P1, "IsParentOf", P3, true);
            Facts.Assert(P1, "IsParentOf", P4, true);
            Facts.Assert(P1, "IsParentOf", P1, false);  // An absurd thing to have to assert

            Tset people = new Tset(P1, P3, P4);
            Tset result = people.Filter(_ => IsParentOf(P1, _));

            Assert.AreEqual("P3, P4", result.Out);
        }
        public void Filter4()
        {
            Facts.Clear();

            Thing P1 = new Thing("P1");
            Thing P3 = new Thing("P3");
            Thing P4 = new Thing("P4");

            Facts.Assert(P1, "IsParentOf", P3, true);
            Facts.Assert(P1, "IsParentOf", P4, true);
            Facts.Assert(P4, "IsParentOf", P3, false);
            Facts.Assert(P3, "IsParentOf", P3, false);

            Tset people = new Tset(P1, P3, P4);
            Tset result = people.Filter(_ => IsParentOf(_, P3));

            Assert.AreEqual("P1", result.Out);
        }