title: Rural hospitals theorem
text: # Rural hospitals theorem
  
  The rural hospitals theorem (RHT) is a fundamental theorem in the theory of stable matching. It considers the problem of matching doctors to hospitals for residency, where each doctor is matched to a single hospital but each hospital has several positions for doctors. The total number of positions is larger than the total number of doctors, so some hospitals inevitably remain with unfilled positions. Usually, rural hospitals are less wanted than urban hospitals, so they often remain with many empty positions. This raised the question of whether the mechanism used to match doctors to hospitals can be changed in order to help these rural hospitals.
  
  The rural hospitals theorem answers this question negatively assuming all preferences are strict (i.e., no doctor is indifferent between two hospitals and no hospital is indifferent between two doctors). The theorem has two parts:
  
  * The set of assigned doctors, and the number of filled positions in each hospital, are the same in all stable matchings.
  * Any hospital that has some empty positions in some stable matching, receives exactly the same set of doctors in all stable matchings.
  
  In other words: changing the matching mechanism (as long as it produces stable matchings) will not help the rural hospitals in any way: they will not receive more doctors, nor better doctors.
  
  The theorem is robust in two-sided matching, since it applies to one-to-one and many-to one matchings, and can be extended to many-to-many matching.
  
  ## History
  
  A special case of the theorem where each hospital has only one position ("stable marriage") was proven by computer scientists McVitie and Wilson in 1970.
  
  In the 1980s economist Alvin E. Roth proved the two parts of the full theorem in two respective papers.
  
  ## Proof of a special case
  
  We will prove the theorem for the special case in which each hospital has only one position. In this case, Part 1 says that all stable matchings have the same set of matched hospitals and the same set of matched doctors, and Part 2 is trivial.
  
  It is useful to first visualize what different stable matchings look like (refer to the graphs on the right). Consider two different stable matchings, A and B. Consider a doctor $d_0$ whose hospitals in A and B are different. Since we assume strict preferences, $d_0$ prefers either his hospital in A or his hospital in B; suppose w.l.o.g. that he prefers his hospital in B, and denote this hospital by $h_1.$ All this is summarized by the green arrow from $d_0$ to $h_1.$
  
  Now, since matching A is stable, $h_1$ necessarily prefers its doctor in A over $d_0$ (otherwise $d_0$ and $h_1$ would de-stabilize matching A); denote this doctor by $d_2,$ and denote the preference of $h_1$ by a red arrow from $h_1$ to $d_2.$
  
  Similarly, since matching B is stable, $d_2$ prefers its hospital in B over $h_1;$ denote this hospital by $h_3,$ and denote the prefererence by a green arrow from $d_2$ to $h_3.$
  
  Since the number of doctors and hospitals is finite, at some point the red arrow from a hospital must land at $d_0,$ closing a directed cycle in the graph. The graph at the top-right shows a cycle of length 4; the graph at the bottom-right shows a cycle of length 6. In these cycles, all doctors point to hospitals they prefer and are matched to in B, and all hospitals point to doctors they prefer and are matched to in A.
  
  Now, consider what happens when the doctor $d_0$ is unmatched in A. Now, the cycle cannot close since no hospital can be matched to $d_0$ in A. It is also impossible that some hospital $h_3$ in this cycle is unmatched in A, since if the hospital preferred to be unmatched than to be matched to its doctor in B, then B could not have been stable. This means that we have an infinite cycle, which cannot be. Hence, if $d_0$ is unmatched in A, he must be unmatched in B too.
  
  The same is true for the hospitals: any hospital that is unmatched in A, must be unmatched in B too.
  
  