A question about the sampling theorem Let's say I have a signal, containing frequencies up to $30$ kHZ.

I am sampling this signal at $40$ kHz with infinite bit depth (just for theory).

Will I be able to recover exactly all the frequencies up to $20$ kHZ , or is that the signal must  only contain frequencies below $20$ kHZ to get the exact magnitudes of the frequencies up to $20$ kHZ ? In other words, will frequencies above $20$ kHZ introduce uncertainty about those below $20$ kHZ ?
If you sample your signal with $f_s=40\,\text{kHz}$ then the band between 20kHz and 30kHz will be folded back to the band between 10kHz and 20kHz. So aliasing will affect the upper half of your spectrum after sampling, i.e. the band between 10 and 20kHz. The lower band from DC to 10kHz will not be corrupted by aliasing.