0% found this document useful (0 votes)
46 views9 pages

FLAT Unitt-1

1. Automata theory deals with abstract machines and their ability to perform computations on strings of symbols according to rules. 2. A language is a collection of strings, which can be finite or infinite, formed over an alphabet. Examples of languages are given. 3. Grammars are used to represent languages as a set of production rules. The elements of a grammar are variables, terminals, production rules, and a start symbol.

Uploaded by

Deepak Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views9 pages

FLAT Unitt-1

1. Automata theory deals with abstract machines and their ability to perform computations on strings of symbols according to rules. 2. A language is a collection of strings, which can be finite or infinite, formed over an alphabet. Examples of languages are given. 3. Grammars are used to represent languages as a set of production rules. The elements of a grammar are variables, terminals, production rules, and a start symbol.

Uploaded by

Deepak Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Formal Language & Automata Theory

Unit- 1

Introduction :-
Automata theory is a branch of the theory of computation. It deals with the study of abstract
machines and their capacities for computation. An abstract machine is called the automata. It
includes the design and analysis of automata, which are mathematical models that can perform
computations on strings of symbols according to a set of rules.

Symbols:
Symbols are an entity or individual objects, which can be any letter, alphabet or any picture.
Example:
1, a, b, #

Alphabets:
Alphabets are a finite set of symbols. It is denoted by ∑.
Examples:
1. ∑ = {a, b}

2. ∑ = {A, B, C, D}

3. ∑ = {0, 1, 2}

4. ∑ = {0, 1, ....., 5]

