Mathematical Preliminaries Hw (p.13) 1, 4, 7, 8, 9, 13,  23, 26, 30, 32
Mathematical Preliminaries Sets  Functions Relations Graphs Proof Techniques
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
Set Representations C = { a, b, c, d, e, f, g, h, i, j, k } C = { a, b, …, k } S = { 2, 4, 6, … } S = { j : j > 0, and j = 2k for some integer k > 0 } S = { j : j is nonnegative and even } finite set infinite set
A = { 1, 2, 3, 4, 5 } Universal Set :  all possible elements  U = { 1 , … , 10 } 1 2 3 4 5 A U 6 7 8 9 10
Set Operations A = { 1, 2, 3 }  B = { 2, 3, 4, 5} Union   A U B = { 1, 2, 3, 4, 5 }  Intersection A  B = { 2, 3 } Difference   A - B = { 1 } B - A = { 4, 5 } U 2 3 1 4 5 2 3 1 Venn diagrams A B
A Complement Universal set = {1, …, 7}  A = { 1, 2, 3 }  A = { 4, 5, 6, 7} 1 2 3 4 5 6 7 A A = A
0 2 4 6 1 3 5 7 even { even integers }  =  { odd integers } odd Integers
DeMorgan’s Laws A U B = A  B U A  B = A U B U
Empty, Null Set: = { } S U  = S S  =  S -  = S - S = U = Universal Set
Subset A = { 1, 2, 3}  B = { 1, 2, 3, 4, 5 } Proper Subset: A B A  B U A  B U
Disjoint Sets A = { 1, 2, 3 }  B = { 5, 6}  A B A  B =  U
Set Cardinality For finite sets A = { 2, 5, 7 } |A| = 3 (set size)
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  )
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
Relation from sets A to B Ex., A = { 1, 2, …, 7 }, B={ 1, 2, …, 50} {(x, y): x  A, y  B, and y= x 2 }  {(x, y): x  A, y  B, and x < y} Are relations from  A to B. A relation  on set A Equivalence relation a partition on set A
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.
GRAPHS A directed graph Nodes (Vertices)   V = { a, b, c, d, e } Edges (Ordered pairs) E = { (a,b), (b,c), (b,e),(c,a), (c,e), (d,c), (e,b), (e,d) } node edge a b c d e
Labeled Graph a b c d e 1 3 5 6 2 6 2
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
Path a b c d e Path  is a walk where no edge is repeated Simple path : no node is repeated
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.
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
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.
(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.
(c, a) (c, a), (a, b) (c, e) (c, e), (e, b) (c, e), (e, d) Step 2 a b c d e origin
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)
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)
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
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.
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.
PROOF TECHNIQUES Proof by induction Proof by contradiction
Induction We have statements   P 1 , P 2 , P 3 , …  If we know for some m that P 1 , P 2 , …, P m  are true for any k >= m that P 1 , P 2 , …, P k   imply  P k+1 Then   Every  P i   is true
Proof by Induction Inductive basis Find P 1 , P 2 , …, P m  which are true Inductive hypothesis Let’s assume P 1 , P 2 , …, P k  are true,  for any k >= m Inductive step Show that P k+1  is true
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
We want to show:   L(n)  ≦  2 n  for n = 0, 1, 2,….   Inductive basis  L(0) =1  ≦  2 0   (the root node  : height=0) Inductive hypothesis Let’s assume L(i)  ≦  2 i  for all i = 0, 1, …, k Induction step we need to show that L(k + 1)  ≦  2 k+1  ,   k ≧0
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
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
Remark Recursion is another thing Example of recursive function: f(n) = f(n-1) + f(n-2) f(0) = 1,  f(1) = 1
Proof by Contradiction We want to prove that a statement P is true we assume that P is false then we arrive at an incorrect conclusion therefore, statement P must be true
Example Theorem:   is not rational Proof: Assume by contradiction that it is rational =  n/m  n, m are nonzero integers and without common factors We will show that this is impossible
= 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!
Languages
A language is a set of  strings String:   A sequence of letters Examples:  “cat”, “dog”, “house”, … Defined over an alphabet: Non-empty and finite
Alphabets and Strings We will use small alphabets: Strings
Empty String A string with no letters
String Operations Concatenation w    = ?    w  = ?
Empty String Observations:
Reverse
String Length Length: Examples: |    | = ?
Length of Concatenation Example:
Example 1.8  (p.17)   | uv | = | u | + | v |   A recursive definition of the length of a string: |  a  | =1, |  wa  | = |  w  | + 1 For all  a  ,  w  is any string from     Fix the string  u   and consider all possible strings   v   (  the length of  v  can be 1, 2, …. ( 0 is trivial) ) The proof is done by induction on the length of  v   ( for any given  u  )
Example 1.8  (p.17)   | uv | = | u | + | v | For a string  u ,  consider the length of  uv , concatenation of  u  with a string  v  Basis   Inductive Step   Induction Assumption
Substring Substring of string:  a subsequence of  consecutive letters String  Substring
Prefix and Suffix Prefixes  Suffixes prefix suffix
Another Operation Example:
Another Operation Definitions:
The * Operation : the set of all possible strings from alphabet   Example:  =  {  a, b }   then  =  ?
The  +  Operation : the set of all possible strings from alphabet  except
Languages Fall 2008 Automata
Note that: Sets Set size Set size String length
Another Example An infinite language
Operations on Languages The usual set operations Complement: ??
When we talk about a  language , we must know what ground does this language stands on ….. Languages We should know the  ALPHABETS  that constitute the language
Complement Example The complement of Universal Set?
Reverse Definition: Examples:
Reverse Hw # 10 (a) Prove or Disprove:  i.e.,  w R    L     w     L R
Concatenation Definition: Example:
Concatenation Hw 8. Prove
Another Operation Definition: Special case:
More Examples
Star-Closure (Kleene *) Definition: Example:
Positive Closure Definition: If   L then L +    L* - {  } It is  not  necessary that
True or False
True or False How to prove your answer?
Try Hw#  9 & 10(b) on p.28 What does  w  L 2  mean? What does  w  L * mean?
More Examples Consider a language on   = { a, b } What is  L 2   ?   L * ? e.g.
Grammars
Another Example Grammar: Derivation of sentence  :
Grammar: Derivation of sentence  :
Other derivations for  Grammar:
Language of the grammar
More Notation Grammar   Set of variables Set of terminal symbols Start variable Set of Production rules p.21
Example Grammar   :
More Notation Sentential Form: A sentence that contains  variables Example: sentence Sentential Forms
We write: Instead of:
In general we write: If:
By default:
Example Grammar Derivations
Another Grammar Example Grammar  : Derivations: From  A   aAb   and  A    , we know A   ,   ab ,  aabb ,  aaabbb , …  * * * *
Language defined by a Grammar For a grammar  with start variable  :  String of terminals
Example For grammar  : 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
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
Example For grammar  : 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
More Examples on Grammars Find grammars for  L  on { a, b } and give brief arguments to explain why they work. 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 |  
1. Problems on p.27  You should be able to do 2 ~ 17, 21 Hand in:  9, 10, 11c, 14ef, 15c, 17  2. Read  P. 37~ 41 , and try to describe  L ( M )   in Fig. 2.6.  Homework for next week.

