FINITESTATEAUTOMATA
States
• AnFSAhasafinitesetofstates
– Asystemhasalimitednumberofconfigurations
• Examples
–
–
–
–
{On,Off},
{1,2,3,4,…,k}
{TVchannels}
…
• Statescanbegraphicallyrepresentedasfollows:
On
Off
Input
• AnFSAisdefinedoveranalphabet
• Thesymbolsofthealphabetrepresenttheinputof
thesystem
• Examples
– {switch_on,switch_off}
– {incoming==0,0<incoming<=10,incoming>10}
Transitionsamongstates
• Whenaninputisreceived,thesystem
changesitsstate
• Thepassagebetweenstatesisperformed
throughtransitions
• Atransitionisgraphicallyrepresentedby
arrows:
On
Off
Simpleexamples(flip-flop)
T
On
Off
T
S
R
R
On
Off
S
FSA
• FSAsarethesimplestmodelofcomputation
• Manyusefuldevicescanbemodeledusing
FSAs
…buttheyhavesomelimitations
Formally
• AnFSAisatriple<Q,A,δ>,where
– Qisafinitesetofstates
– Aistheinputalphabet
– δ isatransitionfunction(thatcanbepartial),
givenby δ:Q× A→ Q
• Remark
ifthefunctionispartial,thennotallthe
transitionsfromallthepossiblestatesforallthe
possibleelementsofthealphabetaredefined
PartialvsTotalTransitionFunction
switch_off
switch_off
switch_on
On
Off
switch_on
An FSA with a total transition function is called
complete
Recognizinglanguages
• InordertobeabletouseFSAsforrecognizing
languages,itisimportanttoidentify:
– theinitialconditionsofthesystem
– thefinaladmissiblestates
• Example:
– Thelightshouldbeoffatthebeginningandattheend
Elements
• Theelementsofthemodelare
– States
– Transitions
– Input
andalso
– Initialstate(s)
– Finalstate(s)
Graphicalrepresentation
• Initialstate
Off
• Finalstate
Off
Formally
• AnFSAisatuple<Q,A,δ ,q0,F>,where
– Qisafinitesetofstates
– Aistheinputalphabet
– δ isa(partial)transitionfunction,givenby
δ:Q× A→ Q
– q0∈Qiscalledinitialstate
– F⊆Qisthesetoffinalstates
Movesequence
• Amovesequence startsfromaninitialstate
andisaccepting ifitreachesoneofthefinal
states
switch_off
switch_on
switch_off
Off
On
switch_on
Formally
• Movesequence:
– δ∗:Q× A∗ → Q
• δ∗ isinductivelydefinedfrom δ
– δ∗(q,ε)=q
– δ∗(q,yi)=δ(δ∗(q,y),i)
• Initialstate:q0 ∈ Q
• Final(oraccepting)states:F⊆ Q
• ∀x(x∈ L↔ δ∗ (q0,x)∈ F)
Apracticalexample
• RecognizingPascalidentifiers
<letter>
<letter>
q0
q1
<digit>
qE
<digit>
<digit>
<letter>
FINITESTATETRANSDUCERS
Automataaslanguagetranslators
Input tape
Control device
(finite state)
Output tape
AfinitestatetransducerisanFSAthatworksontwotapes.
→itisakindof``translatingmachine''.
Theidea
• y=τ(x)
– x:inputstring
– y:output
– τ:functionfromL1 toL2
• Examples:
– τ1 theoccurrencesof“1”aredoubled(1-->11)
– τ2 ‘a’isswappedwith‘b’(a<--->b):
• butalso
– Compressionoffiles
– Compilingfromhighlevellanguagesintoobjectlanguages
– TranslationfromEnglishtoItalian
Informally
• Transitionswithoutput
i/w
q
q’
• Example:τ halvesthenumberof“0”sand
doublesthenumberof“1”s
1/11
0/ε
q0
1/11
q1
0/0
Formally
• Afinitestatetransducer(FST)isatuple
T=<Q,I,δ,q0,F,O,η>
– <Q,I,δ,q0,F>:justlikeacceptors
– O:outputalphabet
– η :Q× I→ O*
• Remark:theconditionforacceptanceremains
thesameasinacceptors
– Thetranslationisperformedonlyonaccepted
strings
Translatingastring
• Aswedidforδ,wedefineη*inductively
– η*(q,ε)=ε
– η∗(q,y.i)=η∗(q,y).η(δ∗ (q,y),i)
• Remarkη*:Q× I* → O*
∀x(τ(x)=η∗(q0,x)iff δ∗ (q0,x)∈ F)
PUMPINGLEMMA
Cycles
Thereisacycle:q1----aabab--->q1
q0
b
q1
b
q5
a
b
a
q9
q2
a
b
q4
a
q3
q8
b
a
q6
b
q7
If one goes through the cycle once, then one
can also go through it 2,3, …, n times
Moreformally
• Ifx∈ L and|x|≥ |Q|,thenthereexistsaq∈
Qandaw∈ I+ suchthat:
– x=ywz
– δ∗ (q,w)=q
• Thereforethefollowingalsoholds:
– ∀n≥0 ywnz ∈ L
ThisisthePumpingLemma (onecan“pump”w)
Consequencesofpumpinglemma
• L=∅?
∃x∈ L↔∃y∈ L|y|<|Q|:
Just“removeallcycles”from
theFSAacceptingx
• |L|=∞?
Checkbyasimilarargumentwhether
∃x∈ L|Q|<=|x|<2|Q|
• Notethatingeneral knowinghowtoanswerthe
question“x∈ L?”foragenericx,doesnot entail
knowinghowtoanswertheotherquestions
– ItworksforFSAs,but…
Impactinpractice
• Areweinterestedinaprogramminglanguage
consistingof…0correctprograms?
• Areweinterestedinaprogramminglanguage
inwhichonecanonlywriteafinitenumberof
programs?
• ...
Anegativeconsequenceof
pumpinglemma
•
•
•
•
IsthelanguageL={anbn |n>0}recognizedbysomeFSA?
Letussupposeitis.Then:
Considerx=ambm,m>|Q|andletusapplyP.L.
Possiblecases:
– x=ywz,w=ak ,k>0====>am+r⋅kbm ∈ L,∀r:NO
– x=ywz,w=bk ,k>0====>same
– x=ywz,w=ak bs ,k,s>0====>am-kakbs akbsbm-s
∈ L:NO
Intuitively
• Inorderto“count”anarbitraryn weneedaninfinite
memory!
• Rigorouslyspeaking,everycomputerisanFSA,but…itisthe
wrongabstraction:intractablenumberofstates!
(samethingasstudyingeverysinglemoleculeintheflightofanairplane)
• Importanceofanabstractnotionofinfinity
• Fromthetoyexample{anbn}tomoreconcretecases:
– Checkingwell-balancingofbrackets(typicallyusedinprogramming
languages)cannotbedonewithfinitememory
• Wethereforeneedmorepowerfulmodels
OPERATIONS ONFSA
Closureinmath
• AsetSisclosed w.r.t.anoperationOPif,when
operationOPisappliedtoelementsofS,theresultis
stillanelementofS
• Examples:
– Naturalnumbersareclosedw.r.t.sum(butnot
subtraction)
– Integersareclosedw.r.t.sum,subtraction,multiplication
(butnotdivision)
– Rationals…
– Reals…
– …
Closureforlanguages
• L ={Li}:family oflanguages
• L isclosedw.r.t.operationOPifandonlyif,
foreveryL1,L2 ∈ L ,L1OPL2 ∈ L .
• R:regularlanguages(recognizedbyFSAs)
• R isclosedw.r.t.set-theoreticoperations,
concatenation, “*”,…
Intersection
The“parallelrun”ofAandBcanbesimulated
by“couplingthem”
A
B
q0
p0
<A,B> q0 p0
b
b
b
q1
p1
q1 p1
a
a
a
q2
p2
q2 p2
a
a
a
q9
p9
q9 p9
Example
A1 :
a
A2 :
q0
∩
q1
p0
a
a
q0 p0
q1 p0
a
33
a
Formally
• Given
– A1 =<Q1,I,δ1,q01,F1>
– A2 =<Q2,I,δ2,q02,F2>
<A1,A2 >=<Q1×Q2,I,δ,<q01,q02>,F1×F2>
– δ(<q1,q2>,i)=<δ1(q1,i),δ2(q2,i)>
• Onecanshow(bysimpleinduction)that
L(<A1,A2>)=L(A1)∩L(A2 )
• Canwedothesameforunion?
Union
• Theunionisbuiltanalogously
• Given
– A1 =<Q1,I,δ1,q01,F1>
– A2 =<Q2,I,δ2,q02,F2>
<A1,A2>=<Q1xQ2,I,δ,<q01,q02>,F1xQ2UQ1xF2>
– δ(<q1,q2>,i)=<δ1(q1,i),δ2(q2,i)>
Complement(1)
• BasicideaFc =Q-F
0
0
1
q0
q1
1
…butingeneralthetransitionfunctionis
partial!
Complement(2)
• Beforeswappingfinalandnonfinalstatesitis
necessarytocompletetheFSA
0
0
0
0
1
1
q0
q0
q1
q1
1
qE
0
0
1
q0
0,1
q1
qE
1
0,1
Unionagain
• Another possibility is tousecomplement and
DeMorgan’s laws:
A∪ B=¬(¬A∩¬B)
Philosophyofcomplement
• IfIscantheentireinputstring,thenitsuffices
to“swapyesandno”(FwithQ-F)
• IfIcannotreachtheendofthestring,then
swappingFwithQ-Fdoesnotwork
• InthecaseofFSAsthereisaneasy
workaround(completingtheFSA)
• Ingeneralwecannotconsiderthenegative
answertoaquestionasequivalenttothe
positiveanswertotheoppositequestion!
© Copyright 2026 Paperzz