Algorithm Search⌘K

Algorithmcore

Talmud rule

Also called Aumann-Maschler rule, contested garment rule.

CEA on half the claims while the estate is at most half the total claims, else half claims plus CEL on the other halves. It is the nucleolus of the bankruptcy game (Aumann and Maschler 1985).

Time
O(n log n) worst
Space
O(n) extra
Where
n = the number of claimants
Properties
deterministicexactofflineiterative
Origin
Robert J. Aumann, Michael Maschler, 1985

The Talmud rule divides an estate among creditors whose claims add up to more than the estate. This page is the rule as an algorithm; the bankruptcy problem page states the problem and compares the rules. While the estate is at most half of the total claims, the Talmud rule gives each creditor an equal share, but no creditor more than half its claim. For a larger estate, each creditor first gets half its claim, and the creditors then share the losses equally on the other halves. Aumann and Maschler found this rule in 1985 behind three numerical examples of the Mishna, and they proved that it is the nucleolus of the bankruptcy game. For two creditors it is the contested garment rule of the Mishna.

In plain words

A man dies and owes more money than he leaves. If the money is short, think of half of each debt as the part that matters most. When the money covers at most half of all the debts, share it equally, but stop paying a creditor when it has half of its debt, and share the rest among the others. When the money covers more than half, give everyone half of its debt first. Then the creditors share the shortfall equally, and nobody can lose more than the other half of its debt. The two halves are mirror images: what creditors get in one case is what they lose in the other. For two creditors this says: each one gets the part of the money that the other does not claim, and they split the rest equally.

The problem

The input is a list of claims c1,…,cn≥0c_1, \ldots, c_n \ge 0 and an estate EE with 0≤E≤C0 \le E \le C, where C=c1+⋯+cnC = c_1 + \cdots + c_n. The output is an award vector xx with x1+⋯+xn=Ex_1 + \cdots + x_n = E and 0≤xi≤ci0 \le x_i \le c_i. The bankruptcy game of the problem gives each coalition SS of creditors what is left after the creditors outside SS are paid in full: v(S)=max⁡(0,E−c(N∖S))v(S) = \max(0, E - c(N \setminus S)), where c(T)c(T) is the sum of the claims in TT.

Two simple rules do most of the work. Constrained equal awards (CEA) gives min⁡(ci,λ)\min(c_i, \lambda), with λ\lambda chosen so that the awards sum to EE. Constrained equal losses (CEL) gives max⁡(0,ci−μ)\max(0, c_i - \mu), so that every creditor loses the same amount μ\mu unless it then gets nothing. The Talmud rule is

