0% found this document useful (0 votes)
3 views

Lecture 1 - Introduction to Automata and Languages

The document is a lecture outline on the Theory of Automata, covering fundamental concepts such as automata, languages, alphabets, strings, and operations on languages. It discusses applications of automata theory in various fields like compiler design, text processing, and cybersecurity, while also introducing formal and informal languages. Exercises and examples are provided to illustrate the concepts of languages and string operations.

Uploaded by

ak1321699
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture 1 - Introduction to Automata and Languages

The document is a lecture outline on the Theory of Automata, covering fundamental concepts such as automata, languages, alphabets, strings, and operations on languages. It discusses applications of automata theory in various fields like compiler design, text processing, and cybersecurity, while also introducing formal and informal languages. Exercises and examples are provided to illustrate the concepts of languages and string operations.

Uploaded by

ak1321699
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

THEORY OF AUTOMATA

Lecture 1: Introduction
Lecturer: Zainab Iftikhar
National University of Technology (NUTECH), Islamabad
OUTLINE

• Automata and the Application of Automata Theory


• Introduction to languages
• Alphabets
• Strings
• Operations on strings
• Words
• Descriptive language
• Operations on languages
• Applications of languages
INTRODUCTION

• 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

• There are two types of languages


• Formal languages (Syntactic languages)
• Informal languages (Semantic languages)
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:

Note: In a computer’s memory, everything is a (binary) string.


LANGUAGES

• 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

• For a language {𝑎, 𝑏}, consider two alphabets:


Σ1 = {𝐵, 𝑎𝐵, 𝑏𝑎𝑏, 𝑑} and Σ2 = {𝐵, 𝐵𝑎, 𝑏𝑎𝑏, 𝑑}.

1. Identify which alphabet the string 𝐵𝑎𝑏𝑎𝑏𝐵 belongs to.


2. Why Can the string 𝐵𝑎𝑏𝑎𝑏𝐵 not be constructed using symbols from both alphabets?
3. Is Σ₁ a subset of Σ₂?
4. List three more strings that can be formed using Σ₁.
5. List three more strings that can be formed using Σ₂.

• Consider the language 𝐿 = {1𝑛2𝑛 ∶ 𝑛 > 0}. Is the string 122 in 𝐿?


STRING OPERATIONS

• 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

• A language is a (finite or infinite) set of strings over a finite alphabet Σ.

Let Σ = {𝑎, 𝑏} and Σ∗ = {𝜀, 𝑎, 𝑏, 𝑎𝑎, 𝑎𝑏, 𝑏𝑎, 𝑏𝑏, 𝑎𝑎𝑎, 𝑎𝑎𝑏, … }.
Some examples of languages over Σ are:
∅, {𝜀}, {𝑎, 𝑏}, {𝜀, 𝑎, 𝑎𝑎, 𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎𝑎}, {𝜀, 𝑎, 𝑎𝑎, 𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎𝑎, … }

• The languages can be defined in different ways


• Descriptive definition
• Using Regular Expressions (RE)
• Using Finite Automaton (FA)
DESCRIPTIVE LANGUAGE

• The language is defined, describing the conditions imposed on its words.


• Examples:
• The language 𝐿 of strings of odd length, defined over Σ = {𝑎}, can be written as
• 𝐿 = {𝑎, 𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎𝑎, … . . }
• The language 𝐿 of strings that does not start with a, defined over Σ = {𝑎, 𝑏, 𝑐}, can be written as
• 𝐿 = {𝜀, 𝑏, 𝑐, 𝑏𝑎, 𝑏𝑏, 𝑏𝑐, 𝑐𝑎, 𝑐𝑏, 𝑐𝑐, … }
• The language 𝐿 of strings of length 2, defined over Σ = {0,1,2}, can be written as
• 𝐿 = {00, 01, 02,10, 11,12,20,21,22}
• The language 𝐿 of strings ending in 0, defined over Σ = {0,1}, can be written as
• 𝐿 = {0,00,10,000,010,100,110, … }
DESCRIPTIVE LANGUAGE: EXERCISE

• 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 INTEGER, of strings defined over Σ = {−, 0,1,2,3,4,5,6,7,8,9} ?

• The language EVEN, of stings defined over Σ = {−, 0,1,2,3,4,5,6,7,8,9} ?

• The language {𝑎𝑛𝑏𝑛 ∶ 𝑛 = 1,2,3, … }, of strings defined over Σ = {𝑎, 𝑏} ?

• The language {𝑎𝑛𝑏𝑛𝑎𝑛 ∶ 𝑛 = 1,2,3, … }, of strings defined over Σ = {𝑎, 𝑏} ?


DESCRIPTIVE LANGUAGE: EXERCISE

• The language FACTORIAL, of strings defined over Σ = {1,2,3,4,5,6,7,8,9} ?

• The language FACTORIAL, of strings defined over Σ = {𝑎}, as {𝑎𝑛! : 𝑛 = 1,2,3, … } ?

• The language DOUBLE FACTORIAL, of strings defined over Σ = {𝑎, 𝑏}, as {𝑎𝑛! 𝑏𝑛! : 𝑛 =
1,2,3, … } ?
2
• The language SQUARE, of strings defined over Σ = {𝑎}, as {𝑎𝑛 ∶ 𝑛 = 1,2,3, … } ?

• The language PRIME, of strings defined over Σ = {𝑎}, as { 𝑎𝑝 ∶ 𝑝 𝑖𝑠 𝑝𝑟𝑖𝑚𝑒} ?


OPERATIONS ON LANGUAGES

• Union
𝐿 ∪ 𝑀 = {𝑤 | 𝑤 ∈ 𝐿 𝑜𝑟 𝑤 ∈ 𝑀}

• Concatenation
𝐿. 𝑀 = 𝐿𝑀 = {𝑤 | 𝑤 = 𝑥𝑦, 𝑥 ∈ 𝐿, 𝑦 ∈ 𝑀}

• Powers
𝐿0 = {𝜀}
𝐿𝑘 = 𝐿. 𝐿𝑘−1 , 𝑓𝑜𝑟 𝑘 ≥ 1

• Kleene Closure

𝐿∗ = ራ 𝐿𝑖
𝑖=0
APPLICATIONS OF LANGUAGES

1. Pattern Matching on the Web


• Problem: Given a search string w and a Web document d, do they match? In other words, should a
search engine, on input w, consider returning d?
• The language to be decided: {<w, d> : d is a candidate match for the query w}.
2. Question-Answering on the Web
• Problem: Given an English question q and a Web document d (which may be in English or Chinese),
does d contain the answer to q?
• The language to be decided: {<q, d> : d contains the answer to q}.
RECAP

• 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.

You might also like