Fixpoint composeOptN' {A} (f : A -> option A) n x :=
match n with
| 0 => Some x
| S n =>
match composeOptN' f n x with
| Some y => f y
| None => None
end
end.

Lemma age_to_join_eq {A}  {JA: Join A}{PA: Perm_alg A}{agA: ageable A}{AgeA: Age_alg A} :
forall k x1 x2 x3,
join x1 x2 x3 ->
k <= level x3 ->
join (age_to k x1) (age_to k x2) (age_to k x3).