160 likes | 234 Views
Learning Outcomes. Mahasiswa dpt membandingkan berbagai bentuk algoritma FA untuk suatu ekspresi/Syntax program agar dapat dianalisis diterima/ditolak. Outline Materi:. FA sebagai model komputasi Gambaran FA dgn digraph Definisi formal Analisis FA NFA Aplikasi state transduser. b. b. b.
E N D
Learning Outcomes • Mahasiswa dpt membandingkan berbagai bentuk algoritma FA untuk suatu ekspresi/Syntax program agar dapat dianalisis diterima/ditolak..
Outline Materi: • FA sebagai model komputasi • Gambaran FA dgn digraph • Definisi formal • Analisis FA • NFA • Aplikasi state transduser
b b b s p q r > a a a a b t a b Deterministic Finite Automata (DFA) For every state q in Q and every character in , one and only one transition of the following form occurs: q q’
Expressiveness of DFA • DFA are a type of programs • Contains concepts of imperative languages: sequences, branching and loops. • Can implement a newspaper vendor machine (see Page 20 of the book) • Can implement pattern matching: find all text containing “Britney Spears” (or “Justin Timberlake”) • Can only implement programs that require a constant amount of memory
Another Example a b A b b a a r r s q q > a a L(A) is the set of all strings having 2 consecutive a’s b a a B a b r r s q q > b L(B) is the set of all strings having 2 consecutive b’s b
Nondeterministic Finite Automata a b a a r r q q b a s > b a b b r’ r q q’ a a b Automaton accepting strings containing 2 a’s or 2 b’s Deterministic?
occurs • No transition: q q’ occurs • One or more transition: q q’ p … Nondeterministic Finite Automata (NFA) For every state q in S and every character in , one of the following will happen:
Nondeterministic Finite Automaton (NFA) • A deterministic finite automaton (NFA) is a 5-tuple (Q,,,s,F) where: • Q is a finite set of elements called states • is a finite input alphabet • s Q called the initial state • F Q called the favorable states • Q × ( × {e}) × Q
“the empty string” e q q’ Nondeterministic Finite Automata (NFA) What else can occur in NFAs? If we start with the configuration (q,aaabbb) and apply this transition, what is the resulting configuration? (q’, aaabbb) “e-transitions” do not process any characters, they just allow to “jump” between states
String Accepted by NFA Given an NFA A = (Q,,,s,F), and a string w *, we say that w is accepted by A if at least one of the configurations yielded by (s,w) is a configuration of the form (f,e) with f a favorable state What is the language accepted by an NFA? L(A) = {w * : w is accepted by A}
Example a r r s q q > b b b
Example # 2 a b a a r r q q b a s > b a b b r’ r q q’ a a b
p Suppose that while processing a configuration (r,w) only by going to state p, a favorable state can be reached. Then, the oracle will choose p a r e q NFA vs DFA • Are deterministic automata, nondeterministic? • The oracle explanation of NFAs: there is an oracle that always makes the right choice • Is the oracle explanation compatible with our definition of acceptability in NFAs?
a r r s q q > b b b NFA vs DFA (2) Are NFAs more powerful than DFAs? (i.e., are there languages that can be recognized by NFAs but not by DFAs)
NFA vs DFA (3) a b a a r r q q b a s > b a b b r’ r q q’ a a b
Terima kasih Selamat belajar