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.
hnf; simpl; intros.
intuition.
unfold level in *.
unfold unsquash in *.
destruct a0; simpl in H.
destruct x; try discriminate.
inv H.
simpl in *; omega.
destruct p; simpl in *.
eapply h; eauto.
Qed.

Lemma strat_unstrat : forall n,
strat n oo unstrat n = id (sinv n).