Definition shorter_ss_l (ss1 ss2 : sseq) (o i: nat) : Prop :=
forall (j : nat), j <= i-o -> ss1.[i-j] = ss2.[i-j].
Definition shorter_ss_u (ss1 ss2 : sseq) (i d: nat) : Prop :=
forall (j : nat), ss1.[i+j+d] = ss2.[i+j].
Definition shorter_ss (ss1 ss2 : sseq) (o i d: nat) : Prop :=
shorter_ss_l ss1 ss2 o i /\ shorter_ss_u ss1 ss2 i d.
(* exists (k:nat), k <= j /\ ss.[o+i] = ss.[o+k]. *)
Definition shorten_ss (ss : sseq) (li d i : nat) : state :=
match i-li with
| 0 => ss.[i]
| _ => ss.[i+d]
end.
(* exists (ss':sseq) (j d:nat), j+d <= i /\ d > 0 /\ shorter_ss ss ss' 0 j d /\ ss.[i] = ss'.[i-d]. *)

Lemma eq_states_no_loop :
forall (i:nat) (ss:sseq),
(forall (ss':sseq) (j d:nat),
d <= 0 \/ ~ shorter_ss ss ss' 0 j d \/ ss.[i] <> ss'.[i-d]
\/ j+d > i) ->
no_loop ss 0 i.