(** * Skelet #35 *)
(** Note: this is mostly a copy of Skelet34.v – the machines are similar enough that the proofs check out. *)
Set Default Goal Selector "!".
Definition tm : TM := fun '(q, s) =>
match q, s with
| A, 0 => Some (1, R, B)  | A, 1 => Some (1, L, C)
| B, 0 => Some (0, R, C)  | B, 1 => Some (0, R, B)
| C, 0 => Some (1, L, D)  | C, 1 => Some (0, L, A)
| D, 0 => Some (1, L, E)  | D, 1 => None
| E, 0 => Some (1, L, A)  | E, 1 => Some (0, L, A)
end.
Notation "c --> c'" := (c -[ tm ]-> c')   (at level 40).
Notation "c -->* c'" := (c -[ tm ]->* c') (at level 40).
Notation "c -->+ c'" := (c -[ tm ]->+ c') (at level 40).
Notation P := Pos.succ.
Definition D n m : Q * tape :=
L n <{{C}} [1; 0; 1; 0] *> R m.
Definition E n a m : Q * tape :=
K n <{{C}} [1; 0; 1; a] *> R m.

Corollary LaR_max : forall l k a m,
(pow2 k - 1 <= b m)%N ->
l <* Lk (bin_min k) <{{C}} [1; 0; 1; a] *> R m -->*
l <* Lk (bin_max k) <{{C}} [1; 0; 1; a] *> R (pow2 k - 1 :+ m).