Grammar question: A and not B is OR A and not B are?

That’s just:
IF ( A OR B )
ain’t it?

[sub]saith De Morgan[/sub]

Yes, it is and to this day I wonder why the person who had written the code chose to write it the way he did.

My guess? He originally wrote !A and !B, realized he was getting the opposite result as intended and wrote !(!A and !B), without realizing that’s really just A or B.

I assume the OR’s not exclusive?

Nemo hit this one right on the head.

“The ball and not the box” is most commonly used when there’s an expectation that the ball and the box are the same (usually because somebody has mistakenly stated so).

Otherwise, “the ball but not the box” would be used where there’s no prior expectation.

In programming, one typically has both inclusive and exclusive OR operators, but it’s the inclusive one that’s usually called “OR”, and the exclusive one is instead called “XOR”.

The De Morgan dual of “AND”, incidentally, is inclusive OR; that is, NOT((NOT A) AND (NOT B)) does indeed translate to A OR B with inclusive OR. The De Morgan dual of XOR is the negation of XOR, sometimes called XNOR.

While I agree that actually knowing the rules is valuable, this does serve as a helpful rule of thumb. If you are having to use esoteric grammar rules, you are likely using a rather esoteric construction. It is likely that said construction will thus be perceived as awkward, whether this is because it is uncommon, or if it is uncommon because it is awkward.

While the best case would be to learn the rule, then decide on stylistic concerns, it isn’t really lazy if the need for the esoteric rule alerts you to the awkwardness of your statement.

Was there other convoluted code in the program? Could the code have been generated by some kind of automated code generator?

I’m thinking of Ratfor, which took an enhanced version of Fortran source code as its input (which Fortran compilers of the day could not compile), and translated it into proper Fortran that could be compiled. It produced lots of silly stuff like this.

For example, the source construct:
IF ( some condition) THEN
stuff stuff stuff
ENDIF

got translated to:
IF ( .NOT. (some condition) ) GOTO 500
stuff stuff stuff
500 CONTINUE

If you had complicated conditional expressions, it could get real weird.

The negation of XOR is commonly called EQV. Is XNOR just the same as that?

“OR” and “AND” may not have the same meanings in “plain english” as they do in logic and programming. In particular, OR in everyday usage is often understood to mean exclusive or, as in:
“I will go to the movie or I will go to the opera.” – That seems to mean: will go to either the movie or the opera (but not both). In law, this is the usual meaning. If you mean “A or B or both”, you need to SAY (or write) “A or B or both”.

Yes, XNOR is the same as EQV.

Actually, what I should say is this:

The De Morgan dual of n-ary XOR is the (n + 1)-ary negation of XOR. When n is odd, this is just n-ary XOR itself (which comes out true just in case an odd number of its inputs are true). When n is even, this is the negation of n-ary XOR, sometimes called n-ary XNOR (which comes out true just in case an even number of its inputs are true).

In the particular case where n = 2, we have binary XNOR, which is equivalent to binary EQV. (It comes out true just in case its two inputs are equal).

Also, the assertion is also made that English “OR” by default means “exclusive OR”, but this does not seem supported by the examples typically used.

For example, if you told me “I will go to the movies or I will go to the opera”, and then you happened to go to both, I would not ordinarily consider you to have lied, even if the implicature had been that you would go to only one.

I have no idea, but I don’t think so. It seems it was just his style of coding.

Because the principle of grammar is that you can say anything you want and still make it grammatically correct. It is never necessary to reword a sentence in order to apply a grammatical rule to it.

Grammar is not the same as Syntax. It is a syntax rule, for example, that you cannot end a sentence with a preposition. That has nothing to do with grammar, and a sentence can be grammatically correct, even if it ends with a preposition. Grammar only requires that persons, genders, tenses, etc, are all consistent throughout the sentence.

Without changing the sentence, the problem is easily solved by using a singular verb when there is a singular subject, which is “the ball”.

That’s a fallacy that many people have problems with.

It’s a prescription that didn’t even appear until the 1700s with which to start.

A foolish idea that originated from scholars trying to apply the rules of Latin to the English language.

You’re talking about the rule that you should never use a preposition to end a sentence with, right?

[sub]Hey! I’m legit! I didn’t end use a preposition to end the above sentence with![/sub]

Similarly, the admonition not to ever split an infinitive comes from overly purist English teachers trying to prissily apply Latin grammar. In Latin of course, and other languages derived therefrom, you can’t split an infinitive because it’s all one word! In English, that space in the middle of an infinitive is often the most natural-sounding place to easily stick a modifier!

And, now let’s talk about double negatives. In English, you shouldn’t never use double negatives. I’ll go along so far as to agree it’s usually a lousy idea, producing awkward sentences. But why? My 8th grade teacher gave a reason that I think was just wrong: LOGIC! Two negatives make a positive! Straight from Algebra or something! “You shouldn’t never use a double negative” means you should ALWAYS use a double negative!

Even then, I called baloney. Two negatives can just as well be even MORE negative! (Hey, that’s Algebra too.) A double negative might be used as a more intensive negative. Besides, who ever said language is logical? Double negatives were quite acceptable in the limited French that I learned.

Huh? Do you mean that grammar is only about consistency? Which meaning of “grammar” excludes syntax, and where did you find it?

Grammar is fundamentally just a very intricate system of conventions. Logic–something very different from convention—often can’t explain grammar (though it sometimes is helpful for keeping track of some of the conventions of grammar). It’s silly to think that you can come to a definite decision about an ambiguous grammatical point by sheer dint of logic.

This is why, for example, a word like family is singular in the U.S. and plural in Britain. That’s simply a grammatical convention, and can’t be explained, justified or better understood by way of formal logic.

Exactly. Double negatives are wrong in English. But they’re normal and acceptable in Spanish.

However, some misguided language purist applying the rules of English to Spanish might foolishly insist that no Spanish speaker use a double negative. It’s certainly possible to construct Spanish sentences without double negatives. But it’s unnecessary and such a rule would prohibit plenty of grammatically correct Spanish sentences.

The way I see it is that rules like this do not originate from scholars but from people with a limited knowledge who want to set things in an orderly manner to make them fit within their own narrow minds.

Besides, I don’t know Latin, but if I understand correctly word order doesn’t matter, so wouldn’t this rule be erroneous anyway?

But two positives do not make a negative.

Yeah, right.

Same thing with Polish (and other Slavic languages). Negative agreement/concord is the norm, so you have sentences that, literally translated, come out to “I never didn’t have nothing” when formal English would have “I never had anything.” (Double/multiple negatives show up routinely in various dialects of English, too.) Language is not math or logic.