How To Use Boolean Operators
Boolean Algebra!
It'south logical actually.
Introduction
We'll start off by covering what exactly Boolean Algebra is and then look at some of the basic edifice blocks, also referred to equally operators. It may seem a petty abstract at this stage just once you lot've worked through this section and the next it will start to make a scrap more sense.
Boolean Algebra
Boolean Algebra is a way of formally specifying, or describing, a item situation or process. We utilise variables to correspond elements of our situation or procedure. Variables may accept ane of only two values. Traditionally this would be Truthful and Fake. So for instance we may have a variable X and land that this represents if it is raining outside or not. The value of Ten would be :
- True if information technology is raining outside.
- False if it is not raining outside.
What you accept to retrieve is that although many things in the existent earth exist on a spectrum, in Boolean Algebra things are reduced to black and white. So we could take, for instance, light rain, steady pelting, or heavy rain. In Boolean Algebra withal, it is either raining or it isn't. This may seem a little limiting but this simplification of things really turns out to be quite powerful.
It is possible to substitute other values in place of True and False. When working with computers information technology is often the instance that Truthful and Imitation is replaced with ane and 0. When working with concrete circuits we may replace Truthful and False with the presence or absence of a voltage.
In this fashion Boolean Algebra is useful to depict a process and and so to build mechanisms which tin can perform those processes. Continue this in heed as you're working through the next few sections. This is what we are building towards.
Basic Operations
We saw above that variables may be used to correspond the current country of elements that we are interested in. Operations allow us to and so define relationships between those variables. There are three basic operations. These are used often in Boolean expressions simply are also used to create more complex operations. You'll probably find that you've actually used these operations quite a bit, you've simply never thought of them formally before.
The outcome of an operation is similar to variables, information technology may merely be either True or Fake.
I have called to ever write operations in all Upper-case letter. This is so they are easily identified every bit operations. Many people follow this convention merely it is non required. Feel complimentary to use whatsoever method suits y'all best.
AND
The showtime operation is AND and it means pretty much what it does in plain english. Then for instance I may land "If it'south sunny outside AND I have completed my work then I will go for a run." To correspond this in Boolean Algebra I may say that:
- ten represents if information technology is sunny exterior or not.
- y represents if I have completed my work or not.
- z represents if I go for a run or non.
And I would write it like and so:
x AND y = z
Here it is represented visually. The shaded region is the region which represents AND.
And now we'll represent information technology using what is called a Truth table. A truth table lists all the possible combinations of inputs for an expression (in this instance a single operation) and what the result, or output should be.
X | Y | Consequence |
---|---|---|
False | Imitation | Fake |
Truthful | Faux | False |
Faux | True | Faux |
Truthful | Truthful | True |
OR
OR is also the same as how we would use it in obviously english. It means that if either of the two variables is True and then the result is True. So for instance I could say that "I will become home early from work if I get to leave early OR the traffic is good".
Hither is OR represented visually :
And again every bit a truth table :
X | Y | Result |
---|---|---|
False | False | Fake |
True | False | Truthful |
False | Truthful | True |
True | True | True |
Note that AND is False for all only True and True whilst OR is True for all but False and False. This observation will get useful to the states after on. In fact there are many shortcuts and advantageous benefits to exist gained from finding patterns like this and then keep an eye out for them.
Not
Not is quite like to how nosotros apply information technology in plain english. Information technology has a subtle divergence when used in Boolean Algebra. Unremarkably I might say something like "I will eat dessert if I am non full". I could also have said "I volition eat dessert if I am withal hungry", which has the same significant but using an opposite value. And so not really has the effect of flipping the value of a variable. If :
- the variable d currently has a value of True then
- the expression not d has a result of False
Represented visually that is :
And as a truth tabular array :
X | Issue |
---|---|
True | False |
False | True |
Derived Operations
The in a higher place three operations are the edifice blocks for but about everything else we can do in Boolean Algebra. We will now introduce what are chosen derived operations. These are essentially shortcuts for commonly used combinations of the bones operations. As we will discover afterwards, some of these derived operations are very useful when we want to do computations and other things.
XOR or Exclusive OR
With the performance OR nosotros saw that every bit long equally one of the variables is Truthful the result is True. It was also True if both of them were True. With the performance XOR nosotros at present say that the result will exist True only if i of the ii variables is Truthful. That is, ane of them is True but merely one of them is True. We may build this performance from the basic operations similar and then :
grand XOR p is equivalent to (1000 OR p) AND NOT(g AND p)
When brackets ( ) are used in an expression this ways that nosotros evaluate that function of the expression first before the other parts.
Permit's run through an example to better understand what's going on.
If g is True and p is False then :
Substituting g and p for those values we get :
(True OR Faux) AND Not(True AND Imitation)
The kickoff set of brackets (Truthful OR Fake) AND Not(True AND False) evaluates to True so let's replace that into the expression and nosotros get :
True AND Non(True AND Fake)
The next ready of brackets True AND NOT (True AND False) evaluates to False so let's replace that into the expression likewise giving us :
True AND Non(False)
Non(False) evaluates to True and then nosotros tin can apply that to the expression and nosotros cease up with :
True and Truthful
And the final event is True.
Visually XOR looks like :
XOR every bit a truth table :
Ten | Y | Result |
---|---|---|
False | Fake | False |
Truthful | Simulated | True |
False | True | True |
True | Truthful | Fake |
NAND or NOT AND
NAND is effectively the opposite of what AND is.
r NAND Southward is equivalent to Not(r AND s)
Visually it looks like this :
NAND as a truth table :
X | Y | Result |
---|---|---|
Simulated | False | Truthful |
Truthful | Imitation | True |
False | True | True |
True | Truthful | Faux |
NOR or Non OR
NOR is effectively the opposite of OR.
b NOR 1000 is equivalent to Non(b OR yard)
Visually it looks like this :
NOR as a truth tabular array :
10 | Y | Issue |
---|---|---|
Faux | False | True |
True | Faux | Imitation |
False | True | Fake |
Truthful | True | False |
Summary
- Variable
- An item inside a Boolean expression.
- Basic Operators
- AND, OR and Not.
- Derived Operators
- XOR, NAND and NOR
- Expression
- The result of combining variables and operators.
- But two values
- There are simply always two possible values in Boolean Algebra. Typically True and Imitation but can exist others such as 0 and 1.
Activities
Now let's evaluate some expressions.
- :
- :
- :
How To Use Boolean Operators,
Source: https://ryanstutorials.net/boolean-algebra-tutorial/boolean-algebra.php
Posted by: barkleymidess.blogspot.com
0 Response to "How To Use Boolean Operators"
Post a Comment