Definition proj_left_max_size (proof_tree : cbv) : cbv :=
proj_left_max_size_list (proof_tree) (sub_trees proof_tree).

(* Specifications: *)
Lemma proj_left_size_le_max proof_tree:
forall p, InCBV p proof_tree ->
term_size (proj_left p) <= term_size (proj_left (proj_left_max_size proof_tree)).
Lemma InCBV_proj_left_max_size p : InCBV (proj_left_max_size p) p.
Fixpoint max_proj_right_size (proof_tree : cbv) : nat :=
match proof_tree with
| cbv_constr lp t v => max (value_size v) (maxl (map max_proj_right_size lp))
| cbv_split lp p t v => max (value_size v) (max (max_proj_right_size p) (maxl (map max_proj_right_size lp)))
| cbv_function _ _ p t v => max (value_size v) (max_proj_right_size p)
end.
Lemma judgement_size_le_projs_size p :
max_judgement_size p <= term_size (proj_left (proj_left_max_size p)) + max_proj_right_size p.
Lemma proj_left_size_le_max proof_tree:
forall p, InCBV p proof_tree ->
term_size (proj_left p) <= term_size (proj_left (proj_left_max_size proof_tree)).
Lemma InCBV_proj_left_max_size p : InCBV (proj_left_max_size p) p.
Fixpoint max_proj_right_size (proof_tree : cbv) : nat :=
match proof_tree with
| cbv_constr lp _ t _ v => max (value_size v) (maxl (map max_proj_right_size lp))
| cbv_split lp p _ t _ v => max (value_size v) (max (max_proj_right_size p) (maxl (map max_proj_right_size lp)))
| cbv_update _ _ p _ t _ v => max (value_size v) (max_proj_right_size p)
| cbv_read _ t v => value_size v
end.
Lemma judgement_size_le_projs_size p :
max_judgement_size p <= term_size (proj_left (proj_left_max_size p)) + max_proj_right_size p.