Fixpoint nb_judgements (proof_tree : cbv) : nat :=
match proof_tree with
| cbv_constr lp _ _ => 1 + suml (map nb_judgements lp)
| cbv_split lp p _ _ => 1 + nb_judgements p + suml (map nb_judgements lp)
| cbv_function _ _ p _ _ => 1 + nb_judgements p
end.
Fixpoint nb_judgements_sub_rec (proof_tree : cbv) : nat :=
match proof_tree with
| cbv_constr lp _ _ => 1 + suml (map nb_judgements_sub_rec lp)
| cbv_split lp p _ _ => 1 + nb_judgements_sub_rec p + suml (map nb_judgements_sub_rec lp)
| cbv_function _ _ _ _ _ => 0
end.
Definition nb_judgements_sub (proof_tree : cbv) : nat :=
match proof_tree with
| cbv_constr _ _ _ => 0
| cbv_split _ _ _ _ => 0
| cbv_function _ _ p _ _ => nb_judgements_sub_rec p
end.

Lemma term_size_proj_left_bound : forall i s p' t v,
let p := cbv_function i s p' t v in
let S := max_active_size p in
wf p ->
forall p',
InCBV p' p -> term_size (proj_left p') <= activation_bound prog S + S.