<h1>Experimental Approach</h1>

<p>This is based on the <a href="https://cseducators.stackexchange.com/a/6308/9097">example given by candied_orange</a>, which I found intriguing because of its simplicity. The example was (slightly edited here):</p>

<blockquote>
  <p>Say I’ve got two coins. They can each take on two states (heads or tails). 
  Flip em both; <code>xor</code> can tell you if they show different states (not-equal coin sides).</p>
</blockquote>

<p>This hypothesis can be empirically verified by a scholar. The coins are physical, everyday objects, which could help to get "in touch" with the topic. Here is what can be observed, by stating the mentioned xor question:</p>

<pre><code>CoinA | CoinB | XOR ("are they different?")
--------------------  
heads | heads | no  
tails | tails | no  
heads | tails | yes  
tails | heads | yes
</code></pre>

<p>In Boolean terms this would of course map to <code>heads=0</code>, <code>tails=1</code>, <code>no=0</code>, <code>yes=1</code> for example.  </p>

<p>Replace "they" in the xor-question with the "coin sides" or "states" or "inputs" as it seems fitting for the explanation. Maybe it makes it clearer when talking about "are they <strong>both/all</strong> different" to underline the "exclusiveness" of <code>xor</code>.</p>

<p>This can also (maybe later on) lead to the awareness that <code>not xor</code> ("not different") is the same as "equality" (<code>==</code> operator) with the paraphrasing question "are they not different (=equal)?". So "all are different" and "all are same" are inverse to each other, logically.</p>

<h1>Paraphrasing XOR</h1>

<p>The thoughts on the subject of the insufficiency to put the meaning of xor into clear words and the suspected unsuitability of using just "or" sentences, <a href="https://cseducators.stackexchange.com/a/6309/9097">posted by Ben I. with comments by Buffy and ctrl-alt-delor</a> lead to the following idea:</p>

<p>To paraphrase the xor operation, you could use "either or" sentences. As in "Either eggs or pancakes?" But this does still not exactly cover it. To make an "exclusiveness" statement about two objects (=inputs) you need a predicate to build a decision, which was stated in the original post and <a href="https://cseducators.stackexchange.com/a/6305/9097">by ctrl-alt-delor in the comments on another question</a>. An example could be: "What is tastier? Either pancakes or eggs?" which optionally/implicitly should state "Pick one exclusive/single option and discard the other. "Both/All" and "None" would not be valid answers then.  </p>

<p>One downside mentioned by Ben I. is, that the predicate of "tastier" does not yield a "true/false" nor a "yes/no" answer, but a "this or that" answer.<br>
Taking the coin example with the "are they different" question yields the desired answer scheme in Boolean terms.</p>

<p>It is quite difficult to find other fitting examples. Imagine having a triangle and a disc cut from paper. The xor questions that come to mind are "Do they both have a sharp tip?", "Which is smaller? The triangle or the disc?", "Are they both made from paper?", "Are they equal?". Each must be carefully evaluated to decide if they generate suited xor statements in Boolean terms.<br>
This can be used as reciprocal exercise to link common language questions to the xor interpretation.</p>

<p>To emphasize the "exclusive" character of xor, it should be made clear, that "if you chose pancakes, you do not get eggs" and vice versa, but this would be the unwanted procedural way of a selection, though.</p>

CC BY-SA 4.0
2020-06-19T14:54:18.060Z
_"So "all are different" and "all are same" are inverse to each other, logically."_ Watch out with your phrasing on the inverses. This is only correct for **two** elements, not for more. In the set `1,1,2`, not all numbers are the same, but not all numbers are different either! Therefore, these two statements are not each other's inverse.
Flater
CC BY-SA 4.0
2020-05-02T15:35:20.720Z
2020-05-03T05:54:12.410Z
2020-05-03T05:54:12.410Z
Antares
<p>The more I think about this, the more that I'm convinced that the <code>or</code> doesn't independently carry the weight of exclusivity in any circumstance <em>outside of choices</em>, and that any exclusivity has to be provided by context of two options that can't coexist.</p>

<p>But the key problem with this for the CS teacher is that in those circumstances, having two <code>true</code> inputs doesn't evaluate to <code>false</code>, it just doesn't make any sense in the first place.  This means that the English <code>or</code> will never truly and entirely carry the intuitive behaviors of <code>xor</code>.</p>

<p>I would love to be proven wrong about this, but I don't think I am.</p>

