Algorithm Search⌘K

Definitioncore

l-diversity

Also called l-diverse table.

Requires each group of records with the same quasi-identifiers to hold at least l well-represented values of the sensitive attribute.

l-diversity is a condition on a released table that protects the sensitive values, not only the identities. k-anonymity makes each record look like at least k−1k - 1 others on the quasi-identifier, so a linkage attack can only find a group of records. But if all records of that group have the same diagnosis, the attacker learns the diagnosis anyway. Machanavajjhala, Gehrke, Kifer and Venkitasubramaniam (ICDE 2006) named this the homogeneity attack, and they asked that each group hold at least ll "well-represented" sensitive values. They gave three exact meanings of "well-represented": distinct, entropy and recursive (c,l)(c, l). The value of ll, and of cc, is a policy choice of the publisher, not a result. l-diversity is a syntactic condition on one release; it gives no bound of the kind that differential privacy gives, and t-closeness shows two attacks that it does not stop.

Definition

A table TT has a set QQ of quasi-identifier attributes and one sensitive attribute SS. The rows of TT that have the same values on QQ form a block (the paper says a q⋆q^\star-block; other papers say an equivalence class). For a block EE and a sensitive value ss, let n(E,s)n(E, s) be the number of rows of EE with value ss, and let p(E,s)=n(E,s)/∣E∣p(E, s) = n(E, s) / |E|. Sort the counts of the values that occur in EE as r1≥r2≥⋯≥rm>0r_1 \ge r_2 \ge \cdots \ge r_m > 0, so mm is the number of distinct sensitive values in EE and r1+⋯+rm=∣E∣r_1 + \cdots + r_m = |E|.

The principle. A block is ll-diverse if it holds at least ll well-represented values of SS. A table is ll-diverse if every block is ll-diverse. The three instances below make "well-represented" exact. Each one is a property of single blocks, so a table has it if and only if every block has it.

  1. Distinct ll-diversity. m≥lm \ge l: the block holds at least ll distinct sensitive values.
  2. Entropy ll-diversity. The Shannon entropy of the block is at least log⁡l\log l:
H(E)=−∑sp(E,s)log⁡p(E,s) ≥ log⁡l.H(E) = -\sum_{s} p(E, s) \log p(E, s) \ \ge\ \log l.

The base of the logarithm does not matter, as long as both sides use the same base. Multiply by ∣E∣|E| and take exponentials: the condition is the same as the integer test ∣E∣∣E∣≥l∣E∣ r1r1r2r2⋯rmrm|E|^{|E|} \ge l^{|E|} \, r_1^{r_1} r_2^{r_2} \cdots r_m^{r_m}, which needs no floating point. 3. Recursive (c,l)(c, l)-diversity. For a constant c>0c > 0,

r1<c (rl+rl+1+⋯+rm).r_1 < c \, (r_l + r_{l+1} + \cdots + r_m).

The most frequent value must not be too frequent compared with the tail that remains after the l−1l - 1 most frequent values. If m<lm < l the tail is empty, the right side is 0, and the block fails.

