1 Introduction
Information about the same “phenomenon” can come from different, possibly “contradicting”, sources. For instance, when evaluating candidates for an open position, data concerning experience and so far achieved successes of the candidates may give different candidate rankings than data concerning their formal qualifications and degrees. In other words, one has to deal with a multimodal data scenario. Clearly, in maximally objective and rationalitydriven decision making, it makes sense to take into account several information resources in order to achieve best possible results. In this work we systematically apply this point of view to the Stable Marriage problem [25]; a key observation here is that several natural and wellmotivated “multimodal variants” of Stable Marriage need to be studied. We investigate the complexity of computing matchings that are stable according to the considered definitions.
In the classic (conservative) Stable Marriage problem [25], we are given two disjoint sets and of agents each, where each of the agents has a strict preference list that ranks every member of the other set. The goal is to find a bijection (which we call a matching) between and without any blocking pair which can endanger the stability of the matching. A pair of agents is blocking a matching if they are not matched to each other but rank each other higher than their respective partners in the matching.
Gale and Shapley [25] introduced the Stable Marriage problem in the fields of Economics and Computer Science in the 1960s. One of their central results was that every Stable Marriage instance with agents admits a stable matching, which can be found by their algorithm in time. Since then Stable Marriage has been intensively studied in Economics, Computer Science, and Social and Political Science [1, 27, 29, 30, 35, 37, 39]. Practical applications of Stable Marriage (and its variants) include partnership issues in various realworld scenarios, matching graduating medical students (socalled residents) with hospitals, students with schools, and organ donors with patients [27, 35, 39], and the design of content delivery systems [36] and other distributed markets [45].
The original model of Stable Marriage assumes, roughly speaking, that there is a (subjective) criterion and that each agent has a single preference list depending on this criterion. In typically complex realworld scenarios, however, there are usually multiple aspects one takes into account when making a decision. For instance, if we consider the classical partnership scenario, then there could be different criteria such as working hours, family background, physical appearance, health, hobbies, etc. In other words, we face a much more complex multimodal scenario. Accordingly, the agents may have multiple preference lists, each defined by a different criterion; we call each of these criteria a layer. For an illustration, let us consider the following stable marriage example with two sets of two agents each, denoted as , , , and , and three layers of preferences, denoted as , , and .
In the above diagram the preferences are depicted right above (respectively, right below) the corresponding agents; preferences are represented through vertical lists where more preferred agents are put above the less preferred ones. For example, in the first layer, all agents from the same set have the same preference list, i.e. both and rank higher than while both and rank higher than . Similarly, in the second layer, both and rank higher than while both and rank higher than . In the last layer, the preference lists of two agents from the same set are reverse to each other. For instance, ranks higher than , which is opposite to . In terms of the classic stable marriage problem, we will have three independent instances, one for each layer. The corresponding stable matching(s) for each instance are depicted through the edges between the agents. For instance, the first layer admits exactly one stable matching, which matches with , and with . Yet, if we want to take all these layers jointly into account, then we need to extend the traditional concept of stability.
With multiple preference lists for each agent, there are many natural ways to extend the original stability concept. We propose three naturally emerging concepts of stability. Assume each agent has (possibly different) preferences lists. All three concepts are defined for a certain threshold with , which quantifies “the strength” of stability. In the following, we briefly describe our three concepts and defer the formal definitions to Section 2.

The first one, called layer global stability, extends the original stability concept in a straightforward way. It assumes that the matched pairs agree on a set of layers where no unmatched pair is blocking the matching in any layer from .
In our introductory example, the matching is stable in the first and the last layer, and thus it is a layer globally stable matching.

The second one, called layer pair stability, changes the “blocking ability” of the unmatched pairs. It forbids an unmatched pair to block more than layers. In other words, each pair of matched agents needs to be stable in some layers, but the choice of these layers can be different for different pairs.
Considering again our running example, we can verify that the layer globally stable matching is also layer pair stable as each unmatched pair is blocking at most one layer. Indeed, we will see that layer pair stability is strictly weaker than layer global stability (Proposition 3.1 and Example 3.1).

