Balanced Stable Marriage: How Close is Close Enough?^{1}^{1}1The research leading to these results received funding from the European Research Council under the European Unionâs Seventh Framework Programme (FP/20072013) / ERC Grant Agreement no. 306992.
Abstract
The Balanced Stable Marriage problem is a central optimization version of the classic Stable Marriage problem. Here, the output cannot be an arbitrary stable matching, but one that balances between the dissatisfaction of the two parties, men and women. We study Balanced Stable Marriage from the viewpoint of Parameterized Complexity. Our “above guarantee parameterizations” are arguably the most natural parameterizations of the problem at hand. Indeed, our parameterizations precisely fit the scenario where there exists a stable marriage that both parties would accept, that is, where the satisfaction of each party is close to the best it can hope for. Furthermore, our parameterizations accurately draw the line between tractability and intractability with respect to the target value.
usenames,dvipsnamesxcolor
1 Introduction
Matching under preferences is a rich topic central to both economics and computer science, which has been consistently and intensively studied for over several decades. One of the main reasons for interest in this topic stems from the observation that it is extremely relevant to a wide variety of practical applications modeling situations where the objective is to match agents to other agents (or to resources). In the most general setting, a matching is defined as an allocation (or assignment) of agents to resources that satisfies some predefined criterion of compatibility/acceptability. Here, the (arguably) best known model is the twosided model, where the agents on one side are referred to as men, and the agents on the other side are referred to as women. A few illustrative examples of real life situations where this model is employed in practice include matching hospitals to residents, students to colleges, kidney patients to donors and users to servers in a distributed Internet service. At the heart of all of these applications lies the fundamental Stable Marriage problem. In particular, the Nobel Prize in Economics was awarded to Shapley and Roth in 2012 “for the theory of stable allocations and the practice of market design.” Moreover, several books have been dedicated to the study of Stable Marriage as well as optimization variants of this classical problem such as the Egalitarian Stable Marriage, SexEqual Stable Marriage and Balanced Stable Marriage problems [11, 14, 16].
The input of the Stable Marriage problem consists of a set of men, , and a set of women, , each person ranking a subset of people of the opposite gender. That is, each person has a set of acceptable partners, , whom this person subjectively ranks. Consequently, each person has a socalled preference list, where denotes the position of in ’s preference list. Without loss of generality, it is assumed that if a person ranks a person , then the person ranks the person as well. The sets of preference lists of the men and the women are denoted by and , respectively. In this context, we say that a pair of a man and a woman, , is an acceptable pair if both and . Accordingly, the notion of a matching refers to a matching between men and women, where two people that are matched to one another form an acceptable pair. Roughly speaking, the goal of the Stable Marriage problem is to find a matching that is stable in the following sense: there should not exist two people who prefer being matched to one another over their current “status”. More precisely, a matching is said to be stable if it does not have a blocking pair, which is an acceptable pair such that (i) either is unmatched by or , and (ii) either is unmatched by or . Here, the notation indicates the person to whom matches the person . Note that a person always prefers being matched to an acceptable partner over being unmatched.
The seminal paper [7] by Gale and Shapely on stable matchings shows that given an instance of Stable Marriage, a stable matching necessarily exists, but it is not necessarily unique. In fact, for a given instance of Stable Marriage, there can be an exponential number of stable matchings, and they should be viewed as a spectrum where the two extremes are known as the manoptimal stable matching and the womanoptimal stable matching. Formally, the manoptimal stable matching, denoted by , is a stable matching such that every stable matching satisfies the following condition: every man is either unmatched by both and or . The womanoptimal stable matching, denoted by , is defined analogously. These two extremes, which give the best possible solution for one party at the expense of the other party, always exist and can be computed in polynomial time [7]. Naturally, it is desirable to analyze matchings that lie somewhere in the middle, being globally desirable, fair towards both sides or desirable by both sides.
Each notion above of what constitutes a desirable stable matching leads to a natural, different optimization problem. The determination of which notion best describes an appropriate outcome depends on the specific situation at hand. Here, the quantity is viewed as the “satisfaction” of in a matching , where a smaller value signifies a greater amount of satisfaction. Under this interpretation, the egalitarian stable matching attempts to be globally desirable by minimizing over the set of all stable matchings, which we denote by . The problem of finding an egalitarian stable matching, called Egalitarian Stable Marriage, is known be solvable in polynomial time due to Irving et al. [12]. Roughly speaking, this problem does not distinguish between men and women, and therefore it does not fit scenarios where it is necessary to differentiate between the individual satisfaction of each party. In such scenarios, the SexEqual Stable Marriage and Balanced Stable Marriage problems come into play. Before we define each of these two problems, we would like to remark that a survey of results related to Egalitarian Stable Marriage and SexEqual Stable Marriage is outside the scope of this paper, and we refer interested readers to the books [11, 14, 16]. Here, we consider these two problems only to understand the context of Balanced Stable Marriage.
In the SexEqual Stable Marriage problem, the objective is to find a stable matching that minimizes the absolute value of over , where . It is thus clear that SexEqual Stable Marriage seeks a stable matching that is fair towards both sides by minimizing the difference between their individual amounts of satisfaction. Unlike the Egalitarian Stable Marriage, the SexEqual Stable Marriage problem is known to be NPhard [13]. On the other hand, in Balanced Stable Marriage, the objective is to find a stable matching that minimizes over . At first sight, this measure might seem conceptually similar to the previous one, but in fact, the two measures are quite different. Indeed, Balanced Stable Marriage does not attempt to find a stable matching that is fair, but one that is desirable by both sides. In other words, Balanced Stable Marriage examines the amount of dissatisfaction of each party individually, and attempts to minimize the worse one among the two. This problem fits the common scenario in economics where each party is selfish in the sense that it desires a matching where its own dissatisfaction is minimized, irrespective of the dissatisfaction of the other party, and our goal is to find a matching desirable by both parties by ensuring that each individual amount of dissatisfaction does not exceed some threshold. In some situations, the minimization of may indirectly also minimize , but in other situations, this may not be the case. Indeed, McDermid [17] constructed a family of instances where there does not exist any matching that is both a sexequal stable matching and a balanced stable matching (the construction is also available in the book [16]).
The Balanced Stable Marriage problem was introduced in the influential work of Feder [6] on stable matchings. Feder [6] proved that this problem is NPhard and that it admits a 2approximation algorithm. Later, it was shown that this problem also admits a approximation algorithm where is the maximum size of a set of acceptable partners [16]. O’Malley [19] phrased the Balanced Stable Marriage problem in terms of constraint programming. Recently, McDermid and Irving [18] expressed interest in the design of fast exact exponentialtime algorithms for Balanced Stable Marriage. In this paper, we study this problem in the realm of fast exact exponentialtime algorithms as defined by the field of Parameterized Complexity (see Section 2). Recall that is the set of all stable matchings. In this context, we would like to remark that Egalitarian Stable Roommates problem is NPcomplete [6]. Recently, Chen et al.[1] showed that it is FPT parameterized by the egalitarian cost. McDermid and Irving [18] showed that SexEqual Stable Marriage is NPhard even if it is only necessary to decide whether the target is 0 or not [18]. In particular, this means that SexEqual Stable Marriage is not only W[1]hard with respect to , but it is even paraNPhard with respect to this parameter.^{4}^{4}4If a parameterized problem cannot be solved in polynomial time even when the value of the parameter is a fixed constant (that is, independent of the input), then the problem is said to be paraNPhard. In the case of Balanced Stable Marriage, however, fixedparameter tractability with respect to the target trivially follows from the fact that this value is lower bounded by .^{5}^{5}5We assume that any stable matching is perfect. We justify this assumption later.
Our Contribution.
We introduce two “aboveguarantee parameterizations” of Balanced Stable Marriage. To this end, we consider the minimum value of the total dissatisfaction of men that can be realized by a stable matching, and the minimum value of the total dissatisfaction of women that can be realized by a stable matching. Formally, , and , where and are the manoptimal and womanoptimal stable matchings, respectively. An input integer would indicate that our objective is to decide whether . In our first parameterization, the parameter is , and in the second one, it is . In other words, we would like to answer the following questions (recall that ).
AboveMin Balanced Stable Marriage (AboveMin BSM) Input: An instance of Balanced Stable Marriage, and a nonnegative integer . Question: Is ? Parameter:
AboveMax Balanced Stable Marriage (AboveMax BSM) Input: An instance of Balanced Stable Marriage, and a nonnegative integer . Question: Is ? Parameter:
Before stating our results, let us explain the choice of these parameterizations. Here, note that the best satisfaction the party of men can hope for is , and the best satisfaction the party of women can hope for is . First, consider the parameter . Whenever we have a solution such that the amounts of satisfaction of both parties are close enough to the best they can hope for, this parameter is small. Indeed, the closer the satisfaction of both parties to the best they can hope for (which is exactly the case where both parties would find the solution desirable), the smaller the parameter is, and the smaller the parameter is, the faster a parameterized algorithm is. In other words, if there exists a solution that is desirable by both parties, our parameter is small.
In the parameterization above, as we take the min of , we need the satisfaction of both parties to be close to optimal in order to have a small parameter. As we are able to show that Balanced Stable Marriage is FPT with respect to this parameter, it is very natural to next examine the case where we take the max of . In this case, the closer the satisfaction of at least one party to the best it can hope for, the smaller the parameter is. In other words, now the demand from a solution—while not changing the definition of a solution in any way, that is, a solution is still a stable matching minimizing —in order to have a small parameter is weaker. In the jargon of Parameterized Complexity, it is said that the parameterization by is “above a higher guarantee” than the parameterization by , since it is always the case that . Unfortunately, as we show in this paper, the parameterization by results in a problem that is W[1]hard. Hence, the complexities of the two parameterizations behave very differently. We remark that in Parameterized Complexity, it is not at all the rule that when one takes an “above a higher guarantee” parameterization, the problem would suddenly become W[1]hard, as can be evidenced by the most classical above guarantee parameterizations in this field, which are of the Vertex Cover problem. For that problem, three above guarantee parameterizations were considered in [10, 15, 3, 20], each above a higher guarantee than the previous one that was studied, and each led to a problem that is FPT. In that context, unlike our case, it is still not clear whether the bar can be raised higher. Overall, our results accurately draw the line between tractability and intractability with respect to the target value in the context of two very natural, useful parameterizations.
Finally, to be more precise, we note that our work proves three main theorems:

