Package aima.core.logic.fol.inference.proof

Examples of aima.core.logic.fol.inference.proof.ProofFinal


    public void setAllProofSteps(List<List<ProofStepBwChGoal>> allProofSteps) {
      for (List<ProofStepBwChGoal> steps : allProofSteps) {
        ProofStepBwChGoal lastStep = steps.get(steps.size() - 1);
        Map<Variable, Term> theta = lastStep.getBindings();
        proofs.add(new ProofFinal(lastStep, theta));
      }
    }
View Full Code Here


    public boolean isAnswer(Clause clause) {
      boolean isAns = false;

      if (answerClause.isEmpty()) {
        if (clause.isEmpty()) {
          proofs.add(new ProofFinal(clause.getProofStep(),
              new HashMap<Variable, Term>()));
          complete = true;
          isAns = true;
        }
      } else {
        if (clause.isEmpty()) {
          // This should not happen
          // as added an answer literal to sos, which
          // implies the database (i.e. premises) are
          // unsatisfiable to begin with.
          throw new IllegalStateException(
              "Generated an empty clause while looking for an answer, implies original KB or usable is unsatisfiable");
        }

        if (clause.isUnitClause()
            && clause.isDefiniteClause()
            && clause
                .getPositiveLiterals()
                .get(0)
                .getAtomicSentence()
                .getSymbolicName()
                .equals(answerLiteral.getAtomicSentence()
                    .getSymbolicName())) {
          Map<Variable, Term> answerBindings = new HashMap<Variable, Term>();
          List<Term> answerTerms = clause.getPositiveLiterals()
              .get(0).getAtomicSentence().getArgs();
          int idx = 0;
          for (Variable v : answerLiteralVariables) {
            answerBindings.put(v, answerTerms.get(idx));
            idx++;
          }
          boolean addNewAnswer = true;
          for (Proof p : proofs) {
            if (p.getAnswerBindings().equals(answerBindings)) {
              addNewAnswer = false;
              break;
            }
          }
          if (addNewAnswer) {
            proofs.add(new ProofFinal(clause.getProofStep(),
                answerBindings));
          }
          isAns = true;
        }
      }
View Full Code Here

    public boolean isAnswer(Chain nearParent) {
      boolean isAns = false;
      if (answerChain.isEmpty()) {
        if (nearParent.isEmpty()) {
          proofs.add(new ProofFinal(nearParent.getProofStep(),
              new HashMap<Variable, Term>()));
          complete = true;
          isAns = true;
        }
      } else {
        if (nearParent.isEmpty()) {
          // This should not happen
          // as added an answer literal to sos, which
          // implies the database (i.e. premises) are
          // unsatisfiable to begin with.
          throw new IllegalStateException(
              "Generated an empty chain while looking for an answer, implies original KB is unsatisfiable");
        }
        if (1 == nearParent.getNumberLiterals()
            && nearParent
                .getHead()
                .getAtomicSentence()
                .getSymbolicName()
                .equals(answerChain.getHead()
                    .getAtomicSentence().getSymbolicName())) {
          Map<Variable, Term> answerBindings = new HashMap<Variable, Term>();
          List<Term> answerTerms = nearParent.getHead()
              .getAtomicSentence().getArgs();
          int idx = 0;
          for (Variable v : answerLiteralVariables) {
            answerBindings.put(v, answerTerms.get(idx));
            idx++;
          }
          boolean addNewAnswer = true;
          for (Proof p : proofs) {
            if (p.getAnswerBindings().equals(answerBindings)) {
              addNewAnswer = false;
              break;
            }
          }
          if (addNewAnswer) {
            proofs.add(new ProofFinal(nearParent.getProofStep(),
                answerBindings));
          }
          isAns = true;
        }
      }
View Full Code Here

      stepFinal = step;
    }

    public void setAnswers(Set<Map<Variable, Term>> answers) {
      for (Map<Variable, Term> ans : answers) {
        proofs.add(new ProofFinal(stepFinal, ans));
      }
    }
View Full Code Here

      // If no bindings being looked for, then
      // is just a true false query.
      for (Clause aClause : resolvents) {
        if (answerClause.isEmpty()) {
          if (aClause.isEmpty()) {
            proofs.add(new ProofFinal(aClause.getProofStep(),
                new HashMap<Variable, Term>()));
            complete = true;
          }
        } else {
          if (aClause.isEmpty()) {
            // This should not happen
            // as added an answer literal, which
            // implies the database (i.e. premises) are
            // unsatisfiable to begin with.
            throw new IllegalStateException(
                "Generated an empty clause while looking for an answer, implies original KB is unsatisfiable");
          }

          if (aClause.isUnitClause()
              && aClause.isDefiniteClause()
              && aClause
                  .getPositiveLiterals()
                  .get(0)
                  .getAtomicSentence()
                  .getSymbolicName()
                  .equals(answerLiteral.getAtomicSentence()
                      .getSymbolicName())) {
            Map<Variable, Term> answerBindings = new HashMap<Variable, Term>();
            List<Term> answerTerms = aClause.getPositiveLiterals()
                .get(0).getAtomicSentence().getArgs();
            int idx = 0;
            for (Variable v : answerLiteralVariables) {
              answerBindings.put(v, answerTerms.get(idx));
              idx++;
            }
            boolean addNewAnswer = true;
            for (Proof p : proofs) {
              if (p.getAnswerBindings().equals(answerBindings)) {
                addNewAnswer = false;
                break;
              }
            }
            if (addNewAnswer) {
              proofs.add(new ProofFinal(aClause.getProofStep(),
                  answerBindings));
            }
          }
        }
View Full Code Here

    public void setAllProofSteps(List<List<ProofStepBwChGoal>> allProofSteps) {
      for (List<ProofStepBwChGoal> steps : allProofSteps) {
        ProofStepBwChGoal lastStep = steps.get(steps.size() - 1);
        Map<Variable, Term> theta = lastStep.getBindings();
        proofs.add(new ProofFinal(lastStep, theta));
      }
    }
View Full Code Here

    public boolean isAnswer(Clause aClause) {
      boolean isAns = false;

      if (answerClause.isEmpty()) {
        if (aClause.isEmpty()) {
          proofs.add(new ProofFinal(aClause.getProofStep(),
              new HashMap<Variable, Term>()));
          complete = true;
          isAns = true;
        }
      } else {
        if (aClause.isEmpty()) {
          // This should not happen
          // as added an answer literal to sos, which
          // implies the database (i.e. premises) are
          // unsatisfiable to begin with.
          throw new IllegalStateException(
              "Generated an empty clause while looking for an answer, implies original KB or usable is unsatisfiable");
        }

        if (aClause.isUnitClause()
            && aClause.isDefiniteClause()
            && aClause
                .getPositiveLiterals()
                .get(0)
                .getAtomicSentence()
                .getSymbolicName()
                .equals(answerLiteral.getAtomicSentence()
                    .getSymbolicName())) {
          Map<Variable, Term> answerBindings = new HashMap<Variable, Term>();
          List<Term> answerTerms = aClause.getPositiveLiterals()
              .get(0).getAtomicSentence().getArgs();
          int idx = 0;
          for (Variable v : answerLiteralVariables) {
            answerBindings.put(v, answerTerms.get(idx));
            idx++;
          }
          boolean addNewAnswer = true;
          for (Proof p : proofs) {
            if (p.getAnswerBindings().equals(answerBindings)) {
              addNewAnswer = false;
              break;
            }
          }
          if (addNewAnswer) {
            proofs.add(new ProofFinal(aClause.getProofStep(),
                answerBindings));
          }
          isAns = true;
        }
      }
View Full Code Here

    public boolean isAnswer(Chain nearParent) {
      boolean isAns = false;
      if (answerChain.isEmpty()) {
        if (nearParent.isEmpty()) {
          proofs.add(new ProofFinal(nearParent.getProofStep(),
              new HashMap<Variable, Term>()));
          complete = true;
          isAns = true;
        }
      } else {
        if (nearParent.isEmpty()) {
          // This should not happen
          // as added an answer literal to sos, which
          // implies the database (i.e. premises) are
          // unsatisfiable to begin with.
          throw new IllegalStateException(
              "Generated an empty chain while looking for an answer, implies original KB is unsatisfiable");
        }
        if (1 == nearParent.getNumberLiterals()
            && nearParent
                .getHead()
                .getAtomicSentence()
                .getSymbolicName()
                .equals(answerChain.getHead()
                    .getAtomicSentence().getSymbolicName())) {
          Map<Variable, Term> answerBindings = new HashMap<Variable, Term>();
          List<Term> answerTerms = nearParent.getHead()
              .getAtomicSentence().getArgs();
          int idx = 0;
          for (Variable v : answerLiteralVariables) {
            answerBindings.put(v, answerTerms.get(idx));
            idx++;
          }
          boolean addNewAnswer = true;
          for (Proof p : proofs) {
            if (p.getAnswerBindings().equals(answerBindings)) {
              addNewAnswer = false;
              break;
            }
          }
          if (addNewAnswer) {
            proofs.add(new ProofFinal(nearParent.getProofStep(),
                answerBindings));
          }
          isAns = true;
        }
      }
View Full Code Here

      stepFinal = step;
    }

    public void setAnswers(Set<Map<Variable, Term>> answers) {
      for (Map<Variable, Term> ans : answers) {
        proofs.add(new ProofFinal(stepFinal, ans));
      }
    }
View Full Code Here

TOP

Related Classes of aima.core.logic.fol.inference.proof.ProofFinal

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.