0.3. Deterministic Finite Acceptors¶
0.3.1. Deterministic Finite Acceptors¶
0.3.1.1. Introduction: Terminology¶
Finite State MachineFinite State AutomataFinite AutomataAutomata: This just means “machine”All names for a simple model of computation that has:* States that the machine can be in (nodes)* Input (string)* Transitions on a character between states (edges)* Some machine types have memory
0.3.1.2. Deterministic Finite Acceptor¶
Our simplest machine.Deterministic: In a state, when given a specific letter, only one thing to do.Finite: Finite number of statesAcceptor: It only decides whether or not a string is in this machine’s language (so it has no ability to modify the tape)input tape
- a
- a
- b
- b
- a
- b
tape headcurrent state10head moves
0.3.1.3. DFA: Formal Definition¶
Define a DFA as (Q,Σ,δ,q0,F) where
Q is a finite set of states
Σ is the input alphabet (a finite set)
δ:Q×Σ→Q. A set of transitions like (qi,a)→qj meaning that when in state qi, if you see letter a, consume it and go to state qj.
q0 is the initial state (q0∈Q)
F⊆Q is a set of final states
0.3.1.4. Concept: Accepting a String¶
Example: A DFA that accepts even binary numbers.
q0q10110Assign meaning to the states: q0 - odd numbers, q1 - even numbers,Note the triangle: Start StateNote the double circle: Final (Accepting) StateWe accept the string if we halt (finish the string) in a final state.
0.3.1.5. Formal Definition¶
M=(Q,Σ,δ,q0,F)=
Tabular Format
01q0q1
0.3.1.6. Example¶
0.3.1.7. .¶
.
0.3.1.8. Concept: Power of DFAs¶
A given DFA can accept a set of strings: A language.All of the possible DFAs form a class of machines.So DFAs (as a class of machines) can accept certain languages (as a matching class of langauges).
0.3.1.9. Algorithm for DFA¶
Start in start state with input on tapeq = current states = current symbol on tapewhile (s != blank) doq=δ(q,s)s = next symbol to the right on tapeif q∈F then accept
0.3.1.10. Trace¶
Example of a trace: 100
1)
- 1
- 0
- 0
q0q12)
- 1
- 0
- 0
q0q13)
- 1
- 0
- 0
q0q14)
- 1
- 0
- 0
q0q1
0.3.1.11. Definitions¶
λ (lambda): The empty stringδ∗(q,λ)=qYou didn’t go anywhere, you are still in state qδ∗(qi,w)=qjGiven string w and starting in state qi, we will reach state qj.δ∗(q,wa)=δ(δ∗(q,w),a)Apply δ to all of w first (some string) and then to aThe language accepted by a DFA M=(Q,Σ,δ,q0,F) is set of all strings on Σ accepted by M.Formally, L(M)={w∈Σ∗∣δ∗(q0,w)∈F}Set of strings not accepted: ¯L(M)={w∈Σ∗∣δ∗(q0,w)∉F}
0.3.1.12. Incomplete DFA¶
Note that our DFA for even binary numbers is “complete”.We always know what to do on any input.Consider the language L(M)={bna|n>0}
q0q1q2babThis is technically incomplete. It shows all ways that we can reach an accepting state.
0.3.1.13. Trap State¶
Can complete by adding one or more “trap” states with the “extra” transitions.
q0q1q2trapbaa,ba,babThere is nothing “special” about a trap state, they are just conceptual.A “trap” state means that once in, all transitions keep us there.A “final” trap state is any trap state that is a final. Example: Define a machine that accepts any string that starts with “ab”.
0.3.1.14. Regular Languages¶
Definition: Given some class or type of Finite Acceptors, the set of languages accepted by that class of Finite Acceptors is called a family.
Definition: Therefore, the DFAs define a family of languages that they accept. A language is regular if and only if there exists a DFA M such that L=L(M).