Lecture 1 - Introduction to Automata and Languages
Lecture 1 - Introduction to Automata and Languages
Lecture 1: Introduction
Lecturer: Zainab Iftikhar
National University of Technology (NUTECH), Islamabad
OUTLINE
• One of the main goals of theoretical computer science is the mathematical study of
computation
• Computability : what can be computed ?
• Tractability : what can be efficiently computed ?
• The mathematical study of computation requires
• Abstract models of computation : automata theory
• Abstract representations of problems/data : formal language theory
AUTOMATA
• Automata is the plural of automaton, and it means “something that works automatically”.
• Automata uses rules to process input and transition between different states.
• Applications of Automata Theory:
• Compiler Design & Programming Languages: Lexical analysis and parsing use finite automata and context-free
grammars (CFG) to convert high-level programming code into machine code.
• Text Processing: Spell checkers, autocomplete, and plagiarism detection use finite automata to process text
efficiently.
• Cybersecurity: Automata theory helps in intrusion detection systems (IDS) by identifying malicious patterns in
network traffic.
• Robotics & Control Systems: Finite state machines (FSMs) help design control systems in robotics.
• Network Protocol Design: Communication protocols (e.g., TCP/IP, HTTP, Bluetooth) use state machines to ensure
correct message sequencing.
• Game Development: Non-Playable Characters (NPCs) in video games behave using finite state machines.
APPLICATIONS OF AUTOMATA THEORY
• Example: Elevator
• States
i. Open
ii. Close
• Input
• Button press
• The states change when input is processed.
Button press
closed open
INTRODUCTION TO LANGUAGES
• Alphabet:
A finite non-empty set of symbols (letters), is called an alphabet. It is denoted by Σ.
• String:
A string is a finite sequence of symbols drawn from some alphabet Σ.
• Can be empty/null (denoted as 𝜀)
• The set of all possible strings over an alphabet Σ is written as Σ ∗
• Examples:
• Words:
Strings belonging to some language.
• Example:
• If Σ = {𝑥} then a language 𝐿 can be defined as 𝐿 = {𝑥𝑛 ∶ 𝑛 = 1,2,3, … . . } or 𝐿 =
{𝑥, 𝑥𝑥, 𝑥𝑥𝑥, … . }
• Here 𝑥, 𝑥𝑥, … are the words of 𝐿
Note: All words are strings, but not all strings are words.
EXERCISE
• Length of a string:
The length of string s, denoted by |𝑠|, is the number of letters in the string.
• Example:
• If Σ = {𝑎, 𝑏} and 𝑠 = 𝑎𝑏𝑎𝑏𝑎, |𝑠| = 5
• If Σ = {𝐵, 𝑎𝐵, 𝑏𝑎𝑏, 𝑑} and 𝑠 = 𝐵𝑎𝐵𝑏𝑎𝑏𝐵𝑑, |𝑠| = ?
• Note: |𝜀| = 0
• Reverse of a string:
The reverse of a string s denoted by 𝑅𝑒𝑣(𝑠) or 𝑠𝑟, is obtained by writing the letters of s in
reverse order.
• Example:
• If 𝑠 = 𝑎𝑏𝑐 is a string defined over Σ = {𝑎, 𝑏, 𝑐}, then 𝑅𝑒𝑣(𝑠) = 𝑐𝑏𝑎
• If Σ = {𝐵, 𝑎𝐵, 𝑏𝑎𝑏, 𝑑} and 𝑠 = 𝐵𝑎𝐵𝑏𝑎𝑏𝐵𝑑, then 𝑅𝑒𝑣(𝑠) = ?
STRING OPERATIONS
• Concatenation:
• The concatenation of two strings 𝑠 and 𝑡, written 𝑠 || 𝑡 or simply 𝑠𝑡, is the string formed by
appending 𝑡 to 𝑠.
• 𝑠 ∣∣ 𝑡 = "abc" ∣∣ "de" = "abcde“
• 𝑠 ∣∣ 𝑡 = "hello" ∣∣ "world" = "helloworld"
• Relations on Strings:
• A string 𝑠 is a substring of a string 𝑡 iff 𝑠 occurs contiguously as part of 𝑡.
• For example:
• 𝑎𝑎𝑎 is a substring of 𝑎𝑎𝑎𝑏𝑏𝑏𝑎𝑎𝑎
• 𝑎𝑎𝑎𝑎𝑎𝑎 is not a substring of 𝑎𝑎𝑎𝑏𝑏𝑏𝑎𝑎𝑎
LANGUAGES
Let Σ = {𝑎, 𝑏} and Σ∗ = {𝜀, 𝑎, 𝑏, 𝑎𝑎, 𝑎𝑏, 𝑏𝑎, 𝑏𝑏, 𝑎𝑎𝑎, 𝑎𝑎𝑏, … }.
Some examples of languages over Σ are:
∅, {𝜀}, {𝑎, 𝑏}, {𝜀, 𝑎, 𝑎𝑎, 𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎𝑎}, {𝜀, 𝑎, 𝑎𝑎, 𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎𝑎, … }
• The language EQUAL, of strings with number of 𝑎’s equal to number of 𝑏’s, defined over Σ =
{𝑎, 𝑏} ?
• The language EVEN-EVEN, of strings with even number of 𝑎’s and even number of 𝑏’s, defined
over Σ = {𝑎, 𝑏} ?
• The language DOUBLE FACTORIAL, of strings defined over Σ = {𝑎, 𝑏}, as {𝑎𝑛! 𝑏𝑛! : 𝑛 =
1,2,3, … } ?
2
• The language SQUARE, of strings defined over Σ = {𝑎}, as {𝑎𝑛 ∶ 𝑛 = 1,2,3, … } ?
• Union
𝐿 ∪ 𝑀 = {𝑤 | 𝑤 ∈ 𝐿 𝑜𝑟 𝑤 ∈ 𝑀}
• Concatenation
𝐿. 𝑀 = 𝐿𝑀 = {𝑤 | 𝑤 = 𝑥𝑦, 𝑥 ∈ 𝐿, 𝑦 ∈ 𝑀}
• Powers
𝐿0 = {𝜀}
𝐿𝑘 = 𝐿. 𝐿𝑘−1 , 𝑓𝑜𝑟 𝑘 ≥ 1
• Kleene Closure
∞
𝐿∗ = ራ 𝐿𝑖
𝑖=0
APPLICATIONS OF LANGUAGES
• Introduction to automata
• Applications of automata theory
• Formal and In-formal languages
• Alphabets, strings, null string, words, length of a string, reverse of a string,
• Defining languages
• Operations on languages
• Descriptive definition of languages
• EQUAL, EVEN-EVEN, INTEGER, EVEN, {𝑎𝑛 𝑏𝑛}, {𝑎𝑛 𝑏𝑛 𝑎𝑛 }, FACTORIAL, DOUBLEFACTORIAL,
SQUARE, DOUBLESQUARE, PRIME.