Lecture01 Single Slide Handout
Lecture01 Single Slide Handout
Lecture 1:
Dr Abdullah Alharbi
Semester 1
(1442 AH – 2020 AD)
Lecture’s content is taken from “Discrete Mathematics and Its Applications” 8th edition by Kenneth H. Rosen. McGraw‐Hill, 2019.
Lectures contents:
Propositional Logic
Applications of Propositional Logic
Propositional Equivalences
Predicates and Quantifiers
2
Propositional Logic:
Propositions:
Truth value
Propositional variables
Atomic propositions
Compound propositions
Connectives (Logical Operators):
Negation
Conjunction ∧
Disjunction ∨
Conditional Statements:
Implication →
Contrapositive
Inverse
Converse
Biconditional
Truth Tables
Precedence of Logical Operators
Logic and Bit Operations 3
Propositions
A proposition is a declarative sentence that is either true or false.
• Examples of propositions:
a) The Moon is made of green cheese.
b) Trenton is the capital of New Jersey.
c) Toronto is the capital of Canada.
d) 1+0=1
e) 0+0=2
5
Propositions
• Compound Propositions:
• constructed from logical connectives and other propositions to form new
propositions.
• Negation (
• Conjunction ( ∧
• Disjunction ( ∨
• Implication ( → )
• Biconditional ( ↔ )
• The area of logic that deals with propositions is called the propositional calculus or
propositional logic.
• It was first developed systematically by the Greek philosopher Aristotle more than 2300
years ago.
6
Negation
• The negation of a proposition p is denoted by p and has this
truth table:
p p
T F
F T
• Example:
• If p denotes “The earth is round.”, then p denotes “It is not
the case that the earth is round,” or more simply “The earth is
not round.”
7
Conjunction
• The conjunction of propositions p and q is denoted by p q and
has this truth table:
p q P∧q
T T T
T F F
F T F
F F F
• Example:
• If p denotes “I am at home.” and q denotes “It is raining.” then
p q denotes “I am at home and it is raining.”
8
Disjunction
• The disjunction of propositions p and q is denoted by p q and
has this truth table:
p q P∨q
T T T
T F T
F T T
F F F
• Example:
• If p denotes “I am at home.” and q denotes “It is raining.” then p ∨ q
denotes “I am at home or it is raining.”
9
The Connective Or in English
• In English “or” has two distinct meanings:
1. “Inclusive Or”:
• In the sentence “Students who have taken CS202 or Math120 may take this class,”
we assume that students need to have taken one of the prerequisites, but may have taken both.
• This is the meaning of disjunction.
• For p ∨ q to be true, either one or both of p and q must be true.
p q P⊕q
2. “Exclusive Or”: T T F
• When reading the sentence “Soup or salad comes with this entrée,”
we do not expect to be able to get both soup and salad. T F T
• This is the meaning of Exclusive Or (Xor). F T T
• In p ⊕ q , one of p and q must be true, but not both. F F F
• The truth table for ⊕ is:
10
Implication
• If p and q are propositions, then p → q is a conditional statement or implication
which is read as “if p, then q” and has this truth table:
p q P→q
T T T
T F F
F T T
• Example: F F T
• If p denotes “I am at home.” and q denotes “It is raining.” then p → q denotes
“If I am at home, then it is raining.”
• In p → q, p is the hypothesis (antecedent or premise) and q is the conclusion (or
consequence).
11
Understanding Implication 1
12
Understanding Implication 2
17
Truth Tables for Compound Propositions
• Construction of a truth table:
• Rows
• Need a row for every possible combination of values for the atomic
propositions.
• Columns
• Need a column for the compound proposition (usually at far right)
• Need a column for the truth value of each expression that occurs in the
compound proposition as it is built up.
• This includes the atomic propositions
18
Example Truth Table
• Construct a truth table for p q→ r
p q r r p∨q p∨q→ r
T T T F T F
T T F T T T
T F T F T F
T F F T T T
F T T F T F
F T F T T T
F F T F F T
F F F T F T
19
Equivalent Propositions
• Two propositions are equivalent if they always have the same
truth value.
• Example:
• Show using a truth table that the conditional is equivalent to the
contrapositive.
• Solution: p q p q p→q q→ p
T T F F T T
T F F T F F
F T T F T T
F F T T T T
20
Using a Truth Table to Show Non‐Equivalence
• Example:
• Show using truth tables that neither the converse nor inverse of an
implication are not equivalent to the implication.
• Solution:
p q p q p→q p→ q q→p
T T F F T T T
T F F T F T T
F T T F T F F
F F T T T T T
21
Problem
• How many rows are there in a truth table with
n propositional variables?
• Solution:
• 2n
• Note that this means that with n propositional variables, we
can construct 2n distinct (that is, not equivalent)
propositions.
22
Precedence of Logical Operators
Operator Precedence
1
∧ 2
∨ 3
→ 4
↔ 5
• p q→ r is equivalent to (p q) → r
• If the intended meaning is p (q → r), then parentheses
must be used.
23
Logic and Bit Operations
• Computers represent information using bits.
• A bit is a symbol with two possible values, namely, 0 (zero) and 1 (one).
• This meaning of the word bit comes from binary digit
• Because zeros and ones are the digits used in binary representations of
numbers.
• A bit can be used to represent a truth value
• Because there are two truth values, namely, true and false.
• We will use a 1 bit to represent true and a 0 bit to represent false.
• That is, 1 represents T (true), 0 represents F (false).
24
Logic and Bit Operations
• A variable is called a Boolean variable if its value is either true or false.
• Consequently, a Boolean variable can be represented using a bit.
• Computer bit operations correspond to the logical connectives.
• By replacing true by a one and false by a zero in the truth tables for the operators ∧, ∨, and ⊕, the
columns in Table 9 for the corresponding bit operations are obtained.
• We will also use the notation OR, AND, and XOR for the operators ∨, ∧, and ⊕, as is done in various
programming languages.
25
Logic and Bit Operations
• Information is often represented using bit strings, which are lists of zeros
and ones.
• When this is done, operations on the bit strings can be used to manipulate this
information.
• Definition:
• A bit string is a sequence of zero or more bits.
• The length of this string is the number of bits in the string.
• Example:
• 101010011 is a bit string of length nine.
26
Logic and Bit Operations
• We can extend bit operations to bit strings.
• We define the bitwise OR, bitwise AND, and bitwise XOR of two strings of the
same length
• We use the symbols:
• ∨ (bitwise OR)
• ∧ (bitwise AND)
• ⊕ (bitwise XOR).
• Example:
• Find the bitwise OR, bitwise AND, and bitwise XOR of the bit strings
01 1011 0110 and 11 0001 1101.
• (Here, bit strings will be split into blocks of four bits to make them easier to read.)
27
Logic and Bit Operations
• Solution:
• The bitwise OR, bitwise AND, and bitwise XOR of these strings are
obtained by taking the OR, AND, and XOR of the corresponding bits,
respectively. This gives us:
28
Applications of Propositional Logic
• Translating English to Propositional Logic
• System Specifications
• Boolean Searching
• Logic Puzzles
• Logic Circuits
29
Translating English Sentences
• Steps to convert an English sentence to a statement in
propositional logic
• Identify atomic propositions and represent using propositional variables.
• Determine appropriate logical connectives
• “If I go to Harry’s or to the country, I will not go shopping.”
• p: I go to Harry’s
• q: I go to the country. p q r
• r: I will go shopping.
If p or q then not r.
30
Example
• Problem: Translate the following sentence into propositional
logic:
• “You can access the Internet from campus only if you are a computer
science major or you are not a freshman.”
• One Solution:
• Let a, c, and f represent respectively “You can access the internet
from campus,” “You are a computer science major,” and “You are a
freshman.”
a c f
31
System Specifications
• System and Software engineers take requirements in English
and express them in a precise specification language based on
logic.
• Example: Express in propositional logic:
• “The automated reply cannot be sent when the file system is full”
• Solution:
• One possible solution: Let p denote “The automated reply can be
sent” and q denote “The file system is full.”
q p
32
Logic Circuits
• Electronic circuits; each input/output signal can be viewed as a 0 or 1.
• 0 represents False
• 1 represents True
• Complicated circuits are constructed from three basic circuits called gates.
• The inverter (NOT gate) takes an input bit and produces the negation of that bit.
• The OR gate takes two input bits and produces the value equivalent to the disjunction of the two bits.
• The AND gate takes two input bits and produces the value equivalent to the conjunction of the two bits.
• More complicated digital circuits can be constructed by combining these basic circuits to produce the
desired output given the input signals by building a circuit for each piece of the output expression and
then combining them.
• Example:
33
Propositional Equivalences
• Tautologies
• Contradictions
• Contingencies
• Logical Equivalence
• Important Logical Equivalences
• Showing Logical Equivalence
34
Tautologies, Contradictions, and Contingencies
• A tautology is a proposition which is always true.
• Example: p ∨ p
• A contradiction is a proposition which is always false.
• Example: p ∧ p
• A contingency is a proposition which is neither a tautology nor a
contradiction, such as p
P p p∨¬p p∧¬p
T F T F
F T T F
35
Logically Equivalent
• Two compound propositions p and q are logically equivalent if p ↔ q is a
tautology.
• We write this as p ⇔ q or as p ≡ q where p and q are compound propositions.
• Two compound propositions p and q are equivalent if and only if the
columns in a truth table giving their truth values agree.
• This truth table shows that p ∨ q is equivalent to 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
36
De Morgan’s Laws
Augustus De Morgan
1806‐1871
p q p q
p q p q
p q p q (p ∨ q) (p ∨ q) p∧ q
T T F F T F F
T F F T T F F
F T T F T F F
F F T T F T T
37
Key Logical Equivalences 1
• Idempotent laws: p p p, p p p
• Negation Laws: p p T , p p F
38
Key Logical Equivalences 2
• Commutative Laws: p q q p, p q q p
• Associative Laws: p q r p q r
p q r p q r
• Distributive Laws: p q r p q p r
p q r p q p r
• Absorption Laws: p p q p p p q p
39
More Logical Equivalences
TABLE 7 Logical Equivalences TABLE 8 Logical Equivalences
Involving Conditional Statements. Involving Biconditional Statements.
p q p q p q p q q p
p q q p
p q p q
p q p q
p q p q p q
p q p q
p q p q
p q p q
p q p r p q r
p r q r p q r
p q p r p q r
p r q r p q r
40
Any questions?
• Keep reviewing this lecture periodically.
• Do the “Extra Examples” found on the textbook’s website.
• Seek help either from me or your tutors as early as possible.
• Try the exercises at the end of each section.
41