Examples of BinarySentence


Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

  private Sentence step(Sentence s) {
    return (Sentence) s.accept(this, null);
  }

  private Sentence transformBiConditionalSentence(BinarySentence bs) {
    Sentence first = new BinarySentence("=>", (Sentence) bs.getFirst()
        .accept(this, null), (Sentence) bs.getSecond().accept(this,
        null));
    Sentence second = new BinarySentence("=>", (Sentence) bs.getSecond()
        .accept(this, null), (Sentence) bs.getFirst()
        .accept(this, null));
    return new BinarySentence("AND", first, second);
  }
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

  }

  private Sentence transformImpliedSentence(BinarySentence bs) {
    Sentence first = new UnarySentence((Sentence) bs.getFirst().accept(
        this, null));
    return new BinarySentence("OR", first, (Sentence) bs.getSecond()
        .accept(this, null));
  }
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

  private Sentence transformNotSentence(UnarySentence us) {
    if (us.getNegated() instanceof UnarySentence) {
      return (Sentence) ((UnarySentence) us.getNegated()).getNegated()
          .accept(this, null);
    } else if (us.getNegated() instanceof BinarySentence) {
      BinarySentence bs = (BinarySentence) us.getNegated();
      if (bs.isAndSentence()) {
        Sentence first = new UnarySentence((Sentence) bs.getFirst()
            .accept(this, null));
        Sentence second = new UnarySentence((Sentence) bs.getSecond()
            .accept(this, null));
        return new BinarySentence("OR", first, second);
      } else if (bs.isOrSentence()) {
        Sentence first = new UnarySentence((Sentence) bs.getFirst()
            .accept(this, null));
        Sentence second = new UnarySentence((Sentence) bs.getSecond()
            .accept(this, null));
        return new BinarySentence("AND", first, second);
      } else {
        return (Sentence) super.visitNotSentence(us, null);
      }
    } else {
      return (Sentence) super.visitNotSentence(us, null);
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

   *            the query, a sentence in propositional logic
   *
   * @return the answer to the specified question using PL-Resolution.
   */
  public boolean plResolution(KnowledgeBase kb, Sentence alpha) {
    Sentence kBAndNotAlpha = new BinarySentence("AND", kb.asSentence(),
        new UnarySentence(alpha));
    Set<Sentence> clauses = new CNFClauseGatherer()
        .getClausesFrom(new CNFTransformer().transform(kBAndNotAlpha));
    clauses = filterOutClausesWithTwoComplementaryLiterals(clauses);
    Set<Sentence> newClauses = new HashSet<Sentence>();
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

      return (Sentence) super.visitNotSentence(us, null);
    }
  }

  private Sentence distributeOrOverAnd(BinarySentence bs) {
    BinarySentence andTerm = bs.firstTermIsAndSentence() ? (BinarySentence) bs
        .getFirst() : (BinarySentence) bs.getSecond();
    Sentence otherterm = bs.firstTermIsAndSentence() ? bs.getSecond() : bs
        .getFirst();
    // (alpha or (beta and gamma) = ((alpha or beta) and (alpha or gamma))
    Sentence alpha = (Sentence) otherterm.accept(this, null);
    Sentence beta = (Sentence) andTerm.getFirst().accept(this, null);
    Sentence gamma = (Sentence) andTerm.getSecond().accept(this, null);
    Sentence distributed = new BinarySentence("AND", new BinarySentence(
        "OR", alpha, beta), new BinarySentence("OR", alpha, gamma));
    return distributed;
  }
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

      } else if (!isImpliedSentence(sentence)) {
        throw new RuntimeException("Sentence " + sentence
            + " is not a horn clause");

      } else {
        BinarySentence bs = (BinarySentence) sentence;
        head = (Symbol) bs.getSecond();
        inferred.put(head, Boolean.FALSE);
        Set<Symbol> symbolsInPremise = new SymbolCollector()
            .getSymbolsIn(bs.getFirst());
        Iterator<Symbol> iter = symbolsInPremise.iterator();
        while (iter.hasNext()) {
          inferred.put(iter.next(), Boolean.FALSE);
        }
        premiseSymbols = new Converter<Symbol>()
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

      return sentences.get(0);
    } else {
      Sentence soFar = sentences.get(0);
      for (int i = 1; i < sentences.size(); i++) {
        Sentence next = sentences.get(i);
        soFar = new BinarySentence(connector, soFar, next);
      }
      return soFar;
    }
  }
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

   *            the query, a sentence in propositional logic
   *
   * @return the answer to the specified question using PL-Resolution.
   */
  public boolean plResolution(KnowledgeBase kb, Sentence alpha) {
    Sentence kBAndNotAlpha = new BinarySentence("AND", kb.asSentence(),
        new UnarySentence(alpha));
    Set<Sentence> clauses = new CNFClauseGatherer()
        .getClausesFrom(new CNFTransformer().transform(kBAndNotAlpha));
    clauses = filterOutClausesWithTwoComplementaryLiterals(clauses);
    Set<Sentence> newClauses = new HashSet<Sentence>();
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

  private Sentence step(Sentence s) {
    return (Sentence) s.accept(this, null);
  }

  private Sentence transformBiConditionalSentence(BinarySentence bs) {
    Sentence first = new BinarySentence("=>", (Sentence) bs.getFirst()
        .accept(this, null), (Sentence) bs.getSecond().accept(this,
        null));
    Sentence second = new BinarySentence("=>", (Sentence) bs.getSecond()
        .accept(this, null), (Sentence) bs.getFirst()
        .accept(this, null));
    return new BinarySentence("AND", first, second);
  }
View Full Code Here

Examples of aima.core.logic.propositional.parsing.ast.BinarySentence

  }

  private Sentence transformImpliedSentence(BinarySentence bs) {
    Sentence first = new UnarySentence((Sentence) bs.getFirst().accept(
        this, null));
    return new BinarySentence("OR", first, (Sentence) bs.getSecond()
        .accept(this, null));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.