0% found this document useful (0 votes)
452 views4 pages

Type - 0 Grammar: Type-0 Grammars Generate Recursively Enumerable Languages. The

Chomsky classified grammars into four types (Type-0 to Type-3) based on the restrictions placed on the productions. Type-0 grammars have no restrictions, Type-1 productions must be of the form αAβ→αγβ, Type-2 productions must be of the form A→γ, and Type-3 productions must be of the form X→a or X→aY. Arden's Theorem states that for regular expressions P and Q, if P does not contain the null string, then the unique solution to R=Q+RP is R=QP*. A context-free grammar to generate all integers (with sign) was presented with non-terminals S and N, terminals {

Uploaded by

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

Type - 0 Grammar: Type-0 Grammars Generate Recursively Enumerable Languages. The

Chomsky classified grammars into four types (Type-0 to Type-3) based on the restrictions placed on the productions. Type-0 grammars have no restrictions, Type-1 productions must be of the form αAβ→αγβ, Type-2 productions must be of the form A→γ, and Type-3 productions must be of the form X→a or X→aY. Arden's Theorem states that for regular expressions P and Q, if P does not contain the null string, then the unique solution to R=Q+RP is R=QP*. A context-free grammar to generate all integers (with sign) was presented with non-terminals S and N, terminals {

Uploaded by

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

1. Explain Chomskys classification of grammar.

According to Noam Chomosky, there are four types of grammars Type 0,


Type 1, Type 2, and Type 3. The following table shows how they differ from
each other :

Type - 0 Grammar
Type-0 grammars generate recursively enumerable languages. The
productions have no restrictions. They are any phase structure grammar
including all formal grammars.

They generate the languages that are recognized by a Turing machine.

The productions can be in the form of where is a string of terminals


and non-terminals with at least one non-terminal and cannot be null. is
a string of terminals and non-terminals.

Example

S ACaB
Bc acB
CB DB
aD Db

Type - 1 Grammar
Type-1 grammars generate context-sensitive languages. The productions
must be in the form

where A N (Non-terminal)and , , (T N)* (Strings of terminals


and non-terminals)

The strings and may be empty, but must be non-empty.

The rule S is allowed if S does not appear on the right side of any rule.
The languages generated by these grammars are recognized by a linear
bounded automaton.
Example

AB AbBc
A bcA
Bb
Type - 2 Grammar
Type-2 grammars generate context-free languages.

The productions must be in the form A where A N (Non terminal)


and (TN)* (String of terminals and non-terminals).

These languages generated by these grammars are be recognized by a non-


deterministic pushdown automaton.

Example

SXa
Xa
X aX
X abc
X
Type - 3 Grammar
Type-3 grammars generate regular languages. Type-3 grammars must
have a single non-terminal on the left-hand side and a right-hand side
consisting of a single terminal or single terminal followed by a single non-
terminal.

The productions must be in the form X a or X aY where X, Y


N (Non terminal) and a T (Terminal).

The rule S is allowed if S does not appear on the right side of any rule.

Example

X
Xa
X aY
2. State And prove the Adrens theorem for regular expressions.

Arden's Theorem
In order to find out a regular expression of a Finite Automaton, we use
Ardens Theorem along with the properties of regular expressions.

Statement

Let P and Q be two regular expressions.

If P does not contain null string, then R = Q + RP has a unique solution


that is R = QP*

Proof

R = Q + (Q + RP)P [After putting the value R = Q + RP]

= Q + QP + RPP

When we put the value of R recursively again and again, we get the
following equation

R = Q + QP + QP2 + QP3..

R = Q ( + P + P2 + P3 + . )

R = QP* [As P* represents ( + P + P2 + P3 + .) ]

Hence, proved.

Find regular grammar of the following: a(a+b)*(ab*+ba*)b?

The regular expression a(a+b)*(ab*+ba*)b does include abababab; in fact, it


includes (ab)n(ab)n for every n0n0. But your automaton is missing a great deal more
than that. For instance, it doesnt accept aaaaaa or bb, both of which are in the language.
3. Construct a context free grammar, G generating all integrer (with
sign)?

Answer:

Definition A context-free grammar (CFG) consisting of a finite set of


grammar rules is a quadruple (N, T, P, S) where

N is a set of non-terminal symbols.

T is a set of terminals where N T = NULL.

P is a set of rules, P: N (N T)*, i.e., the left-hand side of the production


rule P does have any right context or left context.

S is the start symbol.

Example

The grammar ({A}, {a, b, c}, P, A), P : A aA, A abc.


The grammar ({S, a, b}, {a, b}, P, S), P: S aSa, S bSb, S
The grammar ({S, F}, {0, 1}, P, S), P: S 00S | 11F, F 00F |

Generation of Derivation Tree

A derivation tree or parse tree is an ordered rooted tree that graphically


represents the semantic information a string derived from a context-free
grammar.

Representation Technique

Root vertex Must be labeled by the start symbol.


Vertex Labeled by a non-terminal symbol.
Leaves Labeled by a terminal symbol or .

If S x1x2 xn is a production rule in a CFG, then the parse tree /


derivation tree will be as follows :

Xn
X2
X1

You might also like