public boolean addTerm(GdlTerm term, Map<GdlVariable, TermModel> varsToModelsMap) {
boolean changesMade = false;
if (term instanceof GdlConstant) {
changesMade = possibleConstants.add((GdlConstant) term);
} else if (term instanceof GdlFunction) {
GdlFunction function = (GdlFunction) term;
NameAndArity sentenceName = new NameAndArity(function);
if (!possibleFunctions.containsKey(sentenceName)) {
changesMade = true;
possibleFunctions.put(sentenceName, getNTermModels(function.arity()));
}
changesMade |= addBodyToModel(possibleFunctions.get(sentenceName), function.getBody(), varsToModelsMap);
} else if (term instanceof GdlVariable) {
changesMade = mergeIn(varsToModelsMap.get(term));
} else {
throw new RuntimeException("Unrecognized term type " + term.getClass() + " for term " + term);
}