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

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


    Sentence quantified = sentence.getQuantified();
    Sentence quantifiedAfterSubs = (Sentence) quantified.accept(this, arg);

    List<Variable> variables = new ArrayList<Variable>();
    for (Variable v : sentence.getVariables()) {
      Term st = substitution.get(v);
      if (null != st) {
        if (st instanceof Variable) {
          // Only if it is a variable to I replace it, otherwise
          // I drop it.
          variables.add((Variable) st.copy());
        }
      } else {
        // No substitution for the quantified variable, so
        // keep it.
        variables.add(v.copy());
View Full Code Here


      theta.put(v, _substVisitor.subst(theta, theta.get(v)));
    }
    // Ensure Function Terms are correctly updates by passing over them
    // again. Fix for testBadCascadeSubstitution_LCL418_1()
    for (Variable v : theta.keySet()) {
      Term t = theta.get(v);
      if (t instanceof Function) {
        theta.put(v, _substVisitor.subst(theta, t));
      }
    }
    return theta;
View Full Code Here

  // http://logic.stanford.edu/classes/cs157/2008/miscellaneous/faq.html#jump165
  // for need for this.
  private Map<Variable, Term> cascadeSubstitutions(FOLKnowledgeBase KB,
      Map<Variable, Term> theta) {
    for (Variable v : theta.keySet()) {
      Term t = theta.get(v);
      theta.put(v, KB.subst(theta, t));
    }

    return theta;
  }
View Full Code Here

  }

  @Test
  public void testParseSimpleVariable() {
    parser.setUpToParse("x");
    Term v = parser.parseVariable();
    Assert.assertEquals(v, new Variable("x"));
  }
View Full Code Here

  }

  @Test
  public void testParseIndexedVariable() {
    parser.setUpToParse("x1");
    Term v = parser.parseVariable();
    Assert.assertEquals(v, new Variable("x1"));
  }
View Full Code Here

  }

  @Test
  public void testParseSimpleConstant() {
    parser.setUpToParse("John");
    Term c = parser.parseConstant();
    Assert.assertEquals(c, new Constant("John"));
  }
View Full Code Here

  }

  @Test
  public void testParseFunction() {
    parser.setUpToParse("BrotherOf(John)");
    Term f = parser.parseFunction();
    Assert.assertEquals(f, getBrotherOfFunction(new Constant("John")));
  }
View Full Code Here

  }

  @Test
  public void testParseMultiArityFunction() {
    parser.setUpToParse("LegsOf(John,Saladin,Richard)");
    Term f = parser.parseFunction();
    Assert.assertEquals(f, getLegsOfFunction());
    Assert.assertEquals(3, ((Function) f).getTerms().size());
  }
View Full Code Here

  }

  @Test
  public void testParseMultiArityFunctionEquality() {
    parser.setUpToParse("LegsOf(John,Saladin,Richard)");
    Term f = parser.parseFunction();

    parser.setUpToParse("LegsOf(John,Saladin,Richard)");
    Term f2 = parser.parseFunction();
    Assert.assertEquals(f, f2);
    Assert.assertEquals(3, ((Function) f).getTerms().size());
  }
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);
    pts1.add(var1);
View Full Code Here

TOP

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

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.