CC BY-SA 4.0
2020-04-24T20:47:09.763Z
Actually, I'm not sure. I think most (or at least many) uses of _or_ actually have an _xor_ intent. "Pancakes or eggs?" The asker will be surprised if you say both. It generates a laugh.
Buffy
CC BY-SA 4.0
2020-04-24T21:39:23.267Z
@buffy "pancakes or eggs" is selection not the xor predicate. It seems that the same word is used for exclusive selection and inclusive predicate.
ctrl-alt-delor
CC BY-SA 4.0
2020-04-25T13:31:49.960Z
@Buffy Exactly! "Pancakes or eggs" is a perfect example. If you try to turn it to code, it becomes clear it's not analogous to `pancakes != eggs`, but instead it's branching. I don't think that the word "or" can, *by itself*, carry an xor relationship.
Ben I.
CC BY-SA 4.0
2020-04-25T13:35:54.520Z
I'm losing track of the argument here. It isn't a question about whether pancakes _are_ eggs. It about whether "I'm eating" pancakes or eggs or maybe both. It isn't the "thing", but the action. "I'm eating pancakes" can be true or false. Etc. If I"m not making sense, then I don't really understand the meaning or intent of the OP here.
Buffy
CC BY-SA 4.0
2020-04-25T16:54:38.643Z
@Buffy The equivalent code is `if (choosesPancakes) bringPancakes(); else if (choosesEggs) bringEggs();` But "both" makes no sense here, and in any case, there is nothing to indicate that both "both" and "neither" would somehow evaluate to `false`.  Ctrl-alt-delor can correct me if I misunderstood, but I believe he wants a situation where the English "or" is evaluated along the lines of Java's `^` or `!=`, and where the full truth table for $xor$ holds true and makes sense. My contention is that those 4 truth table evaluations (00->0, 01->1, 10->1, 11->0) cannot be held by the word "or".
Ben I.
CC BY-SA 4.0
2020-05-02T07:53:15.720Z
What about using "either or" for paraphrasing xor... would this improve things? As in "Either eggs or pancakes?" -- I think the question must be formed like this: "What is tastier? Either pancakes or eggs? [optionally/implicitly: Pick one exclusive/single option and discard the other!]. "Both" and "None" would not be valid answers then.
Antares
CC BY-SA 4.0
2020-05-02T10:04:26.740Z
@Antares That seems closer to me, though "invalid" is, of course, different from "false", and the word `or` is only holding half of the meaning. That said, it seems to me that the addition of `either` makes it work fairly well.  In the context of this question, your formulation is one of the best possible answers, and shouldn't be buried in a comment. You should really post an answer. :)
Ben I.
CC BY-SA 4.0
2020-04-24T20:27:16.833Z
2020-04-24T20:27:16.833Z
Ben I.
<p>This was fun!  Here are three, and I will update as I think of more:</p>

<ol>
<li><p>You may go on the symphony trip if you are in the music history class or if you are not enrolled in any arts class this semester.</p></li>
<li><p>You want to find people for your cliff-climbing trip? You're in the wrong place.  Ask around in the groups that took the jogging or bike trips up the mountain on Mountain Day, not the group that took the bus trip!</p></li>
<li><p>Whether you got here by some connection to the uppity-ups or just by sheer dumb luck, you're my problem now.</p></li>
</ol>

CC BY-SA 4.0
2020-04-23T14:49:59.327Z
Love the last one, but 1 - 3 seem to be inclusive or, not xor.
Buffy
CC BY-SA 4.0
2020-04-23T14:52:13.010Z
How about "you will pass this class, or not".
Buffy
CC BY-SA 4.0
2020-04-23T14:54:12.047Z
@Buffy That's merely a Boolean, xor requires two Booleans to compare.
Gypsy Spellweaver
CC BY-SA 4.0
2020-04-23T15:04:46.573Z
@GypsySpellweaver, how so? "You will pass this class or you will not pass this class". Clear xor. "You will pass this class or you won't be able to graduate".
Buffy
CC BY-SA 4.0
2020-04-23T15:12:53.393Z
Pass `or` not is a result. What are the two, _exclusive_ conditions which determine the result. Pass `not` graduate is a single input `not`ed.
Gypsy Spellweaver
CC BY-SA 4.0
2020-04-23T16:36:56.943Z
@Buffy A xor not A is true. So yes it is an xor. But also a tautology. Is it a useful phrase? I don't know.
ctrl-alt-delor
CC BY-SA 4.0
2020-04-23T16:41:15.353Z
1 and 2 look like inclusive. But only incidentally. E.g. You can enter if you are tall or short. There are incidental exclusive, that is we would not exclude someone if they were found to be both tall and short.
ctrl-alt-delor
CC BY-SA 4.0
2020-04-23T13:47:28.460Z
2020-04-23T13:47:28.460Z
Ben I.
<p>Here's an example - A 2 way switch</p>

<p>Both 'up'  / both 'down' == off</p>

<p>Single 'down' == on</p>

<p>So, in English, one can perhaps say, "The light is on if switch A is down <code>xor</code> switch B is down" </p>

