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

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


  @Test
  public void testMultipleVariables() {
    Set<Variable> variables = vc.collectAllVariables(parser
        .parse("BrotherOf(x) = EnemyOf(y)"));
    Assert.assertEquals(2, variables.size());
    Assert.assertTrue(variables.contains(new Variable("x")));
    Assert.assertTrue(variables.contains(new Variable("y")));
  }
View Full Code Here


    // Note: Should collect quantified variables
    // even if not mentioned in clause.
    Set<Variable> variables = vc.collectAllVariables(parser
        .parse("FORALL x,y,z (BrotherOf(x) = EnemyOf(y))"));
    Assert.assertEquals(3, variables.size());
    Assert.assertTrue(variables.contains(new Variable("x")));
    Assert.assertTrue(variables.contains(new Variable("y")));
    Assert.assertTrue(variables.contains(new Variable("z")));
  }
View Full Code Here

    List<Variable> replVariables = new ArrayList<Variable>();
    for (Variable v : sentence.getVariables()) {
      // If local variable has be renamed already
      // then I need to come up with own name
      if (seenSoFar.contains(v)) {
        Variable sV = new Variable(quantifiedIndexical.getPrefix()
            + quantifiedIndexical.getNextIndex());
        localSubst.put(v, sV);
        // Replacement variables should contain new name for variable
        replVariables.add(sV);
      } else {
View Full Code Here

  public Term parseVariable() {
    Token t = lookAhead(1);
    String value = t.getText();
    consume();
    return new Variable(value);
  }
View Full Code Here

  private Sentence parseQuantifiedSentence() {
    String quantifier = lookAhead(1).getText();
    consume();
    List<Variable> variables = new ArrayList<Variable>();
    Variable var = (Variable) parseVariable();
    variables.add(var);
    while (lookAhead(1).getType() == LogicTokenTypes.COMMA) {
      consume();
      var = (Variable) parseVariable();
      variables.add(var);
View Full Code Here

        .collectAllVariables(aSentence);
    Map<Variable, Term> renameSubstitution = new HashMap<Variable, Term>();
    Map<Variable, Term> reverseSubstitution = new HashMap<Variable, Term>();

    for (Variable var : toRename) {
      Variable v = null;
      do {
        v = new Variable(standardizeApartIndexical.getPrefix()
            + standardizeApartIndexical.getNextIndex());
        // Ensure the new variable name is not already
        // accidentally used in the sentence
      } while (toRename.contains(v));
View Full Code Here

    Set<Variable> toRename = variableCollector.collectAllVariables(clause);
    Map<Variable, Term> renameSubstitution = new HashMap<Variable, Term>();

    for (Variable var : toRename) {
      Variable v = null;
      do {
        v = new Variable(standardizeApartIndexical.getPrefix()
            + standardizeApartIndexical.getNextIndex());
        // Ensure the new variable name is not already
        // accidentally used in the sentence
      } while (toRename.contains(v));
View Full Code Here

    Set<Variable> toRename = variableCollector.collectAllVariables(chain);
    Map<Variable, Term> renameSubstitution = new HashMap<Variable, Term>();

    for (Variable var : toRename) {
      Variable v = null;
      do {
        v = new Variable(standardizeApartIndexical.getPrefix()
            + standardizeApartIndexical.getNextIndex());
        // Ensure the new variable name is not already
        // accidentally used in the sentence
      } while (toRename.contains(v));
View Full Code Here

    }

    Map<Variable, Term> renameSubstitution = new HashMap<Variable, Term>();

    for (Variable var : toRename) {
      Variable v = null;
      do {
        v = new Variable(standardizeApartIndexical.getPrefix()
            + standardizeApartIndexical.getNextIndex());
        // Ensure the new variable name is not already
        // accidentally used in the sentence
      } while (toRename.contains(v));
View Full Code Here

TOP

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

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.