(* lt devrait aussi être défini par un let … in, mais ça plante à l'application du lemme et je ne comprends pas pourquoi. *)

(* Specifications: *)
(* Théorème 70 *)
Lemma active_size_bound qic qif cs: forall i sub p c f lv d v, forall pi,
valid_QI qic qif cs ->
let t :=  (fapply f lv) in
let proof_tree := cbv_update i sub p c t d v in
let l:= (map (fun x=> mcs * (term_size t)) lv) in
wf proof_tree -> In pi (activations proof_tree) -> cache_bounded qic qif c ->
judgsize pi <= (max_arity + 1) * (qif f l) + 1.
Lemma active_size_bound_max qic qif cs: forall i s p c f lv d v,
valid_QI qic qif cs ->
let t :=  (fapply f lv) in
let pi := cbv_update i s p c t d v in
let la := (activations pi)  in
let l:= (map (fun x=> mcs * (term_size t)) lv) in
wf pi -> cache_bounded qic qif c -> forall la', incl la' la ->
maxl (map judgsize la') <= (max_arity + 1) * qif f l + 1.
Lemma max_active_size_sublist: forall c c' lp lp',
andl (map wf lp) -> cache_path c c' lp = true -> incl lp' lp ->
(forall p : cbv, In p lp -> wf p ->
max_active_size p <= maxl (map judgsize (activations p))) ->
maxl (map (@max_active_size _ _ _) lp') <=
maxl (map judgsize (flat_map (activations (constructor:=constructor)) lp')).
Lemma max_active_size_is_max: forall pi,
let S := max_active_size pi in
wf pi -> S <= maxl (map judgsize (activations pi)).
Theorem max_active_size_bound qic qif cs: forall i s p c f lv d v,
valid_QI qic qif cs ->
let t :=  (fapply f lv) in
let pi := cbv_update i s p c t d v in
let l:= (map (fun x=> mcs * (term_size t)) lv) in
let S := max_active_size pi in
wf pi -> cache_bounded qic qif c -> S <= (max_arity + 1) * (qif f l) + 1.