Answers.Body: <p>Think pizza shop. You order a one-topping pie.  Would you like pepperoni <code>or</code> sausage?  In common parlance, that's an exclusive or.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T13:31:57.823Z
Answers.Text: I'm pretty sure that's inclusive or, because "both" would be a fine answer. "Would you like a white pie or pie with sauce" would be exclusive.
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T22:00:06.490Z
Answers.Text: You will notice I said "one-topping pie"
Answers.UserDisplayName: ncmathsadist
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T22:02:06.603Z
Answers.Text: You give me far too much credit, sir. ;-D
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T22:48:57.643Z
Answers.Text: Do you happen to know of a situation analogous to (or English equivalent of) $A \oplus B \oplus C$?
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T22:50:08.457Z
Answers.Text: This means an odd number of A, B and C ar true.
Answers.UserDisplayName: ncmathsadist
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T22:50:43.657Z
Answers.Text: This leads to a simple proof that $\oplus$ is associative.
Answers.UserDisplayName: ncmathsadist
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T12:54:54.843Z
Answers.LastActivityDate: 2017-08-01T12:54:54.843Z
Answers.UserDisplayName: ncmathsadist
Answers.Body: <p>I enjoy using cartoons in my teaching, such as <a href="http://www.toothpastefordinner.com/index.php?date=071310" rel="nofollow noreferrer">this one</a>:</p>
  
  <p><a href="https://i.sstatic.net/iNlPM.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iNlPM.gif" alt="Boolean Hair Logic"></a></p>
  
  <p>You can also teach students the <a href="https://en.wikipedia.org/wiki/XOR_swap_algorithm" rel="nofollow noreferrer">XOR trick</a> for swapping two values without using intermediate storage:</p>
  
  <pre><code>X := X XOR Y
  Y := X XOR Y
  X := X XOR Y
  </code></pre>
  
  <p>See <a href="https://en.wikipedia.org/wiki/XOR_swap_algorithm#Proof_of_correctness" rel="nofollow noreferrer">correctness proof</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T19:35:08.230Z
Answers.LastActivityDate: 2017-08-01T19:35:08.230Z
Answers.UserDisplayName: Ellen Spertus
Answers.Body: <p>I wouldn't bother trying to tie this in to English language. Exclusive or is a strange connective. For example:</p>
  
  <p>$a \oplus (b \oplus c)$</p>
  
  <p>means "An odd number of ($a$, $b$, $c$) is true" (you can see this by working out the truth table). In general if you stack up disjuncts like this, exclusive or means "an odd number of these disjuncts is true"; it is the binary odd counting function.</p>
  
  <p>No connective in natural language behaves in this way, and definitely not English 'or'. For this reason, you should not use the English language to clarify exclusive or.</p>
  
  <p>The 'or' in "You may have ice cream or cake (but not both)" is not even a disjunction, because you can infer from it that you may have ice cream. From a real disjunction like "He is in Paris or London", you can't infer that he is in Paris. Unfortunately, most elementary logic textbooks get this wrong; this highlights the confusion you get when you try to make formal logic clearer by comparing it to natural language. Math is perfectly clear; natural language is a complete mess : )</p>
  
  <p>I think the simplest clarification of the difference between these two connectives is by comparing it to the difference between "At least one of these two things is true", and "Exactly one of these things is true".</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-31T21:50:18.413Z
