how is the expectation of the empirical error based on an i.i.d. sample S is equal to the generalization error? I am on the 28 page of the book called "foundations of machine learning" by M.Mohri which states that for a fixed hypothesis h,the expected value of the empirical error is equal to generalization error.I am a bit confused because the true error(generalization error) is based on the whole input space X,where as the empirical error is based on a sample drawn from X.Also in the book linearity of expectation is taken into consideration,How it can be applied to prove that expected value of empirical error is equal to true error.

also here in the above image,it is written "for any x in sample S" and in the immediate next line they have taken the whole input space into consideration(x belongs to D and not D^m).
 A: 
I am a bit confused because the true error(generalization error) is
based on the whole input space X,where as the empirical error is based
on a sample drawn from X

Intuitively, if you were to draw numerous sample sets of size $m$ (i.e. $\mathcal S$), from $\mathcal D^m$, the average of the the empirical errors estimated from each of them will be close to the true mean, and it'll be even closer if you have more and more sets. So, it's not a statistic calculated from a single sample but a collection of samples. This is quite similar with the simple fact that the expected value of the sample mean is equal to true mean of the distribution (when it's defined), i.e. $E[\bar X]=\mu$.

also here in the above image,it is written "for any x in sample S" and
in the immediate next line they have taken the whole input space into
consideration(x belongs to D and not D^m).

$x\sim \mathcal D$ because $\mathcal D$ is the input space, but $\mathcal D^m$ is the space of sample sets, e.g. $(x_1,x_2...x_m)$ is a sample set.
