(*
 * Copyright (c) 2009-2011, Andrew Appel, Robert Dockins and Aquinas Hobor.
 *
 *)

Require Import VST.msl.base.
Local Open Scope nat_scope.

Require Import VST.msl.ageable.
Require Import VST.msl.functors.
Require Import VST.msl.predicates_hered.

Import CovariantFunctor.
Import CovariantFunctorLemmas.
Import CovariantFunctorGenerator.

Module Type TY_FUNCTOR_PROP.
  Parameter F : functor.
  Parameter other : Type.
End TY_FUNCTOR_PROP.

Module Type KNOT_HERED.
  Declare Module TF:TY_FUNCTOR_PROP.
  Import TF.

  Parameter knot:Type.
  Parameter ag_knot : ageable knot.
  Existing Instance ag_knot.
  Existing Instance ag_prod.

  Definition predicate := pred (knot * other).

  Parameter squash : (nat * F predicate) -> knot.
  Parameter unsquash : knot -> (nat * F predicate).

  Parameter approx : nat -> predicate -> predicate.

  Axiom squash_unsquash : forall k:knot, squash (unsquash k) = k.
  Axiom unsquash_squash : forall (n:nat) (f:F predicate),
    unsquash (squash (n,f)) = (n, fmap F (approx n) f).

  Axiom approx_spec : forall n p k,
    proj1_sig (approx n p) k = (level k < n /\ proj1_sig p k).

  Axiom knot_level : forall k:knot, level k = fst (unsquash k).

  Axiom knot_age1 : forall k,
    age1 k =
    match unsquash k with
    | (O,_) => None
    | (S n,x) => Some (squash (n,x))
    end.

End KNOT_HERED.

Module KnotHered (TF':TY_FUNCTOR_PROP) : KNOT_HERED with Module TF:=TF'.
  Module TF:=TF'.
  Import TF.

  Definition sinv_prod X := prod X (F X * other -> Prop).

  Definition guppy_sig := (fun T:Type => T * (F T * other -> Prop) -> Prop).
  Definition guppy_ty := sigT guppy_sig.

  Definition guppy_step_ty (Z:guppy_ty) : Type :=
    (sig (fun (x:sinv_prod (projT1 Z)) => projT2 Z x)).

  Definition guppy_step_prop (Z:guppy_ty) (xf:sinv_prod (guppy_step_ty Z)) :=
    forall (k:F (guppy_step_ty Z)) (o:other),
      snd xf (k,o) -> snd (proj1_sig (fst xf)) (fmap F (@fst _ _ oo @proj1_sig _ _) k,o).

  Definition guppy_step (Z:guppy_ty) : guppy_ty :=
    existT guppy_sig (guppy_step_ty Z) (guppy_step_prop Z).

  Definition guppy_base : guppy_ty :=
    existT guppy_sig unit (fun _ => True).

  Fixpoint guppy (n:nat) : guppy_ty :=
    match n with
    | 0    => guppy_base
    | S n' => guppy_step (guppy n')
    end.

  Definition sinv (n:nat) : Type := projT1 (guppy n).
  Definition sinv_prop (n:nat) : prod (sinv n) (F (sinv n) * other -> Prop) -> Prop := projT2 (guppy n).

  Fixpoint floor (m:nat) (n:nat) (p:sinv (m+n)) : sinv n :=
    match m as m' return forall (p : sinv (m'+n)), sinv n with
    | O => fun p => p
    | S m' => fun p => floor m' n (fst (proj1_sig p))
    end p.

  Definition knot := { n:nat & F (sinv n) }.

  Definition k_age1 (k:knot) : option (knot) :=
    match k with
      | (existT _ 0 f) => None
      | (existT _ (S m) f) => Some
          (existT (F oo sinv) m (fmap F (@fst _ _ oo @proj1_sig _ _) f))
    end.

  Definition k_age (k1 k2:knot) := k_age1 k1 = Some k2.

  Definition ko_age1 (x:knot * other) :=
    match k_age1 (fst x) with
    | None => None
    | Some a' => Some (a',snd x)
    end.
  Definition ko_age x y := ko_age1 x = Some y.


  Definition predicate := { p:knot * other -> Prop | hereditary ko_age p }.

  Definition app_sinv (n:nat) (p:sinv (S n)) (x:F (sinv n) * other) :=
    snd (proj1_sig p) x.

  Lemma app_sinv_age : forall n (p:sinv (S (S n))) (f:F (sinv (S n)) * other),
    app_sinv (S n) p f ->
    app_sinv n (fst (proj1_sig p)) (fmap F (@fst _ _ oo @proj1_sig _ _) (fst f), snd f).
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: app_sinv n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) (S n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) (S n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) (S n)))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) (S n))) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) (S n)) x) p)) (@pair (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x))) (@fst (_functor F (sinv (S n))) other f)) (@snd (_functor F (sinv (S n))) other f)) *)
    unfold app_sinv in *.
(* Goal: @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (@fst (@projT1 Type guppy_sig (guppy_step ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy_step ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy_step ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy_step ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) => @projT2 Type guppy_sig (guppy_step ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) x) p))) (@pair (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x))) (@fst (_functor F (sinv (S n))) other f)) (@snd (_functor F (sinv (S n))) other f)) *)
    destruct p; simpl in *; fold guppy in *.
