Module Compute := Compute Ctx. Export Compute.
Definition flip_dir (d : dir) :=
match d with
| L => R
| R => L
end.
Definition flip_tape (t : tape) :=
match t with
| l {{s}} r => r {{s}} l
end.
Definition flip (tm : TM) : TM := fun qs =>
match tm qs with
| Some (s, d, q) => Some (s, flip_dir d, q)
| None => None
end.
Definition flip_conf (c : Q * tape) : Q * tape :=
match c with
| q;; t => q;; flip_tape t
end.
#[export] Hint Resolve flip_some : core.
#[export] Hint Resolve flip_step : core.
#[export] Hint Resolve flip_multistep : core.
#[export] Hint Resolve flip_halted : core.
#[export] Hint Resolve flip_halts_in : core.

Lemma flip_halts_iff : forall tm c,
halts tm c <-> halts (flip tm) (flip_conf c).