Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome to ! Theory Of Automata Irum Feroz Irum.feroz@superior.edu.pk.

Similar presentations


Presentation on theme: "Welcome to ! Theory Of Automata Irum Feroz Irum.feroz@superior.edu.pk."— Presentation transcript:

1 Welcome to ! Theory Of Automata Irum Feroz

2 Text and Reference Material
Introduction to Computer Theory, by Daniel I. Cohen, John Wiley and Sons, Inc., 1991, Second Edition Introduction to Languages and Theory of Computation, by J. C. Martin, McGraw Hill Book Co., 1997, Second Edition

3 What does automata mean?
It is the plural of automaton, and it means “something that works automatically”

4 Automation

5 What is Automata Theory?
Cpt S 317: Spring 2009 What is Automata Theory? Study of abstract computing devices, physical processes ,theoretical machines or mathematical model A mathematical model is a description of a system using mathematical concepts and language. Analyzing strength and weakness on various inputs to get powerful machine Goal: Limitations Computability vs. Complexity School of EECS, WSU

6 Language Every time we introduce a new machine, we will learn its language; and every time we develop a new language, we will try to find a machine that corresponds to it. In particular, the way we shall be studying about computers is to build mathematical models, called machines, and then to study their limitations by analyzing the types of inputs on which they can operate successfully. The collection of these successful inputs is called the language of the machine

7 Computer Language Certain character strings DO, IF END …
Certain Commands COPY, CUT… Set of commands = program Program -> Machine command

8 Spoken vs Machine language
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. Valid program statement ? Unlike English Machine language is strict to rules

9 Formal Language All rules should be precisely described
What symbols can occur? Game of symbols with formal rules Example ? Informal Language??

10 Languages Structure Alphabets
A finite non-empty set of symbols (letters), is called an alphabet. It is denoted by Σ ( Greek letter sigma). Example: Σ={a,b} Σ={0,1}

11 Strings Definition: Concatenation of finite symbols from the alphabet is called a string. Example: If Σ= {a,b} then a, abab, aaabb, ababababababababab

12 Length of Strings Definition:
The length of string s, denoted by |s|, is the number of letters in the string. Example: Σ={a,b} s=ababa |s|=5

13 EMPTY STRING or NULL STRING
Sometimes a string with no symbol at all is used, denoted by (Capital Greek letter Lambda) Λ, is called an empty string or null string.

14 Words Definition: Words are permissible strings belonging to some language. Example: If Σ= {x} then a language L can be defined as L={xn : n=1,3,5,7…..} or L={x,xxx,xxxxx….} Here x,xxx,… are the words of L

15 Examples Example: The language {anbn }, of strings defined over Σ={a,b}, as {ab, aabb, aaabbb,aaaabbbb,…} Example: The language {anbnan }, of strings defined over Σ={a,b}, as {aba, aabbaa, aaabbbaaa,aaaabbbbaaaa,…}

16 Language Set of words. Set of Rules
English words ={All words in standard dictionary}

17 Defining Languages The languages can be defined in different ways , such as Descriptive definition, Recursive definition, using Regular Expressions(RE) and using Finite Automaton(FA) etc.

18 Descriptive definition of language:
Defining Languages Descriptive definition of language: The language is defined, describing the conditions imposed on its words.

19 New Languages Example 1:
The language L of strings of odd length, defined over Σ={a}, can be written as L={a, aaa, aaaaa,…..} Example 2: The language L of strings that does not start with a, defined over Σ={a,b,c}, can be written as L={b, c, ba, bb, bc, ca, cb, cc, …}

20 Example 3: 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 4: The language L of strings ending in 0, defined over Σ ={0,1}, can be written as L={0,00,10,000,010,100,110,…}

21 Examples Example 5: 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,…} Example 6: The language EVEN-EVEN, of strings with even number of a’s and/or even number of b’s, defined over Σ={a,b}, can be written as {Λ, aa, bb, aaaa,aabb,abab, abba, baab, baba, bbaa, bbbb,…}

22 Example 7: The language INTEGER, of strings defined over Σ={-,0,1,2,3,4,5,6,7,8,9}, can be written as INTEGER = {…,-2,-1,0,1,2,…} Example 8: The language EVEN, of stings defined over Σ={-,0,1,2,3,4,5,6,7,8,9}, can be written as EVEN = { …,-4,-2,0,2,4,…}

