Documentation

CslibFrontier.Algorithms.Lean.StableMatching.Roommates

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 #

Main results #

References #

Roommates matchings #

A perfect roommates matching on Fin n: a fixed-point-free involution pairing agents into disjoint pairs.

  • partner : Fin n → Fin n

    Partner assigned to agent i.

  • no_fixed (i : Fin n) : self.partner i ≠ i

    No agent is matched to itself.

  • involutive : Function.Involutive self.partner

    Pairing is symmetric: if i is matched to j, then j is matched to i.

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.

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.

  • pref : Fin n → Equiv.Perm (Fin n)

    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
        theorem Cslib.Algorithms.Lean.StableMatching.RoommatesInstance.IsStable.rank_lt {n : ℕ} {I : RoommatesInstance n} {μ : RoommatesMatching n} (hμ : I.IsStable μ) {i j : Fin n} (hne : i ≠ j) (hi : I.rank i j < I.rank i (μ.partner i)) :
        I.rank j (μ.partner j) < I.rank j i

        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 proposer p : Fin n as index p.val in Fin (2 * n).

        Embed receiver r : Fin n as index n + r.val in Fin (2 * n).

        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 0 ranks 2 > 1 > {3, …, n - 1} (via Equiv.swap 0 2),
        • agent 1 ranks 0 > 2 > {3, …, n - 1} (via Equiv.swap 1 2),
        • agent 2 ranks 1 > 0 > {3, …, n - 1} (via Equiv.swap 0 1),
        • every agent i ≥ 3 holds an arbitrary preference list rest 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.

        The 4-agent stable roommates nonexistence example of [GS62] and [SV07], Section 10.4.3, pp. 261–262 (with 0, 1, 2, 3 indexing agents 1, 2, 3, 4 and the printed p. 262 typo 2, 1, 4 in column ≻_4 corrected to 2, 1, 3, i.e., 1 > 0 > 2).

        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.