Foam is a material which is formed by trapping pockets of gas. It can be a variety of densities, firmnesses, and weights. Based on the uniformity of the cells, they will be more or less rigid.
Closed cell foam has a uniform cell structure which creates rigidity. Open cell foam is softer due to a less uniform cell structure.
The weight of a foam is dependent upon mass, not upon firmness or density. Therefore rigid foam may also be lightweight, whereas softer foam may be heavier.
Memory foam (viscoelastic) has increased viscosity and density which allows it to slowly return to its shape after compression.