22
CS 490 CS 490 Mathematical Logic, Mathematical Logic, Combinatorics, Counting Combinatorics, Counting Arguments, Graph Theory, Arguments, Graph Theory, Number Theory, Discrete Number Theory, Discrete Probability, Recurrence Probability, Recurrence Relation. Relation. Thao Tran. Thao Tran.

CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Embed Size (px)

Citation preview

Page 1: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

CS 490CS 490

Mathematical Logic, Mathematical Logic, Combinatorics, Counting Combinatorics, Counting

Arguments, Graph Theory, Arguments, Graph Theory, Number Theory, Discrete Number Theory, Discrete

Probability, Recurrence Relation.Probability, Recurrence Relation.

Thao Tran.Thao Tran.

Page 2: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Mathematical LogicMathematical Logic Proposition and Logical Operators:Proposition and Logical Operators:

Proposition:Proposition: A proposition is a sentence to which one and only one of the terms true o A proposition is a sentence to which one and only one of the terms true o

false can be meaningful applied.false can be meaningful applied. Example: “four is even,” “43 >= 21” Example: “four is even,” “43 >= 21”

Logical Operators:Logical Operators: Conjunction (And): If Conjunction (And): If pp and and q q are propositions, their conjunction, are propositions, their conjunction, p and q p and q

(denoted p ^ q), is defined by:(denoted p ^ q), is defined by:p q p q p ^ qp ^ q0 00 0 0 00 10 1 0 01 01 0 0 01 11 1 1 1

Disjunction (Or): If Disjunction (Or): If pp and and q q are propositions, their disjunction, are propositions, their disjunction, p and q p and q (denoted p v q), is defined by:(denoted p v q), is defined by:

p q p q p v qp v q0 00 0 0 00 10 1 1 11 01 0 1 11 11 1 1 1

Page 3: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Mathematical Logic (cont.)Mathematical Logic (cont.) Negation: Negation:

if p is a proposition, its negation, not p, is denoted ~p if p is a proposition, its negation, not p, is denoted ~p and is defined byand is defined by

pp ~p~p00 1111 00

Conditional Operator( if…then):Conditional Operator( if…then): The conditional statement if p then q, denoted The conditional statement if p then q, denoted

p --> q , is defined byp --> q , is defined bypp qq p p q q00 00 1 100 11 1 111 00 0 011 11 1 1

Example: Example: If I pass the final, then I’ll graduate.If I pass the final, then I’ll graduate.

Page 4: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Mathematical Logic( cont.)Mathematical Logic( cont.)

Truth table:Truth table:

Page 5: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Mathematical Logic (cont.)Mathematical Logic (cont.) Tautology, Contradiction and Equivalent: Tautology, Contradiction and Equivalent:

Tautology: An expression involving logical variables that Tautology: An expression involving logical variables that is true in all cases of its truth table.is true in all cases of its truth table.

Example: p v ~pExample: p v ~p

Contradiction: An expression involving logical variable Contradiction: An expression involving logical variable that is false in all cases of its truth table.that is false in all cases of its truth table.

Example: p ^ ~pExample: p ^ ~p

Equivalent: Let S be a set of propositions and let r and s Equivalent: Let S be a set of propositions and let r and s be propositions generated by S. r and s are equivalent if be propositions generated by S. r and s are equivalent if r <--> s is a tautology, denoted rr <--> s is a tautology, denoted rs.s.

Example: p v q Example: p v q q v p q v p

Page 6: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Counting PrinciplesCounting Principles

It is frequently necessary to count It is frequently necessary to count how many ways certain choices can how many ways certain choices can be made.be made.

Basic methods:Basic methods: Sum and product rulesSum and product rules Counting functions and sequences Counting functions and sequences Binomial theoremBinomial theorem

Page 7: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Sum and Product RulesSum and Product Rules

Rule of sum:Rule of sum: The number of ways in which either of two mutually The number of ways in which either of two mutually

exclusive events can occur is equal to the sum of exclusive events can occur is equal to the sum of the number of ways in which each can occur the number of ways in which each can occur separately.separately.

Rule of product:Rule of product: The number of ways in which two independent The number of ways in which two independent

events Eevents E1 1 and Eand E2 2 can occur is the product of the can occur is the product of the numbers of ways in which Enumbers of ways in which E1 1 and Eand E2 2 can occur can occur separately. separately.

Page 8: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Sum and Product (cont.)Sum and Product (cont.)

Example:Example: Suppose that a system of car registrartion is Suppose that a system of car registrartion is

adopted in which and allowable registration adopted in which and allowable registration plate consists of 1,2, or 3 letters, followed by plate consists of 1,2, or 3 letters, followed by a number (not starting with 0) having the a number (not starting with 0) having the same number of digits as there are letters. same number of digits as there are letters. How many possible registration are there?How many possible registration are there?