CC BY-SA 4.0
2020-04-28T12:09:10.247Z
2020-04-28T14:08:15.270Z
2020-04-28T14:08:15.270Z
Suraaj K S
<h2>Parity of a sum</h2>
<p>In other words, when is <code>a+b</code> odd and when is it even?</p>
<p>The sum of two integers (<code>a+b</code>) is odd only if <em>exactly one</em> of the two terms (<code>a</code>, <code>b</code>) is odd. If both <code>a</code> and <code>b</code> are odd, then their sum is even. If both <code>a</code> and <code>b</code> are even, then their sum is also even.</p>
<p>Therefore, when trying to find out if <code>a+b</code> is odd, we need to use an <code>xor</code>:</p>
<pre><code>[A+B is odd] = [A is odd] XOR [B is odd]
</code></pre>
<p>Compare this to multiplication, where we specifically need <strong>both</strong> <code>a</code> and <code>b</code> to be odd if <code>a*b</code> is to be odd.</p>
<pre><code>[A*B is odd] = [A is odd] AND [B is odd]
</code></pre>
<p>Similarly, when we're looking for products that are even, we use the inverse, which is an <code>or</code>:</p>
<pre><code>[A*B is even] = [A is even] OR [B is even]
</code></pre>
<p>At least one of them must be even, but both can be even as well.</p>
<hr />
<p>Just for completion's sake, if we're looking for even sums, then we have to use the much less commonly used <a href="https://en.wikipedia.org/wiki/XNOR_gate" rel="nofollow noreferrer"><code>xnor</code></a> (which is the inverse of <code>xor</code>, where both need to be equal)</p>
<pre><code>[A+B is even] = [A is even] XNOR [B is even]
</code></pre>
<p>This sounds complicated, but it usually usually boils down to an equality check:</p>
<pre><code>[A+B is even] = [A is even] == [B is even]
</code></pre>
<hr />
<p>It's hard to come up with natural examples of an <code>xor</code>, for two main reasons:</p>
<ul>
<li>In natural languages, the word &quot;or&quot; generally refers to <code>xor</code>, but not exclusively so. The difference is implied contextually. Compare the following examples:
<ul>
<li>Do you want to buy many toys or one expensive toy?</li>
<li>Can Tom or Cindy please come to the front desk please.</li>
<li>I like cars that are blue or yellow</li>
<li>It's ambiguous whether I like cars that are blue and yellow, or whether I only like cars that are fully yellow or fully blue (this sentence itself is a compounded example of using &quot;or&quot; and whether it means <code>or</code> or <code>xor</code>).</li>
</ul>
</li>
<li>In real life, <code>xor</code> is actually quite rare, when you already exclude things like choices or binary states</li>
</ul>
<p><code>xor</code> is more commonly encountered in cases where both terms would cancel each other out, as having only one term &quot;active&quot; means that their effect exists and is not canceled out.</p>

CC BY-SA 4.0
2020-06-19T15:47:13.090Z
Example 3 is the only predicate, it is a contracted sentence, of I like cars that are fully blue or fully yellow yellow, and has the meaning I like cars that are fully yellow and cars that are fully blue. And there for has the meaning AND. Examples 1 and 2 are selection not a predicate (selection is usually mutually exclusive, but not in example 2)
ctrl-alt-delor
CC BY-SA 4.0
2020-06-19T15:52:02.407Z
@ctrl-alt-delor: Your assertion that semantical english unambiguously translates to logic simply does not hold true. "and" is used differently as `and` (I like cars and planes != I like vehicles that are both a car and a plane), and "or" is similarly used differently than `or` (cfr all the above examples)
Flater
CC BY-SA 4.0
2020-06-19T16:02:42.770Z
Did I assert that? Sorry for making such a suggestion. As for the 2nd bit, I don't grok it all, but your negative predicate is true of English and of logic. However I agree English is not as formal and unambiguous as logic.
ctrl-alt-delor
CC BY-SA 4.0
2020-06-19T14:43:31.167Z
2020-06-19T15:02:27.727Z
2020-06-19T15:02:27.727Z
Flater
<p>Am I leaving a comment or an answer but not both?</p>

CC BY-SA 4.0
2020-04-30T13:23:15.937Z
Zen moment: it is a comment and an answer.
Ben I.
CC BY-SA 4.0
2020-04-29T23:27:48.097Z
2020-04-29T23:27:48.097Z
philipxy
<p>I am going to the local animal shelter. I will adopt a dog xor I will adopt a cat. (I only plan to adopt one pet.)</p>