The last one, called layer individual stability, focuses on the “willingness” of an agent to stay with its partner. It requires that for each unmatched pair, at least one of the agents prefers to stay with its partner in at least layers.
In our introductory example, the matching is also layer individually stable. Thus, it is tempting to assume that layer individual stability also generalizes layer global stability. This is, however, not true as the following matching is layer globally stable but not layer individually stable. Neither does the latter implies the former. We refer to Example 3.2 for more explanations.
1.1 Related work
While we are not aware of research on an arbitrary number of layers, there is some work on layers. Weems [48] considered the case where each agent has two preference lists that are the reverse of each other. He provided a polynomialtime algorithm to find a bistable matching, i.e. a matching that is stable in both layers. Thus, while his concept falls into our layer global stability concept for , it is a special case since the preference lists in the two layers are the reverse of each other. In fact, for , we show that the complexity of determining layer global stability is NPhard.
Aggregating the preference lists of multiple layers into one (by comparing each pair of agents) and then searching for a “stable” matching for the agents with aggregated preferences is a plausible approach to multimodal stable marriages. As already noted by Farczadi et al. [23], the aggregated preferences may be intransitive or even cyclic. Addressing this situation, they consider a generalized variant of Stable Marriage, where each agent of one side, say , has a strict preference list (as in the original Stable Marriage) while each agent of the other side, say , may order each possible pair of partners separately, expressed by a subset
of ordered pairs. They defined a matching
to be stable if no unmatched pair satisfies “ and ”. It turns out that our concept of individual stability and their concept for a more generalized case where both sides of the agents may have intransitive preferences are related, and we can use one of their results as a subroutine. In a way, our analysis provides a more finegrained view, since we consider a richer model and thus are able to discuss how certain assumptions on elements of this model (e.g., the number of layers, the threshold value , etc.) affect the computational complexity of the problem.Aziz et al. [2] considered a variant of Stable Marriage
, where each agent has a probability for each ordered pair of potential partners. Assigning a probability of 1 to either
or for each and , their variant is closely related to the one of Farczadi et al. [23] and is shown to be NPhard.1.2 Our contributions
We introduce three main concepts of stability for Stable Marriage with multimodal preferences. In Section 2 we formally define these concepts, global stability, pair stability, and individual stability, and provide motivating and illustrating examples. In Section 3, we study the relations between the three concepts and show that pair stability is the least restrictive form while global and individual stability are in general incomparable (also see Figure 1 for a much refined picture). In Section 4, we consider the special case of alllayers stability () for the three concepts. On the one hand, we provide a polynomialtime algorithm for checking individual stability for arbitrary large number of preference lists. On the other hand, through an involved construction, we show NPhardness for the other two stability concepts, even if there are only two layers. The hardness results demonstrate a complexity dichotomy for both global and pair stability since for singlelayer preference lists, all three concepts of stability are the same and polynomialtime computable. In Section 5 we investigate the case of finding stable matchings with respect to less than all layers and only find NPhardness results. In Section 6, we identify two special scenarios with strong but natural restrictions on the preference lists. For the fist scenario we assume that one side of the agents has singlelayered preferences, i.e. on one side the preference list of each agent remains the same in all layers. We find that under such restrictions two out of three studied concepts are equivalent, and can be computed in polynomial time; for global stability we obtain W[1]hardness (and also NPhardness) and XP membership for the threshold parameter . In the second scenario, we assume that the preferences of all agents on each side are uniform in each layer, i.e. when for each fixed layer and side all agents have the same preference list, and when considering individual stability we find surprising tight connections to the complexity of the Graph Isomorphism problem. Table 1 gives a broad overview on our complexity results.
Parameters  global stability  pair stability  individual stability 

