Section Shift.
Variable sig : finType.
Variable (f : sig -> bool). (* halt if this symbol was read (and overwritten) *)
Definition Shift_Step_Rel (s : sig) : pRel sig (sig + unit) 1 :=
fun tin '(yout, tout) =>
match current tin[@Fin0] with
| Some c =>
if f c
then tout[@Fin0] = doAct tin[@Fin0] (Some s, Nmove) /\ yout = inr tt
else tout[@Fin0] = doAct tin[@Fin0] (Some s, Rmove) /\ yout = inl c
| None => tout[@Fin0] = tape_write tin[@Fin0] (Some s) /\ yout = inr tt
end.
Definition Shift_Step (s : sig) : pTM sig (sig + unit) 1 :=
Switch (ReadChar)
(fun c => match c with
| Some c =>
if f c then Return (Write s) (inr tt)
else Return (WriteMove s Rmove) (inl c)
| None => Return (Write s) (inr tt)
end).

Lemma Shift_Step_Sem (s : sig) : Shift_Step s ⊨c(3) Shift_Step_Rel s.