CC BY-SA 4.0
2020-04-24T21:36:46.083Z
While this is a use of `or` in english, and it is exclusive. It is not an xor operation. Because it is not a predicate. It is a procedure. It is selection (a branch/if/conditional), not xor.
ctrl-alt-delor
CC BY-SA 4.0
2020-04-28T13:22:02.383Z
@ctrl-alt-delor, I don't see that statement as imperative. I see an assertion about the future. It can be tested after the person who made it returns from the animal shelter. If they return with one dog or one cat, then the assertion was true. If they come back with anything else, then the assertion was false.
Ohm's Lawman
CC BY-SA 4.0
2020-04-29T09:11:37.660Z
@besmirched and if they comeback with both?
ctrl-alt-delor
CC BY-SA 4.0
2020-04-29T11:12:17.820Z
@ctrl-alt-delor Ha ha! While I still disagree with you about whether or not the example is "procedural," I guess I've added another example of how one must be careful when attempting to express the XOR idea in English.
Ohm's Lawman
CC BY-SA 4.0
2020-04-23T19:55:55.827Z
2020-04-23T19:55:55.827Z
paw88789
<p>I can't tell whether I've missed something in the other answers or comments, but the natural language equivalent of XOR is to ask "is there any <em>difference</em>?" </p>

<p>Used in a sentence which follows the broad format of those in the question, you'd be saying something like "the light is on differs-from the door is open", with the compound 'differs-from' element being the XOR operator.</p>

<p>Even in computer science, the XOR and XNOR operators typically go by other aliases, such as Not-Equal and Equal operators, respectively.</p>

CC BY-SA 4.0
2020-04-25T17:00:04.810Z
Yes! "Does this differ from that?" is truly xor.  I don't think that *or* can hold that relationship in English.
Ben I.
CC BY-SA 4.0
2020-05-01T00:06:58.443Z
@BenI. But that particular phrasing lacks a level of quotation. Correct would be, whether x differs from whether y.
philipxy
CC BY-SA 4.0
2020-06-19T15:02:35.660Z
@Flater, `!=` *is* `xor`! The distinction between the return values of the bitwise and logical operators when applied to bit arrays, was out of scope. I'd be happy to provide a comprehensive answer if you asked for a deeper explanation.
Steve
CC BY-SA 4.0
2020-04-25T14:55:08.753Z
2020-04-25T14:55:08.753Z
Steve
<p>Say I’ve got two coins. They can each take on two states (heads or tails). Flip em both; <code>xor</code> can tell you if they are different (not-equal).</p>

<p>The name has exclusive in it because when xor is yes/1/true, the heads are exclusive. That is, one head excludes the other. This is also true for the tails.</p>

CC BY-SA 4.0
2020-05-03T05:31:07.387Z
I liked your simple and easy to understand example! (+1) Sorry for editing your answer too much. I extracted my changes and made it another answer based on yours, as was suggested to me. I hope I have restored your text without mistake.
Antares
CC BY-SA 4.0
2020-05-03T05:34:07.510Z
@Antares it's all good.
candied_orange
CC BY-SA 4.0
2020-04-24T12:09:05.753Z
2020-05-02T19:58:25.987Z
2020-05-02T19:58:25.987Z
candied_orange
<p>Let me give a not-answer that may be just about as valuable as an answer. Natural language is ambiguous. Many uses of <em>or</em> in natural language have an <em>xor</em> intent. Your intention, I expect, is to make the lesson clear that the meaning of these two computing operators isn't the same. </p>

<p>It may actually be more dramatic if you use examples that explore the ambiguity in natural language and contrast it with the specific (logic based) meaning in programming that will get the message across more dramatically than simple examples where natural language seems to do the right thing. </p>

<p>So, the answer to "Would you like bacon or sausage?" is "yes - both". And people chuckle (assuming no ethnic or religious restrictions, of course). But the distinction between inclusive and exclusive or is easy to teach noting that we try to avoid such ambiguous constructs in programming languages. </p>

CC BY-SA 4.0
2020-04-24T20:53:34.917Z
2020-04-24T20:53:34.917Z
Buffy
<p>I have been trying to think of an example of <code>xor</code> to connect with what students already know. I did some searches. But everything I found, seems to have unconsciously switched to procedural.</p>

<p>For example:
They say for <code>and</code> "the lights are on and my eyes are open".
But when they get to <code>xor</code>, they say "Choose this xor choose that". This is not a boolean predicate that evaluates to <code>true</code> or <code>false</code>. This is a selection.</p>

<p>So the question:
Can you provide an example of use of <code>xor</code> in a boolean statement, that is accessible to students, that are new to boolean?</p>

<p>I am not yet interested in all the beautiful things that can be done with xor. That is easy. At this stage I am trying to connect to what we say in English language.</p>

