Ltac solve_exprD := solve_exprD.solve_exprD tbl.Ltac destruct_as_list :=
repeat
match goal with
| [ H : context [ match as_list ?x with _ => _ end] |- _] => destruct (as_list x) eqn:?
| [ |- context [ match as_list ?x with _ => _ end]] => destruct (as_list x) eqn:?
| [ H : as_list _ = Some (inr _) |- _ ] => apply as_list_nil in H
| [ H : as_list _ = Some (inl (_ , _, _)) |- _ ] => apply as_list_cons in H
| [ H : as_list _ = Some (inl (?p, _)) |- _ ] => destruct p
| [ H : as_list _ = Some (inl ?p) |- _ ] => destruct p
| [ H : as_list _ = Some ?p |- _ ] => destruct p
end;
subst.

(* Specifications: *)
Lemma rnth_error_eq2 : forall typ xs n tus tvs val, exprD' tus tvs (tylist typ) xs = Some val -> exprD' tus tvs (tyoption typ) (App (Inj (inr (Data (fnth_error typ n)))) xs) = exprD' tus tvs (tyoption typ) (rnth_error typ xs n).
Lemma typeof_rreplace_nth: forall t xs x n tus tvs, typeof_expr tus tvs xs = Some (tylist t) -> typeof_expr tus tvs x = Some t -> typeof_expr tus tvs (rreplace_nth t n xs x) = Some (tylist t).
Lemma rreplace_nth_eq2 : forall typ xs x n tus tvs val v, exprD' tus tvs (tylist typ) xs = Some val -> exprD' tus tvs typ x = Some v -> exprD' tus tvs (tylist typ) (App (App (Inj (inr (Data (freplace_nth typ n)))) xs) x) = exprD' tus tvs (tylist typ) (rreplace_nth typ n xs x).