Definition all_possible_sub_activation_same_rank (f: function) (lv: list term) : list term :=
let psa := all_possible_subarguments lv in
flat_map (fun g => map (fun sa => fapply g sa) psa) (functions_of_prog prog).

(* Specifications: *)
Lemma all_possible_sub_activation_same_rank_bound (f: function) (lv: list term) :
length (all_possible_sub_activation_same_rank f lv)
<= length (functions_of_prog prog) * prodl (map (@term_size _ _ _) lv).
Lemma all_possible_subarguments_self lt : lt ∈ all_possible_subarguments lt.
Lemma sub_terms_self a : In a (sub_terms a).
Lemma PPO_value_all_possible_subarguments l lv:
(forall x, In x lv -> term_value x) ->
Forall2 (clos_refl (PPO rank)) l lv ->  l ∈ all_possible_subarguments lv.
(* Toute activation de même rang doit être un « sous-terme » *)
Lemma  all_possible_sub_activation_same_rank_spec p' i s p c1 f lt c2 v:
PPO_prog ->
let proof_tree := cbv_update i s p c1 (fapply f lt) c2 v in
wf proof_tree ->
In p' (activations proof_tree) ->
activation_rank rank p' = rank f ->
In (proj_left p') (all_possible_sub_activation_same_rank f lt).