public Object visitQuantifiedSentence(QuantifiedSentence sentence,
Object arg)
{
List<Variable> seenSoFar = (List<Variable>)arg;
// Keep track of what I have to subst locally and
// what my renamed variables will be.
Dictionary<Variable, Term> localSubst = new Dictionary<Variable, Term>();
List<Variable> replVariables = new List<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.Add(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.AddRange(replVariables);
Sentence sQuantified = (Sentence)subst.accept(this, arg);
return new QuantifiedSentence(sentence.getQuantifier(), replVariables,
sQuantified);
}
}