  The formation of a two-dimensional electron gas at oxide interfaces as a
consequence of polar discontinuities has generated an enormous amount of
activity due to the variety of interesting effects it gives rise to. Here we
study under what circumstances similar processes can also take place underneath
ferroelectric thin films. We use a simple Landau model to demonstrate that in
the absence of extrinsic screening mechanisms a monodomain phase can be
stabilized in ferroelectric films by means of an electronic reconstruction.
Unlike in the LaAlO$_3$/SrTiO$_3$ heterostructure, the emergence with thickness
of the free charge at the interface is discontinuous. This prediction is
confirmed by performing first principles simulations of free standing slabs of
PbTiO$_3$. The model is also used to predict the response of the system to an
applied electric field, demonstrating that the two-dimensional electron gas can
be switched on and off discontinuously and in a non-volatile fashion.
Furthermore, the reversal of the polarization can be used to switch between a
two-dimensional electron gas and a two-dimensional hole gas, which should, in
principle, have very different transport properties. We discuss the possible
formation of polarization domains and how such configuration competes with the
spontaneous accumulation of free charge at the interfaces.
