private boolean satisfies(Map<GdlVariable, GdlConstant> assignment,
GdlLiteral literal, SetMultimap<SentenceForm, GdlSentence> sentencesSoFar) {
if (literal instanceof GdlSentence) {
return satisfiesSentence(assignment, (GdlSentence) literal, sentencesSoFar);
} else if (literal instanceof GdlNot) {
GdlLiteral body = ((GdlNot) literal).getBody();
if (!(body instanceof GdlSentence)) {
throw new IllegalStateException("Negated literal should be a sentence but isn't: " + body);
}
return !satisfiesSentence(assignment, (GdlSentence) body, sentencesSoFar);
} else if (literal instanceof GdlDistinct) {
return satisfiesDistinct(assignment, (GdlDistinct) literal);
} else if (literal instanceof GdlOr) {
GdlOr or = (GdlOr) literal;
for (int i = 0; i < or.arity(); i++) {
GdlLiteral innerLiteral = or.get(i);
if (satisfies(assignment, innerLiteral, sentencesSoFar)) {
return true;
}
}
return false;