1 / 20

Teori Bahasa dan Otomata 2 sks

Teori Bahasa dan Otomata 2 sks. Ekuivalensi DFA-NDFA dengan ɛ-move Versi 2. Rifki Indra Perwira, S.Kom rifkiindra@gmail.com. Cakupan Bahasan. NDFA dengan ɛ-move Algoritma ɛ-move ke NDFA Kenapa harus ekuivalen? Persamaan VS Perbedaan Langkah2 penyamaan DFA-NDFA Contoh permasalahan.

esben
Télécharger la présentation

Teori Bahasa dan Otomata 2 sks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Teori Bahasa dan Otomata2 sks Ekuivalensi DFA-NDFA denganɛ-move Versi2 Rifki Indra Perwira, S.Kom rifkiindra@gmail.com

  2. Cakupan Bahasan • NDFA dengan ɛ-move • Algoritma ɛ-move ke NDFA • Kenapa harus ekuivalen? • Persamaan VS Perbedaan • Langkah2 penyamaan DFA-NDFA • Contoh permasalahan

  3. Non DFA dengan  - move (transisi ) • Dapat merubah state satu ke state lain tanpa membaca input • Tidak bergantung pada suatu input ketika melakukan transisi  q0 q1  a b q3 q4 q2  b dari q0 tanpa membaca input dapat berpindah ke q1 dan q3 dari q4 tanpa membaca input dapat berpindah ke q2

  4.  q0 q1 q2 a  b q3 q4 b -closure untuk NFA -move • Himpunan state yang dapat dicapai dari sebuah state tanpa membaca input. • State yg tidak memiliki transisi , maka -closurenya adalah state itu sendiri Dari diagram NDFA dengan-move makadihasilkan: • -closure (q0)= q0,q1,q2 • -closure (q1) = q1,q2 • -closure (q2) = q2 • -closure (q3) = q3 • -closure (q4) = q1,q2,q4

  5. Algoritma ɛ-move ke NDFA • Buat tabel transisi NFA dengan -move awal • Tentukan -closure untuk setiap state • Carilah setiap fungsi transisi hasil perubahan dari NFA dengan - move ke NFA tanpa -move (kita sebut saja sebagai ’) dimana ’ didapatkan dengan rumus: ’(state, input) = _closure ((_closure(state, input)) • Berdasarkan hasil diatas, kita bisa membuat tabel transisi dan diagram transisi dari NFA tanpa -move yang ekivalen dengan NFA dengan -move tersebut. • Jangan lupa menentukan state-state akhir untuk Non-deterministic Finite Automata tanpa -move tersebut, yaitu state-state akhir semula ditambah dengan state-state yang _closure –nya menuju ke salah satu dari state akhir semula. Dalam bahasa formalnya: F’ = F q(-closure (q)  F) 

  6. a  q1 q0 b  q2 b Contoh 1: Buatlah NDFA tanpa -move yang ekivalen dengan NDFA -move dibawah !

  7. 1. 2. • Tentukan -closure untuk setiap state: • _ closure (q0) = q0,q1 • _ closure (q1) = q1 • _ closure (q2) = q0,q1,q2

  8. 3. Tentukan ’: • ’(q0,a) = _closure ((_closure(q0),a)) • = _closure ((q0,q1,a)) =(q0,a) U (q1,a)=q0 U  = q0, sehingga_closure (q0) = q0,q1 • ’(q0,b) = _closure ((_closure(q0),b)) • = _closure ((q0,q1,b)) =(q0,b) U (q1,b)= U q2= q2sehingga_closure (q2)= q0,q1,q2 • ’(q1,a) = _closure ((_closure(q1),a)) • = _closure ((q1,a)) = _closure () =  • ’(q1,b) = _closure ((_closure(q1),b)) • = _closure ((q1,b)) = (q1,b) = q2 • sehingga _closure (q2) = q0,q1,q2 • ’(q2,a) = _closure ((_closure(q2),a)) • = _closure ((q0,q1,q2,a)) = (q0,a)U(q1,a)U(q2,a)=q0UU =q0, sehingga _closure (q0) = q0,q1 • ’(q2,b) = _closure ((_closure(q2),b)) • = _closure ((q0,q1,q2,b)) = _closure (q2) = q0,q1,q2

  9. 4. 5. Tentukan State Akhir - Himpunan state akhirsemulaadalahq0 - Cari _closure yang memuatstate q0  dikenai masing2 input   _close (q0,a) U _close (q0,b) (q0,q1)a U (q0,q1)b hasilnya q0 U q2 jadi F = {q0,q2}

  10. b a,b q0 a,b q1 b b a,b b a,b q2 b

  11. Kenapa harus ekuivalen? • Ada apa dengan NFA ? konsep yang sulit diimplementasikan. • Komputer sepenuhnya deterministic. • Kenapa dipelajari ? Lebih dekat ke sistem nyata • Tujuannya menerima bahasa yang sama

  12. DFA vs NDFA

  13. Algoritma Ekuivalen NDFA-DFA • Buatsemua state yang merupakan subset dari state semula. jumlah state menjadi 2Q • Telusuritransisi state–state yang baruterbentuk, dari diagram transisi. • Fokus yang “mendua” • Tentukan state awal • Tentukan state akhiradalah state yang elemennyamengandung state akhir • Rename state yang tersisa (*optional)

  14. Contoh 1 : • Diberikan tabel transisi NDFA Bagaimanakah DFA yg ekuivalen? Dengan initial state = Q0 Final state = Q1

  15. Mari kita kerjakan sama-sama

  16. Contoh 2: • Buatlah DFA yang ekuivalen dengan NDFA berikut : Q={P,Q,R,S} ∑={0,1} S=P F={Q,S}

  17. 1 Q 0,1 0,1 > 1 R P 0 S 0 1 0 Ø

  18. Fokus pada “yg mendua” awal : • {Q,S} • {Q,R} 1.(Q,0) U (S,0)= R U Ø = R (Q,1) U (S,1)= {Q,R} U P= {P,Q,R} 2.(Q,0) U (R,0)= R U S={R,S} (Q,1) U (R,1)= {Q,R} U P = {P,Q,R} 3.(P,0) U (Q,0) U (R,0) = {Q,S} U R U S={Q,R,S} (P,1) U (Q,1) U (R,1) = Q U {Q,R} U P = {P,Q,R} 4.(R,0) U (S,0) = S U Ø = S (R,1) U (S,1) = P U P = P 5.(Q,0) U (R,0) U (S,0) = R U S U Ø = {R,S} (Q,1) U (R,1) U (S,1) = {Q,R} U P U P= {P,Q,R} State awal = 4, muncul state baru berjumlah 5, shg total state setelah ekuivalen = 9

  19. Shg DFA yg ekuivalen dgn NDFA tadi adalah …. 1 Q,R 1 0 Q R 0 1 S > P 1 0 0 Q,R,S 0 Q,S 0 1 0 1 1 P,Q,R R,S 1 0 1

  20. Kemudian boleh di rename state2 baru 1 U(Q,R) 1 0 Q R 0 1 S > P 1 0 0 X(Q,R,S) T(Q,S) 0 1 0 1 1 V(P,Q,R) 1 W(R,S) 1 0 0

More Related