Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.

Similar presentations


Presentation on theme: "Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory."— Presentation transcript:

1 Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory

2 Consider the problem of designing a "computer / controller" that controls a toll gate. When a car arrives at the toll gate, the gate is closed. The gate opens as soon as the driver has paid 50 piaster. Assume that only three coin denominations: 10, 20, and 50 piaster. Also assume that no excess change is returned.

3 After having arrived at the toll gate, the driver inserts a sequence of coins into the machine. At any time, the machine has to decide whether or not to open the gate, i.e., whether or not the driver has paid 50 piaster (or more). In order to decide this, the machine is in one of the following six states, At any time during the process:

4 The machine is in state q 0, if it has not collected any money yet. The machine is in state q 1, if it has collected exactly 10 piaster. The machine is in state q 2, if it has collected exactly 20 piaster. The machine is in state q 3, if it has collected exactly 30 piaster. The machine is in state q 4, if it has collected exactly 40 piaster. The machine is in state q 5, if it has collected 50 piaster or more.

5 Initially (when a car arrives at the toll gate), the machine is in state q 0. The machine will switch to state q 5 as soon as the driver inserts 50 piaster (or more) and the gate will open. The design of such machine as fa will look as:

6

7 Finite Automata: Informal Def. Informally, fa can considered as The machine M: States: q 1 and q 2 Start state: q 1 (arrow from nowhere) Accept state: q 2 (double circle) State transitions: arrows

8 Finite Automata: Informal Def. The machine M: On input string s = s 1 s 2 · · · s n, M operates as follows: Begins in start state q 1 and reads the string s from left to right. When reading symbol s i it follows the transition labeled s i from the current state After reading s n, the last symbol in the string, it accepts s if it is in an accept state rejects s if it is not in an accept state

9 Representation of Finite Automata fa can be represented by: State diagram Transition Table

10 Finite Automata: Formal Def.

11 Definition: a finite automata (fa) is a 5-tuples M = (Q, Σ, δ, q, F), where Q is a finite set, whose elements are called states. Σ is a finite set, called the alphabet, the element of Σ are called symbols. δ : Q × Σ → Q is a function, called a transition function.

12 q Q called start state. F Q, the elements of F are called accept states. Note1: δ (transition function) can be consider as the “program” that tells what M can do in “one step”. Note2: such fa that describe by M is known also as dfa (deterministic finite automata).

13 Example 3: the computer that designed for controlling the toll gate in example 1 above, can be considered as dfa, as follows: Q = {q 0, q 1, q 2, q 3, q 4, q 5 }, Σ = {5, 10, 50}, q = q 0 (start state), F = {q 5 }, and δ is given by the following table:

14 102050 q0q0 q0q0 q1q1 q2q2 q1q1 q3q3 q1q1 q1q1 q2q2 q2q2 q2q2 q4q4 q3q3 q3q3 q3q3 q5q5 q4q4 q4q4 q4q4 q5q5 q5q5 q5q5 q5q5 q5q5

15 Example 4 Given Q =, Σ = { 0, 1 }, A = {10 }, the initial state q 0 =, as fa, its transition function is as shown in the following table. 1 0 1 0 1 0 0 1 0 1 0 1 0 0 0 Input (a) State (q) 10 1 0 1 1 0 1 1 0 1 1

16 The transition diagram representing the fa is 0 1 10 11 0 00 1 01 0 1 1 1 1 0 0 0 0 0 1 1

17 Example 5 design of fa that controls opening a door based on the following. Actually the door is opened if {0,..., 9} * 1234{0,..., 9} * is entered

18 The machine needs to remember if the input given so far contains the subsequence 1234

19 DEFINITIONS Trap State Consider the following dfa q1q1 q2q2 q3q3 a ba, b When ever the dfa goes into state q 3, then it can never escape. In this case q 3 is a trap state In this case q 3 is a trap state

20 Extending the notation: the function For any dfa, M = (Σ, Q, q, δ, A), If the machine M in state q and recieves input symbol a then it is δ(q,a). Which state M ends up, if it begins in state q, receives the string x of several input symbols. δ * can be thought of to replace δ, and the M state is denoted by δ*(q,x) δ * is considered as the extention function of δ.

21 The extended δ * on M can be given by δ * : Q x Σ * Q and recursively can be defined as follows: 1. For any 2. For any

22 Example 6 if and then proof Formally, Can be defined recursively by: for all Now let us apply it on the simple case. (use **) * **

23 but *** use ***, to get #

24 Example 7 Given transitions of a dfa as shown below Show that q1q1 q2q2 q3q3 q4q4 Q RF

25 some properties on Theorem 1: For any state q Є Q and any symbol a Є Σ for a dfa M = (Σ, Q, q, δ, A), proof since, then By definition of, Also by definition

26 hence # Theorem 2: For any state q of Q and any string x and y over Σ for a dfa M = (Σ, Q, q, δ, A), Proof: it is going to be proven by induction on string y. that is the statement to be proven is For any arbitrary fixed string x is true for any y

27 now, Let us recall, *.*. and for, and, then if, then also Hence the theorem is true for By the definition of

28 assume is true for any arbitrary string y. we are going to prove that: is true for any arbitrary string a of Σ. By the definition of Thus the theorem has proven

29 fa can be found in different forms such as dfa: Deterministic Finite Automata, DFA nfa: Nondeterministic Finite Automata, NFA pfa: Pushdown Finite Automata, PDA


Download ppt "Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory."

Similar presentations


Ads by Google