Lecture 01 - Introduction To LT & FA-2024
Lecture 01 - Introduction To LT & FA-2024
Lecture 01 - Introduction To LT & FA-2024
• Automata
• Symbols
• Alphabet
• Strings
• Language
• Finite Automata
1/21/2024
Theory of Computation
1/21/2024 3
Language Theory
LAG
Symbol
Alphabet
String
Language
1/21/2024 4
What we study in this course?
To know about the laws of computations
the laws of computation tell us what is (im)possible for computers.
Just like the laws of physics tell us what is (im)possible for nature to do
1/21/2024 5
Automata Theory
We will study • We will not study
1/21/2024 6
What is an Automata
Useful model for many important systems, both hardware or
software
1/21/2024 7
Example
• States
On/off switch • Transitions
• Inputs
• Start state
• Final (accepting) state
push
on off
push
1/21/2024 9
Automata Theory
In English, we have letter, words and sentences (relationship)
Not all collection of letters form a valid word, not all collections of
words form a valid sentence
Same in Computer Languages
Certain character strings are recognized (do, if, While)
Certain strings of words are recognizable commands
Certain set of commands become a program
Its important to adopt a structure, where the decision whether
certain smaller units constitute a larger unit is based on explicit rules
and not guesswork.
Its hard to state all the rules for the language ENGLISH
But in programming languages we can insist on precise rules,
computers cannot understand informal speech
1/21/2024 10
Formal Languages
A language in which all rules for language are explicitly stated.
1/21/2024 11
Formal Languages
In computer science, formal languages are often used as the basis for
defining programming languages and other systems in which the words
of the language are associated with particular meanings or semantics.
Software for parsing formal languages may be generated by means of a
compiler, often separated into a lexical analyzer and parser generator.
Formal statements have one and only one meanings unlike informal
languages
1/21/2024 12
Introduction - Basics
Symbols : Basic building blocks for language
Symbols { a, b, 0, 1, or anything like, ψ, Ю, ж, , ……}
we can form
Set can be anything like {0,1}, {0,1,…9}. There are 2 types of set
Finite Set: a set having upper bound (ending value), i.e., {0,1, ….
9}, or {a, b, c,….z}
Infinite Set: a set having no upper bound (no ending value, i.e.,
{0,1,2,….}
String { a, b, aa, bb, abb, ….}
String is nothing, just a sequence of Symbols define over Alphabet
a string with length 1.
aa string with length 2 etc.
1/21/2024 13
Introduction - Basics
String { a, b, aa, bb, abb, ….}
we can form
Example:
Keywords/reserve words, identifiers etc
1/21/2024 14
Introduction - Basics
1/21/2024 15
Introduction - Basics
How many strings are possible for Σ {a, b} of length n.
___ ___ ___ ___ …… __
aa bb ab ba …… n
2 x 2 x 2 x 2 …… n
2n
>
-
length (n)
>
- number of characters (a , b)
1/21/2024 16
Introduction - Language
1/21/2024 17
Introduction - Language
In term of Language Theory: A language is nothing, but a collections of
Strings.
Example: Σ {a, b}
2 n = 2 2= 4
L2 = Set of all strings of length 3 {aaa, aab, aba, abb, baa, bab, bba, bbb}
2 n= 2 3= 8
L3 = Set of all strings starting with “a” {a, aa, ab, aab, aba, ….}
2n
1/21/2024 19
Introduction - Language
Sigma Σ: If Σ {a, b}
L* = L0 U L1 U L2 U……..
1/21/2024 20
Introduction - Language
Positive Closure:
Let L be a language over some alphabet Σ then positive closure of L is
denoted by L+ defined as follows
L+ = {Set of all Strings over Σ }
L+ = L1 U L2 U……..
Or Σ+ = Σ*-Σ0
Example:
S={0}
1/21/2024 21
Example
1/21/2024 22
Introduction - Language
Why we need to study about “String” or “Language”?
All the string for C-Language are build over the above mention Σ
set.
void main(){
Now Programing example, int a,b;
:
C-Program Language set of all “valid” :
}
Programs
Valid means correct, for invalid you will get error while compiling
1/21/2024 23
Introduction - Language
How many Programs are valid in “C” ?
Simplest Solution:
1. Save all possible programs on the computer
2. Match the new program within the list one/one
3. If Match == Yes Then given program is valid
4. Else Invalid program
1/21/2024 24
Introduction - Language
Solution 2: To define a language over set Σ with a finite set of
strings and then just verify that a given string from any given
program is out of the language or not.
Example: Σ {a,b} and L1 { aa, ab, ba, bb}, so the given string
Saaa (to check it is a part of the language or not)
But if L2 {a, ab, aba, ……} then the given string Sababa
1/21/2024 25
Introduction - Language
Language ( L )
Yes (accept)
String (given) Finite
String
No (Reject)
• The given Language (L) have finite string, where any given
string are match with the finite string of the language.
• if match=Yes then accepted else rejected
1/21/2024 26
Introduction - Language
Language ( L )
Yes (accept)
String (given) Finite
Automata
No (Reject)
1/21/2024 28
Introduction – Finite Automata
Example:
a
a
A B
1/21/2024 29
Introduction – Finite Automata
Example:
a
a
A B
Given string
a a
aa A B B
aaa a a a
A B B B
aaaa…… ?
A String should be valid from the list,
if it leads from initial to final state.
1/21/2024 30
Introduction – Finite Automata
Case - 02 Case - 03
a, b a, b
a a
A B A B
b
Given String { aa, aab, aba…} a, b
C
a a b
A B B B
babaaa…… ?
babaaa…… ?
5. Language over {a,b} with the number of a’s in each word exactly
2.
6. Language over {a,b} with all the words starting and ending with
the same letters. E.g., if it begins with ‘a’ must end with ‘a’ etc.
7. Language over {a,b} with all the words starting and ending with
opposite letters. E.g., if it starts with the letter ‘a’ must end with
letter ‘b’ and vice versa.
1/21/2024 32
End of Lesson – 01
Thanks to Dr. Irfan
Any questions?
1/21/2024 33