28.10.2022 Views

Computability complexity and Languages- Fundamentals of Theoretical Computer Science

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3. Syntax 27

Suppose we have a program 9' and a state u of 9'. In order to say what

happens "next," we also need to know which instruction of 9' is about to

be executed. We therefore define a snapshot or instantaneous description

of a program 9' of length n to be a pair (i, u) where 1 ~ i ~ n + 1, and u

is a state of 9'. (Intuitively the number i indicates that it is the ith

instruction which is about to be executed; i = n + 1 corresponds to a

"stop" instruction.)

If s = (i, u) is a snapshot of 9' and V is a variable of 9', then the value

of Vats just means the value of V at u.

A snapshot (i, u) of a program 9' of length n is called terminal if

i = n + 1. If (i, u) is a nonterminal snapshot of 9', we define the successor

of (i, u) to be the snapshot (j, T) defined as follows:

Case 1. The ith instruction of 9' is V ~ V + 1 and u contains the

equation V = m. Then j = i + 1 and T is obtained from u by

replacing the equation V = m by V = m + 1 (i.e., the value of V

at T ism+ 1).

Case 2. The ith instruction of 9' is V ~ V- 1 and u contains the

equation V = m. Then j = i + 1 and T is obtained from u by

replacing the equation V = m by V = m - 1 if m -=!= 0; if m = 0,

T = U.

Case 3. The ith instruction of 9' is V ~ V. Then T = u and j = i + 1.

Case 4. The ith instruction of 9' is IF V-=!= 0 GOTO L. Then T = u, and

there are two subcases:

Case 4a. u contains the equation V = 0. Then j = i + 1.

Case 4b. u contains the equation V = m where m -=1= 0. Then, if there is

an instruction of 9' labeled L, j is the least number such that

the jth instruction of 9' is labeled L. Otherwise, j = n + 1.

For an example, we return to the program of (b), Section 2. Let u be

the state

X= 4, Y= 0, Z=O

and let us compute the successor of the snapshots (i, u) for various values

of i.

For i = 1, the successor is (4, u) where u is as above. For i = 2, the

successor is (3, T ), where T consists of the equations

X=4, Y= 0, Z=l.

For i = 7, the successor is (8, u ). This is a terminal snapshot.

A computation of a program 9' is defined to be a sequence (i.e., a list)

s 1 ,s 2 , ••• ,sk of snapshots of 9' such that s;+t is the successor of s; for

i = 1, 2, ... , k - 1 and sk is terminal.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!