예제 #1
0
        public void TestCollectSymbolsFromComplexSentence()
        {
            Sentence        sentence = (Sentence)parser.Parse("(~B11 | P12 | P21) & (B11 | ~P12) & (B11 | ~P21)");
            ISet <Sentence> s        = new HashSet <Sentence>(SymbolCollector.GetSymbolsFrom(sentence)); // En C# si usas ISet<PropositionSymbol> no te va a dejar mirar si Contains algo que son Sentences :-(

            Assert.AreEqual(3, s.Count);
            Sentence b11 = parser.Parse("B11");
            Sentence p21 = parser.Parse("P21");
            Sentence p12 = parser.Parse("P12");

            Assert.IsTrue(s.Contains(b11));
            Assert.IsTrue(s.Contains(p21));
            Assert.IsTrue(s.Contains(p12));
        }
예제 #2
0
파일: ModelTest.cs 프로젝트: gonzsa04/IA
        public void TestComplexSentence()
        {
            string p = "P";
            string q = "Q";

            m = m.Union(new PropositionSymbol(p), true);
            m = m.Union(new PropositionSymbol(q), false);
            Sentence sent = (Sentence)parser.Parse("((P | Q) &  (P => Q))");

            Assert.IsFalse(m.IsTrue(sent));
            Assert.IsTrue(m.IsFalse(sent));
            Sentence sent2 = (Sentence)parser.Parse("((P | Q) & (Q))");

            Assert.IsFalse(m.IsTrue(sent2));
            Assert.IsTrue(m.IsFalse(sent2));
        }
예제 #3
0
        /**
         * Devuelve la respuesta a la consulta específica usando el algoritmo TT-Entails.
         *
         * @param queryString
         *            una consulta para CONSULTAR a la BC
         *
         * @return la respuesta a la consulta específica usando el algoritmo TT-Entails.
         */
        public bool AskWithTTEntails(string queryString)
        {
            PLParser parser = new PLParser();

            Sentence alpha = parser.Parse(queryString);

            return(new TT_Entails().TTEntails(this, alpha));
        }
예제 #4
0
파일: ModelTest.cs 프로젝트: gonzsa04/IA
        [SetUp] // El @Before de Java
        public void SetUp()
        {
            parser = new PLParser();

            trueSentence          = (Sentence)parser.Parse("true");
            falseSentence         = (Sentence)parser.Parse("false");
            andSentence           = (Sentence)parser.Parse("(P  &  Q)");
            simpleOrSentence      = (Sentence)parser.Parse("A | B");
            orSentence            = (Sentence)parser.Parse("(P  |  Q)");
            impliedSentence       = (Sentence)parser.Parse("(P  =>  Q)");
            biConditionalSentence = (Sentence)parser.Parse("(P  <=>  Q)");

            m = new Model();
        }
예제 #5
0
        public void TestSymbolTransform()
        {
            Sentence             symbol      = parser.Parse("A");
            ConjunctionOfClauses transformed = ConvertToConjunctionOfClauses.Convert(symbol);

            Assert.AreEqual("{{A}}", transformed.ToString());
        }
예제 #6
0
 /**
  * Añade la sentencia específica a la BC.
  *
  * @param aSentence
  *            hecho para ser añadido a la BC.
  */
 public void Tell(string aSentence)
 {
     Tell((Sentence)parser.Parse(aSentence));
 }
예제 #7
0
        public void TestSymbolTransform()
        {
            Sentence symbol      = parser.Parse("A");
            Sentence transformed = ConvertToCNF.Convert(symbol);

            Assert.AreEqual("A", transformed.ToString());
        }