Theres obviously some overlap, but in general I would use these definitions:
-Machine-pistol: A select-fire handgun
-Sub-machine gun: A shoulder-fired, select-fire carbine firing a pistol round
-Assault rifle: A select fire rifle firing an intermediate-power rifle cartridge (5.45, 5.56, 7.62x39, etc)
-Machine-gun: A select-fire or full-auto-only weapon firing a rife cartridge, designed for sustained full-auto fire
To me, a true machine-gun is a belt-fed weapon with changeable barrels designed for sustained full-auto fire in a support role, usually shot off a bipod or even a tripod. But there are also plenty of magazine-fed machine guns that are basically beefed-up assault rifles designed for sustained full-auto fire. Some machines guns, like the M249 SAW (Squad Automatic Weapon), were used on the squad level as a more lightweight, direct-support weapon. Now the Marine Corps is using a piston-operated, beefed up version of the M16 to fill the Squad Automatic Weapon role.
M16s and AK-47s are assault rifles; they are select-fire rifles. They're not machine guns because they aren't designed for sustained full-auto fire.
0331: "Accuracy by volume."