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

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


      // ((consp x) (or (occurs-in? var (first x) subst) (occurs-in? var
      // (rest x) subst)))
    } else if (x instanceof Function) {
      // (or (occurs-in? var (first x) subst) (occurs-in? var (rest x)
      // subst)))
      Function fx = (Function) x;
      for (Term fxt : fx.getArgs()) {
        if (occurCheck(theta, var, fxt)) {
          return true;
        }
      }
    }
View Full Code Here


      for (Variable eVar : sentence.getVariables()) {
        if (universalScope.size() > 0) {
          // Replace with a Skolem Function
          String skolemFunctionName = parser.getFOLDomain()
              .addSkolemFunction();
          skolemSubst.put(eVar, new Function(skolemFunctionName,
              new ArrayList<Term>(universalScope)));
        } else {
          // Replace with a Skolem Constant
          String skolemConstantName = parser.getFOLDomain()
              .addSkolemConstant();
View Full Code Here

  // PRIVATE METHODS
  //
  private Function getBrotherOfFunction(Term t) {
    List<Term> l = new ArrayList<Term>();
    l.add(t);
    return new Function("BrotherOf", l);
  }
View Full Code Here

  }

  private Function getEnemyOfFunction() {
    List<Term> l = new ArrayList<Term>();
    l.add(new Constant("Saladin"));
    return new Function("EnemyOf", l);
  }
View Full Code Here

  private Function getLegsOfFunction() {
    List<Term> l = new ArrayList<Term>();
    l.add(new Constant("John"));
    l.add(new Constant("Saladin"));
    l.add(new Constant("Richard"));
    return new Function("LegsOf", l);
  }
View Full Code Here

    // Should be: [{P(F(c#),F(c#)),P(G(F(c#)),F(c#))}]
    c = c.getNonTrivialFactors().iterator().next();
    Literal p = c.getPositiveLiterals().get(0);
    Assert.assertEquals("P", p.getAtomicSentence().getSymbolicName());
    Function f = (Function) p.getAtomicSentence().getArgs().get(0);
    Assert.assertEquals("F", f.getFunctionName());
    Variable v = (Variable) f.getTerms().get(0);
    f = (Function) p.getAtomicSentence().getArgs().get(1);
    Assert.assertEquals("F", f.getFunctionName());
    Assert.assertEquals(v, f.getTerms().get(0));

    //
    p = c.getPositiveLiterals().get(1);
    f = (Function) p.getAtomicSentence().getArgs().get(0);
    Assert.assertEquals("G", f.getFunctionName());
    f = (Function) f.getTerms().get(0);
    Assert.assertEquals("F", f.getFunctionName());
    Assert.assertEquals(v, f.getTerms().get(0));
    f = (Function) p.getAtomicSentence().getArgs().get(1);
    Assert.assertEquals("F", f.getFunctionName());
    Assert.assertEquals(v, f.getTerms().get(0));

    // p(g(x)), q(x), p(f(a)), p(x), p(g(f(x))), q(f(a))
    c = new Clause();
    c.addPositiveLiteral((Predicate) parser.parse("P(G(x))"));
    c.addPositiveLiteral((Predicate) parser.parse("Q(x)"));
View Full Code Here

      // ((consp x) (or (occurs-in? var (first x) subst) (occurs-in? var
      // (rest x) subst)))
    } else if (x instanceof Function) {
      // (or (occurs-in? var (first x) subst) (occurs-in? var (rest x)
      // subst)))
      Function fx = (Function) x;
      for (Term fxt : fx.getArgs()) {
        if (occurCheck(theta, var, fxt)) {
          return true;
        }
      }
    }
View Full Code Here

    Assert.assertEquals(2, result.size());

    List<Term> terms = new ArrayList<Term>();
    terms.add(new Constant("John"));
    Function mother = new Function("Mother", terms);
    Assert.assertEquals(mother, theta.get(new Variable("x")));
    Assert.assertEquals(new Constant("John"), theta.get(new Variable("y")));
  }
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

    FOLKnowledgeBase akb = FOLKnowledgeBaseFactory
        .createABCDEqualityAndSubstitutionKnowledgeBase(infp, true);

    List<Term> terms = new ArrayList<Term>();
    terms.add(new Constant("A"));
    Function fa = new Function("F", terms);
    terms = new ArrayList<Term>();
    terms.add(fa);
    TermEquality query = new TermEquality(new Function("F", terms),
        new Constant("A"));

    InferenceResult answer = akb.ask(query);

    Assert.assertTrue(null != answer);
View Full Code Here

TOP

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

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.