Monday, 2 June 2008

Boolean Logic/Algebra

Boolean logic was developed by George Boole who lived between 1815 and 1864. It is said to be the foundation upon which digital electronics stand today.
In Boolean logic a statement could only generate two values of which only one of the two can be correct at a time. The two values are: true or false which could also be represented as high or low or 1 or 0 depending on where it is applied. Computer uses the Boolean logic to decide on the operation or action to perform. Most programming languages use the conditional statements to control event and occurrences in its application. These controlled statements use Boolean logic to arrive at a conclusion of what to do.
For example:
If (x==2) and (x==4), do something
Else, do something.
The above operation would either find x==2 and x==4 to be true or false and not both. If the statement is true, certain action is performed and if false, another action is performed.
The use of Boolean logic also finds application in our day to day activities and making personal decision or at reaching a logical conclusion.
Consider the following logic, an applicant is considered for a job which required qualifications are B.Sc Computing background and the applicant must be a female. Decision on who to employ is based on these qualification. An applicant could either meet the qualification or not which could be true or false. If true, he meets the requirement and if false, requirements not met.
The use of these set of analyses will aid easy and quick arrival at conclusions.
Boolean logic uses a number of operators in making decisions. They are; AND, OR and NOT operators.
AND Operator
An AND operator is a Boolean operator that returns a value of TRUE or 1 or ON or High if both its operands are TRUE or 1 or ON or High, and FALSE or 0 or OFF or Low otherwise. Operands are the statements that are being compared by an operator. The AND operator is said to be a conjunction operator
The AND operator will only return true if and only if the two compared operands are true. If either or both the compared operands are false, the returned value will be false. When bit values are used, the operator returns 1 only if both operands are 1 and returns 0 for other combinations. When state of a circuit is being compared, the circuit is ON or HIGH when both inputs are ON or HIGH. The circuit is OFF or LOW for every other combination.
There are two types of AND operators:
Logical AND which is represented with two ampersand signs &&: when using the logical operator, the operands are evaluated from left to right. If the left operand returns a value FALSE, 0, LOW or OFF, the right operand will not be evaluated and the entire result will return a value, FALSE, 0, LOW or OFF. This reduces the run time or latency of a program as it makes the program run faster since it’s know that the AND operator can only return a TRUE value when both operands are TRUE.
Bitwise AND which is represented with one ampersand sign &: when using the bitwise AND operator, the two operands are evaluated irrespective of what the left side operand returns. This is useful when both operands need to be evaluated always. When using the bitwise AND operator, both operands must be integers. The output of a bitwise operation can only be either “1” or “0”.



AND Gate
The AND gate shown below is a digital gate that is used in digital circuit. It can have two or more inputs and one output. Its output is only true if all inputs are true.
This first symbol show the traditional way of representing the AND Gate and it is the most







The other symbol used in representing the AND gate which is the The IEC (International Electrotechnical Commission) symbol which is a rectangles with an ampersand sign(&) inside to show the gate function. This is not common in logic circuit despite its official status.









AND Truth Table
This is the table that shows the results of all the possible combinations of operands in a Boolean expression. For logical operations using TRUE and FALSE, the following table show all the possible combinations and outputs.



Venn Diagram Representation of AND operator
The AND operation can also be represented using a Venn diagram as shown below:





OR Operator
The OR operator is a Boolean operator that returns a value of TRUE or 1 or ON or High when either or both of its operands are TRUE or 1 or ON or High, and FALSE or 0 or OFF or Low only when the two operands are FALSE or 0 or OFF or Low. The OR operator is said to be a disjunction operator
OR operation can be represented with a plus sign “+” (e.g. A+B reads as A OR B).
The OR operator will only return FALSE if and only if the two compared operands are FALSE. If either or both of the compared operands are TRUE, the returned value will be TRUE. If bit values are used, the operator returns 0 only if both operands are 0 and returns 1 for other combinations. When state of a circuit is being compared, the circuit is ON or HIGH when either or both inputs are ON or HIGH. The circuit is OFF or LOW only when both inputs are OFF or LOW.


There are two types of OR operator. They are:
Logical OR which is represented with two vertical strokes sign “”: when using the logical operator, the operands are evaluated from left to right. If the left operand returns a value TRUE, the right operand will not be evaluated and the entire result will return a value TRUE. This reduces the run time or latency of a program as it makes the program run faster since it’s know that the OR operator will always return a TRUE value when either or both of its operands are TRUE.
Bitwise OR which is represented with one vertical stroke sign “”: when using the bitwise OR operator, the two operands are evaluated irrespective of what the left side operand returns. This is useful when both operands need to be evaluated always. When using the bitwise OR operator, both operands must be integers. The output of a bitwise operation can only be either “1” or “0”.

OR Gate
The OR gate is a digital gate employed in digital circuit to perform OR operations. The OR gate is represented with the following symbols:



The first symbol shows the traditional representation of the gate;


The second symbol shows the IEC (International Electrotechnical Commission) symbol:






OR Truth Table
This is the table that shows the results of all the possible combinations of operands in a Boolean expression. For logical OR operations using TRUE and FALSE, the following table show all the possible combinations and outputs.

Venn Diagram Representation of OR operator
The OR operation can also be represented using a Venn diagram as shown below:


NOT Operator
The NOT operator is a Boolean operator that returns the opposite value of its input as output. The NOT operator unlike the AND and OR operators only evaluates one operand. If the value of the operand evaluated is TRUE, the NOT operator returns FALSE.
NOT Gate (Inverter)
The NOT gate is a logic gate that is also referred to as Inverter. The NOT gate has only one input and one output. The output is the reverse of the input.
The traditional symbol for the NOT gate is shown below:



The second symbol shows the IEC (International Electrotechnical Commission) symbol:




NOT Truth Table

Venn Diagram Representation of NOT operator






Referential Gates
Referential gates are gates that are derived from the three primary gates; AND, OR and NOT.
NAND Gate (Not AND)
The NAND gate is an inverted AND gate. Its output is an inversion of the AND output. When the output of an AND gate is connected to a NOT gate, a NAND gate is formed. For all possible combinations, the NAND gate produces a “1” only when both inputs are not “1”. When both inputs are “1”, a “0” output is obtained.
This is represented with a dot attached to the AND gate as shown below:







NOR Gate (Not OR)
The NOR gate is an inverted OR gate which has its output as the revise of the OR gate. For all possible combinations, the NOR gate produces a “1” only when both inputs are “0”. Other combinations produce an output of “0”. The following show the symbols for NOR gate and the NOR truth table.


NOR Truth Table

Exclusive OR Gate (Ex-OR)
The Ex-OR gate can only have two inputs. It is like the OR gate but having a FALSE output for a combination of two operands with value, TRUE. The output is always TRUE if the values of the two inputs are different.
The following shows the symbols of an Ex-OR gate:




Ex-OR Truth Table
Exclusive NOR Gate (Ex-NOR)
The Ex-NOR is an Ex-OR gate with an inverted output. The Ex-NOR gate can only have two inputs and one output. The output will always be TRUE if and only if the two inputs are of the same value.
The following shows the symbols for the Ex-NOR gate with the truth table.





Ex-NOR Truth Table

No comments: