fact: Fixpoint decompose (vars : nat) (p : list term) (lp lc : list expr) := match lp with | nil => Some p | cons h t => match find_expr h vars t lc with | Some n => decompose vars (cons (Forward n) p) t lc | None => match h with | Evar n => decompose vars (cons (Forward (length t + n)) p) t lc | Econst _ => None | Eunary o e1 => match find_expr e1 vars t lc with | Some n => decompose vars (cons (Unary o n) p) t lc | None => None end | Ebinary o e1 e2 => match find_expr e1 vars t lc with | Some n1 => match find_expr e2 vars t lc with | Some n2 => decompose vars (cons (Binary o n1 n2) p) t lc | None => None end | None => None end end end end.
imports: Coq(ZArith Reals List Psatz) Xreal Tree