(* Goal: @snd (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) (@fst (guppy_step_ty (guppy n)) (forall _ : prod (_functor F (guppy_step_ty (guppy n))) other, Prop) x)) (@pair (_functor F (@projT1 Type guppy_sig (guppy n))) other (@fmap F (@sig (prod (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x)) (@projT1 Type guppy_sig (guppy n)) (@compose (@sig (prod (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x)) (prod (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop)) (@projT1 Type guppy_sig (guppy n)) (@fst (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x))) (@fst (_functor F (sinv (S n))) other f)) (@snd (_functor F (sinv (S n))) other f)) *)
    apply p; auto.
(* Goal: @snd (guppy_step_ty (guppy n)) (forall _ : prod (_functor F (guppy_step_ty (guppy n))) other, Prop) x (@pair (_functor F (guppy_step_ty (guppy n))) other (@fst (_functor F (sinv (S n))) other f) (@snd (_functor F (sinv (S n))) other f)) *)
    destruct f; auto.
  Qed.

  Section stratifies.
    Variable Q:knot * other -> Prop.
    Variable HQ:hereditary ko_age Q.

    Fixpoint stratifies (n:nat) : sinv n -> Prop :=
    match n as n' return sinv n' -> Prop with
    | 0 => fun _ => True
    | S n' => fun (p:sinv (S n')) =>
          stratifies n' (fst (proj1_sig p)) /\
          forall (k:F (sinv n')) (o:other), snd (proj1_sig p) (k,o) <-> Q (existT (F oo sinv) n' k,o)
    end.

    Lemma stratifies_unique : forall n p1 p2,
      stratifies n p1 ->
      stratifies n p2 ->
      p1 = p2.
    Proof.
(* Goal: forall (n : nat) (p1 p2 : sinv n) (_ : stratifies n p1) (_ : stratifies n p2), @eq (sinv n) p1 p2 *)
      induction n; simpl; intuition.
(* Goal: @eq (sinv O) p1 p2 *)
(* Goal: @eq (sinv (S n)) p1 p2 *)
      destruct p1; destruct p2; auto.
(* Goal: @eq (sinv (S n)) p1 p2 *)
      destruct p1; destruct p2.
(* Goal: @eq (sinv (S n)) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x0 p0) *)
      simpl in *; fold guppy in *.
(* Goal: @eq (sinv (S n)) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x0 p0) *)
      cut (x = x0).
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
      intros.
(* Goal: @eq (sinv (S n)) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x0 p0) *)
(* Goal: @eq (sinv_prod (@projT1 Type guppy_sig (guppy n))) x x0 *)
      revert p p0 H2 H3.
(* Goal: forall (p : @projT2 Type guppy_sig (guppy n) x) (p0 : @projT2 Type guppy_sig (guppy n) x0) (_ : forall (k : _functor F (sinv n)) (o : other), iff (@snd (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop) x (@pair (_functor F (sinv n)) other k o)) (Q (@pair (@sigT nat (@compose nat Type Type (_functor F) sinv)) other (@existT nat (@compose nat Type Type (_functor F) sinv) n k) o))) (_ : forall (k : _functor F (sinv n)) (o : other), iff (@snd (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop) x0 (@pair (_functor F (sinv n)) other k o)) (Q (@pair (@sigT nat (@compose nat Type Type (_functor F) sinv)) other (@existT nat (@compose nat Type Type (_functor F) sinv) n k) o))), @eq (sinv (S n)) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x0 p0) *)
(* Goal: @eq (sinv_prod (@projT1 Type guppy_sig (guppy n))) x x0 *)
      rewrite <- H0.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
      intros.
(* Goal: @eq (sinv (S n)) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p0) *)
(* Goal: @eq (sinv_prod (@projT1 Type guppy_sig (guppy n))) x x0 *)
      replace p0 with p by (apply proof_irr); auto.
(* Goal: @eq (sinv_prod (@projT1 Type guppy_sig (guppy n))) x x0 *)
      destruct x; destruct x0; simpl in *.
(* Goal: @eq (sinv_prod (@projT1 Type guppy_sig (guppy n))) (@pair (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop) p1 P) (@pair (@projT1 Type guppy_sig (guppy n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop) p2 P0) *)
      apply injective_projections; simpl.
(* Goal: @eq (@projT1 Type guppy_sig (guppy n)) p1 p2 *)
(* Goal: @eq (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy n))) other, Prop) P P0 *)
      apply IHn; auto.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
      extensionality; intros.
(* Goal: @eq Prop (P x) (P0 x) *)
      simpl in *.
(* Goal: @eq Prop (P x) (P0 x) *)
      destruct (H2 (fst x) (snd x)); destruct (H3 (fst x) (snd x)).
(* Goal: @eq Prop (P x) (P0 x) *)
      apply prop_ext; destruct x; intuition.
    Qed.

    Definition stratify (n:nat) : { x:sinv n | stratifies n x }.
    Proof.
      induction n.
      exists tt; simpl; exact I.
      assert (HX:
        projT2 (guppy n)
        (proj1_sig IHn, fun v : F (sinv n) * other => Q (existT (F oo sinv) n (fst v),snd v))).
      destruct n.
      simpl; exact I.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
      simpl; intros.
      destruct IHn; simpl.
      simpl in s; destruct s.
(* Goal: @eq (sinv (S n)) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x0 p0) *)
      destruct x; simpl in *; fold guppy in *.
(* Goal: @eq Prop (P x) (P0 x) *)
      destruct x; simpl in *.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
      hnf; simpl; intros.
