0% found this document useful (0 votes)
11 views41 pages

Toa Handout 2

Uploaded by

waseem khosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views41 pages

Toa Handout 2

Uploaded by

waseem khosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 41

Theory of Automata

Handout no 2

1
Courtesy Costas Busch - RPI 2
Languages

3
Language

• In English, there are at least three


different types of entities: letters,
words, sentences.
• Letters are from a finite alphabet { a,
b, c, . . . , z }
• Words are made up of certain
combinations of letters from the
alphabet.
Not all combinations of letters lead to a valid English word.
• Sentences are made up of certain
combinations of words.
Not all combinations of words lead to a valid English sentence.

• So we see that some basic units are


combined to make bigger units.
Languages
• How can you tell whether a given
sentence belongs to a particular
languages
– Black is cat the
– The tea is hot
– I like chocolates two much
• Rules give a clue to forming as well as
validating sentences.
Formal vs. Informal

• Informal language
• Incoherent strings are also
understandable
• Like idiom
• Raise ambiguity
– Interpretation varies with region
– Same words have multiple meanings.
• Like, light, base, etc.
Informal languages

• Natural languages are generally


defined informally
• Human brain
– Capable to understand incoherent even
invalid sentences.
• You mangoes like
– Rectify grammatical errors etc.
– Resolve ambiguity
• Interpret according to context
• Supporting aids such as Facial expressions
and body language etc.
How to Communicate with
machines ?
• Need a language: what sort
• Machines don’t have human mind
though may have its partial imitation
• Would fail on incorrect or ambiguous
input
– Some recovery or input corrections may be
proposed but again very limited.
• Thus need a precise, explicit and
universal definition of communication
language
Summary of Languages
• Three aspects/specifications
– Lexical
• Defines valid words/units of a language
– Syntactic
• Defines rules for combining the units to form
valid sentences (computer programs in
context of machines)
– Semantic
• Concerned with the interpretation or
meaning of a sentence (what output to
produce in context of machines)
• Affected by ambiguity the most.
Formal languages

• Rules defined explicitly and clearly


• No ambiguities
• Universally uniform understanding
• Lets the machine
– Interpret an input uniformly every time.
i.e. always produces same output for a
particular input
– Explicitly reject invalid input
Formal Languages

• Need uniformly understandable


notation
• Representations
– Alphabet
• Represents a finite set of fundamental units of
lanauges, e.g. for English ={a,b,….z.A,…Z,}
∑ = {0,1}
∑ = {0,1,2,3,4,5,6,7,8,9}
Formal Languages

– List of words
• Set of all valid words of a given language,
e.g., a language English_Words that contains
all valid words of English would have a  =
{all entries of the dictionary + punctuation
marks and blank space….}
• Denoted by 
• Strings: A string a finite sequence of symbols
chosen from alphabet. For example
0111100 , 123045, abbbcdeg etc.
• String Variable: A letter used for
denoting a string. The author uses w, x, y
and z as string variable. For example
w = 0111100 , x = 123045, z =
abbbcdeg
• Length of String: The number of
positions for symbols in the string. For
simplicity we can say that it is the
number of symbols in the string. For
example
|w| = 7 , |x| = ? , |z| = ?
Finite vs. Infinite Languages

• Finite Languages
– Countable set of words
– Can be defined by rigorously listing the
words in 
– E.g. English-Words
• Infinite Languages
– Infinite set of valid words
– Cant be listed completely
– E.g. English_Sentences
Infinite Languages
• Most of the languages are infinite
• How can u check whether a word
belongs to a language if it is
– Finite
• Checking its entry in 
– Infinite
• Validating against rules
Defining Languages
• Define alphabet set
• Define rules for forming valid words and
sequences of words from 
– Called grammar
– Can be descriptive
– Can be mathematical
• Can also define supporting functions e.g.,
length(X), reverse(x)
Defining languages
• Example ={a,b,…z}
– L = {all words formed only of odd number
of xs}
– L = {xn | n is odd}
– L = {all words of length less than or equal
to 4}
– PALINDROME ={Λ, all strings x such that
reverse (x) = x}
Kleene Closure
• Set closure
• Kleene Closure (applied to )
– A set of all the strings (finite) that can be
formed by the elements of  where the
elements may be repeated any number of
times.
– Denoted by *
– Also called Kleene star.
• ∑* : The set of all strings over an
alphabet ∑ and called Kleene Star
Closure of alphabet. So we have
∑* = ∑0 U ∑1 U ∑2 U ∑3 U……………
• ∑+ : The set of all strings over an
alphabet ∑ excluding empty string, ε,
and called plus operation. So we
have
∑+ = ∑1 U ∑2 U ∑3 U……………
Some observations
• Λ represents an empty string (not
alphabet thus not a part of )
• ε also represents the same
• ε is not equivalent to 
• If  =  then
 * = {Λ}
