320 likes | 333 Views
Introduction. What lies ahead : formalization of computation various models of computation (increasing difficulty/power) what can / cannot be done ?. Introduction. What lies ahead : formalization of computation various models of computation (increasing difficulty/power)
E N D
Introduction • What lies ahead : • formalization of computation • various models of computation (increasing difficulty/power) • what can / cannot be done ?
Introduction • What lies ahead : • formalization of computation • various models of computation (increasing difficulty/power) • what can / cannot be done ? • Motivation ?
Discrete Math • Models are mathematical • need basic discrete math knowledge [Part I of the book] • we will go over Sections 1.5, 2.4, and 2.5 • Notation in the book • A’ is the complement of a set A • N is the set of natural numbers (these slides use N) • Quiz
[Section 1.5] Languages
[Section 1.5] Languages A language is a set of strings involving symbols from some alphabet. An alphabet is a finite set of symbols, typically denoted by . Examples :
[Section 1.5] Languages A language is a set of strings involving symbols from some alphabet. An alphabet is a finite set of symbols, typically denoted by . A string over is a finite (possibly empty) sequence of elements of . Examples of strings over {0,1} : These are not strings over {0,1} :
[Section 1.5] Languages A language is a set of strings involving symbols from some alphabet. An alphabet is a finite set of symbols, typically denoted by . A string over is a finite (possibly empty) sequence of elements of . denotes the null string – the empty sequence of elem. of . If x is a string over , |x| denotes the length of x, i.e. the number of symbols of the alphabet in the string.
[Section 1.5] Languages * denotes the language of all strings over . Examples :
[Section 1.5] Languages * denotes the language of all strings over . A language over is a subset of *. Examples : What are the sizes of these languages ?
[Section 1.5] Operations on languages • Set operations : • union L1[ L2 • intersection L1Å L2 • difference L1 - L2 • complement L’ =
[Section 1.5] Operations on languages Operations on strings • Let x,y 2*. • xy is the concatenation of x and y • Examples :
[Section 1.5] Operations on languages Operations on strings • Let x,y 2*. • xy is the concatenation of x and y • for an integer k, xk is the concatenation of k copies of x • Examples :
[Section 1.5] Operations on languages Operations on strings • Let x,y 2*. • xy is the concatenation of x and y • for an integer k, xk is the concatenation of k copies of x • x is a substring of y iff there exist w,z2* such that y = wxz • Examples :
[Section 1.5] Operations on languages Operations on strings • Let x,y 2*. • xy is the concatenation of x and y • for an integer k, xk is the concatenation of k copies of x • x is a substring of y iff there exist w,z2* such that y = wxz • x is a prefix of y iff there exists z2* such that y = xz • Examples :
[Section 1.5] Operations on languages Operations on strings • Let x,y 2*. • xy is the concatenation of x and y • for an integer k, xk is the concatenation of k copies of x • x is a substring of y iff there exist w,z2* such that y = wxz • x is a prefix of y iff there exists z2* such that y = xz • x is a suffix of y iff there exists z2* such that y = zx • Examples :
[Section 1.5] Operations on languages Operations on strings • Let x,y 2*. • xy is the concatenation of x and y • for an integer k, xk is the concatenation of k copies of x • x is a substring of y iff there exist w,z2* such that y = wxz • x is a prefix of y iff there exists z2* such that y = xz • x is a suffix of y iff there exists z2* such that y = zx • xr is the reverse of x iff xr is “x written backwards” • Examples :
[Section 1.5] Operations on languages Operations on strings extended to languages • Let L, L1, L2µ*. • L1L2 is the concatenation of languages L1L2, i.e. • L1L2 = { xy | x 2 L1, y 2 L2 } • Examples :
[Section 1.5] Operations on languages Operations on strings extended to languages • Let L, L1, L2µ*. • L1L2 is the concatenation of languages L1L2, i.e. • L1L2 = { xy | x 2 L1, y 2 L2 } • - for an integer k, Lk is the concatenation of k copies of L • Examples :
[Section 1.5] Operations on languages Operations on strings extended to languages • Let L, L1, L2µ*. • L1L2 is the concatenation of languages L1L2, i.e. • L1L2 = { xy | x 2 L1, y 2 L2 } • for an integer k, Lk is the concatenation of k copies of L • L* = [k=0…1Lk (this operation is called Kleene’s star) • Examples :
[Section 1.5] Operations on languages Operations on strings extended to languages • Let L, L1, L2µ*. • L1L2 is the concatenation of languages L1L2, i.e. • L1L2 = { xy | x 2 L1, y 2 L2 } • for an integer k, Lk is the concatenation of k copies of L • L* = [k=0…1Lk (this operation is called Kleene’s star) • L+ = [k=1…1Lk • Examples :
[Section 1.5] Operations on languages Operations on strings extended to languages • Let L, L1, L2µ*. • L1L2 is the concatenation of languages L1L2, i.e. • L1L2 = { xy | x 2 L1, y 2 L2 } • for an integer k, Lk is the concatenation of k copies of L • L* = [k=0…1Lk (this operation is called Kleene’s star) • L+ = [k=1…1Lk • Lr is the reverse of L, i.e. Lr = { xr | x 2 L } • Examples :
[Section 2.4] Recursive Definitions • A well-known recursive definition : • 1) 0! = 1 • for every n 2 N, (n+1)! = (n+1) . n! • Compute 5!
[Section 2.4] Recursive Definitions Recursive definition of *
[Section 2.4] Recursive Definitions Recursive definition of the length of a string
[Section 2.4] Recursive Definitions Recursive definition of the reverse of a string Compute (abcb)r.
[Section 2.4] Recursive Definitions Recursive definition of a language A palindrome is a string that reads the same forward and backward. Examples :
[Section 2.4] Recursive Definitions Recursive definition of a language A palindrome is a string that reads the same forward and backward. abpal is the language of all palindromes over {a,b}. Recursive definition of abpal 1) 2abpal 2) for every w 2abpal and 2{a,b}, w 2abpal 3) nothing else is in abpal Is the definition correct ?
[Section 2.4] Recursive Definitions Recursive definition of a language L0=1µ {0,1}* : 1) 2 L0=1 2) for every x 2 L0=1, 0x1, 1x0, 01x, 10x, x01, and x10 2 L0=1 3) no other strings are in L0=1 Can you describe L0=1 in words ?
[Section 2.5] Structural Induction We will prove that every string z in the (corrected) language L0=1 contains the same number of zeros and ones.
Mathematical Induction We proved : L0=1µ { z | z 2 {0,1}* and #0’s in z = #1’s in z } To prove equality, we need to say that every string z with the same number of 0’s and 1’s can be generated by rules 1)-3).
Mathematical Induction We proved : L0=1µ { z | z 2 {0,1}* and #0’s in z = #1’s in z } To prove equality, we need to say that every string z with the same number of 0’s and 1’s can be generated by rules 1)-3).
Another Exercise Recursive definition of a language La ¸ bµ {a,b}* : 1) a 2 La ¸ b 2) for every x 2 La ¸ b, ax 2 La ¸ b 3) for every x,y 2 La ¸ b, bxy, xby, and xyb 2 La ¸ b 4) no other strings are in La ¸ b