Some facts follow at once, and each is a theorem:

  • Entropy and recursive imply distinct. H(E)≤log⁡mH(E) \le \log m, with equality for the uniform distribution, so H(E)≥log⁡lH(E) \ge \log l forces m≥lm \ge l. A recursive (c,l)(c, l)-diverse block has a non-empty tail, so m≥lm \ge l.
  • A bound on the whole table. The distribution of SS in TT is the mixture of the block distributions, with weights ∣E∣/∣T∣|E| / |T|. Entropy is concave, so H(T)≥∑E∣E∣∣T∣H(E)H(T) \ge \sum_E \frac{|E|}{|T|} H(E). If each block has H(E)≥log⁡lH(E) \ge \log l, then H(T)≥log⁡lH(T) \ge \log l. A table whose sensitive column has low entropy can be entropy ll-diverse only for a small ll, whatever the anonymization does.
  • Monotonicity. If two blocks are ll-diverse in one of the three senses, then the block made by merging them is ll-diverse in the same sense. For entropy this is the concavity again. For the recursive form it holds because r1r_1 and the sum of the l−1l - 1 largest counts are both subadditive under merging. So a coarser generalization of an ll-diverse table is ll-diverse, and the lattice searches that prune by monotonicity, such as Incognito, work for l-diversity as they do for k-anonymity.
  • Background knowledge in the recursive form. Suppose a block is recursive (c,l)(c, l)-diverse and the attacker can rule out one sensitive value for the target, for example because the target is male and the value is a pregnancy. Remove that value from the block. The rest is recursive (c,l−1)(c, l - 1)-diverse. If the removed value had rank 1, the new largest count is r2≤r1r_2 \le r_1 and the new tail is the old tail. If it had rank j≥2j \ge 2, the largest count is still r1r_1, and the new tail is the old tail, or the old tail with rjr_j replaced by rl−1≥rjr_{l-1} \ge r_j. So an attacker who can rule out l−2l - 2 values still faces a (c,2)(c, 2)-diverse block, in which the most frequent value has fewer than cc times the rows of all the others.

proofs/correctness.md proves the monotonicity and the test below. The test reads each row once, groups the rows by their quasi-identifier values, and checks each block.

  1. L-DIVERSE(T, Q, S, l, variant, c)
  2. 1B ← the blocks of T: the groups of rows with equal values on Q
  3. 2for each block E in B do
  4. 3r_1 ≥ r_2 ≥ ... ≥ r_m ← the counts of the distinct values of S in E
  5. 4if variant = distinct and m < l then return false
  6. 5if variant = entropy and |E|^|E| < l^|E| · r_1^r_1 ⋯ r_m^r_m then return false ▷ the same as H(E) < log l
  7. 6if variant = recursive and r_1 ≥ c · (r_l + ... + r_m) then return false
  8. 7return true

With a hash table for the blocks, line L1 takes O(n)O(n) expected time for nn rows with a fixed number of quasi-identifiers, in the word-RAM model. Line L3 sorts the counts, O(mlog⁡m)O(m \log m) per block and O(nlog⁡n)O(n \log n) in total. Line L5 multiplies integers with up to O(∣E∣log⁡∣E∣)O(|E| \log |E|) bits, which is cheap for the small blocks that releases use; a floating point version with a tolerance is the usual choice for large blocks.

Examples and non-examples

The table below is synthetic. It is already generalized: Age and ZIP code are the quasi-identifiers, and the disease is sensitive. It has three blocks of 4 rows, so it is 4-anonymous.

block Age ZIP diseases counts r1,r2,…r_1, r_2, \ldots
E1E_1 < 30 130** heart, heart, heart, heart 4
E2E_2 ≥ 40 1485* flu, heart, cancer, flu 2, 1, 1
E3E_3 3* 130** flu, cancer, viral, heart 1, 1, 1, 1
  • E1E_1 is the homogeneity attack. An attacker who knows that a neighbour is under 30, lives in 130**, and is in the table, learns that the neighbour has heart disease, although the table is 4-anonymous. E1E_1 has m=1m = 1, so the table is not even distinct 2-diverse.
  • E2E_2. Distinct: m=3m = 3. Entropy: H(E2)=−(12log⁡212+2⋅14log⁡214)=1.5H(E_2) = -(\tfrac12 \log_2 \tfrac12 + 2 \cdot \tfrac14 \log_2 \tfrac14) = 1.5 bits, and 21.5≈2.832^{1.5} \approx 2.83, so E2E_2 is entropy ll-diverse for l=2l = 2 but not for l=3l = 3. The integer test for l=2l = 2 reads 44=256≥24⋅22⋅1⋅1=644^4 = 256 \ge 2^4 \cdot 2^2 \cdot 1 \cdot 1 = 64. Recursive: for l=2l = 2 the condition is 2<c⋅(1+1)2 < c \cdot (1 + 1), true for every c>1c > 1; for l=3l = 3 it is 2<c⋅12 < c \cdot 1, so E2E_2 is (3,3)(3, 3)-diverse but not (2,3)(2, 3)-diverse.
  • E3E_3. All four values differ, H(E3)=2H(E_3) = 2 bits, and E3E_3 is ll-diverse in every sense for each l≤4l \le 4 (recursive with any c>1c > 1).
  • A repair by merging. Generalize Age in E1E_1 and E2E_2 to "any" and ZIP to 1****. The merged block has counts 5 (heart), 2 (flu), 1 (cancer). Its entropy is 1.2991.299 bits, and 21.299≈2.462^{1.299} \approx 2.46, so it is entropy 2-diverse. Monotonicity does not predict this, because E1E_1 was not 2-diverse; the merge works because E2E_2 brings enough other values. The merged block is recursive (c,2)(c, 2)-diverse for c>5/3c > 5/3 (the test is 5<3c5 < 3c) and recursive (c,3)(c, 3)-diverse only for c>5c > 5.
  • l = 1. Every non-empty block is 1-diverse in all three senses, so 1-diversity adds nothing to k-anonymity.
  • The skewness attack (a non-example of protection). Li, Li and Venkatasubramanian take a test result with 99 percent negative and 1 percent positive records. A block with 50 percent positive records is distinct, entropy and recursive 2-diverse, yet it raises the chance that a member is positive from 1 percent to 50 percent. A block with 49 positive and 1 negative records is distinct 2-diverse and has the same entropy as one with 1 positive and 49 negative. Their Example 2 also notes that a distinct 2-diverse version of a table of 10000 such records can have at most 10000×1%=10010000 \times 1\% = 100 blocks, because each block needs a positive record, so the information loss is large.
  • The similarity attack (a non-example of protection). A block with the diseases gastric ulcer, gastritis and stomach cancer is distinct 3-diverse, but each value is a stomach disease, so the attacker learns that. The salaries 3k, 4k and 5k in one block are distinct, but all low. l-diversity treats the values as labels with no distance between them.
  • k-anonymity: the condition that l-diversity extends. Distinct ll-diversity of a block with mm values implies that the block has at least ll rows, so a distinct ll-diverse table is ll-anonymous.
  • Quasi-identifier and linkage attack: the attributes that define the blocks, and the attack that k-anonymity stops and l-diversity extends to sensitive values.
  • t-closeness: asks that the distribution of SS in each block be close to its distribution in the whole table, under the earth mover's distance. It answers the skewness and similarity attacks above.
  • Anatomy: releases the quasi-identifiers and the sensitive values in two tables joined by a group id, with ll-diverse groups, and gives a breach probability of at most 1/l1/l without generalization.
  • m-invariance: l-diversity for a table that is released again after insertions and deletions; each single release can be ll-diverse and the sequence can still leak.
  • Generalization and suppression, Incognito and Mondrian: the methods that produce the blocks; each can test l-diversity in place of k-anonymity.
  • Differential privacy: a condition on the release mechanism, not on the released table, that holds against every background knowledge.
Proof: The l-diversity test is exact, and the three instances survive the merging of blocksfull

We use the notation of the page. A block EE has the sorted positive counts r1≥⋯≥rmr_1 \ge \cdots \ge r_m of its sensitive values, with r1+⋯+rm=∣E∣r_1 + \cdots + r_m = |E|. For a count vector xx over the sensitive values (zeros allowed), write N(x)=∑sxsN(x) = \sum_s x_s, M(x)=max⁡sxsM(x) = \max_s x_s, and Tj(x)T_j(x) for the sum of the jj largest entries of xx. Then recursive (c,l)(c, l)-diversity of a block with vector xx reads M(x)<c (N(x)−Tl−1(x))M(x) < c\,(N(x) - T_{l-1}(x)). If xx has fewer than ll positive entries, then Tl−1(x)=N(x)T_{l-1}(x) = N(x), the right side is 0, and the block fails, which agrees with the page.

Claim 1 (the test). L-DIVERSE returns true if and only if every block of TT satisfies the chosen instance.

