AIMA.Test.Core.Unit.Logic.FOL.CNFConverterTest.testExamplesPg299AIMA2e C# (CSharp) Method

testExamplesPg299AIMA2e() private method

private testExamplesPg299AIMA2e ( ) : void
return void
        public void testExamplesPg299AIMA2e()
        {
            FOLDomain domain = DomainFactory.lovesAnimalDomain();
            FOLParser parser = new FOLParser(domain);

            // FOL A.
            Sentence origSentence = parser
                    .parse("FORALL x (FORALL y (Animal(y) => Loves(x, y)) => EXISTS y Loves(y, x))");

            CNFConverter cnfConv = new CNFConverter(parser);

            CNF cnf = cnfConv.convertToCNF(origSentence);

            // CNF A1. and A2.
            Assert
                    .AreEqual(
                            "[Animal(SF0(x)), Loves(SF1(x),x)],[~Loves(x,SF0(x)), Loves(SF1(x),x)]",
                            cnf.ToString());

            // FOL B.
            origSentence = parser
                    .parse("FORALL x (EXISTS y (Animal(y) AND Kills(x, y)) => FORALL z NOT(Loves(z, x)))");

            cnf = cnfConv.convertToCNF(origSentence);

            // CNF B.
            Assert.AreEqual("[~Animal(y), ~Kills(x,y), ~Loves(z,x)]", cnf
                    .ToString());

            // FOL C.
            origSentence = parser.parse("FORALL x (Animal(x) => Loves(Jack, x))");

            cnf = cnfConv.convertToCNF(origSentence);

            // CNF C.
            Assert.AreEqual("[~Animal(x), Loves(Jack,x)]", cnf.ToString());

            // FOL D.
            origSentence = parser
                    .parse("(Kills(Jack, Tuna) OR Kills(Curiosity, Tuna))");

            cnf = cnfConv.convertToCNF(origSentence);

            // CNF D.
            Assert.AreEqual("[Kills(Curiosity,Tuna), Kills(Jack,Tuna)]", cnf
                    .ToString());

            // FOL E.
            origSentence = parser.parse("Cat(Tuna)");

            cnf = cnfConv.convertToCNF(origSentence);

            // CNF E.
            Assert.AreEqual("[Cat(Tuna)]", cnf.ToString());

            // FOL F.
            origSentence = parser.parse("FORALL x (Cat(x) => Animal(x))");

            cnf = cnfConv.convertToCNF(origSentence);

            // CNF F.
            Assert.AreEqual("[~Cat(x), Animal(x)]", cnf.ToString());

            // FOL G.
            origSentence = parser.parse("NOT(Kills(Curiosity, Tuna))");

            cnf = cnfConv.convertToCNF(origSentence);

            // CNF G.
            Assert.AreEqual("[~Kills(Curiosity,Tuna)]", cnf.ToString());
        }