proposition: Lemma reverse_lookup l i : i < length l → reverse l !! i = l !! (length l - S i).
proof: Proof. revert i. induction l as [|x l IH]; simpl; intros i Hi; [done|]. rewrite reverse_cons. destruct (decide (i = length l)); subst. + by rewrite list_lookup_middle, Nat.sub_diag by by rewrite reverse_length. + rewrite lookup_app_l by (rewrite reverse_length; lia). rewrite IH by lia. by assert (length l - i = S (length l - S i)) as -> by lia. Qed.
imports: stdpp(options)