Lecture # 1-2-3
-
Upload
fakhar1981 -
Category
Documents
-
view
218 -
download
0
Transcript of Lecture # 1-2-3
-
7/26/2019 Lecture # 1-2-3
1/36
Theory of
ComputationLecture # 1-2-3
-
7/26/2019 Lecture # 1-2-3
2/36
BookIntroduction to Theory of Computation by Anil
Maheshwari Michiel Smid, 2014
Introduction to computer theory by Daniel I.A. Cohen Second
Edition
Introduction to the Theory of Computation
second!third edition"by Michael Sipser
Introduction to Languages and Theory of Computation by !. C.
"artin "c#ra$ %ill &oo' Co. ())* Second Edition
-
7/26/2019 Lecture # 1-2-3
3/36
Main contentsRE
NFA
FA!F"
A
NS
$M%$he !hurch-$urin& $hesis '
eci(able an( )n(eci(able Lan&ua&es
N !o*pleteness !o*ple+ity $heory
Re(ucibility , ntractability
-
7/26/2019 Lecture # 1-2-3
4/36
Lan&ua&eNatural Lan&ua&esEn&lish. !hinese. French. )r(u etc
ro&ra**in& Lan&ua&esBasic. Fortran. !. !//. 0aa etc
Mathe*atics
State (ia&ra*
etc
-
7/26/2019 Lecture # 1-2-3
5/36
!o*ponents o Lan&ua&eAlphabetsBasic ele*ents
Set o letters or characters
Rules"ra**ar$ells you that or(s belon&s to a lan&ua&e
Synta+
Meanin&Se*antics
-
7/26/2019 Lecture # 1-2-3
6/36
e4nitionLan&ua&eSet o strin&s o characters ro* the alphabets
5or(A set o characters belon&s to the lan&ua&e
-
7/26/2019 Lecture # 1-2-3
7/36
En&lish 5or(sAlphabetsa b c667 A B ! 6689 punctuation *arks.
blank space etc
5or(sAll or(s in stan(ar( (ictionary
5hat is on the e+a*$he :uick bron o+ ;u*pe( oer the la7y (o&
E8& conte+t-ree. re&ular66
-
7/26/2019 Lecture # 1-2-3
8/36
!-Lan&ua&eAlphabetsAS! characters
5or(sro&ra*s
#inclu(e
-
7/26/2019 Lecture # 1-2-3
9/36
!onentions
-
7/26/2019 Lecture # 1-2-3
10/36
5hat (oes $heory o auto*ata
*eanD$he or( ?$heory *eans that this sub;ect is
a *ore *athe*atical sub;ect an( lesspractical8
Auto*ata is the plural o the or( Auto*atonhich *eans ?sel-actin&
n &eneral. this sub;ect ocuses on thetheoretical aspects o co*puter science8
-
7/26/2019 Lecture # 1-2-3
11/36
Theory of Automata
Applications$his sub;ect plays a *a;or role in
e4nin& co*puter lan&ua&es
!o*piler !onstruction
arsin&
etc
-
7/26/2019 Lecture # 1-2-3
12/36
Types of languages$here are to types o lan&ua&esFor*al Lan&ua&es are use( as a basis or
(e4nin& co*puter lan&ua&es A pre(e4ne( set o sy*bols an( strin& For*al lan&ua&e theory stu(ies purely syntactical
aspects o a lan&ua&e %e8&8. or( abcd'
nor*al Lan&ua&es such as En&lish has *any(ierent ersions
-
7/26/2019 Lecture # 1-2-3
13/36
Basic Element of a Formal
Language Alphabetse4nitionA 4nite non-e*pty set o sy*bols %letters'. is
calle( an alphabet8 t is (enote( by "reek lettersi&*a G8
E+a*ple
GH>1.2.3CGH>I.1C JJBinary (i&its
GH>i.;.kC
-
7/26/2019 Lecture # 1-2-3
14/36
Example Computer Languages! Lan&ua&e
!//
0aa
Kb8net
!#8net
etc
-
7/26/2019 Lecture # 1-2-3
15/36
What are StringsA Strin& is or*e( by co*binin& arious sy*bols
ro* an alphabet8
E+a*ple
GH >1.IC then so*e sa*ple strin&s areI. 1. 11II11. 688
Si*ilarly. GH >a. bC then so*e sa*ple strin&sarea. b. abbbbbb. aaaabbbbb. 688
-
7/26/2019 Lecture # 1-2-3
16/36
5hat is an EM$ or N)LL Strin&A strin& ith no sy*bol is (enote( by %Small
"reek letter La*b(a' or %Capital "reekletter La*b(a' 8 t is calle( an e*pty strin&or null strin&8
lease (ont conuse it ith lo&ical operator
Oan(8
-
7/26/2019 Lecture # 1-2-3
17/36
What are Words5or(s are strin&s that belon& to so*e speci4c
lan&ua&e8
E+a*ple GH >aC then a lan&ua&e L can be (eine( as
LH>a.aa.aaa.68C here L is a set o or(s o
the lan&ua&e (e4ne by &ien set o alphabets8Also a. aa.6 are the or(s o L but not ab8
-
7/26/2019 Lecture # 1-2-3
18/36
!e"ning Alphabets #uidelines$he olloin& are three i*portant rules or (e4nin&
Alphabets or a lan&ua&e
Shoul( not contain e*pty sy*bol
Shoul( be 4nite8 $hus. the nu*ber o sy*bols are4nite
Shoul( not be a*bi&uous E+a*ple an alphabet *ay contain letters consistin&
o &roup o sy*bols or e+a*ple G1H >A. aA. bab. (C8
All startin& letters are uni:ue
-
7/26/2019 Lecture # 1-2-3
19/36
!e"ning Alphabets #uidelinesNo consi(er an alphabet
G2H >A. Aa. bab. (C an( a strin& AababA8
$his strin& can be actore( in to (ierent ays%Aa'. %bab'. %A'
%A'. %abab'. %A'
5hich shos that the secon( &roup cannot be
i(entiie( as a strin&. (eine( oer G H >a. bC8$his is (ue to a*bi&uity in the (e4ne( alphabet
G2
%Because o A an( Aa'
-
7/26/2019 Lecture # 1-2-3
20/36
Ambiguity ExamplesG1H >A. aA. bab. (C
G2H >A. Aa. bab. (C
$%is a &alidalphabet hile $'is an in(&alidalphabet8
Si*ilarly.
G1H >a. ab. acC
G2H >a. ba. caC
n this case. $% is a in&alidalphabet hile $' is a
&alid alphabet8
-
7/26/2019 Lecture # 1-2-3
21/36
Length of Stringse4nition
$he len&th o strin& s. (enote( by PsP. is thenu*ber o lettersJsy*bols in the strin&8
E+a*ple
GH>a.bC
sHaaabb
PsPHQ
-
7/26/2019 Lecture # 1-2-3
22/36
5or( Len&th E+a*pleNu*ber o or(s in a strin&
E+a*pleGH >A. aA. bab. (C
sHAaAbabA(
Factorin&H%A'. %aA'. %bab'. %A'. %('
PsPHQ
ne i*portant point to note here is that aA has alen&th 1 an( not 28
-
7/26/2019 Lecture # 1-2-3
23/36
Length of strings o&er n
alphabetsFormula) Nu*ber o strin&s o length *m+ (e4ne(
oer alphabet o *n+ lettersis nm
E+a*ples$he lan&ua&e o strin&s o length '. (e4ne( oer
GH>a.bCis LH>aa. ab. ba. bbC i#e#nu*ber o strin&s H22
$he lan&ua&e o strin&s o len&th 3. (e4ne( oerGH>a.bC is LH>aaa. aab. aba. baa. abb. bab. bba. bbbC
i#e#nu*ber o strin&s H 23
-
7/26/2019 Lecture # 1-2-3
24/36
,e&erse of a String$he reerse o a strin& s (enote( by ,e&-s. or sr. is
obtaine( by ritin& the letters o s in reerse or(er8
E+a*ple
sHabc is a strin& (eine( oer GH>a.b.cC
then Re%s' or srH cba
GH >A. aA. bab. (C
sHAaAbabA(
Re%s'H(AbabAaA
-
7/26/2019 Lecture # 1-2-3
25/36
ALNRME+,alindrome e-amples !K!. MAAM. RAAR. S$A$S. $ALLA$. R$A$R/
$he lan&ua&e consistin& o an( the strin&s s(eine( oer G such that Re%s'Hs8
t is to be (enote( that the or(s o ALNRMEare calle( palin(ro*es8
E+a*pleFor GH>a. bC
ALNRMEH> . a. b. aa. bb. aaa. aba. bab.bbb. 888C
-
7/26/2019 Lecture # 1-2-3
26/36
Een EenAll strin&s that contains een nu*ber o as
an( een nu*ber o bs
E8&
. aa. bb. aabb. abab. abba. baab etc
-
7/26/2019 Lecture # 1-2-3
27/36
Tleene Star closuret is (enote( by GUan( represent all collection
o strin&s (eine( oer G inclu(in& Null strin&8
$he lan&ua&e pro(uce( by Tleene closure isin4nite8 t contains in4nite or(s. hoeereach or( has 4nite len&th8
-
7/26/2019 Lecture # 1-2-3
28/36
Tleene Star closureExamples
G H >+C
$hen GU H >. +. ++. +++. ++++. 68C
G H >I.1C
$hen GU H >. I. 1. II. I1. 1I. 11. 68C
G H >aaB. cC
$hen GU H > .aaB. c. aaBaaB. aaBc. caaB. cc.68C
-
7/26/2019 Lecture # 1-2-3
29/36
Tleene Star closureConsider the language S/0 1here S 2 3a b45
6o1 many 1ords does this language ha&e oflength '7 of length 87 of length n7
Nu*ber o or(s H n* %n is nu*ber o sy*bols an( * is len&th'
Len&th 2 22H V
Len&th 3 23H W
Len&th n 2n
-
7/26/2019 Lecture # 1-2-3
30/36
9lus :peration5ith lus peration. co*bination o (ierent
letters are or*e(8 @oeer. Null Strin& is notpart o the &enerate( lan&ua&e8
-
7/26/2019 Lecture # 1-2-3
31/36
9lus :perationExamples
G H >+C
$hen G/
H > +. ++. +++. ++++. 68C G H >I.1C
$hen G/H > I. 1. II. I1. 1I. 11. 68C
G H >aaB. cC
$hen G/H >aaB. c. aaBaaB. aaBc. caaB. cc.68C
-
7/26/2019 Lecture # 1-2-3
32/36
e4nin& lan&ua&eFour (ierent ays. in hich a lan&ua&e can be (e4ne($here are our ays that e ill stu(y in this course
escriptie ay
Recursie ay
Re&ular E+pression
Finite Auto*ata
-
7/26/2019 Lecture # 1-2-3
33/36
escriptie ay an( its e+a*ples$he lan&ua&e an( its associate( con(itions are (e4ne( in plain
En&lish8
Example) $he lan&ua&e L o strin&s o e&en length. (eine( oer GH>bC. can
be ritten as
LH>bb. bbbb. 688C
Example) $he lan&ua&e L o strin&s that does not start 1ith a. (e4ne( oer
GH>a.b.cC. can be ritten as
LH>b. c. ba. bb. bc. ca. cb. cc. 6C
-
7/26/2019 Lecture # 1-2-3
34/36
escriptie ay an( its e+a*plesExample)$he lan&ua&e L o strings of length 8. (eine( oer GH>I.1.2C. can be
ritten as
LH>III. I12. I22.1I1. 1I1.12I.6C
Example)$he lan&ua&e L o strings ending in %. (eine( oer G H>I.1C. can be
ritten as
LH>1.II1.1I1.III1.I1I1.1II1.11I1.6C
Example)$he lan&ua&e E;a.bC. can be ritten as
LH> .ab.aabb.abab.baba.abba.6C
-
7/26/2019 Lecture # 1-2-3
35/36
escriptie ay an( its e+a*plesExample) $he lan&ua&e E>E?(E>E?. o strin&s ith een nu*ber o as
an( een nu*ber o bs. (eine( oer GH>a.bC. can be ritten as
LH>. aa. bb. aaaa. aabb.abab. abba. baab. baba. bbaa. bbbb.
6C
Example) $he lan&ua&e @?TE#E,. o strin&s (e4ne( oer
GH>-.I.1.2.3.V.Q.X.Y.W.ZC. can be ritten as
N$E"ER H >6.-2.-1.I.1.2.6C
Example) $he lan&ua&e E>E?. o stin&s (e4ne( oer
GH>-.I.1.2.3.V.Q.X.Y.W.ZC. can be ritten as
EKEN H > 6.-V.-2.I.2.V.6C
-
7/26/2019 Lecture # 1-2-3
36/36
escriptie ay an( its e+a*plesExample) $he lan&ua&e >anbnC. o strin&s (e4ne( oer
GH>a.bC. as
>an bn nH1.2.3.6C. can be ritten asLH >ab. aabb. aaabbb.aaaabbbb.6C
Example) $he lan&ua&e >anbncnC. o strin&s (e4ne( oer
GH>a.b.cC. as >anbncn nH1.2.3.6C. can be rittenas
LH >abc. aabbcc. aaabbbccc.aaaabbbbcccc.6C