First, we prove (in Section 3) that AboveMin BSM admits a kernel where the number of people is linear in . For this purpose, we introduce notions that might be of independent interest in the context of a “functional” variant of AboveMin BSM. Our kernelization algorithm consists of several phases, each simplifying a different aspect of AboveMin BSM, and shedding light on structural properties of the Yesinstances of this problem. Note that this result already implies that AboveMin BSM is FPT.

Second, we prove (in Section 4) that AboveMin BSM admits a parameterized algorithm whose running time is single exponential in the parameter . This algorithm first builds upon our kernel, and then incorporates the method of bounded search trees.

Third, we prove (in Section 5) that AboveMax BSM is W[1]hard. This reduction is quite technical, and its importance lies in the fact that it rules out (under plausible complexitytheoretic assumptions) the existence of a parameterized algorithm for AboveMax BSM. Thus, we show that although AboveMax BSM seems quite similar to AboveMin BSM, in the realm of Parameterized Complexity, these two problems are completely different.
2 Preliminaries
Let be a function . For a subset , we let denote the restriction of to . That is, , and for all .
Throughout the paper, whenever the instance of Balanced Stable Marriage under discussion is not clear from context or we would like to put emphasis on , we add “” to the appropriate notation. For example, we use the notation rather than . When we would like to refer to the balance of a stable matching in a specific instance , we would use the notation . A matching is called a perfect matching if it matches every person (to some other person).
While designing our kernelization algorithm (see “Parameterized Complexity”), we might be able to determine whether the input instance is a Yesinstance or a Noinstance. For the sake of clarity, in the first case, we simply return Yes, and in second case, we simply return No. To properly comply with the definition of a kernel, the return of Yes and No should be interpreted as the return of a trivial Yesinstance and a trivial Noinstance, respectively. Here, a trivial Yesinstance can be the one in which and , where the only stable matching is the one that is empty and whose balance is 0, and a trivial Noinstance can be the one where , , , and .
Parameterized Complexity.
A parameterization of a problem is the association of an integer with each input instance, which results in a parameterized problem. For our purposes, we need to recall three central notions that define the parameterized complexity of a parameterized problem. The first one is the notion of a kernel. Here, a parameterized problem is said to admit a kernel of size for some function that depends only on if there exists a polynomialtime algorithm, called a kernelization algorithm, that translates any input instance into an equivalent instance of the same problem whose size is bounded by and such that the value of the parameter does not increase. In case the function is polynomial in , the problem is said to admit a polynomial kernel. Hence, kernelization is a mathematical concept that aims to analyze the power of preprocessing procedures in a formal, rigorous manner. The second notion that we use is the one of fixedparameter tractability (FPT). Here, a parameterized problem is said to be FPT if there is an algorithm that solves it in time , where is the size of the input and is a function that depends only on . Such an algorithm is called a parameterized algorithm. In other words, the notion of FPT signifies that it is not necessary for the combinatorial explosion in the running time of an algorithm for to depend on the input size, but it can be confined to the parameter . Finally, we recall that Parameterized Complexity also provides tools to refute the existence of polynomial kernels and parameterized algorithms for certain problems (under plausible complexitytheoretic assumptions), in which context the notion of W[1]hard is a central one. It is widely believed that a problem that is W[1]hard is unlikely to be FPT, and we refer the reader to the books [2, 5] for more information on this notion in particular, and on Parameterized Complexity in general. The notation is used to hide factors polynomial in the input size.
Reduction Rule. To design our kernelization algorithm, we rely on the notion of a reduction rule. A reduction rule is a polynomialtime procedure that replaces an instance of a parameterized problem by a new instance of . Roughly speaking, a reduction rule is useful when the instance is in some sense “simpler” than the instance . In particular, it is desirable to ensure that . The rule is said to be safe if is a Yesinstance if and only if is a Yesinstance.
A Functional Variant of Stable Marriage.
To obtain our kernelization algorithm for AboveMin BSM, it will be convenient to work with a “functional” definition of preferences, resulting in a “functional” variant of this problem which we call AboveMin FBSM. Here, instead of the sets of preferences lists and , the input consists of sets of preference functions and , where replaces and replaces . Specifically, every person has an injective (onetoone) function , called a preference function. Intuitively, a lower function value corresponds to a higher preference. Since every preference function is injective, it defines a total order over a set of acceptable partners. Note that all of the definitions presented in the introduction extend to our functional variant in the natural way. For the sake of formality, we specify the required adaptations below.
The input of the Functional Stable Marriage problem consists of a set of men, , and a set of women, . Each person has a set of acceptable partners, denoted by , and an injective function called a preference function. Without loss of generality, it is assumed that if a person belongs to the set of acceptable partners of a person , then the person belongs to the set of acceptable partners of the person . The set of preference functions of the men and the women are denoted by and , respectively. A pair of a man and a woman, , is an acceptable pair if both and . Accordingly, the notion of a matching refers to a matching between men and women, where two people that are matched to one another form an acceptable pair. A matching stable if it does not have a blocking pair, which is an acceptable pair such that (i) either is unmatched by or , and (ii) either is unmatched by or . The goal of the Functional Stable Marriage problem is to find a stable matching.
The manoptimal stable matching, denoted by , is a stable matching such that every stable matching satisfies the following condition: every man is either unmatched by both and or . The womanoptimal stable matching, denoted by , is defined analogously. Given a stable matching , define
Moreover, , where SM is the set of all stable matchings, , and . Finally, AboveMin FBSM is defined as follows.
AboveMin Functional Balanced Stable Marriage (AboveMin FBSM) Input: An instance of Functional Balanced Stable Marriage, and a nonnegative integer . Question: Is ? Parameter:
From the above discussions it is straightforward to turn an instance of AboveMin BSM into an equivalent instance of AboveMin FBSM as stated in the following observation.
Observation 1.
Let be an instance of AboveMin BSM. For each , define by setting for all . Then, is a Yesinstance of AboveMin BSM if and only if is a Yesinstance of AboveMin FBSM.
Known Results.
Finally, we state several classical results, which were originally presented in the context of Stable Marriage. By their original proofs, these results also hold in the context of Functional Stable Marriage. To be more precise, given an instance of Functional Stable Marriage, we can construct an equivalent instance of Stable Marriage, by ranking the acceptable partners in the order of their function values, where a smaller value implies a higher preference. The instances are equivalent in the sense that they give rise to the exact same set of stable matchings. Hence, all the structural results about stable matchings in the usual setting (modeled by strict preference lists) apply to the generalized setting, modeled by injective functions.
Proposition 1 ([8]).
For any instance of Stable Marriage (or Functional Stable Marriage), there exist a manoptimal stable matching, , and a womanoptimal stable matching, , and both and can be computed in polynomial time.
The following powerful proposition is known as the RuralHospital Theorem.
Proposition 2 ([9]).
Given an instance of Stable Marriage (or AboveMin FBSM), the set of men and women that are matched is the same for all stable matchings.
We further need a proposition regarding the manoptimal and womanoptimal stable matchings that implies Proposition 2 [9].
Proposition 3 ([11]).
For any instance of Stable Marriage (or Functional Stable Marriage), every stable matching satisfies the following conditions: every woman is either unmatched by both and or , and every man is either unmatched by both and or .
3 Kernel
In this section, we design a kernelization algorithm for AboveMin BSM. More precisely, we prove the following theorem.
Theorem 3.1.
AboveMin BSM admits a kernel that has at most men, at most women, and such that each person has at most acceptable partners.
3.1 Functional Balanced Stable Marriage
To prove Theorem 3.1, we first prove the following result for the AboveMin FBSM problem.
Lemma 3.1.
AboveMin FBSM admits a kernel with at most men, at most women, and such that the image of the preference function of each person is a subset of .
To obtain the desired kernelization algorithm, we execute the following plan.

