theory of automata ASSIGNMENT 1 (FA21-BCS-011) AMNA SOHAIB (FA21-BCS-014) ARSHIA AZMAT (FA21-BCS-017) FAHAD KHAN (FA21-BCS-020) FASIHA ARSHAD (FA21-BCS-041) MOMINA AMJAD Theory of automata Assignment 1 Q1: What is the link of Automata Theory with the Theory of Computation? Automata theory and the theory of computation are two closely related fields of computer science that deal with the study of computation and computational devices. The theory of computation analyzes the computational problems that these devices can solve, whereas automata theory studies abstract computing devices. The fundamental theoretical foundation for the study of computation is provided by automata theory. It provides a framework for understanding the capabilities and limitations of various computing devices, such as finite-state machines, pushdown automata, and Turing machines. Algorithms that are able to effectively solve problems are developed by utilizing these abstract models of computation to evaluate the computational complexity of a variety of issues. In contrast, the study of the computational problems that can be solved by these abstract computing devices is the primary focus of the theory of computation. This includes the study of the complexity of various computational problems, the creation of effective problem-solving algorithms, and algorithm analysis. In addition, the theory of computation provides a framework for understanding the connection that exists between various computational problems and the various devices that are capable of solving them. To understand the theory of computation, formal languages and automata theory must be studied. For example, the study of regular languages and finite-state machines is crucial for understanding basic string manipulation and parsing algorithms, while the study of context-free languages and pushdown automata is essential for understanding compilers and programming language design. In conclusion, automata theory and the theory of computation are two closely related fields that are essential for understanding the fundamental principles of computer science. Automata theory provides a theoretical foundation for the study of computation, while the theory of computation focuses on the study of computational problems and the algorithms that can solve them. Both fields are critical for the design and analysis of efficient algorithms and the development of new computing technologies. __________________________________________________________________________________ Q2: What is the role of Alan Turing in Theory of Automata? Alan Turing played a significant role in the development of the theory of automata. His work on the concept of Turing machines, which are abstract models of computation, laid the foundation for the study of computational complexity and the limits of computability. Turing machines are essentially mathematical models that can simulate the logic of a computer program and are capable of performing any computation that can be done by a modern electronic computer. Turing's work on the theory of automata was not limited to the concept of Turing machines. He also introduced the idea of a universal machine, which is a machine capable of simulating any other machine. This concept played a key role in the development of computer science, as it paved the way for the development of the first electronic computers. In addition to his theoretical work on the theory of automata, Turing also made significant contributions to the war effort during World War II by developing the Bombe. Overall, Alan Turing's contributions to the theory of automata and computer science were groundbreaking and significant. His work on the concept of Turing machines and the limits of computability laid the foundation for the study of computational complexity and the development of modern electronic computers. __________________________________________________________________________________ Q3: What are the different applications of Automata Theory? Mention at least 5. AUTOMATA THEORY Automata theory is a branch of theoretical computer science that deals with the study of abstract machines and computational models, which are used in problem solving. Understanding the fundamental concepts of computing as well as the characteristics and constraints of various computational models is the core goal of automata theory. Automata theory includes the study of formal languages, which are sequences of symbols that have a specific syntax and grammar. These languages can be represented by mathematical models called automata. There are different types of automata, such as Finite Automata, Pushdown Automata, Turing Machines, and Cellular Automata. These models vary in their computational power and complexity and can be used to solve different types of problems in various fields. APPLICATIONS Here are five different applications of Automata Theory: • COMPILER DESIGN: Automata Theory is widely used in the design of compilers and interpreters for programming languages. It is used in the development of two essential components of a compiler: 1. Syntax Analyzer: a parser responsible for checking the correctness of syntax according to some rules. 2. Lexical Analyzer: a scanner that is used to break down the input source code into a sequence of tokens. Use of Automata Theory in compiler design ensures development of efficient lexical and syntax analysers that can recognize the input source code and produce an error-free parse tree that can be used to generate the machine code. The efficient use of automata theory in compiler design helps to produce fast and reliable compilers that can handle large and complex programs. • NATURAL LANGUAGE PROCESSING: Automata Theory plays a crucial role in natural language processing, especially in the areas of speech recognition and machine translation. It is used to model the structure and syntax of natural language and to design algorithms for language recognition and translation. It provides a powerful set of tools for developing models and algorithms for various tasks in natural language processing. Some specific uses of automata theory in NLP: 1. 2. 3. 4. Part-of-Speech tagging Morphological analysis Sentiment Analysis Machine Translation • SOFTWARE VERIFICATION AND TESTING: Automata Theory is used to verify and test the correctness and reliability of software systems. It is used to model software behaviour and to design algorithms for detecting and eliminating errors and bugs in software systems. • DATABASE SYSTEMS: Automata Theory is used in the design of database systems and data management systems. It is used to model the structure and behaviour of databases and to design algorithms for data retrieval and manipulation. It helps in the processes of: 1. Query optimization 2. Transaction Processing 3. Data Mining 4. XML Processing Automata theory provides a rich set of tools and techniques for analysing, processing, and managing data in various contexts, and it has important applications in database systems and related fields. • ROBOTICS: The design of robots and autonomous systems require the use of Automata theory to some extent. It is used to model the behaviour and decision-making processes of robots and to design algorithms for robot control and navigation. Some examples include: 1. Planning: represent the possible plans and schedules of the robot, and can help optimize them based on various criteria, such as time, resource utilization, or energy efficiency. 2. Finite State Machines: used to model the behaviour of robots and other autonomous systems. 3. Model Checking: verifying correctness and safety of a system. CONCLUSION Automata Theory is a very vast concept having several applications in various fields. It provides a powerful set of tools and techniques for problem solving and has important applications in various domains of research and development. __________________________________________________________________________________ Q4: What Regular Expressions could solve the following real-world problems. i. Admin can search students through their registration numbers. To match the registration number with the record a generalized regular expression will help the application. Possible patterns of registration numbers include FA10-BCS-008, SP11-BSE-001, FA11-BDS-009, SP20-BCY-087, FA21-BAI-002, FA10-RCS-011, and SP14-PCS-007. Regular expression: [SP|FA] [0-9] [0-9] [-] [BCS|BSE|BDS|BCY|BAI|RCS|PCS] [-] [0-9]3 ii. Provide regular expressions for the following. a) To match a yahoo email address For a specific yahoo email, the email is supposed to end with ‘@yahoo.com’. The part before that can consist of numbers, alphabets, and/or some characters such as a period, hyphen, and an underscore. [A-Za-z0-9 ._-]* @yahoo.com b) IP address As an IP address can be from 0 to 255 not more than that, hence: zeroTo255 -> ((0-9){1, 2} | (0|1) (0-9){2} | 2[0-4](0-9) | 25[0-5]) first condition means any 1 or 2 digit number from 0-9. Second condition means if the first digit is 0 or 1, then last two can be any from 0-9. Third condition says that if the first digit is 2, second must be from 0-4 and third from 0-9. Last condition says that if the first two digits are 25 then the third must be from 0-5. Combining this to make the regular expression for the IP Address: zeroTo255 + "\\." + zeroTo255 + "\\." + zeroTo255 + "\\." + zeroTo255 c) HTTP URL’s with .com domain For a URL, it must start with either http or https and must include ‘://’. After that it can consist of numbers, alphabets, and special characters. This is for the domain part and the next set of characters is for the query part. The length of the domain can only be from 2 to 256. After this a period follows which is followed by 2 to 6 characters part of the top domain. The next set of characters are for the query. (http|https)://) [a-zA-Z0-9@:%._\\+~#?&//=]{2,256} \\.[a-z]{2,6} ([-a-zA-Z09@:%._\\+~#?&//=]*) d) C variable For a c variable it can only start with an alphabet or an underscore, nothing else but can consist of numbers also. Hence, the regular expression becomes: (A-Za-z|_)* (A-Za-z0-9_)* Q5. a) How the pacman game can be represented using finite automata (FA)? Consider the below mentioned case study of the pacman game for designing FA. Mention all the 5-tuples of FA, draw the state transition table and state diagram for this problem. For those unfamiliar with the gameplay, Pac-Man requires the player to navigate through a maze, eating pellets and avoiding the ghosts who chase him through the maze. Occasionally, Pac-Man can turn the tables on his pursuers by eating a power pellet, which temporarily grants him the power to eat the ghosts. When this occurs, the ghosts’ behaviour changes, and instead of chasing PacMan they try to avoid him. The ghosts have following behaviours or exist in these states: • Randomly wander the maze • Chase Pac-man, when he is within line of sight • Flee Pac-man, after Pac-Man has consumed a power pellet • Return to the central base to regenerate if dead States of the system are • Pac-Man eats the Ghost , He will keep finding the dots and power pellets for eating them • Ghost eats the Pac-Man, Game ends State transition table State diagram b) How can we represent the working of an automatic washing machine using Finite state automata? c) What would be the possible accepted strings for the following languages. i. Language of all strings having length greater than 3 and prefix bb over ∑={a,b} L = {bbaa, bbaab, bbab, bbaba, bbabb, bbbaa, bbbab, bbbba, bbbbb, … } ii. L = {a n b n | n N}, = {a,b} L = {ab, aabb, aaabbb, aaaabbbb, aaaaabbbbb, aaaaaabbbbbb, aaaaaaabbbbbbb, aaaaaaaabbbbbbbb } iii. Language of all strings having even number of 0’s and odd number of 1’s over ∑={0,1} L = {1, 001, 00111, 00001, 1100111, 10101, 000111011,… } iv. Language of all strings having exactly two a’s and more than three b’s over ∑={a,b} L = {abbba, bababbbb, aabbbbbbbb, bbabbbab, abbbbbbba, … } v. Language of PALINDROME over ∑={a,b} with length not greater than 5. L = { ε, a, b, aa, bb, aba, bab, abba, baab, bbb, … } d) Prove that for all sets S, a) (S+ ) * = (S* ) * S+ = All strings excluding ε S* = All strings including ε (S+)* = ε and all strings in S+ = ε and all strings in (except ε, all string) = ε and all string = S* (S*)* = ε and all strings in S* = ε and all string in (ε and all strings) = ε and all string = S* Hence proved: (S+)* = (S*)* b) (S+ )+ = S + (S+)+ = except ε, all string in S+ = except ε, all String in (except ε, all string) =except ε, all string =S+ Hence proved (S+)+ = S+ e) Let S = {ab, bb} and T = {ab, bb, bbbb}. Show that S* is a subset of T* S* = {ε, ab, bb, abab, bbbb, abbbb, bbbbbb, abbbbbb, bbbbbbbb, …} T* = {ε, ab, bb, bbbb, abbbb, bbbbbb, abbbbbb, bbbbbbbb, abbbbbbbb, …} Since every element of S* is also an element of T*, all of the strings in S* contain only the letters "a" and "b", which are also the only letters in T*, we can say that S* is a subset of T*. Now, show that T* is a subset of S*: Since every element of T* is also an element of S*, we can observe that every element of T* can be generated using only the letters "a" and "b", which are also the only letters in S*. Any element of T* that contains more than one "a" can be obtained by concatenating the string "ab" with some element of S*, while any element of T* that contains only one "a" can be obtained by concatenating the string "a" with some element of S*, we can say that T* is a subset of S*. Therefore, since S* and T* are both subsets of each other, we can say that S* = T*. __________________________________________________________________________________