6

I'm trying to explain XOR logic compared to OR logic.

OR examples are many, e.g. "i need to be inside or use an umbrella to stay dry", but XOR examples are harder.

potrzebie
  • 1,768
  • 1
  • 12
  • 25
  • http://stackoverflow.com/questions/2096916/real-world-use-cases-of-bitwise-operators See if this helps... – Tharindu Rusira Sep 22 '13 at 14:20
  • This is actually a good question many will ask. – user3437460 Dec 19 '17 at 17:42
  • The best approach I found is to read the sentence with an "either" in the beginning. So the sentence would be "either I stay inside or use an umbrella". The "either" suggests that you should not do both at the same time. So supposing that you stay inside (first proposition TRUE) and you also use the umbrella (second proposition also TRUE), the whole sentence is FALSE, because you suggested that you would only do one of them, but ended up doing both. – bruno Dec 01 '19 at 12:25

6 Answers6

23

XOR is like cheating on your girlfriend: if you are alone with her it is ok, if you are alone with the other girl is ok, if you with none or with both you are screwed.

[ no girls were harmed for the sake of this example ]

moonwave99
  • 21,957
  • 3
  • 43
  • 64
11

"OR" example of yours gives about "dryness" while my "XOR" tells "if an action is a waste" .

If you are inside while using an umbrella == waste.

If you are outside while not using an umbrella == waste again.

IF you are inside while not using umbrella, it is ok.

If you are outside while using umbrella, it is ok.

Actually, neural networks getting popular and will become real life. Plus, there are many xor examples made for neural network training, there are so many of them that you need to have an umbrella to stay dry.

It's up to you to give some meaning to 1s and 0s.

Triple XOR:

  Moving through time : yes=1, no=0
  Moving through space: yes=1, no=0
  Screaming           : yes=1, no=0

  Mission: escaping from a falling-piano.

  time                         :(1,0,0) => (1) see the future, 
                                                  call an ambulance


         space                 :(0,1,0) => (1) walk one step back
                                                  so piano misses you


                      scream   :(0,0,1) => (1) people hear you
                                               people help you get to
                                               emergency of hospital

 time     space                :(1,1,0) => (0) at that time and location, 
                                                  you are kept as hostage
                                                  in a robbery scene


 time                scream    :(1,0,1) => (0) yelling at wrong time,
                                                  will not save you


        space        scream    :(0,1,1) => (0) you evade the piano,
                                                  but you are still screaming,
                                                  :D

 time     space        scream  :(1,1,1) => (1) you see future and call ambulance,
                                                  also move 
                                                  now you are in robbery
                                                  but you scream 
                                                  so robbers escape
                                                  they had fake guns
                                                  you save money and life

        (none)                 :(0,0,0) => (0)  piano falls, noone hears
                                                   also they loot your body
                                                   epic items
huseyin tugrul buyukisik
  • 11,469
  • 4
  • 45
  • 97
  • "... there are many xor examples made for neural network training ...". Care to share/reference some? – SBhojani Feb 18 '14 at 08:48
  • 1
    You give inputs and outputs for a case such as "1 1, 0" and alter the multipliers of each neuron such that they are more close to the perfect case. Then do same things for other cases and repeat all process until network gives close enough results for all cases. http://home.agh.edu.pl/~vlsi/AI/xor_t/en/main.htm and http://www.di.unito.it/~cancelli/retineu06_07/FNN.pdf and http://www.heatonresearch.com/online/introduction-neural-networks-java-edition-2/chapter-1/page4.html and http://mnemstudio.org/neural-networks-multilayer-perceptrons.htm – huseyin tugrul buyukisik Feb 18 '14 at 08:52
  • Those examples are good for understanding XOR's ANN implementations. I was looking for more "real-world" examples in contrast to "let's see how to build an ANN that can do XOR". – SBhojani Feb 18 '14 at 09:58
  • @SBhojani I just added areal world example into my answer a microwave app. – huseyin tugrul buyukisik Feb 18 '14 at 10:17
  • 1
    @huseyintugrulbuyukisik i have no idea how I ended up reading this, but I am very happy i did. – Eugene Dec 20 '17 at 20:37
  • Youre welcome. I wish I'm helping enough to the community. – huseyin tugrul buyukisik Dec 20 '17 at 22:50
5

Think of it like telling a child they can have candy, or ice cream. But they can't have both!

ben_re
  • 518
  • 2
  • 12
2

The room has two light switches controlling one light bulb. If both switches are ON, the light is off. If one is ON, the light is on, if none is ON, the light is off.

  • Commenting on where you decided to vote or what should have been the accepted answer is not an answer, and neither is your opinion of which example is best. – Saveen Jan 07 '17 at 13:04
1

A Simple real life example is magnetic pole. Like poles repel while unlike poles attract.

Lokesh
  • 7,810
  • 6
  • 48
  • 78
0

Pushing both buttons opens the trap door, so we wired that to the AND gate. Pushing only one of the buttons, either one, releases the hounds, so we wired that to the XOR gate.

Method of operation:

Press one of the buttons to release the dogs. Once subject is running frantically press both buttons to open the trap door. Caution, opening the trap door first may be disastrous for the dogs.

Kastor
  • 617
  • 5
  • 14