Cleaning Prefixes and Suffixes. Simplify the preference functions by “cleaning” suffixes and thereby also “cleaning” prefixes.

Perfect Matching. Zoom into the set of people matched by every stable matching.

Overcoming Sadness. Bound the number of “sad” people. Roughly speaking, a “sad” person is one whose best attainable partner, , does not reciprocate by considering as the best attainable partner.

Marrying Happy People. Remove “happy” people from the instance.

Truncating HighValues. Obtain “compact” preference functions by truncating “highvalues”.

Shrinking Gaps. Shrink some of the gaps created by previous steps.
Each of the following subsections captures one of the steps above. In what follows, we let denote our current instance of AboveMin FBSM. Initially, this instance is the input instance, but as the execution of our algorithm progresses, the instance is modified. The reduction rules that we present are applied exhaustively in the order of their presentation. In other words, at each point of time, the first rule whose condition is true is the one that we apply next. In particular, the execution terminates once the value of drops below , as implied by the following rule.
Reduction Rule 1.
If , then return No.
Lemma 3.3.
Reduction Rule 1 is safe.
Proof.
For every , it holds that . Thus, if , then every satisfies . In this case, we conclude that , and therefore is a Noinstance. ∎
Note that if , then it also holds that , and that if , then . We remark that by Proposition 1, it would be clear that each of our reduction rules can indeed be implemented in polynomial time.
Cleaning Prefixes and Suffixes.
We begin by modifying the images of the preference functions. We remark that it is necessary to perform this step first as otherwise the following steps would not be correct. To clean prefixes while ensuring both safeness and that the parameter does not increase, we would actually need to clean suffixes first. Formally, we define suffixes as follows.
Definition 3.1.
Let denote an acceptable pair. If is matched by and , then we say that belongs to the suffix of . Similarly, if is matched by and , then we say that belongs to the suffix of .
By Proposition 3, we have the following observation.
Observation 2.
Let denote an acceptable pair such that one of its members belongs to the suffix of the other member. Then, there is no that matches with .
For every person , let be the person in to whom assigns its worst preference value. More precisely, . We will now clean suffixes.
Reduction Rule 2.
If there exists a person such that belongs to the suffix of , then define the preference functions as follows.

