CC141
Discrete Structures
Introduction
1
The Scope
• Discrete Structures deals with
The studies of mathematical structures that are
fundamentally discrete (Not require the notion of
continuity)
The countable things
2
Why Discrete Math?
• Discrete math forms the basis for computer
science
Sequences
Digital logic (how computers compute)
Algorithms
Program correctness
Probability and gambling (or taking risks)
“Continuous” math forms the basis for most
physical and biological sciences
3
Propositions
• A proposition is a statement that is either
true or false
“The sky is blue”
“Today the temperature is below freezing”
“9 + 3 = 12”
Not propositions:
“Who is Bob?”
“How many persons are there in this group?”
“X + 1 = 7.”
4
Propositional (or Boolean) variables
• Variables that refer to propositions
Usually denoted by lower case letters p, q, r, etc.
Can have one of two values true (T) or false (F)
• A proposition can be
A single variable p
A formula of multiple variables
o E.g. p ∧ q, s ∨¬r
5
Propositional (or Boolean) operators
• About a dozen operators
Similar to the algebraic operators e.g. +, *, -, /
In the following examples:
P =: “Today is Friday”
q =: “Today is my birthday”
=: reads as “represents” or “means”
P is syntax.
“Today is Friday” is the semantic.
6
Logical operator: NOT
• A not operation switches (negates) the truth value.
• Symbol used for NOT is ¬ or ~
E.g. ¬ P =: “Today is not Friday”
• In programming languages like C++ and Java, the
symbol used is !
7
Logical operator: AND
8
Logical operator: OR
9
Logical operator: EXCLUSIVE OR
10
(Inclusive) OR or EXCLUSIVE OR?
11
Logical Operator NAND and NOR
12
Conditional Operator
13
Conditional operators
14
Conditional operators
15
Set representations
A proposition p can also be represented by a
set (a collection of elements) for which the
proposition is true.
p
p
pp p∧q
q
q
¬p p∨q
Venn diagram
16
Bi-conditional Statements
17
Translating into English
18
Translating into English
Example
“You cannot ride the roller coaster if you are
under 4 feet tall unless you are older than
16 years old.”
Q = “You can ride the roller coaster”
R = “You are under 4 feet tall”
S = “You are older than 16 years old”
(R S) Q
19
Precedence of Operators
20
Boolean operators in search
• Boolean search
• System Specifications (formal methods in SE)
• Logical Puzzles (like in GRE exam)
• Logical Circuits (Electronics/DLD)
21
Tautology and Contradiction
• Compound proposition refers to an expression
formed from propositional variables using
logical operators, e.g. p ∧ q
• A compound proposition that is always true is
called a tautology
• A compound proposition that is always false is
called a contradiction
• A compound proposition that is neither a
tautology nor a contradiction is called a
contingency
22
Logical Equivalence
• Compound propositions p and q are called logically
equivalent if p ↔ q is a tautology
• Notation p ≡ q denotes that p and q are logically
equivalent
• Note that
The symbol ≡ is not a logical connective
p ≡ q is not a compound proposition but rather is the
statement that p ↔ q is a tautology
The symbol ⇔ is sometimes used instead of ≡ to denote
logical equivalence
23
Example
Show that p → q and ¬p ∨ q are logically equivalent.
24
Logical Equivalences
25
Logical Equivalences
26
How to prove Equivalences
• Two methods
Using truth tables
o Not good for long formulae (e.g. involving more than 5
variables)
Using logical equivalences
27
Example
Show that (p ∧ q) → (p ∨ q) is a tautology.
Solution.
Draw truth table to verify it.
28