Arbitrary  
[25]  [25]  [25]  
NPh [T. 4.2+P. 4.4]  NPh [C. 4.3+P. 4.4]  [T. 4.1]  
NPh [P. 5.1]  NPh [P. 5.4+P. 5.5]  ?  
NPh [P. 5.1]  NPh [C. 5.3]  NPh [T. 5.2]  
Singlelayered  
NPh for unbounded [T. 6.2]  NPh when [C. 5.3]  NPh when [T. 5.2]  
W[1]h & in XP for [T. 6.2]  when [P. 6.3]  when [P. 6.3]  
Uniform  
[P. 6.7]  ?  [C. 6.6]  
[P. 6.7]  ?  Graph Isom.hard [T. 6.5] 
2 Definitions and Notations
For each natural number by we denote the set .
Let and be two element disjoint sets of agents. There are layers of preferences, where is a nonnegative integer. For each and each , let be a linear order on that represents the ranking of agent over all agents from in layer . Analogously, for each and each , the symbol represents a linear order on that encodes preferences of in layer . We refer to such linear orders as preference lists. A preference profile of layer is a collection of preference lists of all the agents in layer , .
Let . A matching is a set of pairwisely disjoint pairs, i.e. for each two pairs it holds that . If , then we also use to refer to and to refer to , and we say that and are their respective partners under ; otherwise we say that is an unmatched pair. Example 2.1 below shows an example matching and introduces a graphical notation that we will use throughout the paper.
Example 2.1.
Consider two sets of agents, and , and two layers of preference profiles, and . Let us recall that in the following diagram the preferences are represented through vertical lists where more preferred agents are put above the less preferred ones. For instance, in the diagram the preference list of agent in the first layer (profile ) is .
In our diagrams we will depict stable matchings in each layer through edges between matched nodes. If a layer has more than one stable matching, then we will use different types of lines (solid, dashed, dotted) and different colors to distinguish between them. For instance, in the above example profile has one stable matching , and has three stable matchings: (1) , (2) , and (3) .
Let us now introduce two notions that we will use when defining various concepts of stability.
Definition 2.1 (Dominating pairs and blocking pairs).
Let be a matching over . Consider an unmatched pair and a layer . We say that dominates in layer if . We say that is blocking matching in layer if it holds that

is unmatched in or dominates in layer , and

is unmatched in or dominates in layer .
For a single layer , a matching is stable in layer if no unmatched pair is blocking in layer . Let us illustrate the concept of dominating and blocking pairs through Example 2.1. Consider the matching and profile of layer . Here, pair dominates both (since prefers to ) and (since prefers to ). Thus, is a blocking pair and so it witnesses that is not stable in profile .
We are interested in matchings which are stable in multiple layers, i.e. we aim at generalizing the classic Stable Marriage problem [25, 35, 27, 39] which is defined for a single layer to the case of multiple layers. The idea behind each of the concepts defined below is similar: in order to call a matching stable for multiple layers we require that it must be stable in at least a certain, given number of layers ( is a number indicating the “strength” of the stability). However, for different concepts we require a different level of agreement with respect to which layers are required for stability. Informally speaking, on the one end of the spectrum we have a variant of stability where we require a global agreement of the agents regarding the set of layers for which the matching must be stable. On the other end of the spectrum we have a variant where we assume that the agents act independently: an agent would deviate if it would find another agent, say , such that prefers to its matched partner in some layers, and prefers to its matched partner in another, possibly different, set of layers. In the intermediate case, we require that a deviating pair must agree on the subset of layers which form the reason for deviation. We formally define the three concepts below.
2.1 layer global stability
Informally speaking, a matching is layer globally stable if there exist layers in each of which is stable.
Definition 2.2 (global stability).
A matching is layer globally stable if there exists a set of layers, such that for each layer and for each unmatched pair at least one of the two following conditions holds:

pair dominates in layer , or