.

.

For all : .
The new instance is .
Lemma 3.4.
Reduction Rule 2 is safe, and .
Proof.
By the definition of the new preference functions, we have that for every , it holds that and . In particular, this means that to conclude that (which implies safeness) as well as that and (which implies that ), it is sufficient to show that SM. For this purpose, first consider some . By Observation 2, it holds that . Hence, is a matching in . Moreover, if has a blocking pair in , then by the definition of the new preference functions, it is also a blocking pair in . Since is stable in , we have that .
In the second direction, consider some . Then, it is clear that is a matching in . Moreover, if has a blocking pair in that is not , then is an acceptable pair in , and therefore by the definition of the new preference functions, we have that is also a blocking pair in . Hence, since is stable in , the only pair that can block in is . Thus, to show that , it remains to prove that cannot block in . Suppose, by way of contradiction, that blocks in . In particular, this means that . However, this contradicts the definition of . ∎
By cleaning suffixes, we actually also accomplish the objective of cleaning prefixes, which are defined as follows.
Definition 3.2.
Let denote an acceptable pair. If is matched by and , then we say that belongs to the prefix of . Similarly, if is matched by and , then we say that belongs to the prefix of .
Let us now claim that we have indeed succeeded in cleaning prefixes.
Lemma 3.5.
Proof.
Suppose, by way of contradiction, that there exists an acceptable pair such that one of its members belongs to the prefix of the other one. Without loss of generality, assume that belongs to the prefix of . Then, . Since is a stable matching, it cannot be blocked by , which means that is matched by and . Thus, we have that belongs to the suffix of , which contradicts the assumption that Reduction Rule 2 was applied exhaustively. ∎
As a direct result of this lemma, we have the following corollary.
Perfect Matching.
Having Corollary 3.1 at hand, we are able to provide a simple rule that allows us to assume that every solution matches all people.
Reduction Rule 3.
If there exists a person unmatched by , then let and denote the subsets of men and women, respectively, who are matched by . For each , denote , and define . The new instance is .
To prove the safeness of this rule, we first prove the following lemma.
Lemma 3.6.
Proof.
Let be a person not matched by . Then, by Proposition 2, it holds that is not matched by any stable matching. Hence, we can assume w.l.o.g. that is man . First, note that cannot contain any woman that is not matched by some stable matching, else would have formed a blocking pair for that stable matching. Second, we claim that cannot contain a woman that is matched by some stable matching. Suppose, by way of contradiction, that this claim is false. Then, by Proposition 2, it holds that contains a woman that is matched by . We have that prefers over , else would have formed a blocking pair for , which is impossible as is a stable matching. However, this implies that belongs to the suffix of , which contradicts the supposition that Reduction Rule 2 has been exhaustively applied. We thus conclude that . ∎
Lemma 3.7.
Reduction Rule 3 is safe, and .
Proof.
By the definition of the new preference functions, we have that for every , it holds that and . To conclude that the lemma is correct, it is thus sufficient to argue that SM. For this purpose, first consider some . By Proposition 2, we have that is also a matching in . Moreover, if has a blocking pair in , then by the definition of the new preference functions, it is also a blocking pair in . Since is stable in , we have that .
In the second direction, consider some . Then, it is clear that is a matching in . By Lemma 3.6, if has a blocking pair in , then both and . However, for such a blocking pair , we have that is an acceptable pair in , and therefore by the definition of the new preference functions, we have that is also a blocking pair in . Hence, since is stable in , we conclude that is also stable in . ∎
By Proposition 2, from now onwards, we have that for the given instance, any stable matching is a perfect matching. Due to this observation, we can denote , and for any stable matching , we have the following equalities.
Overcoming Sadness.
As every stable matching is a perfect matching, every person is matched by every stable matching, including the manoptimal and womanoptimal stable matchings. Thus, it is well defined to classify the people who do not have the same partner in the manoptimal and womanoptimal stable matchings as “sad”. That is,
Definition 3.3.
A person is sad if .
We let and denote the sets of sad men and sad women, respectively. People who are not sad are termed happy. Accordingly, we let and denote the sets of happy men and happy women, respectively. Note that if and only if . Moreover, note that by the definition of and , for a happy person it holds that and are matched to one another by every stable matching. Let us now bound the number of sad people in a Yesinstance.
Reduction Rule 4.
If or , then return No.
Lemma 3.8.
Reduction Rule 4 is safe.
Proof.
We only prove that if , then is a Noinstance, as the proof of the other case is symmetric to this one. Let us assume that . Suppose, by way of contradiction, that is a Yesinstance. Then, there exists a stable matching such that . Partition as follows. Set to be the set of all in such that is not the partner of in .
Accordingly, set . Since , at least one among and is (strictly) larger than . Let us first handle the case where . Then,
Here, the first inequality followed directly from the definition of . As we have reached a contradiction, it must hold that . However, we now have that
Here, the first inequality followed from the definition of . Indeed, for all , we have that , else would have belonged to . However, in this case we deduce that , and since , we have that , which implies that . As we have again reached a contradiction, we conclude the proof. ∎
Marrying Happy People.
Towards the removal of happy people, we first need to handle the special case where there are no sad people. In this case, there is exactly one stable matching, which is the manoptimal stable matching (that is equal, in this case, to the womanoptimal stable matching). This immediately implies the safeness of the following rule.
Reduction Rule 5.
If , then return Yes if and No otherwise.
Observation 3.
Reduction Rule 5 is safe.
We now turn to discard happy people. When we perform this operation, we need to ensure that the balance of the instance is preserved. More precisely, we need to ensure that , where denotes the new instance resulting from the removal of some happy people. Towards this, we let denote a happy pair, which is simply a pair of a happy man and happy woman who are matched to each other in every stable matching. Then, we redefine the preference functions in a manner that allows us to transfer the “contributions” of and from to via some sad man and woman. We remark that these sad people exist because Reduction Rule 5 does not apply. The details are as follows.
Reduction Rule 6.
If there exists a happy pair , then proceed as follows. Select an arbitrary sad man and an arbitrary sad woman . Denote and . For each person , the new preference function is defined as follows.

