(* Computes A_T, with a given maximal *)
Definition A_T (proof_tree: cbv) : nat :=
maxl (map (fun p => length (activations_at_rank (activation_rank rank p) p)) (activations proof_tree)).
(* B_i, with i = rank *)
Definition activations_at_rank_bound (A_T: nat) (rank: nat) :=
Nat.pow max_rank (max_rank - rank) *
Nat.pow (max 1 (max_nb_rhs_functions prog)) (max_rank - rank) *
Nat.pow A_T (S (max_rank - rank)).
Definition gary_seven_poly (A_T:nat) :=
suml (map (activations_at_rank_bound A_T) (seq 0 (S max_rank))).

(* Specifications: *)
Lemma PPO_activation_rank_decreasing i s p c1 f lt c2 v:
let proof_tree := cbv_update i s p c1 (fapply f lt) c2 v in
PPO_prog ->
wf proof_tree ->
forall p, In p (activations proof_tree) ->
activation_rank rank p <= rank f.