23 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

24 Example: Σ= {B, aB, bab, d} s=BaBbabBd Rev(s)=dBbabBaB

25 Defined over Σ such that Rev(s)=s.
An Important language PALINDROME: 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, ...}

26 Regular Expressions

27 Why Regular Expressions?
Previously, we defined the languages: • L1 = {Xn for n = 1, 2, 3, . . .} • L2 = {Xn for n = 1, 3, 5, . . .} • L2 = {Xn for n = 1, 4, 7, } But these are not very precise ways of defining languages rather guess Work

28 Regular Expressions *, + and () Remove ambiguity altogether
Regular expressions are written in bold face letters and are a way of specifying the language. *, + and () + presents choice or disjunction (some time authors used U for this purpose) () used for grouping

29 Powers of an alphabet ∑* : 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……………

30 Language-Defining Symbols: Star Sign
In R.E Kleene star applied directly to the letter x and written as a superscript:. x* This simple expression indicates some sequence of x’s (may be none at all): a* = Λ or a or aa or aaa…

31 The notation x* can be used to define languages by writing, say L = language (x*)
Since x* is any string of x’s, L is then the language of all possible strings of x’s of any length (including Λ).

32 We can apply the Kleene star to the whole string ab if we want:
(ab)* = Λ or ab or abab or ababab… Observe that (ab)* ≠ a*b* because the language defined by the expression on the left contains the word abab, whereas the language defined by the expression on the right does not. Prove it?

33 Example 1 Given ∑ = {a, b}, define the language L that contains all words of the form one a followed by some number of b’s (maybe no b’s at all); that is L = {a, ab, abb, abbb, abbbb, …} Using the language-defining symbol, we may write L = language (ab*)

34 Regular Expression example 2
language L1 = {x; xx; xxx; …}, we can write R.E = language(xx*) which means that each word of L1 must start with an x followed by some (or no) x’s. Note that we can also define L1 using the notation + (as an exponent) introduced in previous lecture L1 = language(x+)

35 Regular Expression example 3
Given ∑ = {a, b}, define the language L that contains all words of the form At least two letters Begin and end with a Have nothing but b or b’s may arrive L = {aa, aba, abba, abbba, abbbba, …} L = language (ab*a)

36 Regular Expression example 4
Strings of a’s and b’s in which all the a’s (if any) come before all the b’s(if any)? ∑=(a,b) Language = {^ ab, aabb,aaabbb … } abab? baaaa ? bababa? L = language (a*b*)

37 Plus Sign Let us introduce another use of the plus sign. By the expression x + y where x and y are strings of characters from an alphabet, we mean either x or y. Care should be taken so as not to confuse this notation with the notation + (as an exponent).

38 Example 1 Consider the language L over the alphabet Σ = {a, b, c}
L = {a; c; ab; cb; abb; cbb; abbb; cbbb; abbbb; cbbbb; …} In other words, all the words in T begin with either an a or c and then are followed by some number of b’s. Using the above plus sign notation, we may write this as L= language((a+ c)b*)

39 Example 2 Consider a finite language L that contains all the strings of a’s and b’s of two exactly: L = {aa, ab, ba, bb} Thus, we may write L = language((a+ b)(a + b))

40 ((a+ b)*) In general, if we want to refer to the set of all possible strings of a’s and b’s of any length whatsoever, we could write language((a+ b)*) This is the set of all possible strings of letters from the alphabet Σ = {a, b}, including the null string.

41 Example Language having double 0 ∑=(0,1) L=(0+1)*00(0+1)*

42 Example all strings containing no more than three a's  =(a,b,c)

43 Formal Definition of Regular Expressions
The set of regular expression is defined by following rules 1. Every letter of  and Λ is a regular expression 2. If r1 and r2 are regular expressions, then so are (r1) r1r2 r1+r2 r1* 3.Nothing else is a regular expression

44 Regular Expressions Given  = {a,b}
a* = {Λ, a,aa,aaa,aaa,aaaa,aaaaa, …} ab* = {a, ab,abb,abbb,abbbb, …} a+b = {a,b} (ab)* = {Λ, ab, abab, ababab, …} (a+b)* = {Λ, any string of as and bs}

