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

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


  public void testMultipleVariablePartiallySucceedsWithPredicate() {
    Sentence beforeSubst = parser.parse("King(x,y)");
    Sentence expectedAfterSubst = parser.parse(" King(John ,y) ");

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

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


    Sentence beforeSubst = parser.parse("BrotherOf(x) = EnemyOf(y)");
    Sentence expectedAfterSubst = parser
        .parse("BrotherOf(John) = EnemyOf(Saladin)");

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

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

  public void testSubstSingleVariableSucceedsWithTermEquality2() {
    Sentence beforeSubst = parser.parse("BrotherOf(John) = x)");
    Sentence expectedAfterSubst = parser.parse("BrotherOf(John) = Richard");

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

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

  public void testSubstWithUniversalQuantifierAndSngleVariable() {
    Sentence beforeSubst = parser.parse("FORALL x King(x))");
    Sentence expectedAfterSubst = parser.parse("King(John)");

    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(parser.parse("FORALL x King(x))"), beforeSubst);
  }
View Full Code Here

  public void testSubstWithUniversalQuantifierAndZeroVariablesMatched() {
    Sentence beforeSubst = parser.parse("FORALL x King(x))");
    Sentence expectedAfterSubst = parser.parse("FORALL x 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(parser.parse("FORALL x King(x))"), beforeSubst);
  }
View Full Code Here

  public void testSubstWithUniversalQuantifierAndOneOfTwoVariablesMatched() {
    Sentence beforeSubst = parser.parse("FORALL x,y King(x,y))");
    Sentence expectedAfterSubst = parser.parse("FORALL x King(x,John)");

    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(parser.parse("FORALL x,y King(x,y))"), beforeSubst);
  }
View Full Code Here

  public void testSubstWithExistentialQuantifierAndSngleVariable() {
    Sentence beforeSubst = parser.parse("EXISTS x King(x))");
    Sentence expectedAfterSubst = parser.parse("King(John)");

    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(parser.parse("EXISTS x King(x)"), beforeSubst);
View Full Code Here

  public void testSubstWithNOTSentenceAndSngleVariable() {
    Sentence beforeSubst = parser.parse("NOT King(x))");
    Sentence expectedAfterSubst = parser.parse("NOT King(John)");

    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(parser.parse("NOT King(x))"), beforeSubst);
  }
View Full Code Here

        .parse("EXISTS x ( King(x) AND BrotherOf(x) = EnemyOf(y) )");
    Sentence expectedAfterSubst = parser
        .parse("( King(John) AND BrotherOf(John) = EnemyOf(Saladin) )");

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

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

  public void testParanthisedSingleVariable() {
    Sentence beforeSubst = parser.parse("((( King(x))))");
    Sentence expectedAfterSubst = parser.parse("King(John) ");

    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(parser.parse("((( King(x))))"), beforeSubst);
  }
View Full Code Here

TOP

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

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.