CS5002 Lecture Notes_Week 1
CS5002 Lecture Notes_Week 1
Lecture 1
Lecturer: Adrienne Slaughter, Tamara Bonaci Scribes:
1.1 Overview
1. Logic: Operators, propositions, equivalences, predicates, quantifiers.
2. Introduction to Boolean algebra
3. Boolean algebra and digital logic
4. Boolean functions
1.2 Introduction
In today’s lecture, we will introduce the field of mathematical logic, a subfield of mathematics that explores
the applications of formal logic to mathematics.
It is often considered that the roots of the modern logic stem from a Greek philosopher Aristotle, who
developed the first collection of rules of deductive reasoning that were intended to serve as a basis for the
study of every branch of knowledge. Aristotle’s ideas, however, remained dormant until the seventeenth
century, when the German philosopher and mathematician Gottfried Leibniz proposed the idea of using
symbols to simplify the process of deductive reasoning, in a similar way as algebraic notation is being used
to reason about numbers and their relationship.
Leibniz’s idea was realized by the English mathematicians George Boole and Augustus De Morgan in the
nineteenth century, when they invented the field of symbolic logic. From there, mathematical logic was born.
The expressive power of formal systems, and the deductive power of formal proof system is often considered
the unifying theme of mathematical logic.
Mathematical logic is often divided into the fields of set theory, model theory, recursion theory, and proof
theory, and in this course, we will talk about all of these theories. Today, however, we will start by focusing
on logical form and logical equivalence.
1-1
1-2 Lecture 1
1.3.1 Definitions
Examples of Propositions:
• 2 + 2 = 4 TRUE
• Seattle is in Washington. True
• 3 × 6 = 15 False
• Seattle is in California. False
Practice
Which of the following are propositions?
1. What’s your favorite movie? No
2. Read the newspaper. No
3. x2 + y 2 = z 2 Yes
4. Seattle is in California. Yes
Just like with algebra, letters are used to represent propositions:
• p: 2 + 2 = 4
• q: Seattle is in California.
Definition 1.2. Truth Value The truth value of a proposition is true (T) if it is a true proposition and
false (F) if it is false.
Definition 1.3. Truth Table A truth table displays the relationship between the truth values of propositions.
p ¬p
T F
F T
Definition 1.4. Negation The negation operator reverses the truth value of a proposition. Represented
by the symbol: ¬
The proposition ¬p is false when p is true, and true when p is false.
p ¬p
T F
F T
Definition 1.5. Conjunction
A conjunction is a fancy word for and.
Lecture 1 1-3
p q p∧q
T T T
T F F
F T F
F F F
Example 1.5.1. Let’s consider the following two propositions, p and q:
p: Sam left the party.
q: Pat arrived at the party.
p∧q
p q p∧q
T T T Sam left the party and Pat arrived at the party.
T F F Sam left the party; Pat did not arrive at the party.
F T F Sam did not leave the party; Pat arrived at the party.
F F F Sam did not leave the party; Pat did not arrive at the party.
p q p∨q
T T T
T F T
F T T
F F F
Example 1.6.1. Let’s consider the following OR example:
p: It is Wednesday.
q: I am preparing lecture.
p∨q
p q p∨q
T T T It is Wednesday and I am preparing lecture.
T F T It is Wednesday but I am not preparing lecture.
F T T It is not Wednesday, but I am preparing lecture.
F F F It is not Wednesday, and I am not preparing lecture.
1-4 Lecture 1
Sometimes I don’t prepare lecture on Wednesdays, but if it’s not Wednesday, then I am preparing lecture.
p q p⊕q
T T F
T F T
F T T
F F F
Example 1.7.1. Let’s examine the following XOR example”
p: It is Wednesday.
q: I am preparing lecture.
p⊕q
p q p⊕q
T T F It is Wednesday and I am preparing lecture.
T F T It is Wednesday but I am not preparing lecture.
F T T It is not Wednesday, but I am preparing lecture.
F F F It is not Wednesday, and I am not preparing lecture.
It is either Wednesday, or I am preparing lecture; it is never the case that I am preparing lecture on
Wednesday.
Definition 1.8. Conditional or Implication
A conditional or implication is also known as “if p, then q”. The proposition p → q is false when p is true
and q is false, and true otherwise.
p q p→q
T T T
T F F
F T T
F F T
p q p→q
T T T The report said rain, so I wore my coat.
T F F The report said rain, so I didn’t wear my coat.
F T T The report said sun, but I wore my coat.
F F T The report said sun, and I didn’t wear my coat.
p = x2 − 4 ≥ 0 (1.1)
q = |x| ≥ 2 (1.2)
p q ???
T T Does there exist an x such that p and q are both true?
T F Does there exist an x such that p is true and q is false? .
F T Does there exist an x such thatp is falseandqis true?
F F Does there exist an x such that p and q are both false?
An implication is true exactly when the if-part is false or the then-part is true.
Example 1.8.3. If pigs fly, then your account won’t get hacked.
This proposition has the form P → Q where the hypothesis P is and the conclusion Q
is “ ”. We just have to figure out if the proposition is true: We know pigs don’t fly, so we
either are ‘ft’ or ‘ff’: Both cases make the proposition as a whole true.
p q p→q
T T T
T F F
F T F
F F T
Example 1.9.1. Biconditional example
p: The weather report says rain.
q: I wear my rain coat.
p↔q
The contrapositive is: “If I do not have a test today, then today is not Thursday”
Logical Equivalence
We can evaluate the logical equivalence of two propositions by comparing the truth tables of each
statement.
Prove the following two statements are logically equivalent:
¬p ∨ q and p → q
p q ¬p ¬p ∨ q p→q
T T F T T
T F F F F
F T T T T
F F T T T
p q p ∨ q ¬(p ∨ q) ¬p ¬q ¬p ∧ ¬q
T T T F F F F
T F T F F T F
F T T F T F F
F F F T T T T
1-8 Lecture 1
Is this a proposition?
p : x2 + y 2 = z 2
Well... kinda.
P (x, y, z) : x2 + y 2 = z 2
Back at the beginning, I said this is a proposition. It’s not really– it’s actually something called a predicate.
Predicates:
P (x) : x > 3
• If x = 5, P (x) = P (5) = 5 > 3 ⇒ true
• If x = 1, P (x) = P (1) = 1 > 3 ⇒ f alse
At this point, you should be thinking: But, we can define some rules that define when P is true and false.
1.3.7.1 Quantifiers:
P (x) : x is a professor
Q(x) : x is ignorant
R(x) : x is vain
Express each of the statements using quantifiers and logical operators, where the universe of discourse is
the set of all people.
1. No professors are ignorant. ∀x(P (x) → ¬Q(x))
2. All ignorant people are vain.∀x(Q(x) → R(x))
3. No professors are vain. ∀x(P (x) → ¬R(x))
4. Does (3) follow from (1) and (2)?
No. P implies not Q; P implies not R; and Q implies R, but no statement has been made about
whether P implies R. The statements do not rule out the possibility of other vain people that are not
ignorant.
Example 1.11.5. Another Example2
P (x) : x is a baby
Q(x) : x is logical
R(x) : x is able to manage a crocodile
S(x) : x is despised
Express each of the statements using quantifiers, logical connectives and the statements, where the universe
of discourse is the set of all people.
1. Babies are illogical: ∀x(P (x) → ¬Q(x))
2. Nobody is despised who can manage a crocodile. ∀x(R(x) → ¬S(x))
3. Illogical persons are despised. ∀x(¬Q(x) → S(x))
4. Babies cannot manage crocodiles. ∀x(P (x) → ¬R(x))
5. Does (4) follow from (1), (2) and (3)?
Yes.
If x is a baby, then by (1), x is illogical. By (3), x is despised. (2) says that if x could manage a
crocodile, then x would not be despised. Therefore, x cannot manage a crocodile.
9/5/19, 3(17 PM
several laws of propositional logic that are particularly useful for establishing the logical
equivalence of compound propositions:
¬∀P (x) ≡ ∃x¬P (x) (1.5)
¬∃P (x) ≡ ∀¬P (x) (1.6)
Table 1.5.1: Laws of propositional logic.
p∨(q∧r)≡(p∨q)∧(p∨r p∧(q∨r)≡(p∧q)∨(p∧r
Distributive laws:
) )
p ∧ ¬p ≡ F p ∨ ¬p ≡ T
Complement laws:
¬T ≡ F ¬F ≡ T
De Morgan's laws: ¬( p ∨ q ) ≡ ¬p ∧ ¬q ¬( p ∧ q ) ≡ ¬p ∨ ¬q
Absorption laws: p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p
Conditional
p → q ≡ ¬p ∨ q p q≡(p→q)∧(q→p)
p28
identities:
PARTICIPATION 1.5.2: The laws of propositional logic can be used to show logical
ACTIVITY equivalence.
1.5 Logic Puzzles (Optional)
Animation
A logic puzzle is content:
a puzzle that provides a story and some clues, and from a few clues, you use logical
reasoning to find the solution. An example is below:
undefined
Example 1.11.6. Logic Puzzle
The U.S.Animation
Air Force captions:
is currently testing a number of new experimental, supersonic aircraft, each built by a
different aerospace company. Using only the clues below, determine the price of each aircraft, as well as the
name of the company that built it. No two aircraft cost the same, and no company built more than
about:blank Page 55one
of 169
aircraft.
Lecture 1 1-11
Clues
1. The Kesseling costs $125 million.
2. The Dragon F-15 costs $175 million.
3. The plane built by Wiseman costs 25 million dollars less than the Kesseling.
4. The plane built by McConnell costs 50 million dollars more than the Vipertooth.
5. The Dragon F-15 is either the $150 million jet or the jet built by Pittakan.
A common way to solve this problem is to draw a chart, fill in the pieces of information that we know from
the clues and then deduce the unknowns from the knowns. It might look something like this:
First, we put an O in the box at the intersection of Kesseling and $125 million. Then, because the plane can
only have one price, and no other plane can have the same price, we fill in X’s to indicate that.
Clue 2: we put an O in the box at the intersection of Dragon F-15 and $175 million, and X’s in the rest of
the row and column.
Clue 3: We know how much the Kesseling costs, so now we know how much the plane built by Wiseman
costs; we mark an O at the intersection of Wiseman and $100 million and the accompanying Xs. We *also*
now know that the Kesseling is NOT made by Wiseman, so we put an X at the intersection of Kesseling and
Wiseman.
Clue 4: We don’t yet know how much the Vipertooth costs, but we know that McConnell didn’t build the
Vipertooth. We also know that the Vipertooth can’t cost $150 or $175 million, and that the plane built by
McConnell MUST cost $150 or $175 million.
Clue 5: This one is a bit more complicated. There are two truth statements here. We know that the overall
clue is TRUE, so one or both of the two statements are true. We know the first part of the statement is not
true (The Dragon F-15 costs $175, not $150 million, which we got from Clue 2), so the second part of the
clue MUST be true. So we put an O in the box at the intersection of Dragon F-15 and Pittakan, and fill in
the accompanying Xs.
At this point, we don’t have any more clues, but we are able to fill in the rest of the grid easily. Then, we
can read the solution off the grid:
An observation: when we get find a truth value of “TRUE” for a given box in the grid, we also get many
more other bits of information, and we can fill out more squares. That is, when we know that one thing
IS true, we know that many other things are FALSE. This isn’t the case when we have a piece of negative
information: just because we know that something ISN’T true, that (by itself) tell us what IS true.
Boolean algebra is a set of rules and operations for working with variables whose values are either 0 or 1. As
it happens, the rules of Boolean algebra are very similar to the rules of propositional logic, where the value
1 typically corresponds to truth value T in the rules of propositional logic, and the value 0 to truth value F.
Variables that can have a value of 1 or 0 are called Boolean variables. Boolean expressions can be built
up by applying Boolean operations to Boolean variables or the constants 1 or 0.
Boolean multiplication, denoted by ·, applies to two elements from {0, 1}, and obeys the standard rules for
multiplication. The results of the multiplication operation are the same as the logical ∧ (”and”) operation.
p q Logical p ∧ q x y Boolean x · y
T T T 1 1 1
T F F 1 0 0
F T F 0 1 0
F F F 0 0 0
Definition 1.13. Boolean Addition
Boolean addition, denoted by +, applies to two elements from {0, 1}, and obeys the standard rules for
addition, except for 1 + 1. An outcome of 2 would not be allowed because all values in Boolean algebra
must be 0 or 1. The results of the addition operation are the same as the logical ∨ (”or”) operation.
p q Logical p ∨ q x y Boolean x + y
T T T 1 1 1
T F T 1 0 1
F T T 0 1 1
F F F 0 0 0
Definition 1.14. Boolean Complement
The complement of an element, denoted with a bar symbol, reverses that element’s value. Complementing
a Boolean value is analogous to applying the ¬ (”not”) operation in logic.
p Logical ¬p x Boolean x̄
T F 1 0
F T 0 1
Two Boolean expressions are equivalent if they have the same value for every possible combination of values
assigned to the variables contained in the expressions. In propositional logic, a special symbol (≡) is used
to denote logical equivalence. In Boolean algebra, the equal sign (=) is used to denote logical equivalence.
The rules of Boolean algebra satisfy the same set of laws (pairs of equivalent expressions) that we studied
in propositional logic.
satisfy the same set of laws (pairs of equivalent expressions) that were satis?ed in
propositional logic:
Lecture 1 1-13
The laws of Boolean algebra can be applied in the same way as the laws of propositional
1.6.3 Boolean Function
logic to show that two Boolean expressions are equivalent.
Definition 1.15. Boolean Function
A Boolean function maps one or more Boolean input values to the set {0, 1}. Let B = {0, 1}. Then B k
PARTICIPATION 2.1.4: Simplifying Boolean expressions using the laws of Boolean
is the set of all k-tuples over the set B. A Boolean function with k input variables maps B k to B.
ACTIVITY algebra.
Definition 1.16. Input-Output Table
Input-output table is one way to define a Boolean function. Input-output table shows the output value of
Animation content:
the function for every possible combination of input values. A Boolean function with k input variables will
require an input/output table with 2k rows.
c1 + c2 + · · · + cm
where each dj for j ∈ {1, ..., m} is a sum of literals, and each d1 is called a clause.
A set of operations is functionally complete if any Boolean function can be expressed using only operations
from the set. The set {addition, multiplication, complement} is functionally complete because any Boolean
function can be expressed in disjunctive normal form which only uses addition, multiplication, and complement
operations.
What happens, however, if some of the operations {addition, multiplication, complement} are hard to
implement in hardware?
For example, if the addition operation was particularly difficult to implement in hardware, we might want
to implement an equivalent Boolean function using only multiplication and complement operations. The
question that arises: is it possible to express any Boolean function using only multiplication and
complement? In other words, is the set multiplication, complement functionally complete?
The answer that that questions is YES, and here are the steps to express any Boolan function using only
multiplication and complement:
• Start with the input/output table for the function.
• Find a DNF expression that is equivalent to the function.
• Repeatedly apply De Morgan’s law to eliminate each addition operation.
Lecture 1 1-15
On the other hand, if multiplication is a difficult operation to implement (instead of addition), we might
want to implement a Boolean function using only addition and complement operations. Againm, we can do
that, and steps are as follows:
• Start with the input/output table for the function.
• Find a DNF expression that is equivalent to the starting function.
• Repeatedly apply De Morgan’s law until all the multiplication operations have been eliminated.
The result will be a Boolean expression that uses only addition and complement, and is equivalent to the
original function. Therefore, the set addition, complement is also functionally complete.
Inspired by the previous observations we might wonder: could we use only one type of operation to
compute any Boolean function? In other words, is it possible for a single Boolean operation to be
functionally complete by itself? As we’ve already seen, neither addition, multiplication, nor complement are
by themselves functionally complete, so only a new operation could possibly be functionally complete by
itself.
Luckily for us such a function exists.
Solving the Boolean satisfiability problem by considering all possible settings for the variables takes time
proportional to 2n for an expression with n variables. Problems that require time proportional to an
exponential of an input are typically called non-polynomial (NP) problems, and are not considered
time efficient.
Note: While a shortcut to solving a Boolean satisfiability problem may exists, as of today, no one knows
a provably efficient method to solve SAT, despite years of research effort. In fact, many computer scientists
1-16
Boolean algebra was defined by George Boole in the mid-19th century. Since then, Boolean algebra has
become the basis of computer circuit design due to the fact that the native language of computers is
expressed in 0s and 1s. Although the physical representation has since changed, the underlying mathematical
foundation is still Boolean algebra. The area of computer science concerned with designing computer circuitry
is called digital logic, an indication of the vital role that logic plays in this field.
Circuits are built from electrical devices called gates. A gate receives some number of Boolean input values,
and produces an output based on the values of the inputs. Thus, a gate implements a simple Boolean
function.
Three types of gates that perform the three basic Boolean operations include:
• The AND gates - compute Boolean multiplication
• The OR gates - compute Boolean addition
• The inverters - compute the complement
Summary
• Propositions
• Truth Values
• Truth Tables
• Logical operators (sometimes called Logic Connectives), to create compound statements
• Predicates
• Quantifiers
• Universe of discourse
• Laws of propositional logic
• De Morgan Laws
• Nested quantifiers
• Boolean algebra
• Boolean variables
• Boolean expressions
• Literals
• Miniterm
• Disjunctive Normal Form (DNF)
• Conjunctive Normal Form (CNF)
• Functional completeness
• NAND operation
• NOR operation
• Boolean satisfiability (SAT) problem
• Digital Logic
• Gates