The preference function of . For each : .

The preference function of . For each : .

For each : .

For each : .
The new instance is .
Let us first state a lemma concerning the proof of the forward direction of the safeness of Reduction Rule 6.
Lemma 3.9.
Let . Then, is a stable matching in such that .
Proof.
We first show that . By Reduction Rule 3, it holds that is a perfect matching in . Since is a happy pair, it is clear that , and therefore is a perfect matching in . Let be some acceptable pair in . Since and it is a perfect matching, it holds that or . Let us consider these two possibilities separately.

Suppose that . If , then and , and therefore . Else, and , and therefore again .

Suppose that . Analogously to the previous case, we get that .
Since the choice of was arbitrary, we conclude that does not have a blocking pair in , and therefore . To show that , note that
This concludes the proof. ∎
To prove a lemma addressing the reverse direction, we first state the following observation, whose correctness follows directly from Corollary 3.1.
Observation 4.
Lemma 3.10.
Let . Then, is a stable matching in such that .
Proof.
We first show that . By Reduction Rule 3, it holds that is a perfect matching in . Since is a happy pair and by Observation 4, we have that is a perfect matching in such that neither nor participate in any pair that blocks (if such a pair exists). Let be some acceptable pair in such that and . Since and it is a perfect matching, it holds that or . Let us consider these two possibilities separately.