pair dominates in layer .
The following example describes a scenario where the above concept of multilayer stability appears to be useful.
Example 2.2.
Assume that the preferences of the agents depend on external circumstances which are not known a priori. Assume that each layer represents a different possible state of the universe. If we want to find a matching that is stable in as many states of the universe as possible, then we need to find an layer globally stable matching for the highest possible value of .
Already for layer global stability we see substantial differences compared to the original concept of stability for a single layer. It is guaranteed that such a matching always exists for ; indeed this would be a matching that is stable in an arbitrary layer. However, one can observe that as soon as an layer globally stable matching might not exist (see Example 3.1).
2.2 layer pair stability
While layer global stability requires that the agents globally agree on a certain subset of layers for which the matching should be stable, pair stability forbids each unmatched pair to block more than a certain number of layers. The formal definition, using the domination concept, is as follows:
Definition 2.3 (pair stability).
A matching is layer pair stable if for each unmatched pair , there is a set of layers such that for each layer at least one of the following conditions holds:

pair dominates in layer , or

pair dominates in layer .
Definition 2.3 can be equivalently formulated using a generalization of the concept of blocking pairs. Let be an integer bound. We say that a pair is blocking if there exists a subset of layers such that for each , pair is blocking in layer .
Proposition 2.1.
A matching is layer pair stable if and only if no unmatched pair is blocking .
Proof.
To prove the statement, we show that a matching is not layer pair stable if and only if there is an unmatched pair that is blocking . For the “if” direction, assume that is an unmatched pair and is a subset of layers such that is blocking every layer in . Now consider an arbitrary subset of size . By the cardinalities of and , it is clear that . Let be such a layer. Then, by assumption, we have that is blocking in layer . This means that none of the conditions stated in Definition 2.3 holds. Thus, is an unmatched pair witnessing that is not layer pair stable.
For the “only if” direction, assume that is not layer pair stable and let be an unmatched pair that witnesses the nonlayer pair stability of . We claim that is blocking . Towards a contradiction, suppose that is not blocking . Then, there must be a subset of at least layers where the pair is not blocking in each layer in . Equivalently, we can say that for each layer , dominates in layer or dominates in layer —a contradiction to being a witness. ∎
The following example motivates layer pair stability.
Example 2.3.
Consider the case when the preferences of the agents depend on a context, yet a context is pairspecific. For instance, in matchmaking a woman may have different preferences over men depending on which country they will decide to live in. Thus, a pair of a man and a woman is blocking if they agree on certain conditions, and if they will find each other more attractive than their current partners according to the agreed conditions.
In Section 3, we show that layer global stability implies layer pair stability (Proposition 3.1). This, among other things, implies that for an layer pair stable matching always exists. However, as soon as the existence is no longer guaranteed (see Example 3.1).
2.3 layer individual stability
We move to the third and last concept of stability.
Definition 2.4 (individual stability).
A matching is layer individually stable if for each unmatched pair there is a set of layers such that at least one of the following conditions holds:

pair dominates in each layer of , or

