Resources
All homework, Quizzesand most other
lecture material will be available on LMS
Additional references shall be provided (if
any)
Text Book
Discrete Mathematics and Its Applications (7th
Edition) by Kenneth H. Rosen.
Reference
Discrete Mathematics by Ross and Wright
3.
Grading Policy
Assignments (3-5)10%
Quizzes (3-5) 10%
Midterm/OHT 30%
End-term 50%
4
Assignments
Quizzes
Mostly unannounced
Occasionally
announced
Point System - every activity in the class gives you a
certain number of points
4.
Quick Overview
Mathematics canbe broadly classified into two categories:
Continuous Mathematics It is based upon continuous
−
number line or the real numbers. It is characterized by the fact
that between any two numbers, there are almost always an
infinite set of numbers. For example, a function in continuous
mathematics can be plotted in a smooth curve without breaks.
Discrete Mathematics It involves distinct values; i.e.
−
between any two points, there are a countable number of
points. For example, if we have a finite set of objects, the
function can be defined as a list of ordered pairs having these
objects, and can be presented as a complete list of those pairs.
5.
Discrete Mathematics
A branchof mathematics that uses algebra and
arithmetic and involving discrete elements is known
as Discrete Mathematics.
Discrete mathematics is mostly applied in the field
of mathematics and computer science. Reasoning
and problem-solving capabilities are improved by
discrete mathematics.
Some of the fundamental concepts of Sets, Relations
and Functions, Mathematical Logic, Group theory,
Counting Theory, Probability, Mathematical
Induction and Recurrence Relations, Graph Theory,
Trees and Boolean Algebra.
Course Outline
Logic: logicalform, logical Equivalence, Conditional
statements. Valid & Invalid arguments, Predicate and
quantifiers. (Useful in digital circuits & hardware design)
Relations: Relation properties, n-ary relations &
Applications , Closures of Relations and equivalence relation.
(Relational DBs)
Algorithms: Searching, Sorting, Greedy Algorithms, The
Growth of Functions, Complexity of Algorithms.
Number Theory: Divisibility and Modular Arithmetic, Integer
Representations and Algorithms, Primes and Greatest
Common Divisors, Solving Congruence. (Information
Security).
9.
Course Outline
Counting: ThePigeonhole Principle, Permutations
and Combinations, Binomial Coefficients and
Identities. (Coding theory)
Graphs: Introduction to Graphs, isomorphism,
Connectivity, Euler and Hamilton Paths, Shortest
Path Problems, planner Graphs& coloring
(Networks)
Trees: Introduction and Applications, Tree
traversal, sorting. (Data structure)
10.
Logic
Logic The rulesof logic give precise meaning to
mathematical statements. These rules are used
to distinguish between valid and invalid
mathematical arguments.
More broadly, logic is the analysis and appraisal
of arguments.
Greek philosopher, Aristotle, was the pioneer of
logical reasoning. It provides the theoretical base
for many areas of mathematics and consequently
computer science.
11.
False, True, Statements
Axiom:False is the opposite to Truth.
A statement is a description of something.
Examples of statements:
I’m 37 years old.
I have 17 children.
I always tell the truth.
I’m lying to you.
Q’s: Which statements are True? False? Both?
Neither?
12.
False, True, Statements
True:I’m 37 years old.
False: I have 17 children.
I always tell the truth.
Both: IMPOSSIBLE, by our Axiom.
13.
False, True, Statements
Neither:I’m lying to you. (If viewed on its own)
HUH? Well suppose that
S = “I’m lying to you.”
were true. In particular, I am actually lying, so S is
false. So it’s both true and false, impossible by
the Axiom.
Okay, so I guess S must be false. But then I must
not be lying to you. So the statement is true.
Again it’s both true and false.
In both cases we get the opposite of our
assumption, so S is neither true nor false.
14.
Propositions
To avoid painfulhead-aches, we ban
such silly non-sense and avoid the
most general type of statements
limiting ourselves to statements with
valid truth-values instead:
DEF: A proposition is a statement that
is true or false but not both.
15.
Propositions
A proposition isa declarative sentence (a
sentence that declares a fact) that is either
true or false, but not both.
Are the following sentences propositions?
Toronto is the capital of Canada.
Read this carefully.
1+2=3
x+1=2
What time is it?
(No)
(No)
(No)
(Yes)
(Yes)
16
16.
Propositional Logic
Propositional Logic– the area of logic
that deals with propositions
Propositional Variables – variables
that represent propositions: p, q, r, s
E.g. Proposition p – “Today is Friday.”
Truth values – T, F
17
17.
Compound Propositions
In PropositionalLogic, we assume a
collection of atomic propositions are
given: p, q, r, s, t, ….
Then we form compound propositions
by using logical connectives (logical
operators) to form propositional
“molecules”.
18.
Logical Connectives
Operator Symbo
l
UsageJava
Negation not !
Conjunctio
n
and &&
Disjunction or ||
Exclusive or xor (p||q)&&(!p||!q)
Conditional if,then p?q:true
Bicondition
al
iff (p&&q)||(!p&&!q)
19.
Negation
This just turnsa false proposition to true and
the opposite for a true proposition.
EG: p = “23 = 15 +7”
p happens to be false, so p is true.
DEFINITION
Let p be a proposition. The negation of p, denoted by ¬p, is the
statement . “It is not the case that p.”
The proposition ¬p is read “not p.” The truth value of the negation
of p, ¬p is the opposite of the truth value of p.
20.
Negation – truthtable
Logical operators are defined by truth
tables –tables which give the output
of the operator in the right-most
column.
Here is the truth table for negation:
p p
F
T
T
F
21.
Conjunction
Conjunction is abinary operator in that it operates on
two propositions when creating compound proposition.
Conjunction is supposed to encapsulate what happens
when we use the word “and” in English. I.e., for “p and
q ” to be true, it must be the case that BOTH p is true,
as well as q. If one of these is false, than the compound
statement is false as well.
DEFINITION
Let p and q be propositions. The conjunction of p and q, denoted
by p Λ q, is the proposition “p and q”. The conjunction p Λ q is
true when both p and q are true and is false otherwise
22.
Conjunction
Examples
Find theconjunction of the propositions p and q where p is the proposition
“Today is Friday.” and q is the proposition “It is raining today.”, and the truth
value of the conjunction.
p q is true
Solution: The conjunction is the proposition “Today
is Friday and it is raining today.” The proposition
is true on rainy Fridays.
23
Disjunction
Note:
inclusive or :The disjunction is true when at least one
of the two propositions is true.
E.g. “Students who have taken calculus or computer science
can take this class.” – those who take one or both classes.
DEFINITION
Let p and q be propositions. The disjunction of p and q,
denoted by p ν q, is the proposition “p or q”. The disjunction p ν
q is false when both p and q are false and is true otherwise.
25
25.
Disjunction – truthtable
Conversely, disjunction is true when at
least one of the components is true:
p q pq
T
T
F
F
T
F
T
F
T
T
T
F
26.
Disjunction
Note: English versionof disjunction “or” does not
always satisfy the assumption that one of p/q being
true implies that “p or q ” is true.
Waiter: “Would you like tea or coffee?” (exclusive or)
Patron: “Coffee, please.”
Waiter: “Would you like cream or sugar?” (inclusive or)
Patron: “I’d like both, thank you.”
Q: Can someone come up with an example?
27.
Exclusive -OR
A: Theentrée is served with soup or salad.
Most restaurants definitely don’t allow you to
get both soup and salad so that the
statement is false when both soup and salad
is served. To address this situation,
exclusive-or is introduced.
- exclusive or : The disjunction is true only when one of
the proposition is true.
E.g. “Students who have taken calculus or computer
science, but not both, can take this class.” – only those who
take one of them.
Propositional Logic
The TruthTable for
the Conjunction of
Two Propositions.
p q p Λ q
T T
T F
F T
F F
T
F
F
F
The Truth Table for
the Disjunction of
Two Propositions.
p q p ν q
T T
T F
F T
F F
T
T
T
F
The Truth Table for the
Exclusive Or (XOR) of
Two Propositions.
p q p q
T T
T F
F T
F F
F
T
T
F
30
30.
Conditional Statements
DEFINITION
Let pand q be propositions. The conditional statement p → q, is the
proposition “if p, then q.” The conditional statement is false when p is
true and q is false, and true otherwise. In the conditional statement p
→ q, p is called the hypothesis (or antecedent or premise) and q is
called the conclusion (or consequence).
A conditional statement is also called an implication.
Example: “If I am elected, then I will lower taxes.” p → q
implication:
elected, lower taxes. T T | T
not elected, lower taxes. F T | T
not elected, not lower taxes. F F | T
elected, not lower taxes. T F | F
31
Conditional: synonyms
There aremany ways to express the
conditional statement p q :
If p then q. p implies q. If p, q.
p only if q. p is sufficient for q.
Some of the ways reverse the order of p and q
but have the same connotation:
q if p. q whenever p. q is necessary for p.
To aid in remembering these, I suggest
inserting “is true” after every variable:
EG: “p is true only if q is true”
33.
Bi-conditional Statement
p ↔q has the same truth value as (p → q) Λ (q → p)
“if and only if” can be expressed by “iff”
Example:
Let p be the statement “You can take the flight” and let q be
the statement “You buy a ticket.” Then p ↔ q is the statement
“You can take the flight if and only if you buy a ticket.”
Implication:
If you buy a ticket you can take the flight.
If you don’t buy a ticket you cannot take the flight.
DEFINITION
Let p and q be propositions. The biconditional statement p ↔ q is
the proposition “p if and only if q.” The biconditional statement p
↔ q is true when p and q have the same truth values, and is false
otherwise. Biconditional statements are also called bi-
implications.
34
34.
Bi-Conditional -- truthtable
p q p q
T
T
F
F
T
F
T
F
T
F
F
T
For p q to be true, p and q must have
the same truth value. Else, p q is false:
Q : Which operator is the opposite of?
35.
Precedence of Logical
Operators
Wecan use parentheses to specify the order in which logical
operators in a compound proposition are to be applied.
To reduce the number of parentheses, the precedence order is
defined for logical operators.
Precedence of Logical Operators.
Operator Precedence
¬ 1
Λ
ν
2
3
→
↔
4
5
E.g. ¬p Λ q = (¬p ) Λ q
p Λ q ν r = (p Λ q ) ν r
p ν q Λ r = p ν (q Λ r)
36
36.
Truth Tables ofCompound
Propositions
We can use connectives to build up complicated compound
propositions involving any number of propositional variables,
then use truth tables to determine the truth value of these
compound propositions.
Example: Construct the truth table of the compound
proposition
(p ν ¬q) → (p Λ q)
The Truth Table of (p ν ¬q) → (p Λ q).
p q ¬q p ν ¬q p Λ q (p ν ¬q) → (p Λ q)
T T
T F
F T
F F
F
T
F
T
T
T
F
T
T
F
F
F
T
F
T
F
37
37.
L3 38
Tautologies, contradictions,
contingencies
DEF:A compound proposition is called a tautology if
no matter what truth values its atomic
propositions have, its own truth value is T.
EG: p ¬p (Law of excluded middle)
The opposite to a tautology, is a compound
proposition that’s always false –a contradiction.
EG: p ¬p
On the other hand, a compound proposition whose
truth value isn’t constant is called a contingency.
EG: p ¬p
38.
L3 39
Tautologies and
contradictions
Theeasiest way to see if a compound
proposition is a
tautology/contradiction is to use a
truth table.
T
F
F
T
p
p
T
T
p p
T
F
F
T
p
p
F
F
p p
39.
L3 40
Tautology example
Demonstratethat
[¬p (p q )]q
is a tautology in two ways:
1. Using a truth table – show that
[¬p (p q )]q is always true
2. Using a proof (will get to this later).
40.
L3 41
Tautology bytruth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T
T F
F T
F F
41.
L3 42
Tautology bytruth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F
T F F
F T T
F F T
42.
L3 43
Tautology bytruth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F T
T F F T
F T T T
F F T F
43.
L3 44
Tautology bytruth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F T F
T F F T F
F T T T T
F F T F F
44.
L3 45
Tautology bytruth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F T F T
T F F T F T
F T T T T T
F F T F F T
45.
Propositional Equivalences
DEFINITION 2
Thecompound propositions p and q are called logically equivalent if p ↔
q is a tautology. The notation p ≡ q denotes that p and q are logically
equivalent.
Truth Tables for ¬p ν q and p → q
p q ¬p ¬p ν q p → q (¬p ν q) ↔ (p → q)
T
T
F
F
T
F
T
F
F
F
T
T
T
F
T
T
T
F
T
T
Compound propositions that have the same truth values in all
possible cases are called logically equivalent.
Example: Show that ¬p ν q and p → q are logically equivalent.
46
46.
Propositional Equivalences
Two propositionsare equivalent if they
always have the same truth value.
Example: Show using a truth table that the
conditional is equivalent to the
contrapositive.
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
47.
Logic and BitOperations
Computers represent information using bits.
A bit is a symbol with two possible values, 0 and 1.
By convention, 1 represents T (true) and 0 represents F (false).
A variable is called a Boolean variable if its value is either true
or false.
Bit operation – replace true by 1 and false by 0 in logical
operations.
Table for the Bit Operators OR, AND, and XOR.
x y x ν y x Λ y x y
0
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
0
1
1
0
48
48.
Logic and BitOperations
Example: Find the bitwise OR, bitwise AND, and bitwise XOR of the
bit string 01 1011 0110 and 11 0001 1101.
DEFINITION 7
A bit string is a sequence of zero or more bits. The length of this string
is the number of bits in the string.
Solution:
01 1011 0110
11 0001 1101
-------------------
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
49
#20 Notice that propositions may be mathemetical in nature, e.g. “23 = 15+7” which translates in English to “twenty three is the sum of fifteen and seven”.