45 Exercise (0 + 10*) (0*10*) (a+b)*
L = { 0, 1, 10, 100, 1000, 10000, … } (0*10*) L = {1, 01, 10, 010, 0010, …} (a+b)* Set of strings of a’s and b’s of any length including the null string. So L = { ^, a, b, aa , ab , bb , ba, aaa…….}

46 Exercise (a+b)*abb (11)* (aa)*(bb)*b
Set of strings of a’s and b’s ending with the string abb. So L = {abb, aabb, babb, aaabb, ababb, …………..} (11)* Set of strings consisting of even number of 1’s So L= {^, 11, 1111, , ……….} (aa)*(bb)*b Set of strings consisting of even number of a’s followed by odd number of b’s so L = {b, aab, aabbb, aabbbbb, aaaab, aaaabbb,..}

47 Regular Expressions what languages do they generate a (b + a)* bb(a+b)
(a+b)(a+b)(a+b) (a+b)*ba (a+b)*a(a+b)* (a+b)*aa(a+b)*

48 Exercise Write RE for the languages over the  ={a,b} consisting of words that contain at least one a and at least one b (a+b)*a(a+b)*b(a+b)* (a+b)*a(a+b)*b(a+b)*+(a+b)*b(a+b)*a(a+b)*

49 Example Set consisting of even number of 1’s including empty string
R.E = (11)*

50 Example Set of strings consisting of even number of a’s followed by odd number of b’s L = {b, aab, aabbb, aabbbbb, aaaab, aaaabbb, …………..} R.E = (aa)*(bb)*b

51 Regular Languages Any language that can be represented by a regular expression is called a regular language It is to be noted that if r1, r2 are regular expressions, corresponding to the languages L1 and L2 then the languages generated by r1+ r2, r1r2( or r2r1) and r1*( or r2*) are also regular languages.

52 Regular Languages All finite languages are regular Example
Consider the language L, defined over Σ = {a,b}, of strings of length 2, starting with a, then L = {aa, ab}, may be expressed by the regular expression aa+ab. L is a regular language.

53 Linear Vs Non Linear The equation of a linear function has no exponents higher than 1, and the graph of a linear function is a straight line. The equation of a nonlinear  function has at least one exponent higher than 1, and the graph of a nonlinear function is a curved line.

54 Regular Languages Power is Linear RE for an where n>=3 aaaa*= aaa*a
RE for a2n where n=0 … n (aa)* RE for a2n+1 where n=0 … n a(aa)*

55 Non Regular Language L= {a0 , a1 , a4 , a9 , a16 , a25 }
Power is non linear an2 n2 is non linear, n* n is not finite. an2 is linear if n<=5 because n is finite now L= {a0 , a1 , a4 , a9 , a16 , a25 }

56 Equivalent Regular Expressions
Definition Two regular expressions are said to be equivalent if they generate the same language. Example Consider the following regular expressions r1 = (a + b)* (aa + bb) r2 = (a + b)*aa + ( a + b)*bb then both regular expressions define the language of strings ending in aa or bb

57 Example The language of all words that have at least two a’s can be defined by the expression: (a + b)*a(a + b)*a(a + b)* Another expression that defines all the words with at least two a’s is b*ab*a(a + b)* Hence, we can write (a + b)*a(a + b)*a(a + b)* = b*ab*a(a + b)* where by the equal sign we mean that these two expressions are equivalent in the sense that they describe the same language.

58 Exercise Write Langugae and RE for the following languages over the  ={a,b}. All words ending with b All words that start with a All words that contains at least two a’s All words that start with a double letter All words that contain at least one double letter All words that start and end with a double letter All words of length >=3 All words that contain exactly one a or exactly one b All words that don’t end at b

59 Exercise Example: Give a regular expression for each of the following over the alphabet { 0, 1 }: { w | w begins with a ‘1’ and ends with a ‘0’ } { w | w contains exactly three 1’s} { w | w contains at least three 1’s} { w | w is a string that begin with a ‘1’ and contain exactly two 0’s } Regular expression definition of a language is not unique.


Download ppt "Welcome to ! Theory Of Automata Irum Feroz Irum.feroz@superior.edu.pk."

Similar presentations


Ads by Google