Package aima.core.logic.propositional.parsing.ast

Examples of aima.core.logic.propositional.parsing.ast.Sentence


    Assert.assertEquals(new Boolean(false), sv.value);
  }

  @Test
  public void testDPLLSucceedsWithAandNotA() {
    Sentence sentence = (Sentence) parser.parse("(A AND (NOT A))");
    boolean satisfiable = dpll.dpllSatisfiable(sentence);
    Assert.assertEquals(false, satisfiable);
  }
View Full Code Here


    Assert.assertFalse(kb.askWithDpll("(NOT P00)"));
  }

  @Test
  public void testDPLLSucceedsWithStackOverflowBugReport1() {
    Sentence sentence = (Sentence) parser
        .parse("((A OR (NOT A)) AND (A OR B))");
    Assert.assertTrue(dpll.dpllSatisfiable(sentence));
  }
View Full Code Here

  public void testIssue66() {
    // http://code.google.com/p/aima-java/issues/detail?id=66
    Model model = new Model();
    model = model.extend(new Symbol("A"), false)
        .extend(new Symbol("B"), false).extend(new Symbol("C"), true);
    Sentence sentence = (Sentence) parser.parse("((A OR B) OR C)");
    Assert.assertTrue(dpll.dpllSatisfiable(sentence, model));
  }
View Full Code Here

    parser = new PEParser();
  }

  @Test
  public void testPLResolveWithOneLiteralMatching() {
    Sentence one = (Sentence) parser.parse("(A OR B)");
    Sentence two = (Sentence) parser.parse("((NOT B) OR C)");
    Sentence expected = (Sentence) parser.parse("(A OR C)");
    Set<Sentence> resolvents = resolution.plResolve(one, two);
    Assert.assertEquals(1, resolvents.size());
    Assert.assertTrue(resolvents.contains(expected));
  }
View Full Code Here

    Assert.assertTrue(resolvents.contains(expected));
  }

  @Test
  public void testPLResolveWithNoLiteralMatching() {
    Sentence one = (Sentence) parser.parse("(A OR B)");
    Sentence two = (Sentence) parser.parse("(C OR D)");
    Set<Sentence> resolvents = resolution.plResolve(one, two);
    Assert.assertEquals(0, resolvents.size());
  }
View Full Code Here

    Assert.assertEquals(0, resolvents.size());
  }

  @Test
  public void testPLResolveWithOneLiteralSentencesMatching() {
    Sentence one = (Sentence) parser.parse("A");
    Sentence two = (Sentence) parser.parse("(NOT A)");
    // Sentence expected =(Sentence) parser.parse("(A OR C)");
    Set<Sentence> resolvents = resolution.plResolve(one, two);
    Assert.assertEquals(1, resolvents.size());
    Assert.assertTrue(resolvents.contains(new Symbol("EMPTY_CLAUSE")));
  }
View Full Code Here

    Assert.assertTrue(resolvents.contains(new Symbol("EMPTY_CLAUSE")));
  }

  @Test
  public void testPLResolveWithTwoLiteralsMatching() {
    Sentence one = (Sentence) parser.parse("((NOT P21) OR B11)");
    Sentence two = (Sentence) parser.parse("(((NOT B11) OR P21) OR P12)");
    Sentence expected1 = (Sentence) parser
        .parse("(  ( P12 OR P21 ) OR  ( NOT P21 )  )");
    Sentence expected2 = (Sentence) parser
        .parse("(  ( B11 OR P12 ) OR  ( NOT B11 )  )");
    Set<Sentence> resolvents = resolution.plResolve(one, two);

    Assert.assertEquals(2, resolvents.size());
    Assert.assertTrue(resolvents.contains(expected1));
View Full Code Here

    model = model.extend(new Symbol("P12"), false);
    model = model.extend(new Symbol("P21"), false);
    model = model.extend(new Symbol("P22"), false);
    model = model.extend(new Symbol("P31"), true);

    Sentence kbs = kb.asSentence();
    Assert.assertEquals(true, model.isTrue(kbs));
  }
View Full Code Here

  public void testComplexSentence() {
    String p = "P";
    String q = "Q";
    m = m.extend(new Symbol(p), true);
    m = m.extend(new Symbol(q), false);
    Sentence sent = (Sentence) parser.parse("((P OR Q) AND  (P => Q))");
    Assert.assertFalse(m.isTrue(sent));
    Assert.assertTrue(m.isFalse(sent));
    Sentence sent2 = (Sentence) parser.parse("((P OR Q) AND  (Q))");
    Assert.assertFalse(m.isTrue(sent2));
    Assert.assertTrue(m.isFalse(sent2));
  }
View Full Code Here

    collector = new SymbolCollector();
  }

  @Test
  public void testCollectSymbolsFromComplexSentence() {
    Sentence sentence = (Sentence) parser
        .parse(" (  (  ( NOT B11 )  OR  ( P12 OR P21 ) ) AND  (  ( B11 OR  ( NOT P12 )  ) AND  ( B11 OR  ( NOT P21 )  ) ) )");
    Set<Symbol> s = collector.getSymbolsIn(sentence);
    Assert.assertEquals(3, s.size());
    Sentence b11 = (Sentence) parser.parse("B11");
    Sentence p21 = (Sentence) parser.parse("P21");
    Sentence p12 = (Sentence) parser.parse("P12");
    Assert.assertTrue(s.contains(b11));
    Assert.assertTrue(s.contains(p21));
    Assert.assertTrue(s.contains(p12));
  }
View Full Code Here

TOP

Related Classes of aima.core.logic.propositional.parsing.ast.Sentence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.