Module Translation.
Definition to_St(x:Q):St :=
match x with
| BB52.A => St0
| BB52.B => St1
| BB52.C => St2
| BB52.D => St3
| BB52.E => St4
end.
Definition of_St(x:St):Q :=
match x with
| St0 => BB52.A
| St1 => BB52.B
| St2 => BB52.C
| St3 => BB52.D
| St4 => BB52.E
end.
Definition to_Σ(x:Sym):Σ :=
match x with
| BB52.S0 => Σ0
| BB52.S1 => Σ1
end.
Definition of_Σ(x:Σ):Sym :=
match x with
| Σ0 => BB52.S0
| Σ1 => BB52.S1
end.
Definition to_Dir(x:TM.dir):Dir :=
match x with
| TM.L => Dneg
| TM.R => Dpos
end.
Definition to_halftape(x:side):nat->Σ :=
fun n => to_Σ (Streams.Str_nth n x).
Definition to_tape(x:tape):BinInt.Z->Σ :=
let '(l0,m0,r0):=x in
make_tape (to_halftape l0) (to_Σ m0) (to_halftape r0).
Definition to_ExecState(x:Q*tape):ExecState Σ :=
let (s0,t0):=x in
(to_St s0,to_tape t0).
Definition to_oTrans(x:option (Sym*TM.dir*Q)):option (Trans Σ) :=
match x with
| None => None
| Some (o,d,s) => Some {| nxt:=to_St s; dir:=to_Dir d; out:=to_Σ o |}
end.
Definition to_TM(tm:TM):BB52Statement.TM Σ :=
fun s0 i0 =>
to_oTrans (tm (of_St s0,of_Σ i0)).

Lemma Str_nth_tl_const{T} n (s0:T):
Streams.Str_nth_tl n (Streams.const s0) = (Streams.const s0).