Lecture 1
Lecture 1
BATTERY
input: switch
output: light bulb
actions: flip switch
states: on, off
A Simple Computer
f
BATTERY
start off on
f
input: switch
bulb is on if and only if
output: light bulb
there was an odd number of
actions: f for “flip switch” flips
states: on, off
Another “computer”
1
1 start off off
1
BATTERY 2 2 2 2
1
2
off on
1
inputs: switches 1 and 2
bulb is on if and only if
actions: 1 for “flip switch 1”
both switches were flipped
actions: 2 for “flip switch 2”
an odd number of times
states: on, off
Example 02
• Definition:
The length of string s, denoted by |s|, is
the number of letters in the string.
• Example:
Σ={a,b}
s=ababa
|s|=5
Length of Strings
• Example:
Σ= {B, aB, bab, d}
s=BaBbabBd
Tokenizing=(B), (aB), (bab), (B), (d)
|s|=5
Reverse of a String
• Definition:
The reverse of a string s denoted by
Rev(s) or sr, is obtained by writing the
letters of s in reverse order.
• Example:
If s=abc is a string defined over Σ={a,b,c}
then Rev(s) or sr = cba
Reverse of a String
• Example:
Σ= {B, aB, bab, d}
s=BaBbabBd
Rev(s)=dBbabaBB
Kleene Star Closure
i. (S+)*=(S*)*
ii. (S+)+=S+
iii. (S*)+=(S+)*
UNIT # 1.4
Defining Languages
Defining Languages
• Example:
The language L of strings of length 2,
defined over Σ={0,1,2}, can be written as
L={00, 01, 02,10, 11,12,20,21,22}
• Example:
The language L of strings ending in 0,
defined over Σ ={0,1}, can be written as
L={0,00,10,000,010,100,110,…}
Defining Languages
• Example: The language EQUAL, of strings with
number of a’s equal to number of b’s, defined
over Σ={a,b}, can be written as
{Λ ,ab,aabb,abab,baba,abba,…}
{aa,aaa,aaaaa,aaaaaaa,aaaaaaaaaaa
…}
An Important language
• PALINDROME:
The language consisting of Λ and the
strings s defined over Σ such that
Rev(s)=s.
It is to be denoted that the words of
PALINDROME are called palindromes.
• Example:For Σ={a,b},
PALINDROME={Λ , a, b, aa, bb, aaa, aba,
bab, bbb, ...}
UNIT # 1.5
Deterministic Finite Automata