pubdoc_1_17895_1712

advertisement
Computation Theory
MSC:ZAINAB F.H.
1. Finite Automata:
A finite-state automaton (FSA) is a machine which takes, as input, a finite
string of symbols from some alphabet ∑. There is a finite set of states in which
the machine can find itself. The state it is in before consuming any input is
called the start state. Some of the states are accepting or final. If the machine
ends in such a state after completely consuming an input string, the string is said
to be accepted by the machine. The actual functioning of the machine is
described by something called a transition function, which specifies what
happens if the machine is in a particular state and looking at a particular input
symbol.
The start state is labeling by "start" or minus sign"-"
The final state is labeling by "final " or plus sign"+"
Sometimes a start state is indicated by an arrow and a final state by drawing a
box or another circle around its circle.
1.1 Deterministic Finite Automata:
A deterministic finite automaton (DFA)—also known as deterministic
finite state machine—is a finite state machine that accepts/rejects finite strings
of symbols and only produces a unique computation (or run) of the automaton
for each input string.
A Deterministic Finite Automaton (DFA) consists of:
1. A finite set of states (Q, typically).
2. An input alphabet (Σ, typically).
3. A transition function (δ, typically).
4. A start state (q0, in Q, typically).
5. A set of final states (F ⊆ Q, typically).
Example 1: Find a DFA with input alphabet Σ = {a, b} that accepts the
language L = {w ∈Σ ∗ |w contains three consecutive a’s }.
Babylon University-Uloom Collage for Women–Computer Science Department–Second Class..1
Computation Theory
MSC:ZAINAB F.H.
4.2 Non-deterministic FiniteAutomata (NFA):
A nondeterministic finite automaton (NFA) or nondeterministic finite
state machine is a finite state machine that can have multiple transitions from a
given state, for a given input symbol. A string is accepted if there exists a
sequence of transitions that results in the machine being in a final state after the
entire string is read.. It is may be є transition that is state transition can be made
without reading a symbol.
A Non-deterministic Finite Automaton (NFA)
consists of:
1. Q ==> a finite set of states.
2. Σ ==> a finite set of input symbols
(alphabet).
3. q0 ==> a start state.
4. F ==> set of final states.
5. δ ==> a transition function, which is a mapping between Q x Σ ==>
subset of Q. It takes two arguments: a state and an input symbol.
In a DFA, the next state is completely determined by the current state and
the symbol being scanned, according to the transition function δ.
In a nondeterministic finite automaton (NFA), there may be a choice of
several states to transition into at each step, and may decide not to advance the
read head.
Transition diagram may have any number of edges with the same label
leaving the same state. There can also be "є edges (meaning: make the transition
without reading the symbol or advancing the read head).
Babylon University-Uloom Collage for Women–Computer Science Department–Second Class..2
Computation Theory
MSC:ZAINAB F.H.
How does such a machine accept a string? A string will be accepted if there is
at least one sequence of state transitions on an input that leaves the machine in
an accepting state.
Example 2: An NFA accepting all strings that end in 01 as follows:
The states of this NFA during the processing of input sequence 00101 change as
follows:
Example 3:
The following example is of a DFA M,
with a binary alphabet, which requires that the
input contains an even number of 0s.
Babylon University-Uloom Collage for Women–Computer Science Department–Second Class..3
Computation Theory
MSC:ZAINAB F.H.
Construct a DFA to accept a string
containing two consecutive zeroes followed
by two consecutive ones.
Exercise 1:
1. Give DFAs that accept the following languages over ∑ = {a, b}.
a) L1 = {x | x contains the substring aba}
b) L2 = L(a∗b∗)
c) L6 = {x | x has no a’s in the even positions}
2. What languages do the following DFAs accept?
Babylon University-Uloom Collage for Women–Computer Science Department–Second Class..4
Computation Theory
MSC:ZAINAB F.H.
Exercise 2:
Give a DFA that accepts the language accepted by the following NFA.
References:
1. "Foundations of Computation", Second Edition, Carol Critchlow and
David Eck, 2011.
2. "An Introduction to Formal Languages and Automata", Third Edition,
Peter Linz, 2001.
3. "Introduction to Theory of Computation", second edition, MICHAEL
SIPSER, 2006.
Babylon University-Uloom Collage for Women–Computer Science Department–Second Class..5
Download