Deterministic Finite-Stte Automt Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 12 August 2013
Outline 1 Introduction 2
Exmple DFA 1 DFA for Odd number of s b b How DFA works.
Exmple DFA 1 DFA for Odd number of s b b e o How DFA works. Ech stte represents property of the input string red so fr: Stte e: Number of s seen is even. Stte o: Number of s seen is odd.
Exmple DFA 2 DFA for Contins the substring bb b, b b b Ech stte represents property of the input string red so fr:
Exmple DFA 2 DFA for Contins the substring bb b b b, b ɛ b bb Ech stte represents property of the input string red so fr: Stte ɛ: Not seen bb nd no suffix in or b. Stte : Not seen bb nd hs suffix. Stte b: Not seen bb nd hs suffix b. Stte bb: Seen bb.
Exmple DFA 3 Accept strings over {0, 1} which stisfy even prity in length 4 blocks. Accept 0101 1010 Reject 0101 1011 DFA for Even prity checker 0 1, e 0 2, e 0 3, e 0, e 0 1 1 1 1 1 1 0 0, o 0, 1 1, o 0 2, o 0 3, o 1
Exmple DFA 4 Accept strings over {, b, /, } which don t end inside C-style comment. Scn from left to right till first /* is encountered; from there to next */ is first comment; nd so on. Accept b/ /bb nd b/ / /bb /. Reject b/ nd b/ / /bb/.
Exmple DFA 4 Accept strings over {, b, /, } which don t end inside C-style comment. Scn from left to right till first /* is encountered; from there to next */ is first comment; nd so on. Accept b/ /bb nd b/ / /bb /. Reject b/ nd b/ / /bb/. DFA for C-comment trcker /, /, / / out pbc in pec
Definitions nd nottion An lphbet is finite set of set of symbols or letters. Eg. A = {, b, c}, Σ = {0, 1}. A string or word over n lphbet A is finite sequence of letters from A. Eg. b is string over {, b, c}. Empty string denoted by ɛ. Set of ll strings over A denoted by A. Wht is the size or crdinlity of A?
Definitions nd nottion An lphbet is finite set of set of symbols or letters. Eg. A = {, b, c}, Σ = {0, 1}. A string or word over n lphbet A is finite sequence of letters from A. Eg. b is string over {, b, c}. Empty string denoted by ɛ. Set of ll strings over A denoted by A. Wht is the size or crdinlity of A? Infinite but Countble: Cn enumerte in lexicogrphic order:. ɛ,, b, c,, b,...
Definitions nd nottion An lphbet is finite set of set of symbols or letters. Eg. A = {, b, c}, Σ = {0, 1}. A string or word over n lphbet A is finite sequence of letters from A. Eg. b is string over {, b, c}. Empty string denoted by ɛ. Set of ll strings over A denoted by A. Wht is the size or crdinlity of A? Infinite but Countble: Cn enumerte in lexicogrphic order: ɛ,, b, c,, b,.... Opertion of conctention on words: String u followed by string v: written u v or simply uv. Eg. bb = bb.
Definitions nd nottion: Lnguges A lnguge over n lphbet A is set of strings over A. Eg. for A = {, b, c}: L = {bc, b}. L 1 = {ɛ, b,, bb, b, b, b, bbb,...}. L 2 = {}. L 3 = {ɛ}. How mny lnguges re there over given lphbet A?
Definitions nd nottion: Lnguges A lnguge over n lphbet A is set of strings over A. Eg. for A = {, b, c}: L = {bc, b}. L 1 = {ɛ, b,, bb, b, b, b, bbb,...}. L 2 = {}. L 3 = {ɛ}. How mny lnguges re there over given lphbet A? Uncountbly infinite Use digonliztion rgument: ɛ b b b bb b b bb bbb L 0 0 1 0 0 0 1 1 0 0 0 0 0 L 1 0 0 0 0 0 0 0 0 0 0 0 0 L 2 1 1 0 1 0 1 1 0 0 1 0 1 L 3 0 0 0 0 0 0 0 0 0 0 0 0 L 4 0 1 0 0 0 1 1 0 0 0 0 0 L 5 1 1 0 1 0 1 1 0 0 1 0 1 L 6 0 1 0 0 0 1 1 0 0 0 0 0 L 7 0 0 0 0 0 0 1 0 0 0 1 0.
Definitions nd nottion: Lnguges Conctention of lnguges: L 1 L 2 = {u v u L 1, v L 2 }. Eg. {bc, b} {ɛ,, bb} = {bc, b, bc, b, bcbb, bbb}.
Definitions nd nottion: DFA A Deterministic Finite-Stte Automton A over n lphbet A is structure of the form (Q, s, δ, F ) where Q is finite set of sttes s Q is the strt stte δ : Q A Q is the trnsition function. F Q is the set of finl sttes.
Definitions nd nottion: DFA A Deterministic Finite-Stte Automton A over n lphbet A is structure of the form (Q, s, δ, F ) where Q is finite set of sttes s Q is the strt stte δ : Q A Q is the trnsition function. F Q is the set of finl sttes. Exmple of Odd s DFA: Here: Q = {e, o}, s = e, F = {o}, nd δ is given by: δ(e, ) = o, δ(e, b) = e, δ(o, ) = e, δ(o, b) = o. b e b o
Definitions nd nottion: Lnguge ccepted by DFA δ tells us how the DFA A behves on given word u. Define δ : Q A Q s δ(q, ɛ) = q δ(q, w ) = δ( δ(q, w), ). Lnguge ccepted by A, denoted L(A), is defined s: L(A) = {w A δ(s, w) F }. Eg. For A = DFA for Odd s, L(A) = {, b, b,, bb, bb, bb,...}.
Regulr Lnguges A lnguge L A is clled regulr if there is DFA A over A such tht L(A) = L. Exmples of regulr lnguges: Odd s, strings tht don t end inside C-style comment, {}, ny finite lnguge. All lnguges over A Regulr Are there non-regulr lnguges?
Regulr Lnguges A lnguge L A is clled regulr if there is DFA A over A such tht L(A) = L. Exmples of regulr lnguges: Odd s, strings tht don t end inside C-style comment, {}, ny finite lnguge. All lnguges over A Regulr Are there non-regulr lnguges? Yes, uncountbly mny, since Reg is only countble while clss of ll lnguges is uncountble.