Package aima.core.logic.fol.parsing.ast

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


    Assert.assertEquals(new Constant("John"), theta.get(new Variable("y")));
  }

  @Test
  public void testKnows5() {
    Sentence query = parser.parse("Knows(John,x)");
    Sentence johnKnowsJane = parser.parse("Knows(y,z)");
    Map<Variable, Term> result = unifier.unify(query, johnKnowsJane, theta);

    Assert.assertEquals(2, result.size());

    Assert.assertEquals(new Variable("z"), theta.get(new Variable("x"))); // x
View Full Code Here


    domain.addFunction("F");
    domain.addFunction("SF0");
    domain.addFunction("SF1");
    FOLParser parser = new FOLParser(domain);

    Sentence s1 = parser.parse("P(SF1(v2),v2)");
    Sentence s2 = parser.parse("P(v3,SF0(v3))");
    Map<Variable, Term> result = unifier.unify(s1, s2);

    Assert.assertNull(result);

    s1 = parser.parse("P(v1,SF0(v1),SF0(v1),SF0(v1),SF0(v1))");
View Full Code Here

    FOLDomain domain = new FOLDomain();
    domain.addPredicate("ISATHEOREM");
    domain.addFunction("EQUIVALENT");
    FOLParser parser = new FOLParser(domain);

    Sentence s1 = parser
        .parse("ISATHEOREM(EQUIVALENT(EQUIVALENT(c1744,c1743),EQUIVALENT(c1742,c1743)))");
    Sentence s2 = parser
        .parse("ISATHEOREM(EQUIVALENT(EQUIVALENT(c1752,c1751),c1752))");
    Map<Variable, Term> result = unifier.unify(s1, s2);

    Assert.assertEquals(
        "{c1744=EQUIVALENT(c1742,c1751), c1743=c1751, c1752=EQUIVALENT(c1742,c1751)}",
View Full Code Here

    domain.addPredicate("P");

    FOLParser parser = new FOLParser(domain);

    // Test Cascade Substitutions handled correctly
    Sentence s1 = parser.parse("P(z, x)");
    Sentence s2 = parser.parse("P(x, a)");
    Map<Variable, Term> result = unifier.unify(s1, s2);

    Assert.assertEquals("{z=a, x=a}", result.toString());

    s1 = parser.parse("P(x, z)");
View Full Code Here

    domain.addFunction("Plus");
    domain.addPredicate("P");

    FOLParser parser = new FOLParser(domain);

    Sentence s1 = parser.parse("NOT(P(A))");
    Sentence s2 = parser.parse("NOT(P(A))");

    Map<Variable, Term> result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.size());
View Full Code Here

    domain.addFunction("Plus");
    domain.addPredicate("P");

    FOLParser parser = new FOLParser(domain);

    Sentence s1 = parser.parse("(P(A) AND P(B))");
    Sentence s2 = parser.parse("(P(A) AND P(B))");

    Map<Variable, Term> result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.size());
View Full Code Here

    domain.addFunction("Plus");
    domain.addPredicate("P");

    FOLParser parser = new FOLParser(domain);

    Sentence s1 = parser
        .parse("FORALL x,y ((P(x) AND P(A)) OR (P(A) => P(y)))");
    Sentence s2 = parser
        .parse("FORALL x,y ((P(x) AND P(A)) OR (P(A) => P(y)))");

    Map<Variable, Term> result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
View Full Code Here

    parser = new FOLParser(DomainFactory.weaponsDomain());
  }

  @Test
  public void testSimpleSentence() {
    Sentence s = parser.parse("(Missile(x) => Weapon(x))");
    List<Predicate> predicates = collector.getPredicates(s);
    Assert.assertNotNull(predicates);
  }
View Full Code Here

    sv = new SubstVisitor();
  }

  @Test
  public void testSubstSingleVariableSucceedsWithPredicate() {
    Sentence beforeSubst = parser.parse("King(x)");
    Sentence expectedAfterSubst = parser.parse(" King(John) ");
    Sentence expectedAfterSubstCopy = expectedAfterSubst.copy();

    Assert.assertEquals(expectedAfterSubst, expectedAfterSubstCopy);
    Map<Variable, Term> p = new LinkedHashMap<Variable, Term>();
    p.put(new Variable("x"), new Constant("John"));

    Sentence afterSubst = sv.subst(p, beforeSubst);
    Assert.assertEquals(expectedAfterSubst, afterSubst);
    Assert.assertEquals(beforeSubst, parser.parse("King(x)"));
  }
View Full Code Here

    Assert.assertEquals(beforeSubst, parser.parse("King(x)"));
  }

  @Test
  public void testSubstSingleVariableFailsWithPredicate() {
    Sentence beforeSubst = parser.parse("King(x)");
    Sentence expectedAfterSubst = parser.parse(" King(x) ");

    Map<Variable, Term> p = new LinkedHashMap<Variable, Term>();
    p.put(new Variable("y"), new Constant("John"));

    Sentence afterSubst = sv.subst(p, beforeSubst);
    Assert.assertEquals(expectedAfterSubst, afterSubst);
    Assert.assertEquals(beforeSubst, parser.parse("King(x)"));
  }
View Full Code Here

TOP

Related Classes of aima.core.logic.fol.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.