2.1.11+Define+the+Boolean+operators

=__**2.1.11 Define the Boolean operators: AND, OR, NOT, NAND, NOR and XOR**__=
 * DISCLAIMER: the IB requests the logic gates to be represented as circles containing the operator inside, not the complicated sign
 * true = 1
 * false = 0

__**AND**__

 * __ **Both inputs are true[[image:How-Logic-Gates-Work-3.gif align="right" caption="Logic Gate Symbols"]]** __
 * a AND b are true


 * Input A || Input B || Output ||
 * 0 || 0 || 0 ||
 * 0 || 1 || 0 ||
 * 1 || 0 || 0 ||
 * 1 || 1 || 1 ||

**__OR__**

 * __ **One input at least is true** __


 * Input A || Input B || Output ||
 * 0 || 0 || 0 ||
 * 0 || 1 || 1 ||
 * 1 || 0 || 1 ||
 * 1 || 1 || 1 ||

**__NOT__**

 * __** input is not true **__
 * only one input
 * converse of input is the output


 * Input A || Output ||
 * 0 || 1 ||
 * 1 || 0 ||

__**NAND**__

 * __ **the inputs are not both true (not AND)** __


 * Input A || Input B || Output ||
 * 0 || 0 || 1 ||
 * 0 || 1 || 1 ||
 * 1 || 0 || 1 ||
 * 1 || 1 || 0 ||

__ **NOR** __

 * ** __not input A (n)or input B are true__ **


 * Input A || Input B || Output ||
 * 0 || 0 || 1 ||
 * 0 || 1 || 0 ||
 * 1 || 0 || 0 ||
 * 1 || 1 || 0 ||

**__XOR__**

 * **__only one input can be true, not both__**


 * Input A || Input B || Output ||
 * 0 || 0 || 0 ||
 * 0 || 1 || 1 ||
 * 1 || 0 || 1 ||
 * 1 || 1 || 0 ||

=__**How do logic gates work?**__=


 * 1) Identify the inputs.
 * 2) Sketch a truth table.
 * 3) Enter the inputs and all possible combinations of 0s and 1s. The total number of combinations is **2 to the power of n, where n is the total number of inputs.**
 * 4) In the following columns write the logic operators and how it combines the inputs.
 * 5) Use the previous columns filled to identify the new combination of 0s and 1s applying the concepts of the logic operators listed above.
 * 6) Continue until all gates are passed and the output is detected.

How to: Logic Diagram


 * Identify the inputs. Right them on the left side.
 * Read the description. Identify the operators and in which way they are combined.
 * For example (see example 1):
 * (NOT A) and (A AND B) are the first to draw
 * These outputs are then combined through (OR)
 * NOT (A AND B) - this means to negate one of the first outputs
 * Combine that through the us of OR with the other output to reach the final output.
 * Step by step combine the operators until a final output is reached.