Proof. Line L1 puts two rows in the same group exactly when they agree on QQ, so the groups are the blocks. Line L3 computes the sorted counts of the block of line L2. The test returns false only at lines L4 to L6, and only for a block that breaks the instance, provided that each line tests the instance exactly. Line L4 is the definition of distinct ll-diversity. Line L6 is the definition of the recursive form, because rl+⋯+rm=∣E∣−Tl−1r_l + \cdots + r_m = |E| - T_{l-1}. For line L5, use ∑iri=∣E∣\sum_i r_i = |E|:

∣E∣⋅H(E)=∑irilog⁡∣E∣ri=log⁡∣E∣∣E∣r1r1⋯rmrm.|E| \cdot H(E) = \sum_i r_i \log \frac{|E|}{r_i} = \log \frac{|E|^{|E|}}{r_1^{r_1} \cdots r_m^{r_m}}.

Since ∣E∣>0|E| > 0 and the logarithm and the exponential are increasing, H(E)≥log⁡lH(E) \ge \log l holds if and only if ∣E∣∣E∣≥l∣E∣ r1r1⋯rmrm|E|^{|E|} \ge l^{|E|}\, r_1^{r_1} \cdots r_m^{r_m}, and line L5 returns false exactly when this fails. If no block fails, the loop ends and line L7 returns true. Each block is visited once, so the loop ends. □\square

Claim 2 (monotonicity). Let blocks AA and BB have count vectors aa and bb, and let A∪BA \cup B be the merged block, with vector a+ba + b. If AA and BB are both ll-diverse in one of the three senses, then A∪BA \cup B is ll-diverse in the same sense.

Proof.

  1. Distinct. Each value that occurs in AA occurs in A∪BA \cup B, so A∪BA \cup B has at least as many distinct values as AA, which is at least ll.
  2. Entropy. Let λ=∣A∣/(∣A∣+∣B∣)\lambda = |A| / (|A| + |B|). The distribution of A∪BA \cup B is λpA+(1−λ)pB\lambda p_A + (1 - \lambda) p_B. The function HH is concave on distributions, because −tlog⁡t-t \log t is concave on [0,1][0, 1]. So H(A∪B)≥λH(A)+(1−λ)H(B)≥λlog⁡l+(1−λ)log⁡l=log⁡lH(A \cup B) \ge \lambda H(A) + (1 - \lambda) H(B) \ge \lambda \log l + (1 - \lambda) \log l = \log l.
  3. Recursive. The condition is M(x)+c Tl−1(x)<c N(x)M(x) + c\, T_{l-1}(x) < c\, N(x). NN is additive. MM is subadditive: for each value ss, as+bs≤M(a)+M(b)a_s + b_s \le M(a) + M(b). Tl−1T_{l-1} is subadditive: let XX be the set of l−1l - 1 values with the largest entries of a+ba + b; then Tl−1(a+b)=∑s∈Xas+∑s∈Xbs≤Tl−1(a)+Tl−1(b)T_{l-1}(a + b) = \sum_{s \in X} a_s + \sum_{s \in X} b_s \le T_{l-1}(a) + T_{l-1}(b). With c>0c > 0,
M(a+b)+c Tl−1(a+b)≤(M(a)+c Tl−1(a))+(M(b)+c Tl−1(b))<c N(a)+c N(b)=c N(a+b). □M(a + b) + c\, T_{l-1}(a + b) \le \big(M(a) + c\, T_{l-1}(a)\big) + \big(M(b) + c\, T_{l-1}(b)\big) < c\, N(a) + c\, N(b) = c\, N(a + b). \ \square

By induction on the number of merges, a generalization whose blocks are unions of the blocks of an ll-diverse table is ll-diverse in the same sense.

Claim 3 (ruling out one value). Let l≥2l \ge 2. If a block is recursive (c,l)(c, l)-diverse, then for each value ss in it, the block without the rows of value ss is recursive (c,l−1)(c, l - 1)-diverse.

