Section TM.
Hypothesis Σ:Set.
Hypothesis Σ0:Σ.
Record Trans:Set := {
nxt: St;
dir: Dir;
out: Σ;
}.
Definition TM:Set := St->Σ->option Trans.
Definition ExecState:Set := St*(Z->Σ).
Definition InitES:ExecState := (St0,fun _=>Σ0).
Definition upd(t:(Z->Σ))(o:Σ) :=
fun x:Z => if Z.eqb x Z0 then o else t x.
Definition mov(t:(Z->Σ))(d:Dir) :=
fun x:Z => t ((x+(Dir_to_Z d))%Z).
Definition step(tm:TM)(st:ExecState): option ExecState :=
let (s,t):=st in
match tm s (t Z0) with
| None => None
| Some tr =>
let (s',d,o):=tr in
Some (s',mov (upd t o) d)
end.
Inductive Steps: TM->nat->ExecState->ExecState->Prop :=
| steps_O tm st:
Steps tm O st st
| steps_S tm n st st0 st1:
Steps tm n st st0 ->
step tm st0 = Some st1 ->
Steps tm (S n) st st1.
Definition HaltsAt(tm:TM)(n:nat)(st:ExecState): Prop :=
exists st', Steps tm n st st' /\ step tm st' = None.
Definition Halts(tm:TM)(st:ExecState): Prop :=
exists n, HaltsAt tm n st.
Definition HaltsFromInit(tm:TM): Prop :=
Halts tm InitES.

Lemma Steps_unique {tm n st st0 st1}:
Steps tm n st st0 ->
Steps tm n st st1 ->
st0 = st1.