  We generalize the results on existence and uniqueness of integrals from
compact groups and Hopf algebras in a pure (co)algebraic setting, and find a
series of new results on (quasi)-co-Frobenius and semiperfect coalgebras. For a
coalgebra $C$, we introduce the generalized space of integrals
$\int_M=\Hom^C(C,M)$ associated to a right $C$-comodule $M$ and study
connections between "uniqueness of integrals" $\dim(\int_M)\leq \dim(M)$ and
"existence of integrals" $\dim(\int_M)\geq \dim(M)$ for all $M$ and
representation theoretic properties of $C$: (quasi)-co-Frobenius, semiperfect.
We show that a coalgebra is co-Frobenius if and only if existence and
uniqueness of integrals holds for any finite dimensional $M$. We give the
interpretation for $\int_M$ for the coalgebra of representative functions of a
compact group - they will be "quantum"-invariant vector integrals. As
applications, new proofs of well known characterizations of co-Frobenius
coalgebras and Hopf algebras are obtained, as well as the uniqueness of
integrals in Hopf algebras. We also give the consequences for the
representation theory of infinite dimensional algebras. We give an extensive
class of examples which show that the results of the paper are the best
possible. These examples are then used to give all the previously unknown
connections between the various important classes of coalgebras appearing in
literature.