(* Goal: (fun _f : _functor F predicate => @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) _f) f *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
      rewrite H0.
      eapply HQ.
      2: apply H1.
      simpl; reflexivity.
      exists ((exist (fun x => projT2 (guppy n) x) ( proj1_sig IHn, fun v:F (sinv n) * other => Q (existT (F oo sinv) n (fst v),snd v) ) HX)).
(* Goal: stratifies (unstratify (S n) p) (S n) p *)
      simpl; split.
      destruct IHn; auto.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
      unfold app_sinv; simpl; intros.
      split; trivial.
    Qed.
  End stratifies.

  Lemma decompose_nat : forall (x y:nat), { m:nat & y = (m + S x) } + { ge x y }.
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros x y; revert x; induction y; simpl; intros.
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat O (Init.Nat.add m (S x)))) (ge x O) *)
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
    right; auto with arith.
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
    destruct (IHy x) as [[m H]|H].
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
    left; exists (S m); omega.
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
    destruct (eq_nat_dec x y).
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
    left; exists O; omega.
(* Goal: sumor (@sigT nat (fun m : nat => @eq nat (S y) (Init.Nat.add m (S x)))) (ge x (S y)) *)
    right; omega.
  Qed.

  Definition unstratify (n:nat) (p:sinv n) : knot * other -> Prop := fun w =>
    match w with (existT _ nw w',o) =>
      match decompose_nat nw n with
        | inleft (existT _ m Hm) => snd (proj1_sig (floor m (S nw) (eq_rect  n _ p (m + S nw) Hm))) (w',o)
        | inright H => False
      end
    end.

  Lemma floor_shuffle:
    forall (m1 n : nat)
      (p1 : sinv (m1 + S n)) (H1 : (m1 + S n) = (S m1 + n)),
      floor (S m1) n (eq_rect (m1 + S n) sinv p1 (S m1 + n) H1) = fst (proj1_sig (floor m1 (S n) p1)).
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq (sinv n) (floor (S m1) n (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (Init.Nat.add (S m1) n) H1)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m1 (S n) p1))) *)
    remember (fst (proj1_sig (floor m1 (S n) p1))) as p.
(* Goal: @eq (sinv n) (floor (S m1) n (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (Init.Nat.add (S m1) n) H1)) p *)
    fold guppy in *.
(* Goal: @eq (sinv n) (floor (S m1) n (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (Init.Nat.add (S m1) n) H1)) p *)
    revert n p1 H1 p Heqp.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    induction m1; simpl; intros.
