FA-91211 / Quantum circuit simulation / Open access
Grover planner reports zero marked items as invalid input · case 01
M = 0 yields "invalid" instead of "no-solution".
ROOT CAUSE
The input validation rejects M <= 0 before the no-solution branch can run.
VERIFIED REPAIR
Validate M < 0 as invalid and handle M == 0 separately as "no-solution".
Unsuccessful approach: The attempted repair returns zero iterations with success 0 for M = 0, hiding the no-solution case.
Case contract
Input [N, M]. "invalid" if N < 1, M < 0 or M > N; "no-solution" if M == 0; if 2M >= N return {"iterations": 0, "success": M/N}; else theta = asin(sqrt(M/N)), k = floor(pi/(4 theta)) and success = sin^2((2k+1) theta). Probabilities rounded to 6 decimals.
Why this case matters
Choosing the Grover iteration count wrongly overshoots the amplitude peak and collapses the success probability.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
N, M = x
if N < 1 or M <= 0 or M > N:
return 'invalid'
if M == 0:
return 'no-solution'
if 2 * M >= N:
return {'iterations': 0, 'success': round(M / N, 6)}
theta = math.asin(math.sqrt(M / N))
k = math.floor(math.pi / (4 * theta))
return {'iterations': k, 'success': round(math.sin((2 * k + 1) * theta) ** 2, 6)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: no marked items', [8, 0], 'no-solution'], ['control: half marked N=4 M=2', [4, 2], {'iterations': 0, 'success': 0.5}], ['control: odd N just under half', [5, 2], {'iterations': 1, 'success': 0.784}], ['control: single marked N=4', [4, 1], {'iterations': 1, 'success': 1.0}], ['control: M greater than N', [4, 5], 'invalid'], ['control: empty space', [0, 0], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: negative M', [4, -1], 'invalid'], ['control: empty space', [0, 0], 'invalid'], ['control: all marked', [8, 8], {'iterations': 0, 'success': 1.0}], ['control: one over the space', [4, 5], 'invalid'], ['control: single marked N=4', [4, 1], {'iterations': 1, 'success': 1.0}]], [['regression: no marked items', [8, 0], 'no-solution'], ['control: all marked N=1', [1, 1], {'iterations': 0, 'success': 1.0}], ['control: all marked N=3', [3, 3], {'iterations': 0, 'success': 1.0}], ['control: N=7 M=3', [7, 3], {'iterations': 1, 'success': 0.708455}], ['control: N=9 M=4', [9, 4], {'iterations': 1, 'success': 0.663923}], ['control: M greater than N', [4, 5], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: N=8 M=1', [8, 1], {'iterations': 2, 'success': 0.945312}], ['control: N=8 M=2', [8, 2], {'iterations': 1, 'success': 1.0}], ['control: N=8 M=3', [8, 3], {'iterations': 1, 'success': 0.84375}], ['control: N=8 M=5', [8, 5], {'iterations': 0, 'success': 0.625}], ['control: negative M', [4, -1], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: N=8 M=7', [8, 7], {'iterations': 0, 'success': 0.875}], ['control: N=16 M=1', [16, 1], {'iterations': 3, 'success': 0.961319}], ['control: N=16 M=2', [16, 2], {'iterations': 2, 'success': 0.945312}], ['control: N=16 M=3', [16, 3], {'iterations': 1, 'success': 0.949219}], ['control: empty space', [0, 0], 'invalid']]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: no marked items | invalid | no-solution | Failed |
| control: half marked N=4 M=2 | {'iterations': 0, 'success': 0.5} | {'iterations': 0, 'success': 0.5} | Passed |
| control: odd N just under half | {'iterations': 1, 'success': 0.784} | {'iterations': 1, 'success': 0.784} | Passed |
| control: single marked N=4 | {'iterations': 1, 'success': 1.0} | {'iterations': 1, 'success': 1.0} | Passed |
| control: M greater than N | invalid | invalid | Passed |
| control: empty space | invalid | invalid | Passed |
SHA-256 / f7a2719c2018a888942eccc515013912dc7ad1383cbbc170383bf22324744010
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
N, M = x
if N < 1 or M < 0 or M > N:
return 'invalid'
if M == 0:
return {'iterations': 0, 'success': 0.0}
if 2 * M >= N:
return {'iterations': 0, 'success': round(M / N, 6)}
theta = math.asin(math.sqrt(M / N))
k = math.floor(math.pi / (4 * theta))
return {'iterations': k, 'success': round(math.sin((2 * k + 1) * theta) ** 2, 6)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: no marked items', [8, 0], 'no-solution'], ['control: half marked N=4 M=2', [4, 2], {'iterations': 0, 'success': 0.5}], ['control: odd N just under half', [5, 2], {'iterations': 1, 'success': 0.784}], ['control: single marked N=4', [4, 1], {'iterations': 1, 'success': 1.0}], ['control: M greater than N', [4, 5], 'invalid'], ['control: empty space', [0, 0], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: negative M', [4, -1], 'invalid'], ['control: empty space', [0, 0], 'invalid'], ['control: all marked', [8, 8], {'iterations': 0, 'success': 1.0}], ['control: one over the space', [4, 5], 'invalid'], ['control: single marked N=4', [4, 1], {'iterations': 1, 'success': 1.0}]], [['regression: no marked items', [8, 0], 'no-solution'], ['control: all marked N=1', [1, 1], {'iterations': 0, 'success': 1.0}], ['control: all marked N=3', [3, 3], {'iterations': 0, 'success': 1.0}], ['control: N=7 M=3', [7, 3], {'iterations': 1, 'success': 0.708455}], ['control: N=9 M=4', [9, 4], {'iterations': 1, 'success': 0.663923}], ['control: M greater than N', [4, 5], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: N=8 M=1', [8, 1], {'iterations': 2, 'success': 0.945312}], ['control: N=8 M=2', [8, 2], {'iterations': 1, 'success': 1.0}], ['control: N=8 M=3', [8, 3], {'iterations': 1, 'success': 0.84375}], ['control: N=8 M=5', [8, 5], {'iterations': 0, 'success': 0.625}], ['control: negative M', [4, -1], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: N=8 M=7', [8, 7], {'iterations': 0, 'success': 0.875}], ['control: N=16 M=1', [16, 1], {'iterations': 3, 'success': 0.961319}], ['control: N=16 M=2', [16, 2], {'iterations': 2, 'success': 0.945312}], ['control: N=16 M=3', [16, 3], {'iterations': 1, 'success': 0.949219}], ['control: empty space', [0, 0], 'invalid']]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: no marked items | {'iterations': 0, 'success': 0.0} | no-solution | Failed |
| control: half marked N=4 M=2 | {'iterations': 0, 'success': 0.5} | {'iterations': 0, 'success': 0.5} | Passed |
| control: odd N just under half | {'iterations': 1, 'success': 0.784} | {'iterations': 1, 'success': 0.784} | Passed |
| control: single marked N=4 | {'iterations': 1, 'success': 1.0} | {'iterations': 1, 'success': 1.0} | Passed |
| control: M greater than N | invalid | invalid | Passed |
| control: empty space | invalid | invalid | Passed |
SHA-256 / f985895385cc124ecf0bfa2cb4c4cb591c9a38f27b98f028ae40b5e1493a6f8f
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
N, M = x
if N < 1 or M < 0 or M > N:
return 'invalid'
if M == 0:
return 'no-solution'
if 2 * M >= N:
return {'iterations': 0, 'success': round(M / N, 6)}
theta = math.asin(math.sqrt(M / N))
k = math.floor(math.pi / (4 * theta))
return {'iterations': k, 'success': round(math.sin((2 * k + 1) * theta) ** 2, 6)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: no marked items', [8, 0], 'no-solution'], ['control: half marked N=4 M=2', [4, 2], {'iterations': 0, 'success': 0.5}], ['control: odd N just under half', [5, 2], {'iterations': 1, 'success': 0.784}], ['control: single marked N=4', [4, 1], {'iterations': 1, 'success': 1.0}], ['control: M greater than N', [4, 5], 'invalid'], ['control: empty space', [0, 0], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: negative M', [4, -1], 'invalid'], ['control: empty space', [0, 0], 'invalid'], ['control: all marked', [8, 8], {'iterations': 0, 'success': 1.0}], ['control: one over the space', [4, 5], 'invalid'], ['control: single marked N=4', [4, 1], {'iterations': 1, 'success': 1.0}]], [['regression: no marked items', [8, 0], 'no-solution'], ['control: all marked N=1', [1, 1], {'iterations': 0, 'success': 1.0}], ['control: all marked N=3', [3, 3], {'iterations': 0, 'success': 1.0}], ['control: N=7 M=3', [7, 3], {'iterations': 1, 'success': 0.708455}], ['control: N=9 M=4', [9, 4], {'iterations': 1, 'success': 0.663923}], ['control: M greater than N', [4, 5], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: N=8 M=1', [8, 1], {'iterations': 2, 'success': 0.945312}], ['control: N=8 M=2', [8, 2], {'iterations': 1, 'success': 1.0}], ['control: N=8 M=3', [8, 3], {'iterations': 1, 'success': 0.84375}], ['control: N=8 M=5', [8, 5], {'iterations': 0, 'success': 0.625}], ['control: negative M', [4, -1], 'invalid']], [['regression: no marked items', [8, 0], 'no-solution'], ['control: N=8 M=7', [8, 7], {'iterations': 0, 'success': 0.875}], ['control: N=16 M=1', [16, 1], {'iterations': 3, 'success': 0.961319}], ['control: N=16 M=2', [16, 2], {'iterations': 2, 'success': 0.945312}], ['control: N=16 M=3', [16, 3], {'iterations': 1, 'success': 0.949219}], ['control: empty space', [0, 0], 'invalid']]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: no marked items | no-solution | no-solution | Passed |
| control: half marked N=4 M=2 | {'iterations': 0, 'success': 0.5} | {'iterations': 0, 'success': 0.5} | Passed |
| control: odd N just under half | {'iterations': 1, 'success': 0.784} | {'iterations': 1, 'success': 0.784} | Passed |
| control: single marked N=4 | {'iterations': 1, 'success': 1.0} | {'iterations': 1, 'success': 1.0} | Passed |
| control: M greater than N | invalid | invalid | Passed |
| control: empty space | invalid | invalid | Passed |
SHA-256 / 7ce205354ac5f8e3f4248ccc8403feabde8355229b6be08234f458af29d82992
Verification & scope
A deterministic bounded teaching model with a stipulated toy contract; amplitudes are rounded to fixed decimals for strict JSON output. It is not a production quantum SDK and claims no standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:51:33.797153+00:00.
Case digest / 7e350566913b0c9349086f4fc7098ae38bb15f6fc06906b111f71da9a4419be9