Theory of Computation
Pumping Lemma for Regular Languages, Proof
by Contradiction, Pumping Lemma Examples,
Context-Free Gr...
Outline
●
Pumping Lemma for Regular Languages
●
Proof by Contradiction
●
Pumping Lemma Examples
●
Context-Free Grammars
●
...
Pumping Lemma
for
Regular Languages
Review: Processing State Sequence
q0 q1
1
0
A processing state sequence is a sequence of states that an FA uses (enters
an...
Review: Pumping Lemma
( )
.0for,and1where
,can writeThen we.andLet
states.DFA withaiswhere,Let
≥∈≤
=≥∈
=
iLwuvv
uvwxnxLx
n...
Review: Pictorial Insight
q0 q’q
M
u
v
w
nxuvwx ≥= ,
Pumping Lemma Use
&
Proof by Contradition
Pumping Lemma Use
●
Pumping Lemma is not used to prove that languages are
regular
●
Pumping Lemma states that if a languag...
Proof by Contradiction
●
Pumping Lemma applications are examples of a proof
technique known as proof by contradiction
●
Pr...
Proof by Contradiction
●
Why does proof by contradiction works?
●
It works because the statement IF A THEN B is true in al...
Three Questions about Proof by Contradiction
●
What contradictions can/should we look for?
– Experience, intuition, and in...
Proof by Contradiction: Example
If r is a real number such that r2
= 2,
then r is not rational (irrational)
Proof by Contradiction: Example
A: r is a real number such that r2
= 2
B: r is not rational (irrational)
Proof by Contradiction: Example
Assume A and NOT B:
A: r is a real number such that r2
= 2
NOT B: r is rational
Now we hav...
Proof by Contradiction: Example
If r is rational (remember that NOT B is
assumed to be true), then r = p/q, q != 0
Proof by Contradiction: Example
We can assume that p and q have no
common divisors (aka mutually prime);
if they had, they...
Proof by Contradiction: Example
●
Since r = p/q, r2
= (p/q)2
●
Since r2
= 2, then 2 = (p/q)2
●
Since 2 = (p/q)2
, 2q2
= p2...
Proof by Contradiction: Example
●
Since p is even, p = 2k, where k is an integer
●
Since 2q2
= p2
, 2q2
= (2k)2
= 4k2
●
Si...
Pumping Lemma Examples
Pumping Lemma Example: Proof 1
{ }
regular.notisHence,s.'ofnumberthe
angreater thstrictlyisyins'ofnumberthebecause,
,Since...
Pumping Lemma Example: Proof 2
{ }
ion.contradictaachievewecases,3theofeachIn.
Thus,.,,If.Thus,s.'
follows'wherestringais,...
Main Implication of the Pumping Lemma
There are languages that are not regular, i.e., languages
for which it is impossible...
Pumping Lemma & Finite Languages
●
Any finite language is regular
●
We can construct a finite automaton for each
individua...
Pumping Lemma & Finite Languages
●
Does the Pumping Lemma contradict the regularity of finite
languages?
●
No, because for...
Context-Free Grammars
Context-Free Grammar (CFG): Definition
( )
.
overstringaisandwhere,formtheof
isproductioneachs;productionofsetfiniteais
sy...
Example 01
{ }
.fromderivedisthatshow,oninduction
By.|:CFGfollowingheConsider t:Proof
free.-contextisLthatShow.0Let:Claim
...
Example 02
{ }
.fromderivedisthatshow,oninduction
By.|:CFGfollowingheConsider t:Proof
free.-contextisthatShow.0|Let:Claim
...
Example 03
{ }
{ } { }
ε
ε
εε
|
|
:LforGCFGaconstructcan
weNow.|:forCFGabeLet.|:for
CFGabeLet.thatObservefree.-contextarea...
Example 04
.andof
rulestheto|addingbyforCFGaconstructcan
Then wely.respective,andofsymbolsstartingtwothebe
andLetly.respec...
Example 05
{ }{ }
( ) .,oflengthon theinductionbyThen,
|
|
:CFGfollowingthebeLet:Proof
.,12|,:Claim
*
LGLz
baX
XXXSS
G
Nkk...
Example 06
{ }{ }
( ) .Then
.||
:CFGfollowingthebeLet:Proof
.|,:Claim
*
LGL
bSbaSaS
G
xxzbazL R
=
→
=∈=
ε
Backus-Naur Notation
Backus-Naur Notation (BNN)
●
BNN is frequently used in R&D on compilers
and programming languages
●
BNN is a CFG specifica...
BNN Example
( ) cba |||exp
|expexp
|expexp
|expexp
|exp*exp
|expexp::exp
<
=
+
−=
Two Derivations of Expression a-b*c
<exp>
<exp> * <exp>
<exp> <exp>-
a b c
<exp>
<exp> - <exp>
<exp> * <exp>
a b c
References & Reading Suggestions
●
Davis, Weyuker, Sigal. Computability, Complexity, and
Languages, 2nd
Edition, Academic ...
Upcoming SlideShare
Loading in …5
×

Theory of Computation: Pumping Lemma for Regular Languages, Proof by Contradiction, Pumping Lemma Examples, Context-Free Grammars, Backus-Naur Notation

1,076 views
952 views

Published on

Pumping Lemma for Regular Languages, Proof by Contradiction, Pumping Lemma Examples, Context-Free Grammars, Backus-Naur Notation

Published in: Science, Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,076
On SlideShare
0
From Embeds
0
Number of Embeds
169
Actions
Shares
0
Downloads
0
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Theory of Computation: Pumping Lemma for Regular Languages, Proof by Contradiction, Pumping Lemma Examples, Context-Free Grammars, Backus-Naur Notation

  1. 1. Theory of Computation Pumping Lemma for Regular Languages, Proof by Contradiction, Pumping Lemma Examples, Context-Free Grammars, Backus-Naur Notation Vladimir Kulyukin
  2. 2. Outline ● Pumping Lemma for Regular Languages ● Proof by Contradiction ● Pumping Lemma Examples ● Context-Free Grammars ● Backus-Naur Notation
  3. 3. Pumping Lemma for Regular Languages
  4. 4. Review: Processing State Sequence q0 q1 1 0 A processing state sequence is a sequence of states that an FA uses (enters and leaves or just enters in the case of final states) to process a given input. Let x = 001. Then the processing path of the above FA is q0, q0, q0, q1: from q0 to q0 on the first 0, on to q0 on the second 0, and on to q1 on 1. q0 q0 q0 q1 0 0 1
  5. 5. Review: Pumping Lemma ( ) .0for,and1where ,can writeThen we.andLet states.DFA withaiswhere,Let ≥∈≤ =≥∈ = iLwuvv uvwxnxLx nMMLL i
  6. 6. Review: Pictorial Insight q0 q’q M u v w nxuvwx ≥= ,
  7. 7. Pumping Lemma Use & Proof by Contradition
  8. 8. Pumping Lemma Use ● Pumping Lemma is not used to prove that languages are regular ● Pumping Lemma states that if a language is regular, then its strings have a specific property (pumping property) ● Pumping Lemma is used to show that languages are not regular: assume that a language is regular and then show that a specific string does not satisfy the pumping property
  9. 9. Proof by Contradiction ● Pumping Lemma applications are examples of a proof technique known as proof by contradiction ● Proof by contradiction is used to prove statements of the form IF A THEN B ● A typical use of this technique consists of two steps: – Assume that A is true and B is false – Find a contradiction, i.e., a statement that contradicts another statement known to be true; that statement can be A itself, which is assumed to be true
  10. 10. Proof by Contradiction ● Why does proof by contradiction works? ● It works because the statement IF A THEN B is true in all cases except when A is true and B is false ● Proof by contradiction allows us to rule out that case by finding a contradiction ● It is this contradiction that proves out the original statement IF A THEN B because it excludes the only case under which this statement can be false
  11. 11. Three Questions about Proof by Contradiction ● What contradictions can/should we look for? – Experience, intuition, and insight ● How can we use the assumptions that A is true and B is false to react a contradiction? – Work forward from both assumptions and see what shakes loose ● When can/should we use proof by contradiction? – A reliable indicator is the word not in the statement B
  12. 12. Proof by Contradiction: Example If r is a real number such that r2 = 2, then r is not rational (irrational)
  13. 13. Proof by Contradiction: Example A: r is a real number such that r2 = 2 B: r is not rational (irrational)
  14. 14. Proof by Contradiction: Example Assume A and NOT B: A: r is a real number such that r2 = 2 NOT B: r is rational Now we have to find a contradiction
  15. 15. Proof by Contradiction: Example If r is rational (remember that NOT B is assumed to be true), then r = p/q, q != 0
  16. 16. Proof by Contradiction: Example We can assume that p and q have no common divisors (aka mutually prime); if they had, they could be divided out
  17. 17. Proof by Contradiction: Example ● Since r = p/q, r2 = (p/q)2 ● Since r2 = 2, then 2 = (p/q)2 ● Since 2 = (p/q)2 , 2q2 = p2 ● Since p2 = 2q2 , p2 is even ● Since p2 is even, p is even
  18. 18. Proof by Contradiction: Example ● Since p is even, p = 2k, where k is an integer ● Since 2q2 = p2 , 2q2 = (2k)2 = 4k2 ● Since 2q2 = (2k)2 = 4k2 , q2 = 2k2 ● Since q2 = 2k2 , then q is even ● But then, since both p and q are even, they have at least one common divisor ● We found a contradiction because p and q were assumed to have no common divisors
  19. 19. Pumping Lemma Examples
  20. 20. Pumping Lemma Example: Proof 1 { } regular.notisHence,s.'ofnumberthe angreater thstrictlyisyins'ofnumberthebecause, ,Since.Consider.forchoice onlytheisThus,states.1ofsequenceprocessinga needsstatesDFA withthe,processTo.1, Lemma,PumpingBy the.||,Then.Let Lemma.PumpingtheofconstantthebeLet:2Proof regular.notis|:Claim 2 Lb aLy avuvvwwuvyv avn navuvwz nzLzbaz n NkbaL n nn kk ∉ === =+ ≤= ≥∈= ∈= + +
  21. 21. Pumping Lemma Example: Proof 2 { } ion.contradictaachievewecases,3theofeachIn. Thus,.,,If.Thus,s.' follows'wherestringais,If. Thus,.,,If.; ;:forchoices3areThere.0, Then.1,Then.||,Let Lemma.PumpingtheofconstantthebeLet:1Proof regular.notis|:Claim 0 02 20 0 Lwuv kmbawuvbvLwuvb awuvbavLwuv mkbawuvavbvbav avvmbaz vuvwznzLz n NkbaL km mk mm kk ∉ >==∉ =∉ <==== =>= ≤=≥∈ ∈= + ++ ++++ +
  22. 22. Main Implication of the Pumping Lemma There are languages that are not regular, i.e., languages for which it is impossible to construct DFAs, NFAs or regular expressions
  23. 23. Pumping Lemma & Finite Languages ● Any finite language is regular ● We can construct a finite automaton for each individual string (that automaton will accept that string and only that string) ● The individual automata can then be compiled into one union automaton that accepts all strings in that language
  24. 24. Pumping Lemma & Finite Languages ● Does the Pumping Lemma contradict the regularity of finite languages? ● No, because for any finite language we can find the length of the longest string (say n) ● The Pumping Lemma's statement is vacuously true for all strings whose length is greater than n, because there are no such strings in the language ● So we do not get any contradiction out of the Pumping Lemma for finite languages
  25. 25. Context-Free Grammars
  26. 26. Context-Free Grammar (CFG): Definition ( ) . overstringaisandwhere,formtheof isproductioneachs;productionofsetfiniteais symbol;starttheis alphabet;terminaltheis alphabet;lnonterminatheis where,,,,tuple-4aisCFGA VΣ yVXyX P VS Σ V PSVGG ∪ ∈→ ∈ Σ=
  27. 27. Example 01 { } .fromderivedisthatshow,oninduction By.|:CFGfollowingheConsider t:Proof free.-contextisLthatShow.0Let:Claim Sban aSbS |nbaL nn nn ε→ ≥=
  28. 28. Example 02 { } .fromderivedisthatshow,oninduction By.|:CFGfollowingheConsider t:Proof free.-contextisthatShow.0|Let:Claim 3 3 Sban aSbbbS LnbaL nn nn ε→ ≥=
  29. 29. Example 03 { } { } { } ε ε εε | | :LforGCFGaconstructcan weNow.|:forCFGabeLet.|:for CFGabeLet.thatObservefree.-contextareandboth 01,ExampleBy.0|and0|Let:Proof .free-contextis0,0|Let:Claim 22 11 21 2222111 12121 21 dcSS baSS SSS dcSSLGbaSSL GLLLLL mdcLnbaL mndcbaL mmnn mmnn → → → →→ = ≥=≥= ≥≥=
  30. 30. Example 04 .andof rulestheto|addingbyforCFGaconstructcan Then wely.respective,andofsymbolsstartingtwothebe andLetly.respective,andforandgrammars free-contextexist twotherefree,-contextareandSince:Proof free.-contextisThen .Letlanguages.free-contextbeandLet:Claim 21 21 21 212121 21 2121 GG SSSLG GG SSLLGG LL L LLLLL → ∪=
  31. 31. Example 05 { }{ } ( ) .,oflengthon theinductionbyThen, | | :CFGfollowingthebeLet:Proof .,12|,:Claim * LGLz baX XXXSS G NkkzbazL = → → ∈+=∈=
  32. 32. Example 06 { }{ } ( ) .Then .|| :CFGfollowingthebeLet:Proof .|,:Claim * LGL bSbaSaS G xxzbazL R = → =∈= ε
  33. 33. Backus-Naur Notation
  34. 34. Backus-Naur Notation (BNN) ● BNN is frequently used in R&D on compilers and programming languages ● BNN is a CFG specification language ● The main difference is that BNN uses ::= instead of  and puts non-terminals inside <>
  35. 35. BNN Example ( ) cba |||exp |expexp |expexp |expexp |exp*exp |expexp::exp < = + −=
  36. 36. Two Derivations of Expression a-b*c <exp> <exp> * <exp> <exp> <exp>- a b c <exp> <exp> - <exp> <exp> * <exp> a b c
  37. 37. References & Reading Suggestions ● Davis, Weyuker, Sigal. Computability, Complexity, and Languages, 2nd Edition, Academic Press ● Brooks Webber. Formal Language: A Practical Introduction, Franklin, Beedle & Associates, Inc ● Hopcroft and Ullman. Introduction to Automata Theory, Languages, and Computation, Narosa Publishing House ● D. Solow. How to Read & Do Proofs, Wiley & Sons

×