How are music downloads 'upsampled'?

When I download music from iTunes, it comes in at maybe a 4mb file. When I change it to an 'Apple Lossless' file, it becomes a 20mb file. Where does that new data come from?
New data can not be created. Upsampling simply uses an algorithm to flll in additional data points. It is simply an educated guess.
Arh is correct, there is no sonic advantage in converting from an iTunes
native file to Apple Lossless. When the data was stripped away to create a
smaller file there is no way to get back the original fidelity by converting
to a different format and larger file.
Can't have what is not there. That is why the hi res stuff is always better. Apple I understand is working on a iTunes hi res service.
No use in converting mp3 to apple lossless just uses up more hard drive space. You could even go all out and convert to 24/192. I have to wonder if that is all they have done with some of the hi Rez downloads they are selling now. I have closely compared some and cannot hear a bit of difference. Just another way for the record companies to try and screw us.
So is the smaller AAC file top quality as Apple claims?

There's no universal definition of 'top quality'. The claim might make some sense if it were qualified by saying it's the best quality you can get at a given file size and bit rate but even then you'd never get universal agreement on that.

Every format from the lowest resolution mp3 to the latest 'high res' files are compromises of convenience versus quality. You pick what works given your storage space, the resolution of your listening device or the streaming speed you have available.

That's not a criticism of making music available in formats like AAC or MP3 or of the people who listen to them. Services like iTunes, MOG and Pandora make music much more accessible to a lot of people and the music is what matters.