FA-89271 / Digital logic simulation / Open access
Scan data shifted toward the scan input · case 01
The chain moves data backwards and scan-in enters at the scan-out end.
ROOT CAUSE
Each flop takes its successor instead of its predecessor.
VERIFIED REPAIR
Flop k takes the old value of flop k-1; the first flop takes scan-in.
Unsuccessful approach: Taking successor values with scan-in at the front still reverses the data movement.
Case contract
Input [chain, logic, state, ops]: chain lists flops from scan-in to scan-out. 'shift' with bit b: scan-out observes the last flop before the edge, then every flop takes its predecessor's old value and the first takes b. 'capture': every flop loads its functional next state logic[f] = [op, inputs] (and/xor/not) computed from the old state of all flops simultaneously. Return [scan-out bits, final chain values].
Why this case matters
Scan-based test simulation must shift and capture as simultaneous register updates.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
chain, logic, state, ops = args
state = dict(state)
sout = []
for op, bit in ops:
if op == 'shift':
sout.append(state[chain[-1]])
vals = [state[f] for f in chain[1:]] + [bit]
for f, v in zip(chain, vals):
state[f] = v
else:
nxt = {}
for f in chain:
kind, ins = logic[f]
bits = [state[i] for i in ins]
nxt[f] = int(all(bits)) if kind == 'and' else (sum(bits) % 2 if kind == 'xor' else 1 - bits[0])
state.update(nxt)
return [sout, [state[f] for f in chain]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1], ['shift', 0]]], [[1, 1], [0, 1, 1, 0]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1]]], [[0], [1, 1, 0, 0]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1]]], [[1, 0], [1, 1, 0, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['shift', 1], ['shift', 0], ['shift', 1]]], [[0, 1, 0], [1, 0, 1, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[1, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1]]], [[1, 0], [1, 1, 1, 0]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1], [1, 1, 1, 0]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1]]], [[1], [1, 1, 0, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1]]], [[0, 0, 0], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0], [1, 1, 1, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['shift', 1], ['shift', 0]]], [[0, 1], [0, 1, 1, 0]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[1, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 0, 1], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0, 1], [1, 1, 1, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1], ['shift', 0], ['shift', 1]]], [[1, 1, 0], [1, 0, 1, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[0, 0, 0, 1, 1], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0, 1, 1], [1, 1, 1, 1]])]]
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 |
|---|---|---|---|
| shift in a pattern | [[1, 1], [1, 1, 1, 0]] | [[1, 1], [0, 1, 1, 0]] | Failed |
| capture then unload | [[0, 0, 0, 0], [0, 0, 0, 0]] | [[0, 0, 1, 1], [0, 0, 0, 0]] | Failed |
| load capture unload | [[0, 1, 0, 0], [1, 0, 0, 0]] | [[0, 0, 0, 0], [0, 0, 1, 0]] | Failed |
| double capture | [[0], [0, 0, 0, 1]] | [[0], [1, 1, 0, 0]] | Failed |
| short chain | [[0, 0], [0, 1]] | [[0, 1], [1, 0]] | Failed |
| flush ones | [[1, 1], [0, 1, 1, 1]] | [[1, 0], [1, 1, 0, 1]] | Failed |
SHA-256 / 3782b8ab06c3b55e18a1dc9027c103e2bf49c477ac31f32d65c26085fdfe6327
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
chain, logic, state, ops = args
state = dict(state)
sout = []
for op, bit in ops:
if op == 'shift':
sout.append(state[chain[-1]])
vals = [bit] + [state[f] for f in chain[1:]]
for f, v in zip(chain, vals):
state[f] = v
else:
nxt = {}
for f in chain:
kind, ins = logic[f]
bits = [state[i] for i in ins]
nxt[f] = int(all(bits)) if kind == 'and' else (sum(bits) % 2 if kind == 'xor' else 1 - bits[0])
state.update(nxt)
return [sout, [state[f] for f in chain]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1], ['shift', 0]]], [[1, 1], [0, 1, 1, 0]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1]]], [[0], [1, 1, 0, 0]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1]]], [[1, 0], [1, 1, 0, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['shift', 1], ['shift', 0], ['shift', 1]]], [[0, 1, 0], [1, 0, 1, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[1, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1]]], [[1, 0], [1, 1, 1, 0]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1], [1, 1, 1, 0]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1]]], [[1], [1, 1, 0, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1]]], [[0, 0, 0], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0], [1, 1, 1, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['shift', 1], ['shift', 0]]], [[0, 1], [0, 1, 1, 0]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[1, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 0, 1], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0, 1], [1, 1, 1, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1], ['shift', 0], ['shift', 1]]], [[1, 1, 0], [1, 0, 1, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[0, 0, 0, 1, 1], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0, 1, 1], [1, 1, 1, 1]])]]
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 |
|---|---|---|---|
| shift in a pattern | [[1, 1], [0, 0, 1, 1]] | [[1, 1], [0, 1, 1, 0]] | Failed |
| capture then unload | [[0, 0, 0, 0], [0, 1, 0, 0]] | [[0, 0, 1, 1], [0, 0, 0, 0]] | Failed |
| load capture unload | [[0, 0, 0, 0], [0, 0, 0, 0]] | [[0, 0, 0, 0], [0, 0, 1, 0]] | Failed |
| double capture | [[0], [1, 0, 0, 0]] | [[0], [1, 1, 0, 0]] | Failed |
| short chain | [[0, 0], [1, 0]] | [[0, 1], [1, 0]] | Failed |
| flush ones | [[1, 1], [1, 1, 0, 1]] | [[1, 0], [1, 1, 0, 1]] | Failed |
SHA-256 / f330c58fa3de181653044e8a71288e50340d5cb1ca4436c9513dbeedf636f119
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(*args):
chain, logic, state, ops = args
state = dict(state)
sout = []
for op, bit in ops:
if op == 'shift':
sout.append(state[chain[-1]])
vals = [bit] + [state[f] for f in chain[:-1]]
for f, v in zip(chain, vals):
state[f] = v
else:
nxt = {}
for f in chain:
kind, ins = logic[f]
bits = [state[i] for i in ins]
nxt[f] = int(all(bits)) if kind == 'and' else (sum(bits) % 2 if kind == 'xor' else 1 - bits[0])
state.update(nxt)
return [sout, [state[f] for f in chain]]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1], ['shift', 0]]], [[1, 1], [0, 1, 1, 0]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1]]], [[0], [1, 1, 0, 0]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1]]], [[1, 0], [1, 1, 0, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['shift', 1], ['shift', 0], ['shift', 1]]], [[0, 1, 0], [1, 0, 1, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[1, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1]]], [[1, 0], [1, 1, 1, 0]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1], [1, 1, 1, 0]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1]]], [[1], [1, 1, 0, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1]]], [[0, 0, 0], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0], [1, 1, 1, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['shift', 1], ['shift', 0]]], [[0, 1], [0, 1, 1, 0]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[1, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 0}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 0, 1], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0, 1], [1, 1, 1, 1]])], [('shift in a pattern', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['shift', 1], ['shift', 0], ['shift', 1]]], [[1, 1, 0], [1, 0, 1, 1]]), ('capture then unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['shift', 0], ['shift', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 1, 1], [0, 0, 0, 0]]), ('load capture unload', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 0, 'f2': 0, 'f3': 0}, [['shift', 1], ['shift', 1], ['capture', 0], ['shift', 0], ['shift', 0]]], [[0, 0, 0, 0], [0, 0, 1, 0]]), ('double capture', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 1, 'f1': 0, 'f2': 1, 'f3': 1}, [['capture', 0], ['capture', 0], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[0, 0, 0, 1, 1], [1, 1, 1, 1]]), ('short chain', [['f0', 'f2'], {'f0': ['not', ['f2']], 'f2': ['xor', ['f0', 'f2']]}, {'f0': 1, 'f2': 0}, [['shift', 0], ['capture', 0], ['shift', 1]]], [[0, 1], [1, 0]]), ('flush ones', [['f0', 'f1', 'f2', 'f3'], {'f0': ['xor', ['f1', 'f2']], 'f1': ['and', ['f0', 'f2']], 'f2': ['not', ['f0']], 'f3': ['xor', ['f2', 'f3']]}, {'f0': 0, 'f1': 1, 'f2': 0, 'f3': 1}, [['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1], ['shift', 1]]], [[1, 0, 1, 0, 1, 1], [1, 1, 1, 1]])]]
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 |
|---|---|---|---|
| shift in a pattern | [[1, 1], [0, 1, 1, 0]] | [[1, 1], [0, 1, 1, 0]] | Passed |
| capture then unload | [[0, 0, 1, 1], [0, 0, 0, 0]] | [[0, 0, 1, 1], [0, 0, 0, 0]] | Passed |
| load capture unload | [[0, 0, 0, 0], [0, 0, 1, 0]] | [[0, 0, 0, 0], [0, 0, 1, 0]] | Passed |
| double capture | [[0], [1, 1, 0, 0]] | [[0], [1, 1, 0, 0]] | Passed |
| short chain | [[0, 1], [1, 0]] | [[0, 1], [1, 0]] | Passed |
| flush ones | [[1, 0], [1, 1, 0, 1]] | [[1, 0], [1, 1, 0, 1]] | Passed |
SHA-256 / 2aeb52de2b29fa584b4a2d2c78f71bd6fa0b33b59bb35fcabdd069b46cb3095a
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:15.954207+00:00.
Case digest / 4b3d9e537367bddbd7f88355e79ec1b0147f14092c9a13010c48ab9a6b67ca3a