We will construct from M in such a way that simulates M and detects when M empties its stack. enters its final state when and only when M empties its stack.Thus will accept a string iff M accepts.
Let where and Xand contains all the transition of , as well as the following two transitions.
and
Transitions 1 causes to enter the initial configuration of M except that will have its own bottom-of-stack marker X which is below the symbols of M's stack. From this point onward will simulate every move of M since all the transitions of M are also in .