27
1 Pertemuan 2 Finite Automata Matakuliah : T0162/Teori Bahasa dan Automata Tahun : 2009

1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

  • View
    224

  • Download
    3

Embed Size (px)

Citation preview

Page 1: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

1

Pertemuan 2Finite Automata

Matakuliah : T0162/Teori Bahasa dan Automata

Tahun : 2009

Page 2: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

2

Learning Outcomes

Pada akhir pertemuan ini, diharapkan mahasiswa

akan mampu :• Menjelaskan Finite Automata• Menjelaskan dan memberikan contoh NFA

dan DFA

Page 3: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Finite automaton

• As was metioned earlier, a finite automaton has a set of states, and its “control” moves from state to state in response to external “inputs”

• Deterministic meaning that automaton cannot be in more than one state at any one time, or nondeterministic that it may be in several states at once.

3

Page 4: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

examples

4

Page 5: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

example

Interaction between participants :

5

Page 6: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

The protocol

• The three participants must design their behaviors carefully.

• The back must behave responsibly, or it cannot be a bank

• It must make sure that two stores cannot both redeem the same money file, and it must not allow money to be

both canceled and redeemed.

Protocols of this type can be represented as finite automata. That is, the state “remembers” that certain important events havce happeded.

6

Page 7: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

example

7

Page 8: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Explanation(c)

• First automaton(c) for the bank, the start state is state 1: it represents the situation where the bank has issued the money file in question but has not been requested either to redeem it or to cancel it.

• If a cancel request is sent to the bank by the customer, then the bank restores the money to the customer’s account and enters state 2.

• The latter state represents situtaion where the money has been cancelled.

8

Page 9: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Explanation (a)

• The automaton representing the actions of the store. While the bank always does the right thing, the store’s system has some defects.

• Imagine that the shipping and financial operations are done by separate processes, so there is the opportunity for the ship action to be done either before, after, or during the redemption of the electronic money.

• That policy allows the store to get into a situation where it has already shipped the goods and then finds out the money was bogus.

9

Page 10: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Explanation (b)

• This automaton has only one state, refrelcting the fact that the customer “can do anything”. The customer can perform the pay and cancel actions any number of times.

10

Page 11: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Enabling automata to ignore actions

11

Page 12: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

solution

12

Page 13: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

DFA

• The term deterministic refers to the fact that on each input there is one and only one state to which the automaton can transition from its current state

13

Page 14: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

2 types of finite automata

14

Page 15: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Example DFA

15

Page 16: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

example

16

Page 17: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

17

Page 18: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

example

18

Page 19: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Transition tables

19

Page 20: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

NFA

• A nondeterministic finite automaton (NFA) has the power to be in several states at once.

20

Page 21: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Example NFA

• Terdapat lebih dari satu transisi untuk input yang sama dari suatu state.

• Contoh :

21

q 0 q 3 q 4

q 1

q 2

Start

1

1

10

0 0 0

01

1

Page 22: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Example NFA

22

Page 23: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

Example NFA

23

Page 24: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

answer

24

Page 25: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

example

25

Page 26: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

example

26

Page 27: 1 Pertemuan 2 Finite Automata Matakuliah: T0162/Teori Bahasa dan Automata Tahun: 2009

27

Summary