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.

(* Specifications: *)
Lemma composeOptN_assoc_aux_None {A} (f : A -> option A) n x : f x = None -> match composeOptN f n x with | Some x => f x | None => None end = None.
Lemma composeOptN_assoc_aux_Some {A} (f : A -> option A) n x y : f x = Some y -> match composeOptN f n x with | Some x => f x | None => None end = composeOptN f n y.
Lemma composeOptN_assoc {A} (f : A -> option A) n x : composeOptN f n x = composeOptN' f n x.
Lemma age_by_ageN {A} `{agA : ageable A} n (x : A) : n <= level x -> ageN n x = Some (age_by n x).
Lemma age_to_ageN {A} `{agA : ageable A} n (x : A) : ageN (level x - n) x = Some (age_to n x).
Lemma age_by_1 {A} {_ : ageable A} x : 0 < level x -> age x (age_by 1 x).
Lemma age_to_1 {A} {_ : ageable A} n x : level x = S n -> age x (age_to n x).
Lemma age_to_identy {A} `{asaA: Age_alg A}: forall k phi, identity phi -> identity (age_to k phi).
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).