Ltac inv_safe H :=
inv H;
try solve[match goal with
| H : semantics.at_external _ _ _ = _ |- _ =>
simpl in H; congruence
| H : j_at_external _ _ _ = _ |- _ =>
simpl in H; congruence
| H : semantics.halted _ _ _ |- _ =>
simpl in H; unfold cl_halted in H; contradiction
end].

Lemma control_as_safe_refl psi n k : control_as_safe psi n k k.