FA-91951 / PLC ladder logic scan cycles / Open access
Program scan reads live inputs instead of the frozen input image · case 01
Two rungs examining the same input disagree within one scan when the field signal changes mid-scan.
ROOT CAUSE
The input image aliases the physical input table instead of copying it at the input scan.
VERIFIED REPAIR
Copy the physical inputs into the image once per scan, before any rung executes.
Unsuccessful approach: Refreshing the image at the end of the previous scan misses changes applied at the start of the current scan.
Case contract
Ladder program scan. rungs is a list of [coil, branches]; a branch is a series list of [XIC|XIO, tag] contacts and the rung is true if any branch is fully true. Each scan item is [start_changes, mid_changes]: start_changes [[tag, value]] update physical inputs before the input scan; the input image is then frozen for the program scan. mid_changes [[rung_index, tag, value]] change physical inputs just before that rung executes and are only seen by the next input scan. Non-input tags are read from the data table, where earlier rungs of the same scan have already written their coils (last OTE wins). Missing tags read false. Return the sorted energized O: tags after each scan.
Why this case matters
Ladder programs are executed as repeated scans; each defect here changes what a rung, timer, counter or data-table instruction reports on a particular scan, which is how commissioning and field faults are actually observed.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rungs, scans):
phys = {}
table = {}
out = []
for start, mid in scans:
for tag, val in start:
phys[tag] = bool(val)
image = phys
for i, (coil, branches) in enumerate(rungs):
for at, tag, val in mid:
if at == i:
phys[tag] = bool(val)
def read(tag):
if tag.startswith('I:'):
return image.get(tag, False)
return table.get(tag, False)
power = any(all(read(t) if k == 'XIC' else not read(t) for k, t in br) for br in branches)
table[coil] = power
out.append(sorted(t for t, v in table.items() if v and t.startswith('O:')))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:0', [[['XIC', 'I:1'], ['XIC', 'O:0'], ['XIC', 'I:1']], [['XIO', 'O:0']]]],
['B:0', [[['XIO', 'I:0'], ['XIO', 'B:1'], ['XIC', 'O:0']], [['XIC', 'I:2'], ['XIC', 'I:2']]]],
['O:1', [[['XIC', 'O:2'], ['XIC', 'I:0'], ['XIC', 'O:0']]]],
['O:1',
[[['XIO', 'O:1'], ['XIC', 'B:0'], ['XIC', 'B:0']], [['XIC', 'O:1'], ['XIC', 'B:0'], ['XIC', 'O:2']]]],
['O:1',
[[['XIC', 'I:0'], ['XIO', 'I:0'], ['XIO', 'O:0']], [['XIC', 'O:2'], ['XIC', 'I:1'], ['XIO', 'B:0']]]]],
[[[['I:0', True], ['I:1', False]], [[1, 'I:2', True]]],
[[['I:2', True]], []],
[[['I:2', True]], [[0, 'I:2', True]]],
[[['I:0', True], ['I:2', False]], [[4, 'I:2', False], [4, 'I:2', True]]]]],
[['O:0'], [], ['O:0'], []]],
['control: scenario 2',
[[['O:1', [[['XIC', 'O:2'], ['XIO', 'O:0'], ['XIO', 'O:0']]]],
['O:0', [[['XIC', 'B:1'], ['XIC', 'O:0']]]],
['B:0', [[['XIC', 'O:2']], [['XIC', 'O:0']]]]],
[[[['I:0', True], ['I:2', False]], []],
[[['I:0', False], ['I:1', True], ['I:2', False]], []],
[[['I:0', True]], []],
[[['I:2', False]], [[0, 'I:2', False]]],
[[['I:0', True], ['I:1', False], ['I:2', True]], [[1, 'I:0', False], [1, 'I:1', True]]],
[[['I:1', False]], [[2, 'I:2', True], [0, 'I:2', True]]]]],
[[], [], [], [], [], []]]],
[['regression: scenario 1',
[[['B:0', [[['XIO', 'I:1'], ['XIC', 'O:0'], ['XIC', 'O:2']]]],
['O:1', [[['XIC', 'O:1'], ['XIO', 'B:0'], ['XIO', 'B:0']]]],
['O:2', [[['XIC', 'O:2'], ['XIC', 'I:2'], ['XIC', 'I:1']], [['XIC', 'O:2'], ['XIC', 'O:0']]]],
['O:1', [[['XIC', 'I:0']], [['XIC', 'I:2'], ['XIO', 'I:0']]]]],
[[[['I:2', False]], []],
[[['I:0', False], ['I:2', False]], [[0, 'I:1', True]]],
[[['I:0', False], ['I:1', True]], [[3, 'I:0', True], [0, 'I:0', True]]],
[[['I:0', False]], [[3, 'I:0', False], [2, 'I:2', False]]],
[[['I:0', True], ['I:1', True], ['I:2', False]], [[3, 'I:0', True]]],
[[['I:2', True]], []]]],
[[], [], [], [], ['O:1'], ['O:1']]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 2',
[[['B:1', [[['XIC', 'O:0'], ['XIC', 'I:2']], [['XIC', 'I:2'], ['XIC', 'B:0'], ['XIC', 'I:1']]]],
['B:1', [[['XIC', 'O:2']]]],
['O:0', [[['XIC', 'O:2']]]],
['B:1', [[['XIO', 'O:0']], [['XIC', 'I:0'], ['XIC', 'O:2'], ['XIO', 'O:1']]]]],
[[[], [[2, 'I:2', True]]],
[[['I:2', True]], []],
[[['I:0', True], ['I:2', False]], [[2, 'I:1', False], [3, 'I:1', False]]],
[[['I:1', True], ['I:2', False]], []]]],
[[], [], [], []]]],
[['regression: scenario 6',
[[['O:1', [[['XIC', 'O:2'], ['XIC', 'O:0'], ['XIC', 'I:0']], [['XIC', 'O:0'], ['XIC', 'I:2']]]],
['O:1', [[['XIC', 'I:0'], ['XIC', 'I:1']], [['XIO', 'I:1']]]],
['B:0', [[['XIO', 'I:2'], ['XIO', 'B:1'], ['XIC', 'B:1']]]]],
[[[], [[0, 'I:2', False], [1, 'I:1', True]]],
[[], [[2, 'I:2', False], [1, 'I:2', False]]],
[[['I:0', False], ['I:1', True], ['I:2', False]], [[0, 'I:2', True]]]]],
[['O:1'], [], []]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:1', [[['XIC', 'O:2'], ['XIO', 'O:0']], [['XIO', 'I:1']]]],
['O:1', [[['XIC', 'I:0'], ['XIC', 'O:1']], [['XIO', 'I:1'], ['XIC', 'O:0']]]],
['B:0', [[['XIC', 'B:0'], ['XIC', 'B:0']]]]],
[[[['I:0', False], ['I:1', True], ['I:2', False]], []],
[[['I:0', True], ['I:1', True], ['I:2', True]], [[0, 'I:2', False]]],
[[['I:1', True], ['I:2', False]], []],
[[['I:0', False], ['I:1', False]], [[2, 'I:2', True]]],
[[['I:0', False]], [[1, 'I:2', False], [2, 'I:2', True]]]]],
[[], [], [], [], []]]],
[['regression: scenario 10',
[[['B:1', [[['XIC', 'I:2'], ['XIC', 'B:1'], ['XIO', 'B:1']], [['XIO', 'B:1']]]],
['B:0', [[['XIC', 'I:1'], ['XIC', 'B:1'], ['XIC', 'O:2']], [['XIC', 'I:1'], ['XIO', 'O:1']]]],
['O:2', [[['XIC', 'B:1']]]],
['B:1', [[['XIC', 'B:1'], ['XIO', 'B:0']], [['XIC', 'I:0'], ['XIC', 'I:0']]]],
['B:0', [[['XIC', 'O:0']], [['XIC', 'I:1'], ['XIO', 'O:0']]]]],
[[[['I:1', True]], [[1, 'I:1', False]]],
[[['I:1', False], ['I:2', False]], [[4, 'I:0', False]]],
[[['I:0', True], ['I:1', True], ['I:2', True]], [[0, 'I:1', True], [4, 'I:0', True]]],
[[['I:0', True]], [[3, 'I:1', True]]],
[[['I:0', True], ['I:2', False]], [[3, 'I:0', True], [2, 'I:1', False]]]]],
[['O:2'], ['O:2'], [], [], []]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:0', [[['XIC', 'O:1'], ['XIO', 'O:1'], ['XIC', 'O:0']]]],
['O:2', [[['XIC', 'I:2'], ['XIO', 'O:0'], ['XIC', 'I:0']]]],
['O:1', [[['XIC', 'O:2'], ['XIO', 'I:1']]]]],
[[[['I:0', False], ['I:1', False], ['I:2', True]], []],
[[['I:0', True], ['I:1', False], ['I:2', False]], [[1, 'I:0', False]]],
[[['I:0', False], ['I:1', True]], [[2, 'I:2', True], [0, 'I:1', False]]],
[[['I:1', False]], [[1, 'I:1', False], [1, 'I:0', False]]]]],
[[], [], [], []]]],
[['regression: scenario 26',
[[['O:2', [[['XIO', 'I:2']], [['XIO', 'I:0'], ['XIC', 'I:2'], ['XIO', 'O:1']]]],
['O:1', [[['XIC', 'I:1'], ['XIC', 'O:0']]]],
['O:1', [[['XIO', 'O:1'], ['XIO', 'I:2'], ['XIO', 'I:2']]]],
['B:1', [[['XIO', 'I:0'], ['XIO', 'I:2']], [['XIO', 'O:0'], ['XIO', 'I:1']]]]],
[[[['I:0', False], ['I:1', False]], [[1, 'I:2', False]]],
[[['I:0', True], ['I:1', False], ['I:2', False]], []],
[[['I:0', False]], [[2, 'I:1', False], [0, 'I:1', False]]],
[[['I:0', False], ['I:1', False], ['I:2', True]], [[0, 'I:2', True]]],
[[['I:1', True], ['I:2', True]], []],
[[['I:1', True]], [[1, 'I:2', False], [2, 'I:2', False]]]]],
[['O:1', 'O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], [], ['O:2'], ['O:2']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: scenario 1',
[[['B:0', [[['XIO', 'I:0']], [['XIO', 'I:0'], ['XIC', 'O:2'], ['XIC', 'B:0']]]],
['O:1', [[['XIO', 'I:2']]]],
['O:2', [[['XIC', 'B:0']], [['XIO', 'O:2']]]],
['B:1', [[['XIC', 'B:0']], [['XIC', 'B:0'], ['XIC', 'I:0'], ['XIC', 'B:0']]]]],
[[[['I:0', False], ['I:1', True], ['I:2', True]], [[2, 'I:0', False]]],
[[['I:1', False], ['I:2', False]], [[2, 'I:1', False], [2, 'I:1', False]]],
[[['I:0', False], ['I:1', True], ['I:2', False]], [[0, 'I:1', False], [3, 'I:1', False]]],
[[['I:0', False], ['I:1', True]], [[0, 'I:2', True], [3, 'I:2', True]]],
[[], [[2, 'I:2', False]]],
[[['I:0', False], ['I:1', False], ['I:2', False]], [[3, 'I:0', True], [2, 'I:2', True]]]]],
[['O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], ['O:2'], ['O:1', 'O:2']]]]]
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: input changes mid scan | [['O:1'], ['O:0', 'O:1']] | [[], ['O:0', 'O:1']] | Failed |
| regression: later rung uses earlier coil | [['O:0'], []] | [['O:0'], []] | Passed |
| regression: earlier rung uses later coil | [[], ['O:0'], ['O:0']] | [[], ['O:0'], ['O:0']] | Passed |
| regression: xio of unwritten tag | [['O:1', 'O:2'], ['O:2']] | [['O:1', 'O:2'], ['O:2']] | Passed |
| regression: parallel branch | [['O:0'], ['O:0']] | [['O:0'], ['O:0']] | Passed |
| regression: duplicate coil | [[], ['O:1']] | [[], ['O:1']] | Passed |
| control: scenario 1 | [['O:0'], [], ['O:0'], []] | [['O:0'], [], ['O:0'], []] | Passed |
| control: scenario 2 | [[], [], [], [], [], []] | [[], [], [], [], [], []] | Passed |
SHA-256 / 63c26f168a8b4c0edc1c5f736daa5ac1b640c53e6b33e82438abaa4d3c34e636
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rungs, scans):
phys = {}
table = {}
image = {}
out = []
for start, mid in scans:
for tag, val in start:
phys[tag] = bool(val)
for i, (coil, branches) in enumerate(rungs):
for at, tag, val in mid:
if at == i:
phys[tag] = bool(val)
def read(tag):
if tag.startswith('I:'):
return image.get(tag, False)
return table.get(tag, False)
power = any(all(read(t) if k == 'XIC' else not read(t) for k, t in br) for br in branches)
table[coil] = power
image = dict(phys)
out.append(sorted(t for t, v in table.items() if v and t.startswith('O:')))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:0', [[['XIC', 'I:1'], ['XIC', 'O:0'], ['XIC', 'I:1']], [['XIO', 'O:0']]]],
['B:0', [[['XIO', 'I:0'], ['XIO', 'B:1'], ['XIC', 'O:0']], [['XIC', 'I:2'], ['XIC', 'I:2']]]],
['O:1', [[['XIC', 'O:2'], ['XIC', 'I:0'], ['XIC', 'O:0']]]],
['O:1',
[[['XIO', 'O:1'], ['XIC', 'B:0'], ['XIC', 'B:0']], [['XIC', 'O:1'], ['XIC', 'B:0'], ['XIC', 'O:2']]]],
['O:1',
[[['XIC', 'I:0'], ['XIO', 'I:0'], ['XIO', 'O:0']], [['XIC', 'O:2'], ['XIC', 'I:1'], ['XIO', 'B:0']]]]],
[[[['I:0', True], ['I:1', False]], [[1, 'I:2', True]]],
[[['I:2', True]], []],
[[['I:2', True]], [[0, 'I:2', True]]],
[[['I:0', True], ['I:2', False]], [[4, 'I:2', False], [4, 'I:2', True]]]]],
[['O:0'], [], ['O:0'], []]],
['control: scenario 2',
[[['O:1', [[['XIC', 'O:2'], ['XIO', 'O:0'], ['XIO', 'O:0']]]],
['O:0', [[['XIC', 'B:1'], ['XIC', 'O:0']]]],
['B:0', [[['XIC', 'O:2']], [['XIC', 'O:0']]]]],
[[[['I:0', True], ['I:2', False]], []],
[[['I:0', False], ['I:1', True], ['I:2', False]], []],
[[['I:0', True]], []],
[[['I:2', False]], [[0, 'I:2', False]]],
[[['I:0', True], ['I:1', False], ['I:2', True]], [[1, 'I:0', False], [1, 'I:1', True]]],
[[['I:1', False]], [[2, 'I:2', True], [0, 'I:2', True]]]]],
[[], [], [], [], [], []]]],
[['regression: scenario 1',
[[['B:0', [[['XIO', 'I:1'], ['XIC', 'O:0'], ['XIC', 'O:2']]]],
['O:1', [[['XIC', 'O:1'], ['XIO', 'B:0'], ['XIO', 'B:0']]]],
['O:2', [[['XIC', 'O:2'], ['XIC', 'I:2'], ['XIC', 'I:1']], [['XIC', 'O:2'], ['XIC', 'O:0']]]],
['O:1', [[['XIC', 'I:0']], [['XIC', 'I:2'], ['XIO', 'I:0']]]]],
[[[['I:2', False]], []],
[[['I:0', False], ['I:2', False]], [[0, 'I:1', True]]],
[[['I:0', False], ['I:1', True]], [[3, 'I:0', True], [0, 'I:0', True]]],
[[['I:0', False]], [[3, 'I:0', False], [2, 'I:2', False]]],
[[['I:0', True], ['I:1', True], ['I:2', False]], [[3, 'I:0', True]]],
[[['I:2', True]], []]]],
[[], [], [], [], ['O:1'], ['O:1']]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 2',
[[['B:1', [[['XIC', 'O:0'], ['XIC', 'I:2']], [['XIC', 'I:2'], ['XIC', 'B:0'], ['XIC', 'I:1']]]],
['B:1', [[['XIC', 'O:2']]]],
['O:0', [[['XIC', 'O:2']]]],
['B:1', [[['XIO', 'O:0']], [['XIC', 'I:0'], ['XIC', 'O:2'], ['XIO', 'O:1']]]]],
[[[], [[2, 'I:2', True]]],
[[['I:2', True]], []],
[[['I:0', True], ['I:2', False]], [[2, 'I:1', False], [3, 'I:1', False]]],
[[['I:1', True], ['I:2', False]], []]]],
[[], [], [], []]]],
[['regression: scenario 6',
[[['O:1', [[['XIC', 'O:2'], ['XIC', 'O:0'], ['XIC', 'I:0']], [['XIC', 'O:0'], ['XIC', 'I:2']]]],
['O:1', [[['XIC', 'I:0'], ['XIC', 'I:1']], [['XIO', 'I:1']]]],
['B:0', [[['XIO', 'I:2'], ['XIO', 'B:1'], ['XIC', 'B:1']]]]],
[[[], [[0, 'I:2', False], [1, 'I:1', True]]],
[[], [[2, 'I:2', False], [1, 'I:2', False]]],
[[['I:0', False], ['I:1', True], ['I:2', False]], [[0, 'I:2', True]]]]],
[['O:1'], [], []]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:1', [[['XIC', 'O:2'], ['XIO', 'O:0']], [['XIO', 'I:1']]]],
['O:1', [[['XIC', 'I:0'], ['XIC', 'O:1']], [['XIO', 'I:1'], ['XIC', 'O:0']]]],
['B:0', [[['XIC', 'B:0'], ['XIC', 'B:0']]]]],
[[[['I:0', False], ['I:1', True], ['I:2', False]], []],
[[['I:0', True], ['I:1', True], ['I:2', True]], [[0, 'I:2', False]]],
[[['I:1', True], ['I:2', False]], []],
[[['I:0', False], ['I:1', False]], [[2, 'I:2', True]]],
[[['I:0', False]], [[1, 'I:2', False], [2, 'I:2', True]]]]],
[[], [], [], [], []]]],
[['regression: scenario 10',
[[['B:1', [[['XIC', 'I:2'], ['XIC', 'B:1'], ['XIO', 'B:1']], [['XIO', 'B:1']]]],
['B:0', [[['XIC', 'I:1'], ['XIC', 'B:1'], ['XIC', 'O:2']], [['XIC', 'I:1'], ['XIO', 'O:1']]]],
['O:2', [[['XIC', 'B:1']]]],
['B:1', [[['XIC', 'B:1'], ['XIO', 'B:0']], [['XIC', 'I:0'], ['XIC', 'I:0']]]],
['B:0', [[['XIC', 'O:0']], [['XIC', 'I:1'], ['XIO', 'O:0']]]]],
[[[['I:1', True]], [[1, 'I:1', False]]],
[[['I:1', False], ['I:2', False]], [[4, 'I:0', False]]],
[[['I:0', True], ['I:1', True], ['I:2', True]], [[0, 'I:1', True], [4, 'I:0', True]]],
[[['I:0', True]], [[3, 'I:1', True]]],
[[['I:0', True], ['I:2', False]], [[3, 'I:0', True], [2, 'I:1', False]]]]],
[['O:2'], ['O:2'], [], [], []]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:0', [[['XIC', 'O:1'], ['XIO', 'O:1'], ['XIC', 'O:0']]]],
['O:2', [[['XIC', 'I:2'], ['XIO', 'O:0'], ['XIC', 'I:0']]]],
['O:1', [[['XIC', 'O:2'], ['XIO', 'I:1']]]]],
[[[['I:0', False], ['I:1', False], ['I:2', True]], []],
[[['I:0', True], ['I:1', False], ['I:2', False]], [[1, 'I:0', False]]],
[[['I:0', False], ['I:1', True]], [[2, 'I:2', True], [0, 'I:1', False]]],
[[['I:1', False]], [[1, 'I:1', False], [1, 'I:0', False]]]]],
[[], [], [], []]]],
[['regression: scenario 26',
[[['O:2', [[['XIO', 'I:2']], [['XIO', 'I:0'], ['XIC', 'I:2'], ['XIO', 'O:1']]]],
['O:1', [[['XIC', 'I:1'], ['XIC', 'O:0']]]],
['O:1', [[['XIO', 'O:1'], ['XIO', 'I:2'], ['XIO', 'I:2']]]],
['B:1', [[['XIO', 'I:0'], ['XIO', 'I:2']], [['XIO', 'O:0'], ['XIO', 'I:1']]]]],
[[[['I:0', False], ['I:1', False]], [[1, 'I:2', False]]],
[[['I:0', True], ['I:1', False], ['I:2', False]], []],
[[['I:0', False]], [[2, 'I:1', False], [0, 'I:1', False]]],
[[['I:0', False], ['I:1', False], ['I:2', True]], [[0, 'I:2', True]]],
[[['I:1', True], ['I:2', True]], []],
[[['I:1', True]], [[1, 'I:2', False], [2, 'I:2', False]]]]],
[['O:1', 'O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], [], ['O:2'], ['O:2']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: scenario 1',
[[['B:0', [[['XIO', 'I:0']], [['XIO', 'I:0'], ['XIC', 'O:2'], ['XIC', 'B:0']]]],
['O:1', [[['XIO', 'I:2']]]],
['O:2', [[['XIC', 'B:0']], [['XIO', 'O:2']]]],
['B:1', [[['XIC', 'B:0']], [['XIC', 'B:0'], ['XIC', 'I:0'], ['XIC', 'B:0']]]]],
[[[['I:0', False], ['I:1', True], ['I:2', True]], [[2, 'I:0', False]]],
[[['I:1', False], ['I:2', False]], [[2, 'I:1', False], [2, 'I:1', False]]],
[[['I:0', False], ['I:1', True], ['I:2', False]], [[0, 'I:1', False], [3, 'I:1', False]]],
[[['I:0', False], ['I:1', True]], [[0, 'I:2', True], [3, 'I:2', True]]],
[[], [[2, 'I:2', False]]],
[[['I:0', False], ['I:1', False], ['I:2', False]], [[3, 'I:0', True], [2, 'I:2', True]]]]],
[['O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], ['O:2'], ['O:1', 'O:2']]]]]
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: input changes mid scan | [[], ['O:0', 'O:1']] | [[], ['O:0', 'O:1']] | Passed |
| regression: later rung uses earlier coil | [[], ['O:0']] | [['O:0'], []] | Failed |
| regression: earlier rung uses later coil | [[], [], ['O:0']] | [[], ['O:0'], ['O:0']] | Failed |
| regression: xio of unwritten tag | [['O:1', 'O:2'], ['O:1', 'O:2']] | [['O:1', 'O:2'], ['O:2']] | Failed |
| regression: parallel branch | [[], ['O:0']] | [['O:0'], ['O:0']] | Failed |
| regression: duplicate coil | [[], []] | [[], ['O:1']] | Failed |
| control: scenario 1 | [['O:0'], [], ['O:0'], []] | [['O:0'], [], ['O:0'], []] | Passed |
| control: scenario 2 | [[], [], [], [], [], []] | [[], [], [], [], [], []] | Passed |
SHA-256 / fa6bbb12c9086a76f7158f568d4c969eaa0c639b1d9d26317e162a169df8d789
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rungs, scans):
phys = {}
table = {}
out = []
for start, mid in scans:
for tag, val in start:
phys[tag] = bool(val)
image = dict(phys)
for i, (coil, branches) in enumerate(rungs):
for at, tag, val in mid:
if at == i:
phys[tag] = bool(val)
def read(tag):
if tag.startswith('I:'):
return image.get(tag, False)
return table.get(tag, False)
power = any(all(read(t) if k == 'XIC' else not read(t) for k, t in br) for br in branches)
table[coil] = power
out.append(sorted(t for t, v in table.items() if v and t.startswith('O:')))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:0', [[['XIC', 'I:1'], ['XIC', 'O:0'], ['XIC', 'I:1']], [['XIO', 'O:0']]]],
['B:0', [[['XIO', 'I:0'], ['XIO', 'B:1'], ['XIC', 'O:0']], [['XIC', 'I:2'], ['XIC', 'I:2']]]],
['O:1', [[['XIC', 'O:2'], ['XIC', 'I:0'], ['XIC', 'O:0']]]],
['O:1',
[[['XIO', 'O:1'], ['XIC', 'B:0'], ['XIC', 'B:0']], [['XIC', 'O:1'], ['XIC', 'B:0'], ['XIC', 'O:2']]]],
['O:1',
[[['XIC', 'I:0'], ['XIO', 'I:0'], ['XIO', 'O:0']], [['XIC', 'O:2'], ['XIC', 'I:1'], ['XIO', 'B:0']]]]],
[[[['I:0', True], ['I:1', False]], [[1, 'I:2', True]]],
[[['I:2', True]], []],
[[['I:2', True]], [[0, 'I:2', True]]],
[[['I:0', True], ['I:2', False]], [[4, 'I:2', False], [4, 'I:2', True]]]]],
[['O:0'], [], ['O:0'], []]],
['control: scenario 2',
[[['O:1', [[['XIC', 'O:2'], ['XIO', 'O:0'], ['XIO', 'O:0']]]],
['O:0', [[['XIC', 'B:1'], ['XIC', 'O:0']]]],
['B:0', [[['XIC', 'O:2']], [['XIC', 'O:0']]]]],
[[[['I:0', True], ['I:2', False]], []],
[[['I:0', False], ['I:1', True], ['I:2', False]], []],
[[['I:0', True]], []],
[[['I:2', False]], [[0, 'I:2', False]]],
[[['I:0', True], ['I:1', False], ['I:2', True]], [[1, 'I:0', False], [1, 'I:1', True]]],
[[['I:1', False]], [[2, 'I:2', True], [0, 'I:2', True]]]]],
[[], [], [], [], [], []]]],
[['regression: scenario 1',
[[['B:0', [[['XIO', 'I:1'], ['XIC', 'O:0'], ['XIC', 'O:2']]]],
['O:1', [[['XIC', 'O:1'], ['XIO', 'B:0'], ['XIO', 'B:0']]]],
['O:2', [[['XIC', 'O:2'], ['XIC', 'I:2'], ['XIC', 'I:1']], [['XIC', 'O:2'], ['XIC', 'O:0']]]],
['O:1', [[['XIC', 'I:0']], [['XIC', 'I:2'], ['XIO', 'I:0']]]]],
[[[['I:2', False]], []],
[[['I:0', False], ['I:2', False]], [[0, 'I:1', True]]],
[[['I:0', False], ['I:1', True]], [[3, 'I:0', True], [0, 'I:0', True]]],
[[['I:0', False]], [[3, 'I:0', False], [2, 'I:2', False]]],
[[['I:0', True], ['I:1', True], ['I:2', False]], [[3, 'I:0', True]]],
[[['I:2', True]], []]]],
[[], [], [], [], ['O:1'], ['O:1']]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 2',
[[['B:1', [[['XIC', 'O:0'], ['XIC', 'I:2']], [['XIC', 'I:2'], ['XIC', 'B:0'], ['XIC', 'I:1']]]],
['B:1', [[['XIC', 'O:2']]]],
['O:0', [[['XIC', 'O:2']]]],
['B:1', [[['XIO', 'O:0']], [['XIC', 'I:0'], ['XIC', 'O:2'], ['XIO', 'O:1']]]]],
[[[], [[2, 'I:2', True]]],
[[['I:2', True]], []],
[[['I:0', True], ['I:2', False]], [[2, 'I:1', False], [3, 'I:1', False]]],
[[['I:1', True], ['I:2', False]], []]]],
[[], [], [], []]]],
[['regression: scenario 6',
[[['O:1', [[['XIC', 'O:2'], ['XIC', 'O:0'], ['XIC', 'I:0']], [['XIC', 'O:0'], ['XIC', 'I:2']]]],
['O:1', [[['XIC', 'I:0'], ['XIC', 'I:1']], [['XIO', 'I:1']]]],
['B:0', [[['XIO', 'I:2'], ['XIO', 'B:1'], ['XIC', 'B:1']]]]],
[[[], [[0, 'I:2', False], [1, 'I:1', True]]],
[[], [[2, 'I:2', False], [1, 'I:2', False]]],
[[['I:0', False], ['I:1', True], ['I:2', False]], [[0, 'I:2', True]]]]],
[['O:1'], [], []]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:1', [[['XIC', 'O:2'], ['XIO', 'O:0']], [['XIO', 'I:1']]]],
['O:1', [[['XIC', 'I:0'], ['XIC', 'O:1']], [['XIO', 'I:1'], ['XIC', 'O:0']]]],
['B:0', [[['XIC', 'B:0'], ['XIC', 'B:0']]]]],
[[[['I:0', False], ['I:1', True], ['I:2', False]], []],
[[['I:0', True], ['I:1', True], ['I:2', True]], [[0, 'I:2', False]]],
[[['I:1', True], ['I:2', False]], []],
[[['I:0', False], ['I:1', False]], [[2, 'I:2', True]]],
[[['I:0', False]], [[1, 'I:2', False], [2, 'I:2', True]]]]],
[[], [], [], [], []]]],
[['regression: scenario 10',
[[['B:1', [[['XIC', 'I:2'], ['XIC', 'B:1'], ['XIO', 'B:1']], [['XIO', 'B:1']]]],
['B:0', [[['XIC', 'I:1'], ['XIC', 'B:1'], ['XIC', 'O:2']], [['XIC', 'I:1'], ['XIO', 'O:1']]]],
['O:2', [[['XIC', 'B:1']]]],
['B:1', [[['XIC', 'B:1'], ['XIO', 'B:0']], [['XIC', 'I:0'], ['XIC', 'I:0']]]],
['B:0', [[['XIC', 'O:0']], [['XIC', 'I:1'], ['XIO', 'O:0']]]]],
[[[['I:1', True]], [[1, 'I:1', False]]],
[[['I:1', False], ['I:2', False]], [[4, 'I:0', False]]],
[[['I:0', True], ['I:1', True], ['I:2', True]], [[0, 'I:1', True], [4, 'I:0', True]]],
[[['I:0', True]], [[3, 'I:1', True]]],
[[['I:0', True], ['I:2', False]], [[3, 'I:0', True], [2, 'I:1', False]]]]],
[['O:2'], ['O:2'], [], [], []]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['control: scenario 1',
[[['O:0', [[['XIC', 'O:1'], ['XIO', 'O:1'], ['XIC', 'O:0']]]],
['O:2', [[['XIC', 'I:2'], ['XIO', 'O:0'], ['XIC', 'I:0']]]],
['O:1', [[['XIC', 'O:2'], ['XIO', 'I:1']]]]],
[[[['I:0', False], ['I:1', False], ['I:2', True]], []],
[[['I:0', True], ['I:1', False], ['I:2', False]], [[1, 'I:0', False]]],
[[['I:0', False], ['I:1', True]], [[2, 'I:2', True], [0, 'I:1', False]]],
[[['I:1', False]], [[1, 'I:1', False], [1, 'I:0', False]]]]],
[[], [], [], []]]],
[['regression: scenario 26',
[[['O:2', [[['XIO', 'I:2']], [['XIO', 'I:0'], ['XIC', 'I:2'], ['XIO', 'O:1']]]],
['O:1', [[['XIC', 'I:1'], ['XIC', 'O:0']]]],
['O:1', [[['XIO', 'O:1'], ['XIO', 'I:2'], ['XIO', 'I:2']]]],
['B:1', [[['XIO', 'I:0'], ['XIO', 'I:2']], [['XIO', 'O:0'], ['XIO', 'I:1']]]]],
[[[['I:0', False], ['I:1', False]], [[1, 'I:2', False]]],
[[['I:0', True], ['I:1', False], ['I:2', False]], []],
[[['I:0', False]], [[2, 'I:1', False], [0, 'I:1', False]]],
[[['I:0', False], ['I:1', False], ['I:2', True]], [[0, 'I:2', True]]],
[[['I:1', True], ['I:2', True]], []],
[[['I:1', True]], [[1, 'I:2', False], [2, 'I:2', False]]]]],
[['O:1', 'O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], [], ['O:2'], ['O:2']]],
['regression: duplicate coil',
[[['O:1', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:1']]]]],
[[[['I:0', True], ['I:1', False]], []], [[['I:0', False], ['I:1', True]], []]]],
[[], ['O:1']]],
['regression: input changes mid scan',
[[['O:0', [[['XIC', 'I:0']]]], ['O:1', [[['XIC', 'I:0']]]]],
[[[['I:0', False]], [[1, 'I:0', True]]], [[], []]]],
[[], ['O:0', 'O:1']]],
['regression: later rung uses earlier coil',
[[['B:0', [[['XIC', 'I:1']]]], ['O:0', [[['XIC', 'B:0']]]]],
[[[['I:1', True]], []], [[['I:1', False]], []]]],
[['O:0'], []]],
['regression: earlier rung uses later coil',
[[['O:0', [[['XIC', 'B:1']]]], ['B:1', [[['XIC', 'I:1']]]]],
[[[['I:1', True]], []], [[], []], [[['I:1', False]], []]]],
[[], ['O:0'], ['O:0']]],
['regression: xio of unwritten tag',
[[['O:2', [[['XIO', 'B:1']]]], ['O:1', [[['XIO', 'I:2']]]]], [[[], []], [[['I:2', True]], []]]],
[['O:1', 'O:2'], ['O:2']]],
['regression: parallel branch',
[[['O:0', [[['XIC', 'I:0']], [['XIC', 'I:1'], ['XIO', 'I:2']]]]],
[[[['I:0', False], ['I:1', True]], []], [[['I:0', True], ['I:1', False]], []]]],
[['O:0'], ['O:0']]],
['regression: scenario 1',
[[['B:0', [[['XIO', 'I:0']], [['XIO', 'I:0'], ['XIC', 'O:2'], ['XIC', 'B:0']]]],
['O:1', [[['XIO', 'I:2']]]],
['O:2', [[['XIC', 'B:0']], [['XIO', 'O:2']]]],
['B:1', [[['XIC', 'B:0']], [['XIC', 'B:0'], ['XIC', 'I:0'], ['XIC', 'B:0']]]]],
[[[['I:0', False], ['I:1', True], ['I:2', True]], [[2, 'I:0', False]]],
[[['I:1', False], ['I:2', False]], [[2, 'I:1', False], [2, 'I:1', False]]],
[[['I:0', False], ['I:1', True], ['I:2', False]], [[0, 'I:1', False], [3, 'I:1', False]]],
[[['I:0', False], ['I:1', True]], [[0, 'I:2', True], [3, 'I:2', True]]],
[[], [[2, 'I:2', False]]],
[[['I:0', False], ['I:1', False], ['I:2', False]], [[3, 'I:0', True], [2, 'I:2', True]]]]],
[['O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], ['O:1', 'O:2'], ['O:2'], ['O:1', 'O:2']]]]]
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: input changes mid scan | [[], ['O:0', 'O:1']] | [[], ['O:0', 'O:1']] | Passed |
| regression: later rung uses earlier coil | [['O:0'], []] | [['O:0'], []] | Passed |
| regression: earlier rung uses later coil | [[], ['O:0'], ['O:0']] | [[], ['O:0'], ['O:0']] | Passed |
| regression: xio of unwritten tag | [['O:1', 'O:2'], ['O:2']] | [['O:1', 'O:2'], ['O:2']] | Passed |
| regression: parallel branch | [['O:0'], ['O:0']] | [['O:0'], ['O:0']] | Passed |
| regression: duplicate coil | [[], ['O:1']] | [[], ['O:1']] | Passed |
| control: scenario 1 | [['O:0'], [], ['O:0'], []] | [['O:0'], [], ['O:0'], []] | Passed |
| control: scenario 2 | [[], [], [], [], [], []] | [[], [], [], [], [], []] | Passed |
SHA-256 / 173f26a030ad5081e3f9d0b2aaedecda6de0bf0bcd034d3f866d64e55254c66e
Verification & scope
A deterministic bounded teaching model of one PLC instruction or rung pattern evaluated scan by scan. The stated contract is a stipulated toy convention, not a claim of conformance to any vendor controller or IEC 61131-3 runtime. 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:41.123300+00:00.
Case digest / 4fb5d29c2d0bb55613cc4c1cb308bb1e77805d7cbb6697ee287075fdf0f8bb73