{ "task": { "id": "case_124", "name": "check_all_equal", "summary": "Check if all elements in a list are equal.", "examples": [ { "input": [ "BOS", 3, 3, 3, 3, 3, 3, 3, 3, 3 ], "output": [ "BOS", 1, 1, 1, 1, 1, 1, 1, 1, 1 ] }, { "input": [ "BOS", 9, 4, 0, 2, 5, 3, 7, 10, 8 ], "output": [ "BOS", 0, 0, 0, 0, 0, 0, 0, 0, 0 ] }, { "input": [ "BOS", 2, 1, 8, 9, 4, 3, 0, 6, 5 ], "output": [ "BOS", 0, 0, 0, 0, 0, 0, 0, 0, 0 ] }, { "input": [ "BOS", 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "output": [ "BOS", 1, 1, 1, 1, 1, 1, 1, 1, 1 ] }, { "input": [ "BOS", 3, 8, 0, 10, 5, 6, 4, 7, 9 ], "output": [ "BOS", 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } ], "is_categorical": true }, "program": "unequal_selector = rasp.Select(rasp.tokens, rasp.tokens, lambda x, y: x != y)\nchecks = rasp.SelectorWidth(unequal_selector)\nzero_selector = rasp.Select(checks, rasp.Map(lambda x: 0, rasp.indices), rasp.Comparison.EQ)\nreturn rasp.Map(lambda x: 1 if x > 0 else 0, rasp.SelectorWidth(zero_selector))", "components": [ { "id": "L0H0_ATTN", "hook": "blocks.0.attn.hook_result[0]", "role": { "tag": "AGGREGATOR", "note": "Aggregates positions holding tokens unequal to the current token into a per-position mismatch count." }, "rasp_vars": [ "unequal_selector" ], "labels": [ "selector_width_4_selector_width_attn_output" ] }, { "id": "L0_MLP", "hook": "blocks.0.mlp.hook_post", "role": { "tag": "MAPPER", "note": "Turns the mismatch signal into a per-position mismatch count and prepares it for the global decision." }, "rasp_vars": [ "checks" ], "labels": [ "selector_width_4", "map_5", "selector_width_4_selector_width_attn_output" ] }, { "id": "L1H0_ATTN", "hook": "blocks.1.attn.hook_result[0]", "role": { "tag": "AGGREGATOR", "note": "Aggregates positions where the mismatch count is zero, producing a per-position count of zero-mismatch occurrences." }, "rasp_vars": [ "zero_selector" ], "labels": [ "selector_width_2_selector_width_attn_output" ] }, { "id": "L1_MLP", "hook": "blocks.1.mlp.hook_post", "role": { "tag": "MAPPER", "note": "Converts the zero-mismatch mask into a scalar-like summary signal that can be read out." }, "rasp_vars": [ "all_equal_signal" ], "labels": [ "selector_width_2", "selector_width_2_selector_width_attn_output" ] }, { "id": "L2_MLP", "hook": "blocks.2.mlp.hook_post", "role": { "tag": "INDICATOR", "note": "Outputs the final binary decision: 1 if all elements are equal, otherwise 0." }, "rasp_vars": [ "all_equal" ], "labels": [ "map_1" ] } ] }