pair dominates in each layer of .
The following example illustrates a potential application in the domain of partnership agencies.
Example 2.4.
Assume that each layer describes a single criterion for preferences. The preferences of each agent may differ depending on the criterion. For instance, the two sets of agents can represent, respectively, men and women, as in the traditional stable marriage problem. Different criteria may correspond, for instance, to the intelligence, sense of humor, physical appearance etc. Assume that an agent will have no incentive to break his or her relationship with , and to have an affair with if he or she prefers to according to at least criteria. In order to match men with women so that they form stable relationships, one needs to find an layer individually stable matching.
Definition 2.4 can be equivalently formulated using a generalization of the concept of dominating pairs. Let be an integer bound. We say that a pair is dominating if there is a subset of layers such that for each the pair dominates in layer .
Proposition 2.2.
A matching is layer individually stable if and only if no unmatched pair exists that is both dominating and dominating .
Proof.
To prove the statement, we show that a matching is not layer individually stable if and only if there is an unmatched pair that is dominating and dominating . For the “if” direction, assume that is an unmatched pair and are two (possibly different) subsets of layers each, such that is dominating in each layer and is dominating in each layer . Now consider an arbitrary subset of size . By the cardinalities of , , and , it is clear that and . Let and be two layers in the intersections. Then, by assumption, we have that is dominating in layer and is dominating in layer . This means that none of the conditions stated in Definition 2.4 holds. Thus, is an unmatched pair witnessing that is not layer individually stable.
For the “only if” direction, assume that is not layer individually stable and let be an unmatched pair that witnesses the nonlayer individual stability of . We claim that is dominating and is dominating . Towards a contradiction, first suppose that is not dominating , meaning that there are at most layers where dominates . This implies that there is a subset of layers such that for each , the pair is dominating , a contradiction to being a witness of the nonlayer individual stability of . Analogously, if was not dominating , then we could obtain the same contradiction. ∎
For an layer individually stable matching always exists (it will follow from Propositions 3.3 and 3.1); however, this is no longer the case when (see Proposition 3.2 and Example 3.1).
Observe that according to layer individual stability the preferences of the agents can be represented as sets of linear orders: it does not matter which preference order comes from which layer. This is not the case for the other two concepts.
2.4 Central computational problems
In this paper, we study the algorithmic complexity of finding matchings that are stable according to the above definitions. To this end, we first investigate how the three concepts relate to each other. Next, we formally define the search problem of finding an layer globally stable matching.
Globally Stable Marriage
Input: Two disjoint sets of agents each, and , preference profiles, and an integer bound .
Output: Return an layer globally stable matching if one exists, or claim there is no such.
The other two problems, Pair Stable Marriage and Individually Stable Marriage, are defined analogously.
3 Relations Between the MultiLayer Concepts of Stability
Below we establish relations among the three concepts. We start by showing that layer pair stability is a weaker notion than layer global stability and layer individual stability.
Proposition 3.1.
An layer globally stable matching is layer pair stable.
Proof.
Let be an layer globally stable matching and let be such that and that for each , matching is stable in layer . For the sake of contradiction let us assume that is not layer pair stable. By Proposition 2.1, let be an blocking pair for . Let be such that and that for each , pair blocks in layer . Since , we get that . Let . This gives a contradiction since on the one hand is stable in layer , and on the other hand blocks in layer . ∎
Proposition 3.2.
An layer individually stable matching is layer pair stable.
Proof.
Consider an layer individually stable matching . Towards a contradiction, suppose that is not layer pair stable. By Proposition 2.1, this means that there exists an unmatched pair and a subset of layers such that is blocking in each layer from . This means that is both dominating and dominating . Then, by Proposition 2.2, is not layer individually stable, a contradiction. ∎
Example 3.1, below, shows a matching which is layer pair stable, but which is not layer globally stable. This example, together with Proposition 3.1, also shows that layer global stability is strictly stronger than layer pair stability.
Example 3.1.
Consider an instance with six agents and two layers of preference profiles.
Observe that matching is layer individually stable and, thus layer pair stable. However, is blocked by pair in the first layer and by in the second. Thus, is not 1layer globally stable. Indeed the only layer globally stable matchings are indicated by the solid lines, which are also layer individually stable (and thus layer pair stable).
As soon as , layer pair stability is not guaranteed to exist, even if . To see this we augment the instance with one more layer whose preference lists are identical to the first layer given in Example 2.1. One can verify that for each of all six possible matchings, there is always an unmatched pair that is blocking at least two layers.
For , we observe that layer pair stability is equivalent to layer individual stability.
Proposition 3.3.
A matching is layer pair stable if and only if it is layer individually stable.
Proof.
By Proposition 3.2, we know that layer individual stability implies layer pair stability. It remains to show the other direction. Let be a layer pair stable matching. Suppose, for the sake of contradiction, that is not layer individually stable. By Proposition 2.2, this means that there is an unmatched pair that is both dominating and dominating . This implies that the pair is indeed blocking , which by Proposition 2.1, is a contradiction to being layer pair stable. ∎
Example 3.2 shows that for , individual stability and pair stability are not equivalent, neither is individual stability equivalent to global stability.
Example 3.2.
Consider the example given in Section 1. Recall that the first layer admits exactly one stable matching, namely (depicted by solid lines). The second layer also admits exactly one (different) stable matching, namely (also depicted by solid lines). The third layer has two stable matchings, and (depicted by solid lines and dashed lines, resp.).
Thus, both and are layer globally stable (and layer pair stable). However, is layer individually stable while is not. To see why is not layer individually stable, we can verify that the unmatched pair dominates in the first and the third layer and it dominates in the first two layers. By Proposition 2.2, is not layer individually stable since .
If we restrict the example to the last two layers only, then matching is also evidence that an layer globally stable (which, by Proposition 3.4, implies layer pair stability) is not layer individually stable.
For global stability and pair stability are equivalent.
Proposition 3.4.
For , a matching is layer globally stable if and only if it is layer pair stable.
Proof.
By Proposition 3.1, layer global stability implies layer pair stability. Now, assume that a matching is layer pair stable. For the sake of contradiction, suppose that is not layer globally stable. This means that there exists a pair, say , and a layer, say , such that is blocking in layer . Thus, is blocking , and so cannot satisfy layer pair stability. This gives a contradiction. ∎
It is somehow counterintuitive that even an layer globally stable matching (i.e. a matching that is stable in each layer) may not be layer individually stable (see Example 3.2). By Proposition 3.5 we can thus infer that layer global stability is strictly weaker than layer individual stability.
Proposition 3.5.
For , an layer individually stable matching is layer globally stable.
Proof.
Proposition 3.2 and Proposition 3.4 imply the statement since . ∎
By Example 3.2, layer global stability does not imply layer individual stability. However, it implies layer individual stability.
Proposition 3.6.
Every layer globally stable matching is layer individually stable. There are instances where layer globally stable matchings are not layer individually stable.
Proof.
For the first statement, let be an layer globally stable matching. Suppose, for the sake of contradiction, that is not layer individually stable. Let , which is . By Proposition 2.2, let be an unmatched pair that is both dominating and dominating . Since , there is at least one layer where is dominating both and , meaning that is blocking layer , a contradiction to being layer globally stable.
To see why layer global stability may not imply layer individual stability, consider the following instance with four agents and layers.
is the only layer globally stable matching. However, it is not layer individually stable as the unmatched pair dominates in layers and and dominates in layers and . By Proposition 2.2, is not layer individually stable since . ∎
The relations among the different concepts of multilayer stability are depicted in Figure 1.
A layer globally stable matching always exists. Together with Propositions 3.2 and 3.1, we obtain the following.
Proposition 3.7.
A preference profile with layers always admits a matching, which is layer globally stable, layer pair stable, and layer individually stable.
4 AllLayers Stability ()
In this section, we discuss the special case when . It turns out that deciding whether a given instance admits an layer individually stable matching can be solved in polynomial time. For the other two concepts of stability, however, the problem becomes NPhard even when .
4.1 Algorithm for layer individual stability
The algorithm for deciding layer individual stability is based on the following simple lemma.
Lemma 4.1.
Let and be two agents such that is the first ranked agent of in some layer , and let be another agent such that prefers over in some layer . Then, no layer individually stable matching contains .
Proof.
Let be the three agents and let be the two (possibly equal) layers as described by the assumption. Suppose towards a contradiction that there is an layer individually stable matching with . This implies that is an unmatched pair under . However, prefers over in layer and prefers over in layer —a contradiction to being layer individually stable. ∎
Lemma 4.1 leads to Algorithm 1 which looks quite similar to the socalled extended GaleShapley algorithm by Irving [28]. The crucial difference is that we loop into different layers and we cannot delete a pair of agents that does not belong to any stable matching, as it may still serve to block certain matchings. Instead of deleting such pair, we will mark it. Herein, marking a pair means marking the agent (resp. ) in the preference list of (resp. ) in every layer.
The correctness of Algorithm 1 follows from Lemmas 4.4, 4.3 and 4.2.
Lemma 4.2.
If a pair is marked during the execution of Algorithm 1, then no layer individually stable matching contains this pair.
Proof.
Each pair is marked within two “foreach” loops in Algorithm 1 and Algorithm 1, respectively (we will refer to them as the “outer” loop and the “inner” loop). Let us fix an arbitrary and and consider the pairs which was marked when the outer and the inner loops were run for and , respectively. We show the statement via induction on the sequence of pairs which were marked when and was considered for the two loops. For the induction to begin, let with and be the first pair that is marked during the execution. This implies that agent ranks in the first position in layer and that prefers to in some (possibly different) layer. By Lemma 4.1, no layer individually stable matching contains .
For the induction assumption, let be the pair (for given and ) that is marked during the execution and no layer individually stable matching contains a pair that is marked prior to . Suppose for the sake of contradiction that there is an layer individually stable matching which contains the marked pair . The fact that has been marked implies that

