1.35k likes | 1.55k Views
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012. 1. Content Finite Automata, FA Deterministic Finite Automata, DFA Nondeterministic Automata NFA NFA DFA Equivalence.
E N D
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012 1
Content • Finite Automata, FA • Deterministic Finite Automata, DFA • Nondeterministic Automata NFA • NFA DFA Equivalence
Finite Automata FA (Finite State Machines) Based on C Busch, RPI, Models of Computation
There is no formal general definition for "automaton". Instead, there are various kinds of automata, each with it's own formal definition. Generally, an automaton • has some form of input • has some form of output • has internal states • may or may not have some form of storage • is hard-wired rather than programmable
Finite Automaton Input String Output Finite Automaton String
Input String Output “Accept” or “Reject” Finite Automaton Finite Accepter
Finite Automaton as Directed Graph • Nodes = States • Edges = Transitions • An edge with several symbols is a short-hand for several edges:
DFA • Deterministic • there is no element of choice • Finite • only a finite number of states and arcs • Acceptors • produce only a yes/no answer
Alphabet = Transition Graph abba -Finite Acceptor initial state final state “accept” transition state
: set of states : input alphabet : transition function : initial state : set of final states Formal Definition • Deterministic Finite Accepter (DFA)
Observation: There is a walk from to with the label
( ) d = * q , ab 0 ( ) d d = * ( q , a ), b 0 ( ( ( ) ) ) d d d l = * q , , a , b 0 ( ( ) ) d d = q , a , b 0 ( ) q d = q , b 2 1
String Acceptance • Definition: • A string w is accepted by DFA M if w drives M to a final state from the initial state. • Formally: M accepts w iff
Language Accepted by DFA • Take a DFA • Definition: • The language contains • all input strings accepted by • = strings that drive to a final state
Alphabet = Example accept
Alphabet = Another Example accept accept accept
Formally • For a DFA • Language accepted by : alphabet transition function initial state final states
Language rejected by Observation • Language accepted by
Alphabet = More Examples accept trap state
Alphabet = = { all strings with prefix } accept
= { all strings without substring } Alphabet =
Regular Languages A language is regular if there is a DFA such that All regular languages form a language family
Alphabet = Example The language is regular
NFA • Nondeterministic • there is an element of choice: in a given state NFA can act on a given string in different ways. Several start/final states are allowed. -transitions are allowed. • Finite • only a finite number of states and arcs • Acceptors • produce only a yes/no answer
Nondeterministic Finite Accepter (NFA) Alphabet = Two choices
First Choice “accept”
Second Choice No transition: the automaton hangs
Second Choice “reject”