public ProofStepChainContrapositive(Chain contrapositive, Chain contrapositiveOf) { this.contrapositive = contrapositive; this.contrapositiveOf = contrapositiveOf; this.predecessors.Add(contrapositiveOf.getProofStep()); }
public ProofStepChainCancellation(Chain cancellation, Chain cancellationOf, Dictionary<Variable, Term> subst) { this.cancellation = cancellation; this.cancellationOf = cancellationOf; this.subst = subst; this.predecessors.Add(cancellationOf.getProofStep()); }
public ProofStepChainReduction(Chain reduction, Chain nearParent, Chain farParent, Dictionary<Variable, Term> subst) { this.reduction = reduction; this.nearParent = nearParent; this.farParent = farParent; this.subst = subst; this.predecessors.Add(farParent.getProofStep()); this.predecessors.Add(nearParent.getProofStep()); }
public bool isAnswer(Chain nearParent) { bool isAns = false; if (answerChain.isEmpty()) { if (nearParent.isEmpty()) { proofs.Add(new ProofFinal(nearParent.getProofStep(), new Dictionary<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 ApplicationException( "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())) { Dictionary<Variable, Term> answerBindings = new Dictionary<Variable, Term>(); List<FOLNode> answerTerms = nearParent.getHead() .getAtomicSentence().getArgs(); int idx = 0; foreach (Variable v in answerLiteralVariables) { answerBindings.Add(v, (Term) answerTerms[idx]); idx++; } bool addNewAnswer = true; foreach (Proof.Proof p in proofs) { if (p.getAnswerBindings().Equals(answerBindings)) { addNewAnswer = false; break; } } if (addNewAnswer) { proofs.Add(new ProofFinal(nearParent.getProofStep(), answerBindings)); } isAns = true; } } if (DateTime.Now.Ticks > finishTime) { complete = true; // Indicate that I have run out of query time timedOut = true; } return isAns; }
public Chain standardizeApart(Chain chain, StandardizeApartIndexical standardizeApartIndexical) { List<Variable> toRename = variableCollector.collectAllVariables(chain); Dictionary<Variable, Term> renameSubstitution = new Dictionary<Variable, Term>(); foreach (Variable var in toRename) { Variable v = null; do { v = new Variable(standardizeApartIndexical.getPrefix() + standardizeApartIndexical.getNextIndex()); // Ensure the new variable name is not already // accidentally used in the sentence } while (toRename.Contains(v)); renameSubstitution.Add(var, v); } if (renameSubstitution.Count > 0) { List<Literal> lits = new List<Literal>(); foreach (Literal l in chain.getLiterals()) { AtomicSentence atom = (AtomicSentence)substVisitor.subst( renameSubstitution, l.getAtomicSentence()); lits.Add(l.newInstance(atom)); } Chain renamed = new Chain(lits); renamed.setProofStep(new ProofStepRenaming(renamed, chain .getProofStep())); return renamed; } return chain; }
public ProofStepChainDropped(Chain dropped, Chain droppedOff) { this.dropped = dropped; this.droppedOff = droppedOff; this.predecessors.Add(droppedOff.getProofStep()); }