CC BY-SA 4.0
2020-04-23T08:01:23.410Z
Related but not the same: https://cseducators.stackexchange.com/q/3038/204
ctrl-alt-delor
CC BY-SA 4.0
2020-04-23T10:28:27.257Z
I'm not sure I understand. In natural language most usages of "or" have an "xor" implication. "Give me liberty xor give me death". Is that what you mean or do I miss something?
Buffy
CC BY-SA 4.0
2020-04-23T10:36:10.803Z
That what all the statements that I found are like. However they have switched from predicates (statements that are true of false), to options or procedures. Can you ask is this statement true or false "Give me liberty xor give me death". It is like asking if "go for a run" is true or false. It is the wrong part of speech: An imperative statement (do this). Not a predicate that can be embedded into a question. You can not say "Are you Give me liberty xor give me death?"
ctrl-alt-delor
CC BY-SA 4.0
2020-04-23T10:44:15.330Z
I still don't understand, since your "and" example isn''t boolean. I'm just confused about what you need here.
Buffy
CC BY-SA 4.0
2020-04-23T10:56:24.197Z
The and example "the lights are on and my eyes are open" is a predicate. You can say that it is true or false. At this time it is true, but then I close my eyes and it is false.
ctrl-alt-delor
CC BY-SA 4.0
2020-04-23T11:07:30.907Z
Actually, though, when said by a natural language speaker it is taken as a statement of fact. I.e. True. But to warp natural language why not "the lights are on xor my eyes are open". Though a speaker would probably use "or" when meaning "xor".
Buffy
CC BY-SA 4.0
2020-04-23T11:18:56.463Z
When someone asks me "Would you like pancakes or eggs" my answer might just be "yes".
Buffy
CC BY-SA 4.0
2020-04-23T13:29:25.823Z
multiway switching? https://en.wikipedia.org/wiki/Multiway_switching
Michel Billaud
CC BY-SA 4.0
2020-04-23T13:34:09.833Z
Good luck! IMO, the trouble you're having is that XOR is an unfamiliar concept to most people. It's easy to construct an English language assertion that uses it. E.g.; "Either my house has five rooms or my house is painted red, but both of those things are not true." That's declarative, and it's testable, and it's completely unlike anything that anybody ever says outside of the context of some logic puzzle.
Solomon Slow
CC BY-SA 4.0
2020-04-23T15:15:03.867Z
Multiway, esp. 3-way is the example I'm always drawn to. Both switches are Boolean (up or down) and the light is the resultant Boolean (on or off).
Gypsy Spellweaver
CC BY-SA 4.0
2020-04-23T15:17:04.627Z
I'm thinking that the _natural language_ examples will end up not being naturally `xor`, rather they will be `(A and not B) or (not A and B)`.
Gypsy Spellweaver
CC BY-SA 4.0
2020-04-23T16:44:02.053Z
So far @MichelBillaud's light switches is the only example that meets the criteria. Maybe also buffy's tortology. solomonslow's observation seems to be true.
ctrl-alt-delor
CC BY-SA 4.0
2020-04-25T11:00:03.817Z
Actually, there's a problem with, say, unique choice questions. You have to tick A, B, or C, but only one of them. That's not  A xor B xor C.
Michel Billaud
CC BY-SA 4.0
2020-04-29T23:26:03.783Z
Am I leaving a comment or an answer but not both?
philipxy
CC BY-SA 4.0
2020-04-29T23:31:58.380Z
@ctrl-alt-delor I guess a tortology is a tortuous tautology? Sounds perfect for this question.
philipxy
<boolean-algebra>
A beginner example of xor, that is functional (does not switch to procedural)
# A beginner example of xor, that is functional (does not switch to procedural)

(Asked by: username_0 on 2020-04-23)

I have been trying to think of an example of `xor` to connect with what students already know. I did some searches. But everything I found, seems to have unconsciously switched to procedural.

For example:
They say for `and` "the lights are on and my eyes are open".
But when they get to `xor`, they say "Choose this xor choose that". This is not a boolean predicate that evaluates to `true` or `false`. This is a selection.

So the question:
Can you provide an example of use of `xor` in a boolean statement, that is accessible to students, that are new to boolean?

I am not yet interested in all the beautiful things that can be done with xor. That is easy. At this stage I am trying to connect to what we say in English language.

**Tags:** boolean-algebra