Page 9: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Sum and Product (cont.)Sum and Product (cont.)

Solution:Solution: (26 x 9) + (26 x 26 x 9 x 10) + (26 x 26 (26 x 9) + (26 x 26 x 9 x 10) + (26 x 26

x 26 x 9 x 10 x 10) = 15879474x 26 x 9 x 10 x 10) = 15879474

Page 10: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Binomial TheoremsBinomial Theorems

Binomial TheoremBinomial Theorem (x+y)(x+y)nn = ∑ = ∑nn

r=0r=0( ( nnrr) x) xrryyn-rn-r

Where :Where :

( ( nnrr) =n!/(n-r)!r!) =n!/(n-r)!r!

Page 11: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Power SetPower Set

Definition: Definition: If A is any set, the power set of A is the If A is any set, the power set of A is the

set of all subsets of A, including the set of all subsets of A, including the empty set and A itself. It is denoted P(A).empty set and A itself. It is denoted P(A).

Example:Example: If A = {1, 2} thenIf A = {1, 2} then P(A) = { P(A) = { φφ, {1}, {2}, {1,2}}, {1}, {2}, {1,2}}

Formula:Formula: P(A) = 2P(A) = 2#A#A

Page 12: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Number TheoryNumber Theory The natural numbers:The natural numbers:

N = {0, 1, 2, 3, …}N = {0, 1, 2, 3, …} The integers:The integers:

Z = {…, -2, -1, 0, 1, 2, …}Z = {…, -2, -1, 0, 1, 2, …} Z stands for Zahlen, meaning “numbers” in GemanZ stands for Zahlen, meaning “numbers” in Geman

The rational numbers:The rational numbers: Denoted Q (quotient), comprises all those numbers that can be Denoted Q (quotient), comprises all those numbers that can be

written in the form a/b, with a,b in Z written in the form a/b, with a,b in Z The real numbers:The real numbers:

Denoted R: Denoted R: Example: √2, Example: √2, ππ

The complex numbers:The complex numbers: The set C of complex numbers is the set of all numbers of the The set C of complex numbers is the set of all numbers of the

form a+bi where a and b are real numbers and iform a+bi where a and b are real numbers and i2 2 = -1= -1 The reason for extending from R to C is to be able to solve all The reason for extending from R to C is to be able to solve all

polynomial equationpolynomial equation

Page 13: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Recurrence RelationsRecurrence Relations Definition:Definition:

Let S be a sequence of numbers. A recurrence Let S be a sequence of numbers. A recurrence relation on S is a formula that relates all but a relation on S is a formula that relates all but a finite number of terms of S to previous terms of finite number of terms of S to previous terms of S. That is, there is a kS. That is, there is a k00 in the domain of S such in the domain of S such that if k > kthat if k > k00, then S(k) is expressed in terms that , then S(k) is expressed in terms that preceed S(k). If the domain of S is {0, 1, 2…}, preceed S(k). If the domain of S is {0, 1, 2…}, the terms S(0), S(1),…,S(kthe terms S(0), S(1),…,S(k00) are not defined by ) are not defined by the recurrence formula. Their values are the the recurrence formula. Their values are the initial conditions (or boundary conditions, or initial conditions (or boundary conditions, or basis) that complete the definition of S.basis) that complete the definition of S.

Example:Example: The Fibonacci sequence:The Fibonacci sequence:

FFkk = F = Fk-2k-2 + F + Fk-1k-1 , k >= 2 , F , k >= 2 , F00=1, F=1, F11= 1= 1 This recurrence relation is called a second-order relation This recurrence relation is called a second-order relation

because Fbecause Fkk depends on the two previous terms of F. depends on the two previous terms of F.

Page 14: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Recurrence Relations (cont.)Recurrence Relations (cont.)

Solving a recurrence relation:Solving a recurrence relation: Sequence are often most easily defined Sequence are often most easily defined

with a recurrence relation; however, the with a recurrence relation; however, the calculation of terms by directly applying calculation of terms by directly applying a recurrence relation can be time a recurrence relation can be time consuming.consuming.

Example:Example: Find recurrence relation for the sequence Find recurrence relation for the sequence

defined by: defined by: D(k) = 5*2D(k) = 5*2kk , k>=0 , k>=0

Page 15: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Recurrence Relations (cont.)Recurrence Relations (cont.)

Answer:Answer:D(k) = 5*2D(k) = 5*2kk = 2*5*2 = 2*5*2k-1k-1 = 2D(k-1) = 2D(k-1)

The relation is:The relation is:

D(k) – 2D(k-1) = 0D(k) – 2D(k-1) = 0

Initial condition D(0) = 5.Initial condition D(0) = 5.

Homogeneous recurrent relation:Homogeneous recurrent relation: An nAn nthth order linear relation is a homogeneous order linear relation is a homogeneous

