if (negated instanceof NotSentence) {
return ((NotSentence) negated).getNegated().accept(this, arg);
}
if (negated instanceof ConnectedSentence) {
ConnectedSentence negConnected = (ConnectedSentence) negated;
Sentence alpha = negConnected.getFirst();
Sentence beta = negConnected.getSecond();
// ~(alpha ^ beta) equivalent to (~alpha V ~beta) (De Morgan)
if (Connectors.isAND(negConnected.getConnector())) {
// I need to ensure the ~s are moved in deeper
Sentence notAlpha = (Sentence) (new NotSentence(alpha)).accept(
this, arg);
Sentence notBeta = (Sentence) (new NotSentence(beta)).accept(
this, arg);
return new ConnectedSentence(Connectors.OR, notAlpha, notBeta);
}
// ~(alpha V beta) equivalent to (~alpha ^ ~beta) (De Morgan)
if (Connectors.isOR(negConnected.getConnector())) {
// I need to ensure the ~s are moved in deeper
Sentence notAlpha = (Sentence) (new NotSentence(alpha)).accept(
this, arg);
Sentence notBeta = (Sentence) (new NotSentence(beta)).accept(
this, arg);
return new ConnectedSentence(Connectors.AND, notAlpha, notBeta);
}
}
// in addition, rules for negated quantifiers:
if (negated instanceof QuantifiedSentence) {