> **Comments:**
> **username_0**: Related but not the same: https://cseducators.stackexchange.com/q/3038/204  
> **username_1**: I'm not sure I understand. In natural language most usages of "or" have an "xor" implication. "Give me liberty xor give me death". Is that what you mean or do I miss something?  
> **username_0**: That what all the statements that I found are like. However they have switched from predicates (statements that are true of false), to options or procedures. Can you ask is this statement true or false "Give me liberty xor give me death". It is like asking if "go for a run" is true or false. It is the wrong part of speech: An imperative statement (do this). Not a predicate that can be embedded into a question. You can not say "Are you Give me liberty xor give me death?"  
> **username_1**: I still don't understand, since your "and" example isn''t boolean. I'm just confused about what you need here.  
> **username_0**: The and example "the lights are on and my eyes are open" is a predicate. You can say that it is true or false. At this time it is true, but then I close my eyes and it is false.  
> **username_1**: Actually, though, when said by a natural language speaker it is taken as a statement of fact. I.e. True. But to warp natural language why not "the lights are on xor my eyes are open". Though a speaker would probably use "or" when meaning "xor".  
> **username_1**: When someone asks me "Would you like pancakes or eggs" my answer might just be "yes".  
> **username_2**: multiway switching? https://en.wikipedia.org/wiki/Multiway_switching  
> **username_3**: Good luck! IMO, the trouble you're having is that XOR is an unfamiliar concept to most people. It's easy to construct an English language assertion that uses it. E.g.; "Either my house has five rooms or my house is painted red, but both of those things are not true." That's declarative, and it's testable, and it's completely unlike anything that anybody ever says outside of the context of some logic puzzle.  
> **username_4**: Multiway, esp. 3-way is the example I'm always drawn to. Both switches are Boolean (up or down) and the light is the resultant Boolean (on or off).  
> **username_4**: I'm thinking that the _natural language_ examples will end up not being naturally `xor`, rather they will be `(A and not B) or (not A and B)`.  
> **username_0**: So far @MichelBillaud's light switches is the only example that meets the criteria. Maybe also buffy's tortology. solomonslow's observation seems to be true.  
> **username_2**: Actually, there's a problem with, say, unique choice questions. You have to tick A, B, or C, but only one of them. That's not  A xor B xor C.  
> **username_5**: Am I leaving a comment or an answer but not both?  
> **username_5**: @username_0 I guess a tortology is a tortuous tautology? Sounds perfect for this question.  

---

## 10 answers

### Answer by username_12 on 2020-04-25. Score: 4

I can't tell whether I've missed something in the other answers or comments, but the natural language equivalent of XOR is to ask "is there any *difference*?"

Used in a sentence which follows the broad format of those in the question, you'd be saying something like "the light is on differs-from the door is open", with the compound 'differs-from' element being the XOR operator.

Even in computer science, the XOR and XNOR operators typically go by other aliases, such as Not-Equal and Equal operators, respectively.

> **Comments:**
> **username_8**: Yes! "Does this differ from that?" is truly xor.  I don't think that *or* can hold that relationship in English.  
> **username_5**: @BenI. But that particular phrasing lacks a level of quotation. Correct would be, whether x differs from whether y.  
> **username_12**: @username_7, `!=` *is* `xor`! The distinction between the return values of the bitwise and logical operators when applied to bit arrays, was out of scope. I'd be happy to provide a comprehensive answer if you asked for a deeper explanation.  

---

### Answer by username_13 on 2020-04-24. Score: 3

Say I’ve got two coins. They can each take on two states (heads or tails). Flip em both; `xor` can tell you if they are different (not-equal).

The name has exclusive in it because when xor is yes/1/true, the heads are exclusive. That is, one head excludes the other. This is also true for the tails.

> **Comments:**
> **username_6**: I liked your simple and easy to understand example! (+1) Sorry for editing your answer too much. I extracted my changes and made it another answer based on yours, as was suggested to me. I hope I have restored your text without mistake.  
> **username_13**: @username_6 it's all good.  

---

### Answer by username_1 on 2020-04-24. Score: 3

Let me give a not-answer that may be just about as valuable as an answer. Natural language is ambiguous. Many uses of *or* in natural language have an *xor* intent. Your intention, I expect, is to make the lesson clear that the meaning of these two computing operators isn't the same.

It may actually be more dramatic if you use examples that explore the ambiguity in natural language and contrast it with the specific (logic based) meaning in programming that will get the message across more dramatically than simple examples where natural language seems to do the right thing.

So, the answer to "Would you like bacon or sausage?" is "yes - both". And people chuckle (assuming no ethnic or religious restrictions, of course). But the distinction between inclusive and exclusive or is easy to teach noting that we try to avoid such ambiguous constructs in programming languages.


---

### Answer by username_6 on 2020-05-02. Score: 2

Experimental Approach
This is based on the example given by username_13, which I found intriguing because of its simplicity. The example was (slightly edited here):

Say I’ve got two coins. They can each take on two states (heads or tails). 
  Flip em both; xor can tell you if they show different states (not-equal coin sides).

This hypothesis can be empirically verified by a scholar. The coins are physical, everyday objects, which could help to get "in touch" with the topic. Here is what can be observed, by stating the mentioned xor question:
CoinA | CoinB | XOR ("are they different?")
--------------------  
heads | heads | no  
tails | tails | no  
heads | tails | yes  
tails | heads | yes

