Upcoming SlideShare
×

# Class1

605 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
605
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
13
0
Likes
0
Embeds 0
No embeds

No notes for slide
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• Fall 2008 Automata
• ### Class1

1. 1. Mathematical Preliminaries Hw (p.13) 1, 4, 7, 8, 9, 13, 23, 26, 30, 32
2. 2. <ul><li>Mathematical Preliminaries </li></ul><ul><li>Sets </li></ul><ul><li>Functions </li></ul><ul><li>Relations </li></ul><ul><li>Graphs </li></ul><ul><li>Proof Techniques </li></ul>
3. 3. A set is a collection of elements SETS We write 1 is a member (or element) of set A ship is not a member (or element) of set B Membership of a given set
4. 4. <ul><li>Set Representations </li></ul><ul><ul><li>C = { a, b, c, d, e, f, g, h, i, j, k } </li></ul></ul><ul><ul><li>C = { a, b, …, k } </li></ul></ul><ul><ul><li>S = { 2, 4, 6, … } </li></ul></ul><ul><ul><li>S = { j : j > 0, and j = 2k for some integer k > 0 } </li></ul></ul><ul><ul><li>S = { j : j is nonnegative and even } </li></ul></ul>finite set infinite set
5. 5. A = { 1, 2, 3, 4, 5 } Universal Set : all possible elements <ul><ul><ul><li>U = { 1 , … , 10 } </li></ul></ul></ul>1 2 3 4 5 A U 6 7 8 9 10
6. 6. <ul><li>Set Operations </li></ul><ul><li>A = { 1, 2, 3 } B = { 2, 3, 4, 5} </li></ul><ul><li>Union </li></ul><ul><li>A U B = { 1, 2, 3, 4, 5 } </li></ul><ul><li>Intersection </li></ul><ul><ul><ul><li>A B = { 2, 3 } </li></ul></ul></ul><ul><li>Difference </li></ul><ul><ul><ul><li>A - B = { 1 } </li></ul></ul></ul><ul><ul><ul><li>B - A = { 4, 5 } </li></ul></ul></ul>U 2 3 1 4 5 2 3 1 Venn diagrams A B
7. 7. A <ul><li>Complement </li></ul><ul><ul><ul><ul><li>Universal set = {1, …, 7} </li></ul></ul></ul></ul><ul><ul><ul><ul><li>A = { 1, 2, 3 } A = { 4, 5, 6, 7} </li></ul></ul></ul></ul>1 2 3 4 5 6 7 A A = A
8. 8. 0 2 4 6 1 3 5 7 even { even integers } = { odd integers } odd Integers
9. 9. DeMorgan’s Laws A U B = A B U A B = A U B U
10. 10. Empty, Null Set: = { } S U = S S = S - = S - S = U = Universal Set
11. 11. Subset A = { 1, 2, 3} B = { 1, 2, 3, 4, 5 } Proper Subset: A B A B U A B U
12. 12. Disjoint Sets A = { 1, 2, 3 } B = { 5, 6} A B A B = U
13. 13. Set Cardinality <ul><li>For finite sets </li></ul>A = { 2, 5, 7 } |A| = 3 (set size)
14. 14. Powersets A powerset is a set of subsets Powerset of S = the set of all the subsets of S S = { a, b, c } 2 S = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} } Observation: | 2 S | = 2 |S| ( 8 = 2 3 )
15. 15. Cartesian Product A = { 2, 4 } B = { 2, 3, 5 } A X B = { (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3), (4, 5) } A X B is an ordered set, i.e. A X B ≠ B X A |A X B| = |A|·|B| Generalizes to more than two sets A X B X … X Z
16. 16. Relation from sets A to B <ul><li>Ex., A = { 1, 2, …, 7 }, B={ 1, 2, …, 50} </li></ul><ul><ul><li>{(x, y): x  A, y  B, and y= x 2 } </li></ul></ul><ul><ul><li>{(x, y): x  A, y  B, and x < y} </li></ul></ul><ul><ul><li>Are relations from A to B. </li></ul></ul><ul><li>A relation on set A </li></ul><ul><ul><li>Equivalence relation </li></ul></ul><ul><ul><li>a partition on set A </li></ul></ul>
17. 17. FUNCTIONS domain 1 2 3 a b c range f : A -> B A B If A = domain then f is a total function otherwise f is a partial function f(1) = a 4 5 In general, we mean this.
18. 18. GRAPHS A directed graph <ul><li>Nodes (Vertices) </li></ul><ul><li>V = { a, b, c, d, e } </li></ul><ul><li>Edges (Ordered pairs) </li></ul><ul><li>E = { (a,b), (b,c), (b,e),(c,a), (c,e), (d,c), (e,b), (e,d) } </li></ul>node edge a b c d e
19. 19. Labeled Graph a b c d e 1 3 5 6 2 6 2
20. 20. Walk Walk is a sequence of adjacent edges (e, d), (d, c), (c, a) is a walk from e to a of length 3 (or denoted as e-d-c-a ) Length = # of edges a b c d e
21. 21. Path a b c d e Path is a walk where no edge is repeated Simple path : no node is repeated
22. 22. Path a b c d e Path is a walk where no edge is repeated Simple path : no node is repeated (e, b), (b, e), (e, d), (d, c), (c, a) is a path from e to a but it is not a simple path.
23. 23. Cycle a b c d e 1 2 3 Cycle : a walk from a node (base) to itself without repeated edges Simple cycle : only the base node is repeated Loop: an edge from a node to itself base
24. 24. Find All Simple Paths starting from c a b c d e origin The longest simple path has at most length 4. Since every vertex can only be visited at most once, and there are 4 other vertices.
25. 25. (c, a) (c, e) Step 1 a b c d e origin Starting from vertex c, list all outgoing edges as long as they do not lead to any vertex already used in the path. At this point, we have all paths of length one starting at c . For all vertices a , e reached by c , we list all outgoing edges originating at a or e according the same way we did before.
26. 26. (c, a) (c, a), (a, b) (c, e) (c, e), (e, b) (c, e), (e, d) Step 2 a b c d e origin
27. 27. Step 3 a b c d e origin (c, a) (c, a), (a, b) (c, a), (a, b), (b, e) (c, e) (c, e), (e, b) (c, e), (e, d)
28. 28. Step 4 a b c d e origin (c, a) (c, a), (a, b) (c, a), (a, b), (b, e) (c, a), (a, b), (b, e), (e,d) (c, e) (c, e), (e, b) (c, e), (e, d)
29. 29. Trees are connected directed graphs without cycles such that there is a special vertex called “root” having exactly one path to every other vertices. root leaf parent child
30. 30. root leaf Level 0 Level 1 Level 2 Level 3 Height 3 The level associated with each vertex is the number of edges in the path form the root to the vertex. The height of the tree is the largest level number of any vertex.
31. 31. Binary Trees A binary tree is a tree in which no parent can have more than two children. A binary tree is a tree in which no parent can have more than two children. (p.10) Example 1.5. Prove that a binary tree of height n has at most 2 n leaves.
32. 32. PROOF TECHNIQUES <ul><li>Proof by induction </li></ul><ul><li>Proof by contradiction </li></ul>
33. 33. Induction We have statements P 1 , P 2 , P 3 , … <ul><li>If we know </li></ul><ul><ul><ul><li>for some m that P 1 , P 2 , …, P m are true </li></ul></ul></ul><ul><ul><ul><li>for any k >= m that </li></ul></ul></ul><ul><ul><ul><ul><ul><li>P 1 , P 2 , …, P k imply P k+1 </li></ul></ul></ul></ul></ul><ul><li>Then </li></ul><ul><li>Every P i is true </li></ul>
34. 34. Proof by Induction <ul><li>Inductive basis </li></ul><ul><ul><ul><li>Find P 1 , P 2 , …, P m which are true </li></ul></ul></ul><ul><li>Inductive hypothesis </li></ul><ul><ul><ul><li>Let’s assume P 1 , P 2 , …, P k are true, </li></ul></ul></ul><ul><ul><ul><li>for any k >= m </li></ul></ul></ul><ul><li>Inductive step </li></ul><ul><ul><ul><li>Show that P k+1 is true </li></ul></ul></ul>
35. 35. Example Theorem: A binary tree of height n has at most 2 n leaves. (p.10) We want to show: L(n) ≦ 2 n for n = 0, 1, 2,…. Proof by induction: let L(i) be the maximum number of leaves of any subtree at height i
36. 36. <ul><li>We want to show: L(n) ≦ 2 n for n = 0, 1, 2,…. </li></ul><ul><li>Inductive basis </li></ul><ul><ul><ul><ul><li>L(0) =1 ≦ 2 0 (the root node : height=0) </li></ul></ul></ul></ul><ul><li>Inductive hypothesis </li></ul><ul><ul><ul><ul><li>Let’s assume L(i) ≦ 2 i for all i = 0, 1, …, k </li></ul></ul></ul></ul><ul><li>Induction step </li></ul><ul><ul><ul><ul><li>we need to show that L(k + 1) ≦ 2 k+1 , k ≧0 </li></ul></ul></ul></ul>
37. 37. Induction Step From Inductive hypothesis: height k k+1 Let’s assume L(i) ≦ 2 i for all i = 0, 1, …, k need to show that L(k + 1) ≦ 2 k+1 0 … L(k) ≦ 2 k
38. 38. L(k) ≦ 2 k L(k+1) ≦ 2 · L(k) ≦ 2· 2 k = 2 k+1 Induction Step height k k+1 (we add at most two nodes for every leaf of level k) … need to show that L(k + 1) ≦ 2 k+1 To get a binary tree of height k+1 from one of height k , we can create at most 2 leaves in place of each previous one
39. 39. Remark <ul><li>Recursion is another thing </li></ul><ul><li>Example of recursive function: </li></ul><ul><ul><ul><li>f(n) = f(n-1) + f(n-2) </li></ul></ul></ul><ul><ul><ul><li>f(0) = 1, f(1) = 1 </li></ul></ul></ul>
40. 40. Proof by Contradiction <ul><li>We want to prove that a statement P is true </li></ul><ul><ul><ul><li>we assume that P is false </li></ul></ul></ul><ul><ul><ul><li>then we arrive at an incorrect conclusion </li></ul></ul></ul><ul><ul><ul><li>therefore, statement P must be true </li></ul></ul></ul>
41. 41. Example <ul><li>Theorem: is not rational </li></ul><ul><li>Proof: </li></ul><ul><ul><ul><li>Assume by contradiction that it is rational </li></ul></ul></ul><ul><ul><ul><li>= n/m </li></ul></ul></ul><ul><ul><ul><li>n, m are nonzero integers and without </li></ul></ul></ul><ul><ul><ul><li>common factors </li></ul></ul></ul><ul><ul><ul><li>We will show that this is impossible </li></ul></ul></ul>
42. 42. = n/m 2 m 2 = n 2 Therefore, n 2 is even n is even n = 2 k 2 m 2 = 4k 2 m 2 = 2k 2 m is even m = 2 p Thus, m and n have a common factor 2 Contradiction!
43. 43. Languages
44. 44. <ul><li>A language is a set of strings </li></ul><ul><li>String: A sequence of letters </li></ul><ul><ul><li>Examples: “cat”, “dog”, “house”, … </li></ul></ul><ul><ul><li>Defined over an alphabet: </li></ul></ul>Non-empty and finite
45. 45. Alphabets and Strings <ul><li>We will use small alphabets: </li></ul><ul><li>Strings </li></ul>
46. 46. Empty String <ul><li>A string with no letters </li></ul>
47. 47. String Operations Concatenation w  = ?  w = ?
48. 48. Empty String <ul><li>Observations: </li></ul>
49. 49. Reverse
50. 50. String Length <ul><li>Length: </li></ul><ul><li>Examples: </li></ul>|  | = ?
51. 51. Length of Concatenation <ul><li>Example: </li></ul>
52. 52. Example 1.8 (p.17) | uv | = | u | + | v | <ul><li>A recursive definition of the length of a string: </li></ul>| a | =1, | wa | = | w | + 1 For all a  , w is any string from  <ul><li>Fix the string u and consider all possible strings v ( the length of v can be 1, 2, …. ( 0 is trivial) ) </li></ul><ul><li>The proof is done by induction on the length of v ( for any given u ) </li></ul>
53. 53. Example 1.8 (p.17) | uv | = | u | + | v | <ul><li>For a string u , consider the length of uv , concatenation of u with a string v </li></ul><ul><li>Basis </li></ul><ul><li>Inductive Step </li></ul><ul><li>Induction Assumption </li></ul>
54. 54. Substring <ul><li>Substring of string: a subsequence of consecutive letters </li></ul><ul><li>String Substring </li></ul>
55. 55. Prefix and Suffix <ul><li>Prefixes Suffixes </li></ul>prefix suffix
56. 56. Another Operation <ul><li>Example: </li></ul>
57. 57. Another Operation <ul><li>Definitions: </li></ul>
58. 58. The * Operation <ul><li>: the set of all possible strings from </li></ul><ul><li>alphabet </li></ul><ul><li>Example: = { a, b } then = ? </li></ul>
59. 59. The + Operation : the set of all possible strings from alphabet except
60. 60. Languages Fall 2008 Automata
61. 61. Note that: Sets Set size Set size String length
62. 62. Another Example <ul><li>An infinite language </li></ul>
63. 63. Operations on Languages <ul><li>The usual set operations </li></ul><ul><li>Complement: ?? </li></ul>
64. 64. <ul><li>When we talk about a language , we must know what ground does this language stands on ….. </li></ul>Languages We should know the ALPHABETS that constitute the language
65. 65. Complement Example <ul><li>The complement of </li></ul>Universal Set?
66. 66. Reverse <ul><li>Definition: </li></ul><ul><li>Examples: </li></ul>
67. 67. Reverse Hw # 10 (a) Prove or Disprove: i.e., w R  L  w  L R
68. 68. Concatenation <ul><li>Definition: </li></ul><ul><li>Example: </li></ul>
69. 69. Concatenation Hw 8. Prove
70. 70. Another Operation <ul><li>Definition: </li></ul><ul><li>Special case: </li></ul>
71. 71. More Examples
72. 72. Star-Closure (Kleene *) <ul><li>Definition: </li></ul><ul><li>Example: </li></ul>
73. 73. Positive Closure <ul><li>Definition: </li></ul>If  L then L +  L* - {  } It is not necessary that
74. 74. True or False
76. 76. Try Hw# 9 & 10(b) on p.28 What does w  L 2 mean? What does w  L * mean?
77. 77. More Examples <ul><li>Consider a language on  = { a, b } </li></ul>What is L 2 ? L * ? e.g.
78. 78. Grammars
79. 79. Another Example <ul><li>Grammar: </li></ul><ul><li>Derivation of sentence : </li></ul>
80. 80. <ul><li>Grammar: </li></ul><ul><li>Derivation of sentence : </li></ul>
81. 81. <ul><li>Other derivations for </li></ul>Grammar:
82. 82. <ul><li>Language of the grammar </li></ul>
83. 83. More Notation <ul><li>Grammar </li></ul>Set of variables Set of terminal symbols Start variable Set of Production rules p.21
84. 84. Example <ul><li>Grammar : </li></ul>
85. 85. More Notation <ul><li>Sentential Form: </li></ul><ul><li>A sentence that contains </li></ul><ul><li>variables </li></ul><ul><li>Example: </li></ul>sentence Sentential Forms
86. 86. <ul><li>We write: </li></ul><ul><li>Instead of: </li></ul>
87. 87. <ul><li>In general we write: </li></ul><ul><li>If: </li></ul>
88. 88. <ul><li>By default: </li></ul>
89. 89. Example Grammar Derivations
90. 90. Another Grammar Example <ul><li>Grammar : </li></ul>Derivations: From A  aAb and A   , we know A   , ab , aabb , aaabbb , … * * * *
91. 91. Language defined by a Grammar <ul><li>For a grammar </li></ul><ul><li>with start variable : </li></ul>String of terminals
92. 92. Example <ul><li>For grammar : </li></ul>Since Pf: show L(G)  {a n b n+1 } & L(G)  {a n b n+1 } from A  aAb we get A  a n Ab n when it is applied n times. Together with A   , we get A  a n b n for n = 0, 1, 2, ….  : w  L(G), i.e. S  * w
93. 93. A Convenient Notation In general, we need to give a proof that a given language indeed generated by a certain grammar. Back to last Example
94. 94. Example <ul><li>For grammar : </li></ul>To show Pf: show L(G)  {a n b n+1 } & L(G)  {a n b n+1 } from A  aAb we get A  a n Ab n when it is applied n times. Together with A   , we get A  a n b n for n = 0, 1, 2, ….  : w  L(G), i.e. S  * w L ( G )  L & L ( G )  L Need to show
95. 95. More Examples on Grammars <ul><li>Find grammars for L on { a, b } and give brief arguments to explain why they work. </li></ul>L contains all strings with exactly one a L contains all strings with at least one a L 3 At Least: S  BaB; B  aB | bB | 
96. 96. 1. Problems on p.27 <ul><li>You should be able to do </li></ul><ul><li>2 ~ 17, 21 </li></ul><ul><li>Hand in: 9, 10, 11c, 14ef, 15c, 17 </li></ul>2. Read P. 37~ 41 , and try to describe L ( M ) in Fig. 2.6. Homework for next week.