Sei sulla pagina 1di 3

Deterministic Finite Automata (DFA)

We now begin the machine view of processing a string over alphabet Σ. The
machine has a semi-infinite tape of squares holding one alphabet symbol per
square. The machine has a finite state set, K, with a known start state. Initially we
want the processing to be deterministic, that is, there is only one possible outcome
from processing a string. Here is how we process it:

 place string on a tape with one symbol in each square


 place machine in start state and the read head on the first square
 a computation step is done by considering the (current state, current tape
symbol) and based the value of this pair, move to a new state and move the
tape head one square to the right
 stop the machine when there are no more symbols to process

According to the description, the state change operation is a function K × Σ ⇾ K.


There are a number of interpretations we can give to this processing method, but
the one of most interest to us is that of accepting the input string based on
terminal state. Because of the deterministic behavior, we can say more strongly
that it is deciding this string, as to whether it belongs to the language or not. The
natural interpretation is means that an accepted string's terminal belongs to a set
of final, or accepting states, F ⊆ K.
The description of a DFA M = (K, Σ, δ, s, F) is that which is defined in the textbook.
We must define precisely what it means to compute an input string. Because the
machine never goes back, and stops after the last symbol, we can characterize
the machine state as a configuration, which is an element of K × Σ* representing
(current machine state, remainingportion of string to process). We define the
binary relation:
⊢ ⊆ (K×Σ*) × (K×Σ*) the yields in one step relation
It is defined as follows: for all σ ∈ Σ,
(p,σw) ⊢ (q,w) for all w ∈ Σ* if and only if δ(p,σ) = q
This makes rigorous several notions about processing in a DFA:

a. symbols are processed from left to right, processing each one only once
b. the state change only consults the current symbol (what is ahead in the string
is irrelevant)

Define ⊢* to be the reflexive, transitive closure of ⊢. This is the yields relation.


In a DFA, computing the string w means to put the machine in the start
configuration:
(s,w)
A terminal state, q, is one in which
(s, w) ⊢* (q, ε)
Because the state transition is a function, it implies that there is only one
state p such that (q,w) ⊢* (p,ε). It is sometimes convenient to express the state
transition as a function:
δ* : K × Σ* ⇾ K
where
δ*(q, w) = p if and only if (q, w) ⊢* (p, ε)
Because of the nature of the DFA, this function is well-defined.
Acceptance
We say the string w is accepted by a DFA if, proceeding from the start state, the
terminal state we reach is final i.e., ∈ F. Concisely, w is accepted if δ*(s,w) ∈ F.
Because of the determinism, it is sometimes said that w is decided by a DFA.
The language accepted by a DFA is the set of all strings accepted by it.
DFA and Regular Language Equivalence
One of the main goals of Chapter 2 is to show the following:

Theorem: A language is accepted by a DFA if and only if it is a regular language


(i.e., has a regular expression).
Although it seems obvious, we still should state the equivalence of the two
representations, in that state transitions by a string is equivalent to paths in the
graph:
Claim: (q0,σ1,q1) (q1,σ2,q2) ... (qn-1,σn,qn) are labeled edges if and only if (q0, σ1σ2...σn)
⊢* (qn, ε)
The empty path (no labeled edges) corresponds to the empty string (no symbols).
Example 2.1.1 in textbook:
This is the even-parity checker for the number of b's in a string, i.e., the machine
accepts the language
L = { w : #b's in w is even }
Accepted strings include: ε, a*, a*ba*b.
We'll soon see the construction of a RE from a DFA, but this one is easy. You can
see two looping paths from the start/final state back to itself by either a or ba*b.
Choose from (a∪ba*b) represents one loop going by two general "paths". We can
repeat this 0 or more times, getting (a∪ba*b)* as our RE for the DFA.
Switching final and non-final states gives us a DFA which represents the
complement of the previous language:
L = { w : #b's in w is odd }.
Note that the RE doesn't easily "complement" in any way.
Example 2.1.2 in textbook:
L = { w : w does not contain the substring bbb }
The state q3 is called a dead state, because no paths beyond this point can reach
a final state. Again, switch final and non-final states constructs the DFA for the
complement language:
L = { w : w contains the substring bbb }
It's also easy to see that a regular expression for L is (a∪b)*bbb(a∪b)*, since we only
need to find the substring bbb somewhere in the string, not necessarily finding the
first occurrence, which is what the DFA does.

Potrebbero piacerti anche