taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 2.2.5-5

Exercise 2.2.5-5

not stated yet in Lean solution written

Rating20
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 2.2.5 of Volume 1

The task

In Table 1 user 10 arrives on floor 0 at time 1048. Show that if user 10 had arrived on floor 2, the elevator would have gone up after the passengers entered on floor 1, and not down, although user 8 wants to go to floor 0.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Find the state when the doors open at time 1063, using step E2.

Hint 2

Then see what the first user who gets in does.

Solution

Show the solution

At time 1048 the elevator is on floor 1 with state GOINGDOWN\mathrm{GOINGDOWN}. In the table user 10 sets CALLUP[0]\mathrm{CALLUP}[0], and this is a call below the elevator. Therefore at time 1063, in step E2, the state GOINGDOWN\mathrm{GOINGDOWN} is kept, and the elevator goes down after the boarding.

Now let user 10 arrive on floor 2 instead. Then the new call is CALLUP[2]\mathrm{CALLUP}[2], and no call exists below floor 1. At time 1063, in step E2, the state is GOINGDOWN\mathrm{GOINGDOWN} and there is no call for a floor below. The rule then asks whether some CALLCAR[j]\mathrm{CALLCAR}[j] with jj above floor 1 is set. None is set, since users 7, 8, 9 have not yet entered. So the state becomes NEUTRAL\mathrm{NEUTRAL}, and the call variables of floor 1 are cleared.

Next, at time 1183 user 7 gets in, with destination floor 2. Step U5 sets CALLCAR[2]←1\mathrm{CALLCAR}[2] \leftarrow 1, and since the state is NEUTRAL\mathrm{NEUTRAL}, it makes the state GOINGUP\mathrm{GOINGUP}. Users 8 and 9 enter later. Step U5 changes the state only when it is neutral, so the call CALLCAR[0]\mathrm{CALLCAR}[0] from user 8 does not change it. When the doors close, the elevator is in state GOINGUP\mathrm{GOINGUP}, and it goes up.

Check

The only changes from the table are the call of user 10 and the state at time 1063, and the argument above uses only steps E2 and U5 of the text.

Remarks

The first person to enter a neutral elevator decides the direction. This is the feature that the exercise shows.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.