Package aima.core.logic.fol.kb.data

Examples of aima.core.logic.fol.kb.data.Literal


  // Note: To support FOL-FC-Ask
  public Set<Map<Variable, Term>> fetch(List<Literal> literals) {
    Set<Map<Variable, Term>> possibleSubstitutions = new LinkedHashSet<Map<Variable, Term>>();

    if (literals.size() > 0) {
      Literal first = literals.get(0);
      List<Literal> rest = literals.subList(1, literals.size());

      recursiveFetch(new LinkedHashMap<Variable, Term>(), first, rest,
          possibleSubstitutions);
    }
View Full Code Here


    for (Variable v : vars) {
      // Ensure copies of the variables are used.
      terms.add(v.copy());
    }

    return new Literal(new Predicate(alName, terms));
  }
View Full Code Here

        // This means I am at the end of the chain of predicates
        // and have found a valid substitution.
        possibleSubstitutions.add(psubst);
      } else {
        // Need to move to the next link in the chain of substitutions
        Literal first = remainingLiterals.get(0);
        List<Literal> rest = remainingLiterals.subList(1,
            remainingLiterals.size());

        recursiveFetch(psubst, first, rest, possibleSubstitutions);
      }
View Full Code Here

      throw new IllegalArgumentException(
          "Only Atomic Queries are supported.");
    }

    List<Literal> goals = new ArrayList<Literal>();
    goals.add(new Literal((AtomicSentence) query));

    BCAskAnswerHandler ansHandler = new BCAskAnswerHandler();

    List<List<ProofStepBwChGoal>> allProofSteps = folbcask(KB, ansHandler,
        goals, new HashMap<Variable, Term>());
View Full Code Here

      thisLevelProofSteps.add(new ArrayList<ProofStepBwChGoal>());
      return thisLevelProofSteps;
    }

    // qDelta <- SUBST(theta, FIRST(goals))
    Literal qDelta = KB.subst(theta, goals.get(0));

    // for each sentence r in KB where
    // STANDARDIZE-APART(r) = (p1 ^ ... ^ pn => q)
    for (Clause r : KB.getAllDefiniteClauses()) {
      r = KB.standardizeApart(r);
      // and thetaDelta <- UNIFY(q, qDelta) succeeds
      Map<Variable, Term> thetaDelta = KB.unify(r.getPositiveLiterals()
          .get(0).getAtomicSentence(), qDelta.getAtomicSentence());
      if (null != thetaDelta) {
        // new_goals <- [p1,...,pn|REST(goals)]
        List<Literal> newGoals = new ArrayList<Literal>(
            r.getNegativeLiterals());
        newGoals.addAll(goals.subList(1, goals.size()));
View Full Code Here

    if (isUseParamodulation()) {
      // Reflexivity Axiom: x = x
      TermEquality reflexivityAxiom = new TermEquality(new Variable("x"),
          new Variable("x"));
      Clause reflexivityClause = new Clause();
      reflexivityClause.addLiteral(new Literal(reflexivityAxiom));
      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());
    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();
        sos.addAll(c.getFactors());
View Full Code Here

    }
  }

  // Returns c if no cancellation occurred
  private Chain tryCancellation(Chain c) {
    Literal head = c.getHead();
    if (null != head && !(head instanceof ReducedLiteral)) {
      for (Literal l : c.getTail()) {
        if (l instanceof ReducedLiteral) {
          // if they can be resolved
          if (head.isNegativeLiteral() != l.isNegativeLiteral()) {
            Map<Variable, Term> subst = unifier
                .unify(head.getAtomicSentence(),
                    l.getAtomicSentence());
            if (null != subst) {
              // I have a cancellation
              // Need to apply subst to all of the
              // literals in the cancellation
View Full Code Here

    return c;
  }

  // Returns c if no dropping occurred
  private Chain tryDropping(Chain c) {
    Literal head = c.getHead();
    if (null != head && (head instanceof ReducedLiteral)) {
      Chain dropped = new Chain(c.getTail());
      dropped.setProofStep(new ProofStepChainDropped(dropped, c));
      return dropped;
    }
View Full Code Here

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

  public IndexedFarParents(List<Chain> sos, List<Chain> background) {
    constructInternalDataStructures(sos, background);
  }

  public int getNumberFarParents(Chain farParent) {
    Literal head = farParent.getHead();

    Map<String, List<Chain>> heads = null;
    if (head.isPositiveLiteral()) {
      heads = posHeads;
    } else {
      heads = negHeads;
    }
    String headKey = head.getAtomicSentence().getSymbolicName();

    List<Chain> farParents = heads.get(headKey);
    if (null != farParents) {
      return farParents.size();
    }
View Full Code Here

TOP

Related Classes of aima.core.logic.fol.kb.data.Literal

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.