Section Bounds.
Variables variable function constructor : Type.
Variable variable_eq_dec : forall (x1 x2 : variable), {x1=x2}+{x1<>x2}.
Variable function_eq_dec : forall (x1 x2 : function), {x1=x2}+{x1<>x2}.
Variable constructor_eq_dec : forall (x1 x2 : constructor), {x1=x2}+{x1<>x2}.
Variable max_arity : nat.
Notation rule := (Syntax.rule variable function constructor).
Notation term := (Syntax.term variable function constructor).
Notation value := (Syntax.value constructor).
Notation cbv := (CBV_cache.cbv variable function constructor).
Variable prog : list rule.
Variable rule_default : rule.
Variable subst_default : variable -> value.
Notation assoc_cache := (assoc (term_beq variable_eq_dec function_eq_dec constructor_eq_dec)).
Notation wf :=
(CBV_cache.wf variable_eq_dec function_eq_dec constructor_eq_dec rule_default prog max_arity).
Variable rank: function -> nat.
Variable max_rank : nat.
Hypothesis pos_max_rank : 0 < max_rank.
Hypothesis max_rank_is_max_rank : forall f, rank f <= max_rank.
Notation PPO_prog := (Ordering.PPO_prog prog rank).
(* Proposition 7 *)
Definition activations_at_rank (rk: nat) (p : cbv) : list cbv :=
filter (fun p => beq_nat rk (activation_rank rank p)) (activations p).

Lemma activations_at_rank_wf (rk: nat) (p p': cbv) :
wf p ->
In p' (activations_at_rank rk p) ->
wf p'.