recurrence relation if f(k) = 0 for all k. For each recurrence relation if f(k) = 0 for all k. For each recurrence relation recurrence relation

S(k) + CS(k) + C11S(k-1)+…+CS(k-1)+…+CnnS(k-n)=f(k) S(k-n)=f(k)

The associated homogeneous relation is The associated homogeneous relation is S(k)+CS(k)+C11S(k-1)+ … + CS(k-1)+ … + CnnS(k-n)=0S(k-n)=0

Page 16: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Graph TheoryGraph Theory Directed Graph: Directed Graph:

Consist of a set of vertices, V, and a set of edges, E, Consist of a set of vertices, V, and a set of edges, E, connecting certain elements of V. Each element of E is connecting certain elements of V. Each element of E is an order pair. The first entry is the initial vertex of the an order pair. The first entry is the initial vertex of the edge and the second entry is the terminal vertex.edge and the second entry is the terminal vertex.

Example:Example:

Simple Graph & Multigraph:Simple Graph & Multigraph: Simple graph is one for which there is no more than Simple graph is one for which there is no more than

one edge directed from any one vertex to any other one edge directed from any one vertex to any other vertex. All other graphs are called multigraph.vertex. All other graphs are called multigraph.

Page 17: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Graph Theory(cont.)Graph Theory(cont.)

Traversals:Traversals: Eulerian Graph:Eulerian Graph:

Konigsberg Bridge Problem:Konigsberg Bridge Problem:

Page 18: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Graph Theory (cont.)Graph Theory (cont.)

Answer:Answer:

A Eulerian path through a graph is a path A Eulerian path through a graph is a path whose edge list contains each edge of the whose edge list contains each edge of the graph exactly once. graph exactly once.

Page 19: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Graph Theory (cont.)Graph Theory (cont.)

Hamiltonian Graph:Hamiltonian Graph: A hamiltonian path A hamiltonian path

through a graph is a path through a graph is a path whose vertex list whose vertex list contains each vertex of contains each vertex of the graph exactly once.A the graph exactly once.A hamiltonian graph is a hamiltonian graph is a graph that possesses a graph that possesses a Hamiltonian path.Hamiltonian path.

Traveling salesman Traveling salesman problem : problem :

A salesman who wants A salesman who wants to minimize the number to minimize the number of miles the he travels in of miles the he travels in visiting his custommers.visiting his custommers.

Page 20: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Discrete ProbabilityDiscrete Probability The calculation of discrete probability usually The calculation of discrete probability usually

involves counting argumentsinvolves counting arguments Permutation:Permutation:

PPrrn n , is called the number of permutations of , is called the number of permutations of nn objects objects

taken taken rr at a time. at a time. PPrr

nn = n(n-1)…(n-r+1) = n(n-1)…(n-r+1) = n! / (n-r)!= n! / (n-r)!

Combination:Combination: Define for an Define for an rr-element subset of an -element subset of an nn-element set A is a -element set A is a

combination of A, taken combination of A, taken r r at a time.at a time. CCnn

r r = n! / r!(n-r)!= n! / r!(n-r)! Example: Compute the number of distinct 5 card hands Example: Compute the number of distinct 5 card hands

which can be dealt from a deck of 52 cards.which can be dealt from a deck of 52 cards.

Page 21: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

Discrete Probability (cont.)Discrete Probability (cont.)

Answer:Answer: CC55

5252 = 52!/(5! 47!) = 2,598,960 = 52!/(5! 47!) = 2,598,960

The pigeonhole principle:The pigeonhole principle: If n pigeons are assigned to m If n pigeons are assigned to m

pigeonholes, and m < n, then at least pigeonholes, and m < n, then at least one pigeonhole contains two or more one pigeonhole contains two or more pigeons. More generally, if n>km, then pigeons. More generally, if n>km, then at least one pigeonhole must contain at least one pigeonhole must contain more than k pogeons.more than k pogeons.

Page 22: CS 490 Mathematical Logic, Combinatorics, Counting Arguments, Graph Theory, Number Theory, Discrete Probability, Recurrence Relation. Thao Tran

ReferencesReferences Truss, J.K. Truss, J.K. Discrete Mathematics for Computer Discrete Mathematics for Computer

Scientist.Scientist. Addison-Wesley Addison-Wesley Publishing Publishing Company, 1991.Company, 1991.

Kolman, Bernard and Robert. Kolman, Bernard and Robert. Discrete Discrete Mathematical Structures forMathematical Structures for Computer Computer Science. Science. Drexel University.Drexel University.

Doerr, Alan and Kenneth. Doerr, Alan and Kenneth. Applied Applied Discrete Structures for ComputerDiscrete Structures for ComputerScienceScience. Science Research Associates, Inc. . Science Research Associates, Inc.

1985. 1985.