  Data shaping is a coding technique that has been proposed to increase the
lifetime of flash memory devices. Several data shaping codes have been
described in recent work, including endurance codes and direct shaping codes
for structured data. In this paper, we study information-theoretic properties
of a general class of data shaping codes and prove a separation theorem stating
that optimal data shaping can be achieved by the concatenation of optimal
lossless compression with optimal endurance coding. We also determine the
expansion factor that minimizes the total wear cost. Finally, we analyze the
performance of direct shaping codes and establish a condition for their
optimality.
