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

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


    Sentence beta = (Sentence) sentence.getSecond().accept(this, arg);

    // 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


    if (negated instanceof NotSentence) {
      return ((NotSentence) negated).getNegated().accept(this, arg);
    }

    if (negated instanceof ConnectedSentence) {
      ConnectedSentence negConnected = (ConnectedSentence) negated;
      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) {
View Full Code Here

    return new NotSentence((Sentence) negated.accept(this, arg));
  }

  public Object visitConnectedSentence(ConnectedSentence sentence, Object arg) {
    return new ConnectedSentence(sentence.getConnector(),
        (Sentence) sentence.getFirst().accept(this, arg),
        (Sentence) sentence.getSecond().accept(this, arg));
  }
View Full Code Here

    Set<Variable> answerLiteralVariables = KB
        .collectAllVariables(answerLiteral.getAtomicSentence());
    Clause answerClause = new Clause();

    if (answerLiteralVariables.size() > 0) {
      Sentence notAlphaWithAnswer = new ConnectedSentence(Connectors.OR,
          notAlpha, answerLiteral.getAtomicSentence());
      for (Clause c : KB.convertToClauses(notAlphaWithAnswer)) {
        c = KB.standardizeApart(c);
        c.setProofStep(new ProofStepGoal(c));
        c.setStandardizedApartCheckNotRequired();
View Full Code Here

    return new NotSentence((Sentence) sentence.getNegated().accept(this,
        arg));
  }

  public Object visitConnectedSentence(ConnectedSentence sentence, Object arg) {
    return new ConnectedSentence(sentence.getConnector(),
        (Sentence) sentence.getFirst().accept(this, arg),
        (Sentence) sentence.getSecond().accept(this, arg));
  }
View Full Code Here

    return new NotSentence((Sentence) sentence.getNegated().accept(this,
        arg));
  }

  public Object visitConnectedSentence(ConnectedSentence sentence, Object arg) {
    return new ConnectedSentence(sentence.getConnector(),
        (Sentence) sentence.getFirst().accept(this, arg),
        (Sentence) sentence.getSecond().accept(this, arg));
  }
View Full Code Here

    // (alpha V (beta ^ gamma)) equivalent to
    // ((alpha V beta) ^ (alpha V gamma))
    if (Connectors.isOR(sentence.getConnector())
        && ConnectedSentence.class.isInstance(beta)) {
      ConnectedSentence betaAndGamma = (ConnectedSentence) beta;
      if (Connectors.isAND(betaAndGamma.getConnector())) {
        beta = betaAndGamma.getFirst();
        Sentence gamma = betaAndGamma.getSecond();
        return new ConnectedSentence(Connectors.AND,
            (Sentence) (new ConnectedSentence(Connectors.OR, alpha,
                beta)).accept(this, arg),
            (Sentence) (new ConnectedSentence(Connectors.OR, alpha,
                gamma)).accept(this, arg));
      }
    }

    // ((alpha ^ gamma) V beta) equivalent to
    // ((alpha V beta) ^ (gamma V beta))
    if (Connectors.isOR(sentence.getConnector())
        && ConnectedSentence.class.isInstance(alpha)) {
      ConnectedSentence alphaAndGamma = (ConnectedSentence) alpha;
      if (Connectors.isAND(alphaAndGamma.getConnector())) {
        alpha = alphaAndGamma.getFirst();
        Sentence gamma = alphaAndGamma.getSecond();
        return new ConnectedSentence(Connectors.AND,
            (Sentence) (new ConnectedSentence(Connectors.OR, alpha,
                beta)).accept(this, arg),
            (Sentence) (new ConnectedSentence(Connectors.OR, gamma,
                beta)).accept(this, arg));
      }
    }

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

      answerLiteralVariables = kb.collectAllVariables(answerLiteral
          .getAtomicSentence());

      // Create the Set of Support based on the Query.
      if (answerLiteralVariables.size() > 0) {
        Sentence refutationQueryWithAnswer = new ConnectedSentence(
            Connectors.OR, refutationQuery, answerLiteral
                .getAtomicSentence().copy());

        sos = createChainsFromClauses(kb
            .convertToClauses(refutationQueryWithAnswer));
View Full Code Here

      descParts.add(part);
    }
    if (descParts.size() == 1) {
      description = descParts.get(0);
    } else if (descParts.size() > 1) {
      description = new ConnectedSentence(Connectors.AND,
          descParts.get(0), descParts.get(1));
      for (int i = 2; i < descParts.size(); i++) {
        description = new ConnectedSentence(Connectors.AND,
            description, descParts.get(i));
      }
    }
  }
View Full Code Here

  @Test
  public void testParseSimpleConnectedSentence() {
    Sentence ps = parser.parse("(King(John) AND NOT King(Richard))");

    Assert.assertEquals(ps, new ConnectedSentence("AND",
        getKingPredicate(new Constant("John")), new NotSentence(
            getKingPredicate(new Constant("Richard")))));

    ps = parser.parse("(King(John) AND King(Saladin))");
    Assert.assertEquals(ps, new ConnectedSentence("AND",
        getKingPredicate(new Constant("John")),
        getKingPredicate(new Constant("Saladin"))));
  }
View Full Code Here

TOP

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

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.