Stable roommates problem #
This module formalizes the non-bipartite stable roommates extension of two-sided stable matching ([GS62]; [SV07], Section 10.4.3, pp. 261–262; [GI89]).
n agents indexed by Fin n each hold a strict complete preference list (RoommatesInstance.pref)
over Fin n; since matchings are fixed-point-free involutions (RoommatesMatching n) and blocking
pairs consist of distinct agents i ≠ j, stability depends only on each agent's strict ranking of
the other n - 1 agents.
Main definitions #
Cslib.Algorithms.Lean.StableMatching.RoommatesMatching: a fixed-point-free involution pairing thenagents into disjoint roommate pairs.Cslib.Algorithms.Lean.StableMatching.RoommatesInstance: strict preference lists fornagents.RoommatesInstance.IsBlockingPair,RoommatesInstance.IsStable: blocking pairs and stability.RoommatesMatching.ofMatching,Instance.toRoommates: bipartite embedding of a two-sidedInstance ninto aRoommatesInstance (2 * n).RoommatesInstance.cyclicInstance,RoommatesInstance.galeShapleyFour: the cyclic nonexistence family for everyn ≥ 4and the4-agent example of [GS62] and [SV07], Section 10.4.3, pp. 261–262 (with the p. 262 column≻_4printed typo2, 1, 4corrected to2, 1, 3, and noting that nonexistence holds regardless of agent3's preferences).
Main results #
RoommatesMatching.even,isEmpty_roommatesMatching_of_odd: a roommates matching exists only for evenn.RoommatesMatching.eq_two,RoommatesInstance.exists_isStable_two: forn = 2, the unique roommates matching is stable for every preference profile.Instance.isStable_toRoommates_ofMatching_iff,Instance.exists_isStable_toRoommates: every bipartite roommates instance arising from a two-sided marketInstance nadmits a stable roommates matching (via Gale–Shapley deferred acceptance).RoommatesInstance.isBlockingPair_cyclicInstance_zero,RoommatesInstance.isBlockingPair_cyclicInstance_one,RoommatesInstance.isBlockingPair_cyclicInstance_two: explicit blocking pairs whenever agent0,1, or2is matched outside{0, 1, 2}(matching [SV07], p. 262).RoommatesInstance.not_exists_isStable_cyclicInstance,RoommatesInstance.not_exists_isStable_galeShapleyFour,RoommatesInstance.exists_not_exists_isStable_of_four_le: unlike bipartite stable matching, a stable roommates matching need not exist for anyn ≥ 4(in particular for every evenn ≥ 4).
References #
Roommates matchings #
A perfect roommates matching on Fin n: a fixed-point-free involution pairing agents into
disjoint pairs.
Partner assigned to agent
i.No agent is matched to itself.
- involutive : Function.Involutive self.partner
Pairing is symmetric: if
iis matched toj, thenjis matched toi.
View a roommates matching as a permutation of Fin n.
Any n admitting a roommates matching must be even.
The unique roommates matching on 2 agents, pairing 0 with 1.
On 2 agents, every roommates matching equals RoommatesMatching.two.
No roommates matching exists when the number of agents is odd.
Stable roommates instances and stability #
A stable roommates instance with n agents indexed by Fin n. pref i k is agent i's
k-th choice (rank 0 is most preferred). Stability inspects only pairs of distinct agents, so
each agent's ranking of the other n - 1 agents is strict and complete.
Agent
i's preference list, from most to least preferred.
The rank of agent j in agent i's preference list (0 is most preferred).
Agent i strictly prefers agent j to agent j'.
Instances For
Distinct agents (i, j) block μ when each strictly prefers the other to its assigned
roommate in μ.
Instances For
A roommates matching is stable when no pair of distinct agents blocks it.
Instances For
In a stable roommates matching, if i strictly prefers j ≠ i to its partner μ.partner i,
then j strictly prefers its own partner μ.partner j to i.
n = 2: unique stable roommates matching #
For n = 2, the unique roommates matching RoommatesMatching.two is stable for every
preference profile.
Every 2-agent roommates instance admits a stable roommates matching.
Bipartite embedding of two-sided stable matching #
Embed a two-sided matching μ : Matching n as a bipartite roommates matching on 2 * n
agents, pairing proposerIdx p with receiverIdx (μ p).
Embed a two-sided stable matching market I : Instance n into a bipartite
RoommatesInstance (2 * n): proposers (0 .. n - 1) rank all receivers (n .. 2n - 1) in
I.propPref order strictly above all proposers, and receivers rank all proposers in I.recvPref
order strictly above all receivers.
Stability of the embedded matching RoommatesMatching.ofMatching μ in I.toRoommates is
equivalent to two-sided stability of μ in I.
Every bipartite roommates instance I.toRoommates admits a stable roommates matching,
witnessed by Gale–Shapley deferred acceptance on I.
Nonexistence for n ≥ 4 (Gale–Shapley 1962; NRTV §10.4.3, pp. 261–262) #
Cyclic roommates preference family on n ≥ 4 agents generalizing the 4-agent example of
[GS62] and [SV07], Section 10.4.3, pp. 261–262:
- agent
0ranks2 > 1 > {3, …, n - 1}(viaEquiv.swap 0 2), - agent
1ranks0 > 2 > {3, …, n - 1}(viaEquiv.swap 1 2), - agent
2ranks1 > 0 > {3, …, n - 1}(viaEquiv.swap 0 1), - every agent
i ≥ 3holds an arbitrary preference listrest i.
In cyclicInstance n hn rest, any matching pairing agent 0 outside {0, 1, 2} is blocked
by (0, 1) (cf. [SV07], p. 262: pairing agent 1 with 4 is blocked by (1, 2)).
In cyclicInstance n hn rest, any matching pairing agent 1 outside {0, 1, 2} is blocked
by (1, 2) (cf. [SV07], p. 262: pairing agent 2 with 4 is blocked by (2, 3)).
In cyclicInstance n hn rest, any matching pairing agent 2 outside {0, 1, 2} is blocked
by (2, 0) (cf. [SV07], p. 262: pairing agent 3 with 4 is blocked by (3, 1)).
No stable roommates matching exists for cyclicInstance n hn rest, for any n ≥ 4 and any
choice of preference lists rest for agents 3, …, n - 1.
Gale–Shapley's 4-agent roommates instance admits no stable matching.
For every n ≥ 4 (in particular, for every even market size n ≥ 4), there exists a
RoommatesInstance n admitting no stable roommates matching.