Exemplo n.º 1
0
		public bool ttEntails(KnowledgeBase kb, string alpha) 
		{
			Sentence kbSentence = kb.asSentence();
			Sentence querySentence = (Sentence) new PEParser().parse(alpha);
			SymbolCollector collector = new SymbolCollector();
			Hashtable kbSymbols= collector.getSymbolsIn(kbSentence);
			Hashtable querySymbols= collector.getSymbolsIn(querySentence);
			Hashtable symbols = new SetOps().union(kbSymbols,querySymbols);
			ArrayList symbolList = new Converter().setToList(symbols);
			return ttCheckAll(kbSentence, querySentence, symbolList, new Model());
		}
Exemplo n.º 2
0
        public bool ttEntails(KnowledgeBase kb, string alpha)
        {
            Sentence        kbSentence    = kb.asSentence();
            Sentence        querySentence = (Sentence) new PEParser().parse(alpha);
            SymbolCollector collector     = new SymbolCollector();
            Hashtable       kbSymbols     = collector.getSymbolsIn(kbSentence);
            Hashtable       querySymbols  = collector.getSymbolsIn(querySentence);
            Hashtable       symbols       = new SetOps().union(kbSymbols, querySymbols);
            ArrayList       symbolList    = new Converter().setToList(symbols);

            return(ttCheckAll(kbSentence, querySentence, symbolList, new Model()));
        }
Exemplo n.º 3
0
        public bool plfcEntails(KnowledgeBase kb, Symbol q)
        {
            ArrayList hornClauses = asHornClauses(kb.getSentences());

            while (_agenda.Count != 0)
            {
                Symbol p = (Symbol)_agenda.Pop();
                while (!inferred(p))
                {
                    if (_inferred.Contains(p))
                    {
                        _inferred[p] = true;
                    }
                    else
                    {
                        _inferred.Add(p, true);
                    }

                    for (int i = 0; i < hornClauses.Count; i++)
                    {
                        HornClause hornClause = (HornClause)hornClauses[i];
                        if (hornClause.premisesContainsSymbol(p))
                        {
                            decrementCount(hornClause);
                            if (countisZero(hornClause))
                            {
                                if (hornClause.head().Equals(q))
                                {
                                    return(true);
                                }
                                else
                                {
                                    _agenda.Push(hornClause.head());
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 4
0
		private void displayPLFCEntailment(KnowledgeBase kb, String q) 
		{
			this.textBox1.Text +=("Running PLFCEntailment on knowledge base  " 
					   + " with query " + q + " gives " + plfce.plfcEntails(kb,q));
		}
Exemplo n.º 5
0
		private void btnPLFCEntails_Click(object sender, System.EventArgs e)
		{
			this.textBox1.Text = (Environment.NewLine + "PLFCEntailsDemo" + Environment.NewLine );
			KnowledgeBase kb =  new KnowledgeBase();
			kb.tell(" (P => Q)");
			kb.tell("((L AND M) => P)");
			kb.tell("((B AND L) => M)");
			kb.tell("( (A AND P) => L)");
			kb.tell("((A AND B) => L)");
			kb.tell("(A)");
			kb.tell("(B)");
			//kb.tell("(P)");

			this.textBox1.Text += (Environment.NewLine + "Example from  page 220 of AIMA 2nd Edition");
			this.textBox1.Text +=(Environment.NewLine + "KnowledgeBsse consists of sentences");
			this.textBox1.Text +=(Environment.NewLine + " (P => Q)");
			this.textBox1.Text +=(Environment.NewLine + "((L AND M) => P)");
			this.textBox1.Text +=(Environment.NewLine + "((B AND L) => M)");
			this.textBox1.Text +=(Environment.NewLine + "( (A AND P) => L)");
			this.textBox1.Text +=(Environment.NewLine + "((A AND B) => L)");
			this.textBox1.Text +=(Environment.NewLine + "(A)");
			this.textBox1.Text +=(Environment.NewLine + "(B)");
			//this.textBox1.Text +=(Environment.NewLine + "(P)");

			displayPLFCEntailment(kb, "Q");
		}
Exemplo n.º 6
0
 public bool plfcEntails(KnowledgeBase kb, string s)
 {
     return(plfcEntails(kb, new Symbol(s)));
 }