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

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


  }

  public Object visitNotSentence(NotSentence notSentence, Object arg) {
    Sentence negated = notSentence.getNegated();

    return new NotSentence((Sentence) negated.accept(this, arg));
  }
View Full Code Here


    // Eliminate <=>, bi-conditional elimination,
    // replace (alpha <=> beta) with (~alpha V beta) ^ (alpha V ~beta).
    if (Connectors.isBICOND(sentence.getConnector())) {
      Sentence first = new ConnectedSentence(Connectors.OR,
          new NotSentence(alpha), beta);
      Sentence second = new ConnectedSentence(Connectors.OR, alpha,
          new NotSentence(beta));

      return new ConnectedSentence(Connectors.AND, first, second);
    }

    // Eliminate =>, implication elimination,
    // replacing (alpha => beta) with (~alpha V beta)
    if (Connectors.isIMPLIES(sentence.getConnector())) {
      return new ConnectedSentence(Connectors.OR, new NotSentence(alpha),
          beta);
    }

    return new ConnectedSentence(sentence.getConnector(), alpha, beta);
  }
View Full Code Here

      Sentence alpha = negConnected.getFirst();
      Sentence beta = negConnected.getSecond();
      // ~(alpha ^ beta) equivalent to (~alpha V ~beta) (De Morgan)
      if (Connectors.isAND(negConnected.getConnector())) {
        // I need to ensure the ~s are moved in deeper
        Sentence notAlpha = (Sentence) (new NotSentence(alpha)).accept(
            this, arg);
        Sentence notBeta = (Sentence) (new NotSentence(beta)).accept(
            this, arg);
        return new ConnectedSentence(Connectors.OR, notAlpha, notBeta);
      }

      // ~(alpha V beta) equivalent to (~alpha ^ ~beta) (De Morgan)
      if (Connectors.isOR(negConnected.getConnector())) {
        // I need to ensure the ~s are moved in deeper
        Sentence notAlpha = (Sentence) (new NotSentence(alpha)).accept(
            this, arg);
        Sentence notBeta = (Sentence) (new NotSentence(beta)).accept(
            this, arg);
        return new ConnectedSentence(Connectors.AND, notAlpha, notBeta);
      }
    }

    // in addition, rules for negated quantifiers:
    if (negated instanceof QuantifiedSentence) {
      QuantifiedSentence negQuantified = (QuantifiedSentence) negated;
      // I need to ensure the ~ is moved in deeper
      Sentence notP = (Sentence) (new NotSentence(
          negQuantified.getQuantified())).accept(this, arg);

      // ~FORALL x p becomes EXISTS x ~p
      if (Quantifiers.isFORALL(negQuantified.getQuantifier())) {
        return new QuantifiedSentence(Quantifiers.EXISTS,
            negQuantified.getVariables(), notP);
      }

      // ~EXISTS x p becomes FORALL x ~p
      if (Quantifiers.isEXISTS(negQuantified.getQuantifier())) {
        return new QuantifiedSentence(Quantifiers.FORALL,
            negQuantified.getVariables(), notP);
      }
    }

    return new NotSentence((Sentence) negated.accept(this, arg));
  }
View Full Code Here

      reflexivityClause = KB.standardizeApart(reflexivityClause);
      reflexivityClause.setStandardizedApartCheckNotRequired();
      usable.add(reflexivityClause);
    }

    Sentence notAlpha = new NotSentence(alpha);
    // Want to use an answer literal to pull
    // query variables where necessary
    Literal answerLiteral = KB.createAnswerLiteral(notAlpha);
    Set<Variable> answerLiteralVariables = KB
        .collectAllVariables(answerLiteral.getAtomicSentence());
View Full Code Here

  public Object visitFunction(Function function, Object arg) {
    return function;
  }

  public Object visitNotSentence(NotSentence sentence, Object arg) {
    return new NotSentence((Sentence) sentence.getNegated().accept(this,
        arg));
  }
View Full Code Here

  public Object visitFunction(Function function, Object arg) {
    return function;
  }

  public Object visitNotSentence(NotSentence sentence, Object arg) {
    return new NotSentence((Sentence) sentence.getNegated().accept(this,
        arg));
  }
View Full Code Here

  public Object visitFunction(Function function, Object arg) {
    return function;
  }

  public Object visitNotSentence(NotSentence sentence, Object arg) {
    return new NotSentence((Sentence) sentence.getNegated().accept(this,
        arg));
  }
View Full Code Here

    public AnswerHandler(FOLKnowledgeBase kb, Sentence query,
        long maxQueryTime) {

      finishTime = System.currentTimeMillis() + maxQueryTime;

      Sentence refutationQuery = new NotSentence(query);

      // Want to use an answer literal to pull
      // query variables where necessary
      Literal answerLiteral = kb.createAnswerLiteral(refutationQuery);
      answerLiteralVariables = kb.collectAllVariables(answerLiteral
View Full Code Here

              for (Literal l : newSentences) {
                Sentence s = null;
                if (l.isPositiveLiteral()) {
                  s = l.getAtomicSentence();
                } else {
                  s = new NotSentence(l.getAtomicSentence());
                }
                KB.tell(s);
              }
              ansHandler.setAnswers(KB.fetch(alpha));
              return ansHandler;
            }
          }
        }
      }
      // add new to KB
      for (Literal l : newSentences) {
        Sentence s = null;
        if (l.isPositiveLiteral()) {
          s = l.getAtomicSentence();
        } else {
          s = new NotSentence(l.getAtomicSentence());
        }
        KB.tell(s);
      }
    } while (newSentences.size() > 0);
View Full Code Here

        terms);
    if (!example.getAttributeValueAsString(
        folDSDomain.getDataSetTargetName()).equals(
        folDSDomain.getTrueGoalValue())) {
      // if not true then needs to be a Not sentence
      classification = new NotSentence(classification);
    }

    // Create the description sentence
    List<Sentence> descParts = new ArrayList<Sentence>();
    for (String dname : folDSDomain.getDescriptionDataSetNames()) {
      String foldDName = folDSDomain.getFOLName(dname);
      terms = new ArrayList<Term>();
      terms.add(ithExampleConstant);
      // If multivalued becomes a two place predicate
      // e.g: Patrons(X1, Some)
      // otherwise: Hungry(X1) or ~ Hungry(X1)
      // see pg 769 of AIMA
      Sentence part = null;
      if (folDSDomain.isMultivalued(dname)) {
        terms.add(new Constant(folDSDomain.getFOLName(example
            .getAttributeValueAsString(dname))));
        part = new Predicate(foldDName, terms);
      } else {
        part = new Predicate(foldDName, terms);
        // Need to determine if false
        if (!folDSDomain.getTrueGoalValue().equals(
            example.getAttributeValueAsString(dname))) {
          part = new NotSentence(part);
        }
      }
      descParts.add(part);
    }
    if (descParts.size() == 1) {
View Full Code Here

TOP

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

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.