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

N = 1
observations = []
def solve(d):
    n=d['size']; b=d['page_size']; i=d['index']; children=[j for j in (2*i+1,2*i+2) if j<n]
    def address(j): return [j//b,j%b]
    return {'address': address(i),
    'parent': None if i==0 else address((i-1)//2),
    'children': [address(j) for j in children],
    'pages': (n+b-1)//b,
    'tail_occupancy': n%b,
    'touched': sorted({j//b for j in [i]+children})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 11, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 12, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 3, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 13, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 1, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 14, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 15, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 3, 'touched': [1, 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):
    n=d['size']; b=d['page_size']; i=d['index']; children=[j for j in (2*i+1,2*i+2) if j<n]
    def address(j): return [j//b,j%b]
    return {'address': address(i),
    'parent': None if i==0 else address((i-1)//2),
    'children': [address(j) for j in children],
    'pages': (n+b-1)//b,
    'tail_occupancy': b,
    'touched': sorted({j//b for j in [i]+children})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 11, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 12, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 3, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 13, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 1, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 14, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 15, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 3, 'touched': [1, 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 paged heap layout certificate reports an incorrect tail occupancy.

A binary heap is stored in fixed-size pages of B slots using zero-based global indices. For n logical members and selected live index i report its page/offset, parent address or None, child addresses, allocated page count, last-page live occupancy, and pages touched by reading i and its existing children. B>=1 and 0<=i<n.

split: open-access


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

N = 1
observations = []
def solve(d):
    n=d['size']; b=d['page_size']; i=d['index']; children=[j for j in (2*i+1,2*i+2) if j<n]
    def address(j): return [j//b,j%b]
    return {'address': address(i),
    'parent': None if i==0 else address((i-1)//2),
    'children': [address(j) for j in children],
    'pages': (n+b-1)//b,
    'tail_occupancy': (n-1)%b+1,
    'touched': sorted({j%b for j in [i]+children})}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 11, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 12, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 3, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 13, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 1, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 14, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 15, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 3, 'touched': [1, 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):
    n=d['size']; b=d['page_size']; i=d['index']; children=[j for j in (2*i+1,2*i+2) if j<n]
    def address(j): return [j//b,j%b]
    return {'address': address(i),
    'parent': None if i==0 else address((i-1)//2),
    'children': [address(j) for j in children],
    'pages': (n+b-1)//b,
    'tail_occupancy': (n-1)%b+1,
    'touched': [i//b]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 11, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 12, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 4, 'tail_occupancy': 3, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 13, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 1, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 14, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 2, 'touched': [1, 3]})], [({'size': 1, 'page_size': 4, 'index': 0}, {'address': [0, 0], 'parent': None, 'children': [], 'pages': 1, 'tail_occupancy': 1, 'touched': [0]}), ({'size': 8, 'page_size': 4, 'index': 3}, {'address': [0, 3], 'parent': [0, 1], 'children': [[1, 3]], 'pages': 2, 'tail_occupancy': 4, 'touched': [0, 1]}), ({'size': 9, 'page_size': 4, 'index': 2}, {'address': [0, 2], 'parent': [0, 0], 'children': [[1, 1], [1, 2]], 'pages': 3, 'tail_occupancy': 1, 'touched': [0, 1]}), ({'size': 15, 'page_size': 3, 'index': 6}, {'address': [2, 0], 'parent': [0, 2], 'children': [[4, 1], [4, 2]], 'pages': 5, 'tail_occupancy': 3, 'touched': [2, 4]}), ({'size': 16, 'page_size': 4, 'index': 7}, {'address': [1, 3], 'parent': [0, 3], 'children': [[3, 3]], 'pages': 4, 'tail_occupancy': 4, 'touched': [1, 3]}), ({'size': 10, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0]], 'pages': 4, 'tail_occupancy': 1, 'touched': [1, 3]}), ({'size': 15, 'page_size': 3, 'index': 4}, {'address': [1, 1], 'parent': [0, 1], 'children': [[3, 0], [3, 1]], 'pages': 5, 'tail_occupancy': 3, 'touched': [1, 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 paged heap layout certificate reports an incorrect touched.

A binary heap is stored in fixed-size pages of B slots using zero-based global indices. For n logical members and selected live index i report its page/offset, parent address or None, child addresses, allocated page count, last-page live occupancy, and pages touched by reading i and its existing children. B>=1 and 0<=i<n.

split: open-access


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

N = 1
observations = []
def solve(d):
    nodes={x[0]:x[1:] for x in d['nodes']}; root=d['root']; todo=[] if root is None else [(root,0)]; seen=[]; indices=[]; repeated=[]
    while todo:
        v,k=todo.pop(0)
        if v in seen:
            repeated.append(v); continue
        seen.append(v); indices.append(k)
        for offset,child in enumerate(nodes[v],1):
            if child is not None: todo.append((child,2*k+offset))
    return {'visits': list(nodes),
    'unreachable': sorted(set(nodes)-set(seen)),
    'repeated': repeated,
    'complete': not repeated and len(seen)==len(nodes) and sorted(indices)==list(range(len(nodes))),
    'right_only': [v for v,(l,r) in nodes.items() if l is None and r is not None],
    'incoming': {v:sum(v==c for pair in nodes.values() for c in pair) for v in nodes}}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None], ['104', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103', '104'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0, '104': 0}})]][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):
    nodes={x[0]:x[1:] for x in d['nodes']}; root=d['root']; todo=[] if root is None else [(root,0)]; seen=[]; indices=[]; repeated=[]
    while todo:
        v,k=todo.pop(0)
        if v in seen:
            repeated.append(v); continue
        seen.append(v); indices.append(k)
        for offset,child in enumerate(nodes[v],1):
            if child is not None: todo.append((child,2*k+offset))
    return {'visits': list(reversed(seen)),
    'unreachable': sorted(set(nodes)-set(seen)),
    'repeated': repeated,
    'complete': not repeated and len(seen)==len(nodes) and sorted(indices)==list(range(len(nodes))),
    'right_only': [v for v,(l,r) in nodes.items() if l is None and r is not None],
    'incoming': {v:sum(v==c for pair in nodes.values() for c in pair) for v in nodes}}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None], ['104', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103', '104'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0, '104': 0}})]][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 complete tree certificate certificate reports an incorrect visits.

A bounded binary pointer-tree certificate gives node records [id,left_id,right_id], root id or None; references name existing nodes or None. Breadth-first traversal stops expanding previously seen ids. Assign conceptual heap indices root=0,left=2i+1,right=2i+2. Report visit ids, unreachable ids, shared/cyclic references encountered, completeness (unique indices 0..n-1 and all nodes reached without repeats), right-only parents, and parent multiplicities.

split: open-access


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

N = 1
observations = []
def solve(d):
    nodes={x[0]:x[1:] for x in d['nodes']}; root=d['root']; todo=[] if root is None else [(root,0)]; seen=[]; indices=[]; repeated=[]
    while todo:
        v,k=todo.pop(0)
        if v in seen:
            repeated.append(v); continue
        seen.append(v); indices.append(k)
        for offset,child in enumerate(nodes[v],1):
            if child is not None: todo.append((child,2*k+offset))
    return {'visits': seen,
    'unreachable': [],
    'repeated': repeated,
    'complete': not repeated and len(seen)==len(nodes) and sorted(indices)==list(range(len(nodes))),
    'right_only': [v for v,(l,r) in nodes.items() if l is None and r is not None],
    'incoming': {v:sum(v==c for pair in nodes.values() for c in pair) for v in nodes}}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None], ['104', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103', '104'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0, '104': 0}})]][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):
    nodes={x[0]:x[1:] for x in d['nodes']}; root=d['root']; todo=[] if root is None else [(root,0)]; seen=[]; indices=[]; repeated=[]
    while todo:
        v,k=todo.pop(0)
        if v in seen:
            repeated.append(v); continue
        seen.append(v); indices.append(k)
        for offset,child in enumerate(nodes[v],1):
            if child is not None: todo.append((child,2*k+offset))
    return {'visits': seen,
    'unreachable': sorted(set(seen)-set(nodes)),
    'repeated': repeated,
    'complete': not repeated and len(seen)==len(nodes) and sorted(indices)==list(range(len(nodes))),
    'right_only': [v for v,(l,r) in nodes.items() if l is None and r is not None],
    'incoming': {v:sum(v==c for pair in nodes.values() for c in pair) for v in nodes}}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None], ['104', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103', '104'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0, '104': 0}})]][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 complete tree certificate certificate reports an incorrect unreachable.

A bounded binary pointer-tree certificate gives node records [id,left_id,right_id], root id or None; references name existing nodes or None. Breadth-first traversal stops expanding previously seen ids. Assign conceptual heap indices root=0,left=2i+1,right=2i+2. Report visit ids, unreachable ids, shared/cyclic references encountered, completeness (unique indices 0..n-1 and all nodes reached without repeats), right-only parents, and parent multiplicities.

split: open-access


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

N = 1
observations = []
def solve(d):
    nodes={x[0]:x[1:] for x in d['nodes']}; root=d['root']; todo=[] if root is None else [(root,0)]; seen=[]; indices=[]; repeated=[]
    while todo:
        v,k=todo.pop(0)
        if v in seen:
            repeated.append(v); continue
        seen.append(v); indices.append(k)
        for offset,child in enumerate(nodes[v],1):
            if child is not None: todo.append((child,2*k+offset))
    return {'visits': seen,
    'unreachable': sorted(set(nodes)-set(seen)),
    'repeated': [],
    'complete': not repeated and len(seen)==len(nodes) and sorted(indices)==list(range(len(nodes))),
    'right_only': [v for v,(l,r) in nodes.items() if l is None and r is not None],
    'incoming': {v:sum(v==c for pair in nodes.values() for c in pair) for v in nodes}}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None], ['104', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103', '104'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0, '104': 0}})]][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):
    nodes={x[0]:x[1:] for x in d['nodes']}; root=d['root']; todo=[] if root is None else [(root,0)]; seen=[]; indices=[]; repeated=[]
    while todo:
        v,k=todo.pop(0)
        if v in seen:
            repeated.append(v); continue
        seen.append(v); indices.append(k)
        for offset,child in enumerate(nodes[v],1):
            if child is not None: todo.append((child,2*k+offset))
    return {'visits': seen,
    'unreachable': sorted(set(nodes)-set(seen)),
    'repeated': sorted(set(repeated)),
    'complete': not repeated and len(seen)==len(nodes) and sorted(indices)==list(range(len(nodes))),
    'right_only': [v for v,(l,r) in nodes.items() if l is None and r is not None],
    'incoming': {v:sum(v==c for pair in nodes.values() for c in pair) for v in nodes}}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0}})], [({'nodes': [], 'root': None}, {'visits': [], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {}}), ({'nodes': [['a', None, None]], 'root': 'a'}, {'visits': ['a'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'a': 0}}), ({'nodes': [['c', None, None], ['a', 'b', 'c'], ['b', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c'], 'unreachable': [], 'repeated': [], 'complete': True, 'right_only': [], 'incoming': {'c': 1, 'a': 0, 'b': 1}}), ({'nodes': [['a', None, 'b'], ['b', None, None], ['c', None, None]], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': ['c'], 'repeated': [], 'complete': False, 'right_only': ['a'], 'incoming': {'a': 0, 'b': 1, 'c': 0}}), ({'nodes': [['a', 'b', 'b'], ['b', 'a', 'a']], 'root': 'a'}, {'visits': ['a', 'b'], 'unreachable': [], 'repeated': ['b', 'a', 'a'], 'complete': False, 'right_only': [], 'incoming': {'a': 2, 'b': 2}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': [], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1}}), ({'nodes': [['a', 'b', 'c'], ['b', None, 'd'], ['c', None, None], ['d', None, None], ['100', None, None], ['101', None, None], ['102', None, None], ['103', None, None], ['104', None, None]], 'root': 'a'}, {'visits': ['a', 'b', 'c', 'd'], 'unreachable': ['100', '101', '102', '103', '104'], 'repeated': [], 'complete': False, 'right_only': ['b'], 'incoming': {'a': 0, 'b': 1, 'c': 1, 'd': 1, '100': 0, '101': 0, '102': 0, '103': 0, '104': 0}})]][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 complete tree certificate certificate reports an incorrect repeated.

A bounded binary pointer-tree certificate gives node records [id,left_id,right_id], root id or None; references name existing nodes or None. Breadth-first traversal stops expanding previously seen ids. Assign conceptual heap indices root=0,left=2i+1,right=2i+2. Report visit ids, unreachable ids, shared/cyclic references encountered, completeness (unique indices 0..n-1 and all nodes reached without repeats), right-only parents, and parent multiplicities.

split: open-access