Mfcs PPT (All Units)
Mfcs PPT (All Units)
Mfcs PPT (All Units)
Mathematical Logic
1
Logic Operators
2
Compound Statement
3
Exclusive-Or
And the formula is true exactly when the input is the second row or the third 4row.
Exclusive-Or
And the formula is true exactly when the input is not in the 1st row and the 4th5row.
Logical Equivalence
p q
T T F T F F
T F T T T T
F T T T T T
F F F F T F
As you see, there are many different ways to write the same logical formula.
One can always use a truth table to check whether two statements are equivalent.
6
Writing Logical Formula for a Truth Table
Digital logic:
Now, suppose we are given only the truth table (i.e. the specification),
how can we construct a circuit (i.e. formula) that has the same function?
7
Writing Logical Formula for a Truth Table
p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F
The formula is true exactly when the input is one of the true rows. 8
Writing Logical Formula for a Truth Table
p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F
The formula is true exactly when the input is not one of the false row. 9
DeMorgan’s Laws
De Morgan’s Law
De Morgan’s Law
10
DeMorgan’s Laws
De Morgan’s Law
T T F F
T F T T
F T T T
F F T T
De Morgan’s Law
11
Simplifying Statement
DeMorgan
Distributive
12
Tautology, Contradiction
A tautology is a statement that is always true.
14
Quantification: ‘All’ and ‘Some’
• In predicate logic, there are two
quantifiers: ‘all’ and ‘some’.
• Here are some examples:
– x Mortal(x) ‘All things are mortal’
– x Mortal(x) ‘Some things are mortal’
– x (Human(x) Mortal(x)) ‘Every human
is mortal’
– x (Human(x) Mortal(x)) ‘Some human
is not mortal’
15
UNIT-II
Sets ,Relations &Functions
16
Foundations : Types of Relations
reflexive
∀a∈S.aRa
transitive
∀ a, b, c ∈ S. a R b /\ b R c a R c
symmetric
∀ a, b ∈ S . a R b b R a
anti-symmetric
∀ a, b ∈ S . a R b /\ b R a a = b 17
Foundations : Anti-Symmetry
anti-symmetric
∀ a, b ∈ S . a R b /\ b R a a =
b
Essentially:
“If you start at X and only follow R to new
elements, you will never get back to X.”
18
Foundations : Posets
19
Foundations : Posets
Examples:
(2S, ⊆)
(Z, <)
(Z, divides)
20
Foundations : Least Upper Bounds
21
Foundations : Greatest Lower Bounds
22
Foundations : Bounds
Essentially:
lub(a, b) = smallest thing bigger than a and
b
glb(a, b) = biggest thing smaller than a and
b
Essentially:
lub(a, b) = smallest thing bigger than a and
b
glb(a, b) = biggest thing smaller than a and
b
glb( , ) = ???
25
Foundations : Lattices
∀ a, b ∈ S . ∃ c . c = lub(a, b) /\ a ⊔ b = c
∀ a, b ∈ S . ∃ c . c = glb(a, b) /\ a ⊓ b = c
27
Foundations : Fancy Lattice Names
⊥ is “botom”
⊤ is “top”
⊔ is “join”
⊓ is “meet”
28
Examples of lattices
• Powerset lattice
29
Examples of lattices
• Powerset lattice
30
Sets
A set is an unordered collection of objects.
Order and repetition
Examples: don’t matter
= {6, 7, 1, 2, 9}
{ 1, 6, 7, 2, 9 }
= {a, a, d, d, e, e, 1, 2, 3}
{ a, d, e, 1, 2, 3}
The empty set, or the set containing no
elements.
= {} Note: {}
Example:
A= {a, b}, B= {1, 2}
A B = {(a,1), (a,2), (b,1), (b,2)}
B A = {(1,a), (1,b), (2,a), (2,b)}
Not commutative!
In general,
A1 x A2 x … x An = {(a1, a2,…, an) | a1 A1, a2 A2, …, an
An}
32
|A1 x A2 x … x An| = |A1| x |A2| x … x |An|
Tree diagrams for the Cartesian product
33
Set Theory :
Inclusion/Exclusion
• What is the cardinality of A B ?
twice
A AB B
Once
• Complement:
– A A¯ = U
– A A¯ =
• Distributive:
– A (B C) = (A B) (A C)
– A (B C) = (A B) (A C)
35
Boolean Identities
Double complement: Associative laws:
x=x x + (y + z) = (x + y) + z
Idempotent laws: x · (y · z) = (x · y) · z
x + x = x, x·x=x Distributive laws:
Identity laws: x + y ·z = (x + y)·(x + z)
x + 0 = x, x·1=x x · (y + z) = x ·y + x ·z
Domination laws: De Morgan’s laws:
x + 1 = 1, x·0=0 (x · y) = x + y, (x + y) = x · y
Commutative laws: Absorption laws:
x + y = y + x, x · y = y · x x + x ·y = x, x · (x + y) = x
37
Permutation
• Set of objects in an ordered arrangement
• ordered arrangement of r members of a
set is r-permutation
• number of r-permutations of a set with n
elements is denoted P(n,r)
38
Number of r-permutations in a
set
• P(n,r) can be found using the product rule:
P(n,r) = n(n-1)(n-2)* … *(n-r+1)
• This is true because the first element of a
permutation can be chosen any one of n
ways; for the second element, there are n-
1 ways to choose; for the third, n-2, etc.
until there are exactly (n-r+1) ways to
choose the rth element
39
Example
• There are 8 runners in a race. The winner
gets a gold medal, the second place
finisher gets a silver, and third place
finisher a bronze. How many different
ways are there to award medals, if all
possible outcomes of the race are equally
likely?
40
Example 1
• There are 3 medals to be awarded, and 8
contenders for a medal
• So the number of ways to award a medal
is the number of 3-permutations on a set
of 8 elements
• P(8,3) = 8*7*6 = 336 ways to award
medals
41
Combinations
• An r-combination of elements of a set is an
unordered selection of r elements from the
set - so an r-combination is a subset with r
elements
• The number of r-combinations in a set of n
distinct elements is denoted by C(n,r) or
(nr)
• C(n,r) = n!/(r!(n-r)!)
• if r<=n, C(n,r) = C(n,n-r)
42
Permutations: Examples
• Example: A news program n!
has time to present 2 of four n Pr
available news stories. How (n r )!
many ways can the evening
4!
n P2
news be set up?
(4 2)!
4 * 3 * 2 *1
4 P2
Checking the process:
If we let A, B, C, D represent the four
shows, then the possible show
2 *1
orders would be:
AB BA CA DA 24
4 P2 12
AC BC CB DB
AD BD CD DC
2
Twelve (12) possible presentations
43
where order matters.
Combinations: Examples
• Example: A news program has time to
n!
n Cr
present 2 of four available news stories.
How many different sets of stories (n r )! r!
can be presented on the evening news?
Checking the process:
If we let A, B, C, D represent the four
shows, then the possible show orders
would be:
AB BA CA DA
AC BC CB DB
4 * 3 * 2 *1
n C2
AD BD CD DC
However, AB and BA represent the
presentation of the same two stories.
If order does not matter, one of these
2 *1* 2 *1
two may be deleted. Repeating the
process results in: AB, AC, AD, BC,
BD, CD,
44
Example
• Suppose there are 12 students in a
discrete math class, of whom 4 are taking
CS2. How many possible combinations of
4 students are there?
• C(12,4) = 12!/(8!4!) = 495
45
Example
• In how many ways can a set of 5 letters be
chosen from the English alphabet?
• C(26,5) = 26!/(21!5!) = 65780
46
Binomial Coefficients
• A number of the form (nr) is called a
binomial coefficient because the numbers
occur as coefficients in the expansion of
powers of binomial expressions (e.g.
(a+b)n)
• Properties of binomial coefficients include
Pascal’s Identity: Let n & k be positive
integers with n k. Then C(n+1,k) =
C(n,k+1) + C(n,k)
47
Pascal’s Triangle
• Can arrange binomial coefficients in a
triangle based on Pascal’s identity
• The nth row of the triangle consists of
coefficients (nk), k=0, 1, … , n
• When 2 adjacent binomial coefficients are
added, the value in the next row between
them is produced
48
Pascal’s Triangle
(00)
(10)(11) Consider (21) + (22) = (32)
(20)(21)(22) derived from n=2, k=2
C(3,2) = C(2,1) + C(2,2)
(30)(31)(32)(33)
49
Binomial Theorem
• Binomial expression: an expression with 2
terms, e.g. x and y
• The binomial theorem gives the
coefficients of the expansion of powers of
binomial expressions, e.g. (x+y)n
50
Binomial Theorem
• For example, the expansion of (x+y)4 can
be found using combinatorial reasoning
instead of multiplying out the terms
(x+y)4 = (x+y) (x+y) (x+y) (x+y)
• All products of a term in each of the sums
are added; terms of the form x4, x3y, x2y2,
xy3 and y4 arise
51
Binomial Theorem
52
Binomial Theorem
• Stated generally, the binomial theorem
holds:
(x+y)n = C(n,j)xn-jyj
= (n0)xn+(n1)xn-1y+(n2)xn-2y2+…+(nn-1) xyn-1+(nn)yn
53
Proof of Binomial Theorem
• The terms in the expanded product are of
the form xn-jyj for j = 0,1,2, … ,n
• To count the number of terms of this form,
it is necessary to choose n-j x’s from the n
sums (the other j terms are y’s)
• So the coefficient of xn-jyj = C(n,n-j) =
C(n,j) as the theorem states
54
Example
55
Examples
• What is the coefficient of x7y6 in (x+y)13?
• C(13,7) = 13!/(7!6!) =
6,227,020,800/5040*720 = 1716
• What is the coefficient of x5y8 in (x+y)13?
• C(13,5) = 13!/(5!8!) = 1287
56
Example
• What is the coefficient of x10y9 in (2x-
3y)19?
• (2x-3y)19 = C(19,j)(2x)19-j(-3y)j
• So coefficient of x10y9 = C(19,10)(2)10(-3)9
= -(19!/(10!9!))21039
57
UNIT-IV
Recurrence Relations
58
Recurrence Relations
A recurrence relation for the sequence {an} is an
equation that expresses an is terms of one or more
of the previous terms of the sequence, namely, a0,
a1, …, an-1, for all integers n with
n n0, where n0 is a nonnegative integer.
59
Recurrence Relations
60
Recurrence Relations
Example:
Consider the recurrence relation
an = 2an-1 – an-2 for n = 2, 3, 4, …
61
Modeling with Recurrence Relations
Example:
Someone deposits $10,000 in a savings account at
a bank yielding 5% per year with interest
compounded annually. How much money will be in
the account after 30 years?
Solution:
Let Pn denote the amount in the account after n
years.
How can we determine Pn on the basis of Pn-1?
62
Modeling with Recurrence Relations
We can derive the following recurrence relation:
Pn = Pn-1 + 0.05Pn-1 = 1.05Pn-1.
The initial condition is P0 = 10,000.
Then we have:
P1 = 1.05P0
P2 = 1.05P1 = (1.05)2P0
P3 = 1.05P2 = (1.05)3P0
…
Pn = 1.05Pn-1 = (1.05)nP0
64
Modeling with Recurrence Relations
Another example:
Let an denote the number of bit strings of length n
that do not have two consecutive 0s (“valid strings”).
Find a recurrence relation and give initial conditions
for the sequence {an}.
Solution:
Idea: The number of valid strings equals the number
of valid strings ending with a 0 plus the number of
valid strings ending with a 1.
65
Modeling with Recurrence Relations
66
Modeling with Recurrence Relations
What are the initial conditions?
a1 = 2 (0 and 1)
a2 = 3 (01, 10, and 11)
a3 = a 2 + a 1 = 3 + 2 = 5
a4 = a 3 + a 2 = 5 + 3 = 8
a5 = a4 + a3 = 8 + 5 = 13
…
This sequence satisfies the same recurrence relation
as the Fibonacci sequence.
Since a1 = f3 and a2 = f4, we have an = fn+2.
67
Solving Recurrence Relations
Linear homogeneous recurrence relation of degree k
with constant coefficients is a recurrence relation of
the form:
an = c1an-1 + c2an-2 + … + ckan-k,
Where c1, c2, …, ck are real numbers, and ck 0.
68
Solving Recurrence Relations
Examples:
The recurrence relation Pn = (1.05)Pn-1
is a linear homogeneous recurrence relation of
degree one.
The recurrence relation fn = fn-1 + fn-2
is a linear homogeneous recurrence relation of
degree two.
The recurrence relation an = an-5
is a linear homogeneous recurrence relation of
degree five.
69
Solving Recurrence Relations
To find solutions of the form an = rn, where r is a
constant.
an = rn is a solution of the recurrence relation
an = c1an-1 + c2an-2 + … + ckan-k if and only if
rn = c1rn-1 + c2rn-2 + … + ckrn-k.
Divide this equation by rn-k and subtract the right-
hand side from the left:
rk - c1rk-1 - c2rk-2 - … - ck-1r - ck = 0
This is called the characteristic equation of the
recurrence relation.
70
Solving Recurrence Relations
solutions of this equation are called the characteristic
roots of the recurrence relation.
linear homogeneous recurrence relations of degree
two.
71
Solving Recurrence Relations
72
Solving Recurrence Relations
Given the equation an = 12n + 2(-1)n and the initial
conditions a0 = 2 and a1 = 7, it follows that
a0 = 2 = 1 + 2
a1 = 7 = 12 + 2 (-1)
74
Solving Recurrence Relations
Example What is the solution of the recurrence
relation an = 6an-1 – 9an-2 with a0 = 1 and a1 = 6?
Solution
The only root of r2 – 6r + 9 = 0 is r0 = 3.
Hence, the solution to the recurrence relation is
an = 13n + 2n3n for some constants 1 and 2.
To match the initial condition, we need
a0 = 1 = 1
a1 = 6 = 13 + 23
Solving these equations yields 1 = 1 and 2 = 1.
Consequently, the overall solution is given by
an = 3n + n3n.
75
Recurrence Relations
• recurrence relation along with initial
conditions specify a single sequence. Any
such sequence is a solution to the relation.
77
Graphs consist of Example 1: The following
picture
points called is a graph. List its vertices and
vertices edges.
lines called edges D
2) Is A adjacent to B?
Is D adjacent to A? C
Is E adjacent to itself?
Is C adjacent to itself?
3) Is AB adjacent to BC?
Is CE adjacent to BD? E
79
Example : The graph on the left has no
Euler paths, but the one on the right has
several.
R R
A D A D
L L
80
Example 6: Unicursal Tracings
Recall the routing problems presented on Tuesday:
•“Do these drawings have unicursal tracings? If so, are they open or closed?”
How might we answer these queries? Well, if we add vertices to the corners of the
tracings we can reduce the questions to asking whether the following graphs have Euler
paths (open tracing) and/or Euler circuits (closed tracing).
(a) (b)
81
(c)
Number of odd vertices Conclusion
Approx. = 0.618 x H 83
The Golden Ratio in Art
Approx. = 0.618 x H 84
The Golden Ratio in Art
85
The Golden Ratio in Art
.618 x Ht.
86
0.618 x Width
The Golden Ratio in Art
.618 x Ht.
87
0.618 x Width
Definitions
• Planar – graph that can be drawn without
edges that intersect within a plane
• Non-Planar – graph that cannot be drawn
without edges that intersect within a plane
88
Do Edges Intersect?
• Planar graphs can sometimes be drawn as
non-planar graphs. It is still a planar graph,
because they are isomorphic.
89
Three Houses / Three Utilities
• Q. Suppose we have three houses and
three utilities. Is it possible to connect
each utility to each of three houses without
any lines crossing?
• Planar or Non-Planar ?
• This is also known as K(3,3) bipartite
graph
90
Examples of Counting Regions
Region –area bounded by a subset of the vertices and
edges of a graph
91
Commonly Used Variables
• Variables used in following mathematical proofs
• G = an arbitrary graph
• P = number of vertices
• Q = number of edges
• R = number of regions
• n = number of edges that bound a region
• N = sum of n for all regions of G
92
First Theorem
• Let G be a connected planar graph
• p = vertices, q = edges, r = regions
• Then p – q + r = 2
• Theorem is by Euler
• Proof can be made by induction
93
Second Theorem
• Let G be a connected planar graph
• p = (vertices >= 3), q = edges
• Then q <= 3p - 6
94
Proof: q <= 3p – 6
• For each region in graph, n = number of
edges to form boundary of its region. Sum
of all these n’s in graph = N
• N >= 3r must be true, since all regions
need at least 3 edges to form them.
• N <= 2q must be true, since no edge can
be used more than twice in forming a
region
95
(con’t) Proof: q <= 3p – 6
• 3r <= N <= 2q
• Solve p – q + r = 2 for r, then substitute
• 3(-p +q + 2) <= 2q
96
Proof: K(3,3) is Non-Planar
• Proof by contradiction of theorems
• Since graph is bipartite, no edge connects
two edges within same subset of vertices
• N >= 4r must be true, since graph contains
no simple triangle regions of 3 edges.
• N <= 2q must be true, since no edge can
be used more than twice in forming a
region
97
(con’t) Proof of K(3,3)
• For K(3,3) p=6, q= 9, r= ??
• 4r <= N <= 2q
• 4r <= (2q = 2 * 9 = 18)
• r <= 4.5
• Proof by contradiction:
• r cannot be both equal to 5 and less than 4.5
• Therefore, K(3,3) is a non-planar graph
98
Complete Graphs
• Denoted by Kp
• All vertices are connected to all vertices
• q = p * (p - 1) / 2
99
Proof: K5 is non-planar
• p=5
• q= p * (p – 1) / 2 = 10
• Using second theorem of planar graphs:
• q <= 3p – 6
• 10 <= 3(5) – 6
• 10 <= 9 ???
• By contradiction, K5 must be non-planar
100
Subdivisions of graph G
• Subdivision – a graph obtained from a graph
G, by inserting vertices of degree two into any
edge
• (H is a valid subdivision of G, while F is not)
101
Peterson Graph
102
Chromatic Number Rules
• Four Color Theorem:
• If G is a planar graph, then X(G) <= 4
103