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).
- Solves
- Bankruptcy problem
- Time
- O(n log n) worst
- Space
- O(n) extra
- Where
- n = the number of claimants
- Model
- Word RAM
- Properties
- deterministicexactofflineiterative
- Evidence
- Proof sketchCode in 1 languages
- 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 and an estate with , where . The output is an award vector with and . The bankruptcy game of the problem gives each coalition of creditors what is left after the creditors outside are paid in full: , where is the sum of the claims in .
Two simple rules do most of the work. Constrained equal awards (CEA) gives , with chosen so that the awards sum to . Constrained equal losses (CEL) gives , so that every creditor loses the same amount unless it then gets nothing. The Talmud rule is
The algorithm
TALMUD(c, E)- 1
C ← c_1 + ... + c_n - 2
if E ≤ C/2: return CEA(c/2, E) - 3
ℓ ← CEA(c/2, C - E) - 4
return c - ℓ CEA(d, A)- 5
order the players so that d_1 ≤ d_2 ≤ ... ≤ d_n; rest ← A - 6
for k ← 1 to n: - 7
λ ← rest / (n - k + 1) - 8
if d_k ≤ λ: x_k ← d_k; rest ← rest - d_k - 9
else: x_j ← λ for j = k, ..., n; go to L10 - 10
return x, in the original order of the players
Lines L3 and L4 use the identity : the losses under CEL are equal awards of losses. With and the losses on the half claims add up to , and the award is . 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 , so and . It gives the division for estates of 100, 200 and 300.
- . The half claims are . Line L7 gives , so line L9 gives each wife .
- . Line L7 gives , so wife 1 gets 50, and . Next, , so wives 2 and 3 get 75 each: .
- . Every wife gets half her claim: , which here is also the proportional division.
- (not in the Mishna). Lines L3 and L4 give , and the award is , the mirror image of .
The table compares the Talmud rule with three other rules on the same claims.
| estate | Talmud | CEA | CEL | proportional |
|---|---|---|---|---|
| 100 | ||||
| 200 | ||||
| 300 | ||||
| 400 |
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 , and TALMUD returns the same: , , , and .
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 , and the first claim above the share forces . Second, lines L1 to L4 compute by the identity above. Third, 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 for a pair below half of , 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 .
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 and an estate with . An award vector has and .
Definitions. For and , constrained equal awards is , where solves . Constrained equal losses is , where solves . The Talmud rule is
Lemma 1 (CEA is well defined). The function is continuous and nondecreasing on , with and for . So some solves . If two values both do, then is constant on , so no is above , and for every . So the vector does not depend on the choice of .
Lemma 2 (lines L5 to L10 compute CEA). Let the code sort as (line L5), and let be a solution of . Before step of line L6 (counting from 1), the invariant is: the players have and for , and . Then .
- If (line L8), then . Otherwise for all , so , and , a contradiction. So paying in full is right, and the invariant holds for .
- If (line L9), then : otherwise every has , and . So every gets , and gives . Line L9 gives exactly this.
- If line L8 succeeds for every , the invariant gives for all , so , and the output is right.
All divisions are exact fractions, so the output is exactly .
Lemma 3 (lines L1 to L4 compute ). If , line L2 returns . Otherwise lines L3 and L4 return . For the losses of CEL are , so . With this gives , which is what line L4 returns. At both branches give .
Lemma 4 (self-duality). . Proof. If , then , and by Lemma 3, . The case is the same statement with and exchanged, and gives on both sides.
The contested garment rule. For two claimants with claims and an estate , let , the part of that claimant does not claim, and . The rule gives , and the same for . It is self-dual: . To see this, write and use . Then , and the difference from is . Each is nondecreasing in , because has slope 0, 1 or 2 in on each piece.
Theorem 1 (consistency). Let . For every pair , with the claims .
Proof. First let , so . Let and .
- If : then and , so and CG splits equally.
- If and : then , so , and . CG gives the amount and the rest, .
- If and : then and , and CG gives and .
- The case with is impossible, because it gives .
Now let . By Lemma 4, with and , so the first part applies to : . By the self-duality of CG, .
Theorem 2 (uniqueness). At most one award vector for is consistent with CG in the sense of Theorem 1.
Proof. Let be two such vectors. Both sum to , so there are with and with . If , then by monotonicity , a contradiction. If , then in the same way , a contradiction.
Theorem 3 (Aumann and Maschler 1985). is the nucleolus of the bankruptcy game .
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 , a vector with and a pair , the reduced game on has and . The property says: if is the prenucleolus of , then is the prenucleolus of .
Step 1: the prenucleolus of 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 and , that is, . The core is a subset of the imputations, so is also the nucleolus.
Step 2: the reduced game of a bankruptcy game at an award vector is a bankruptcy game. Take and let . Since ,
Both and are at least 0. The first term is largest, 0, at ; the second is largest, , at . So , which is the bankruptcy game of two claimants with claims and estate .
Step 3: for two players, the prenucleolus is . The excesses of and are and ; their sum is fixed by , so the larger one is smallest when they are equal. With , this is the contested garment division .
So is consistent with CG. By Theorem 1 so is , and by Theorem 2 they are equal.
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 claims in time, and the loop of lines L6 to L9 takes more. Line L1 and line L4 take . The extra space is for the order and the output. Sorting is not necessary: the level can be found in time by repeated median selection, as for a weighted median. Writing the output needs time, so this is optimal. The code uses exact fractions; with integer claims and estate, every award is an integer divided by for some .
Properties
- Self-dual. : 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 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, . It agrees with the Talmud rule only at 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 gives in place of , and CEL on the full claims gives .
- Full claims in place of half claims. CEA on the full claims gives for , which is the rule of Maimonides, not the Talmud rule.
- The upper branch without the half claims. For the award is plus CEL on with the excess , not CEL on with . For the second gives .
- Floating point. The level is a ratio, and float rounding can break the exact sum or the order of equal claims. Use fractions.
- An estate above the total claims. The rule needs . 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.
# 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
- 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
- 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
- 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
- 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)
- 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)
- 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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag J1054R Edit this page History Report an error Markdown