Boolean Logic

Learning Outcomes

  • Combine sets using Boolean logic, using proper notations
  • Use statements and conditionals to write and interpret expressions

Logic is, basically, the study of valid reasoning. First we will learn about Boolean logic and then we will look at logical arguments and how we can determine the validity of a claim.

learning new vocabulary

Recall that learning new mathematical vocabulary, terminology and processes is a challenging task. Give yourself plenty of time to get familiar with new words and symbols before being tested on them!

This section introduces several new terms and even more than one term for the same ideas. But the principles of math study hold; practice and repetition will help your success.

You may have found by now that certain study strategies work particularly well for you. If so, continue to employ them as the course increases in difficulty. Give yourself time to get help and time to understand. You’ve got this!

Boolean Logic

We can often classify items as belonging to sets. If you went the library to search for a book and they asked you to express your search using unions, intersections, and complements of sets, that would feel a little strange. Instead, we typically use words like “and,” “or,” and “not” to connect our keywords together to form a search. These words, which form the basis of Boolean logic, are directly related to set operations with the same terminology.

Boolean Logic

Boolean logic combines multiple statements that are either true or false into an expression that is either true or false.

  • In connection to sets, a boolean search is true if the element in question is part of the set being searched.

Suppose M is the set of all mystery books, and C is the set of all comedy books. If we search for “mystery”, we are looking for all the books that are an element of the set M; the search is true for books that are in the set.

When we search for “mystery and comedy” we are looking for a book that is an element of both sets, in the intersection. If we were to search for “mystery or comedy” we are looking for a book that is a mystery, a comedy, or both, which is the union of the sets. If we searched for “not comedy” we are looking for any book in the library that is not a comedy, the complement of the set C.

Connection to Set Operations

A and B       elements in the intersection AB

A or B         elements in the union AB

Not A          elements in the complement Ac (recall from our study of sets, that complement of A can also be written )

Notice here that or is not exclusive. This is a difference between the Boolean logic use of the word and common everyday use. When your significant other asks “do you want to go to the park or the movies?” they usually are proposing an exclusive choice – one option or the other, but not both. In Boolean logic, the or is not exclusive – more like being asked at a restaurant “would you like fries or a drink with that?” Answering “both, please” is an acceptable answer.

In the following video, You will see examples of how Boolean operators are used to denote sets.

Example

Suppose we are searching a library database for Mexican universities. Express a reasonable search using Boolean logic.

In most internet search engines, it is not necessary to include the word and; the search engine assumes that if you provide two keywords you are looking for both. In Google’s search, the keyword or has be capitalized as OR, and a negative sign in front of a word is used to indicate not. Quotes around a phrase indicate that the entire phrase should be looked for. The search from the previous example on Google could be written:

Mexico university -“New Mexico”

Example

Describe the numbers that meet the condition:

even and less than 10 and greater than 0

Try It

Which Comes First?

Sometimes statements made in English can be ambiguous. For this reason, Boolean logic uses parentheses to show precedent, just like in algebraic order of operations.

The English phrase “Go to the store and buy me eggs and bagels or cereal” is ambiguous; it is not clear whether the requestors is asking for eggs always along with either bagels or cereal, or whether they’re asking for either the combination of eggs and bagels, or just cereal.

For this reason, using parentheses clarifies the intent:

Eggs and (bagels or cereal) means Option 1: Eggs and bagels,  or Option 2: Eggs and cereal
(Eggs and bagels) or cereal means  Option 1: Eggs and bagels,  or Option 2: Cereal

Example

Describe the numbers that meet the condition:

odd number and less than 20 and greater than 0 and (multiple of 3 or multiple of 5)

Be aware that when a string of conditions is written without grouping symbols, it is often interpreted from the left to right, resulting in the latter interpretation.

Statements and Conditionals

We will continue our study of logic by looking at statements and conditionals (or conditional statements). A statement is sentence that is either true or false, but not both.  In the study of logic, we will often label our statements using letters such as P and Q (if more than two, we continue with R, S, and T).  When statements are combined in the form “if P then Q“, the result is a conditional statement (or simply called a conditional).  The truth value of a conditional depends on the truth values of P and Q individually.  In a conditional. the statement P is often referred to as the “hypothesis”, while the statement Q is referred to as the “proposition”.

Example

A statement like 3 < 5 is true; a statement like “a rat is a fish” is false. The sentence “The movie was good” is not considered a statement since it can be true or false depending on individual opinions.   An example of a conditional is “if it is raining, then Daisy will not ride her bike”.  The conditional is made up of the two statements:  “it is raining” and “Daisy will not ride her bike”.

Statements and Conditionals

A statement (also referred to as a simple statement) is a sentence that is either true or false but not both.
A compound statement (also referred to as a complex statement) is a sentence with two or more simple statements combined using a connective (such as and and or).
A conditional is a compound statement of the form
“if P then Q”  or  “if P then Q, else S”.

The symbol often used when writing conditionals is → (a rightwards arrow).  So you can write “if P then Q” as “P → Q”.

In common language, an example of a conditional statement would be “If it is raining, then we’ll go to the mall. Otherwise we’ll go for a hike.”
The statement “If it is raining” is the condition—this may be true or false for any given day. If the condition is true, then we will follow the first course of action, and go to the mall. If the condition is false, then we will use the alternative, and go for a hike.

Try It

*Ignore the “Try a similar question.”  There is only one attempt at each question.

We can create more complex conditions by using the operators and, or, and not to join simpler conditions together.

Example

A parent might say to their child “if you clean your room and take out the garbage, then you can have ice cream.” Under what circumstances will this conditional be true?

Notice that if the parent had said “if you clean your room or take out the garbage, then you can have ice cream”, then the child would only need to complete one chore to meet the condition.

Click here to see a short video with an example of a conditional and determining whether it is true or false.