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

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


  @Test
  public void testParseComplexParanthizedSentence() {
    Sentence ps = parser.parse("(NOT BrotherOf(John) = EnemyOf(Saladin))");
    Assert.assertEquals(ps, new NotSentence(new TermEquality(
        getBrotherOfFunction(new Constant("John")),
        getEnemyOfFunction())));
  }
View Full Code Here


  @Test
  public void testParseSimpleConnectedSentence() {
    Sentence ps = parser.parse("(King(John) AND NOT King(Richard))");

    Assert.assertEquals(ps, new ConnectedSentence("AND",
        getKingPredicate(new Constant("John")), new NotSentence(
            getKingPredicate(new Constant("Richard")))));

    ps = parser.parse("(King(John) AND King(Saladin))");
    Assert.assertEquals(ps, new ConnectedSentence("AND",
        getKingPredicate(new Constant("John")),
        getKingPredicate(new Constant("Saladin"))));
  }
View Full Code Here

  public void testComplexConnectedSentence1() {
    Sentence ps = parser
        .parse("((King(John) AND NOT King(Richard)) OR King(Saladin))");

    Assert.assertEquals(ps, new ConnectedSentence("OR",
        new ConnectedSentence("AND", getKingPredicate(new Constant(
            "John")), new NotSentence(
            getKingPredicate(new Constant("Richard")))),
        getKingPredicate(new Constant("Saladin"))));
  }
View Full Code Here

    return new Function("BrotherOf", l);
  }

  private Function getEnemyOfFunction() {
    List<Term> l = new ArrayList<Term>();
    l.add(new Constant("Saladin"));
    return new Function("EnemyOf", l);
  }
View Full Code Here

    return new Function("EnemyOf", l);
  }

  private Function getLegsOfFunction() {
    List<Term> l = new ArrayList<Term>();
    l.add(new Constant("John"));
    l.add(new Constant("Saladin"));
    l.add(new Constant("Richard"));
    return new Function("LegsOf", l);
  }
View Full Code Here

    Assert.assertEquals("[[B = A]]", resolvents.toString());
  }

  @Test
  public void testHashCode() {
    Term cons1 = new Constant("C1");
    Term cons2 = new Constant("C2");
    Term var1 = new Variable("v1");
    List<Term> pts1 = new ArrayList<Term>();
    List<Term> pts2 = new ArrayList<Term>();
    pts1.add(cons1);
    pts1.add(cons2);
View Full Code Here

    Assert.assertEquals(c1.hashCode(), c2.hashCode());
  }

  @Test
  public void testSimpleEquals() {
    Term cons1 = new Constant("C1");
    Term cons2 = new Constant("C2");
    Term var1 = new Variable("v1");
    List<Term> pts1 = new ArrayList<Term>();
    List<Term> pts2 = new ArrayList<Term>();
    pts1.add(cons1);
    pts1.add(cons2);
View Full Code Here

    Sentence johnKnowsJane = parser.parse("Knows(y,Bill)");
    Map<Variable, Term> result = unifier.unify(query, johnKnowsJane, theta);

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

    Assert.assertEquals(new Constant("Bill"), theta.get(new Variable("x"))); // x
    // =
    // Bill
    Assert.assertEquals(new Constant("John"), theta.get(new Variable("y"))); // y
    // =
    // John
  }
View Full Code Here

    Map<Variable, Term> result = unifier.unify(query, johnKnowsJane, theta);

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

    List<Term> terms = new ArrayList<Term>();
    terms.add(new Constant("John"));
    Function mother = new Function("Mother", terms);
    Assert.assertEquals(mother, theta.get(new Variable("x")));
    Assert.assertEquals(new Constant("John"), theta.get(new Variable("y")));
  }
View Full Code Here

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

    Assert.assertEquals(new Variable("z"), theta.get(new Variable("x"))); // x
    // =
    // z
    Assert.assertEquals(new Constant("John"), theta.get(new Variable("y"))); // y
    // =
    // John
  }
View Full Code Here

TOP

Related Classes of aima.core.logic.fol.parsing.ast.Constant

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.