  We study definably amenable NIP groups. We develop a theory of generics,
showing that various definitions considered previously coincide, and study
invariant measures. Applications include: characterization of regular ergodic
measures, a proof of the conjecture of Petrykowski connecting existence of
bounded orbits with definable amenability in the NIP case, and the Ellis group
conjecture of Newelski and Pillay connecting the model-theoretic connected
component of an NIP group with the ideal subgroup of its Ellis enveloping
semigroup.