(* Goal: @eq (sinv n) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (@eq_rect nat (S n) sinv p1 (S n) H1))) p *)
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv p1 (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    replace H1 with (refl_equal (S n)) by (apply proof_irr); simpl; auto.
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv p1 (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    assert (m1 + S n = S m1 + n) by omega.
(* Goal: @eq (sinv (S n)) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x p) (@exist (sinv_prod (@projT1 Type guppy_sig (guppy n))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy n)) => @projT2 Type guppy_sig (guppy n) x) x0 p0) *)
    destruct p1 as [[p1 f'] Hp1]; simpl in *; fold guppy in *.
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv (@exist (sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) => @projT2 Type guppy_sig (guppy (Init.Nat.add m1 (S n))) x) (@pair (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) other, Prop) p1 f') Hp1) (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    generalize (IHm1 n p1 H p Heqp).
(* Goal: forall _ : @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (S (Init.Nat.add m1 n)) H)))) p, @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv (@exist (sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) => @projT2 Type guppy_sig (guppy (Init.Nat.add m1 (S n))) x) (@pair (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) other, Prop) p1 f') Hp1) (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    clear.
(* Goal: forall _ : @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (S (Init.Nat.add m1 n)) H)))) p, @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv (@exist (sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) => @projT2 Type guppy_sig (guppy (Init.Nat.add m1 (S n))) x) (@pair (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) other, Prop) p1 f') Hp1) (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    revert Hp1 H1; generalize H.
(* Goal: forall (H : @eq nat (Init.Nat.add m1 (S n)) (S (Init.Nat.add m1 n))) (Hp1 : @projT2 Type guppy_sig (guppy (Init.Nat.add m1 (S n))) (@pair (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) other, Prop) p1 f')) (H1 : @eq nat (S (Init.Nat.add m1 (S n))) (S (S (Init.Nat.add m1 n)))) (_ : @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (S (Init.Nat.add m1 n)) H)))) p), @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv (@exist (sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) => @projT2 Type guppy_sig (guppy (Init.Nat.add m1 (S n))) x) (@pair (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) other, Prop) p1 f') Hp1) (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    revert p1 f'.
(* Goal: @eq (prod nat (_functor F predicate)) (@pair nat (_functor F predicate) n (@fmap F predicate predicate (approx n) (@fmap F predicate predicate (approx (S n)) f))) (unsquash x') *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite H.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    simpl; intros.
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (S (Init.Nat.add m1 n))) sinv (@exist (sinv_prod (guppy_step_ty (guppy (Init.Nat.add m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy (Init.Nat.add m1 n))) => guppy_step_prop (guppy (Init.Nat.add m1 n)) x) (@pair (guppy_step_ty (guppy (Init.Nat.add m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy (Init.Nat.add m1 n)))) other, Prop) p1 f') Hp1) (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    replace H1 with (refl_equal (S (S (m1 + n)))) by (apply proof_irr).
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) p1))) p *)
    replace H0 with (refl_equal (S (m1+n))) in H2 by (apply proof_irr).
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) p1))) p *)
    simpl in H2.
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) p1))) p *)
    trivial.
  Qed.

  Lemma unstratify_hered : forall n p,
    hereditary ko_age (unstratify n p).
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    hnf; intros k k'; intros.
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    simpl in H.
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    destruct k.
(* Goal: @eq (option knot) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) (@Some knot k') *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    destruct k as [x f]. destruct x.
(* Goal: @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    discriminate.
    destruct k' as [k' o'].
    assert (o = o').
    hnf in H.
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    simpl in H.
(* Goal: @eq nat (level (@existT nat (fun n : nat => _functor F (sinv n)) (S x) _f)) (S (level y)) *)
    inv H. auto.
    subst o'.
    replace k' with
      (existT (F oo sinv) x (fmap F (@fst _ _ oo @proj1_sig _ _ ) f)).
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    2: inversion H; auto.
(* Goal: stratifies (unstratify n p) n p *)
    clear H.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    case_eq (decompose_nat x n); intros.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    case_eq (decompose_nat (S x) n); intros.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
    destruct n.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    elimtype False; omega.
    assert (S x1 = x0) by omega; subst x0.
    revert H0.
    unfold unstratify.
    rewrite H; rewrite H1.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    generalize e e0; revert p; rewrite e0; intros.
    rewrite floor_shuffle.
    replace e2 with (refl_equal (x1 + S (S x))) in H0;
      simpl eq_rect in H0.
    2: apply proof_irr.
    change f with (fst (f,o)).
    change o with (snd (f,o)).
    eapply app_sinv_age; apply H0.

    revert H0.
    unfold unstratify.
    rewrite H; rewrite H1.
(* Goal: iff (and (lt (level (@fst knot other w)) n) (and (lt (level (@fst knot other w)) (S n)) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w))) (and (lt (level (@fst knot other w)) n) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w)) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    intuition.

(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    case_eq (decompose_nat (S x) n); intros.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    elimtype False; omega.
    revert H0.
    unfold unstratify.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    rewrite H; rewrite H1; auto.
  Qed.

  Lemma unstratify_Q : forall n (p:sinv n) Q,
    stratifies Q n p ->
    forall (k:knot) o,
      projT1 k < n ->
      (unstratify n p (k,o) <-> Q (k,o)).
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
    unfold unstratify.
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    destruct k.
    destruct (decompose_nat x n).
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
    simpl in H0.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    2: simpl in *; elimtype False; omega.
    clear H0.
    revert p H.
    generalize e.
    rewrite e.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
    replace e0 with (refl_equal (x0 + S x)) by apply proof_irr.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
    clear e e0.
    revert p H.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    induction x0; simpl; intros.
    destruct H.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
    destruct H.
    apply IHx0.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
  Qed.

  Lemma stratifies_unstratify_more :
    forall (n m1 m2:nat) (p1:sinv (m1+n)) (p2:sinv (m2+n)),
      floor m1 n p1 = floor m2 n p2 ->
      (stratifies (unstratify (m1+n) p1) n (floor m1 n p1) ->
       stratifies (unstratify (m2+n) p2) n (floor m2 n p2)).
  Proof.
(* Goal: iff (and (lt (level (@fst knot other w)) n) (and (lt (level (@fst knot other w)) (S n)) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w))) (and (lt (level (@fst knot other w)) n) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w)) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    induction n; intuition.
    split.
    assert (m2 + S n = S m2 + n) by omega.
    erewrite <- floor_shuffle.
    instantiate (1:=H1).
    replace (unstratify (m2 + S n) p2)
      with (unstratify (S m2 + n) (eq_rect (m2 + S n) sinv p2 (S m2 + n) H1)).
(* Goal: @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv p1 (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    assert (m1 + S n = S m1 + n) by omega.
    eapply (IHn (S m1) (S m2)
      (eq_rect (m1 + S n) sinv p1 (S m1 + n) H2)).
    rewrite floor_shuffle.
    rewrite floor_shuffle.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    rewrite H; auto.
    clear - H0.
    rewrite floor_shuffle.
    simpl in H0.
    destruct H0.
    clear H0.
    revert p1 H.
    generalize H2.
    rewrite <- H2.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    replace H0 with (refl_equal (m1 + S n)) by apply proof_irr; auto.
(* Goal: forall _ : @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (S (Init.Nat.add m1 n)) H)))) p, @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv (@exist (sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) => @projT2 Type guppy_sig (guppy (Init.Nat.add m1 (S n))) x) (@pair (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) other, Prop) p1 f') Hp1) (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    clear.
    revert p2.
    generalize H1.
    rewrite H1.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    replace H0 with (refl_equal (S m2 + n)) by apply proof_irr; auto.

(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
    destruct (decompose_nat n (m2 + S n)).
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
    assert (m2 = x).
    omega.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor x (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add x (S n)) e))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    subst x.
    replace e with (refl_equal (m2 + S n)).
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    simpl; tauto.
    apply proof_irr.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    elimtype False; omega.
  Qed.

  Lemma stratify_unstratify : forall n p H,
    proj1_sig (stratify (unstratify n p) H n) = p.
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq (sinv n) (@proj1_sig (sinv n) (fun x : sinv n => stratifies (unstratify n p) n x) (stratify (unstratify n p) H n)) p *)
    apply stratifies_unique with (unstratify n p).
(* Goal: stratifies (unstratify n p) n (@proj1_sig (sinv n) (fun x : sinv n => stratifies (unstratify n p) n x) (stratify (unstratify n p) H n)) *)
(* Goal: stratifies (unstratify n p) n p *)
    destruct (stratify _ H n).
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    simpl; auto.
(* Goal: stratifies (unstratify n p) n p *)
    clear H.
    revert p; induction n.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    simpl; intros; auto.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: stratifies (unstratify (S n) p) (S n) p *)
    simpl; split.

(* Goal: stratifies (unstratify (S n) p) n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p)) *)
(* Goal: forall (k : _functor F (sinv n)) (o : other), iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) match decompose_nat n (S n) with | inleft (existT _ m Hm as s) => @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o) | inright H => False end *)
    assert (stratifies (unstratify n (fst (proj1_sig p))) n (fst (proj1_sig p))).
(* Goal: stratifies (unstratify n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p))) n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p)) *)
(* Goal: stratifies (unstratify (S n) p) n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p)) *)
(* Goal: forall (k : _functor F (sinv n)) (o : other), iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) match decompose_nat n (S n) with | inleft (existT _ m Hm as s) => @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o) | inright H => False end *)
    apply IHn.
(* Goal: stratifies (unstratify (S n) p) n (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p)) *)
(* Goal: forall (k : _functor F (sinv n)) (o : other), iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) match decompose_nat n (S n) with | inleft (existT _ m Hm as s) => @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o) | inright H => False end *)
    apply (stratifies_unstratify_more n 0 1 (fst (proj1_sig p)) p).
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    simpl; auto.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.

(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) match decompose_nat n (S n) with | inleft (existT _ m Hm as s) => @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o) | inright H => False end *)
    destruct (decompose_nat n (S n)).
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
    assert (x = 0) by omega.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor x (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add x (S n)) e))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    subst x.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (@eq_rect nat (S n) sinv p (S n) e)) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    simpl in e.
    replace e with (refl_equal (S n)) by apply proof_irr.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    split; auto.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    elimtype False; omega.
  Qed.


  Definition strat (n:nat) (p:predicate) : sinv n :=
    proj1_sig (stratify (proj1_sig p) (proj2_sig p) n).

  Definition unstrat (n:nat) (p:sinv n) : predicate :=
    exist (hereditary ko_age) (unstratify n p) (unstratify_hered n p).

  Definition squash (x:nat * F predicate) : knot :=
    match x with (n,f) => existT (F oo sinv) n (fmap F (strat n) f) end.

  Definition unsquash (k:knot) : nat * F predicate :=
    match k with existT _ n f => (n, fmap F (unstrat n) f) end.

  Definition level (x:knot) : nat := fst (unsquash x).
  Program Definition approx (n:nat) (p:predicate) : predicate :=
     fun w => level (fst w) < n /\ p w.
  Next Obligation.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    hnf; simpl; intros.
(* Goal: iff (and (lt (level (@fst knot other w)) n) (and (lt (level (@fst knot other w)) (S n)) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w))) (and (lt (level (@fst knot other w)) n) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w)) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    intuition.
    unfold level in *.
    unfold unsquash in *.
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    destruct a0; simpl in H.
(* Goal: @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    destruct x; try discriminate.
(* Goal: @eq nat (level (@existT nat (fun n : nat => _functor F (sinv n)) (S x) _f)) (S (level y)) *)
    inv H.
    simpl in *; omega.
(* Goal: @eq Prop (P x) (P0 x) *)
    destruct p; simpl in *.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    eapply h; eauto.
  Qed.

  Lemma strat_unstrat : forall n,
    strat n oo unstrat n = id (sinv n).
  Proof.
(* Goal: forall n : nat, @eq (forall _ : sinv n, sinv n) (@compose (sinv n) predicate (sinv n) (strat n) (unstrat n)) (id (sinv n)) *)
    intros; extensionality p.
(* Goal: @eq (sinv n) (@compose (sinv n) predicate (sinv n) (strat n) (unstrat n) p) (id (sinv n) p) *)
    unfold compose, id.
(* Goal: @eq (sinv n) (strat n (unstrat n p)) p *)
    unfold strat, unstrat.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
(* Goal: @eq (sinv n) (@proj1_sig (sinv n) (fun x : sinv n => stratifies (unstratify n p) n x) (stratify (unstratify n p) (unstratify_hered n p) n)) p *)
    rewrite stratify_unstratify.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
  Qed.

  Lemma predicate_eq : forall (p1 p2:predicate),
    proj1_sig p1 = proj1_sig p2 ->
    p1 = p2.
  Proof.
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    intros; destruct p1; destruct p2; simpl in H.
(* Goal: @eq predicate (@exist (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) x h) (@exist (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) x0 h0) *)
    subst x0.
    replace h0 with h by apply proof_irr.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
  Qed.

  Lemma unstrat_strat : forall n,
    unstrat n oo strat n = approx n.
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
    extensionality.
    unfold compose.
    unfold unstrat, strat.
    unfold approx.
(* Goal: @eq predicate (@compose predicate predicate predicate (approx n) (approx (S n)) p) (approx n p) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    apply predicate_eq.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
    extensionality k.
(* Goal: iff (and (lt (level (@fst knot other w)) n) (and (lt (level (@fst knot other w)) (S n)) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w))) (and (lt (level (@fst knot other w)) n) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w)) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    apply prop_ext; intuition.
    unfold unstratify in H.
    destruct a.
    destruct (decompose_nat x0 n).
    unfold level.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
    omega.
    elim H.
    rewrite <- unstratify_Q.
    apply H.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    destruct (stratify (proj1_sig x) (proj2_sig x) n); auto.
    unfold unstratify in H.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    destruct a; simpl.
    destruct (decompose_nat x0 n).
    destruct s; omega.
    elim H.
    rewrite unstratify_Q.
    apply H1.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    destruct (stratify (proj1_sig x) (proj2_sig x) n); auto.
    unfold level in H0.
(* Goal: @eq Prop (P x) (P0 x) *)
    destruct a; simpl in *.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
  Qed.

  Lemma squash_unsquash : forall k, squash (unsquash k) = k.
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    destruct k as [x f]; simpl.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (_functor F (sinv x)) (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv x) predicate (unstrat x) f)) f *)
    change ((fmap F (strat x) oo fmap F (unstrat x)) f = f).
(* Goal: @eq (_functor F (sinv x)) (@compose (_functor F (sinv (S x))) (_functor F predicate) (_functor F (sinv x)) (@fmap F predicate (sinv x) (strat x)) (@fmap F (sinv (S x)) predicate (unstrat (S x))) f) (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) f) *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    rewrite fmap_comp.
(* Goal: @eq (_functor F (sinv x)) (@fmap F (sinv x) (sinv x) (@compose (sinv x) predicate (sinv x) (strat x) (unstrat x)) f) f *)
    rewrite strat_unstrat.
(* Goal: @eq (_functor F (sinv x)) (@fmap F (sinv x) (sinv x) (id (sinv x)) f) f *)
    rewrite fmap_id.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
  Qed.

  Lemma unsquash_squash : forall n f,
    unsquash (squash (n,f)) = (n, fmap F (approx n) f).
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq (prod nat (_functor F predicate)) (unsquash (squash (@pair nat (_functor F predicate) n f))) (@pair nat (_functor F predicate) n (@fmap F predicate predicate (approx n) f)) *)
    unfold unsquash, squash.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (_functor F predicate) (@fmap F (sinv n) predicate (unstrat n) (@fmap F predicate (sinv n) (strat n) f)) (@fmap F predicate predicate (approx n) f) *)
    change ((fmap F (unstrat n) oo fmap F (strat n)) f = fmap F (approx n) f).
(* Goal: @eq (_functor F (sinv x)) (@compose (_functor F (sinv (S x))) (_functor F predicate) (_functor F (sinv x)) (@fmap F predicate (sinv x) (strat x)) (@fmap F (sinv (S x)) predicate (unstrat (S x))) f) (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) f) *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    rewrite fmap_comp.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate (sinv n) predicate (unstrat n) (strat n)) f) (@fmap F predicate predicate (approx n) f) *)
    rewrite unstrat_strat.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
  Qed.

  Lemma strat_unstrat_Sx : forall x,
    @fst _ _ oo @proj1_sig _ _ = strat x oo unstrat (S x).
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
    extensionality k.
    change (sinv (S x)) in k.
    unfold compose.
(* Goal: @eq (sinv n) (strat n (unstrat n p)) p *)
    unfold strat, unstrat.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
    apply stratifies_unique with (unstratify x (fst (proj1_sig k))).
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    revert k; induction x; simpl; auto.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
    split.
    eapply (stratifies_unstratify_more x 0 1 ).
    simpl; reflexivity.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
    apply IHx.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
    destruct (decompose_nat x (S x)).
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) (let (m, Hm) := s in @snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) (floor m (S n) (@eq_rect nat (S n) sinv p (Init.Nat.add m (S n)) Hm))) (@pair (_functor F (sinv n)) other k o)) *)
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    destruct s.
(* Goal: @eq predicate (@exist (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) x h) (@exist (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) x0 h0) *)
    assert (x0 = 0) by omega; subst x0.
(* Goal: @eq Prop (P x) (P0 x) *)
    simpl in *.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    replace e with (refl_equal (S x)) by apply proof_irr; simpl.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    tauto.
(* Goal: iff (@snd (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n))) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) n) x) p) (@pair (_functor F (sinv n)) other k o)) False *)
    elimtype False; omega.
    destruct (stratify (unstratify (S x) k)
      (unstratify_hered (S x) k) x).
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    simpl; auto.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    cut (x0 = (fst (proj1_sig k))); intros.
(* Goal: @eq predicate (@exist (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) x h) (@exist (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) x0 h0) *)
    subst x0.
    eapply (stratifies_unstratify_more x 1 0).
    simpl; reflexivity.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    simpl; auto.
    eapply stratifies_unique.
    apply s.
    eapply (stratifies_unstratify_more x 0 1).
    simpl; reflexivity.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
    generalize (fst (proj1_sig k) : sinv x).
