What is digital logic and how do logic gates work?
Let us examine the two basic circuits below. The top one has an open switch and therefore the bulb is OFF. The second one is closed and the bulb is ON.
The bulb in ON or OFF depending on the position of the switch. Let use 0 to describe the switch when it is open and 1 when the switch is closed. We also use 0 to describe the bulb when it is OFF and 1 when the bulb is ON to write all possible situations in the following table.


We now examine circuits with two switches in parallel as in the figure below. Since the switches are in parallel, if either switch X is closed or switch Y is closed or both are closed the circuit is closed and the bulb is ON. The table below includes all possible combinations of the positions of the two switches and the corresponding state of the bulb (ON or OFF).


The above table corresponds exactly to the OR function as defined in Boolean algebra.
Using Boolean algebra, the results in the table above may be written as follows:
X  Y  X+Y 
0  0  1 
0  1  1 
1  0  1 
1  1  1 
Although the first three sums have the same meaning as in any mathematical addition, the last sum 1 + 1 = 1 suggests that the meaning of addition here is different. This is boolean algebra which originally used "TRUE" and "FALSE" before it was adopted in digital systems and 1 and 0 replaced the "TRUE" and "FALSE".
We now examine circuits with two switches in series as in the figure below. Since the switches are in series, the bulb is ON only when both switches are closed. The table below includes all possible combinations of the positions of the two switches and the corresponding state of the bulb (ON or OFF).


The above table corresponds exactly to the AND function as defined in Boolean algebra.
Using Boolean algebra, the results in the table above may be written as follows:
X  Y  X ^{. }Y 
0  0  0 
0  1  0 
1  0  0 
1  1  1 
This is boolean algebra which originally used "TRUE" and "FALSE" before it was adopted in digital systems and 1 and 0 replaced the "TRUE" and "FALSE".
The above circuits with switches were used to explain the idea behind digital logic circuits. In practice these circuits are electronic circuits and their representation is as follows:
X  Y  X ^{⊕}Y 
0  0  0 
0  1  1 
1  0  1 
1  1  0 