Proof. Let ss have rank jj, so its count is rjr_j, and let r′r' be the sorted counts after the removal. The old condition is r1<c (rl+⋯+rm)r_1 < c\,(r_l + \cdots + r_m).

  • If j=1j = 1, then r1′=r2≤r1r'_1 = r_2 \le r_1, and the entries of r′r' from rank l−1l - 1 on are rl,…,rmr_l, \ldots, r_m. So r1′≤r1<c (rl+⋯+rm)=c (rl−1′+⋯+rm−1′)r'_1 \le r_1 < c\,(r_l + \cdots + r_m) = c\,(r'_{l-1} + \cdots + r'_{m-1}).
  • If 2≤j≤l−12 \le j \le l - 1, then r1′=r1r'_1 = r_1, and the entries from rank l−1l - 1 on are again rl,…,rmr_l, \ldots, r_m. The same chain holds.
  • If j≥lj \ge l, then r1′=r1r'_1 = r_1, and the entries from rank l−1l - 1 on are rl−1r_{l-1} and the values rl,…,rmr_l, \ldots, r_m without rjr_j. Their sum is (rl+⋯+rm)+rl−1−rj≥rl+⋯+rm(r_l + \cdots + r_m) + r_{l-1} - r_j \ge r_l + \cdots + r_m, because rl−1≥rjr_{l-1} \ge r_j. The chain holds again. ■\blacksquare

Cost. Line L1 takes O(n)O(n) expected time with a hash table, line L3 takes O(nlog⁡n)O(n \log n) over all blocks, and lines L4 and L6 take O(m)O(m) per block. Line L5 multiplies integers of O(∣E∣log⁡∣E∣)O(|E| \log |E|) bits.

Code

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.

l_diversity.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/l-diversity/. The authors are listed in prov/HGM0PD.jsonl.

from collections import Counter
from collections.abc import Hashable, Sequence
from fractions import Fraction

Row = Sequence[Hashable]


def blocks(table: Sequence[Row], qi: Sequence[int]) -> dict[tuple[Hashable, ...], list[Row]]:
    """Group the rows of the table by their values on the quasi-identifier columns qi.

    Cost: O(n) expected time for n rows and a fixed number of columns.
    """
    out: dict[tuple[Hashable, ...], list[Row]] = {}
    for row in table:
        out.setdefault(tuple(row[j] for j in qi), []).append(row)
    return out


def block_is_diverse(
    counts: Sequence[int], l: int, variant: str = "distinct", c: Fraction | int = 1
) -> bool:
    """Test one block, given the counts of its distinct sensitive values.

    Precondition: every count is positive, l >= 1, c > 0, and variant is
    "distinct", "entropy" or "recursive". The entropy test is exact: it
    compares N^N with l^N * prod(r^r), where N is the size of the block.
    Cost: O(m log m) for m values, plus the big integer products.
    """
    r = sorted(counts, reverse=True)  # @line L3
    m = len(r)
    size = sum(r)
    if variant == "distinct":
        return m >= l  # @line L4
    if variant == "entropy":
        rhs = l**size
        for x in r:
            rhs *= x**x
        return size**size >= rhs  # @line L5
    if variant == "recursive":
        return Fraction(r[0]) < Fraction(c) * sum(r[l - 1 :]) if m > 0 else False  # @line L6
    raise ValueError("unknown variant " + repr(variant))


def is_l_diverse(
    table: Sequence[Row],
    qi: Sequence[int],
    s: int,
    l: int,
    variant: str = "distinct",
    c: Fraction | int = 1,
) -> bool:
    """Return True if every block of the table is l-diverse in the given sense.

    table is a list of rows, qi the column indices of the quasi-identifier and
    s the column index of the sensitive attribute. An empty table is l-diverse.
    Precondition: l >= 1 and c > 0. Cost: O(n log n) for n rows in the word-RAM
    model, plus the integer products of the entropy test.
    """
    groups = blocks(table, qi)  # @line L1
    for rows in groups.values():  # @line L2
        counts = list(Counter(row[s] for row in rows).values())
        if not block_is_diverse(counts, l, variant, c):
            return False
    return True  # @line L7
