Fixpoint activations (proof_tree : cbv) : list cbv :=
match proof_tree with
| cbv_constr lp _ _ _ _ => flat_map activations lp
| cbv_split lp p _ _ _ _ => activations p ++ flat_map activations lp
| cbv_update _ _ p _ _ _ _ as p' => p' :: activations p
| cbv_read _ _ _ => []
end.
Fixpoint activations_cache_order (proof_tree : cbv) : list cbv :=
match proof_tree with
| cbv_constr lp _ _ _ _ => revflatten (map activations_cache_order lp)
| cbv_split lp p _ _ _ _ => activations_cache_order p ++ revflatten (map activations_cache_order lp)
| cbv_update _ _ p _ _ _ _ as p' => p' :: activations_cache_order p
| cbv_read _ _ _ => []
end.

(* Specifications: *)
Lemma activations_cache_order_are_activations (p: cbv) :
Permutation (activations p) (activations_cache_order p).
Lemma activations_are_subtrees: forall p pi:cbv,
In p (activations pi) -> In p (sub_trees pi).
Corollary activations_inCBV: forall p pi:cbv,
In p (activations pi) -> InCBV p pi.