ranks in the position in layer for some , and

prefers over in some layer .
However, by the description of the algorithm in layer (Lines 1–1) for each agent that prefers to in layer , i.e. , we have that is marked (see the “until” condition in Algorithm 1). The induction assumption implies that does not contain any with . Thus, it follows that prefers to in layer , i.e. . This is a contradiction to being layer individually stable on the unmatched pair since there is a layer such that . ∎
The following lemma ensures that in Algorithm 1 if is matched to an agent , then it is the most preferred unmarked agent of in all layers.
Lemma 4.3.
If no agent’s preference list consists of only marked agents and there is an agent and two different layers , such that the first unmarked agent in the preference list of in layer differs from the one in layer , then Algorithm 1 will mark at least one more pair.
Proof.
Suppose towards a contradiction that no new pair is marked, but there is an agent such that the first agent unmarked by is different in different layers, say and in layers and , with and . Since no new pair will be marked, is the last unmarked agent in the preference lists of and in all layers (see Algorithm 1 of Algorithm 1). Since there is a different agent such that for each agent we have that is not the last unmarked agent in the preference list of in any layer. Since no agent’s preference list consists of only marked agents, the preference list of (in some layer) contains an agent which is unmarked. Denote this agent as . Again, since no new pair will be marked, in the preference list of , agent is the last unmarked agent—a contradiction. ∎
When Algorithm 1 terminates and no agent contains a preference list that consists of only marked agents, then we can construct an layer individually stable matching by assigning to each agent its first unmarked agent in any preference list (note that Lemma 4.3 ensures on termination that for each agent it holds that in all layers is first unmarked agent is the same).
Lemma 4.4.
If upon termination no agent’s preference list consists of only marked agents, then the matching computed by Algorithm 1 is layer individually stable.
Proof.
Towards a contradiction suppose that returned by Algorithm 1 is not layer individually stable. That is, there is an unmatched pair with and and two layers such that and . Observe that agent is matched with the first agent, denoted as , in the preference list of such that the pair is not marked, and so we infer that is marked. Thus, the innermost loop of the algorithm has been run for the pair (see Algorithm 1). By Algorithm 1 of Algorithm 1 for all agents where for some layer , the pair is marked. This includes the pair since —a contradiction to Lemma 4.2. ∎
Finally, we obtain that Algorithm 1 computes an layer individually stable matching if one exists.
Theorem 4.1.
For , Algorithm 1 solves Individually Stable Marriage in