{
  "unit": "L-meta-25842",
  "statement": "∃ C : PEqualNP.CircuitLowerBounds.Circuit, PEqualNP.MetaComplexity.FanInTwo C ∧ C.size ≤ 5 ∧ PEqualNP.Represents.Represents (fun u v : Fin 4 => (31711 : ℕ).testBit (4 * u.val + v.val)) C",
  "statement_sha256": "4fe198e282e212a2320c6a06c6cb80f66d704aae2c295e86f3a10f54759dc9fe",
  "method": "Breadth-first closure over sets of 16-cell truth tables. The fetched statement agrees with the brief. Counts at depths 0–4 are distinct reachable states with that many new tables. The depth-5 count is the number of terminal states visited, deduplicated within each parent and counted again when reached from a different parent. The independent scalar evaluator produced decimal mask 31711 (row-major rows 1111, 1011, 1101, 1110) for the six-gate circuit. The four-gate sanity witness is OR(1,6), OR(2,5), AND(8,9), NOT(10), with output wire 11.",
  "verdict": "no_circuit",
  "search_complete": true,
  "min_gates_found": null,
  "circuit": null,
  "six_gate_check": "pass",
  "sanity": {
    "found_at_4": true,
    "absent_at_3": true
  },
  "counts": {
    "0": 1,
    "1": 53,
    "2": 1762,
    "3": 48290,
    "4": 1209269,
    "5": 98122321
  },
  "seconds": 1.7,
  "coverage": "On the 16 oneEach inputs each wire is a truth table, with bit 4u+v for cell (u,v). The available tables start with the eight input tables and an implicit zero for any unavailable wire, including the output. FanInTwo allows only AND, OR and NOT. Empty AND and NOT give all ones; empty OR gives zero. Unary or repeated-input AND/OR returns the input table. With a missing operand, AND gives zero and OR returns the other operand. NOT ignores its second operand and complements its first, including implicit zero. Thus new tables come only from the constant ones, complements, and AND/OR on pairs of distinct available tables. A gate adding an available table can be skipped at the table-set level because future gates need only values and can select existing representatives or a missing index for zero. Each retained transition is realizable by one gate. The search tests the initial outputs and every new table. For exact sizes, any shorter witness can be padded by unused gates, moving an absent output index past the final wire if needed. The last layer needs only a full scan of outgoing transitions, since there are no later transitions to merge.",
  "program": "#include <algorithm>\n#include <array>\n#include <cstdint>\n#include <cstdlib>\n#include <iostream>\n#include <unordered_set>\n#include <vector>\n\nusing Table = std::uint16_t;\nusing State = std::uint64_t;\nusing Layer = std::unordered_set<State>;\nconstexpr Table full = 0xffff;\nconstexpr Table target = 31711;\nconstexpr Table sanity = full ^ ((1u << 5) | (1u << 10));\n\nenum Op { And, Or, Not };\nstruct Gate {\n    Op op;\n    std::vector<unsigned> inputs;\n};\nstruct Circuit {\n    std::vector<Gate> gates;\n    unsigned output;\n};\n\nstd::array<Table, 8> inputs() {\n    std::array<Table, 8> tables{};\n    for (unsigned u = 0; u < 4; ++u)\n        for (unsigned v = 0; v < 4; ++v) {\n            tables[u] |= 1u << (4 * u + v);\n            tables[4 + v] |= 1u << (4 * u + v);\n        }\n    return tables;\n}\nconst auto base = inputs();\n\nstd::vector<Table> unpack(State state, unsigned depth) {\n    std::vector<Table> tables;\n    for (unsigned i = 0; i < depth; ++i) {\n        tables.push_back(static_cast<Table>(state));\n        state >>= 16;\n    }\n    return tables;\n}\n\nState insert(const std::vector<Table>& sorted, Table added) {\n    State result = 0;\n    unsigned shift = 0;\n    for (Table present : sorted) {\n        if (added < present) {\n            result |= State(added) << shift;\n            shift += 16;\n            added = full; // no further insertion before an existing table\n        }\n        result |= State(present) << shift;\n        shift += 16;\n    }\n    if (shift == 16 * sorted.size())\n        result |= State(added) << shift;\n    return result;\n}\n\ntemplate<class Emit>\nvoid choices(const std::vector<Table>& wires, Emit emit) {\n    const unsigned missing = wires.size();\n    emit(full, And, missing, missing);\n    for (unsigned i = 0; i < wires.size(); ++i) {\n        emit(full ^ wires[i], Not, i, missing);\n        for (unsigned j = i + 1; j < wires.size(); ++j) {\n            emit(wires[i] & wires[j], And, i, j);\n            emit(wires[i] | wires[j], Or, i, j);\n        }\n    }\n}\n\nstd::vector<Table> available(const std::vector<Table>& extra) {\n    std::vector<Table> wires(base.begin(), base.end());\n    wires.insert(wires.end(), extra.begin(), extra.end());\n    return wires;\n}\n\n// Recover a valid insertion order by following reachable predecessors.\nvoid recover(State state, unsigned depth, const std::array<Layer, 5>& layers,\n             std::vector<Table>& wires, std::vector<Gate>& gates) {\n    if (depth == 0) return;\n    const auto extra = unpack(state, depth);\n    for (Table last : extra) {\n        State before = 0;\n        unsigned shift = 0;\n        for (Table table : extra)\n            if (table != last) {\n                before |= State(table) << shift;\n                shift += 16;\n            }\n        if (!layers[depth - 1].contains(before)) continue;\n        bool possible = false;\n        choices(available(unpack(before, depth - 1)),\n                [&](Table t, Op, unsigned, unsigned) { possible |= t == last; });\n        if (!possible) continue;\n        recover(before, depth - 1, layers, wires, gates);\n        choices(wires, [&](Table t, Op op, unsigned i, unsigned j) {\n            if (t != last || gates.size() == depth) return;\n            const unsigned missing = wires.size();\n            std::vector<unsigned> args;\n            if (i != missing) args.push_back(i);\n            if (j != missing) args.push_back(j);\n            gates.push_back({op, args});\n        });\n        wires.push_back(last);\n        return;\n    }\n    std::abort();\n}\n\n// Independent scalar evaluation of all 16 Lean oneEach inputs.\nTable evaluate(const Circuit& circuit) {\n    Table result = 0;\n    for (unsigned u = 0; u < 4; ++u)\n        for (unsigned v = 0; v < 4; ++v) {\n            std::vector<bool> wires(8, false);\n            wires[u] = wires[4 + v] = true;\n            auto read = [&](unsigned i) { return i < wires.size() && wires[i]; };\n            for (const auto& gate : circuit.gates) {\n                bool value = gate.op == And;\n                if (gate.op == Not) {\n                    value = gate.inputs.empty() || !read(gate.inputs.front());\n                } else {\n                    for (unsigned i : gate.inputs)\n                        value = gate.op == And ? value && read(i) : value || read(i);\n                }\n                wires.push_back(value);\n            }\n            if (read(circuit.output)) result |= 1u << (4 * u + v);\n        }\n    return result;\n}\n\nvoid print_circuit(State before, unsigned depth, Table wanted,\n                   const std::array<Layer, 5>& layers) {\n    auto wires = available({});\n    Circuit circuit{};\n    recover(before, depth, layers, wires, circuit.gates);\n    choices(wires, [&](Table t, Op op, unsigned i, unsigned j) {\n        if (t != wanted || circuit.gates.size() != depth) return;\n        const unsigned missing = wires.size();\n        std::vector<unsigned> args;\n        if (i != missing) args.push_back(i);\n        if (j != missing) args.push_back(j);\n        circuit.gates.push_back({op, args});\n    });\n    if (circuit.gates.size() != depth + 1) std::abort();\n    circuit.output = wires.size();\n    if (evaluate(circuit) != wanted) std::abort();\n    std::cout << \"witness \" << wanted << \" output \" << circuit.output << '\\n';\n    for (const auto& gate : circuit.gates) {\n        std::cout << (gate.op == And ? \"and\" : gate.op == Or ? \"or\" : \"not\");\n        for (unsigned i : gate.inputs) std::cout << ' ' << i;\n        std::cout << '\\n';\n    }\n}\n\nint main() {\n    const Circuit six{{{And, {1, 5}}, {And, {2, 6}}, {And, {3, 7}},\n                       {Or, {8, 9}}, {Or, {11, 10}}, {Not, {12}}}, 13};\n    const Table six_mask = evaluate(six);\n    std::cout << \"six \" << six_mask << '\\n';\n    std::array<Layer, 5> layers;\n    layers[0].insert(0);\n    std::array<int, 2> minimum{-1, -1};\n    const std::array<Table, 2> wanted{target, sanity};\n    std::array<State, 2> predecessor{};\n    for (unsigned i = 0; i < wanted.size(); ++i)\n        if (!wanted[i] || std::find(base.begin(), base.end(), wanted[i]) != base.end())\n            minimum[i] = 0;\n\n    // Per-parent generation stamps deduplicate candidate tables.\n    std::array<std::uint64_t, 65536> seen{};\n    std::uint64_t stamp = 0;\n    for (unsigned depth = 0; depth < 5; ++depth) {\n        std::cout << \"count \" << depth << ' ' << layers[depth].size() << std::endl;\n        std::uint64_t children = 0;\n        for (State state : layers[depth]) {\n            ++stamp;\n            const auto extra = unpack(state, depth);\n            const auto wires = available(extra);\n            seen[0] = stamp;\n            for (Table t : wires) seen[t] = stamp;\n            choices(wires, [&](Table t, Op, unsigned, unsigned) {\n                if (seen[t] == stamp) return;\n                seen[t] = stamp;\n                ++children;\n                for (unsigned i = 0; i < wanted.size(); ++i)\n                    if (t == wanted[i] && minimum[i] == -1) {\n                        minimum[i] = depth + 1;\n                        predecessor[i] = state;\n                    }\n                if (depth < 4) layers[depth + 1].insert(insert(extra, t));\n            });\n        }\n        if (depth == 4) std::cout << \"count 5 \" << children << '\\n';\n    }\n    for (unsigned i = 0; i < wanted.size(); ++i) {\n        std::cout << \"minimum \" << wanted[i] << ' ' << minimum[i] << '\\n';\n        if (minimum[i] > 0)\n            print_circuit(predecessor[i], minimum[i] - 1, wanted[i], layers);\n    }\n}\n",
  "program_language": "C++20",
  "program_sha256": "566f9717b373fcc0109c0ae50886f1f1cef1a65db5011bfc4d46602951903240",
  "how_to_run": "From the directory containing result.json, run jq -j '.program' result.json > search.cpp, then c++ -std=c++20 -O3 search.cpp -o search && ./search. A minimum of -1 means absent through size five. The program requires only a C++20 compiler and standard library.",
  "pr_open": 0,
  "held_now": false
}
