Lemma nth_error_appP {X: Type} {l1 l2: list X} {i: nat} {x: X} :
nth_error (l1 ++ l2) i = Some x <->
((i < length l1 /\ nth_error l1 i = Some x) \/ (length l1 <= i /\ nth_error l2 (i - length l1) = Some x)).