private void checkForPossibleAnswers(Set<Clause> resolvents) { // 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)); } } } if (System.currentTimeMillis() > finishTime) { complete = true; // Indicate that I have run out of query time timedOut = true; } } }