001    package aima.logic.demos;
002    
003    import aima.logic.propositional.algorithms.KnowledgeBase;
004    
005    /**
006     * @author Ravi Mohan
007     * 
008     */
009    public class TTEntailsDemo {
010            public static void main(String[] args) {
011                    KnowledgeBase kb = new KnowledgeBase();
012                    kb.tell("(B12 <=> (P11 OR (P13 OR (P22 OR P02))))");
013                    kb.tell("(B21 <=> (P20 OR (P22 OR (P31 OR P11))))");
014                    kb.tell("(B01 <=> (P00 OR (P02 OR P11)))");
015                    kb.tell("(B10 <=> (P11 OR (P20 OR P00)))");
016                    kb.tell("(NOT B21)");
017                    kb.tell("(NOT B12)");
018                    kb.tell("(B10)");
019                    kb.tell("(B01)");
020    
021                    System.out.println("\nTTEntailsDemo\n");
022                    System.out.println("(B12 <=> (P11 OR (P13 OR (P22 OR P02))))");
023                    System.out.println("(B21 <=> (P20 OR (P22 OR (P31 OR P11))))");
024                    System.out.println("(B01 <=> (P00 OR (P02 OR P11)))");
025                    System.out.println("(B10 <=> (P11 OR (P20 OR P00)))");
026                    System.out.println("(NOT B21)");
027                    System.out.println("(NOT B12)");
028                    System.out.println("(B10)");
029                    System.out.println("(B01)");
030    
031                    displayTTEntails(kb, "(P00)");
032                    displayTTEntails(kb, "(NOT P00)");
033    
034            }
035    
036            private static void displayTTEntails(KnowledgeBase kb, String s) {
037                    System.out.println(" ttentails (\"" + s + "\" ) returns "
038                                    + kb.askWithTTEntails(s));
039            }
040    }