5. ∑ = {#, β, Δ}

String:
It is a finite collection of symbols from the alphabet. The string is denoted by w.
Example 1:
If ∑ = {a, b}, various string that can be generated from ∑ are {ab, aa, aaa, bb, bbb, ba, aba.....}.
o A string with zero occurrences of symbols is known as an empty string. It is represented
by ε.
o The number of symbols in a string w is called the length of a string. It is denoted by |w|.
Example 2:
Let w = 010
Number of Sting |w| = 3

Language:
A language is a collection of appropriate string. A language which is formed over Σ can
be Finite or Infinite.
Example: 1
L1 = {Set of string of length 2}
= {aa, bb, ba, bb} Finite Language
Example: 2
L2 = {Set of all strings starts with 'a'}
= {a, aa, aaa, abb, abbb, ababb} Infinite Language

Closure Representation:
L+ : It is a Positive Closure that represents a set of all strings except Null or ε-strings.
L* : It is “Kleene Closure“, that represents the occurrence of certain alphabets for given
language alphabets from zero to the infinite number of times. In which ε-string is also included.
From the above two statements, it can be concluded that:
L* = εL+
Example:
(a) Regular expression for language accepting all combination of g's over Σ={g}:
R = g*
R={ε,g,gg,ggg,gggg,ggggg,...}
(b) Regular Expression for language accepting all combination of g's over Σ={g} :
R = g+
R={g,gg,ggg,gggg,ggggg,gggggg,...}
Note: Σ* is a set of all possible strings(often power set(need not be unique here or we can say
multiset) of string) So this implies that language is a subset of Σ*.This is also called a “Kleene
Star”.
Kleene Star is also called a “Kleene Operator” or “Kleene Closure”. It is one kind of Unary
operator. In Kleene Star methodology all individual elements of a given string must be present
but additional elements or combinations of these alphabets can be included to any extent.
Example:
Input String: "GFG".
Σ* = { ε,"GFG","GGFG","GGFG","GFGGGGGGGG","GGGGGGGGFFFFFFFFFGGGGGGGG",...}
(Kleene Star is an infinite set but if we provide any grammar rules then it can work as a finite
set. Please note that we can include ε string also in given Kleene star representation.)

Grammar:-

Standard way of representing the language is called grammar in Automata. Grammar contains
set of production rules which makes the strings of language. The set of all possible strings which
can be derived from grammar is known as Language of that grammar.

Real Life Example of Grammar

Grammar is just like the same as English grammar. If the sentence is correct grammatically then
that sentence will be the part of grammar otherwise not. Example
 “I am going to school”. It is a valid example of grammar.
 I going am to school. It is not a valid example of grammar.

Elements of Grammar

To get better understanding of Grammar, we first understand the elements of grammar.


Elements of a grammar depends on depends on types of grammar. The basic elements of
grammar are given below.

G = (V, T, P, S) Where V, T, P, S are the elements of Grammar (G).


1. V = Variables (Non-Terminal)
 Finite number of non-empty set Represented by capital symbols. A, B, C
 Not a part of string which makes after production rule.

2. T = Terminal
 Finite set of Alphabets (Σ), Represented by small letters, i.e. a,b,c.
 All variables are replaced with non-terminals through production rules.
 Terminals are part of string which makes after production rule.

3. P = Production Rules
 (Finite set of non-empty rules to makes a string of Language)
 i.e. P = { S → aSb , S → bSa , S → ∈ }

4. S = Start symbol
Start symbol is used to start the production rule represented by S.
Note: Above grammar generates the strings through production rules having equal number of
a’s and b’s. As given Below
L = {ab, aabb, aaabbb, …….}

Equivalent Grammars

Two grammars will be equivalent if and only if they both generate the same languages.

Grammar G1: Consider the Grammar 1 (G1) with following production Rules.
 S → aSb
 S→∈
Grammar G2: Consider the Grammar 2 (G2) with following production Rules.
 S → aAb / ∈
 A → aAb / ∈

Result: The above Both grammars (G1 and G2) will generate the same language as given below.
L = { anbn , n>=0 }
So, L(G1) = L(G2).
It can be Represented as
∴ G1 ≡ G2

Types of Grammars:

The Noam Chomsky classifies the types of grammar into four types: Type0, Type1, Type2 and
Type3. It is also called the Chomsky hierarchy of grammar. These are types of grammar used in
the theory of computation.
Types Grammars Automata Languages Productions

Type- Unrestricted recursively


Turning Machine α→β
0 Grammar enumerable

Type- Context Sensitive Linear-bounded α → β,


context-sensitive
1 Grammar Machine |β|>=|α|

Type- Context Free Pushdown


context-free A→α
2 Grammar Automata

Type- Finite-State
Regular Grammar regular A → αB, A -> a
3 Automata

where, A and B are non-terminal symbols, α and β are string of terminals and non-terminals
and a is terminal symbol.

Production
Furthermore, a grammar for a language L (over an alphabet ∑) consists of a set of grammar
rules (productions) of the following form −
α → β,
Where α, β are strings of symbols taken from the set of terminals (∑) and non-terminals.
A grammar rule α → β can be read in any of several ways men oned below −
 “replace α by β”,
 “α produces β”,
 “α rewrites to β” ,
 “α reduces to β”.

Formal definition of grammar


Consider an example given below −
If ∑ = {a, b} and S is a non-terminal symbol then the rules S → aS, S → ∧ are examples of
productions for a grammar L.
Now we are ready for the formal definition of a grammar, which is as follows −
 An alphabet T of symbols called terminals. These are identical to the alphabet of the
resulting language.
 An alphabet N of grammar symbols is called non-terminals and is used in the production
rules.
 A specific non-terminal called the start symbol. It is usually S.
 A finite set of produc ons of the form α → β, where α and β are strings over the alphabet
N ∪ T.

Derivation :
Derivation is a sequence of production rules. It is used to get input strings. During parsing, we
have to take two decisions, which are as follows
 We have to decide the non-terminal which is to be replaced.
 We have to decide the production rule by which the non-terminal will be replaced.
Two options to decide which non-terminal has to be replaced with the production rule are as
follows −
 Left most derivation
 Right most derivation.
Let us understand these two options in detail.
1. Left Most Derivation
In the leftmost derivation, the input is scanned and then replaced with the production rule
from left side to right. So, we have to read that input string from left to right.

Example
Production rules:
E=E+E rule1
E=E-E rule2
E=a|b rule3
Let the input be a-b+a
Now, when we perform the Left Most Derivation, the result will be as follows −
E=E+E
E=E-E+E from rule2
E=a-E+E from rule3
E=a-b+E from rule3
E=a-b+a from rule3
Finally, the given string is parsed
2. Right Most Derivation
In Right most derivation, the input is scanned and replaced with the production rule right to
left. So, we have to read the input string from right to left.
Example
Production rule:
E=E+E rule1
E=E-E rule2
E=a|b rule3
Let the input be a-b+a
Now, when we perform the Right Most Derivation, we get the following result −
E=E-E
E=E-E+E from rule1
E=E-E+a from rule3
E=E-b+a from rule3
E=a-b+a from rule3

Chomsky Hierarchy
Chomsky Hierarchy represents the class of languages that are accepted by the different
machine. The category of language in Chomsky's Hierarchy is as given below:

1. Type 0 known as Unrestricted Grammar.


2. Type 1 known as Context Sensitive Grammar.
3. Type 2 known as Context Free Grammar.
4. Type 3 Regular Grammar.
This is a hierarchy. Therefore every llanguage
anguage of type 3 is also of type 2, 1 and 0. Similarly, every
language of type 2 is also of type 1 and type 0, etc.

Type 0 Grammar:

Type 0 grammar is known as Unrestricted grammar. There is no restriction on the grammar


rules of these types of languages. These languages can be efficiently
ntly modeled by Turing
machine, and JVM

For example:

bAa → aa
S→s

Type 1 Grammar:

Type 1 grammar is known as Context Sensitive Grammar. The context sensitive grammar is used
to represent context sensitive language. The context sensitive grammar follows the following
rules:

o The context sensitive grammar may have more than one symbol on tthe he left hand side of
their production rules.
o The number of symbols on the leftleft-hand
hand side must not exceed the number of symbols
on the right-hand side.
o The rule of the form A → ε is not allowed unless A is a start symbol. It does not occur on
the right-hand side of any rule.
o The Type 1 grammar should be Type 0. In type 1, Production is in the form of V → T
Where the count of symbol in V is less than or equal to T.

For example:

S → AT
T → xy
A→a

Type 2 Grammar:

Type 2 Grammar is known as Context Free Grammar. Context free languages are the languages
which can be represented by the context free grammar (CFG). Type 2 should be type 1. The
production rule is of the form

A→α

Where A is any single non-terminal and is any combination of terminals and non-terminals.

For example:

A → aBb
A→b
B→a

Type 3 Grammar:

Type 3 Grammar is known as Regular Grammar. Regular languages are those languages which
can be described using regular expressions. These languages can be modeled by NFA or DFA.

Type 3 is most restricted form of grammar. The Type 3 grammar should be Type 2 and Type 1.
Type 3 should be in the form of

V → T*V / T*

For example:

A → xy

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy