FA-89106 / Digital logic simulation / Open access
Unknown state outputs a definite zero · case 01
While the state register is unknown the output reads 0 instead of 'x'.
ROOT CAUSE
The unknown state has no table row and falls back to a default output of 0.
VERIFIED REPAIR
Output 'x' while the state is unknown.
Unsuccessful approach: Borrowing the start state's output still reports a definite value.
Case contract
Input [table, start, stream]: table[state] = {'out': o, 'next': {bit: state}}; stream items are [bit, rst] with bit 0/1/'x'. Each cycle outputs the current state's output (or 'x' in the unknown state 'X'), then clocks: rst==1 -> start (synchronous), else unknown input or state 'X' -> 'X', else follow next[bit], staying put if that transition is absent. Return [outputs, final state].
Why this case matters
Cycle-based simulators must emit Moore outputs from the pre-edge state and model unknown propagation through state registers.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
table, start, stream = args
state = start
outs = []
for bit, rst in stream:
o = table.get(state, {'out': 0})['out']
if rst == 1:
state = start
elif state == 'X' or bit == 'x':
state = 'X'
else:
state = table[state]['next'].get(str(bit), state)
outs.append(o)
return [outs, state]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0]]], [[0, 0, 1, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0]]], [[0, 'x', 0], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [0, 0], [1, 0]]], [[1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0]]], [[0, 'x', 0, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0]]], [[0, 0, 0], 'C']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0]]], [[0, 0, 0], 'C']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 1, 1, 0], 'B'])]]
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 |
|---|---|---|---|
| detects two ones | [[0, 0, 1, 0, 0], 'A'] | [[0, 0, 1, 0, 0], 'A'] | Passed |
| reset while in output state | [[0, 0, 1, 0, 0], 'C'] | [[0, 0, 1, 0, 0], 'C'] | Passed |
| missing transition holds state | [[0, 0, 1, 1], 'A'] | [[0, 0, 1, 1], 'A'] | Passed |
| unknown input poisons state | [[0, 0, 0, 0, 0, 0], 'B'] | [[0, 0, 'x', 'x', 'x', 0], 'B'] | Failed |
| reset from unknown state | [[0, 0, 0], 'C'] | [[0, 'x', 0], 'C'] | Failed |
| reset asserted in first cycle | [[0, 0, 0, 1], 'A'] | [[0, 0, 0, 1], 'A'] | Passed |
| start in accepting state | [[1, 1, 0], 'B'] | [[1, 1, 0], 'B'] | Passed |
SHA-256 / 6530ea7849da413e664741eb09b64558b114427430a8ee6944c6dc2613dddaf6
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
table, start, stream = args
state = start
outs = []
for bit, rst in stream:
o = table[start]['out'] if state == 'X' else table[state]['out']
if rst == 1:
state = start
elif state == 'X' or bit == 'x':
state = 'X'
else:
state = table[state]['next'].get(str(bit), state)
outs.append(o)
return [outs, state]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0]]], [[0, 0, 1, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0]]], [[0, 'x', 0], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [0, 0], [1, 0]]], [[1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0]]], [[0, 'x', 0, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0]]], [[0, 0, 0], 'C']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0]]], [[0, 0, 0], 'C']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 1, 1, 0], 'B'])]]
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 |
|---|---|---|---|
| detects two ones | [[0, 0, 1, 0, 0], 'A'] | [[0, 0, 1, 0, 0], 'A'] | Passed |
| reset while in output state | [[0, 0, 1, 0, 0], 'C'] | [[0, 0, 1, 0, 0], 'C'] | Passed |
| missing transition holds state | [[0, 0, 1, 1], 'A'] | [[0, 0, 1, 1], 'A'] | Passed |
| unknown input poisons state | [[0, 0, 0, 0, 0, 0], 'B'] | [[0, 0, 'x', 'x', 'x', 0], 'B'] | Failed |
| reset from unknown state | [[0, 0, 0], 'C'] | [[0, 'x', 0], 'C'] | Failed |
| reset asserted in first cycle | [[0, 0, 0, 1], 'A'] | [[0, 0, 0, 1], 'A'] | Passed |
| start in accepting state | [[1, 1, 0], 'B'] | [[1, 1, 0], 'B'] | Passed |
SHA-256 / 05efecdc3eeb57b7249b27eb5d1edfb8b029ca79e1f345140b9fa56e3d1846c8
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
table, start, stream = args
state = start
outs = []
for bit, rst in stream:
o = 'x' if state == 'X' else table[state]['out']
if rst == 1:
state = start
elif state == 'X' or bit == 'x':
state = 'X'
else:
state = table[state]['next'].get(str(bit), state)
outs.append(o)
return [outs, state]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0]]], [[0, 0, 1, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0]]], [[0, 'x', 0], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [0, 0], [1, 0]]], [[1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0]]], [[0, 'x', 0, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0]]], [[0, 0, 0], 'C']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0]]], [[0, 0, 0], 'C']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 1, 0], 'B'])], [('detects two ones', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], [[0, 0, 1, 0, 0, 0, 0, 0, 0], 'A']), ('reset while in output state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 0, 1, 0, 0, 1, 1, 1, 1], 'C']), ('missing transition holds state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0]]], [[0, 0, 1, 1, 1, 1, 1, 1], 'A']), ('unknown input poisons state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 0], ['x', 0], [1, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1], [1, 0]]], [[0, 0, 'x', 'x', 'x', 'x', 'x', 'x', 'x', 0], 'B']), ('reset from unknown state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'B', [['x', 0], [0, 1], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0]]], [[0, 'x', 0, 1, 1, 1, 1], 'C']), ('reset asserted in first cycle', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'A', [[1, 1], [1, 0], [1, 0], [0, 0]]], [[0, 0, 0, 1], 'A']), ('start in accepting state', [{'A': {'out': 0, 'next': {'1': 'B'}}, 'B': {'out': 0, 'next': {'0': 'A', '1': 'C'}}, 'C': {'out': 1, 'next': {'0': 'A'}}}, 'C', [[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [1, 0]]], [[1, 1, 1, 1, 1, 1, 0], 'B'])]]
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 |
|---|---|---|---|
| detects two ones | [[0, 0, 1, 0, 0], 'A'] | [[0, 0, 1, 0, 0], 'A'] | Passed |
| reset while in output state | [[0, 0, 1, 0, 0], 'C'] | [[0, 0, 1, 0, 0], 'C'] | Passed |
| missing transition holds state | [[0, 0, 1, 1], 'A'] | [[0, 0, 1, 1], 'A'] | Passed |
| unknown input poisons state | [[0, 0, 'x', 'x', 'x', 0], 'B'] | [[0, 0, 'x', 'x', 'x', 0], 'B'] | Passed |
| reset from unknown state | [[0, 'x', 0], 'C'] | [[0, 'x', 0], 'C'] | Passed |
| reset asserted in first cycle | [[0, 0, 0, 1], 'A'] | [[0, 0, 0, 1], 'A'] | Passed |
| start in accepting state | [[1, 1, 0], 'B'] | [[1, 1, 0], 'B'] | Passed |
SHA-256 / 50f0c6fdd66f8e8e0d34caaf42086b1fc25540a03a4454ac77426eecfbedca84
Verification & scope
A deterministic bounded teaching model of one simulator rule set; the contract is stipulated and is not a claim of conformance to any HDL standard or commercial simulator. 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:14.259945+00:00.
Case digest / 0a724216b3e9a50b9cb2b5ff971463dfe001868c7d2d7fcede2d9abac40269d3