Presentation is loading. Please wait.

Presentation is loading. Please wait.

56 Rumination on the Formal Definition of DPDA In the definition of DPDA, there are some parts that do not agree with our intuition. Let M = (Q, , ,

Similar presentations


Presentation on theme: "56 Rumination on the Formal Definition of DPDA In the definition of DPDA, there are some parts that do not agree with our intuition. Let M = (Q, , ,"— Presentation transcript:

1 56 Rumination on the Formal Definition of DPDA In the definition of DPDA, there are some parts that do not agree with our intuition. Let M = (Q, , , , q 0, Z 0, F ) be a DPDA. According to the definition, M has the following restrictions. (1) For a state p  Q and a stack top symbol A , if  (q, a, A) is defined, then  ( p, , A) must be undefined, and vice versa, i.e., the machine cannot have both  -move and non-  -move in the same state with the same stack top symbol. (2) M is not allowed to read the blank symbol next to the end of input string to check whether the whole input string has been read. Notice that the blank symbol is not an input symbol. (Recall that the same restriction is applied for FA's.) About Restriction (1): Suppose that  (p, a, A) = (q, BA) and  ( p, , A) = (r, CA), for some p, q, r  Q and A,B,C  . Transition  (p, a, A) = (q, BA) (also see the figure at right) denotes the following: (a) in state p reads the stack top, and if it is A, (b) reads the input, and if it is a, (c) enters state q and pushes B on top of the stack. Transition  (p, , A) = (r, CA) denote the following: (a) in state p reads the stack top, and if it is A, (b) does not read the input, and (c) enters state r and pushes C on top of the stack. p q (a, A/BA) p r ( , A/CA)

2 57 Rumination on the Formal Definition of DPDA (cont’ed) Notice that each PDA transition involves three actions: (a) Reads the stack top. This is always done in every transition. (b) Either read (e.g.,  (p, a, A) is defined) or does not read (e.g.,  ( p, , A) is defined). (c) Enters a state and changes stack top (i.e., pushes, pops or replaces the top stack symbol). If a PDA has both  (p, a, A) and  ( p, , A) defined, then these two transitions imply that the machine, in state p with stack top symbol A, reads and does not read(sounds strange?) the input. This machine operates nondeterministically, i.e., with the same cause (i.e., p and A) it shows two different responses (or actions), i.e., reads and does not read. If a machine is defined such that it takes multiple actions for the same cause, we call it a nondeterministic machine. Note that these multiple actions do not have to be "contradictory", like read and not read, live and die, etc. For example, if an FA has both transitions  (p, a) = r and  (p, a) = s, it is a nondeterministic FA (NFA) since the machine, reading the same symbol a in state p(i.e., with the same cause), enters two different states. If a PDA has transitions  (p, a, A) = (q, BA) and  (p, a, A) = (q, CA), then this PDA operates nondeterministically because for the same cause p, a and A, it takes two different responses; one pushing B and the other pushes C. Nondeterministic machines are conceptual models that cannot be realized. We use them as tools for designing and analyzing real machines. We will study such models as our next topic.

3 58 Rumination on the Formal Definition of DPDA (cont’ed) q0q0 q1q1 q2q2 q3q3 (X, Z 0 /X Z 0 ) (Y, X/YX ) ( , X/X ) (X, X/  ) ( , Z 0 /Z 0 ) start In general nondeterministic PDA are more powerful than deterministic ones. The following example shows how we can use nondeterministic transitions and make a PDA more powerful. Consider the language L = {xx R | x  {a,b} + }. It has been proved that no deterministic PDA can accept L. (Try to build one.) However, if we allow a PDA to have both  (p, a, A) and  ( p, , A) defined, for some state p, an input symbol a and stack symbol A, we can construct a PDA M that recognizes L as shown below. In the state transition graph, for the notational convenience, we use X, Y  {a, b}. Notice that X and Y are not necessarily distinct. So (Y, X/YX) denotes four cases; (a, b/ab), (b, a/ba), (a, a/aa) or (b, b/bb), and (X, X/  ) denotes two cases; (a, a/  ), or (b, b/  ). About the Restriction (2): Recall that by definition we say that an input string is accepted by a PDA if it satisfies the following two conditions: (a) The machine is in an accepting state. (b) The whole input string has been read (i.e., processed), which implies that the input head read the last symbol of the input string, and moved onto its right neighboring blank cell.

4 59 Rumination on the Formal Definition of DPDA (cont’ed) Notice that a PDA can be in an accepting state in the middle of the computation. Being only in an accepting state (i.e., condition (a)) doesn't necessarily mean that the input is accepted. We need additional condition (b) above. Also notice that deciding whether the input is accepted or not is supposed to be made by us, not by the machine. The decision is made by examining the status (i.e., (a) and (b) above by definition) of the machine. When we design a PDA, because of condition (b) above, we are tempted to have our PDA check if the input symbol read is a blank before it accepts (or rejects) by (not) entering an accepting state depending on the current state of the machine. In other words, we are tempted to use an end-of-input marker, like we put a semicolon at the end of every statement of C programming language. Consider a simple example; Clearly, the DPDA in Figure (a) below recognizes language {a i | i > 0 } by satisfying the two conditions (a) and (b) above. Notice that whatever the number of a’s in the input, the machine reads the whole input, if it has only a’s. You may feel uncomfortable with condition (b), because you want to know if the machine accepts the input just by watching whether it enters an accepting state or not, like what we do for Turing machines. However, it is impossible for the machine, while reading a’s, to know whether the a just read is the last one or not until it reads special end marker, like the blank or semicolon. So, if we do not like condition (b) above, we need a marker put at the end of every string. The above language should be modified as {a i ; | i > 0 }, if we want to use semicolon as the end-of-string marker. This language can be recognized by the DPDA shown in Figure (b) below. In real world, each string (which corresponds to a program) of the language is provided by the users of the machine. Now, we can raise the following question; “Can we rely on them to put the special marker at the end of every string?” In a sense, we are transferring part of our burden for designing the machine to the user. (a, Z 0 /Z 0 ) Figure (a) (a, Z 0 /Z 0 ) ( ;, Z 0 /Z 0 ) Figure (b)

5 60 Rumination on the Formal Definition of DPDA (cont’ed) Notice that a PDA can be in an accepting state in the middle of its computation. If we restrict a PDA such that it cannot enter an accepting state in the middle of the computation, then obviously no DPDA can do any meaningful computation without checking the end-of-input marker. For example, it is easy to see that no DPDA can accept the language {a i | i > 0} with this restriction, because it is impossible to identify the last a without reading the blank symbol from its right neighboring cell, which is not allowed. Finally, you may ask; “Why Turing machines and LBA have only one accepting condition?” Recall that Turing machines and LBA accept the input if it enters an accepting state, with no regard to the position of the input head. They are two-way machines and are allowed to read blank cells (for Turing machines) or the boundary marker ( for LBA). By definition they can check the end of string. Thus we can design a TM or an LBA such that the acceptance can be decided by its state only.


Download ppt "56 Rumination on the Formal Definition of DPDA In the definition of DPDA, there are some parts that do not agree with our intuition. Let M = (Q, , ,"

Similar presentations


Ads by Google