(* Goal: forall _ : @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (Init.Nat.add m1 (S n)) sinv p1 (S (Init.Nat.add m1 n)) H)))) p, @eq (sinv n) (floor m1 n (@fst (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => @projT2 Type guppy_sig (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@fst (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) (forall _ : prod (_functor F (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) other, Prop) (@proj1_sig (sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)))) (fun x : sinv_prod (guppy_step_ty (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n))) => guppy_step_prop (guppy ((fix add (n m : nat) {struct n} : nat := match n with | O => m | S p => S (add p m) end) m1 n)) x) (@eq_rect nat (S (Init.Nat.add m1 (S n))) sinv (@exist (sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) (fun x : sinv_prod (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) => @projT2 Type guppy_sig (guppy (Init.Nat.add m1 (S n))) x) (@pair (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n)))) (forall _ : prod (_functor F (@projT1 Type guppy_sig (guppy (Init.Nat.add m1 (S n))))) other, Prop) p1 f') Hp1) (S (S (Init.Nat.add m1 n))) H1)))))) p *)
    clear.
(* Goal: iff (and (lt (level (@fst knot other w)) n) (and (lt (level (@fst knot other w)) (S n)) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w))) (and (lt (level (@fst knot other w)) n) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w)) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    induction x; simpl; intuition.
    eapply (stratifies_unstratify_more x 0 1).
    simpl; reflexivity.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
    apply IHx.
    destruct (decompose_nat x (S x)).
    destruct s0.
    assert (x0 = 0) by omega; subst.
(* Goal: @eq Prop (P x) (P0 x) *)
    simpl in *.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    replace e with (refl_equal (S x)); simpl; auto.
    apply proof_irr.
    omega.
    destruct (decompose_nat x (S x)).
    destruct s0.
    assert (x0 = 0) by omega; subst.
(* Goal: @eq Prop (P x) (P0 x) *)
    simpl in *.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    replace e with (refl_equal (S x)) in H; simpl; auto.
    apply proof_irr.
    elim H.
  Qed.

  Lemma unsquash_inj : forall k k',
    unsquash k = unsquash k' -> k = k'.
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq knot k k' *)
    rewrite <- (squash_unsquash k).
(* Goal: @eq knot (squash (unsquash k)) k' *)
    rewrite <- (squash_unsquash k').
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    congruence.
  Qed.

  Lemma knot_age_age1 : forall k k',
    k_age1 k = Some k' <->
    match unsquash k with
    | (O,_) => None
    | (S n,x) => Some (squash (n,x))
    end = Some k'.
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    split; intros.
(* Goal: @eq (option knot) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) (@Some knot k') *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    unfold k_age1 in H.
(* Goal: @eq (option knot) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) (@Some knot k') *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    unfold unsquash in H.
(* Goal: @eq (option knot) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) (@Some knot k') *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    destruct k as [x f].
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    destruct x; auto.
(* Goal: @eq nat (level (@existT nat (fun n : nat => _functor F (sinv n)) (S x) _f)) (S (level y)) *)
    inv H.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
    change (fmap F (strat x) (fmap F (unstrat (S x)) f))
      with ((fmap F (strat x) oo fmap F (unstrat (S x))) f).
(* Goal: @eq (_functor F (sinv x)) (@compose (_functor F (sinv (S x))) (_functor F predicate) (_functor F (sinv x)) (@fmap F predicate (sinv x) (strat x)) (@fmap F (sinv (S x)) predicate (unstrat (S x))) f) (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) f) *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    rewrite fmap_comp.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (forall _ : sinv (S x), sinv x) (@compose (sinv (S x)) predicate (sinv x) (strat x) (unstrat (S x))) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    symmetry.
(* Goal: @eq (forall _ : sinv (S x), sinv x) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) (@compose (sinv (S x)) predicate (sinv x) (strat x) (unstrat (S x))) *)
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    apply (strat_unstrat_Sx x).

(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    simpl in H.
(* Goal: @eq (option knot) (k_age1 k) (@Some knot k') *)
    destruct k.
(* Goal: forall _ : @eq (option knot) (match x return (forall _ : _functor F (sinv x), option knot) with | O => fun _ : _functor F (sinv O) => @None knot | S m => fun f : _functor F (sinv (S m)) => @Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) m (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m) x)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m) x)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m) x))) f)) end _f) (@None knot), @eq (option knot) (@None knot) match x with | O => @None knot | S n => @Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) n (@fmap F predicate (sinv n) (strat n) (@fmap F (sinv x) predicate (unstrat x) _f))) end *)
    destruct x.
(* Goal: @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    discriminate.
(* Goal: @eq nat (level (@existT nat (fun n : nat => _functor F (sinv n)) (S x) _f)) (S (level y)) *)
    inv H.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    hnf; simpl.
(* Goal: @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    unfold k_age1.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f) (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)) *)
    rewrite strat_unstrat_Sx.
(* Goal: @eq (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (sinv (S x)) predicate (sinv x) (strat x) (unstrat (S x))) _f) (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)) *)
    rewrite <- fmap_comp.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
  Qed.

  Program Instance ag_knot : ageable knot :=
  { age1 := k_age1
  ; level := level
  }.
  Next Obligation.
