Semiconductors - Fermi energy and function As I understand it, the Fermi function $$f(E) = \frac{1}{1+e^{(E-E_f)/(kT)}}$$ gives the probability of finding an electron at a particular energy in a material.
It also has the following property : $$f(E_f+E_0) = 1 - f(E_f-E_0)$$ which means that the probability of finding an electron at an energy $E_0$ above $E_f$ (Fermi energy) is equal to the probability of not finding it an energy $E_0$ below $E_f$.
It is then logical to expect the Fermi energy to be between the valence and conduction band in a metal. For semiconductors however, I have some difficulties to reason about the Fermi energy. Here are my questions : 


*

*In a non-doped semiconductor, $E_f$ is also midway
between the valence and conduction band (in the bandgap). However,
if this "Fermi theory" still applies, wouldn't there be a non-zero
probability of finding an electron immediately just below and above
$E_f$ contradicting with the fact that no electron can be in the
bandgap?

*In a doped semiconductor (let's say n-type) at $0$ $K$, $E_f$ is
    still situated below but closer to the conduction band. As the
    temperature increases, $E_f$ returns midway between the valence and
    conduction band. Why is that?
P.S. : I am not very comfortable with quantum mechanics so I would appreciate if your answers could contain the least possible of it.
 A: 1) The Fermi function tells you the probability that a state with energy $E$ is filled. However, it does not guarantee that such a state exists! You are correct that no states exist within the band gap (assuming a perfect crystal).
So, there is no contradiction: the Fermi function only applies if a state exists, and states don't exist in the gap.
2) The Fermi energy is defined at zero temperature, so you can't talk about the Fermi energy changing as a function of temperature. You're probably interested in is the chemical potential $\mu$, which is temperature dependent and as is equal to $E_f$ at zero temperature. If you're interested in non-zero temperatures, you need to replace $E_f$ with $\mu$ in your definition of the Fermi function.*
$E_f$ also doesn't need to be below the conduction band. You can dope a semiconductor hightly enough that the Fermi energy is in the conduction band ("degenerate doping").
I'm not sure why $\mu$ would go to the middle of the gap as the temperature is increased. I'm not sure it's true. Could you provide some context or a source?
EDIT: I see why the chemical potential would go to the midpoint of the gap, at least for a semiconductor that's not degenerately doped. An explanation is here. I can try to flesh out the explanation if the page is confusing.
*(That said, even at non-zero temperature, people often work with $E_f$ instead of $\mu$: when you convert $E_f$ to a temperature -- the Fermi temperature -- you get temperatures like 10,000 K for many materials, and compared to that, room temperature might as well be absolute zero. For that reason, $E_f$ and $\mu$ sometimes get used interchangeably, even tho they shouldn't.)
A: 1) The reason the Fermi Energy is midway(only true if the valence and conduction band have same parabolic dispersion relation) is the following : 
assume you have N carriers in the valence band at 0K and now you consider T=5K. if  a carrier gets into the conduction band thanks to thermal generation, it should generate a hole in the valence band. 
Note that it is note because there is a non negligible proabailty of finding a carrier in the band gap that there will be a carrier there. Indeed, the number of carriers in an energy level $\varepsilon$ are given by : $n(\varepsilon) = f(\varepsilon)g(\varepsilon)$ where g is the density of states. Since g=0 in the gap there can not be any charges although there is a non zero probability of finding a carrier at that energy at that temperature. 
