You are on page 1of 59

Finite automata

automation - automatic machine /


self controlled
Example
• Computer
• ATM
• Any machine that has automatic mechanism.
Why we study it?
• It allow us to think systematically about what
machine do without going to hardware details.
• Through theoretical model for machines.
• E.g.
• State/Actions
Language
• Alphabets
• Strings
• Words
• What is Language ?
Why language is important ?
• Because system has limitation -> ATM
– Rules
– Enter
– Cancel
– 0-9

• Why ATM can’t perform other tasks like general computer. That’s why language is important
– Iphone swift language/ objective c language
– Android java language
– Window phone csharp language

• Understanding of system
• Understanding of machine
• How it work systematically

• What will be the input(input is language) ? That help us to understand the system
language
• Letters
1. Character/symbols out of which we build language
for machine, a,b,c,d-z 0,1,2,3,4-9

• Alphabets
1. A set of letters, denoted by sigma Σ
2. Σ = {a,b}
2. set
• String
1. Concatenation of letters
2. Or Sequence of letter
3. Aa, bb, ab, ba

• Language ?
• A set of string with rules
• Rule of every language
• E.g.
• Make a language for machine which strings starts with ‘a’ and end with ‘a’ from
alphabet {a,b}
– Aa
– Aba
– Abbbbaaaaabbbba
– Abababababbbbbbbaaabbbbbbbbbbbbbba
Strings from {a,b}
1. Concatenation of letters

• Aa
• Abbbba
• Baaabbbbaaaa
• aabbbaab
• Abaaaabbaa
• Baa…
Make a language for machine which strings starts with
‘a’ and end with ‘a’ from alphabet {a , b}

• Aa
• aba
• abba
• aBa
• aaba
• aba
1. L1 = {aa , aba , abba , aaba…} this is language with rule
2. English = {home , chair, English , zahid}
3. L2 ={aneela, aqsa, allama, asia, akifa…}
String vs word
• aa
• Bb
• Aba
• abbbbbbbbba
• Abbbbbbbaaabbbaaab
• Ababaab
• aaaaaab
These are string
• But word is aa,aba
1. Because it is permissible in language
2. L1 ={aa,aba, abbbbbbbbba…}
Properties of string
• Empty string
• Length of string
• Reverse of string
• Power of alphabet
• Power of string
• Σ = {a,b} alphabet denoted by Σ

• This alphabet has only two letters


• Any string contains a and b only
• a b ab ba bb aa
Empty string
• string that has no letter, know as null string
– Null
• Donated by ε or Λ or λ.
• Gamma and Epsilon
• Its length is zero(0)
Length of string
• Is the number of letter in string
• Denoted by
• |s|
1. Example: s = ababab
|s| = 6 or length(s) = 6
length(abab) = 4
Reverse of string
• Is obtain by writing letters of string in reverse
order
• Denoted by
– Rev(s) Sr reverse()
1. Example
1. S= abab
2. Rev(s) = baba
Power of alphabet
• Determines that the string made from
alphabet will be of length equal to power of
alphabet.
• Σ = {a,b}2 {aa ab ba bb}
• Total number of letter in alphabet ?
• N m = 22 = 4

• where m is length/power
Power of string
• Determine the length of string
• {bab}2 bab bab

• {bab}4 bab bab bab bab

• ba3b = baaab
Consider the language S*
• Where LanguageS = {a,b}

• How many words does this language have of


length 2 ? Of length 3? Of length n ?
Theory of Automata and formal language

• Kleene star / Closure / Operator

• kleene plus / Positive / Positive closure

• Lexicography order
Power of alphabet
• Determines that the string made from
alphabet will be of length equal to power of
alphabet.
• Σ = {a,b}2 or Σ 2 = {aa ab ba bb}
• Σ 2 = {aa ab ba bb}
Power of string
• Determine the length of string
• {baba}2 = baba baba
• ba2b = baab

• {baba}3 = baba baba baba


• ba3b = baaab
Kleene star
• It is a type of power
• It is undermined power, Represent infinite
number of terms can be made including
empty string.

• Denoted by *
So what is kleene star ?
• Σ 2 = {aa ab ba bb}

• Kleene star {a,b}* 🡪 infinite number of terms


• Σ * = {^, a, b, aa, bb, ab, ba, aaa, aab… }

• ba*b = bb, bab, baab, baaab, baaaab, baaaaab


• Ba3b = baaab

• This Is called kleene star


Kleene plus
• It is a type of power
• It is undermined power, Represent infinite
number of terms can be made except empty
string.
• Denoted by +
So what is kleene plus?
• Σ + = { a, b, aa, bb, ab, ba, aaa, aab… }
• Ba+b =bab, baab, baaab , baaaab, baaaaab…
Why these power ?
• Because we have to understand the limits of
computation.
• When any machine get input , how it accept the
input on what rules ?
• What could be the limit
• Ba*b
• Ba+b
• ab+b
• Above two are example of power
Lexicography order

• Σ + = {a, b, aa, bb, ab, ba, aaa, aab… }


• Σ * = {^, {a, b}, {aa, bb, ab, ba}, {aaa, aab…} }
• Ba*b = {bb, bab, baab, baaaaab…}

• Method of sequencing a language in which


strings are grouped by their length.
• E.g. string of shortest length first.
Formal vs informal language
• What is formal language
• What is informal language
• Difference between both
Why this is important ?
• Because we directly start learning
– State diagram
– Regular expression
– Push down automata and so on.
• But we don’t know why we learn these method to
understand any language.
• This require basic concept
– Importance of automata
– Language ?
– Word, string ? Etc
– Properties of string
Next
• We will understand the difference bw formal
and informal language.
• in automata which language is used.
• Which language can be define using which
methods?
language
• Set of string with rules
• E.g. language of string that start with a and
end with b.
– L1 = {aab, abbbaab, aabab, abbab, abbbab,…}
Informal language
• English language(informal)
• concerned with rule and meaning
• Help(t) ephl(f)

