Boyle's Law states that, for a given quantity of a gas in a container, the pressure is inversely related to the volume of the container. This means that as a container's volume increases, the pressure within the container decreases and, if the container is open to the atmosphere, molecules of air will move into the container, causing pressure to progressively increase until it equilibrates again with atmospheric pressure. In the case of the lung, the container is the thoracic cavity. During inspiration, the volume of the
thoracic cavity increases, causing intrapleural pressure to decrease. This decrease in intrapleural pressure causes transpulmonary pressure to increase since
transpulmonary pressure = intra-alveolar pressure - intrapleural pressure. This causes the lung itself to expand and intra-alveolar pressure to decrease. It is this decrease in intra-alveolar pressure that causes air to move into the lungs. During expiration, the volume of the thoracic cavity decreases, causing intrapleural pressure to increase. This increase in intrapleural pressure causes transpulmonary pressure to decrease (intra-alveolar pressure - intrapleural pressure), which causes the lung itself to retract and decrease volume due to its elastic nature, thereby increasing intra-alveolar pressure. It is this increase in intra-alveolar pressure that causes air to move out of the lungs.