In Boolean terms this would of course map to heads=0, tails=1, no=0, yes=1 for example.  
Replace "they" in the xor-question with the "coin sides" or "states" or "inputs" as it seems fitting for the explanation. Maybe it makes it clearer when talking about "are they both/all different" to underline the "exclusiveness" of xor.
This can also (maybe later on) lead to the awareness that not xor ("not different") is the same as "equality" (== operator) with the paraphrasing question "are they not different (=equal)?". So "all are different" and "all are same" are inverse to each other, logically.
Paraphrasing XOR
The thoughts on the subject of the insufficiency to put the meaning of xor into clear words and the suspected unsuitability of using just "or" sentences, posted by username_8 with comments by username_1 and username_0 lead to the following idea:
To paraphrase the xor operation, you could use "either or" sentences. As in "Either eggs or pancakes?" But this does still not exactly cover it. To make an "exclusiveness" statement about two objects (=inputs) you need a predicate to build a decision, which was stated in the original post and by username_0 in the comments on another question. An example could be: "What is tastier? Either pancakes or eggs?" which optionally/implicitly should state "Pick one exclusive/single option and discard the other. "Both/All" and "None" would not be valid answers then.  
One downside mentioned by username_8 is, that the predicate of "tastier" does not yield a "true/false" nor a "yes/no" answer, but a "this or that" answer.
Taking the coin example with the "are they different" question yields the desired answer scheme in Boolean terms.
It is quite difficult to find other fitting examples. Imagine having a triangle and a disc cut from paper. The xor questions that come to mind are "Do they both have a sharp tip?", "Which is smaller? The triangle or the disc?", "Are they both made from paper?", "Are they equal?". Each must be carefully evaluated to decide if they generate suited xor statements in Boolean terms.
This can be used as reciprocal exercise to link common language questions to the xor interpretation.
To emphasize the "exclusive" character of xor, it should be made clear, that "if you chose pancakes, you do not get eggs" and vice versa, but this would be the unwanted procedural way of a selection, though.

> **Comments:**
> **username_7**: _"So "all are different" and "all are same" are inverse to each other, logically."_ Watch out with your phrasing on the inverses. This is only correct for **two** elements, not for more. In the set `1,1,2`, not all numbers are the same, but not all numbers are different either! Therefore, these two statements are not each other's inverse.  

---

### Answer by username_8 on 2020-04-24. Score: 2

The more I think about this, the more that I'm convinced that the `or` doesn't independently carry the weight of exclusivity in any circumstance *outside of choices*, and that any exclusivity has to be provided by context of two options that can't coexist.

But the key problem with this for the CS teacher is that in those circumstances, having two `true` inputs doesn't evaluate to `false`, it just doesn't make any sense in the first place. This means that the English `or` will never truly and entirely carry the intuitive behaviors of `xor`.

I would love to be proven wrong about this, but I don't think I am.

> **Comments:**
> **username_1**: Actually, I'm not sure. I think most (or at least many) uses of _or_ actually have an _xor_ intent. "Pancakes or eggs?" The asker will be surprised if you say both. It generates a laugh.  
> **username_0**: @buffy "pancakes or eggs" is selection not the xor predicate. It seems that the same word is used for exclusive selection and inclusive predicate.  
> **username_8**: @username_1 Exactly! "Pancakes or eggs" is a perfect example. If you try to turn it to code, it becomes clear it's not analogous to `pancakes != eggs`, but instead it's branching. I don't think that the word "or" can, *by itself*, carry an xor relationship.  
> **username_1**: I'm losing track of the argument here. It isn't a question about whether pancakes _are_ eggs. It about whether "I'm eating" pancakes or eggs or maybe both. It isn't the "thing", but the action. "I'm eating pancakes" can be true or false. Etc. If I"m not making sense, then I don't really understand the meaning or intent of the OP here.  
> **username_8**: @username_1 The equivalent code is `if (choosesPancakes) bringPancakes(); else if (choosesEggs) bringEggs();` But "both" makes no sense here, and in any case, there is nothing to indicate that both "both" and "neither" would somehow evaluate to `false`.  Ctrl-alt-delor can correct me if I misunderstood, but I believe he wants a situation where the English "or" is evaluated along the lines of Java's `^` or `!=`, and where the full truth table for $xor$ holds true and makes sense. My contention is that those 4 truth table evaluations (00->0, 01->1, 10->1, 11->0) cannot be held by the word "or".  
> **username_6**: What about using "either or" for paraphrasing xor... would this improve things? As in "Either eggs or pancakes?" -- I think the question must be formed like this: "What is tastier? Either pancakes or eggs? [optionally/implicitly: Pick one exclusive/single option and discard the other!]. "Both" and "None" would not be valid answers then.  
> **username_8**: @username_6 That seems closer to me, though "invalid" is, of course, different from "false", and the word `or` is only holding half of the meaning. That said, it seems to me that the addition of `either` makes it work fairly well.  In the context of this question, your formulation is one of the best possible answers, and shouldn't be buried in a comment. You should really post an answer. :)  

---

### Answer by username_8 on 2020-04-23. Score: 2

This was fun! Here are three, and I will update as I think of more:

1. You may go on the symphony trip if you are in the music history class or if you are not enrolled in any arts class this semester.
2. You want to find people for your cliff-climbing trip? You're in the wrong place. Ask around in the groups that took the jogging or bike trips up the mountain on Mountain Day, not the group that took the bus trip!
3. Whether you got here by some connection to the uppity-ups or just by sheer dumb luck, you're my problem now.