T(c,E)={CEA(c/2,E)if E≤C/2,c/2+CEL(c/2,E−C/2)if E≥C/2.T(c, E) = \begin{cases} \mathrm{CEA}(c/2, E) & \text{if } E \le C/2, \\ c/2 + \mathrm{CEL}(c/2, E - C/2) & \text{if } E \ge C/2. \end{cases}

The algorithm

  1. TALMUD(c, E)
  2. 1C ← c_1 + ... + c_n
  3. 2if E ≤ C/2: return CEA(c/2, E)
  4. 3ℓ ← CEA(c/2, C - E)
  5. 4return c - ℓ
  6. CEA(d, A)
  7. 5order the players so that d_1 ≤ d_2 ≤ ... ≤ d_n; rest ← A
  8. 6for k ← 1 to n:
  9. 7λ ← rest / (n - k + 1)
  10. 8if d_k ≤ λ: x_k ← d_k; rest ← rest - d_k
  11. 9else: x_j ← λ for j = k, ..., n; go to L10
  12. 10return x, in the original order of the players

Lines L3 and L4 use the identity CEL(d,B)=d−CEA(d,∑idi−B)\mathrm{CEL}(d, B) = d - \mathrm{CEA}(d, \sum_i d_i - B): the losses under CEL are equal awards of losses. With d=c/2d = c/2 and B=E−C/2B = E - C/2 the losses ℓ\ell on the half claims add up to C−EC - E, and the award is c/2+(c/2−ℓ)=c−ℓc/2 + (c/2 - \ell) = c - \ell. So the second branch is CEA again, applied to the losses.

The procedure CEA is water filling. Line L7 computes the share of each creditor that is not yet paid if the rest is split equally. A creditor whose claim is at most that share is paid in full in line L8, and the share of the others grows. The first creditor whose claim is above the share stops the loop: from there on every claim is above the share, so all the remaining creditors get exactly the share (line L9).

Example

The Mishna (tractate Ketubot) discusses a man with three wives whose marriage contracts are worth c=(100,200,300)c = (100, 200, 300), so C=600C = 600 and C/2=300C/2 = 300. It gives the division for estates of 100, 200 and 300.

  • E=100E = 100. The half claims are (50,100,150)(50, 100, 150). Line L7 gives λ=100/3<50\lambda = 100/3 < 50, so line L9 gives each wife 100/3100/3.
  • E=200E = 200. Line L7 gives λ=200/3≥50\lambda = 200/3 \ge 50, so wife 1 gets 50, and rest=150\mathit{rest} = 150. Next, λ=150/2=75<100\lambda = 150/2 = 75 < 100, so wives 2 and 3 get 75 each: (50,75,75)(50, 75, 75).
  • E=300=C/2E = 300 = C/2. Every wife gets half her claim: (50,100,150)(50, 100, 150), which here is also the proportional division.
  • E=400E = 400 (not in the Mishna). Lines L3 and L4 give ℓ=CEA((50,100,150),200)=(50,75,75)\ell = \mathrm{CEA}((50, 100, 150), 200) = (50, 75, 75), and the award is c−ℓ=(50,125,225)c - \ell = (50, 125, 225), the mirror image of E=200E = 200.

The table compares the Talmud rule with three other rules on the same claims.

estate Talmud CEA CEL proportional
100 (100/3,100/3,100/3)(100/3, 100/3, 100/3) (100/3,100/3,100/3)(100/3, 100/3, 100/3) (0,0,100)(0, 0, 100) (50/3,100/3,50)(50/3, 100/3, 50)
200 (50,75,75)(50, 75, 75) (200/3,200/3,200/3)(200/3, 200/3, 200/3) (0,50,150)(0, 50, 150) (100/3,200/3,100)(100/3, 200/3, 100)
300 (50,100,150)(50, 100, 150) (100,100,100)(100, 100, 100) (0,100,200)(0, 100, 200) (50,100,150)(50, 100, 150)
400 (50,125,225)(50, 125, 225) (100,150,150)(100, 150, 150) (100/3,400/3,700/3)(100/3, 400/3, 700/3) (200/3,400/3,200)(200/3, 400/3, 200)

The contested garment (tractate Bava Metzia) is the case of two claimants: one claims the whole garment, worth 1, and the other claims half of it. The second claimant does not claim the other half, so the first gets it; the half that both claim is split equally. The result is (3/4,1/4)(3/4, 1/4), and TALMUD((1,1/2),1)((1, 1/2), 1) returns the same: C=3/2C = 3/2, E=1>3/4E = 1 > 3/4, ℓ=CEA((1/2,1/4),1/2)=(1/4,1/4)\ell = \mathrm{CEA}((1/2, 1/4), 1/2) = (1/4, 1/4), and c−ℓ=(3/4,1/4)c - \ell = (3/4, 1/4).

Correctness

The file proofs/correctness.md proves four things. First, lines L5 to L10 compute CEA exactly: the loop keeps the invariant that the creditors paid so far have claims at most the true level λ∗\lambda^*, and the first claim above the share forces λ∗=rest/(n−k+1)\lambda^* = \mathit{rest}/(n - k + 1). Second, lines L1 to L4 compute TT by the identity above. Third, TT is consistent with the contested garment rule: for every pair of creditors, the amount they get together is divided between them as the contested garment rule divides it. The proof checks the three cases of min⁡(ck/2,λ)\min(c_k/2, \lambda) for a pair below half of CC, and uses the self-duality of both rules above half. At most one award vector has this property, because the contested garment awards are nondecreasing in the estate. Fourth, the nucleolus of the bankruptcy game is also consistent with the contested garment rule. For this the proof uses the reduced game property of the prenucleolus (Sobolev 1975, in Peleg and Sudholter, Chapter 6), shows that the reduced game of a bankruptcy game on a pair is the bankruptcy game of that pair, and solves the two-player case. So the nucleolus is TT.

Proof: The code computes the Talmud rule, which is consistent with the contested garment rule and equals the nucleolusfull

A bankruptcy problem is a vector of claims c=(c1,…,cn)≥0c = (c_1, \ldots, c_n) \ge 0 and an estate EE with 0≤E≤C=c1+⋯+cn0 \le E \le C = c_1 + \cdots + c_n. An award vector xx has ∑ixi=E\sum_i x_i = E and 0≤xi≤ci0 \le x_i \le c_i.

Definitions. For d≥0d \ge 0 and 0≤A≤∑idi0 \le A \le \sum_i d_i, constrained equal awards is CEA(d,A)i=min⁡(di,λ)\mathrm{CEA}(d, A)_i = \min(d_i, \lambda), where λ\lambda solves ∑imin⁡(di,λ)=A\sum_i \min(d_i, \lambda) = A. Constrained equal losses is CEL(d,A)i=max⁡(0,di−μ)\mathrm{CEL}(d, A)_i = \max(0, d_i - \mu), where μ\mu solves ∑imax⁡(0,di−μ)=A\sum_i \max(0, d_i - \mu) = A. The Talmud rule is

T(c,E)={CEA(c/2,E)if E≤C/2,c/2+CEL(c/2,E−C/2)if E≥C/2.T(c, E) = \begin{cases} \mathrm{CEA}(c/2, E) & \text{if } E \le C/2, \\ c/2 + \mathrm{CEL}(c/2, E - C/2) & \text{if } E \ge C/2. \end{cases}

Lemma 1 (CEA is well defined). The function g(λ)=∑imin⁡(di,λ)g(\lambda) = \sum_i \min(d_i, \lambda) is continuous and nondecreasing on [0,∞)[0, \infty), with g(0)=0g(0) = 0 and g(λ)=∑idig(\lambda) = \sum_i d_i for λ≥max⁡idi\lambda \ge \max_i d_i. So some λ\lambda solves g(λ)=Ag(\lambda) = A. If two values λ<λ′\lambda < \lambda' both do, then gg is constant on [λ,λ′][\lambda, \lambda'], so no did_i is above λ\lambda, and min⁡(di,λ)=di=min⁡(di,λ′)\min(d_i, \lambda) = d_i = \min(d_i, \lambda') for every ii. So the vector CEA(d,A)\mathrm{CEA}(d, A) does not depend on the choice of λ\lambda. □\square

Lemma 2 (lines L5 to L10 compute CEA). Let the code sort dd as d(1)≤⋯≤d(n)d_{(1)} \le \cdots \le d_{(n)} (line L5), and let λ∗\lambda^* be a solution of g(λ)=Ag(\lambda) = A. Before step kk of line L6 (counting from 1), the invariant is: the players (1),…,(k−1)(1), \ldots, (k-1) have x=dx = d and d(j)≤λ∗d_{(j)} \le \lambda^* for j<kj < k, and rest=A−∑j<kd(j)\mathit{rest} = A - \sum_{j < k} d_{(j)}. Then ∑j≥kmin⁡(d(j),λ∗)=rest\sum_{j \ge k} \min(d_{(j)}, \lambda^*) = \mathit{rest}.

  • If d(k)≤rest/(n−k+1)d_{(k)} \le \mathit{rest}/(n - k + 1) (line L8), then d(k)≤λ∗d_{(k)} \le \lambda^*. Otherwise λ∗<d(k)≤d(j)\lambda^* < d_{(k)} \le d_{(j)} for all j≥kj \ge k, so rest=(n−k+1)λ∗\mathit{rest} = (n - k + 1)\lambda^*, and λ∗=rest/(n−k+1)≥d(k)\lambda^* = \mathit{rest}/(n - k + 1) \ge d_{(k)}, a contradiction. So paying d(k)d_{(k)} in full is right, and the invariant holds for k+1k + 1.
  • If d(k)>λ=rest/(n−k+1)d_{(k)} > \lambda = \mathit{rest}/(n - k + 1) (line L9), then λ∗<d(k)\lambda^* < d_{(k)}: otherwise every j≥kj \ge k has min⁡(d(j),λ∗)≥d(k)\min(d_{(j)}, \lambda^*) \ge d_{(k)}, and rest≥(n−k+1)d(k)>rest\mathit{rest} \ge (n - k + 1) d_{(k)} > \mathit{rest}. So every j≥kj \ge k gets λ∗\lambda^*, and (n−k+1)λ∗=rest(n - k + 1)\lambda^* = \mathit{rest} gives λ∗=λ\lambda^* = \lambda. Line L9 gives exactly this.
  • If line L8 succeeds for every kk, the invariant gives d(j)≤λ∗d_{(j)} \le \lambda^* for all jj, so A=g(λ∗)=∑jdjA = g(\lambda^*) = \sum_j d_j, and the output x=dx = d is right.

All divisions are exact fractions, so the output is exactly CEA(d,A)\mathrm{CEA}(d, A). □\square

Lemma 3 (lines L1 to L4 compute TT). If E≤C/2E \le C/2, line L2 returns CEA(c/2,E)\mathrm{CEA}(c/2, E). Otherwise lines L3 and L4 return c−CEA(c/2,C−E)c - \mathrm{CEA}(c/2, C - E). For d=c/2d = c/2 the losses of CEL are di−max⁡(0,di−μ)=min⁡(di,μ)d_i - \max(0, d_i - \mu) = \min(d_i, \mu), so CEL(d,B)=d−CEA(d,∑idi−B)\mathrm{CEL}(d, B) = d - \mathrm{CEA}(d, \sum_i d_i - B). With B=E−C/2B = E - C/2 this gives c/2+CEL(c/2,E−C/2)=c/2+c/2−CEA(c/2,C−E)c/2 + \mathrm{CEL}(c/2, E - C/2) = c/2 + c/2 - \mathrm{CEA}(c/2, C - E), which is what line L4 returns. At E=C/2E = C/2 both branches give c/2c/2. □\square

Lemma 4 (self-duality). T(c,C−E)=c−T(c,E)T(c, C - E) = c - T(c, E). Proof. If E<C/2E < C/2, then C−E>C/2C - E > C/2, and by Lemma 3, T(c,C−E)=c−CEA(c/2,E)=c−T(c,E)T(c, C - E) = c - \mathrm{CEA}(c/2, E) = c - T(c, E). The case E>C/2E > C/2 is the same statement with EE and C−EC - E exchanged, and E=C/2E = C/2 gives c/2c/2 on both sides. □\square

The contested garment rule. For two claimants with claims ci,cjc_i, c_j and an estate e≤ci+cje \le c_i + c_j, let ai=max⁡(0,e−cj)a_i = \max(0, e - c_j), the part of ee that claimant jj does not claim, and aj=max⁡(0,e−ci)a_j = \max(0, e - c_i). The rule gives CGi(e)=ai+(e−ai−aj)/2=(e+ai−aj)/2\mathrm{CG}_i(e) = a_i + (e - a_i - a_j)/2 = (e + a_i - a_j)/2, and the same for jj. It is self-dual: ci−CGi(ci+cj−e)=CGi(e)c_i - \mathrm{CG}_i(c_i + c_j - e) = \mathrm{CG}_i(e). To see this, write p(z)=max⁡(0,z)p(z) = \max(0, z) and use p(z)−p(−z)=zp(z) - p(-z) = z. Then ci−CGi(ci+cj−e)=12(ci−cj+e−p(ci−e)+p(cj−e))c_i - \mathrm{CG}_i(c_i + c_j - e) = \tfrac12 (c_i - c_j + e - p(c_i - e) + p(c_j - e)), and the difference from 12(e+p(e−cj)−p(e−ci))\tfrac12 (e + p(e - c_j) - p(e - c_i)) is 12(ci−cj+(cj−e)+(e−ci))=0\tfrac12 (c_i - c_j + (c_j - e) + (e - c_i)) = 0. Each CGi(e)\mathrm{CG}_i(e) is nondecreasing in ee, because e+ai−aje + a_i - a_j has slope 0, 1 or 2 in ee on each piece.

Theorem 1 (consistency). Let x=T(c,E)x = T(c, E). For every pair i≠ji \ne j, (xi,xj)=CG(xi+xj)(x_i, x_j) = \mathrm{CG}(x_i + x_j) with the claims ci,cjc_i, c_j.

Proof. First let E≤C/2E \le C/2, so xk=min⁡(ck/2,λ)x_k = \min(c_k/2, \lambda). Let ci≤cjc_i \le c_j and e=xi+xje = x_i + x_j.

  • If xi=xj=λx_i = x_j = \lambda: then λ≤ci/2\lambda \le c_i/2 and e=2λ≤ci≤cje = 2\lambda \le c_i \le c_j, so ai=aj=0a_i = a_j = 0 and CG splits ee equally.
  • If xi=ci/2≤λx_i = c_i/2 \le \lambda and xj=λ≤cj/2x_j = \lambda \le c_j/2: then e−cj≤ci/2−cj/2≤0e - c_j \le c_i/2 - c_j/2 \le 0, so ai=0a_i = 0, and aj=λ−ci/2≥0a_j = \lambda - c_i/2 \ge 0. CG gives ii the amount (e−aj)/2=ci/2(e - a_j)/2 = c_i/2 and jj the rest, λ\lambda.
  • If xi=ci/2x_i = c_i/2 and xj=cj/2x_j = c_j/2: then ai=0a_i = 0 and aj=(cj−ci)/2a_j = (c_j - c_i)/2, and CG gives ci/2c_i/2 and cj/2c_j/2.
  • The case xj=cj/2x_j = c_j/2 with xi=λ<ci/2x_i = \lambda < c_i/2 is impossible, because it gives λ<ci/2≤cj/2≤λ\lambda < c_i/2 \le c_j/2 \le \lambda.

Now let E>C/2E > C/2. By Lemma 4, x=c−yx = c - y with y=T(c,C−E)y = T(c, C - E) and C−E<C/2C - E < C/2, so the first part applies to yy: (yi,yj)=CG(yi+yj)(y_i, y_j) = \mathrm{CG}(y_i + y_j). By the self-duality of CG, (xi,xj)=(ci−yi,cj−yj)=CG(ci+cj−yi−yj)=CG(xi+xj)(x_i, x_j) = (c_i - y_i, c_j - y_j) = \mathrm{CG}(c_i + c_j - y_i - y_j) = \mathrm{CG}(x_i + x_j). □\square

Theorem 2 (uniqueness). At most one award vector for (c,E)(c, E) is consistent with CG in the sense of Theorem 1.

Proof. Let x≠yx \ne y be two such vectors. Both sum to EE, so there are ii with xi<yix_i < y_i and jj with xj>yjx_j > y_j. If xi+xj≤yi+yjx_i + x_j \le y_i + y_j, then by monotonicity xj=CGj(xi+xj)≤CGj(yi+yj)=yjx_j = \mathrm{CG}_j(x_i + x_j) \le \mathrm{CG}_j(y_i + y_j) = y_j, a contradiction. If xi+xj>yi+yjx_i + x_j > y_i + y_j, then in the same way xi≥yix_i \ge y_i, a contradiction. □\square

Theorem 3 (Aumann and Maschler 1985). T(c,E)T(c, E) is the nucleolus of the bankruptcy game v(S)=max⁡(0,E−c(N∖S))v(S) = \max(0, E - c(N \setminus S)).

Proof. This proof uses one cited result: the prenucleolus has the reduced game property of Davis and Maschler (Sobolev 1975; Peleg and Sudholter 2007, Chapter 6). For a game (N,v)(N, v), a vector xx with x(N)=v(N)x(N) = v(N) and a pair {i,j}\{i, j\}, the reduced game ww on {i,j}\{i, j\} has w({i,j})=xi+xjw(\{i, j\}) = x_i + x_j and w({i})=max⁡Q⊆N∖{i,j}(v({i}∪Q)−x(Q))w(\{i\}) = \max_{Q \subseteq N \setminus \{i, j\}} (v(\{i\} \cup Q) - x(Q)). The property says: if xx is the prenucleolus of vv, then (xi,xj)(x_i, x_j) is the prenucleolus of ww.

Step 1: the prenucleolus ν\nu of vv is an award vector. The game is convex (Curiel, Maschler and Tijs 1987), so its core is not empty, and the prenucleolus lies in the core; core points satisfy xi≥v({i})≥0x_i \ge v(\{i\}) \ge 0 and x(N∖{i})≥v(N∖{i})≥E−cix(N \setminus \{i\}) \ge v(N \setminus \{i\}) \ge E - c_i, that is, xi≤cix_i \le c_i. The core is a subset of the imputations, so ν\nu is also the nucleolus.

Step 2: the reduced game of a bankruptcy game at an award vector xx is a bankruptcy game. Take Q⊆N∖{i,j}Q \subseteq N \setminus \{i, j\} and let R=N∖({i,j}∪Q)R = N \setminus (\{i, j\} \cup Q). Since E=xi+xj+x(Q)+x(R)E = x_i + x_j + x(Q) + x(R),

v({i}∪Q)−x(Q)=max⁡(−x(Q), xi+xj−cj−(c(R)−x(R))).v(\{i\} \cup Q) - x(Q) = \max\big({-x(Q)},\ x_i + x_j - c_j - (c(R) - x(R))\big).

Both x(Q)x(Q) and c(R)−x(R)c(R) - x(R) are at least 0. The first term is largest, 0, at Q=∅Q = \emptyset; the second is largest, xi+xj−cjx_i + x_j - c_j, at R=∅R = \emptyset. So w({i})=max⁡(0,xi+xj−cj)w(\{i\}) = \max(0, x_i + x_j - c_j), which is the bankruptcy game of two claimants with claims ci,cjc_i, c_j and estate xi+xjx_i + x_j.

Step 3: for two players, the prenucleolus is xi=w({i})+(w({i,j})−w({i})−w({j}))/2x_i = w(\{i\}) + (w(\{i, j\}) - w(\{i\}) - w(\{j\}))/2. The excesses of {i}\{i\} and {j}\{j\} are w({i})−xiw(\{i\}) - x_i and w({j})−xjw(\{j\}) - x_j; their sum is fixed by xi+xj=w({i,j})x_i + x_j = w(\{i, j\}), so the larger one is smallest when they are equal. With w({i})=aiw(\{i\}) = a_i, this is the contested garment division CG(xi+xj)\mathrm{CG}(x_i + x_j).

So ν\nu is consistent with CG. By Theorem 1 so is T(c,E)T(c, E), and by Theorem 2 they are equal. □\square

Remark. The tests in impl/python/test_talmud_rule.py check the Mishna values, Theorem 1 on 300 random problems, Lemma 4, a second implementation of CEA that tries every breakpoint, and Theorem 3 against a brute-force lexicographic minimum over a grid of imputations with step 1/6 for 2 and 3 claimants.

Complexity

Line L5 sorts the nn claims in O(nlog⁡n)O(n \log n) time, and the loop of lines L6 to L9 takes O(n)O(n) more. Line L1 and line L4 take O(n)O(n). The extra space is O(n)O(n) for the order and the output. Sorting is not necessary: the level λ\lambda can be found in O(n)O(n) time by repeated median selection, as for a weighted median. Writing the output needs Ω(n)\Omega(n) time, so this is optimal. The code uses exact fractions; with integer claims and estate, every award is an integer divided by 2m2m for some m≤nm \le n.

Properties

  • Self-dual. T(c,C−E)=c−T(c,E)T(c, C - E) = c - T(c, E): dividing the losses by the rule gives the same result as dividing the estate. The 400 row of the table is the mirror of the 200 row.
  • Consistent. If some creditors leave with their awards, the rule applied to the others and the money left gives them the same awards. For pairs this is the contested garment property proved on this page.
  • Order preserving. A larger claim never gets a smaller award or a smaller loss.
  • Half claims are a threshold. Below E=C/2E = C/2 every award is at most half its claim, and above it every award is at least half its claim.
  • Monotone in the estate. No creditor gets less when the estate grows.
  • In the core. As the nucleolus of a convex game, the award vector is in the core of the bankruptcy game: no group of creditors gets less than what is left for it after the others are paid in full.

Variants and improvements

  • Constrained equal awards. CEA on the full claims, the rule that Maimonides proposed. It protects small claims.
  • Constrained equal losses. CEL on the full claims. It protects large claims.
  • Proportional rule. Awards proportional to the claims, xi=Eci/Cx_i = E c_i / C. It agrees with the Talmud rule only at E=C/2E = C/2 and in special cases.
  • Random arrival rule. The creditors arrive in a random order and each is paid in full or with what is left. O'Neill studied it in 1982; it is the Shapley value of the bankruptcy game, while the Talmud rule is its nucleolus.
  • The general nucleolus. For other cooperative games, the sequential LP computes the nucleolus with exponentially many constraints. The Talmud rule is the fast special case for bankruptcy games, and the tests of the sequential LP check it against these values.

When to use it

Use the Talmud rule when an estate, a budget or a capacity must be divided among claims that exceed it, and the parties accept the idea that half of each claim is the part to protect first. It is a good choice when the division must not change if a subgroup redivides its share (consistency), and when gains and losses must be treated in the same way (self-duality). If the claims have a natural order of time, the random arrival rule or a priority rule may be a better match. If the law asks for shares proportional to the claims, use the proportional rule.

Pitfalls

  • CEL in place of CEA below half. Both branches use the half claims, and the lower branch is CEA, not CEL. Using CEL on the half claims for E=200E = 200 gives (50/3,200/3,350/3)(50/3, 200/3, 350/3) in place of (50,75,75)(50, 75, 75), and CEL on the full claims gives (0,50,150)(0, 50, 150).
  • Full claims in place of half claims. CEA on the full claims gives (200/3,200/3,200/3)(200/3, 200/3, 200/3) for E=200E = 200, which is the rule of Maimonides, not the Talmud rule.
  • The upper branch without the half claims. For E>C/2E > C/2 the award is c/2c/2 plus CEL on c/2c/2 with the excess E−C/2E - C/2, not CEL on cc with EE. For E=400E = 400 the second gives (100/3,400/3,700/3)(100/3, 400/3, 700/3).
  • Floating point. The level λ\lambda is a ratio, and float rounding can break the exact sum EE or the order of equal claims. Use fractions.
  • An estate above the total claims. The rule needs E≤CE \le C. The code raises an error otherwise.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

talmud_rule.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/talmud-rule/. The authors are listed in prov/J1054R.jsonl.
"""The Talmud rule for bankruptcy problems (Aumann and Maschler 1985).

A bankruptcy problem is a list of claims c_1, ..., c_n >= 0 and an estate E with
0 <= E <= C = c_1 + ... + c_n. The Talmud rule gives constrained equal awards on the
half claims while E <= C/2, and for a larger estate it gives each claimant half its claim
plus constrained equal losses on the other half. It equals the nucleolus of the bankruptcy
game v(S) = max(0, E - c(N minus S)).

All arithmetic is in Fraction, so the result is exact. The cost is O(n log n) for the sort.
"""

from fractions import Fraction


def _check(claims, estate):
    claims = [Fraction(c) for c in claims]
    estate = Fraction(estate)
    if any(c < 0 for c in claims):
        raise ValueError("claims must be nonnegative")
    if estate < 0 or estate > sum(claims):
        raise ValueError("the estate must be between 0 and the sum of the claims")
    return claims, estate


def cea(claims, amount):
    """Constrained equal awards: x_i = min(c_i, lam) with sum x = amount."""
    claims, amount = _check(claims, amount)
    n = len(claims)
    order = sorted(range(n), key=lambda i: claims[i])  # @line L5
    x = [Fraction(0)] * n
    rest = amount
    for k, i in enumerate(order):  # @line L6
        lam = rest / (n - k)  # @line L7
        if claims[i] <= lam:  # @line L8
            x[i] = claims[i]
            rest -= claims[i]
        else:
            for j in order[k:]:  # @line L9
                x[j] = lam
            break
    return x  # @line L10


def cel(claims, amount):
    """Constrained equal losses: x_i = max(0, c_i - mu) with sum x = amount."""
    claims, amount = _check(claims, amount)
    loss = cea(claims, sum(claims) - amount)
    return [c - l for c, l in zip(claims, loss)]


def talmud(claims, estate):
    """Return the Talmud awards as a list of Fractions, in the order of the claims."""
    claims, estate = _check(claims, estate)
    total = sum(claims)  # @line L1
    half = [c / 2 for c in claims]
    if estate <= total / 2:  # @line L2
        return cea(half, estate)
    loss = cea(half, total - estate)  # @line L3
    return [c - l for c, l in zip(claims, loss)]  # @line L4


def contested_garment(c1, c2, estate):
    """The two-claimant rule of the Mishna: each concedes what exceeds its own claim, the
    rest is split equally."""
    (c1, c2), estate = _check([c1, c2], estate)
    a1 = max(Fraction(0), estate - c2)  # conceded to claimant 1 by claimant 2
    a2 = max(Fraction(0), estate - c1)
    rest = estate - a1 - a2
    return [a1 + rest / 2, a2 + rest / 2]
test_talmud_rule.py 190 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/talmud-rule/. The authors are listed in prov/J1054R.jsonl.
"""Tests for talmud_rule: the Mishna values, consistency, duality and the nucleolus."""

import itertools
import random
import unittest
from fractions import Fraction as F

from talmud_rule import cea, cel, contested_garment, talmud


def cea_by_breakpoints(claims, amount):
    """A second CEA: try each number k of fully paid claimants and solve for lam."""
    claims = [F(c) for c in claims]
    n = len(claims)
    s = sorted(claims)
    for k in range(n):
        lam = (F(amount) - sum(s[:k])) / (n - k)
        low = s[k - 1] if k else F(0)
        if low <= lam <= s[k]:
            return [min(c, lam) for c in claims]
    return list(claims)


def talmud_by_formula(claims, estate):
    """The Talmud rule written as CEA or CEL on the half claims."""
    claims = [F(c) for c in claims]
    half = [c / 2 for c in claims]
    total = sum(claims)
    if estate <= total / 2:
        return cea_by_breakpoints(half, estate)
    extra = cel(half, F(estate) - total / 2)
    return [h + e for h, e in zip(half, extra)]


def bankruptcy_game(claims, estate):
    n = len(claims)
    v = [F(0)] * (1 << n)
    for S in range(1, 1 << n):
        rest = sum(claims[i] for i in range(n) if not S >> i & 1)
        v[S] = max(F(0), F(estate) - rest)
    return v


def theta(v, x):
    n = len(x)
    full = (1 << n) - 1
    ex = []
    for S in range(1, full):
        ex.append(v[S] - sum(x[i] for i in range(n) if S >> i & 1))
    return sorted(ex, reverse=True)


def grid_nucleolus(claims, estate, D):
    """The lexicographic minimum of the sorted excesses over the imputations on a 1/D grid.
    In a bankruptcy game v({i}) = max(0, E - sum of the other claims)."""
    n = len(claims)
    v = bankruptcy_game(claims, estate)
    base = [v[1 << i] for i in range(n)]
    slack = int((F(estate) - sum(base)) * D)
    best = None
    for ks in itertools.product(range(slack + 1), repeat=n - 1):
        last = slack - sum(ks)
        if last < 0:
            continue
        x = [base[i] + F(k, D) for i, k in enumerate(list(ks) + [last])]
        key = theta(v, x)
        if best is None or key < best[0]:
            best = (key, x)
    return best[1]


def random_problem(rng, n, top):
    claims = [rng.randint(0, top) for _ in range(n)]
    if sum(claims) == 0:
        claims[0] = 1
    estate = F(rng.randint(0, 4 * sum(claims)), 4)
    return claims, estate


class CheckValues(unittest.TestCase):
    def test_mishna_table(self):
        claims = [100, 200, 300]
        self.assertEqual(talmud(claims, 100), [F(100, 3)] * 3)
        self.assertEqual(talmud(claims, 200), [50, 75, 75])
        self.assertEqual(talmud(claims, 300), [50, 100, 150])

    def test_contested_garment(self):
        self.assertEqual(contested_garment(1, F(1, 2), 1), [F(3, 4), F(1, 4)])
        self.assertEqual(talmud([1, F(1, 2)], 1), [F(3, 4), F(1, 4)])

    def test_cea_cel(self):
        self.assertEqual(cea([100, 200, 300], 200), [F(200, 3)] * 3)
        self.assertEqual(cea([100, 200, 300], 400), [100, 150, 150])
        self.assertEqual(cel([100, 200, 300], 300), [0, 100, 200])
        self.assertEqual(cel([100, 200, 300], 450), [50, 150, 250])

    def test_edges(self):
        self.assertEqual(talmud([5], 3), [3])
        self.assertEqual(talmud([4, 6], 0), [0, 0])
        self.assertEqual(talmud([4, 6], 10), [4, 6])
        self.assertEqual(talmud([4, 6], 5), [2, 3])
        self.assertEqual(talmud([0, 6], 4), [0, 4])
        self.assertEqual(talmud([3, 3, 3], 4), [F(4, 3)] * 3)

    def test_bad_input(self):
        with self.assertRaises(ValueError):
            talmud([1, 2], 4)
        with self.assertRaises(ValueError):
            talmud([1, -2], 0)
        with self.assertRaises(ValueError):
            talmud([1, 2], -1)


class Properties(unittest.TestCase):
    def setUp(self):
        rng = random.Random(2024)
        self.cases = [random_problem(rng, rng.randint(1, 6), 20) for _ in range(300)]

    def test_feasible(self):
        for c, E in self.cases:
            x = talmud(c, E)
            self.assertEqual(sum(x), E)
            self.assertTrue(all(0 <= xi <= ci for xi, ci in zip(x, c)))

    def test_second_implementation(self):
        for c, E in self.cases:
            self.assertEqual(talmud(c, E), talmud_by_formula(c, E))
            self.assertEqual(cea(c, min(E, sum(c))), cea_by_breakpoints(c, min(E, sum(c))))

    def test_self_dual(self):
        for c, E in self.cases:
            x = talmud(c, E)
            y = talmud(c, sum(c) - E)
            self.assertEqual(y, [ci - xi for ci, xi in zip(c, x)])

    def test_order_preserving(self):
        for c, E in self.cases:
            x = talmud(c, E)
            for i, j in itertools.combinations(range(len(c)), 2):
                if c[i] <= c[j]:
                    self.assertLessEqual(x[i], x[j])
                    self.assertLessEqual(c[i] - x[i], c[j] - x[j])

    def test_half_claims(self):
        for c, E in self.cases:
            x = talmud(c, E)
            half = sum(c) / F(2)
            for xi, ci in zip(x, c):
                if E <= half:
                    self.assertLessEqual(xi, F(ci, 2))
                else:
                    self.assertGreaterEqual(xi, F(ci, 2))

    def test_contested_garment_consistent(self):
        for c, E in self.cases:
            x = talmud(c, E)
            for i, j in itertools.combinations(range(len(c)), 2):
                self.assertEqual([x[i], x[j]], contested_garment(c[i], c[j], x[i] + x[j]))

    def test_estate_monotone(self):
        rng = random.Random(5)
        for _ in range(40):
            c = [rng.randint(0, 15) for _ in range(rng.randint(1, 5))]
            prev = None
            for k in range(4 * sum(c) + 1):
                x = talmud(c, F(k, 4))
                if prev is not None:
                    self.assertTrue(all(a <= b for a, b in zip(prev, x)))
                prev = x


class Nucleolus(unittest.TestCase):
    def test_grid_nucleolus(self):
        rng = random.Random(77)
        cases = [([100, 200, 300], 100), ([100, 200, 300], 200), ([100, 200, 300], 300)]
        scaled = [([c // 50 for c in cl], E // 50) for cl, E in cases]
        for _ in range(12):
            n = rng.randint(2, 3)
            c = [rng.randint(0, 5) for _ in range(n)]
            if sum(c) == 0:
                continue
            scaled.append((c, rng.randint(0, sum(c))))
        for c, E in scaled:
            self.assertEqual(grid_nucleolus(c, E, 6), talmud(c, E), (c, E))


if __name__ == "__main__":
    unittest.main()

History

The Mishna, compiled around 200 CE, gives the three divisions of the table in tractate Ketubot (in the Babylonian Talmud, Ketubot 93a) and the contested garment in tractate Bava Metzia (Bava Metzia 2a). The garment division is easy to explain, but the estate divisions looked inconsistent: the first is equal, the third is proportional, and the second is neither. O'Neill studied the problem with game theory in 1982. Aumann and Maschler showed in 1985 that all three divisions follow one rule, the unique division that is consistent with the contested garment rule, and that this rule is the nucleolus of the bankruptcy game. Curiel, Maschler and Tijs showed in 1987 that bankruptcy games are convex. Thomson's survey of 2003 places the rule among the main division rules and their axioms.

References

  1. Robert J. Aumann and Michael Maschler, Game theoretic analysis of a bankruptcy problem from the Talmud, Journal of Economic Theory 36(2) (1985), 195-213, the contested garment rule, the consistent extension to n claimants, its description by half claims, and the theorem that it is the nucleolus of the bankruptcy game
  2. Barry O'Neill, A problem of rights arbitration from the Talmud, Mathematical Social Sciences 2(4) (1982), 345-371, the first game theoretic study of the Talmud division problems, and the random arrival rule
  3. Imma J. Curiel, Michael Maschler and Stef H. Tijs, Bankruptcy games, Zeitschrift fur Operations Research 31(5) (1987), A143-A159, bankruptcy games are convex, and the rules that correspond to solutions of the game
  4. William Thomson, Axiomatic and game-theoretic analysis of bankruptcy and taxation problems, a survey, Mathematical Social Sciences 45(3) (2003), 249-297, the Talmud rule among the main rules, with its axioms (self-duality, consistency, order preservation)
  5. Michael Maschler, Eilon Solan and Shmuel Zamir, Game Theory, Cambridge University Press, 2013, Section 20.8, The bankruptcy problem (the Talmud examples and the nucleolus of the bankruptcy game)
  6. Introduction to the Theory of Cooperative Games, Chapter 6, The prenucleolus (the reduced game property of Davis and Maschler, used in the proof that the rule is the nucleolus)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example