How to: Logic Tables
 * Write all possible combinations for the inputs.
 * use **2 to the power of n, where n is the number of inputs** to find how many combinations are possible
 * Identify the first operation
 * Use the inputs to complete the first operation according to the instructions given by the operation
 * e.g. NOT A is the inverse of the input A
 * Identify the next relevant operation and use the previously constructed columns to fill in the new column.
 * Repeat until the final output is reached.


 * e.g. (A AND B) NAND (NOT A)**


 * Consider the inputs A & B**


 * Input A || Input B ||
 * 0 || 0 ||
 * 0 || 1 ||
 * 1 || 0 ||
 * 1 || 1 ||


 * Combine them using AND**


 * A AND B ||
 * 0 + 0 = 0 ||
 * 0 + 1 = 0 ||
 * 1 + 0 = 0 ||
 * 1 + 1 = 1 ||


 * Negate A (NOT A)**


 * Input A || NOT A (Inverse) ||
 * 0 || 1 ||
 * 0 || 1 ||
 * 1 || 0 ||
 * 1 || 0 ||


 * Combine (NOT A) NAND (A AND B)**


 * A AND B || NOT A || Output ||
 * 0 || 1 || 1 ||
 * 0 || 1 || 1 ||
 * 0 || 0 || 1 ||
 * 1 || 0 || 1 ||


 * Logic gates are important in real life, as they can be used in circuits and programs. For example, lets take the example and see where it would be applicable in real life. These could be logic gates regulating whether too much pollution is caused and a warning alarm should be let off.**


 * __Example 1: ((NOT A) OR //(A AND B)) OR (NOT(A AND B))//__**




 * Input A || Input B || NOT A || A AND B || D = (NOT A) OR (A AND B) || E = NOT (A AND B) || D OR E = Output C ||
 * 0 || 0 || 1 || 0 || 1 || 1 || 1 ||
 * 0 || 1 || 1 || 0 || 1 || 1 || 1 ||
 * 1 || 0 || 0 || 0 || 0 || 1 || 1 ||
 * 1 || 1 || 0 || 1 || 1 || 0 || 1 ||


 * __Example 2: ((A OR C) NOR //(A AND B)) NAND (B XOR C)//__**




 * Input A || Input B || Input C || A OR C || A AND B || (A OR C) NOR (A AND B) || B XOR C || NAND ||
 * 0 || 0 || 0 || 0 || 0 || 1 || 0 || 1 ||
 * 0 || 0 || 1 || 1 || 0 || 0 || 1 || 1 ||
 * 0 || 1 || 0 || 0 || 0 || 1 || 1 || 0 ||
 * 0 || 1 || 1 || 1 || 0 || 0 || 0 || 1 ||
 * 1 || 0 || 0 || 1 || 0 || 0 || 0 || 1 ||
 * 1 || 0 || 1 || 1 || 0 || 0 || 1 || 1 ||
 * 1 || 1 || 0 || 1 || 1 || 0 || 1 || 1 ||
 * 1 || 1 || 1 || 1 || 1 || 0 || 0 || 1 ||

__Practice Problem - Real Life Example:__


 * If traffic light A is green (on) traffic light, traffic light C can/must be green too. However, traffic light B can not be green then. Thus, if traffic light B is not on, neither is traffic light D.**


 * Hint:**


 * Input A || Input B || Input C || Input D || A AND C || B AND D || (A AND C) NAND (B AND D) ||
 * 0 || 0 || 0 || 0 || 0 || 0 || 1 ||
 * 0 || 0 || 0 || 1 || 0 || 0 || 1 ||
 * 0 || 0 || 1 || 0 || 0 || 0 || 1 ||
 * 0 || 0 || 1 || 1 || 0 || 0 || 1 ||
 * 0 || 1 || 0 || 0 || 0 || 0 || 1 ||
 * 0 || 1 || 0 || 1 || 0 || 1 || 1 ||
 * 0 || 1 || 1 || 0 || 0 || 0 || 1 ||
 * 0 || 1 || 1 || 1 || 0 || 1 || 1 ||
 * 1 || 0 || 0 || 0 || 0 || 0 || 1 ||
 * 1 || 0 || 0 || 1 || 0 || 0 || 1 ||
 * 1 || 0 || 1 || 0 || 1 || 0 || 1 ||
 * 1 || 0 || 1 || 1 || 1 || 0 || 1 ||
 * 1 || 1 || 0 || 0 || 0 || 0 || 1 ||
 * 1 || 1 || 0 || 1 || 0 || 1 || 1 ||
 * 1 || 1 || 1 || 0 || 1 || 0 || 1 ||
 * 1 || 1 || 1 || 1 || 1 || 1 || 0 ||

Created By: Lucie Charlotte Magister Last update: 20/11/2014

Sources:
 * Cambridge Igcse Computer Studies Revision Guide. N.p.: Cambridge Univ Pr, 2012. Print.
 * "How Logic Gates Work." Softpedia. N.p., n.d. Web. 20 Nov. 2014. .