private Dictionary<Variable, Term> cascadeSubstitutions(FOLKnowledgeBase KB, Dictionary<Variable, Term> theta) { foreach (Variable v in theta.Keys) { Term t = theta[v]; theta.Add(v, KB.subst(theta, t)); } return theta; }