// Note: see page 327. public StandardizeApartResult standardizeApart(Sentence sentence, StandardizeApartIndexical standardizeApartIndexical) { List <Variable> toRename = variableCollector.collectAllVariables(sentence); Dictionary <Variable, Term> renameSubstitution = new Dictionary <Variable, Term>(); Dictionary <Variable, Term> reverseSubstitution = 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); reverseSubstitution.Add(v, var); } Sentence standardized = substVisitor.subst(renameSubstitution, sentence); return(new StandardizeApartResult(sentence, standardized, renameSubstitution, reverseSubstitution)); }
public Clause standardizeApart(Clause clause, StandardizeApartIndexical standardizeApartIndexical) { List <Variable> toRename = variableCollector.collectAllVariables(clause); Dictionary <Variable, Term> renameSubstitution = new Dictionary <Variable, Term>(); foreach (Variable var in toRename) { Variable v; 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[var] = v; } if (renameSubstitution.Count > 0) { List <Literal> literals = new List <Literal>(); foreach (Literal l in clause.getLiterals()) { literals.Add(substVisitor.subst(renameSubstitution, l)); } Clause renamed = new Clause(literals); renamed.setProofStep(new ProofStepRenaming(renamed, clause .getProofStep())); return(renamed); } return(clause); }
public Clause standardizeApart(Clause clause, StandardizeApartIndexical standardizeApartIndexical) { ISet <Variable> toRename = variableCollector.collectAllVariables(clause); IMap <Variable, Term> renameSubstitution = CollectionFactory.CreateInsertionOrderedMap <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.Put(var, v); } if (renameSubstitution.Size() > 0) { ICollection <Literal> literals = CollectionFactory.CreateQueue <Literal>(); foreach (Literal l in clause.getLiterals()) { literals.Add(substVisitor.subst(renameSubstitution, l)); } Clause renamed = new Clause(literals); renamed.setProofStep(new ProofStepRenaming(renamed, clause.getProofStep())); return(renamed); } return(clause); }
// Note: see page 327. public StandardizeApartResult standardizeApart(Sentence aSentence, StandardizeApartIndexical standardizeApartIndexical) { List<Variable> toRename = variableCollector .collectAllVariables(aSentence); Dictionary<Variable, Term> renameSubstitution = new Dictionary<Variable, Term>(); Dictionary<Variable, Term> reverseSubstitution = 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); reverseSubstitution.Add(v, var); } Sentence standardized = substVisitor.subst(renameSubstitution, aSentence); return new StandardizeApartResult(aSentence, standardized, renameSubstitution, reverseSubstitution); }
public Dictionary <Variable, Term> standardizeApart(List <Literal> l1Literals, List <Literal> l2Literals, StandardizeApartIndexical standardizeApartIndexical) { List <Variable> toRename = new List <Variable>(); foreach (Literal pl in l1Literals) { toRename.AddRange(variableCollector.collectAllVariables(pl .getAtomicSentence())); } foreach (Literal nl in l2Literals) { toRename.AddRange(variableCollector.collectAllVariables(nl .getAtomicSentence())); } 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)); if (renameSubstitution.ContainsKey(var)) { renameSubstitution[var] = v; } else { renameSubstitution.Add(var, v); } } List <Literal> posLits = new List <Literal>(); List <Literal> negLits = new List <Literal>(); foreach (Literal pl in l1Literals) { posLits.Add(substVisitor.subst(renameSubstitution, pl)); } foreach (Literal nl in l2Literals) { negLits.Add(substVisitor.subst(renameSubstitution, nl)); } l1Literals.Clear(); l1Literals.AddRange(posLits); l2Literals.Clear(); l2Literals.AddRange(negLits); return(renameSubstitution); }
public IMap <Variable, Term> standardizeApart(ICollection <Literal> l1Literals, ICollection <Literal> l2Literals, StandardizeApartIndexical standardizeApartIndexical) { ISet <Variable> toRename = CollectionFactory.CreateSet <Variable>(); foreach (Literal pl in l1Literals) { toRename.AddAll(variableCollector.collectAllVariables(pl .getAtomicSentence())); } foreach (Literal nl in l2Literals) { toRename.AddAll(variableCollector.collectAllVariables(nl.getAtomicSentence())); } IMap <Variable, Term> renameSubstitution = CollectionFactory.CreateInsertionOrderedMap <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.Put(var, v); } ICollection <Literal> posLits = CollectionFactory.CreateQueue <Literal>(); ICollection <Literal> negLits = CollectionFactory.CreateQueue <Literal>(); foreach (Literal pl in l1Literals) { posLits.Add(substVisitor.subst(renameSubstitution, pl)); } foreach (Literal nl in l2Literals) { negLits.Add(substVisitor.subst(renameSubstitution, nl)); } l1Literals.Clear(); l1Literals.AddAll(posLits); l2Literals.Clear(); l2Literals.AddAll(negLits); return(renameSubstitution); }
public Clause standardizeApart(Clause clause, StandardizeApartIndexical standardizeApartIndexical) { List<Variable> toRename = variableCollector.collectAllVariables(clause); 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)); if (renameSubstitution.ContainsKey(var)) { renameSubstitution[var] = v; } else { renameSubstitution.Add(var, v); } } if (renameSubstitution.Count > 0) { List<Literal> literals = new List<Literal>(); foreach (Literal l in clause.getLiterals()) { literals.Add(substVisitor.subst(renameSubstitution, l)); } Clause renamed = new Clause(literals); renamed.setProofStep(new ProofStepRenaming(renamed, clause .getProofStep())); return renamed; } return clause; }
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 object visitQuantifiedSentence(QuantifiedSentence sentence, object arg) { ISet <Variable> seenSoFar = (Set <Variable>)arg; // Keep track of what I have to subst locally and // what my renamed variables will be. IMap <Variable, Term> localSubst = CollectionFactory.CreateInsertionOrderedMap <Variable, Term>(); ICollection <Variable> replVariables = CollectionFactory.CreateQueue <Variable>(); foreach (Variable v in sentence.getVariables()) { // If local variable has be renamed already // then I need to come up with own name if (seenSoFar.Contains(v)) { Variable sV = new Variable(quantifiedIndexical.getPrefix() + quantifiedIndexical.getNextIndex()); localSubst.Put(v, sV); // Replacement variables should contain new name for variable replVariables.Add(sV); } else { // Not already replaced, this name is good replVariables.Add(v); } } // Apply the local subst Sentence subst = substVisitor.subst(localSubst, sentence.getQuantified()); // Ensure all my existing and replaced variable // names are tracked seenSoFar.AddAll(replVariables); Sentence sQuantified = (Sentence)subst.accept(this, arg); return(new QuantifiedSentence(sentence.getQuantifier(), replVariables, sQuantified)); }
public Dictionary<Variable, Term> standardizeApart(List<Literal> l1Literals, List<Literal> l2Literals, StandardizeApartIndexical standardizeApartIndexical) { List<Variable> toRename = new List<Variable>(); foreach (Literal pl in l1Literals) { toRename.AddRange(variableCollector.collectAllVariables(pl .getAtomicSentence())); } foreach (Literal nl in l2Literals) { toRename.AddRange(variableCollector.collectAllVariables(nl .getAtomicSentence())); } 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)); if (renameSubstitution.ContainsKey(var)) { renameSubstitution[var] = v; } else { renameSubstitution.Add(var, v); } } List<Literal> posLits = new List<Literal>(); List<Literal> negLits = new List<Literal>(); foreach (Literal pl in l1Literals) { posLits.Add(substVisitor.subst(renameSubstitution, pl)); } foreach (Literal nl in l2Literals) { negLits.Add(substVisitor.subst(renameSubstitution, nl)); } l1Literals.Clear(); l1Literals.AddRange(posLits); l2Literals.Clear(); l2Literals.AddRange(negLits); return renameSubstitution; }
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; }