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

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


    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("A"), result.get(new Variable("x")));
  }
View Full Code Here


    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));

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

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.size());

    s1 = parser.parse("(P(A) OR P(B))");
    s2 = parser.parse("(P(A) OR P(C))");

    result = unifier.unify(s1, s2);

    Assert.assertNull(result);

    s1 = parser.parse("(P(A) OR P(B))");
    s2 = parser.parse("(P(A) OR P(x))");

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));

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

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.size());

    s1 = parser.parse("(P(A) => P(B))");
    s2 = parser.parse("(P(A) => P(C))");

    result = unifier.unify(s1, s2);

    Assert.assertNull(result);

    s1 = parser.parse("(P(A) => P(B))");
    s2 = parser.parse("(P(A) => P(x))");

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));

    s1 = parser.parse("(P(A) <=> P(B))");
    s2 = parser.parse("(P(A) <=> P(B))");

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.size());

    s1 = parser.parse("(P(A) <=> P(B))");
    s2 = parser.parse("(P(A) <=> P(C))");

    result = unifier.unify(s1, s2);

    Assert.assertNull(result);

    s1 = parser.parse("(P(A) <=> P(B))");
    s2 = parser.parse("(P(A) <=> P(x))");

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));

    s1 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");
    s2 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.size());

    s1 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");
    s2 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(A))))");

    result = unifier.unify(s1, s2);

    Assert.assertNull(result);

    s1 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");
    s2 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(x))))");

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("C"), result.get(new Variable("x")));
  }
View Full Code Here

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("A"), result.get(new Variable("x")));

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

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(0, result.size());

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

    result = unifier.unify(s1, s2);

    Assert.assertNull(result);

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

    result = unifier.unify(s1, s2);

    Assert.assertNull(result);

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

    result = unifier.unify(s1, s2);

    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(new Constant("A"), result.get(new Variable("x")));
  }
View Full Code Here

    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

  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

  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

  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

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.