Class1

  • 1.
    Mathematical Preliminaries Hw(p.13) 1, 4, 7, 8, 9, 13, 23, 26, 30, 32
  • 2.
    Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques
  • 3.
    A set isa 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.
    Set Representations C= { a, b, c, d, e, f, g, h, i, j, k } C = { a, b, …, k } S = { 2, 4, 6, … } S = { j : j > 0, and j = 2k for some integer k > 0 } S = { j : j is nonnegative and even } finite set infinite set
  • 5.
    A = {1, 2, 3, 4, 5 } Universal Set : all possible elements U = { 1 , … , 10 } 1 2 3 4 5 A U 6 7 8 9 10
  • 6.
    Set Operations A= { 1, 2, 3 } B = { 2, 3, 4, 5} Union A U B = { 1, 2, 3, 4, 5 } Intersection A B = { 2, 3 } Difference A - B = { 1 } B - A = { 4, 5 } U 2 3 1 4 5 2 3 1 Venn diagrams A B
  • 7.
    A Complement Universalset = {1, …, 7} A = { 1, 2, 3 } A = { 4, 5, 6, 7} 1 2 3 4 5 6 7 A A = A
  • 8.
    0 2 46 1 3 5 7 even { even integers } = { odd integers } odd Integers
  • 9.
    DeMorgan’s Laws AU B = A B U A B = A U B U
  • 10.
    Empty, Null Set:= { } S U = S S = S - = S - S = U = Universal Set
  • 11.
    Subset A ={ 1, 2, 3} B = { 1, 2, 3, 4, 5 } Proper Subset: A B A B U A B U
  • 12.
    Disjoint Sets A= { 1, 2, 3 } B = { 5, 6} A B A B = U
  • 13.
    Set Cardinality Forfinite sets A = { 2, 5, 7 } |A| = 3 (set size)
  • 14.
    Powersets A powersetis 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.
    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.
    Relation from setsA to B Ex., A = { 1, 2, …, 7 }, B={ 1, 2, …, 50} {(x, y): x  A, y  B, and y= x 2 } {(x, y): x  A, y  B, and x < y} Are relations from A to B. A relation on set A Equivalence relation a partition on set A
  • 17.
    FUNCTIONS domain 12 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.
    GRAPHS A directedgraph Nodes (Vertices) V = { a, b, c, d, e } Edges (Ordered pairs) E = { (a,b), (b,c), (b,e),(c,a), (c,e), (d,c), (e,b), (e,d) } node edge a b c d e
  • 19.
    Labeled Graph ab c d e 1 3 5 6 2 6 2
  • 20.
    Walk Walk isa 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.
    Path a bc d e Path is a walk where no edge is repeated Simple path : no node is repeated
  • 22.
    Path a bc 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.
    Cycle a bc 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.
    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.
    (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.
    (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.
    Step 3 ab 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.
    Step 4 ab 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.
    Trees are connecteddirected 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.
    root leaf Level0 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.
    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.
    PROOF TECHNIQUES Proofby induction Proof by contradiction
  • 33.
    Induction We havestatements P 1 , P 2 , P 3 , … If we know for some m that P 1 , P 2 , …, P m are true for any k >= m that P 1 , P 2 , …, P k imply P k+1 Then Every P i is true
  • 34.
    Proof by InductionInductive basis Find P 1 , P 2 , …, P m which are true Inductive hypothesis Let’s assume P 1 , P 2 , …, P k are true, for any k >= m Inductive step Show that P k+1 is true
  • 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.
    We want toshow: L(n) ≦ 2 n for n = 0, 1, 2,…. Inductive basis L(0) =1 ≦ 2 0 (the root node : height=0) Inductive hypothesis Let’s assume L(i) ≦ 2 i for all i = 0, 1, …, k Induction step we need to show that L(k + 1) ≦ 2 k+1 , k ≧0
  • 37.
    Induction Step FromInductive 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.
    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.
    Remark Recursion isanother thing Example of recursive function: f(n) = f(n-1) + f(n-2) f(0) = 1, f(1) = 1
  • 40.
    Proof by ContradictionWe want to prove that a statement P is true we assume that P is false then we arrive at an incorrect conclusion therefore, statement P must be true
  • 41.
    Example Theorem: is not rational Proof: Assume by contradiction that it is rational = n/m n, m are nonzero integers and without common factors We will show that this is impossible
  • 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.
  • 44.
    A language isa set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Non-empty and finite
  • 45.
    Alphabets and StringsWe will use small alphabets: Strings
  • 46.
    Empty String Astring with no letters
  • 47.
  • 48.
  • 49.
  • 50.
    String Length Length:Examples: |  | = ?
  • 51.
  • 52.
    Example 1.8 (p.17) | uv | = | u | + | v | A recursive definition of the length of a string: | a | =1, | wa | = | w | + 1 For all a  , w is any string from  Fix the string u and consider all possible strings v ( the length of v can be 1, 2, …. ( 0 is trivial) ) The proof is done by induction on the length of v ( for any given u )
  • 53.
    Example 1.8 (p.17) | uv | = | u | + | v | For a string u , consider the length of uv , concatenation of u with a string v Basis Inductive Step Induction Assumption
  • 54.
    Substring Substring ofstring: a subsequence of consecutive letters String Substring
  • 55.
    Prefix and SuffixPrefixes Suffixes prefix suffix
  • 56.
  • 57.
  • 58.
    The * Operation: the set of all possible strings from alphabet Example: = { a, b } then = ?
  • 59.
    The + Operation : the set of all possible strings from alphabet except
  • 60.
  • 61.
    Note that: SetsSet size Set size String length
  • 62.
    Another Example Aninfinite language
  • 63.
    Operations on LanguagesThe usual set operations Complement: ??
  • 64.
    When we talkabout a language , we must know what ground does this language stands on ….. Languages We should know the ALPHABETS that constitute the language
  • 65.
    Complement Example Thecomplement of Universal Set?
  • 66.
  • 67.
    Reverse Hw #10 (a) Prove or Disprove: i.e., w R  L  w  L R
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
    Star-Closure (Kleene *)Definition: Example:
  • 73.
    Positive Closure Definition:If  L then L +  L* - {  } It is not necessary that
  • 74.
  • 75.
    True or FalseHow to prove your answer?
  • 76.
    Try Hw# 9 & 10(b) on p.28 What does w  L 2 mean? What does w  L * mean?
  • 77.
    More Examples Considera language on  = { a, b } What is L 2 ? L * ? e.g.
  • 78.
  • 79.
    Another Example Grammar:Derivation of sentence :
  • 80.
  • 81.
  • 82.
  • 83.
    More Notation Grammar Set of variables Set of terminal symbols Start variable Set of Production rules p.21
  • 84.
  • 85.
    More Notation SententialForm: A sentence that contains variables Example: sentence Sentential Forms
  • 86.
  • 87.
    In general wewrite: If:
  • 88.
  • 89.
  • 90.
    Another Grammar ExampleGrammar : Derivations: From A  aAb and A   , we know A   , ab , aabb , aaabbb , … * * * *
  • 91.
    Language defined bya Grammar For a grammar with start variable : String of terminals
  • 92.
    Example For grammar : 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.
    A Convenient NotationIn general, we need to give a proof that a given language indeed generated by a certain grammar. Back to last Example
  • 94.
    Example For grammar : 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.
    More Examples onGrammars Find grammars for L on { a, b } and give brief arguments to explain why they work. 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.
    1. Problems onp.27 You should be able to do 2 ~ 17, 21 Hand in: 9, 10, 11c, 14ef, 15c, 17 2. Read P. 37~ 41 , and try to describe L ( M ) in Fig. 2.6. Homework for next week.

Editor's Notes