Fixpoint fapplies_in_term (t: term) : list term :=
match t with
| var _       => []
| capply _ lt =>      flat_map fapplies_in_term lt
| fapply _ lt => t :: flat_map fapplies_in_term lt
end.

(* Specifications: *)
Lemma fapplies_in_term_are_fapplies t1 t2 :
In t1 (fapplies_in_term t2) ->
exists f lt, t1 = fapply f lt.
Lemma fapplies_in_value_nil (v: value) :
fapplies_in_term (@term_from_value v) = [].