Section EnumVal.
Variables (d : unit) (T : finPOrderType d).
Implicit Types (x : T) (A : {pred T}).
Definition enum_rank_in x0 A (Ax0 : x0 \in A) x :=
insubd (Ordinal (@enum_rank_subproof _ x0 A Ax0)) (index x (enum A)).
Definition enum_rank x := @enum_rank_in x T (erefl true) x.
Definition enum_val A i := nth (@enum_default _ A i) (enum A) i.
Prenex Implicits enum_val.
Definition sig : ordsum -> T  := enum_val \o (cast_ord (esym card)).
Definition rank : T -> ordsum := (cast_ord card) \o enum_rank.
Definition sig1 s : 'I_n             := tag (sig s).
Definition sig2 s : 'I_(p_ (sig1 s)) := tagged (sig s).
Definition Rank i (j : 'I_(p_ i))    := rank (Tagged _ j).

Lemma rankEsum p : rank p = \sum_(i < n | (i < tag p)%N) p_ i + tagged p :> nat.