AIMA.Core.Logic.Propositional.Algorithms.KnowledgeBase.askWithDpll C# (CSharp) Method

askWithDpll() public method

public askWithDpll ( String queryString ) : bool
queryString String
return bool
        public bool askWithDpll(String queryString)
        {
            Sentence query = null, cnfForm = null;
            try
            {
                // just a check to see that the query is well formed
                query = (Sentence)parser.parse(queryString);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("error parsing query" + e);
            }

            Sentence kbSentence = asSentence();
            Sentence kbPlusQuery = null;
            if (kbSentence != null)
            {
                kbPlusQuery = (Sentence)parser.parse(" ( " + kbSentence.ToString()
                        + " AND (NOT " + queryString + " ))");
            }
            else
            {
                kbPlusQuery = query;
            }
            try
            {
                cnfForm = new CNFTransformer().transform(kbPlusQuery);
                // System.Console.WriteLine(cnfForm.ToString());
            }
            catch (Exception e)
            {
                System.Console.WriteLine("error converting kb +  query to CNF "
                        + e);

            }
            return !new DPLL().dpllSatisfiable(cnfForm);
        }

Usage Example

Beispiel #1
0
        public void testDoesNotKnow()
        {
            KnowledgeBase kb = new KnowledgeBase();
            kb.tell("A");

            Assert.IsFalse(kb.askWithDpll("B"));
            Assert.IsFalse(kb.askWithDpll("(NOT B)"));
        }
All Usage Examples Of AIMA.Core.Logic.Propositional.Algorithms.KnowledgeBase::askWithDpll