Section MoveToStart.
Definition MoveToStart_Rel : pRel sigSim unit 1 :=
ignoreParam
(fun tin tout =>
forall tps, atNil tin[@Fin0] tps ->
atStart tout[@Fin0] tps).
Definition isStart : sigSim -> bool :=
fun s => match s with
| inl START => true
| _ => false
end.
Definition MoveToStart : pTM sigSim unit 1 :=
MoveToSymbol_L isStart id.
(* Definition tape_size (tp : tape sig) : nat := match tp with | niltape _ => 1 | rightof l ls => 3 + length ls | leftof r rs => 3 + length rs | midtape ls m rs => 3 + length ls + length rs end.  Fixpoint tapes_size (tps : list (tape sig)) : nat := match tps with | nil => 1 | tp :: tps' => 1 + tape_size tp + tapes_size tps' end.  Lemma tape_size_length (tp : tape sig) : tape_size tp = length (encode_tape tp). *)
Definition MoveToStart_steps (tps : list (tape sig)) :=
8 + 4 * length (encode_list _ tps).
Definition MoveToStart_T : tRel sigSim 1 :=
fun tin k => exists tps, atNil tin[@Fin0] tps /\ MoveToStart_steps tps <= k.

(* TODO: somewhere *)
Lemma removelast_length (X : Type) (xs : list X) :
length (removelast xs) = length xs - 1.