0% found this document useful (0 votes)
10 views12 pages

Lec 6

The lecture covers the concepts of context-free grammars (CFGs), context-free languages (CFLs), and pushdown automata (PDAs), including the equivalence of CFGs and PDAs. It introduces the Pumping Lemma for CFLs as a method to prove certain languages are not context-free and discusses Turing machines, including their definitions and classifications as Turing-recognizable and Turing-decidable languages. The session concludes with a review of the key points discussed, including the implications of the Pumping Lemma and the characteristics of Turing machines.

Uploaded by

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

Lec 6

The lecture covers the concepts of context-free grammars (CFGs), context-free languages (CFLs), and pushdown automata (PDAs), including the equivalence of CFGs and PDAs. It introduces the Pumping Lemma for CFLs as a method to prove certain languages are not context-free and discusses Turing machines, including their definitions and classifications as Turing-recognizable and Turing-decidable languages. The session concludes with a review of the key points discussed, including the implications of the Pumping Lemma and the characteristics of Turing machines.

Uploaded by

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

Lecture 6

Last time:
- Context free grammars (CFGs)
- Context free languages (CFLs)
- Pushdown automata (PDA)
- Converting CFGs to PDAs

Today:
- Proving languages not Context Free
- Turing machines
- T-recognizable and T-decidable languages

1
Equivalence of CFGs and PDAs
Recall Theorem: is a CFL iff some PDA recognizes
Done.
Need to know the fact, not the proof

Corollaries:
1) Every regular language is a CFL.
2) If is a CFL and is regular then is a CFL.
Proof sketch of (2):
While reading the input, the finite control of the PDA for simulates the DFA for .

Note 1: If and are CFLs then may not be a CFL (will show today).
Therefore the class of CFLs is not closed under .
Note 2: The class of CFLs is closed under (see Pset 2).

2
Proving languages not Context Free
Let . We will show that isn’t a CFL.

Pumping Lemma for CFLs: For every CFL , there is a such


that if and then where
1) for all
2) ≥𝑝
3) 𝑢𝑣𝑥 𝑦 𝑧
𝑠=¿
Informally: All long strings in are pumpable and stay in .
𝑢 𝑣𝑣 𝑥 𝑦 𝑦 𝑧
≤𝑝

3
Pumping Lemma – Proof
Pumping Lemma for CFLs: For every CFL , there is a
such that if and then where
1) for all
2)
3) E

Proof by picture: E R
E
R
𝑢
𝑣 R
𝑦 𝑧
R
R 𝑥
𝑣 𝑥 𝑦 𝑢 𝑧
R Generates Generates

𝑠=¿ 𝑦 𝑧
𝑢 𝑣 𝑥 Long “cutting and pasting” argument
tall parse tree

4
Pumping Lemma – Proof details
For where , we have where:
1) for all …cutting and pasting
2) …start with the smallest parse tree for
3) …pick the lowest repetition of a variable

Let the length of the longest right hand side of a rule (E E+T)
the max branching of the parse tree E
E
Let the height of the parse tree for . E+T
A tree of height and max branching has at most leaves. want
So . R
Let where # variables in the grammar.
So if then and so . R

Thus at least variables occur in the longest path. 𝑠=¿ 𝑢 𝑣 𝑥 𝑦 𝑧


So some variable must repeat on a path.
use
5 set
Example 1 of Proving Non-CF
Pumping Lemma for CFLs: For every CFL , there is a
such that if and then where
1) for all
2)
3)

Let
Show: is not a CFL
Proof by Contradiction:
Check-in
Assume (to 5.1
get a contradiction) that is a CFL .
LetCFL(equal
The pumping #s oflemma
0s andgives
1s) as above. Let . 𝑠=¿00 ⋯ 0011⋯ 1122⋯ 22
Let (equal #s of 1s that
and can
2s) divide satisfying the 3 conditions.
Pumping lemma says 𝑢 𝑣𝑥𝑦 𝑧
Observe 3that
Condition () PDAs
impliescan recognize
that and . What
cannot contain bothcan we now
0s and 2s. conclude? ≤𝑝
Soa) has
Theunequal
class ofnumbers
CFLs is not
of closed
0s, 1s, under
and 2s.intersection.
b) ,The
Thus Pumping
violating Lemma1.shows
Condition that is not a CFL .
Contradiction!
c) The class
Therefore of CFLs is closed
our assumption under
( is a CFL) is complement.
false. We conclude that is not a CFL .

6 Check-in 5.1
Example 2 of Proving Non-CF
Pumping Lemma for CFLs: For every CFL , there is a
such that if and then where
1) for all
2)
3)

Let .
Show: is not a CFL.
𝑠1=¿
000 ⋯ 001000 ⋯ 001
Assume (for contradiction) that is a CFL.
The CFL pumping lemma gives as above. Need to choose . Which ? 𝑢 𝑣𝑥𝑦 𝑧
Try . But can be pumped and stay inside . Bad choice of .
Try . 𝑠2 =¿
0 ⋯ 01 ⋯ 10 ⋯ 01⋯ 1
Show cannot be pumped satisfying the 3 conditions. 𝑢 𝑣𝑥𝑦 𝑧
Condition 3 implies that does not overlap two runs of 0s or two runs of 1s.
Therefore, in , two runs of 0s or two runs of 1s have unequal length.
So violating Condition 1. Contradiction! Thus is not a CFL.
7
Turing Machines (TMs)
head
a b a b b ˽ ˽ ...
Finite
control read/write input tape

1) Head can read and write


2) Head is two way (can move left or right)
3) Tape is infinite (to the right)
4) Infinitely many blanks “˽“ follow input
5) Can accept or reject any time (not only at end of input)

8
TM – example
TM recognizing
1) Scan right until ˽ while checking if input is in , reject if not.
head
2) Return head to left end. input tape
3) Scan right, crossing off single a, b, and c. a a a b b b c c c ˽ ˽
Finite
4) If the last one of each symbol, accept. control
5) If the last one of some symbol but not others, reject.
6) If all symbols remain, return to left end and repeat from (3). accept

Check-in 5.2
How do we get the effect of “crossing off” with a Turing machine?
a) We add that feature to the model.
b) We use a tape alphabet , , , , , , ˽ }.
c) All Turing machines come with an eraser.

9 Check-in 5.2
TM – Formal Definition
Defn: A Turing Machine (TM) is a 7-tuple
input alphabet
tape alphabet ()
{L, R} (L = Left, R = Right)
R

On input a TM may halt (enter or )


Check-in 5.3
or may run forever (“loop”).
This Turing machine model is deterministic.
So has 3 possible outcomes for each input : How would we change it to be nondeterministic?
1. Accept (enter ) a) Add a second transition function.
2. Reject by halting (enter ) b) Change to be {L, R}
3. Reject by looping (running forever) c) Change the tape alphabet to be infinite.

10 Check-in 5.3
TM Recognizers and Deciders
Let be a TM. Then accepts .
Say that recognizes if .
Defn: is Turing-recognizable if for some TM .

Defn: TM is a decider if halts on all inputs. T-recognizable

Say that decides if and is a decider.


Defn: is Turing-decidable if for some TM decider . T-decidable

CFLs

regular

11
Quick review of today

1. Proved the CFL Pumping Lemma


as a tool for showing that
languages are not context free.
2. Defi ned Turing machines (TMs).
3. Defi ned TM deciders (halt on all
inputs).
4. T-recognizable and T-decidable
languages.

12

You might also like