1. Lecture # 1 Theory Of Automata By Dr. MM Alam
  2. Text and Reference Material 1. Introduction to Computer Theory, by Daniel I. Cohen, John Wiley and Sons, Inc., 1991, Second Edition (as a Text Book) 2. Introduction to Languages and Theory of Computation, by J. C. Martin, McGraw Hill Book Co., 1997, Second Edition (for Additional Reading)
  3. What does Theory of automata mean? • The word “Theory” means that this subject is a more mathematical subject and less practical. • It is not like your other courses such as programming. However, this subject is the foundation for many other practical subjects. • Automata is the plural of the word Automaton which means “self-acting” • In general, this subject focuses on the
  4. Theory of Automa Applications • This subject plays a major role in: – Theory of Computation – Compiler Construction – Parsing – Formal Verification – Defining computer languages
  5. Types of languages • There are two types of languages – Formal Languages are used as a basis for defining computer languages • A predefined set of symbols and string • Formal language theory studies purely syntactical aspects of a language (e.g., word abcd) – Informal Languages such as English has many different versions.
  6. Basic Element of a Formal Language – Alphabets • Definition: A finite non-empty set of symbols (letters), is called an alphabet. It is denoted by Greek letter sigma Σ. • Example: Σ={1,2,3} Σ={0,1} //Binary digits Σ={i,j,k}
  7. Example Computer Languages • C Language • Java Language • C++ • Java • Visual C++
  8. What are Strings • A String is formed by combining various symbols from an alphabet. • Example: If Σ= {1,0} then 0, 1, 110011, ….. • Similarly, If Σ= {a,b} then a, b, abbbbbb, aaaabbbbb, …..
  9. What is an EMPTY or NULL String • A string with no symbol is denoted by (Small Greek letter Lambda) λ or (Capital Greek letter Lambda) Λ. It is called an empty string or null string. • We will prefer Λ in this course. Please don’t confuse it with logical operator ‘and’. • One important thing to note is that we never allow Λ to be part of alphabet of a language
  10. What are Words • Words are strings that belong to some specific language. • Thus, all words are strings, but vice versa is not true. Example: If Σ= {a} then a language L can be defined as L={a,aa,aaa,….} where L is a set of words of the language. Also a,aa,… are the words of L but not ab.
  11. Defining Alphabets – Guidelines The following are three important rules for defining Alphabets for a language: • Should not contain empty symbol Λ • Should be finite. Thus, the number of symbols are finite • Should not be ambiguous
  12. Ambiguity (Cont’d…) • Example: an alphabet may contain letters consisting of group of symbols for example Σ1= {A, aA, bab, d}. • Now consider an alphabet Σ2= {A, Aa, bab, d} and a string AababA.
  13. Ambiguity (Cont’d…) • This string can be factored in two different ways – (Aa), (bab), (A) – (A), (abab), (A) Which shows that the second group cannot be identified as a string, defined over Σ = {a, b}. • This is due to ambiguity in the defined alphabet Σ2
  14. Ambiguity (Cont’d…) • Why Ambiguity comes: A computer program first scans A as a letter belonging to Σ2, while for the second letter, the computer program would not be able to identify the symbols correctly. • Ambiguity Rule:- The Alphabets should be defined in a way that letters consisting of more than one symbols should not start with a letter, already being used by some other letter.
  15. Ambiguity Examples • Σ1= {A, aA, bab, d} • Σ2= {A, Aa, bab, d} Σ1 is a valid alphabet while Σ2 is an in-valid alphabet. Similarly, • Σ1= {a, ab, ac} • Σ2= {a, ba, ca} In this case, Σ1 is a invalid alphabet while Σ2 is a valid alphabet.
  16. Length of Strings • Definition: The length of string s, denoted by |s|, is the number of letters/symbols in the string. • Example: Σ={a,b} s=aaabb |s|=5
  17. Word Length Example • Example: Σ= {A, aA, bab, d} s=AaAbabAd Factoring=(A), (aA), (bab), (A), (d) |s|=5 • One important point to note here is that aA has a length 1 and not 2.
  18. Length of strings over n alphabets • Formula: Number of strings of length ‘m’ defined over alphabet of ‘n’ letters is nm • Examples: – The language of strings of length 2, defined over Σ={a,b}is L={aa, ab, ba, bb} i.e. number of strings = 22 – The language of strings of length 3, defined over Σ={a,b} is L={aaa, aab, aba, baa, abb, bab, bba, bbb} i.e. number of strings = 23
  19. 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
  20. • Example: Σ= {A, aA, bab, d} s=AaAbabAd Rev(s)=dAbabaAA or Rev(s)= dAbabAaA Which one is correct?