Answers.Text: Welcome to [cseducators.se]! A very interesting point. But I don't quite see how this answers the question. Could you please edit your answer to add an example for illustrating the difference between OR and XOR?
Answers.UserDisplayName: ItamarG3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-31T21:51:22.057Z
Answers.Text: It is interesting that I have told my fellow programmers to not do `if condition == true`, because we don't say “would you like fries with that is true”, but here I see this in natural language. As I am from only one part of the English speaking world, and the way we speak can change in less than 100 miles. I would like to ask. Do people add “Is true” to the end of questions, where you are from? — thanks
Answers.UserDisplayName: ctrl-alt-delor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-01T00:07:30.767Z
Answers.Text: This really is an interesting point, but while I agree that I can't think of any English construction comparable to $A\oplus (B \oplus C)$, why is $A \oplus B$ not the same has he is in Paris or London?
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-03T22:05:32.867Z
Answers.Text: @Ben Just because we think it's the same "or" as "he is in Paris or London or Istanbul". Clearly it can't be mathematical ex-or.
Answers.UserDisplayName: mander
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-03T22:23:42.200Z
Answers.Text: @mander I agree that "He is in Paris or London or Istanbul" is not equivalent to $inParis \oplus inLondon \oplus inIstanbul$, because that is a matter of 3 $\oplus$s.  But "He is in Paris or London" should be an identical statement to $inParis \oplus inLondon$.
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-31T21:39:13.933Z
Answers.LastActivityDate: 2017-08-03T20:11:08.150Z
Answers.LastEditDate: 2017-08-03T20:11:08.150Z
Answers.UserDisplayName: mander
Answers.Body: <p>You might go about explaining it by using the words "either" and "or".</p>
  
  <p>"Either" means that any option out of two available would be enough:</p>
  
  <blockquote>
    <p>perfect indifference of the two (or more) things. </p>
  </blockquote>
  
  <p>But also </p>
  
  <blockquote>
    <p>to emphasize the mutual exclusiveness: <em>either</em> of the two, <em>but not both</em>.</p>
  </blockquote>
  
  <p>(taken from Oxford English Dictionary).</p>
  
  <p>This means that xor is true only when either one is, but not when neither are true or neither are false. The key point to stress is <em>"either one"</em>.</p>
  
  <p>As for practice, you can ask the students to come up with 3-4 properties (boy\girl, reads many books\doesn't read many books, etc.) that some students have and some don't. </p>
  
  <p>For the first property, ask every student who has that property (can't think of a better word <code>:/</code>) to write in their notebooks the numer 1 (they might ask "where should I write it?", it doesn't matter that much as long as there's room for a few more numbers). Students who don't have that property should write <code>0</code>.</p>
  
  <p>Then go through the other properties (or <em>conditions</em>) and for each one, ask every student who has the current property to do the following: </p>
  
  <p>If they have written the number <code>1</code> for the previous property, to write the number <code>0</code> (maybe next to the <code>1</code>)<br>
  Every student who didn't write <code>1</code>, should do so.  </p>
  
  <p>Every student who doesn't have the current propery, should copy what they wrote for the last property.</p>
  
  <p>After reaching the fourth property, ask students to check if the last number is <code>1</code>. If it is, ask them to reflect whether they have either one of the properties, but not an even number. Explain that this is what xor does: only if an odd number of conditions is fullfilled, is the result <code>true</code>. </p>
  
  <p>Now, after they understand this point, go through the 4 properties again but this time ask the students to write <code>1</code> as soon as you get to a property they have, and 0 if they don't have the current property. </p>
  
  <p>Every student that has a <code>1</code>, is a student that an OR operator would result in <code>true</code>, had they been passed as a parameter (if they are high-school students, they might find being called "parameters" intriguing and this might make more students listen during the lesson).</p>
  
  <p>By comparing the results for the first practice with the one from the second practice, the difference between OR and XOR becomes quite clear. </p>
  
  <p>Another way to make it unquestionably clear is to show the truth table of each operator.</p>
  
  <p>(you iterate the properties)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-31T18:40:59.457Z
Answers.LastActivityDate: 2017-07-31T18:40:59.457Z
Answers.UserDisplayName: ItamarG3
Answers.Body: <h2>Play the “if you have brown hair stand up” game.</h2>
  
  <p>For the introductory lesson. We use this to introduce selection (if statements), and a little bit of boolean logic.</p>
  
  <blockquote>
    <p>“Stand up if you have got brown hair.”<br>
    “Sit down.” look around “Stand up if you have blue eyes.”<br>
    …<br>
    With out asking them to sit down “Stand up if you …”<br>
    Address why some people are still standing, are they correct [yes], or are the seated people correct [no]. Why? [because I did not ask them to sit].<br>
    …<br>
    “stand up if you have brown hair or you are …” (this is where we start to cover Boolean logic, I have only done and, or, not).</p>
  </blockquote>
  
  <p>In another lesson you could add <code>xor</code>, <code>nand</code>, <code>nor</code>. </p>
  
  <h2>Xor examples</h2>
  
  <blockquote>
    <p>“if you have blond hair or you have blue eyes stand up”<br>
    “if you have blond hair xor you have blue eyes stand up”</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-31T17:42:29.490Z
Answers.LastActivityDate: 2017-07-31T21:39:59.073Z
Answers.LastEditDate: 2017-07-31T21:39:59.073Z
Answers.UserDisplayName: ctrl-alt-delor
Body: <p>How can I illustrate the difference between $\lor$ and $\oplus$ in a way that isn't just boring?  Are there fun ways to illustrate and provide practice for this small, yet key, distinction?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-31T16:19:53.443Z
Comments.Text: Do you mean in logic computations, specifically or as an operation in programming? Do you mean also "short circuit" evaluation?
Comments.UserDisplayName: Buffy
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-31T16:53:17.423Z
Comments.Text: Well, exclusive or kind of matches people's intuition of what "or" means, inclusive or is slightly more counterintuitive.
Comments.UserDisplayName: EJoshuaS - Stand with Ukraine
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-31T17:43:31.140Z
Comments.Text: some of the answer here may be of help https://cseducators.stackexchange.com/questions/2750/active-learning-for-boolean-algebra/
Comments.UserDisplayName: ctrl-alt-delor
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-31T21:27:21.567Z
Comments.Text: For the "What's the point" kind of questions, I would point out how in English as it is commonly practiced, context can change the meaning of the conjunctions. "AND" can sometimes mean "OR". For example: "You have two choices: You can go to the party, and you can stay home." Everyone hearing it would understand you are listing exclusive options. In this case, "AND" means "XOR".
Comments.UserDisplayName: Katie Kilian
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-31T21:30:16.377Z
Comments.Text: OR and AND are ambiguous in English: "You can hang your sign here if it's blue or if it's purple."  "You can hang your sign here if it's blue and if it's purple." They mean the same thing. The point of rigorously defining the binary (and logical) operators is so they mean one thing and only one thing, to make sure you're telling the computer exactly what you want it to do.
Comments.UserDisplayName: Katie Kilian
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-01T03:30:37.827Z
Comments.Text: A 3-way (4-way, multiway) light switch can model a xor operation. When both switches are down, the light is out, when one switch is up, the light is on, and when both switches are up, the light is back off. In multiway configurations, the system behaves as the generic definition of the xor function: if the number of switches that are up is odd, then the light is on, else, the light is off. This is all assuming that no switch has been installed upside down, of course.
Comments.UserDisplayName: sleblanc
Tags: <boolean-algebra>
Title: Differentiating Inclusive from Exclusive Or
ThreadText: # Differentiating Inclusive from Exclusive Or
  
  (Asked by: username_0 on 2017-07-31)
  
  How can I illustrate the difference between $\lor$ and $\oplus$ in a way that isn't just boring? Are there fun ways to illustrate and provide practice for this small, yet key, distinction?
  
  **Tags:** boolean-algebra
  
  > **Comments:**
  > **username_1**: Do you mean in logic computations, specifically or as an operation in programming? Do you mean also "short circuit" evaluation?  
  > **username_2**: Well, exclusive or kind of matches people's intuition of what "or" means, inclusive or is slightly more counterintuitive.  
  > **username_3**: some of the answer here may be of help https://cseducators.stackexchange.com/questions/2750/active-learning-for-boolean-algebra/  
  > **username_4**: For the "What's the point" kind of questions, I would point out how in English as it is commonly practiced, context can change the meaning of the conjunctions. "AND" can sometimes mean "OR". For example: "You have two choices: You can go to the party, and you can stay home." Everyone hearing it would understand you are listing exclusive options. In this case, "AND" means "XOR".  
  > **username_4**: OR and AND are ambiguous in English: "You can hang your sign here if it's blue or if it's purple."  "You can hang your sign here if it's blue and if it's purple." They mean the same thing. The point of rigorously defining the binary (and logical) operators is so they mean one thing and only one thing, to make sure you're telling the computer exactly what you want it to do.  
  > **username_5**: A 3-way (4-way, multiway) light switch can model a xor operation. When both switches are down, the light is out, when one switch is up, the light is on, and when both switches are up, the light is back off. In multiway configurations, the system behaves as the generic definition of the xor function: if the number of switches that are up is odd, then the light is on, else, the light is off. This is all assuming that no switch has been installed upside down, of course.  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_3 on 2017-07-31. Score: 7
  
  ## Play the “if you have brown hair stand up” game.
  
  For the introductory lesson. We use this to introduce selection (if statements), and a little bit of boolean logic.
  
  > “Stand up if you have got brown hair.”  
  > “Sit down.” look around “Stand up if you have blue eyes.”  
  > …  
  > With out asking them to sit down “Stand up if you …”  
  > Address why some people are still standing, are they correct [yes], or are the seated people correct [no]. Why? [because I did not ask them to sit].  
  > …  
  > “stand up if you have brown hair or you are …” (this is where we start to cover Boolean logic, I have only done and, or, not).
  
  In another lesson you could add `xor`, `nand`, `nor`.
  
  ## Xor examples
  
  > “if you have blond hair or you have blue eyes stand up”  
  > “if you have blond hair xor you have blue eyes stand up”
  
  
  ---
  
  ### Answer by username_9 on 2017-07-31. Score: 5
  
  You might go about explaining it by using the words "either" and "or".
  
  "Either" means that any option out of two available would be enough:
  
  > perfect indifference of the two (or more) things.
  
  But also
  
  > to emphasize the mutual exclusiveness: *either* of the two, *but not both*.
  
  (taken from Oxford English Dictionary).
  
  This means that xor is true only when either one is, but not when neither are true or neither are false. The key point to stress is *"either one"*.
  
  As for practice, you can ask the students to come up with 3-4 properties (boy\girl, reads many books\doesn't read many books, etc.) that some students have and some don't.
  
  For the first property, ask every student who has that property (can't think of a better word `:/`) to write in their notebooks the numer 1 (they might ask "where should I write it?", it doesn't matter that much as long as there's room for a few more numbers). Students who don't have that property should write `0`.
  
  Then go through the other properties (or *conditions*) and for each one, ask every student who has the current property to do the following:
  
  If they have written the number `1` for the previous property, to write the number `0` (maybe next to the `1`)  
  Every student who didn't write `1`, should do so.
  
  Every student who doesn't have the current propery, should copy what they wrote for the last property.
  
  After reaching the fourth property, ask students to check if the last number is `1`. If it is, ask them to reflect whether they have either one of the properties, but not an even number. Explain that this is what xor does: only if an odd number of conditions is fullfilled, is the result `true`.
  
  Now, after they understand this point, go through the 4 properties again but this time ask the students to write `1` as soon as you get to a property they have, and 0 if they don't have the current property.
  
  Every student that has a `1`, is a student that an OR operator would result in `true`, had they been passed as a parameter (if they are high-school students, they might find being called "parameters" intriguing and this might make more students listen during the lesson).
  
  By comparing the results for the first practice with the one from the second practice, the difference between OR and XOR becomes quite clear.
  
  Another way to make it unquestionably clear is to show the truth table of each operator.
  
  (you iterate the properties)
  
  
  ---
  
  ### Answer by username_7 on 2017-08-01. Score: 4
  
  I enjoy using cartoons in my teaching, such as [this one](http://www.toothpastefordinner.com/index.php?date=071310):
  
  [![Boolean Hair Logic](https://i.sstatic.net/iNlPM.gif)](https://i.sstatic.net/iNlPM.gif)
  
  You can also teach students the [XOR trick](https://en.wikipedia.org/wiki/XOR_swap_algorithm) for swapping two values without using intermediate storage:
  
  ```
  X := X XOR Y
  Y := X XOR Y
  X := X XOR Y
  
  ```
  
  See [correctness proof](https://en.wikipedia.org/wiki/XOR_swap_algorithm#Proof_of_correctness).
  
  
  ---
  
  ### Answer by username_6 on 2017-08-01. Score: 3
  
  Think pizza shop. You order a one-topping pie. Would you like pepperoni `or` sausage? In common parlance, that's an exclusive or.
  
  > **Comments:**
  > **username_0**: I'm pretty sure that's inclusive or, because "both" would be a fine answer. "Would you like a white pie or pie with sauce" would be exclusive.  
  > **username_6**: You will notice I said "one-topping pie"  
  > **username_0**: You give me far too much credit, sir. ;-D  
  > **username_0**: Do you happen to know of a situation analogous to (or English equivalent of) $A \oplus B \oplus C$?  
  > **username_6**: This means an odd number of A, B and C ar true.  
  > **username_6**: This leads to a simple proof that $\oplus$ is associative.  
  
  ---
  
  ### Answer by username_8 on 2017-07-31. Score: 2
  
  I wouldn't bother trying to tie this in to English language. Exclusive or is a strange connective. For example:
  
  $a \oplus (b \oplus c)$
  
  means "An odd number of ($a$, $b$, $c$) is true" (you can see this by working out the truth table). In general if you stack up disjuncts like this, exclusive or means "an odd number of these disjuncts is true"; it is the binary odd counting function.
  
  No connective in natural language behaves in this way, and definitely not English 'or'. For this reason, you should not use the English language to clarify exclusive or.
  
  The 'or' in "You may have ice cream or cake (but not both)" is not even a disjunction, because you can infer from it that you may have ice cream. From a real disjunction like "He is in Paris or London", you can't infer that he is in Paris. Unfortunately, most elementary logic textbooks get this wrong; this highlights the confusion you get when you try to make formal logic clearer by comparing it to natural language. Math is perfectly clear; natural language is a complete mess : )
  
  I think the simplest clarification of the difference between these two connectives is by comparing it to the difference between "At least one of these two things is true", and "Exactly one of these things is true".
  
  > **Comments:**
  > **username_9**: Welcome to [cseducators.se]! A very interesting point. But I don't quite see how this answers the question. Could you please edit your answer to add an example for illustrating the difference between OR and XOR?  
  > **username_3**: It is interesting that I have told my fellow programmers to not do `if condition == true`, because we don't say “would you like fries with that is true”, but here I see this in natural language. As I am from only one part of the English speaking world, and the way we speak can change in less than 100 miles. I would like to ask. Do people add “Is true” to the end of questions, where you are from? — thanks  
  > **username_0**: This really is an interesting point, but while I agree that I can't think of any English construction comparable to $A\oplus (B \oplus C)$, why is $A \oplus B$ not the same has he is in Paris or London?  
  > **username_8**: @Ben Just because we think it's the same "or" as "he is in Paris or London or Istanbul". Clearly it can't be mathematical ex-or.  
  > **username_0**: @username_8 I agree that "He is in Paris or London or Istanbul" is not equivalent to $inParis \oplus inLondon \oplus inIstanbul$, because that is a matter of 3 $\oplus$s.  But "He is in Paris or London" should be an identical statement to $inParis \oplus inLondon$.  
  
  ---
  
  