250 likes | 389 Views
Discrete Structures. Li Tak Sing( 李德成 ) mt263f -11- 12.ppt. Counting Strings. The set A* of all strings over a finite alphabet A is countably infinite. Proof. A* is the union of A 0 , A 1 ,... Since each A n is finite, therefore the union of these finite sets are countable.
E N D
Discrete Structures Li Tak Sing(李德成) mt263f-11-12.ppt
Counting Strings • The set A* of all strings over a finite alphabet A is countably infinite. • Proof. A* is the union of A0, A1,... Since each An is finite, therefore the union of these finite sets are countable.
Uncountable sets • Diagonalization • Let A be an alphabet with two or more symbols and let So, S1, ..., Sn, ..., be countable listing of sequences of the form Sn=(ano, an1,....), where aniA. The sequences are listed as the rows of the following infinite matrix:
Then there is a sequence S=(b0, b1, b2,..) over A that is not in the original list. We can construct S from the list of diagonal elements (a00, a11, a22,...) by changing each element so that bnann for each n.
Uncountability of the reals. • We can have a bijection between R and the set U of real numbers between 0 and 1. Therefore |U|=|R|. • An example of such functions: • Assume that U is countable. Therefore, there is a bijection between U and N. In other words, we can call the elements as:, , ,.... Since all the elements of U are numbers between 0 and 1, we can consider them as list of decimal digits. Using the last rule, there must be a decimal number which are not in the list. Therefore, such bijection does not exist and therefore U is uncountable. Hence, R is uncountable.
Limits on computability • The set of programs for a programming language is countably infinite. • Programs can be considers as strings over a particular set of alphabets, therefore, according to the countability of strings, programs are countabily infinite.
Not everything is computable • We only have countable programs, therefore we can only generate countable number of results. • For example, there are uncountable real numbers. So we cannot use programs to generate all the real numbers as we only have countable programs.
Higher cardinalities • |A|<|power(A)| • Proof. This is true for finite A. • For infinite A, we see that for each element of A, say x, {x} is an element of A. So we can see that |A| is at lease less than or equal to |power(A)|. • Would it be possible that |A|=|power(A)|?
Higher cardinalities • Assume that that is the case, therefore there is a bijection between A and power(A). So each x in A is associated with a subset Sx of A. Now, consider the subset:S={xA|xSx} • There is an y such that S=Sy • Now, ySy y Sy and y Sy ySy • Therefore, contradition and such bijection does not exist. • Therefore |A|<|power(A)|
There are uncountably many languages over a finite alphabet • A language is a subset of all the strings over a set of alphabets. So all the languages over a set of alphabets form the power set of all the strings over a set of alphabets. • Since the set of all strings over a set of alphabets is countably infinite, the power set is uncountably infinite.
Examples • Show that the cardinality of the odd integers is the same as the cardinality of the integers. • Show that the set of even natural numbers have the same cardinality as the set Z of integers. • Prove that the open intervals of real numbers (1,2) and (4,10) have the same cardinality.
Solution • There is a bijection between odd integers and all integers:Therefore |odd integers|=|Z| • There is a bijectionbetween even natural integers and integers.
Solution • There is a bijection between (1,2) and (4,10):
Construction Techniques • Inductively Defined Sets • Basis: Specify one or more elements of s. • Induction: Give one or more rules to construct new elements of S from existing elements of S. • Closure: State that S consists exactly of the elements obtained by the basis and induction steps.
Examples • Consider how to define the following sets inductively: • {4,2,0,-2 ...} • {2, 6,18, 54,….} • {4,-8, 16, -32,...} • {...,-6,-3,0,3,6,...}
Solution • Basis: induction: • Basis: induction: • Basis: induction: • Basis: induction:
Strings • All strings over A* • Basis: A* • Induction: if sA* and aA, then asA*.
String examples • Show how to generate the following set of strings inductively. • S={ab, aabb, aaabbb,....} • S={aba, aabaa, aaabaaa,.....} • S={ab, abab, ababab,...} • S={am(bc)n|m,nN}
Solution • Basis: induction: • Basis: induction: • Basis: induction: • Basis: induction:
Lists • All lists over A • Basis: <> lists(A). • Induction: If xA and Llists(A), then cons(x,L)list(A).
Lists examples • Write the inductive definiton for the sets: • C={L|Llists({a,b}) where a's and b's alternate} • S={x|x lists(N) and x has even length}
Solution • Basis:induction: • Basis:induction:
Binary trees • All binary trees over A • Basis: <>B. • Induction: if x A and L,R B, then tree(L,x,R) B.
Binary trees • Write an inductive definition for each of the following Binary trees • All binary trees over {a} • The set of binary trees over {a} where each node has two identical subtrees.
Solution • Basis: induction: • Basis: induction: