Title: AUBER F1
1 CD5560 FABER Formal Languages, Automata and
Models of Computation Lecture 2 Mälardalen
University 2010
2- Content
- Languages, Alphabets and Strings
- Strings String Operations
- Languages Language Operations
- Regular Expressions
- Finite Automata, FA
- Deterministic Finite Automata, DFA
3Languages, Alphabets and Strings
4Languages
A language is a set of strings
A String is a sequence of letters
An alphabet is a set of symbols
5Alphabets and Strings
- We will use small alphabets
Strings
6Operations on Strings
7String Operations
Concatenation (sammanfogning)
xy ? abbabbbaaa
8Reverse (reversering)
Example Longest odd length palindrome in a
natural language saippuakauppias (Finnish soap
salesman)
9String Length
Examples
10Recursive Definition of Length
- For any letter
- For any string
- Example
11Length of Concatenation
Example
12Proof of Concatenation Length
- Claim
- Proof By induction on the length
- Induction basis
- From definition of length
13for
Inductive step we will prove
for
14Inductive Step
- Write , where
- From definition of length
- From inductive hypothesis
- Thus
END OF PROOF
15Empty String
- A string with no letters
- (Also denoted as ?)
- Observations
16Substring (delsträng)
- Substring of a string
- a subsequence of consecutive characters
- String
Substring
17Prefix and Suffix
Prefixes
18Repetition
n
w
ww...
w
n
19The (Kleene star) Operation
- the set of all possible strings from
alphabet -
Kleene is pronounced "clay-knee
http//en.wikipedia.org/wiki/Kleene_star
20The (Kleene plus) Operation
the set of all possible strings from the
alphabet except
S
,
b
a
21Example
l
-
S
oj, fy, usch, ojoj, fyfy,uschusch, ojfy, ojusch
K
22Operations on Languages
23Language
- A language is any subset of
- Example
- Languages
S
,
b
a
l
S
,
,
,
,
,
,
,
,
aaa
bb
ba
ab
aa
b
a
K
l
,
,
aab
aa
a
l
,
,
,
,
,
aaaaaa
ab
aa
baba
abba
24Example
25Operations on Languages
26Reverse
Definition
Examples
27Concatenation
Example
28Repeat
29Example
30Star-Closure (Kleene )
31Positive Closure
1
2
L
L
L
L
U
U
l
-
L
32Regular Expressions
33Regular Expressions Recursive Definition
34Examples
35Building Regular Expressions
- Zero or more.
- a means "zero or more a's."
-
- To say "zero or more ab's," that is,
- , ab, abab, ababab, ..., you need to say
(ab). -
- ab denotes a, ab, abb, abbb, abbbb, ....
36Building Regular Expressions
- One or more.
- Since a means "zero or more a's", you can use
aa (or equivalently, aa) to mean "one or more
a's. -
- Similarly, to describe "one or more ab's,"
that is, - ab, abab, ababab, ..., you can use ab(ab).
37Building Regular Expressions
- Any string at all.
- To describe any string at all (with a, b,
c), you can use (abc). - Any nonempty string.
- This can be written as any character from
followed by any string at all (abc)(abc).
38Building Regular Expressions
- Any string not containing....
- To describe any string at all that doesn't
contain an a (with a, b, c), you can use
(bc). -
- Any string containing exactly one...
- To describe any string that contains exactly one
a, put "any string not containing an a," on
either side of the a, like this (bc)a(bc).
39Languages of Regular Expressions
language of regular expression
Example
40Definition
- For primitive regular expressions
41Definition (continued)
- For regular expressions and
-
42Example
Regular expression
43Example
44Example
45Example
46Example
- Regular expression
- (consists of repeating 1s and 01s).
47Example
all strings without two consecutive 0
Equivalent solution
(In order not to get 00 in a string, after each 0
there must be an 1, which means that strings of
the form 1....101....1 are repeated. That is the
first parenthesis. To take into account strings
that end with 0, and those consisting of 1s
solely, the rest of the expression is added.)
48Equivalent Regular Expressions
Definition
are equivalent if
49Example
and
are equivalent regular expressions.
50Additional Sources
- http//www.math.uu.se/salling/ Lennart Salling
- http//www.math.uu.se/salling/AUTOMATA_DV/index.h
tml - Introduktion movie .mov
- Program, strings, integers and integer functions
.mov - Different infinities and integer functions that
can not be calculated by a program .mov - Strings and languages .mov Regular languages and
regular expressions .mov