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

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


    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);
    pts1.add(var1);
View Full Code Here


    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

    //
    // START-FOLVisitor
    public Object visitPredicate(Predicate p, Object arg) {
      List<Term> newTerms = new ArrayList<Term>();
      for (Term t : p.getTerms()) {
        Term subsTerm = (Term) t.accept(this, arg);
        newTerms.add(subsTerm);
      }
      return new Predicate(p.getPredicateName(), newTerms);
    }
View Full Code Here

      }
      return new Predicate(p.getPredicateName(), newTerms);
    }

    public Object visitTermEquality(TermEquality equality, Object arg) {
      Term newTerm1 = (Term) equality.getTerm1().accept(this, arg);
      Term newTerm2 = (Term) equality.getTerm2().accept(this, arg);
      return new TermEquality(newTerm1, newTerm2);
    }
View Full Code Here

        }
      }

      List<Term> newTerms = new ArrayList<Term>();
      for (Term t : function.getTerms()) {
        Term subsTerm = (Term) t.accept(this, arg);
        newTerms.add(subsTerm);
      }
      return new Function(function.getFunctionName(), newTerms);
    }
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

    IdentifyCandidateMatchingTerm icm = getMatchingSubstitution(
        assertion.getTerm1(), expression);

    if (null != icm) {
      Term replaceWith = substVisitor.subst(
          icm.getMatchingSubstitution(), assertion.getTerm2());
      // Want to ignore reflexivity axiom situation, i.e. x = x
      if (!icm.getMatchingTerm().equals(replaceWith)) {
        ReplaceMatchingTerm rmt = new ReplaceMatchingTerm();
View Full Code Here

          TermEquality assertion = (TermEquality) possEqLit
              .getAtomicSentence();

          // Test matching for both sides of the equality
          for (int x = 0; x < 2; x++) {
            Term toMatch, toReplaceWith;
            if (x == 0) {
              toMatch = assertion.getTerm1();
              toReplaceWith = assertion.getTerm2();
            } else {
              toMatch = assertion.getTerm2();
              toReplaceWith = assertion.getTerm1();
            }

            for (Literal l1 : topClause.getLiterals()) {
              IdentifyCandidateMatchingTerm icm = getMatchingSubstitution(
                  toMatch, l1.getAtomicSentence());

              if (null != icm) {
                Term replaceWith = substVisitor.subst(
                    icm.getMatchingSubstitution(),
                    toReplaceWith);

                // Want to ignore reflexivity axiom situation,
                // i.e. x = x
View Full Code Here

    rVal = args1.size() - args2.size();

    if (0 == rVal && args1.size() > 0) {
      // Move forward and compare the
      // first arguments
      Term t1 = args1.get(0);
      Term t2 = args2.get(0);

      if (t1.getClass() == t2.getClass()) {
        // Note: Variables are considered to have
        // the same order
        if (t1 instanceof Constant) {
          rVal = t1.getSymbolicName().compareTo(t2.getSymbolicName());
        } else if (t1 instanceof Function) {
          rVal = t1.getSymbolicName().compareTo(t2.getSymbolicName());
          if (0 == rVal) {
            // Same function names, therefore
            // compare the function arguments
            rVal = compareArgs(t1.getArgs(), t2.getArgs());
          }
        }

        // If the first args are the same
        // then compare the ordering of the
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.