This preview shows page 1. Sign up to view the full content.
Unformatted text preview: LANGUAGES AND AUTOMATA Tuesday, February 9, 2010 DATA MODEL
Σ: a ﬁnite alphabet, e.g. {0, 1}, {a, b, c}. string or word: a ﬁnite sequence of concatenated symbols of Σ.
0110 abbccbcac empty string: length: 0110 = 4, abbccbcac = 9,  = 0. Convention: a, b, c, · · · ∈ Σ u, v, w, x, y, z used for symbols used for strings Tuesday, February 9, 2010 STRING OPERATIONS
concatenation: x = abbc, y = bccba xy = abbcbccba yx = bccbaabbc
If X and Y are two sets of strings, then XY = {xy : x ∈ X, y ∈ Y } Example. If X = {ab, abca} and Y = {, ab, ca}, then XY = {ab, abab, abca, abcaab, abcaca} Σn = {w : w = n}: set of all strings of length n. Example. for Σ = {0, 1}: Σ0 = {}, Σ1 = {0, 1}, Σ2 = {00, 01, 10, 11}, . . .
We can also deﬁne it inductively: {} n Σ= Σn−1 Σ
Tuesday, February 9, 2010 if n = 0 if n > 0 KLEENE STAR
Σ∗ =
NOTE: Σ∗ is inﬁnite and contains arbitrarily long strings but it contains no inﬁnite strings.
n ∈N Σn Example. If Σ = {0, 1}: If w ∈ Σ∗ , then for i ∈ N we deﬁne if i = 0 i w= wwi−1 if i > 0 We also deﬁne:
Σ+ = Σn = ΣΣ∗ Σ∗ = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, . . .} n≥1 Tuesday, February 9, 2010 LANGUAGES
Example.
Any L ⊆ Σ∗ is called a language. {w : w ∈ {0, 1} and w ≥ 5} {} {w : w is prime} {w ∈ {a, b, . . . , z }∗ : w is an English word}
∗ More Deﬁnitions: The complement of L is L = Σ∗ − L. Tuesday, February 9, 2010 MORE DEFINITIONS
L=
n {} Ln−1 L if n = 0 if n > 0 So, Ln is the set of all the words of the form w1 w2 . . . wn where each wi ∈ L. L∗ = Ln L+ = Ln
n∈N n≥1 substring w = w1 uw2 preﬁx w = uw2 A string u is a of a string w if suﬃx w = w1 u for some w1 , w2 ∈ Σ∗ . Tuesday, February 9, 2010 STRING INDUCTION
Inductive deﬁnition of wR = reverse of w: w if w = 0 R w= av R if w ≥ 1 and w = va, a ∈ Σ, v ∈ Σ∗ Example. (abc)R = ((ab)c)R = c(ab) = c((a)b)R = c(b(a)R )
R = c(b(()a)R ) = c(b(a()R )) = c(b(a)) = cba
Lemma. For all x, y ∈ Σ∗ : (xy )R = y R xR .
Tuesday, February 9, 2010 FINITE STATE MACHINES
start here → 0 1 1 0 0 0 1 0 1 0
q4 q0 q3 q2 q1 one way Rules: “if in state qi scanning ‘0’, go to state qj and move right one cell” Some states (q2 and q4 ) cause the machine to light up. If the light is on after reading the last input symbol, then machine accepts input.
Tuesday, February 9, 2010 MORE PRECISE DEFINITIONS
A DFA is a directed graph with edges labeled with characters of Σ, a start vertex and a set of ﬁnal vertices. The vertices are also called “states”. 0, 1 1
0 0 0 q0 1 q1 q2 q3 1 For each state q and each symbol a ∈ Σ, there is exactly one edge labeled a out of q .
Final (accepting) states are doublecircled.
M accepts w if and only if the unique path starting from q0 , labeled with w ends at a ﬁnal state. Tuesday, February 9, 2010 LANGUAGE OF A DFA
The language accepted by M is L(M ) = {w : M accepts w}.
Note: “L is accepted by M ” means L = L(M ) or w∈L It doesn’t mean ∀w ∈ L : M accepts w (which only means L ⊆ L(M )).
L ⊆ Σ∗ is REGULAR if and only if there exists a DFA M such that L = L(M ). ⇔ M accepts w. Tuesday, February 9, 2010 EXAMPLES
1 0 Design M such that it accepts the following set of words: q0 {w : w is a (binary) number divisible by 5} q2 1 q1 0 0, 1 Tuesday, February 9, 2010 DETERMINISTIC FINITE AUTOMATON
M = (Q, Σ, δ, q0 , F ) Q: Finite set of states Σ: Finite alphabet δ : Q × Σ → Q: Nextstate or transition function q0 : Initial state F ⊆ Q: Final states Tuesday, February 9, 2010 ACCEPTANCE
We extend δ to strings: δ : Q × Σ∗ → Q δ (q, ) = q δ (q, ua) = δ (δ (q, u), a) M accepts w if and only if δ (q0 , w) ∈ F .
Tuesday, February 9, 2010 δ (q0 ,Excercise: reached on δ (q, uvw.= δ (δ (q, u), v ). w): state prove that input ) EXAMPLE
Σ = {0, 1} Ln = {w : nth character from end of w is 1} Mn remembers the last n characters of w seen so far. states: δ: F:
Tuesday, February 9, 2010 {b1 b2 . . . bn : bi ∈ {0, 1}} δ (b1 b2 . . . bn , 0) = b2 b3 . . . bn 0 δ (b1 b2 . . . bn , 1) = b2 b3 . . . bn 1 {1b2 b3 . . . bn : bi ∈ {0, 1}} INTERSECTION
If M1 accepts L1 ⊆ Σ∗ and M2 accepts L2 ⊆ Σ∗ , then there is M accepting L1 ∩ L2 . Idea: Run M1 and M2 simultaneously on input w. Accept iﬀ M1 and M2 both do. Tuesday, February 9, 2010 CROSSPRODUCT CONSTRUCTION
1 M1 = (Q1 , Σ, δ1 , q0 , F1 ) 2 M2 = (Q2 , Σ, δ2 , q0 , F2 ) M = (Q1 × Q2 , Σ, δ, q0 , F2 )
12 q0 =q0 , q0 F = F1 × F2 = {q1 , q2 : q1 ∈ F1 , q2 ∈ F2 } δ (q1 , q2 , a) = δ1 (q1 , a), δ2 (q2 , a) Tuesday, February 9, 2010 EXAMPLE
1 0 q0 0 1 0
q2 q3 0, 3 1, 3 1
0, 2 0
1, 2 q1 1 0 1 1 1 0 0 1
Tuesday, February 9, 2010 0 CORRECTNESS
M simulates M1 and M2 : ∀w ∈ Σ∗ , ∀q1 ∈ Q1 , ∀q2 ∈ Q2 δ (q1 , q2 , w) = δ1 (q1 , w), δ2 (q2 , w) w ∈ L(M ) ⇐⇒ w ∈ L(M1 ) ∩ L(M2 ) Tuesday, February 9, 2010 ...
View
Full
Document
This note was uploaded on 04/11/2010 for the course CSC CSC236 taught by Professor Farzanazadeh during the Spring '10 term at University of Toronto Toronto.
 Spring '10
 FarzanAzadeh

Click to edit the document details