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

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


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

  @Test
  public void testMultipleVariableSubstitutionWithPredicate() {
    Sentence beforeSubst = parser.parse("King(x,y)");
    Sentence expectedAfterSubst = parser.parse(" King(John ,England) ");

    Map<Variable, Term> p = new LinkedHashMap<Variable, Term>();
    p.put(new Variable("x"), new Constant("John"));
    p.put(new Variable("y"), 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


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

  @Test
  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

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

  @Test
  public void testSubstSingleVariableSucceedsWithTermEquality() {
    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

        parser.parse("BrotherOf(x) = EnemyOf(y)"));
  }

  @Test
  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

    Assert.assertEquals(parser.parse("BrotherOf(John) = x)"), beforeSubst);
  }

  @Test
  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

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

  @Test
  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

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

  @Test
  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

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

  @Test
  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

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

  @Test
  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

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

  @Test
  public void testConnectiveANDSentenceAndSngleVariable() {
    Sentence beforeSubst = parser
        .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) )"),
        beforeSubst);
  }
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.