Definition as_list (e : expr typ func) : option
((typ * expr typ func * expr typ func) + typ) :=
match e with
| Inj (inr (Data (fnil ty))) => Some (inr ty)
| App (App (Inj (inr (Data (fcons ty)))) hd) tl => Some (inl (ty, hd, tl))
| _ => None
end.
Fixpoint rnth_error (t: typ) (xs: expr typ func) (n: nat) : expr typ func :=
match as_list xs with
| Some (inr ty) => none_reif ty
| Some (inl (ty, hd, tl)) =>
match n with
| O => some_reif hd ty
| S n0 => rnth_error ty tl n0
end
| _ => App (Inj (inr (Data (fnth_error t n)))) xs
end.
Fixpoint rreplace_nth (t: typ) (n: nat) (xs: expr typ func) (x: expr typ func) : expr typ func :=
match as_list xs with
| Some (inr ty) => xs
| Some (inl (ty, hd, tl)) =>
match n with
| O => App (App (Inj (inr (Data (fcons ty)))) x) tl
| S n0 => App (App (Inj (inr (Data (fcons ty)))) hd) (rreplace_nth t n0 tl x)
end
| _ => App (App (Inj (inr (Data (freplace_nth t n)))) xs) x
end.
Section tbled.
Variable tbl : SymEnv.functions RType_typ.
Let RSym_sym := RSym_sym tbl.
Existing Instance RSym_sym.
Let RSym_sym_ok :  RSymOk RSym_sym := _.
Existing Instance RSym_sym_ok.
Let Expr_expr_fs := Expr_expr_fs tbl.
Existing Instance Expr_expr_fs.
Let Expr_ok_fs := Expr_ok_fs tbl.
Existing Instance Expr_ok_fs.
Existing Instance MA.
Definition reflect tus tvs e (ty : typ)
:= @exprD _ _ _ Expr_expr_fs tus tvs e ty.

Lemma some_none: forall T v, @None T = Some v -> False.
intros. congruence.