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.

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).