• Is S* == (S*)* and so on
Alphabets and Strings
We will use small alphabets: a, b

Strings
a
ab u ab
abba v bbbaaa
baba w abba
aaabbbaabab
22
String Operations

w a1a2  an abba
v b1b2 bm bbbaaa

Concatenation

wv a1a2  anb1b2 bm abbabbbaaa

23
w a1a2  an ababaaabbb

Reverse

R
w an  a2 a1 bbbaaababa

24
String Length
w a1a2  an
Length: w n

Examples: abba 4
aa 2
a 1
25
Length of Concatenation

uv  u  v

Example: u aab, u 3
v abaab, v 5

uv  aababaab 8
uv  u  v 3  5 8
26
Empty String
A string with no letters:  , 

Observations:  0

w w w

abba abba abba


27
Substring
Substring of string:
a subsequence of consecutive
characters

String Substring
abbab ab
abbab abba
abbab b
abbab bbab
28
Prefix and Suffix
abbab
Prefixes Suffixes
 abbab w uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab 
29
Another Operation
n
w ww
 
w
n
2
Example: abba  abbaabba

0
Definition: w 
0
abba  
30
The * Operation
 * : the set of all possible strings from
alphabet

 a, b
*  , a, b, aa, ab, ba, bb, aaa, aab,

31
The + Operation
 : the set of all possible strings from

alphabet except

 a, b
*  , a, b, aa, ab, ba, bb, aaa, aab,


  *  

 a, b, aa, ab, ba, bb, aaa, aab,
32
Languages
*
A language is any subset of

Example:  a, b
*  , a, b, aa, ab, ba, bb, aaa,

Languages: 

a, aa, aab


{ , abba, baba, aa, ab, aaaaaa}
33
Note that:

Sets  { } {}

Set size { }   0

Set size {} 1


String length  0
34
Another Example

n n
An infinite language L {a b : n 0}


ab
L abb  L
aabb
aaaaabbbbb
35
Operations on Languages
The usual set operations

a, ab, aaaa bb, ab {a, ab, bb, aaaa}


a, ab, aaaa bb, ab {ab}
a, ab, aaaa  bb, ab a, aaaa
Complement: L  *  L

a, ba  , b, aa, ab, bb, aaa,


36
Reverse

R R
Definition: L {w : w  L}

Examples:ab, aab, baba R


ba, baa, abab

n n
L {a b : n 0}

R n n
L {b a : n 0}
37
Concatenation

Definition: L1L2  xy : x  L1, y  L2 

Example:a, ab, bab, aa

ab, aaa, abb, abaa, bab, baaa

38
Another Operation
Definition: n
L LL L
n
3
a, b a, ba, ba, b 
aaa, aab, aba, abb, baa, bab, bba, bbb
0
Special case: L 

a, bba, aaa0 


39
Star-Closure (Kleene *)

0 1 2
Definition: L* L  L  L 

Example:
 , 
a, bb, 
 
a, bb*  
 aa , abb, bba , bbbb, 
aaa, aabb, abba, abbbb,
40
Positive Closure

 1 2
Definition: L L  L 
L *   

a, bb, 
  
a, bb aa, abb, bba, bbbb, 
aaa, aabb, abba, abbbb,
 
41

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy