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

Simplification of Grammer

Uploaded by

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

Simplification of Grammer

Uploaded by

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

THEORY OF AUTOMATA AND FORMAL LANGUAGES

BCSC0011

-By Nishtha Parashar

Assistant Professor, Department of CEA, GLA University, Mathura


CHURCH-TURING THESIS
Church-Turing Thesis

Alonzo Church Alan Turing


(1903-1995) (1912-1954)

Some common interpretations of the thesis are-


▪ Every algorithmically computable function is TM-computable.
▪ A function is computable iff it can be solved by a Turing Machine.

Thesis not Theorem: because we cannot prove this.. With a counter example we can try to disprove it (but this has
not been done yet).
Church-Turing Thesis

TM is a general model of computation, is simply to say that any


algorithmic procedure that can be carried out by any mechanical means
can be carried by a TM. This statement was first formulated by Alonzo
Church in 1930. It was usually refer to as Church Thesis or Church Turing
Thesis.
Some arguments why Turing Thesis is accepted as definition of
mechanical computation or computer.

a) Anything that can be done by existing digital computer can also be


done by ‘TM’.
b) No one has yet been able to suggest a problem, solvable by what we
intuitively consider an algorithm, for which a turing machine program
cannot be written.
c) Alternative models have been proposed for mechanical computations,
but none of them are more powerful than the Turing machine model.
▪ It is a mathematically precise statement because we do not have a
precise definition of the term “Algorithmic Procedure”. Therefore, it is
not something that we can prove. (that’s why it is not a theorem)

▪ Since invention of TM however enough evidence has accumulated to


cause the church-turing thesis to be generally accepted.
RECURSIVELY ENUMERABLE
&
RECURSIVE LANGUAGES
Definition:

A language is recursively enumerable if some Turing


Machine accepts it.
▪ Let L be a recursively enumerable
language and M be the Turing Machine
that accepts it. L

For string w: No
TM
▪ If w L then M halts in a final state. ∞
▪ If w L then M halts in a non-final state
or loops forever. Yes
Definition:

▪ A language is recursive, if some Turing Machine accepts it


and halts on any input string.

In other words:
▪ If for a language there is a halting turing machine then such
language is called as recursive language.
▪ Let L be a recursive language and M
be the Turing Machine that accepts it.

For string w L

▪ If w L then M halts in a final state.


▪ If w L then M halts in a non-final
state. Halting TM TM No

Yes
REMARK:

▪ A Problem/Language with two answers (yes/no) is


decidable.

▪ A Problem/ Language is undecidable if it is not decidable.


L

No
TM

Yes
1. The context free languages are closed under:
a) Intersection
b) Complement
c) Kleene
d) None of the mentioned

2. Context free languages are not closed under:


a) Intersection
b) Intersection with Regular Language
c) Complement
d) All of the mentioned
4. If L1 and L2 are context free languages, L1-L2 are context free:
a) always
b) sometimes
c) never
d) none of the mentioned
5. Recursively Enumerable languages are not closed under
a) Complementation
b) Union
c) Intersection
d) none of these

6. If there exists a language L, for which there exists a TM, T, that accepts every word in L and
either rejects or loops for every word that is not in L, is called
a) Recursive
b) Recursively Enumerable
c) NP-Hard
d) none of the mentioned
7. Universal Turing Machine influenced the concept of
a) stored program computers.
b) interpretative implementation of programming language.
c) computability.
d) all of these.
CHOMSKY CLASSIFICATION
Derivation Tree or Parse Tree
Leftmost and Rightmost Derivations

▪A leftmost derivation of a string is a derivation in which each


production rule is applied to the leftmost non-terminal in the string.

▪A rightmost derivation of a string is a derivation in which each


production rule is applied to the rightmost non-terminal in the string.
EXAMPLE:

Consider G whose productions are

S → aAS | a, A → SbA | SS |ba.



Show that S  aabbaa

Construct a derivation tree whose yield is aabbaa.

S  aAS  aSbAS  aabAS  aabbaS  aabbaa


EXAMPLE:
Consider the grammar G with production rules −
S → S+S | S*S |S| a
Find two Left Most Derivations of the string ”a+a*a”

Derivation 1 : S → S+S → a +S → a+ S*S → a+a*S → a+a*a

Derivation 2 : S → S*S → S+S*S → a+ S*S → a+a*S → a+a*a


Simplification of CFGs
◼ Context Free Grammar can be simplified / reduced by:
◼ Useless production elimination
or
Construction of reduced grammar
◼ -production elimination / Null-production
◼ Unit production elimination
Derive some strings

• A non-terminal
X is useless if: S → aSb | c | Ac
• X does not generate any string of A → aA
terminals.
B → bB | b
• It cannot derive a terminal
string
Any production involving a
OR useless symbol is a useless
• X does not occur in any production.
sentential form
• It cannot be reached from start
symbol
Elimination of Useless Productions

Phase 1 − Derivation of an equivalent grammar, G′, from the CFG, G,


such that each variable derives some terminal string.

Phase 2 − Derivation of an equivalent grammar, G″, from the CFG, G′,


such that each symbol appears in a sentential form.
Let G contain following productions
S →AB A →a B →b B →C E→c

Find G′ such that every variable in G′ derives some terminal string.

V1′ = {A, B, E} A →a, B →b, E → c


V2′ = {A, B, E, S} S →AB
V3′ = {A, B, E, S}
= V2 ′

Here we get V′={S,A,B,E}.


So P′= S →AB, A →a, B →b and E → c
We had G as S →AB, A →a, B →b, B →C, and E → c

Then we got G′ as S →AB, A →a, B →b and E → c

V1″ = {S}
V2″ = {S, A, B} S →AB
V3″ = {S, A, B} A →a, B →b
= V2 ″

Here we get V″={S,A,B}.


So P″= S →AB, A →a, B →b
Question. Find a reduced grammar equivalent to the grammar G, having production rules, P: S→ AC| B,
A-> a, C→c| BC, E→aA|e
Elimination of Null Productions
Elimination of Unit Productions
Thank You

You might also like