(* Goal: ageable_facts knot level k_age1 *)
    econstructor.
    (* unage *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    destruct (unsquash x') as [n f] eqn:?H; intros.
(* Goal: @ex knot (fun x : knot => @eq (option knot) (k_age1 x) (@Some knot x')) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    exists (squash (S n, f)).
(* Goal: @eq (option knot) (k_age1 (squash (@pair nat (_functor F predicate) (S n) f))) (@Some knot x') *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite knot_age_age1.
(* Goal: @eq (prod nat (_functor F predicate)) (unsquash (squash (@pair nat (_functor F predicate) n (@fmap F predicate predicate (approx (S n)) f)))) (unsquash x') *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite unsquash_squash.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq knot (squash (@pair nat (_functor F predicate) n (@fmap F predicate predicate (approx (S n)) f))) x' *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    apply unsquash_inj.
(* Goal: @eq (prod nat (_functor F predicate)) (unsquash (squash (@pair nat (_functor F predicate) n (@fmap F predicate predicate (approx (S n)) f)))) (unsquash x') *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite unsquash_squash.
(* Goal: @eq (prod nat (_functor F predicate)) (@pair nat (_functor F predicate) n (@fmap F predicate predicate (approx n) (@fmap F predicate predicate (approx (S n)) f))) (unsquash x') *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite H.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (approx n) (@fmap F predicate predicate (approx (S n)) f)) f *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    cut (f = fmap F (approx n) f).
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (approx n) (@fmap F predicate predicate (approx (S n)) f)) f *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite fmap_app.
(* Goal: (fun _f : _functor F predicate => @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) _f) f *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    pattern f at 2. rewrite H0.
(* Goal: @eq (_functor F predicate) (@fmap F predicate predicate (@compose predicate predicate predicate (approx n) (approx (S n))) f) (@fmap F predicate predicate (approx n) f) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    f_equal.
(* Goal: @eq (forall _ : predicate, predicate) (@compose predicate predicate predicate (approx n) (approx (S n))) (approx n) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    extensionality p.
(* Goal: @eq predicate (@compose predicate predicate predicate (approx n) (approx (S n)) p) (approx n p) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    apply predicate_eq.
(* Goal: @eq (forall _ : prod knot other, Prop) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) (@compose predicate predicate predicate (approx n) (approx (S n)) p)) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) (approx n p)) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    extensionality w.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    simpl. apply prop_ext.
(* Goal: iff (and (lt (level (@fst knot other w)) n) (and (lt (level (@fst knot other w)) (S n)) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w))) (and (lt (level (@fst knot other w)) n) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p w)) *)
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    intuition.
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    generalize H; intro.
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite <- (squash_unsquash x') in H.
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite H0 in H.
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    rewrite unsquash_squash in H.
(* Goal: @eq (_functor F predicate) f (@fmap F predicate predicate (approx n) f) *)
(* Goal: forall x : knot, iff (@eq (option knot) (k_age1 x) (@None knot)) (@eq nat (level x) O) *)
(* Goal: forall (x y : knot) (_ : @eq (option knot) (k_age1 x) (@Some knot y)), @eq nat (level x) (S (level y)) *)
    congruence.

    (* level 0 *)
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    intro x. destruct x; simpl.
(* Goal: @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    destruct x; intuition; discriminate.

    (* level S *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros. destruct x; simpl in *.
(* Goal: forall _ : @eq (option knot) (match x return (forall _ : _functor F (sinv x), option knot) with | O => fun _ : _functor F (sinv O) => @None knot | S m => fun f : _functor F (sinv (S m)) => @Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) m (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m) x)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m) x)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m))) other, Prop)) (fun x : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) m) x))) f)) end _f) (@None knot), @eq (option knot) (@None knot) match x with | O => @None knot | S n => @Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) n (@fmap F predicate (sinv n) (strat n) (@fmap F (sinv x) predicate (unstrat x) _f))) end *)
    destruct x. discriminate.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    inv H. simpl. auto.
  Qed.

  Existing Instance ag_prod.

  Lemma approx_spec : forall n p (k:knot * other),
    proj1_sig (approx n p) k = (ageable.level k < n /\ proj1_sig p k).
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros.
(* Goal: @eq Prop (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) (approx n p) k) (and (lt (@ageable.level (prod knot other) (ag_prod knot other ag_knot) k) n) (@proj1_sig (forall _ : prod knot other, Prop) (fun p : forall _ : prod knot other, Prop => @hereditary (prod knot other) ko_age p) p k)) *)
    apply prop_ext.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    unfold approx; simpl.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intuition; simpl in *; auto.
  Qed.

  Lemma knot_level : forall k:knot, level k = fst (unsquash k).
  Proof. reflexivity. Qed.

  Lemma knot_age1 : forall k,
    age1 k =
    match unsquash k with
    | (O,_) => None
    | (S n,x) => Some (squash (n,x))
    end.
  Proof.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros. simpl.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    case_eq (k_age1 k). intros.
(* Goal: @eq (option knot) (@Some knot k0) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) n (@fmap F predicate (sinv n) (strat n) x)) end) *)
(* Goal: forall _ : @eq (option knot) (k_age1 k) (@None knot), @eq (option knot) (@None knot) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) n (@fmap F predicate (sinv n) (strat n) x)) end) *)
    rewrite knot_age_age1 in H.
(* Goal: forall _ : @eq (option knot) (@None knot) (@None knot), @eq (option knot) (@None knot) (@None knot) *)
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    auto.
(* Goal: @eq (option knot) (@age1 knot ag_knot k) (let (n0, x) := unsquash k in match n0 with | O => @None knot | S n => @Some knot (squash (@pair nat (_functor F predicate) n x)) end) *)
    destruct k; simpl. destruct x. auto.
(* Goal: forall _ : @eq (option knot) (@Some (@sigT nat (@compose nat Type Type (_functor F) sinv)) (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@compose (@sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0)) (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (@fst (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (@proj1_sig (prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) (forall _ : prod (_functor F (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x))) other, Prop)) (fun x0 : sinv_prod (@projT1 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x)) => @projT2 Type guppy_sig ((fix guppy (n : nat) : guppy_ty := match n with | O => guppy_base | S n' => guppy_step (guppy n') end) x) x0))) _f))) (@None knot), @eq (option knot) (@None knot) (@Some knot (@existT nat (@compose nat Type Type (_functor F) sinv) x (@fmap F predicate (sinv x) (strat x) (@fmap F (sinv (S x)) predicate (unstrat (S x)) _f)))) *)
    intros. discriminate.
  Qed.

End KnotHered.
