Section ConstantsOfTerm.
Context {X: Const}.
Implicit Types (s t: exp X).
Fixpoint consts s :=
match s with
| var x => nil
| const c => [c]
| lambda s => consts s
| app s t => consts s ++ consts t
end.
Definition Consts S := (flat_map consts S).

Lemma consts_subst_in x sigma s:
x ∈ consts (sigma • s) -> x ∈ consts s \/
exists y, y ∈ vars s /\ x ∈ consts (sigma y).