Finite Automata
Total Page:16
File Type:pdf, Size:1020Kb
Finite Automata CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri A simplified model String Machine String A simplified model String Machine String Finite sequence of letters from an alphabet Σ, e.g. {0, 1} A general-purpose computer String #uring String Machine A general-purpose computer We might revisit these later String #uring String Machine A general-purpose computer String #uring String Machine Church$#uring #hesis: An% “effecti(e/mechanical/real-*orld” calculation can be carried out on a #uring machine Alan #uring, 1-12 – 1-5/ A simple &computer” Deterministic Finite String 2es/3o Automaton 0DFA1 An example 1 0 2es 3o 0 1 An example 1 0 2es 3o 0 1 05inary input) An example 1 0 2es 3o 0 1 6nput: 01001 An example 1 0 2es 3o 0 1 6nput: 01001 An example 1 0 2es 3o 0 1 6nput: 01001 An example 1 0 2es 3o 0 1 6nput: 01001 An example 1 0 2es 3o 0 1 6nput: 01001 An example 1 0 2es 3o 0 1 6nput: 01001 An example 1 0 2es 3o 0 1 6nput: 01001 An example 1 0 2es 3o 0 1 6nput: 01001 7utput: 2es8 An example 1 0 2es 3o 0 1 6n general, on what binary strings does this DFA return 2es9 An example 1 0 2es 3o 0 1 Ans: All strings with an e(en number of 1's Deterministic Finite Automaton ● A DFA is a 5-tuple M = (Q, Σ, δ, q0, F) Deterministic Finite Automaton ● A DFA is a 5-tuple M = (Q, Σ, δ, q0, F) – Q is a finite set ofstates 2es 3o Deterministic Finite Automaton ● A DFA is a 5-tuple M = (Q, Σ, δ, q0, F) – Q is a finite set ofstates – Σ is a finite input alphabet (e.g. {0, 1}1 2es 3o Deterministic Finite Automaton ● A DFA is a 5-tuple M = (Q, Σ, δ, q0, F) – Q is a finite set ofstates – Σ is a finite input alphabet (e.g. {0, 1}1 – δ is a transition function δ : Q × Σ → Q 1 0 2es 3o 0 1 Deterministic Finite Automaton ● A DFA is a 5-tuple M = (Q, Σ, δ, q0, F) – Q is a finite set ofstates – Σ is a finite input alphabet (e.g. {0, 1}1 – δ is a transition function δ : Q × Σ → Q – q0 ∈ Q is the start/initial state 1 0 2es 3o 0 1 Deterministic Finite Automaton ● A DFA is a 5-tuple M = (Q, Σ, δ, q0, F) – Q is a finite set ofstates – Σ is a finite input alphabet (e.g. {0, 1}1 – δ is a transition function δ : Q × Σ → Q – q0 ∈ Q is the start/initial state – F ⊆ Q is the set of final/accepting states 1 0 2es 3o 0 1 ;hat does this DFA accept9 q0 0any symbol) ;hat does this DFA accept9 q0 0any symbol) Ans*er: 3o strings ;hat does this DFA accept9 q0 0any symbol) ;hat does this DFA accept9 q0 0any symbol) Ans*er: All strings ;hat does this DFA accept9 0an% 0an% symbol) symbol) q0 q1 q2 0any symbol) ;hat does this DFA accept9 0an% 0an% symbol) symbol) q0 q1 q2 0any symbol) Ans*er: Strings of length 1 ;hat does this DFA accept9 Hell 0an% 0an% symbol) symbol) q0 q1 q2 0any symbol) Ans*er: Strings of length 1 ;hat does this DFA accept9 0 q q 1 0 1 0,1 ;hat does this DFA accept9 0 q q 1 0 1 0,1 Ans*er: Strings containing only 1's ;hat does this DFA accept9 1 1 q q q 0 0 1 2 0,1 0 ;hat does this DFA accept9 1 1 q q q 0 0 1 2 0,1 0 Ans*er: Strings containing no two consecuti(e 1's <anguage ● =i(en alpha,et Σ, a language L is a set of strings o(er the alpha,et, i.e. L ⊆ Σ* <anguage ● =i(en alpha,et Σ, a language L is a set of strings o(er the alpha,et, i.e. L ⊆ Σ* Set of all possible strings over Σ ● ;e say a language L is accepted/recogni>ed by a DFA?M, if M accepts input string x ∈ Σ* if and only if x ∈ L <anguage ● =i(en alpha,et Σ, a language L is a set of strings o(er the alpha,et, i.e. L ⊆ Σ* Set of all possible strings over Σ <anguage ● =i(en alpha,et Σ, a language L is a set of strings o(er the alpha,et, i.e. L ⊆ Σ* Set of all possible strings over Σ ● ;e say a language L is accepted/recogni>ed by a DFA?M, if M accepts input string x ∈ Σ* if and only if x ∈ L ;hat language does this DFA accept9 1 0,1 q q q 0 1 2 0,1 0 ;hat language does this DFA accept9 1 0,1 q q q 0 1 2 0,1 0 Ans*er: 7nly the string 1 ;hat language does this DFA accept9 0 1 1 0,1 q q q q 0 1 2 3 0,1 0 ;hat language does this DFA accept9 0 1 1 0,1 q q q q 0 1 2 3 0,1 0 Ans*er: 7nly the string 11 DFA's find it difficult to count ● A DFA that recogni>es the language {1c} (the single string of c 1's) must ha(e at least c states DFA's find it difficult to count ● A DFA that recogni>es the language {1c} (the single string of c 1's) must ha(e at least c states – #he parent alphabet is irrele(ant (but must of course contain 11 (Proof discussion to be completed next class).