Repeating a machine until a tape goes blank #
repeatUntilBlank i tm runs tm repeatedly. After each round it reads the cell under the head of
work tape i and halts if that cell is blank. Each round of a Turing.MultiTapeTM.TransformsTapes
specification ends with every head on the first cell of its word, so the loop halts exactly when
the word on tape i is empty. The body always runs at least once.
Main results #
Turing.MultiTapeTM.transformsTapes_repeatUntilBlank: a loop invariant preserved by every round gives a specification ofrepeatUntilBlank i tm, with time bound(rounds + 1) * (t + 1)and space bound2 * k * s + k.
The states of repeatUntilBlank i tm: those of tm, and a state check for reading tape i
between rounds.
- run {State : Type u_3} (q : State) : RepeatUntilBlankState State
The repeated machine is running, in its state
q. - check {State : Type u_3} : RepeatUntilBlankState State
Tape
iis being read, between two rounds.
Instances For
tm, with its halting transitions sent to the state check. From check, the machine halts
if the cell under the head of tape i is blank and otherwise restarts tm, moving no head.
Instances For
Let P n be a loop invariant after n rounds, on the words on the tapes and the word emitted
so far. If each round n < rounds takes P n to P (n + 1) and leaves tape i non-empty, and
the round after that takes P rounds to R and empties tape i, then repeatUntilBlank i tm
takes P 0 to R.
Each of the rounds + 1 rounds takes at most t + 1 steps. No head leaves [-s, s], since every
round starts with all heads at cell 0 and uses at most s cells.