broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['entries']; old=d['old_last']; new=min(x[1] for x in a); dest=[(x[0],(x[1]^new).bit_length()) for x in a]
    return {'threshold': new,
    'destinations': [[i,b] for i,b in dest],
    'zero_ids': [x[0] for x in a if x[1]==new],
    'moved': len(a),
    'source_after': [x[0] for x in a],
    'largest_destination': max(b for i,b in dest)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [101, 9]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [101, 0]], 'zero_ids': [2, 101], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [102, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [102, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [103, 11]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [103, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [104, 12]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [104, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [105, 13]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [105, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['entries']; old=d['old_last']; new=min(x[1] for x in a); dest=[(x[0],(x[1]^new).bit_length()) for x in a]
    return {'threshold': new,
    'destinations': [[i,b] for i,b in dest],
    'zero_ids': [x[0] for x in a if x[1]==new],
    'moved': len(a),
    'source_after': [x[0] for x in a if x[1]!=new],
    'largest_destination': max(b for i,b in dest)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [101, 9]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [101, 0]], 'zero_ids': [2, 101], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [102, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [102, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [103, 11]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [103, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [104, 12]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [104, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [105, 13]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [105, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The bounded radix redistribute certificate reports an incorrect source after.

Redistribute one nonempty radix bucket with entries [id,key], all keys at least old_last. Set new_last to bucket minimum and move every entry to bit_length(key XOR new_last); preserve entry order within each destination bucket. Report threshold, assignments, bucket-zero ids, moved count, old-bucket clearing, and maximum destination.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['entries']; old=d['old_last']; new=min(x[1] for x in a); dest=[(x[0],(x[1]^new).bit_length()) for x in a]
    return {'threshold': new,
    'destinations': [[i,b] for i,b in dest],
    'zero_ids': [x[0] for x in a if x[1]==new],
    'moved': len(a),
    'source_after': [],
    'largest_destination': max((x[1]^old).bit_length() for x in a)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [101, 9]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [101, 0]], 'zero_ids': [2, 101], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [102, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [102, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [103, 11]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [103, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [104, 12]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [104, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [105, 13]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [105, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['entries']; old=d['old_last']; new=min(x[1] for x in a); dest=[(x[0],(x[1]^new).bit_length()) for x in a]
    return {'threshold': new,
    'destinations': [[i,b] for i,b in dest],
    'zero_ids': [x[0] for x in a if x[1]==new],
    'moved': len(a),
    'source_after': [],
    'largest_destination': max(0,max(b for i,b in dest)-1)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [101, 9]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [101, 0]], 'zero_ids': [2, 101], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [102, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [102, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [103, 11]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [103, 2]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [104, 12]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [104, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})], [({'old_last': 0, 'entries': [[1, 8]]}, {'threshold': 8, 'destinations': [[1, 0]], 'zero_ids': [1], 'moved': 1, 'source_after': [], 'largest_destination': 0}), ({'old_last': 3, 'entries': [[1, 7], [2, 4], [3, 6]]}, {'threshold': 4, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 7, 'entries': [[1, 15], [2, 8], [3, 8], [4, 12]]}, {'threshold': 8, 'destinations': [[1, 3], [2, 0], [3, 0], [4, 3]], 'zero_ids': [2, 3], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 1, 'entries': [[1, 3], [2, 2]]}, {'threshold': 2, 'destinations': [[1, 1], [2, 0]], 'zero_ids': [2], 'moved': 2, 'source_after': [], 'largest_destination': 1}), ({'old_last': 4, 'entries': [[1, 7], [2, 5], [3, 6]]}, {'threshold': 5, 'destinations': [[1, 2], [2, 0], [3, 2]], 'zero_ids': [2], 'moved': 3, 'source_after': [], 'largest_destination': 2}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2]], 'zero_ids': [2], 'moved': 4, 'source_after': [], 'largest_destination': 3}), ({'old_last': 8, 'entries': [[1, 15], [2, 9], [3, 11], [4, 10], [105, 13]]}, {'threshold': 9, 'destinations': [[1, 3], [2, 0], [3, 2], [4, 2], [105, 3]], 'zero_ids': [2], 'moved': 5, 'source_after': [], 'largest_destination': 3})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The bounded radix redistribute certificate reports an incorrect largest destination.

Redistribute one nonempty radix bucket with entries [id,key], all keys at least old_last. Set new_last to bucket minimum and move every entry to bit_length(key XOR new_last); preserve entry order within each destination bucket. Report threshold, assignments, bucket-zero ids, moved count, old-bucket clearing, and maximum destination.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['slots']; i=d['i']; j=d['j']; after=list(a); after[i],after[j]=after[j],after[i]; pos={x:k for k,x in enumerate(a)}
    return {'slots': a,
    'positions': {x:k for k,x in enumerate(after)},
    'first_moved': [a[i],j],
    'second_moved': [a[j],i],
    'changed_handles': [] if i==j else [a[i],a[j]],
    'bijective': len(set(after))==len(pos)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 1, 'j': 3}, {'slots': ['q', 't', 's', 'r', 'u'], 'positions': {'q': 0, 't': 1, 's': 2, 'r': 3, 'u': 4}, 'first_moved': ['r', 3], 'second_moved': ['t', 1], 'changed_handles': ['r', 't'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 2, 'j': 4}, {'slots': ['q', 'r', 'u', 't', 's'], 'positions': {'q': 0, 'r': 1, 'u': 2, 't': 3, 's': 4}, 'first_moved': ['s', 4], 'second_moved': ['u', 2], 'changed_handles': ['s', 'u'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 3, 'j': 0}, {'slots': ['t', 'r', 's', 'q', 'u'], 'positions': {'t': 0, 'r': 1, 's': 2, 'q': 3, 'u': 4}, 'first_moved': ['t', 0], 'second_moved': ['q', 3], 'changed_handles': ['t', 'q'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 1}, {'slots': ['q', 'u', 's', 't', 'r'], 'positions': {'q': 0, 'u': 1, 's': 2, 't': 3, 'r': 4}, 'first_moved': ['u', 1], 'second_moved': ['r', 4], 'changed_handles': ['u', 'r'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 0, 'j': 2}, {'slots': ['s', 'r', 'q', 't', 'u'], 'positions': {'s': 0, 'r': 1, 'q': 2, 't': 3, 'u': 4}, 'first_moved': ['q', 2], 'second_moved': ['s', 0], 'changed_handles': ['q', 's'], 'bijective': True})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['slots']; i=d['i']; j=d['j']; after=list(a); after[i],after[j]=after[j],after[i]; pos={x:k for k,x in enumerate(a)}
    return {'slots': a[:i]+[a[j]]+a[i+1:],
    'positions': {x:k for k,x in enumerate(after)},
    'first_moved': [a[i],j],
    'second_moved': [a[j],i],
    'changed_handles': [] if i==j else [a[i],a[j]],
    'bijective': len(set(after))==len(pos)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 1, 'j': 3}, {'slots': ['q', 't', 's', 'r', 'u'], 'positions': {'q': 0, 't': 1, 's': 2, 'r': 3, 'u': 4}, 'first_moved': ['r', 3], 'second_moved': ['t', 1], 'changed_handles': ['r', 't'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 2, 'j': 4}, {'slots': ['q', 'r', 'u', 't', 's'], 'positions': {'q': 0, 'r': 1, 'u': 2, 't': 3, 's': 4}, 'first_moved': ['s', 4], 'second_moved': ['u', 2], 'changed_handles': ['s', 'u'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 3, 'j': 0}, {'slots': ['t', 'r', 's', 'q', 'u'], 'positions': {'t': 0, 'r': 1, 's': 2, 'q': 3, 'u': 4}, 'first_moved': ['t', 0], 'second_moved': ['q', 3], 'changed_handles': ['t', 'q'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 1}, {'slots': ['q', 'u', 's', 't', 'r'], 'positions': {'q': 0, 'u': 1, 's': 2, 't': 3, 'r': 4}, 'first_moved': ['u', 1], 'second_moved': ['r', 4], 'changed_handles': ['u', 'r'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 0, 'j': 2}, {'slots': ['s', 'r', 'q', 't', 'u'], 'positions': {'s': 0, 'r': 1, 'q': 2, 't': 3, 'u': 4}, 'first_moved': ['q', 2], 'second_moved': ['s', 0], 'changed_handles': ['q', 's'], 'bijective': True})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The bounded indexed swap certificate reports an incorrect slots.

An indexed heap swap receives unique entry ids in slots, an exact inverse position map, and two in-range positions i,j. Swap the records, update both inverse-map locations, keep cardinality and membership, and report the two moved identities. Self-swap is allowed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['slots']; i=d['i']; j=d['j']; after=list(a); after[i],after[j]=after[j],after[i]; pos={x:k for k,x in enumerate(a)}
    return {'slots': after,
    'positions': pos,
    'first_moved': [a[i],j],
    'second_moved': [a[j],i],
    'changed_handles': [] if i==j else [a[i],a[j]],
    'bijective': len(set(after))==len(pos)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 1, 'j': 3}, {'slots': ['q', 't', 's', 'r', 'u'], 'positions': {'q': 0, 't': 1, 's': 2, 'r': 3, 'u': 4}, 'first_moved': ['r', 3], 'second_moved': ['t', 1], 'changed_handles': ['r', 't'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 2, 'j': 4}, {'slots': ['q', 'r', 'u', 't', 's'], 'positions': {'q': 0, 'r': 1, 'u': 2, 't': 3, 's': 4}, 'first_moved': ['s', 4], 'second_moved': ['u', 2], 'changed_handles': ['s', 'u'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 3, 'j': 0}, {'slots': ['t', 'r', 's', 'q', 'u'], 'positions': {'t': 0, 'r': 1, 's': 2, 'q': 3, 'u': 4}, 'first_moved': ['t', 0], 'second_moved': ['q', 3], 'changed_handles': ['t', 'q'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 1}, {'slots': ['q', 'u', 's', 't', 'r'], 'positions': {'q': 0, 'u': 1, 's': 2, 't': 3, 'r': 4}, 'first_moved': ['u', 1], 'second_moved': ['r', 4], 'changed_handles': ['u', 'r'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 0, 'j': 2}, {'slots': ['s', 'r', 'q', 't', 'u'], 'positions': {'s': 0, 'r': 1, 'q': 2, 't': 3, 'u': 4}, 'first_moved': ['q', 2], 'second_moved': ['s', 0], 'changed_handles': ['q', 's'], 'bijective': True})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['slots']; i=d['i']; j=d['j']; after=list(a); after[i],after[j]=after[j],after[i]; pos={x:k for k,x in enumerate(a)}
    return {'slots': after,
    'positions': {**pos,a[i]:j},
    'first_moved': [a[i],j],
    'second_moved': [a[j],i],
    'changed_handles': [] if i==j else [a[i],a[j]],
    'bijective': len(set(after))==len(pos)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 1, 'j': 3}, {'slots': ['q', 't', 's', 'r', 'u'], 'positions': {'q': 0, 't': 1, 's': 2, 'r': 3, 'u': 4}, 'first_moved': ['r', 3], 'second_moved': ['t', 1], 'changed_handles': ['r', 't'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 2, 'j': 4}, {'slots': ['q', 'r', 'u', 't', 's'], 'positions': {'q': 0, 'r': 1, 'u': 2, 't': 3, 's': 4}, 'first_moved': ['s', 4], 'second_moved': ['u', 2], 'changed_handles': ['s', 'u'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 3, 'j': 0}, {'slots': ['t', 'r', 's', 'q', 'u'], 'positions': {'t': 0, 'r': 1, 's': 2, 'q': 3, 'u': 4}, 'first_moved': ['t', 0], 'second_moved': ['q', 3], 'changed_handles': ['t', 'q'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 1}, {'slots': ['q', 'u', 's', 't', 'r'], 'positions': {'q': 0, 'u': 1, 's': 2, 't': 3, 'r': 4}, 'first_moved': ['u', 1], 'second_moved': ['r', 4], 'changed_handles': ['u', 'r'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 0, 'j': 2}, {'slots': ['s', 'r', 'q', 't', 'u'], 'positions': {'s': 0, 'r': 1, 'q': 2, 't': 3, 'u': 4}, 'first_moved': ['q', 2], 'second_moved': ['s', 0], 'changed_handles': ['q', 's'], 'bijective': True})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The bounded indexed swap certificate reports an incorrect positions.

An indexed heap swap receives unique entry ids in slots, an exact inverse position map, and two in-range positions i,j. Swap the records, update both inverse-map locations, keep cardinality and membership, and report the two moved identities. Self-swap is allowed.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['slots']; i=d['i']; j=d['j']; after=list(a); after[i],after[j]=after[j],after[i]; pos={x:k for k,x in enumerate(a)}
    return {'slots': after,
    'positions': {x:k for k,x in enumerate(after)},
    'first_moved': [a[j],j],
    'second_moved': [a[j],i],
    'changed_handles': [] if i==j else [a[i],a[j]],
    'bijective': len(set(after))==len(pos)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 1, 'j': 3}, {'slots': ['q', 't', 's', 'r', 'u'], 'positions': {'q': 0, 't': 1, 's': 2, 'r': 3, 'u': 4}, 'first_moved': ['r', 3], 'second_moved': ['t', 1], 'changed_handles': ['r', 't'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 2, 'j': 4}, {'slots': ['q', 'r', 'u', 't', 's'], 'positions': {'q': 0, 'r': 1, 'u': 2, 't': 3, 's': 4}, 'first_moved': ['s', 4], 'second_moved': ['u', 2], 'changed_handles': ['s', 'u'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 3, 'j': 0}, {'slots': ['t', 'r', 's', 'q', 'u'], 'positions': {'t': 0, 'r': 1, 's': 2, 'q': 3, 'u': 4}, 'first_moved': ['t', 0], 'second_moved': ['q', 3], 'changed_handles': ['t', 'q'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 1}, {'slots': ['q', 'u', 's', 't', 'r'], 'positions': {'q': 0, 'u': 1, 's': 2, 't': 3, 'r': 4}, 'first_moved': ['u', 1], 'second_moved': ['r', 4], 'changed_handles': ['u', 'r'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 0, 'j': 2}, {'slots': ['s', 'r', 'q', 't', 'u'], 'positions': {'s': 0, 'r': 1, 'q': 2, 't': 3, 'u': 4}, 'first_moved': ['q', 2], 'second_moved': ['s', 0], 'changed_handles': ['q', 's'], 'bijective': True})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    a=d['slots']; i=d['i']; j=d['j']; after=list(a); after[i],after[j]=after[j],after[i]; pos={x:k for k,x in enumerate(a)}
    return {'slots': after,
    'positions': {x:k for k,x in enumerate(after)},
    'first_moved': [a[i],i],
    'second_moved': [a[j],i],
    'changed_handles': [] if i==j else [a[i],a[j]],
    'bijective': len(set(after))==len(pos)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 1, 'j': 3}, {'slots': ['q', 't', 's', 'r', 'u'], 'positions': {'q': 0, 't': 1, 's': 2, 'r': 3, 'u': 4}, 'first_moved': ['r', 3], 'second_moved': ['t', 1], 'changed_handles': ['r', 't'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 2, 'j': 4}, {'slots': ['q', 'r', 'u', 't', 's'], 'positions': {'q': 0, 'r': 1, 'u': 2, 't': 3, 's': 4}, 'first_moved': ['s', 4], 'second_moved': ['u', 2], 'changed_handles': ['s', 'u'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 3, 'j': 0}, {'slots': ['t', 'r', 's', 'q', 'u'], 'positions': {'t': 0, 'r': 1, 's': 2, 'q': 3, 'u': 4}, 'first_moved': ['t', 0], 'second_moved': ['q', 3], 'changed_handles': ['t', 'q'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 1}, {'slots': ['q', 'u', 's', 't', 'r'], 'positions': {'q': 0, 'u': 1, 's': 2, 't': 3, 'r': 4}, 'first_moved': ['u', 1], 'second_moved': ['r', 4], 'changed_handles': ['u', 'r'], 'bijective': True})], [({'slots': ['a'], 'i': 0, 'j': 0}, {'slots': ['a'], 'positions': {'a': 0}, 'first_moved': ['a', 0], 'second_moved': ['a', 0], 'changed_handles': [], 'bijective': True}), ({'slots': ['z', 'a'], 'i': 0, 'j': 1}, {'slots': ['a', 'z'], 'positions': {'a': 0, 'z': 1}, 'first_moved': ['z', 1], 'second_moved': ['a', 0], 'changed_handles': ['z', 'a'], 'bijective': True}), ({'slots': ['b', 'd', 'a'], 'i': 0, 'j': 2}, {'slots': ['a', 'd', 'b'], 'positions': {'a': 0, 'd': 1, 'b': 2}, 'first_moved': ['b', 2], 'second_moved': ['a', 0], 'changed_handles': ['b', 'a'], 'bijective': True}), ({'slots': ['a', 'b', 'c', 'd'], 'i': 1, 'j': 3}, {'slots': ['a', 'd', 'c', 'b'], 'positions': {'a': 0, 'd': 1, 'c': 2, 'b': 3}, 'first_moved': ['b', 3], 'second_moved': ['d', 1], 'changed_handles': ['b', 'd'], 'bijective': True}), ({'slots': ['x', 'y', 'z'], 'i': 1, 'j': 1}, {'slots': ['x', 'y', 'z'], 'positions': {'x': 0, 'y': 1, 'z': 2}, 'first_moved': ['y', 1], 'second_moved': ['y', 1], 'changed_handles': [], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 4, 'j': 0}, {'slots': ['u', 'r', 's', 't', 'q'], 'positions': {'u': 0, 'r': 1, 's': 2, 't': 3, 'q': 4}, 'first_moved': ['u', 0], 'second_moved': ['q', 4], 'changed_handles': ['u', 'q'], 'bijective': True}), ({'slots': ['q', 'r', 's', 't', 'u'], 'i': 0, 'j': 2}, {'slots': ['s', 'r', 'q', 't', 'u'], 'positions': {'s': 0, 'r': 1, 'q': 2, 't': 3, 'u': 4}, 'first_moved': ['q', 2], 'second_moved': ['s', 0], 'changed_handles': ['q', 's'], 'bijective': True})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The bounded indexed swap certificate reports an incorrect first moved.

An indexed heap swap receives unique entry ids in slots, an exact inverse position map, and two in-range positions i,j. Swap the records, update both inverse-map locations, keep cardinality and membership, and report the two moved identities. Self-swap is allowed.

split: open-access