{
 "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",
 "statement_matches_brief": true,
 "statement_note": "Fetched text matches the brief: exists C, FanInTwo C, C.size <= 5, Represents (fun u v : Fin 4 => (31711 : N).testBit (4*u.val+v.val)) C. 31711 = 0x7BDF gives row masks 15, 13, 11, 7, i.e. A u v = not(u = v and u >= 1).",
 "method": "Explicit enumeration (C, depth-first) of gate sequences over 16-bit wire truth tables on the 16 oneEach inputs, deduplicating gates by the table they produce, for every gate count 0..5; found circuits checked with a literal evaluator of Circuit.wires/eval.",
 "verdict": "no_circuit",
 "search_complete": true,
 "min_gates_found": null,
 "min_gates_note": "No circuit of at most 5 gates exists; the 6-gate circuit below meets the statement with 6, so the minimum is 6.",
 "circuit": null,
 "six_gate_circuit": {
  "gates": [
   {
    "op": "and",
    "inputs": [
     1,
     5
    ]
   },
   {
    "op": "and",
    "inputs": [
     2,
     6
    ]
   },
   {
    "op": "and",
    "inputs": [
     3,
     7
    ]
   },
   {
    "op": "or",
    "inputs": [
     8,
     9
    ]
   },
   {
    "op": "or",
    "inputs": [
     11,
     10
    ]
   },
   {
    "op": "not",
    "inputs": [
     12
    ]
   }
  ],
  "output": 13
 },
 "six_gate_check": "pass",
 "sanity": {
  "found_at_4": true,
  "absent_at_3": true,
  "found_circuit": {
   "gates": [
    {
     "op": "and",
     "inputs": [
      1,
      5
     ]
    },
    {
     "op": "and",
     "inputs": [
      2,
      6
     ]
    },
    {
     "op": "or",
     "inputs": [
      8,
      9
     ]
    },
    {
     "op": "not",
     "inputs": [
      10
     ]
    }
   ],
   "output": 11
  }
 },
 "counts": {
  "unit": "DFS states (distinct-table gate prefixes visited) per gate bound G",
  "by_gate_count": {
   "0": 1,
   "1": 1,
   "2": 54,
   "3": 3194,
   "4": 210630,
   "5": 15441086
  }
 },
 "seconds": 1.25,
 "coverage": "Each wire is its 16-bit table on the 16 oneEach inputs (cell 4u+v); wires 0-3 are x0..x3, 4-7 are y0..y3. Under the definitions a gate reading index i sees wire i if i < current length, else false, so every index is either an existing wire or the constant-0 table (one class, index 99). With FanInTwo, ops are AND/OR/NOT with 0-2 inputs, repeats allowed: AND[]=1, OR[]=0, NOT[]=1, AND[a]=OR[a]=a, NOT[a]=NOT[a,b]=~a, AND[a,a]=a, AND[a,b]=a&b, OR[a,b]=a|b. So each gate's table is 1, 0, a, ~a, a&b or a|b over available tables incl. 0. The output (any natural) reads an existing wire or 0. The DFS keeps the set S of available tables and adds every new table one gate can make; a gate whose table is already in S is never needed (redirect its readers to the earlier equal wire and drop it, giving a smaller circuit with the same output), and smaller sizes are covered because every G from 0 to 5 is searched and the target is accepted if already in S. The last gate is checked directly (target = const, ~a, a&b, a|b). MOD/MAJ gates are excluded by FanInTwo. Cross-check: a raw enumerator over every literal gate list (op, 0-2 indices, nonexistent class) of up to 3 gates gave exactly the same reachable-table set as the search for all 65536 targets (1358 tables, 0 mismatches; 350 at 2 gates). Sanity and six-gate claims were re-evaluated with a literal Circuit.wires/eval evaluator.",
 "program": "/* Exhaustive search: does a FanInTwo circuit (AND/OR/NOT, <=2 inputs) of at most G gates\n   represent a 4x4 bipartite graph A (Represents: correct on the 16 oneEach inputs)?\n   Wires 0..3 = left one-hot x0..x3, wires 4..7 = right one-hot y0..y3.\n   Cell c = 4*u + v; a wire's table is a 16-bit mask over cells. */\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <time.h>\ntypedef unsigned short T;\nenum { AND = 0, OR = 1, NOT = 2 };\nstatic const char *OPN[] = {\"and\", \"or\", \"not\"};\ntypedef struct { int op, n, in[2]; } Gate;\n#define FAR 99 /* an index beyond every wire: reads false */\n\n/* Evaluator that follows Circuit.wires/eval literally on input oneEach u v. */\nstatic int eval_circuit(const Gate *g, int ng, int out, int u, int v) {\n  int w[64], len = 8;\n  for (int i = 0; i < 4; i++) { w[i] = (i == u); w[4 + i] = (i == v); }\n  for (int k = 0; k < ng; k++) {\n    int vals[2];\n    for (int j = 0; j < g[k].n; j++) { int i = g[k].in[j]; vals[j] = (i < len) ? w[i] : 0; }\n    int r;\n    if (g[k].op == AND) { r = 1; for (int j = 0; j < g[k].n; j++) r &= vals[j]; }\n    else if (g[k].op == OR) { r = 0; for (int j = 0; j < g[k].n; j++) r |= vals[j]; }\n    else r = g[k].n ? !vals[0] : 1;\n    w[len++] = r;\n  }\n  return out < len ? w[out] : 0;\n}\nstatic T circuit_table(const Gate *g, int ng, int out) {\n  T t = 0;\n  for (int u = 0; u < 4; u++) for (int v = 0; v < 4; v++)\n    if (eval_circuit(g, ng, out, u, v)) t |= (T)(1u << (4 * u + v));\n  return t;\n}\n\nstatic T target;\nstatic T S[16]; static int Sidx[16]; static int nS;  /* distinct tables available + wire index */\nstatic unsigned char inS[65536];\nstatic Gate stk[8]; static int nstk;\nstatic long long states[8];\nstatic int found; static Gate fg[8]; static int fng, fout;\n\nstatic void addS(T t, int idx) { S[nS] = t; Sidx[nS] = idx; nS++; inS[t] = 1; }\nstatic void popS(void) { nS--; inS[S[nS]] = 0; }\n\n/* can the target be the output with at most one more gate? record it if so */\nstatic int finish(int allow_gate) {\n  int ng = nstk;\n  for (int i = 0; i < nS; i++) if (S[i] == target) {\n    memcpy(fg, stk, sizeof(Gate) * ng); fng = ng; fout = Sidx[i]; return 1; }\n  if (!allow_gate) return 0;\n  int wi = 8 + ng; Gate G;\n  if (target == 0xFFFF) { G = (Gate){AND, 0, {0, 0}}; goto rec; }\n  for (int i = 0; i < nS; i++) if ((T)~S[i] == target) { G = (Gate){NOT, 1, {Sidx[i], 0}}; goto rec; }\n  for (int i = 0; i < nS; i++) {\n    T a = S[i];\n    if ((a & target) == target)\n      for (int j = i; j < nS; j++) if ((T)(a & S[j]) == target) { G = (Gate){AND, 2, {Sidx[i], Sidx[j]}}; goto rec; }\n    if ((a | target) == target)\n      for (int j = i; j < nS; j++) if ((T)(a | S[j]) == target) { G = (Gate){OR, 2, {Sidx[i], Sidx[j]}}; goto rec; }\n  }\n  return 0;\nrec:\n  memcpy(fg, stk, sizeof(Gate) * ng); fg[ng] = G; fng = ng + 1; fout = wi; return 1;\n}\n\n/* depth-first over sequences of gates whose tables are new; 'rem' gates remain */\nstatic int dfs(int rem) {\n  states[nstk]++;\n  if (rem <= 1) return finish(rem == 1);\n  if (finish(0)) return 1;\n  int wi = 8 + nstk;\n  /* candidate new tables (deduplicated) */\n  T cand[512]; Gate cg[512]; int nc = 0;\n  static unsigned char seen[8][65536];\n  unsigned char *sn = seen[nstk];\n#define PUT(t, G) do { T _t = (t); if (!inS[_t] && !sn[_t]) { sn[_t] = 1; cand[nc] = _t; cg[nc] = (G); nc++; } } while (0)\n  PUT(0xFFFF, ((Gate){AND, 0, {0, 0}}));\n  for (int i = 0; i < nS; i++) PUT((T)~S[i], ((Gate){NOT, 1, {Sidx[i], 0}}));\n  for (int i = 0; i < nS; i++) for (int j = i + 1; j < nS; j++) {\n    PUT((T)(S[i] & S[j]), ((Gate){AND, 2, {Sidx[i], Sidx[j]}}));\n    PUT((T)(S[i] | S[j]), ((Gate){OR, 2, {Sidx[i], Sidx[j]}}));\n  }\n  for (int c = 0; c < nc; c++) sn[cand[c]] = 0;\n  for (int c = 0; c < nc; c++) {\n    stk[nstk++] = cg[c]; addS(cand[c], wi);\n    int r = dfs(rem - 1);\n    popS(); nstk--;\n    if (r) return 1;\n  }\n  return 0;\n}\n\nstatic int search(T tgt, int G) {\n  target = tgt; nS = 0; nstk = 0; memset(inS, 0, sizeof inS); memset(states, 0, sizeof states);\n  Gate none[1];\n  for (int i = 0; i < 8; i++) addS(circuit_table(none, 0, i), i);\n  addS(0, FAR); /* nonexistent index reads false */\n  return dfs(G);\n}\nstatic void print_gates(const Gate *g, int ng, int out) {\n  printf(\"{\\\"gates\\\":[\");\n  for (int k = 0; k < ng; k++) {\n    printf(\"%s{\\\"op\\\":\\\"%s\\\",\\\"inputs\\\":[\", k ? \",\" : \"\", OPN[g[k].op]);\n    for (int j = 0; j < g[k].n; j++) printf(\"%s%d\", j ? \",\" : \"\", g[k].in[j]);\n    printf(\"]}\");\n  }\n  printf(\"],\\\"output\\\":%d}\", out);\n}\nstatic T table_of_A(unsigned n) { T t = 0; for (int c = 0; c < 16; c++) if ((n >> c) & 1) t |= 1u << c; return t; }\n\nint main(int argc, char **argv) {\n  unsigned N = argc > 1 ? (unsigned)strtoul(argv[1], 0, 10) : 31711;\n  int MAXG = argc > 2 ? atoi(argv[2]) : 5;\n  T A = table_of_A(N);\n  clock_t t0 = clock();\n  /* six-gate check */\n  Gate six[6] = {{AND,2,{1,5}},{AND,2,{2,6}},{AND,2,{3,7}},{OR,2,{8,9}},{OR,2,{11,10}},{NOT,1,{12,0}}};\n  int ok6 = 1;\n  for (int u = 0; u < 4; u++) for (int v = 0; v < 4; v++)\n    if (eval_circuit(six, 6, 13, u, v) != ((N >> (4 * u + v)) & 1)) ok6 = 0;\n  printf(\"six_gate_check %s\\n\", ok6 ? \"pass\" : \"fail\");\n  /* sanity: NOT((x1&y1)|(x2&y2)) */\n  Gate four[4] = {{AND,2,{1,5}},{AND,2,{2,6}},{OR,2,{8,9}},{NOT,1,{10,0}}};\n  T s = circuit_table(four, 4, 11);\n  int f3 = search(s, 3), f4 = search(s, 4);\n  printf(\"sanity table %u absent_at_3 %d found_at_4 %d \", s, !f3, f4);\n  if (f4) { print_gates(fg, fng, fout); printf(\" verify %d\", circuit_table(fg, fng, fout) == s); }\n  printf(\"\\n\");\n  /* main search */\n  int minf = -1;\n  for (int G = 0; G <= MAXG; G++) {\n    int f = search(A, G);\n    long long tot = 0; for (int i = 0; i < 8; i++) tot += states[i];\n    printf(\"G %d found %d states %lld\\n\", G, f, tot);\n    if (f) { minf = G; printf(\"circuit \"); print_gates(fg, fng, fout);\n      printf(\" verify %d\\n\", circuit_table(fg, fng, fout) == A); break; }\n  }\n  printf(\"min_gates_found %d\\nseconds %.2f\\n\", minf, (double)(clock() - t0) / CLOCKS_PER_SEC);\n  return 0;\n}\n",
 "program_language": "C (C99)",
 "program_sha256": "cd6c679be87103cb9aaa34b802275efe1cbdcefaec6538aaa12d78812784e450",
 "how_to_run": "Save program as enum.c; gcc -O2 -o enum enum.c && ./enum [N=31711] [maxG=5]. Prints six_gate_check, sanity, per-G found/states, min_gates_found (-1 = none).",
 "pr_open": 0,
 "held_now": false
}