# What Is Boolean Logic? - Definition, Diagram & Examples

Instructor: Lonny Meinecke

Lonny is a PhD student, a part-time teaching assistant/Sennseis for positive psychology, and has a bachelor's degree in IT and a master's degree in psychology.

In this lesson you will learn about Boolean logic, which is a way to figure out the ''truth'' of an expression using the simple concept of true or false (1 or 0). This type of simple math is ideal for use on computers, since they really only handle 1s and 0s.

## Boolean? What's That?

The word Boolean doesn't show up in your everyday text message, does it? It comes from a famous guy named George Boole who figured out a way to put formal logic into mathematical form. Simply put, Boolean logic is a very easy way to figure out the truth of an expression using the simple concept of true or false. In a nutshell, Boolean logic means you are working with stuff that is either TRUE or FALSE (and nothing else as Monty Python would say). Logicians refer to this exclusiveness as the law of excluded middle. That's what we mean by truth here -- it is or it isn't true.

Let's say we have a variable value called sunny_day. It can be either true or false. That's a Boolean. Now let's say you want to go body surfing at the beach, but you don't want to go when it's cold or rainy, just when it's a sunny day. You can use Boolean logic:

IF (sunny_day) THENâ€¦

Now let's say you don't swim so well, so you gotta have your water-wings on too. You add the variable water-wings:

IF (sunny_day) AND (water-wings) THENâ€¦

That's the gist of it. If both of these are true, then the output is true (and you head to the beach). But if even one of these are false, then the output is false (and you stay home and dream of the beach).

## You've Been Using Booleans and Didn't Know It

Did you know you have been using Boolean logic whenever you search the web? Well, you sure have! Let's say you want to do a search for Thomas Jefferson. You could type in Thomas. Or, you could type in Jefferson. Or, you could type in Thomas Jefferson. The search results you end up with depend on what you propose. Let's say you simply type in his full name:

You may get this:

You get this odd jumble of folks because the search engine is looking for either Thomas or Jefferson. To fix it, you could use quotes around the two words -- or you could use a Boolean operator called AND:

Now you're sure to get results for the third U.S. President. See? You already know what some Boolean logic looks like!

## It Can't be that Easy!

You're right; there's a bit more to Boolean logic than this. There are several more Boolean operators besides just AND. The most common ones are AND, OR, NOT, NAND, NOR, XOR. Let's go over them really quickly. We'll use the conventional letters P and Q.

AND means that if P and Q are both true, the result is true. Otherwise, the result is false.

OR means that if either P or Q are true, the result is true. Otherwise, the result is false.

NOT means to flip the current state. True becomes false and false becomes true.

NAND is just like AND but you flip each possible combination.

NOR is just like OR but you flip each possible combination.

XOR means if either P or Q is true - but not both - the output is true. Otherwise, the result is false.

Maybe we should show you some truth tables? They make it super simple. For any combination, just line up the present states of P and Q and read across.

## Now to Prove This with an Example, or QED as They Say

You are no doubt wondering what all these neat logical truths are leading up to. Well, there are lots of times (especially in computer science) when you simply have to reduce a set of conditions to some simple math. The simplest math, as you might guess, would just use 1 and 0 or TRUE and FALSE.

Harry Fairhead at I Programmer uses a really common example to demonstrate Boolean logic for us, such as the need to design a computer program or electrical circuit that helps us catch burglars.

P will be our way of telling whether it's daytime.

To unlock this lesson you must be a Study.com Member.

### Register for a free trial

Are you a student or a teacher?
Back

Back

### Earning College Credit

Did you know… We have over 95 college courses that prepare you to earn credit by exam that is accepted by over 2,000 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.