test_l_diversity.py 139 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/l-diversity/. The authors are listed in prov/HGM0PD.jsonl.

import itertools
import math
import random
from collections import Counter
from fractions import Fraction

from l_diversity import block_is_diverse, is_l_diverse

TABLE = [
    ("<30", "130**", "heart"),
    ("<30", "130**", "heart"),
    ("<30", "130**", "heart"),
    ("<30", "130**", "heart"),
    (">=40", "1485*", "flu"),
    (">=40", "1485*", "heart"),
    (">=40", "1485*", "cancer"),
    (">=40", "1485*", "flu"),
    ("3*", "130**", "flu"),
    ("3*", "130**", "cancer"),
    ("3*", "130**", "viral"),
    ("3*", "130**", "heart"),
]


def test_example_blocks() -> None:
    assert not is_l_diverse(TABLE, [0, 1], 2, 2, "distinct")
    e2 = [2, 1, 1]
    assert block_is_diverse(e2, 3, "distinct")
    assert block_is_diverse(e2, 2, "entropy")
    assert not block_is_diverse(e2, 3, "entropy")
    assert block_is_diverse(e2, 2, "recursive", Fraction(101, 100))
    assert not block_is_diverse(e2, 2, "recursive", 1)
    assert block_is_diverse(e2, 3, "recursive", 3)
    assert not block_is_diverse(e2, 3, "recursive", 2)
    e3 = [1, 1, 1, 1]
    assert block_is_diverse(e3, 4, "entropy")
    assert block_is_diverse(e3, 4, "recursive", 2)


def test_example_merge() -> None:
    merged = [(a if a == "3*" else "any", z if a == "3*" else "1****", d) for a, z, d in TABLE]
    assert is_l_diverse(merged, [0, 1], 2, 2, "entropy")
    assert not is_l_diverse(merged, [0, 1], 2, 3, "entropy")
    assert is_l_diverse(merged, [0, 1], 2, 2, "recursive", Fraction(17, 10))
    assert not is_l_diverse(merged, [0, 1], 2, 2, "recursive", Fraction(5, 3))
    assert is_l_diverse(merged, [0, 1], 2, 3, "recursive", 6)
    assert not is_l_diverse(merged, [0, 1], 2, 3, "recursive", 5)


def test_edges() -> None:
    for v in ("distinct", "entropy", "recursive"):
        assert is_l_diverse([], [0], 1, 3, v, 2)
        assert is_l_diverse([("a", "x")], [0], 1, 1, v, 2)
        assert not is_l_diverse([("a", "x")], [0], 1, 2, v, 2)
    # uniform block with exactly l values: entropy equals log l, which passes
    assert block_is_diverse([3, 3, 3], 3, "entropy")
    assert not block_is_diverse([3, 3, 2], 3, "entropy")
    # skewness: 49 against 1 is distinct 2-diverse
    assert block_is_diverse([49, 1], 2, "distinct")
    assert not block_is_diverse([49, 1], 2, "entropy")


def oracle(counts: list[int], l: int, variant: str, c: Fraction) -> bool:
    size = sum(counts)
    if variant == "distinct":
        return len(counts) >= l
    if variant == "entropy":
        h = -sum(x / size * math.log(x / size) for x in counts)
        return h >= math.log(l) or math.isclose(h, math.log(l), rel_tol=1e-12, abs_tol=1e-12)
    # recursive: the tail after the l - 1 largest counts is the smallest total
    # that remains after removing any l - 1 of the values
    if len(counts) < l:
        return False
    tail = min(size - sum(x) for x in itertools.combinations(counts, l - 1))
    return max(counts) < c * tail


def random_counts(rng: random.Random) -> list[int]:
    return [rng.randint(1, 6) for _ in range(rng.randint(1, 6))]