> **Comments:**
> **username_1**: Love the last one, but 1 - 3 seem to be inclusive or, not xor.  
> **username_1**: How about "you will pass this class, or not".  
> **username_4**: @username_1 That's merely a Boolean, xor requires two Booleans to compare.  
> **username_1**: @GypsySpellweaver, how so? "You will pass this class or you will not pass this class". Clear xor. "You will pass this class or you won't be able to graduate".  
> **username_4**: Pass `or` not is a result. What are the two, _exclusive_ conditions which determine the result. Pass `not` graduate is a single input `not`ed.  
> **username_0**: @username_1 A xor not A is true. So yes it is an xor. But also a tautology. Is it a useful phrase? I don't know.  
> **username_0**: 1 and 2 look like inclusive. But only incidentally. E.g. You can enter if you are tall or short. There are incidental exclusive, that is we would not exclude someone if they were found to be both tall and short.  

---

### Answer by username_9 on 2020-04-28. Score: 1

Here's an example - A 2 way switch

Both 'up' / both 'down' == off

Single 'down' == on

So, in English, one can perhaps say, "The light is on if switch A is down `xor` switch B is down"


---

### Answer by username_7 on 2020-06-19. Score: 0

Parity of a sum
In other words, when is a+b odd and when is it even?
The sum of two integers (a+b) is odd only if exactly one of the two terms (a, b) is odd. If both a and b are odd, then their sum is even. If both a and b are even, then their sum is also even.
Therefore, when trying to find out if a+b is odd, we need to use an xor:
[A+B is odd] = [A is odd] XOR [B is odd]

Compare this to multiplication, where we specifically need both a and b to be odd if a*b is to be odd.
[A*B is odd] = [A is odd] AND [B is odd]

Similarly, when we're looking for products that are even, we use the inverse, which is an or:
[A*B is even] = [A is even] OR [B is even]

At least one of them must be even, but both can be even as well.

Just for completion's sake, if we're looking for even sums, then we have to use the much less commonly used xnor (which is the inverse of xor, where both need to be equal)
[A+B is even] = [A is even] XNOR [B is even]

This sounds complicated, but it usually usually boils down to an equality check:
[A+B is even] = [A is even] == [B is even]


It's hard to come up with natural examples of an xor, for two main reasons:

In natural languages, the word "or" generally refers to xor, but not exclusively so. The difference is implied contextually. Compare the following examples:

Do you want to buy many toys or one expensive toy?
Can Tom or Cindy please come to the front desk please.
I like cars that are blue or yellow
It's ambiguous whether I like cars that are blue and yellow, or whether I only like cars that are fully yellow or fully blue (this sentence itself is a compounded example of using "or" and whether it means or or xor).


In real life, xor is actually quite rare, when you already exclude things like choices or binary states

xor is more commonly encountered in cases where both terms would cancel each other out, as having only one term "active" means that their effect exists and is not canceled out.

> **Comments:**
> **username_0**: Example 3 is the only predicate, it is a contracted sentence, of I like cars that are fully blue or fully yellow yellow, and has the meaning I like cars that are fully yellow and cars that are fully blue. And there for has the meaning AND. Examples 1 and 2 are selection not a predicate (selection is usually mutually exclusive, but not in example 2)  
> **username_7**: @username_0: Your assertion that semantical english unambiguously translates to logic simply does not hold true. "and" is used differently as `and` (I like cars and planes != I like vehicles that are both a car and a plane), and "or" is similarly used differently than `or` (cfr all the above examples)  
> **username_0**: Did I assert that? Sorry for making such a suggestion. As for the 2nd bit, I don't grok it all, but your negative predicate is true of English and of logic. However I agree English is not as formal and unambiguous as logic.  

---

### Answer by username_5 on 2020-04-29. Score: -1

Am I leaving a comment or an answer but not both?

> **Comments:**
> **username_8**: Zen moment: it is a comment and an answer.  

---

### Answer by username_10 on 2020-04-23. Score: -1

I am going to the local animal shelter. I will adopt a dog xor I will adopt a cat. (I only plan to adopt one pet.)

> **Comments:**
> **username_0**: While this is a use of `or` in english, and it is exclusive. It is not an xor operation. Because it is not a predicate. It is a procedure. It is selection (a branch/if/conditional), not xor.  
> **username_11**: @username_0, I don't see that statement as imperative. I see an assertion about the future. It can be tested after the person who made it returns from the animal shelter. If they return with one dog or one cat, then the assertion was true. If they come back with anything else, then the assertion was false.  
> **username_0**: @besmirched and if they comeback with both?  
> **username_11**: @username_0 Ha ha! While I still disagree with you about whether or not the example is "procedural," I guess I've added another example of how one must be careful when attempting to express the XOR idea in English.  

---

