protected void testEqualityAndSubstitutionNoAxiomsKBabcdPFFASucceeds(
                InferenceProcedure infp, bool expectedToFail)
        {
            FOLKnowledgeBase akb = FOLKnowledgeBaseFactory
                    .createABCDEqualityAndSubstitutionKnowledgeBase(infp, false);

            List<Term> terms = new List<Term>();
            terms.Add(new Constant("A"));
            Function fa = new Function("F", terms);
            terms = new List<Term>();
            terms.Add(fa);
            Function ffa = new Function("F", terms);
            terms = new List<Term>();
            terms.Add(ffa);
            Predicate query = new Predicate("P", terms);

            InferenceResult answer = akb.ask(query);

            Assert.IsTrue(null != answer);
            if (expectedToFail)
            {
                Assert.IsTrue(answer.isPossiblyFalse());
                Assert.IsFalse(answer.isTrue());
                Assert.IsFalse(answer.isUnknownDueToTimeout());
                Assert.IsFalse(answer.isPartialResultDueToTimeout());
                Assert.IsTrue(0 == answer.getProofs().Count);
            }
            else
            {
                Assert.IsFalse(answer.isPossiblyFalse());
                Assert.IsTrue(answer.isTrue());
                Assert.IsFalse(answer.isUnknownDueToTimeout());
                Assert.IsFalse(answer.isPartialResultDueToTimeout());
                Assert.IsTrue(1 == answer.getProofs().Count);
                Assert.IsTrue(0 == answer.getProofs()[0]
                        .getAnswerBindings().Count);
            }
        }
Beispiel #2
0
        public void testKnows3()
        {
            Sentence query = parser.parse("Knows(John,x)");
            Sentence johnKnowsJane = parser.parse("Knows(y,Mother(y))");
            Dictionary<Variable, Term> result = unifier.unify(query, johnKnowsJane, theta);

            Assert.AreEqual(2, result.Count);

            List<Term> terms = new List<Term>();
            terms.Add(new Constant("John"));
            Function mother = new Function("Mother", terms);
            Assert.AreEqual(mother, theta[new Variable("x")]);
            Assert.AreEqual(new Constant("John"), theta[new Variable("y")]);
        }