def test_against_oracle() -> None:
    rng = random.Random(7)
    for _ in range(1500):
        counts = random_counts(rng)
        l = rng.randint(1, 5)
        c = Fraction(rng.randint(1, 12), rng.randint(1, 4))
        for v in ("distinct", "entropy", "recursive"):
            assert block_is_diverse(counts, l, v, c) == oracle(counts, l, v, c)


def test_table_against_oracle() -> None:
    rng = random.Random(11)
    for _ in range(500):
        n = rng.randint(0, 20)
        table = [(rng.randint(0, 2), rng.randint(0, 1), rng.choice("abcde")) for _ in range(n)]
        l = rng.randint(1, 4)
        for v in ("distinct", "entropy", "recursive"):
            want = all(
                oracle(list(Counter(r[2] for r in table if (r[0], r[1]) == key).values()), l, v, Fraction(2))
                for key in {(r[0], r[1]) for r in table}
            )
            assert is_l_diverse(table, [0, 1], 2, l, v, 2) == want


def merge(a: list[tuple[str, int]], b: list[tuple[str, int]]) -> list[int]:
    total: Counter[str] = Counter()
    for s, x in a + b:
        total[s] += x
    return list(total.values())


def test_monotone_under_merge() -> None:
    rng = random.Random(3)
    for _ in range(1000):
        a = [(s, rng.randint(1, 5)) for s in rng.sample("abcdefg", rng.randint(1, 5))]
        b = [(s, rng.randint(1, 5)) for s in rng.sample("abcdefg", rng.randint(1, 5))]
        l = rng.randint(1, 4)
        c = Fraction(rng.randint(1, 8), rng.randint(1, 3))
        for v in ("distinct", "entropy", "recursive"):
            if block_is_diverse([x for _, x in a], l, v, c) and block_is_diverse([x for _, x in b], l, v, c):
                assert block_is_diverse(merge(a, b), l, v, c)


def test_ruling_out_one_value() -> None:
    rng = random.Random(5)
    for _ in range(1000):
        counts = random_counts(rng)
        l = rng.randint(2, 5)
        c = Fraction(rng.randint(1, 8), rng.randint(1, 3))
        if block_is_diverse(counts, l, "recursive", c):
            for j in range(len(counts)):
                rest = counts[:j] + counts[j + 1 :]
                assert block_is_diverse(rest, l - 1, "recursive", c)
        if block_is_diverse(counts, l, "entropy"):
            assert block_is_diverse(counts, l, "distinct")

References

  1. Ashwin Machanavajjhala, Johannes Gehrke, Daniel Kifer and Muthuramakrishnan Venkitasubramaniam, l-diversity: privacy beyond k-anonymity, 22nd International Conference on Data Engineering (ICDE 2006), page 24, the homogeneity and background knowledge attacks on k-anonymity, the l-diversity principle, and its entropy and recursive (c, l) instances
  2. Ashwin Machanavajjhala, Daniel Kifer, Johannes Gehrke and Muthuramakrishnan Venkitasubramaniam, l-diversity: privacy beyond k-anonymity, ACM Transactions on Knowledge Discovery from Data 1(1), article 3, 2007, the journal version, with Bayes-optimal privacy as the motivation, the monotonicity of the instances, and the use of l-diversity inside Incognito
  3. Ninghui Li, Tiancheng Li and Suresh Venkatasubramanian, t-closeness: privacy beyond k-anonymity and l-diversity, ICDE 2007, pages 106-115, Section 3 (the limits of l-diversity, with the skewness attack and the similarity attack, and Example 2 on a skewed test result)
  4. Benjamin C. M. Fung, Ke Wang, Rui Chen and Philip S. Yu, Privacy-preserving data publishing: a survey of recent developments, ACM Computing Surveys 42(4), article 14, 2010, the privacy models against attribute linkage, which compare l-diversity with its variants and with t-closeness

Where this leads

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 proofH2 full proof
  • correctness: no review record reviews/HGM0PD/proof-correctness.yaml
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)
WritingW4 complete
  • a review of the text: no review record reviews/HGM0PD/text.yaml