Click here to load reader
View
109
Download
5
Embed Size (px)
DESCRIPTION
Presentation on Transition Graph
CSI 3104 /Winter 2006: Introduction to Formal Languages Chapter 6: Transition Graphs
Chapter 6: Transition GraphsWe introduce the first non-deterministic but simple theoretical machine: Transition Graph.
Dr. Nejib Zaguia
CSI3104-W06
1
Chapter 6: Transition Graphs
b a
a
a ba,b
+
b
An FA: {baa} a,b The word a? The word baabb? The input fails, or the machine fails on the input. The input is rejected.Dr. Nejib Zaguia CSI3104-W06 2
Chapter 6: Transition Graphs
ba
ab a,b a,b+
aa, ab, bb
A transition graph that accepts the language {baa} What it seems to be a More Powerful Machine
Dr. Nejib Zaguia
CSI3104-W06
3
Chapter 6: Transition Graphs
Two other equivalent Transition Graphs with fewer states baa baa + +
all else
a,b
a,b
The word a? The word baabb? The input crashes. The machine crashes. The input is rejected. (2 ways for an input to be rejected)CSI3104-W06 4
Dr. Nejib Zaguia
Chapter 6: Transition Graphs
a,b
a,b aa,bb+
baa? a choice, a decision 2 possible paths
b|aa - accepted b|a|a - rejected 1 way to crash ba|a rejected The machine represents a language L. baa L? For all w, w L if there exists a path that arrives at a final state.Dr. Nejib Zaguia CSI3104-W06 5
Chapter 6: Transition Graphs
ba
1
ab+
baa
2
b
baab? 2 possible paths, both end in a final state.Dr. Nejib Zaguia CSI3104-W06 6
Chapter 6: Transition Graphs
A transition graph (TG) is the following 3 things: 1. a finite set of states, at least one of which is designated as the start state, and some (maybe none) of which are designated the final states (or accepting states) 2. an alphabet of input letters 3. a finite set of transitions that show how to go to a new state, for some pairs of state and substrings of letters (or ). (One pair can have 0, 1, or more next-states.)Dr. Nejib Zaguia CSI3104-W06 7
Chapter 6: Transition Graphs
A successful path is a series of edges beginning at some start state and ending at a final state. The concatenation of all the substrings that label the edges in the path is a word accepted by this machine. The set of words accepted is the language of the transition graph.
Dr. Nejib Zaguia
CSI3104-W06
8
Chapter 6: Transition Graphs
Example:1
abb
2
L aa
3
a
4 +
b2 3 1 4
abbaab
1
abb
L
aa
b
abbab crashes.Dr. Nejib Zaguia CSI3104-W06 9
Chapter 6: Transition Graphs
Many start states1 2 3
a b aba+
L
1 2
a b aba+
L L
3
These two machines are clearly equivalent. Remark: Every finite automaton is a transition graph.Dr. Nejib Zaguia CSI3104-W06 10
Chapter 6: Transition Graphs
+
L=
L = {L} L baa +
abba
L = {L, abba, baa}Dr. Nejib Zaguia CSI3104-W06 11
Chapter 6: Transition Graphs
L = {}+ +
L
L
L+
L
+
Dr. Nejib Zaguia
CSI3104-W06
12
Chapter 6: Transition Graphs
All words ending in b: (a+b)*b
a,b b +
a
FA b a
b+
transition graph: Some words can fail, crash, and succeed: abab.
Dr. Nejib Zaguia
CSI3104-W06
13
Chapter 6: Transition Graphs
a,b b a b aa b aaDr. Nejib Zaguia CSI3104-W06 14
+
a,b a b b b+
+
Chapter 6: Transition Graphs
Language EVEN-EVEN
FA:even a even b
b 2 b a b a 4 beven a odd b
Transition Graph:aa,bb+ ab,ba aa,bb
1 +
aodd a even b
abalanced odd a odd bCSI3104-W06
ab,baunbalanced
3
Dr. Nejib Zaguia
15
Chapter 6: Transition Graphs
b a bbb a a a,b + b
ab
ab bbb bb
abbbabbbabba
bb aDr. Nejib Zaguia
CSI3104-W06
16
Chapter 6: Transition Graphs
L
La a+
Infinitely many paths for aa
Is there an algorithm to determine if a word is accepted?Dr. Nejib Zaguia CSI3104-W06 17
Chapter 6: Transition Graphs
L
a
a
+
L We can delete the L transitiona, L
a b, LBut not hereDr. Nejib Zaguia CSI3104-W06
a
+
18
Chapter 6: Transition Graphs
A generalized transition graph (GTG) is the following 3 things: 1. a finite set of states, at least one of which is designated as the start state, and some (maybe none) of which are designated the final states (or accepting states) 2. an alphabet of input letters 3. a finite set of edges connecting some pairs of states, each labeled with a regular expressionDr. Nejib Zaguia CSI3104-W06 19
Chapter 6: Transition Graphs
Words without 2 bs in a row: a*
a*+
(ba+a)*
b+L
+
Dr. Nejib Zaguia
CSI3104-W06
20
Chapter 6: Transition Graphs
Kleene Star Closure and Loops b
a,b+
a,b
a
(a+b)*
(a+b)
b*
a
+
Dr. Nejib Zaguia
CSI3104-W06
21
Chapter 6: Transition Graphs
Choosing Transitions
4
ab
b
4
abb
3
abb5
3
Dr. Nejib Zaguia
abb5
22
CSI3104-W06
Chapter 6: Transition Graphs
Choices even with restriction of 1 letter per edge8
a
Machine is nondeterministic
7
b b
9 1 0
78
b1 0
a b L9
23
Dr. Nejib Zaguia
CSI3104-W06