– Informal language = semantic language (according


to meaning)
Formal language
• L1(concerned with just rule/syntax not with
meaning)
• L1: start with e end with l.
– Help ephl

– Formal language = syntactic language(according


rules)
Focus on language
• Automata focuses on formal language
Next
• We learn how to define formal language
– Descriptive definition(method)
– Recursive definition
– Regular expression
– etc

– Language
– Or you can say formal language
– Through these three methods
• So far we know what is alphabet
• What is string ?
• What is word
• What is language
– Set of string with rules
How do automata accept or reject the
input ?
• How machine know given input is correct or wrong ?
• Input given by keyboard, touchpad

• How can automata know given string is valid or not ?

• All this can be done by language


– C++
– C# 🡪 >net MVC
– Cin>> input
– Cout>> out
– Int/string/char/double/float
How do automata accept or reject the
input ?
• There are different method with which we can
define formal language.
• So far we discus the working of machine
theoretically or mathematically.
• We are not going into software or hardware
details.
• We just see how machine work systematically.
How language can be define for automata ?

• Descriptive language is method to define


language.
• It is one of the language defining method.
Descriptive method
• In this method , we simply describe the condition imposed on its
string/words.
• There are some standard to describe language.
– Language name
–=
–{
– Defination, set of all string start with a and end with a
–}
– Exampele:
1. L1 = {any finite string of letters that does not start with letter 0}
2. L1 = {101, 111, 1000000000, 1000, 001}

3. L2 = {set of all string start with a and end with a}


4. L2 = {aba, abba, abbbba, abbbaabba, aabb}
Palindrome language ?
• Define Palindrome language with descriptive definition
– A = 121 , maham
– Reverse(A) = 121 , maham
– MOM
– Madam
– Aziza
– Level
– Afifa

– B = 12321
– Reverse(B) = 12321
Palindrome = {^,all string A such that reverse(A)} {a to z}
E.g.
PalindromeLanguaeName ={abb, a, b, aa, bb, aaa, aba,
abba, abbba, abbbba…}
• Descriptive definition is a method by which we
define language.
• Can Describe condition imposed on language
• languageName = {definition}
Recursive Definition
• What is recursive definition ?
• How to use this ?
• Will Understand with example
– Positive even numbers
– Palindrome

– Recursion
Automata input
• How automata know to accept or reject
input ?
– It based on rules and language
– Language is must for every machine
– Rules is important
• Int intt🡪 c++ compiler
– Accept or reject input based on rules

– There are different method


Recursive Definition
• It is one of the language defining method.
• This method focus on three steps
1. First we specify some object in the set, the
number of object must be finite.
• PositiveEven = {2, 4,6,8,10,12,14,16,18,20,22+2, 24+2,
26, …}
• Basic object is 2 here

• Oop ?????
Recursive Definition
2- Give finite number of rules for constructing
more object in the set from the one we
already know. 2
x+2

3- No object except those constructed allowed


in set.
Positive even no: example
• Recursive definition for positive even numbers
• Rules
1. step1: 2 is in P-EvenLanguage
2. step2: if x is in P-EvenLanguage, then next is x+2
3. step3: the only element in the set P-Even are
those that can be produced from the two rule
above.
• P-EvenLanguage = {2,4,6,8,10,12,14,16,18,20…}
after recursive call
Recursive definition for palindrome
?
Recursive definition for palindrome
• Rules
1. ^,a and b are in Palindrome
2. If word(w) belong to Palindrome , then so are
awa, bwb
3. No other string is in Palindrome unless it can
be produce by rule 1 and 2.
• Reverse(x) = x
Regular Expression
• There are different method with which we can
define language.
• It is one of the language defining method
– In descriptive we define constraints in word
– In recursive we define according to 3 rules
– How to do in this(RE) ??

– In this method , language is represented in terms of


strings. (because language is developed by string)
String ?
• What is string we already know.
• What is word we already know.
• We know the difference.

• We know the properties of string.


– Reverse of string ,
– Length of string
– Power of alphabet
– Power of string
Example(power)
• String contains only a letters using kleene plus
• L={^,a, aa, aaa, aaaa, aaaaa, …}

• RE = a* 🡪 kleene star 🡪 it is undermined power

• L = {^,a,aa,aaa,aaaa…}

• String contains only a letters


• L={a,aa,aaa,aaaa,aaaaa…}

• RE = a+
• L = {+, a+, aa+, aaa+…}
• L = {a,aa,aaa,aaaa…..}
Class task
• String start with a and contain any b letters ?
Example(Concatenation)
• Example:
• String start with a and contain any b letters
• L={a,ab,abb,abbb,abbbb. Abbbbb, abbbbbb…}
• RE = ab*
• Re
= ab+

• ab (concatenation)
• We just learned how to define language with the
help of string.
Class task
• String contains any a or any b ?
• Example:
• String contains a or b only
• L = {a,b}
• RE = (a + b) (union of string) OR

• String contains any a or any b


• RE = (a+b)* = {aaaaaaaa, bb, bbb,aaaa,aa,
aaaabbb, bbbbbb}
• String start with a and end with a
• L={aa,aaa,aba, aaaa, aaba, abaa,abba, abbba…}
• RE = a (a+b)* a
• Ab*a = aba, ababababa, abbba,

• L1={aa,aba,abba,abbb,abbbba}
• Re= ab*a

• L1={aa,aaa,aaaa,aaaa,aaaaaa}
• Re= aa*a

• Here (a+b) is sub string


Quiz
• Get ready for quiz

• Quiz will start within Few Minutes

You might also like