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

N = 1
observations = []
def solve(d):
    a=d['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': sorted(f+children),
    'chosen': nxt,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': sorted(f+children,key=lambda i:(a[i],-i)),
    'chosen': nxt,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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 heap frontier certificate reports an incorrect ready.

A read-only best-first traversal of a valid binary min heap has already emitted parent slot p and a frontier of distinct slots. Insert p children that exist into the frontier, order by (key,index), and choose next. Return new frontier, chosen slot, child additions, traversal output key, preserved heap, and next frontier after selection. Initial frontier excludes p and its children.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': min(children,key=lambda i:a[i]) if children else None,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': f[0] if f else children[0] if children else None,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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 heap frontier certificate reports an incorrect chosen.

A read-only best-first traversal of a valid binary min heap has already emitted parent slot p and a frontier of distinct slots. Insert p children that exist into the frontier, order by (key,index), and choose next. Return new frontier, chosen slot, child additions, traversal output key, preserved heap, and next frontier after selection. Initial frontier excludes p and its children.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': [2*p,2*p+1] if 2*p+1<len(a) else [],
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': [2*p+1] if 2*p+1<len(a) else [],
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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 heap frontier certificate reports an incorrect children.

A read-only best-first traversal of a valid binary min heap has already emitted parent slot p and a frontier of distinct slots. Insert p children that exist into the frontier, order by (key,index), and choose next. Return new frontier, chosen slot, child additions, traversal output key, preserved heap, and next frontier after selection. Initial frontier excludes p and its children.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': children,
    'next_key': None if nxt is None else nxt,
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': children,
    'next_key': a[p],
    'heap_after': a,
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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 heap frontier certificate reports an incorrect next key.

A read-only best-first traversal of a valid binary min heap has already emitted parent slot p and a frontier of distinct slots. Insert p children that exist into the frontier, order by (key,index), and choose next. Return new frontier, chosen slot, child additions, traversal output key, preserved heap, and next frontier after selection. Initial frontier excludes p and its children.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': [x for i,x in enumerate(a) if i!=p],
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': sorted(a),
    'frontier_after': ready[1:]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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 heap frontier certificate reports an incorrect heap after.

A read-only best-first traversal of a valid binary min heap has already emitted parent slot p and a frontier of distinct slots. Insert p children that exist into the frontier, order by (key,index), and choose next. Return new frontier, chosen slot, child additions, traversal output key, preserved heap, and next frontier after selection. Initial frontier excludes p and its children.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': ready}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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['keys']; p=d['parent']; f=d['frontier']; children=[i for i in (2*p+1,2*p+2) if i<len(a)]; ready=sorted(f+children,key=lambda i:(a[i],i)); nxt=ready[0] if ready else None
    return {'ready': ready,
    'chosen': nxt,
    'children': children,
    'next_key': None if nxt is None else a[nxt],
    'heap_after': a,
    'frontier_after': []}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 9], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 9], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 10], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 10], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 11], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 11], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 12], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 12], 'frontier_after': [4, 7]})], [({'keys': [1], 'parent': 0, 'frontier': []}, {'ready': [], 'chosen': None, 'children': [], 'next_key': None, 'heap_after': [1], 'frontier_after': []}), ({'keys': [1, 7, 2], 'parent': 0, 'frontier': []}, {'ready': [2, 1], 'chosen': 2, 'children': [1, 2], 'next_key': 2, 'heap_after': [1, 7, 2], 'frontier_after': [1]}), ({'keys': [1, 4, 2, 7, 5, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 5, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 4, 2, 7, 4, 3, 6], 'parent': 1, 'frontier': [2]}, {'ready': [2, 4, 3], 'chosen': 2, 'children': [3, 4], 'next_key': 2, 'heap_after': [1, 4, 2, 7, 4, 3, 6], 'frontier_after': [4, 3]}), ({'keys': [1, 3, 3, 5, 6, 7, 8], 'parent': 0, 'frontier': []}, {'ready': [1, 2], 'chosen': 1, 'children': [1, 2], 'next_key': 3, 'heap_after': [1, 3, 3, 5, 6, 7, 8], 'frontier_after': [2]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 8], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 8], 'frontier_after': [4, 7]}), ({'keys': [1, 2, 3, 4, 5, 6, 7, 13], 'parent': 3, 'frontier': [2, 4]}, {'ready': [2, 4, 7], 'chosen': 2, 'children': [7], 'next_key': 3, 'heap_after': [1, 2, 3, 4, 5, 6, 7, 13], 'frontier_after': [4, 7]})]][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 heap frontier certificate reports an incorrect frontier after.

A read-only best-first traversal of a valid binary min heap has already emitted parent slot p and a frontier of distinct slots. Insert p children that exist into the frontier, order by (key,index), and choose next. Return new frontier, chosen slot, child additions, traversal output key, preserved heap, and next frontier after selection. Initial frontier excludes p and its children.

split: open-access