Suppose that . If , then and , and therefore . Else, and , and therefore again .

Suppose that . Analogously to the previous case, we get that .
Since the choice of was arbitrary, we conclude that does not have a blocking pair in , and therefore . To show that , we follow the exact same argument as the one present in the proof of Lemma 3.9. ∎
We now turn to justify the use of Reduction Rule 6.
Lemma 3.11.
Reduction Rule 6 is safe, and .
Proof.
Before we proceed to examine preference functions more closely, let us take a step back and prove the following result.
Lemma 3.12.
Proof.
Notice that each rule among Reduction Rules 1 to 6 can be applied in polynomial time, and it either terminates the execution of the algorithm or shrinks the size of the instance. Hence, it is clear that the instance is obtained in polynomial time, and the claim that follows from Lemmata 3.7 and 3.11. Due to Reduction Rules 3 and 6, we have that all people in are sad and matched by every stable matching. Thus, due to Reduction Rule 4, we also have that there exist at most men and at most women. ∎
Truncating HighValues.
Up until now, we have bounded the number of people. However, the images of the preference functions can contain integers that are not bounded by a function polynomial in the parameter. Thus, even though the number of people is upper bounded by , the total size of the instance can be huge. Accordingly, in what follows, we need to process the images of the preference functions. Recall that we have already modified preference functions so that they would not contain irrelevant information in their prefixes and suffixes. Our current goal is to truncate “highvalues”’ of preference functions. To understand the intuition behind the rule we present next, suppose that there exists a stable matching and a man such that . That is, matches to a woman whose position is larger than the position of the woman with whom is matched by by at least units. Then, . Hence, irrespective of whether or not the current instance is a Yesinstance, we know that is not a yescertificate. We thus observe that we should delete all those acceptable pairs whose presence in any stable matching prevents its balance from being upper bounded by