001 package aima.logic.demos; 002 003 import aima.logic.propositional.algorithms.KnowledgeBase; 004 import aima.logic.propositional.algorithms.PLFCEntails; 005 import aima.logic.propositional.parsing.PEParser; 006 007 /** 008 * @author Ravi Mohan 009 * 010 */ 011 public class PLFCEntailsDemo { 012 private static PEParser parser = new PEParser(); 013 014 private static PLFCEntails plfce = new PLFCEntails(); 015 016 public static void main(String[] args) { 017 018 System.out.println("\nPLFCEntailsDemo\n"); 019 KnowledgeBase kb = new KnowledgeBase(); 020 kb.tell(" (P => Q)"); 021 kb.tell("((L AND M) => P)"); 022 kb.tell("((B AND L) => M)"); 023 kb.tell("( (A AND P) => L)"); 024 kb.tell("((A AND B) => L)"); 025 kb.tell("(A)"); 026 kb.tell("(B)"); 027 028 System.out.println("Example from page 220 of AIMA 2nd Edition"); 029 System.out.println("KnowledgeBsse consists of sentences"); 030 System.out.println(" (P => Q)"); 031 System.out.println("((L AND M) => P)"); 032 System.out.println("((B AND L) => M)"); 033 System.out.println("( (A AND P) => L)"); 034 System.out.println("((A AND B) => L)"); 035 System.out.println("(A)"); 036 System.out.println("(B)"); 037 038 displayPLFCEntailment(kb, "Q"); 039 } 040 041 private static void displayPLFCEntailment(KnowledgeBase kb, String q) { 042 System.out.println("Running PLFCEntailment on knowledge base " 043 + " with query " + q + " gives " + plfce.plfcEntails(kb, q)); 044 } 045 }