1 Languages and Finite Automata or how to talk to machines...
-
date post
20-Dec-2015 -
Category
Documents
-
view
228 -
download
0
Transcript of 1 Languages and Finite Automata or how to talk to machines...
2
A language is a set of strings
String:A sequence of letters (a word)
Examples: “cat”, “dog”, “house”, …
Defined over an alphabet:set of symbols (letters)
Languages
zcba ,,,,
3
Alphabets and StringsWe will use small alphabets
Strings
abbaw
bbbaaav
abu
ba,
baaabbbaaba
baba
abba
ab
a
4
String Operations
Concatenation
Reverse
abbaw
aaaw n
21
bbbaaav
bbbv m
21
abbabbbaaawv
bbbaaawv mn
2121
aaabbbv
bbbvR
mR
12
6
Recursive Definition of LengthFor any letter:
For any string :
Example:
1a
1wwawa
4
1111
111
11
1
a
ab
abbabba
8
Proof of Concatenation LengthClaim:
Proof:By induction on the length
Induction basis:
is only one symbol
From definition of length:
vuuv
v
1v
vuuuv 1
v
10
Inductive StepWrite , where
From definition of length:
From inductive hypothesis:
Thus:
wav 1, anw
1
1
wwa
uwuwauv
wuuw
vuwauwuuv 1
12
SubstringDefinition:
A substring of a string is any sequence of consecutive characters
Example: Substrings
w
abbab
bbab
b
abba
ab
13
Prefix and Suffix
Prefixes Suffixes
abbab
abbab
abba
abb
ab
a
b
ab
bab
bbab
abbabuvw
prefix
suffix
15
The * Operation : the set of all possible strings from alphabet
Example:
*
,,,,,,,,,*
,
aabaaabbbaabaaba
ba
*
,,,,,,,, aabaaabbbaabaaba
16
LanguageA language is any subset of
Examples:
A string is called “sentence”
*
,,,,,,,,,*
,
aabaaabbbaabaaba
ba
},,,,,{
,,,
aaaaaaabaababaabba
aabaaa
18
Operations on LanguagesThe usual set operations
Complement:
aaaaaabbbaaaaaba
ababbbaaaaaba
aaaabbabaabbbaaaaaba
,,,,
}{,,,
},,,{,,,
LL *
,,,,,,, aaabbabaabbaa
21
Another OperationDefinition:
Example:
Special case:
n
n LLLL
bbbbbababbaaabbabaaabaaa
babababa
,,,,,,,
,,,, 3
0
0
,, aaabbaa
L
23
Star-Closure (Kleene *)
Definition:
Example:
210* LLLL
,,,,
,,,,
,,
,
*,
abbbbabbaaabbaaa
bbbbbbaabbaa
bbabba
27
Transition Graph
0q 1q 2q 3q 4qa b b a
initialstate
final state“accept”state
transition
5q
a a bb
ba,Abba -Finite Accepter
ba,
37
FormalitiesDeterministic Finite Accepter (DFA)
FqQM ,,,, 0
Q
0q
F
: set of states
: input alphabet
: transition function
: initial state
: set of final states
43
Transition Function
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b
0q
1q
2q
3q
4q
5q
1q 5q
5q 2q
2q 3q
4q 5q
ba,5q5q5q5q
44
Extended Transition Function
*
QQ *:*
50
40
20
,*
,*
,*
qabbaaq
qabbaq
qabq
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
45
Recursive Definition
)),,(*(,*
,*
awqwaq
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
2
1
0
0
0
0
,
,,
,,,*
),,(*
,*
q
bq
baq
baq
baq
abq
46
Languages Accepted by DFAsTake DFA
Definition:The language accepted by contains all input strings accepted by
In other words: = { strings that drive to a final
state}
M
ML MM
M ML
49
Formally
For a DFA
Language accepted by :
FqQM ,,,, 0
M
FwqwML ,*:* 0
alphabet transitionfunction
initialstate
finalstates
54
Regular LanguagesDefinition:
A language is regularif there is a DFA such that
All the regular languages form a family
LM
MLL