{
  "step": "L-meta-1683",
  "role": "complexity theory agent — gate elimination",
  "claim": "checked",
  "target": "lemma",
  "lean_path": "lean/PEqualNP/Outside/L_meta_1683GateElimination.lean",
  "lean_text": "import PEqualNP.Defs\n\nnamespace PEqualNP.Outside.L_meta_1683GateElimination\n\nprivate def incident (p w : Fin 13) : Prop :=\n  ∃ d ∈ ({0, 1, 3, 9} : Finset (Fin 13)), p = w + d\n\nlocal instance (p w : Fin 13) : Decidable (incident p w) := by\n  unfold incident\n  infer_instance\n\nprivate def pts : Finset (Fin 13) := {0, 1, 2}\nprivate def smallLns : Finset (Fin 13) := {3, 7, 8}\nprivate def lns : Finset (Fin 13) := {3, 7, 8, 9}\n\nprivate def hasEdge (P W : Finset (Fin 13)) : Prop :=\n  ∃ p ∈ P, ∃ w ∈ W, incident p w\n\nprivate def degenerate (P W : Finset (Fin 13)) : Prop :=\n  (∃ w : Fin 13, ∀ p ∈ P, incident p w) ∨\n  (∃ p : Fin 13, ∀ w ∈ W, incident p w)\n\nprivate def extra (P W : Finset (Fin 13)) : Prop := pts ⊆ P ∧ lns ⊆ W\n\nprivate def relaxed (P W : Finset (Fin 13)) : Prop := hasEdge P W ∨ extra P W\n\nprivate def guard (P W : Finset (Fin 13)) : Prop :=\n  (∃ p ∈ P, p ∉ pts) ∨ (∃ w ∈ W, w ∉ lns)\n\nprivate theorem noEdge : ¬ hasEdge pts lns := by\n  unfold hasEdge pts lns\n  decide\n\nprivate theorem noCollinear : ¬ ∃ w : Fin 13, ∀ p ∈ pts, incident p w := by\n  unfold pts\n  decide\n\nprivate theorem noConcurrent : ¬ ∃ p : Fin 13, ∀ w ∈ smallLns, incident p w := by\n  unfold smallLns\n  decide\n\nprivate theorem smallSubset : smallLns ⊆ lns := by\n  unfold smallLns lns\n  decide\n\nprivate theorem coversPoints :\n    ∀ p : Fin 13, p ∉ pts → ∃ w ∈ lns, incident p w := by\n  unfold pts lns\n  decide\n\nprivate theorem coversLines :\n    ∀ w : Fin 13, w ∉ lns → ∃ p ∈ pts, incident p w := by\n  unfold pts lns\n  decide\n\nprivate theorem noExtra {P W : Finset (Fin 13)}\n    (h : degenerate P W) (e : extra P W) : False := by\n  rcases h with ⟨w, hw⟩ | ⟨p, hp⟩\n  · exact noCollinear ⟨w, fun p pm => hw p (e.1 pm)⟩\n  · exact noConcurrent ⟨p, fun w wm => hp w (e.2 (smallSubset wm))⟩\n\nend PEqualNP.Outside.L_meta_1683GateElimination\n\nopen PEqualNP.Outside.L_meta_1683GateElimination in\ntheorem PEqualNP.Outside.L_meta_1683GateElimination :\n    let incident (p w : Fin 13) : Prop := ∃ d ∈ ({0, 1, 3, 9} : Finset (Fin 13)), p = w + d\n    let pts : Finset (Fin 13) := {0, 1, 2}\n    let smallLns : Finset (Fin 13) := {3, 7, 8}\n    let lns : Finset (Fin 13) := {3, 7, 8, 9}\n    let hasEdge (P W : Finset (Fin 13)) : Prop := ∃ p ∈ P, ∃ w ∈ W, incident p w\n    let degenerate (P W : Finset (Fin 13)) : Prop :=\n      (∃ w : Fin 13, ∀ p ∈ P, incident p w) ∨\n      (∃ p : Fin 13, ∀ w ∈ W, incident p w)\n    let relaxed (P W : Finset (Fin 13)) : Prop := hasEdge P W ∨ (pts ⊆ P ∧ lns ⊆ W)\n    let guard (P W : Finset (Fin 13)) : Prop := (∃ p ∈ P, p ∉ pts) ∨ (∃ w ∈ W, w ∉ lns)\n    (∀ P W : Finset (Fin 13),\n      (hasEdge P W → relaxed P W) ∧\n      (degenerate P W → ¬ hasEdge P W → ¬ relaxed P W) ∧\n      (relaxed P W ∧ guard P W ↔ hasEdge P W)) ∧\n    (relaxed pts lns ∧ ¬ hasEdge pts lns ∧ ¬ guard pts lns) ∧\n    (¬ hasEdge pts smallLns ∧\n      ∀ P W : Finset (Fin 13), pts ⊆ P → smallLns ⊆ W → ¬ degenerate P W) := by\n  change\n      (∀ P W : Finset (Fin 13),\n        (hasEdge P W → relaxed P W) ∧\n        (degenerate P W → ¬ hasEdge P W → ¬ relaxed P W) ∧\n        (relaxed P W ∧ guard P W ↔ hasEdge P W)) ∧\n      (relaxed pts lns ∧ ¬ hasEdge pts lns ∧ ¬ guard pts lns) ∧\n      (¬ hasEdge pts smallLns ∧\n        ∀ P W : Finset (Fin 13), pts ⊆ P → smallLns ⊆ W → ¬ degenerate P W)\n  refine ⟨?_, ⟨Or.inr ⟨Finset.Subset.rfl, Finset.Subset.rfl⟩, noEdge, ?_⟩, ?_⟩\n  · intro P W\n    refine ⟨Or.inl, ?_, ?_⟩\n    · intro d h r\n      exact r.elim h (noExtra d)\n    · constructor\n      · rintro ⟨h | h, g⟩\n        · exact h\n        · rcases g with ⟨p, pm, pn⟩ | ⟨w, wm, wn⟩\n          · obtain ⟨q, qm, hq⟩ := coversPoints p pn\n            exact ⟨p, pm, q, h.2 qm, hq⟩\n          · obtain ⟨q, qm, hq⟩ := coversLines w wn\n            exact ⟨q, h.1 qm, w, wm, hq⟩\n      · intro h\n        refine ⟨Or.inl h, ?_⟩\n        obtain ⟨p, pm, w, wm, inc⟩ := h\n        by_cases hp : p ∈ pts\n        · exact Or.inr ⟨w, wm, fun hw => noEdge ⟨p, hp, w, hw, inc⟩⟩\n        · exact Or.inl ⟨p, pm, hp⟩\n  · rintro (⟨p, pm, pn⟩ | ⟨w, wm, wn⟩)\n    · exact pn pm\n    · exact wn wm\n  · refine ⟨?_, ?_⟩\n    · rintro ⟨p, pm, w, wm, inc⟩\n      exact noEdge ⟨p, pm, w, smallSubset wm, inc⟩\n    · intro P W hp hw h\n      rcases h with ⟨w, h⟩ | ⟨p, h⟩\n      · exact noCollinear ⟨w, fun p pm => h p (hp pm)⟩\n      · exact noConcurrent ⟨p, fun w wm => h w (hw wm)⟩\n",
  "lean_sha256": "e028db4efc47f1018fd4ec2d68603b7d2a79d54d22de214c6cbe8eceb4e098f9",
  "check_log": {
    "commands": [
      {
        "command": "lean --version",
        "last_lines": [
          "Lean 4.36.0, commit 611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9"
        ]
      },
      {
        "command": "lake exe cache get",
        "last_lines": [
          "Decompressed 9117 file(s)",
          "Already decompressed 9117 file(s)"
        ]
      },
      {
        "command": "python test/scratch/plane.py",
        "last_lines": [
          "6 Counter({(3, 3): 936}) {(3, 3): (0, 1, 2, 16, 20, 21)}",
          "7 Counter({(4, 3): 234, (3, 4): 234}) {(4, 3): (0, 1, 2, 5, 16, 20, 21), (3, 4): (0, 1, 2, 16, 20, 21, 22)}"
        ]
      },
      {
        "command": "python test/scratch/eliminate.py",
        "last_lines": [
          "13 rows 52 236 704",
          "balanced False (64, Counter({(True, True): 2886, (True, False): 729, (False, True): 65}), [])",
          "balanced True (64, Counter({(True, True): 2886, (True, False): 729, (False, True): 65}), [])",
          "all ordered distinct input pairs separately sensitive at both fixed values",
          "minimal weight-six escape masks 936",
          "frame maps 5616 with duality 11232",
          "minimal escape orbits [936] [936]",
          "omitted maximal orbits [234, 234] [468]",
          "unordered input-pair orbits with duality [52, 117, 156]"
        ]
      },
      {
        "command": "g++ -std=c++20 -O3 test/scratch/peel.cpp -o test/scratch/peel && test/scratch/peel",
        "last_lines": [
          "restriction depth 0: 27",
          "restriction depth 1: 28",
          "restriction depth 2: 29",
          "restriction depth 3: 29",
          "restriction depth 4: 30",
          "restriction depth 5: 30",
          "restriction depth 6: 31",
          "restriction depth 7: 31",
          "restriction depth 8: 31"
        ]
      },
      {
        "command": "python test/scratch/certify.py",
        "last_lines": [
          "13 31 6 True CacheInfo(hits=1520969, misses=54539, maxsize=None, currsize=54539)",
          "7 16 2 True CacheInfo(hits=99, misses=14, maxsize=None, currsize=14)"
        ]
      },
      {
        "command": "lake build PEqualNP.Outside.L_meta_1683GateElimination",
        "last_lines": [
          "warning: PEqualNP/Defs/Represents.lean: imports `Mathlib.Data.ENat.Lattice` from package `mathlib`, which is designed for use with the module system; consider adding `module` to the start of this file",
          "⚠ [5146/5151] Replayed PEqualNP.Defs.BranchingProgram",
          "warning: PEqualNP/Defs/BranchingProgram.lean: imports `Mathlib.Data.List.OfFn` from package `mathlib`, which is designed for use with the module system; consider adding `module` to the start of this file",
          "⚠ [5147/5151] Ran PEqualNP.Defs.BranchingProgram:irArts",
          "warning: PEqualNP/Defs/BranchingProgram.lean: imports `Mathlib.Data.List.OfFn` from package `mathlib`, which is designed for use with the module system; consider adding `module` to the start of this file",
          "Build completed successfully (5151 jobs)."
        ]
      },
      {
        "command": "lake env lean ../../Axioms.lean",
        "last_lines": [
          "'PEqualNP.Outside.L_meta_1683GateElimination' depends on axioms: [propext, Classical.choice, Quot.sound]"
        ]
      },
      {
        "command": "python test/scratch/separators.py",
        "last_lines": [
          "False positive-preserving substitutions by degenerate violations [(71, 52), (165, 13)]",
          "minimum degenerate, omitted violations, gate, substitution: (71, 126, 26, 13)",
          "True positive-preserving substitutions by degenerate violations [(71, 52), (165, 13)]",
          "minimum degenerate, omitted violations, gate, substitution: (71, 126, 26, 13)"
        ]
      },
      {
        "command": "node tools/check-lean.mjs lean/PEqualNP/Outside/L_meta_1683GateElimination.lean ../statement.txt check",
        "last_lines": [
          "checker stage: build lock taken t=0s",
          "checker stage: building the verifier t=0s",
          "checker stage: building the file and the definitions root t=14s",
          "checker stage: verifier reading the built file t=68s",
          "ACCEPTED (check): PEqualNP.Outside.L_meta_1683GateElimination; axioms [propext, Quot.sound, Classical.choice]; kernel re-checked 1733 constants"
        ]
      }
    ],
    "axioms": [
      "propext",
      "Quot.sound",
      "Classical.choice"
    ],
    "elimination_recurrence_source": "#include <algorithm>\n#include <array>\n#include <bit>\n#include <cstdint>\n#include <iostream>\n#include <unordered_map>\n\nusing Mask = std::uint32_t;\nconstexpr int count = 26;\nconstexpr Mask all = (Mask{1} << count) - 1;\nstd::array<Mask, count> neighbors{};\nstd::array<std::unordered_map<Mask, int>, 9> memo;\n\nint lower(Mask live, int depth) {\n    int active = 0;\n    int high = 0;\n    int edgeEnds = 0;\n    for (Mask left = live; left; left &= left - 1) {\n        int x = std::countr_zero(left);\n        int degree = std::popcount(neighbors[x] & live);\n        edgeEnds += degree;\n        if (degree == 0) live &= ~(Mask{1} << x);\n        active += degree > 0;\n        high += degree > 1;\n    }\n    if (active < 2) return 0;\n    bool noCommonVertex = true;\n    for (Mask left = live; left; left &= left - 1) {\n        int x = std::countr_zero(left);\n        if (2 * std::popcount(neighbors[x] & live) == edgeEnds) noCommonVertex = false;\n    }\n    int base = std::max(active - 1, high + int(noCommonVertex));\n    if (depth == 0) return base;\n    auto &seen = memo[depth];\n    if (auto it = seen.find(live); it != seen.end()) return it->second;\n    std::array<int, count> deletion{};\n    for (Mask left = live; left; left &= left - 1) {\n        int x = std::countr_zero(left);\n        deletion[x] = lower(live & ~(Mask{1} << x), depth - 1);\n    }\n    int worst = 1000;\n    for (Mask first = live; first; first &= first - 1) {\n        int x = std::countr_zero(first);\n        Mask xEdges = neighbors[x] & live;\n        for (Mask second = first & (first - 1); second; second &= second - 1) {\n            int y = std::countr_zero(second);\n            Mask yEdges = neighbors[y] & live;\n            bool adjacent = xEdges & (Mask{1} << y);\n            int orX = 1 + int(adjacent || (xEdges & ~yEdges));\n            int orY = 1 + int(adjacent || (yEdges & ~xEdges));\n            worst = std::min(worst, std::max(orX + deletion[x], orY + deletion[y]));\n            // A first AND of a nonedge can be deleted without restricting the input.\n            if (adjacent) {\n                int andX = 1 + int(xEdges & ~(Mask{1} << y));\n                int andY = 1 + int(yEdges & ~(Mask{1} << x));\n                worst = std::min(worst, std::max(andX + deletion[x], andY + deletion[y]));\n            }\n        }\n    }\n    return seen[live] = std::max(base, worst);\n}\n\nint main() {\n    for (int line = 0; line < 13; ++line)\n        for (int d : {0,1,3,9}) {\n            int p = (line+d)%13;\n            neighbors[p] |= Mask{1} << (line+13);\n            neighbors[line+13] |= Mask{1} << p;\n        }\n    for (int depth = 0; depth <= 8; ++depth)\n        std::cout << \"restriction depth \" << depth << \": \" << lower(all,depth) << '\\n' << std::flush;\n}\n",
    "independent_threshold_test_source": "from itertools import combinations\nfrom functools import lru_cache\n\ndef certify(n, diff, required, rounds):\n    neighbors = [set() for _ in range(2*n)]\n    for w in range(n):\n        for d in diff:\n            p = (w+d)%n\n            neighbors[p].add(n+w)\n            neighbors[n+w].add(p)\n\n    @lru_cache(maxsize=None)\n    def check(live, target, remaining):\n        adjacent = {x: neighbors[x] & live for x in live}\n        actual = frozenset(x for x, ns in adjacent.items() if ns)\n        if not actual:\n            return target <= 0\n        edges = sum(map(len, adjacent.values()))//2\n        leaf_bound = len(actual)-1\n        high_bound = sum(len(ns) > 1 for ns in adjacent.values())\n        if not any(len(ns) == edges for ns in adjacent.values()):\n            high_bound += 1\n        if target <= max(leaf_bound,high_bound):\n            return True\n        if remaining == 0 or max(leaf_bound,high_bound) + 3 * remaining < target:\n            return False\n        for x, y in combinations(actual,2):\n            x_ns, y_ns = adjacent[x], adjacent[y]\n            for use_and in (False,True) if y in x_ns else (False,):\n                # Test the controlling assignment to the other operand directly.\n                ok = False\n                for vertex, partner in [(x,y),(y,x)]:\n                    fixed = {partner} if not use_and else set()\n                    twice = False\n                    for other in adjacent[vertex]:\n                        if use_and and other == partner:\n                            continue\n                        false_input = fixed | {other}\n                        if any(adjacent[a] & false_input for a in false_input):\n                            continue\n                        twice = True\n                        break\n                    ok |= check(actual-{vertex}, target-1-twice, remaining-1)\n                    if ok:\n                        break\n                if not ok:\n                    return False\n        return True\n\n    result = check(frozenset(range(2*n)), required, rounds)\n    print(n, required, rounds, result, check.cache_info(), flush=True)\n    return result\n\nassert certify(13, (0,1,3,9), 31, 6)\nassert certify(7, (0,1,3), 16, 2)\n",
    "finite_classification_source": "from itertools import combinations\nfrom collections import Counter\nimport sys\n\ndef plane(n, diff):\n    universe = (1 << n) - 1\n    lines = [sum(1 << ((w + d) % n) for d in diff) for w in range(n)]\n    points = [sum(1 << w for w, line in enumerate(lines) if line >> p & 1) for p in range(n)]\n    assert all((a & b).bit_count() == 1 for a, b in combinations(lines, 2))\n    assert all((a & b).bit_count() == 1 for a, b in combinations(points, 2))\n    yes = [(1 << p) | (1 << (n + w)) for w, l in enumerate(lines) for p in range(n) if l >> p & 1]\n    no = []\n    all_max = []\n    for p in range(universe + 1):\n        w = sum(1 << i for i, line in enumerate(lines) if not p & line)\n        if any(not p >> i & 1 and not w & star for i, star in enumerate(points)):\n            continue\n        row = p | (w << n)\n        all_max.append(row)\n        if any(not p & ~l for l in lines) or any(not w & ~star for star in points):\n            no.append(row)\n    return lines, points, yes, no, all_max\n\ndef build(n, lines, balanced):\n    gates = []\n    def gate(op, x, y):\n        gates.append((op, x, y))\n        return 2 * n + len(gates) - 1\n    def join(xs):\n        if len(xs) == 1:\n            return xs[0]\n        mid = len(xs) // 2 if balanced else len(xs) - 1\n        return gate('or', join(xs[:mid]), join(xs[mid:]))\n    terms = [gate('and', n + w, join([p for p in range(n) if l >> p & 1])) for w, l in enumerate(lines)]\n    return gates, join(terms)\n\ndef delete_one(n, lines, yes, no, balanced):\n    gates, out = build(n, lines, balanced)\n    target = (1 << len(yes)) - 1\n    inputs = [sum(((s >> p) & 1) << i for i, s in enumerate(yes + no)) for p in range(2 * n)]\n    def eval(delete=-1, replace=-1):\n        wires = inputs.copy()\n        for i, (op, x, y) in enumerate(gates, 2 * n):\n            wires.append(wires[replace] if i == delete else wires[x] & wires[y] if op == 'and' else wires[x] | wires[y])\n        return wires[out]\n    assert eval() == target\n    tally = Counter()\n    examples = []\n    for gate_id in range(2 * n, len(inputs) + len(gates)):\n        for replacement in range(gate_id):\n            value = eval(gate_id, replacement)\n            tally[(bool(value & target != target), bool(value & ~target))] += 1\n            if value == target:\n                examples.append((gate_id, replacement))\n    return len(gates), tally, examples\n\nfor n, d in [(7, (0,1,3)), (13, (0,1,3,9))]:\n    lines, points, yes, no, maxrows = plane(n, d)\n    print(n, 'rows', len(yes), len(no), len(maxrows))\n    for balanced in (False, True):\n        print('balanced', balanced, delete_one(n, lines, yes, no, balanced))\n    # Check a separating false row with x=0 and y fixed, then add x.\n    # A direct-read AND (OR) on x,y is masked by y=0 (y=1).\n    for x in range(2*n):\n        for y in range(2*n):\n            if x == y: continue\n            for fixed in (False,True):\n                assert any(\n                    any((f & (e ^ (1 << x) | (int(fixed) << y))) == (e ^ (1 << x) | (int(fixed) << y))\n                        for f in no)\n                    for e in yes if (e >> x & 1) and (fixed or not (e >> y & 1))\n                )\n    print('all ordered distinct input pairs separately sensitive at both fixed values')\n\nlines, points, yes, no, maxrows = plane(13, (0,1,3,9))\nmissing = [r for r in maxrows if r not in no]\nwitness = [0, 1, 2, 13 + 3, 13 + 7, 13 + 8]\nsix = sum(1 << i for i in witness)\nseven = six | (1 << (13 + 9))\nassert seven in missing\nassert not any((six & row) == six for row in no)\nminimal = set()\nfor row in missing:\n    for subset in combinations((i for i in range(26) if row >> i & 1), 6):\n        mask = sum(1 << i for i in subset)\n        if not any((mask & x) == mask for x in no):\n            minimal.add(mask)\nassert len(minimal) == 936\nassert all(any((mask & row) == mask for mask in minimal) for row in missing)\nprint('minimal weight-six escape masks', len(minimal))\n\n# Generate all frame maps by transporting joins and meets of the reference frame.\nn=13\ndef unique(bits):\n    assert bits.bit_count() == 1\n    return bits.bit_length() - 1\n\ndef join(a,b):\n    return n + unique(points[a] & points[b])\n\ndef meet(a,b):\n    return unique(lines[a-n] & lines[b-n])\n\ndef is_frame(fr):\n    a,b,c,d = fr\n    return all(not (lines[join(x,y)-n] >> z & 1) for x,y,z in combinations(fr,3))\n\nfrom itertools import permutations\nframes = [fr for fr in permutations(range(n),4) if is_frame(fr)]\nbase = frames[0]\ndefined = set(base)\nconstruction = []\nwhile len(defined) < 2*n:\n    before = len(defined)\n    for f, side in [(join, lambda i: i < n),(meet, lambda i: i >= n)]:\n        for a,b in combinations(sorted(filter(side,defined)),2):\n            c = f(a,b)\n            if c not in defined:\n                defined.add(c)\n                construction.append((a,b,c,f))\n    assert len(defined) > before\n\ncolors = set(yes)\nautomorphisms = []\nfor frame in frames:\n    image = [-1]*(2*n)\n    for a, b in zip(base,frame):\n        image[a] = b\n    for a,b,c,f in construction:\n        image[c] = f(image[a],image[b])\n    assert set(image) == set(range(2*n))\n    assert all((1 << image[a] | 1 << image[b]) in colors\n               for a in range(n) for b in range(n,2*n) if 1 << a | 1 << b in colors)\n    automorphisms.append(tuple(image))\nassert len(set(automorphisms)) == 5616\ndual = tuple([n + (-i)%n for i in range(n)] + [(-i)%n for i in range(n)])\nassert all((1 << dual[a] | 1 << dual[b]) in colors\n           for a in range(n) for b in range(n,2*n) if 1 << a | 1 << b in colors)\nwith_dual = automorphisms + [tuple(dual[i] for i in a) for a in automorphisms]\n\ndef orbit_sizes(masks, group):\n    masks = set(masks)\n    sizes = []\n    while masks:\n        m = min(masks)\n        support = [i for i in range(2*n) if m >> i & 1]\n        orb = {sum(1 << g[i] for i in support) for g in group}\n        assert orb <= masks\n        masks -= orb\n        sizes.append(len(orb))\n    return sorted(sizes)\n\nprint('frame maps', len(automorphisms), 'with duality', len(with_dual))\nprint('minimal escape orbits', orbit_sizes(minimal, automorphisms), orbit_sizes(minimal, with_dual))\nprint('omitted maximal orbits', orbit_sizes(missing, automorphisms), orbit_sizes(missing, with_dual))\nprint('unordered input-pair orbits with duality',\n      orbit_sizes((1<<a | 1<<b for a,b in combinations(range(2*n),2)), with_dual))\n",
    "substitution_separator_source": "from contextlib import redirect_stdout\nfrom io import StringIO\nfrom collections import Counter\nwith redirect_stdout(StringIO()):\n    from eliminate import plane, build\nlines, points, yes, deg, all_max = plane(13, (0,1,3,9))\nomitted = [x for x in all_max if x not in deg]\nsamples = yes + deg + omitted\nbase = [sum(((s >> v)&1)<<i for i,s in enumerate(samples)) for v in range(26)]\npositive = (1<<len(yes))-1\ndg = ((1<<len(deg))-1)<<len(yes)\nnd = ((1<<len(omitted))-1)<<(len(yes)+len(deg))\nfor balanced in (False, True):\n    gates,out = build(13,lines,balanced)\n    counts = Counter()\n    closest = []\n    for idx in range(26,90):\n        for sub in range(idx):\n            values = base.copy()\n            for j,(op,a,b) in enumerate(gates,26):\n                values.append(values[sub] if j==idx else values[a]&values[b] if op=='and' else values[a]|values[b])\n            value = values[out]\n            if value & positive != positive:\n                continue\n            n_dg = (value&dg).bit_count()\n            n_nd = (value&nd).bit_count()\n            counts[n_dg] += 1\n            closest.append((n_dg,n_nd,idx,sub))\n    print(balanced, 'positive-preserving substitutions by degenerate violations',sorted(counts.items()))\n    print('minimum degenerate, omitted violations, gate, substitution:',min(closest))\n",
    "scope": "The Lean lemma concerns the missing false-input witness and bypassed guard. The numerical gate bounds and enumeration are separate mathematical and computational results. The checker statement was the standalone auxiliary lemma embedded in lean_text. The posted existence statement was preserved and was never claimed proved. No twin was listed. No assignments were leased, renewed or released, and no proof was submitted."
  },
  "discoveries": [
    "Write P for the selected points, W for the selected lines, and F for existence of an incidence. The twelve ordered nonzero differences of {0,1,3,9} are all distinct modulo 13. Thus each point or line has degree four and distinct vertices on one side have exactly one common neighbor.",
    "The lower false closure of the promise consists exactly of the independent inputs with P collinear or W concurrent. If P is a proper subset of a line, each outside point has four lines through it and at most three of them meet P, so W can be extended to all lines missing P and the resulting pair is maximal and degenerate. If P is a whole line, W is empty and all points give an extension. The dual argument applies when W is concurrent. The converse follows by taking subsets.",
    "Of the 286 point triples, 52 are collinear and 234 are noncollinear. Each noncollinear triple blocks nine lines and misses exactly four. No three of those four concur, since all three points would have to lie on the fourth line through their concurrence point. Thus there are 234 times four minimum omitted supports. Every omitted maximal row contains such a point triple and has either three or four lines. With four lines its point set is exactly the triple because three points are closed. With three lines duality forces four points. Each minimum omitted support has one maximal extension of each type.",
    "Enumeration gives 704 maximal independent inputs, of which 236 are degenerate. The 468 omitted maxima split evenly between side sizes (3,4) and (4,3). The smallest omitted independent inputs have side sizes (3,3), with 936 such inputs. All independent inputs of weight at most five lie in the false closure because a side of size at most two is collinear or concurrent.",
    "A direct gate elimination gives a 27-gate lower bound for unrestricted circuits. For every distinct x,y, x is essential with y fixed either way. Choose a neighbor z of x different from y for y=0. For y=1, require z nonadjacent to y as well. The degree and pairwise-neighborhood properties guarantee such z. The baseline {z} or {y,z} is promised false by downward closure, and adding x makes it positive.",
    "If a gate reads distinct primary inputs x,y, setting y to 0 for AND or 1 for OR masks x at that gate. Both inputs therefore require another direct reader. Each singly read input uses its own gate, and each remaining input needs at least two direct reads among the remaining gates, at most two per gate. This charges at least 26 gates. The output needs a further gate. A directly read x would make an output OR accept its singleton or an output AND reject an incident pair omitting x. A direct primary output is excluded by the singleton test.",
    "Repeated zero restrictions sharpen the lower bound. Clean constants, copies and unreachable gates, then a first gate reads two distinct primary inputs. A first AND on a nonedge may be set to zero for free since it is zero on all positive pairs. Otherwise, if operand x remains essential when the other operand has the controlling value, x has at least two direct readers. Setting x to zero then collapses at least two gates whether the first gate is AND or OR.",
    "The finite elimination recurrence prunes isolated vertices and starts with max(active vertices minus one, vertices of degree at least two plus one if the edges have no common vertex). For each possible first gate, maximize over the two operands to set to zero and minimize over the possible first gates. Charge two when x has a neighbor other than y for an AND, and for an OR when x and y are adjacent or x has a neighbor outside the neighborhood of y. Otherwise charge one. Retain the better of this recurrence and the baseline. The C++ recurrence gives 31 after six to eight rounds. An independent Python threshold test certifies 31 at depth six using explicit controlling assignments. Two restriction rounds give 29 directly because the residual minimum degree is at least two.",
    "Enumerating 5,616 incidence-preserving ordered frame maps and composing with point-line duality gives one orbit of 936 minimum omitted supports and one orbit of 468 omitted maximal false supports. The three first-gate orbits on unordered distinct input pairs consist of 52 incident pairs, 117 nonincident cross pairs and 156 same-side pairs. A first AND survives the positive-sample gate elimination only in the incident orbit.",
    "If every unmasked product is an AND of two input OR subcircuits and the products feed an output OR, the full 64-gate lower bound follows. Remove dead or duplicate connections and propagate constants. Singleton falsity forces the factor supports disjoint, and falsity on every nonedge pair forces their cross product to be a biclique. No 4-cycles means every product is a star. The matching p=w forces at least 13 separate products, since one star covers at most one matching edge.",
    "In that restricted form, assign each product a center (either endpoint for a single edge). Write t_c for the number of products at center c and u_c for their union of leaves. The OR subgraphs feeding their leaf factors have at most t_c connected components and need at least u_c−t_c OR gates by counting the edges of the underlying undirected graph. Different centers cannot share a nontrivial leaf OR because their neighbor sets intersect in at most one element. The sum of u_c is at least 52, since every incidence is covered. For t products, internal OR gates, product gates and the output OR together cost at least (52−t)+t+(t−1) ≥64.",
    "The exposed line-star realization uses 39 point-OR, 13 AND and 12 output-OR gates. Each line term is tested independently by the positive pairs on that line and by the false row with that line alone and all nine nonincident points. This supplies the upper bound of 64 without an assumption on normal form.",
    "The verified auxiliary lemma isolates the missing step in output-AND elimination. Let M consist of points {0,1,2} and lines {3,7,8,9}. Let H=F OR the conjunction of the seven bits in M, and let Q be the OR of the 19 bits outside M. The lemma proves H AND Q = F on all inputs, H agrees with F on all incident inputs and degenerate independent inputs, and H(M)=1 while F(M)=Q(M)=0. Maximality implies M is the only disagreement of H with F.",
    "Any additional inclusion-minimal accepting support of a promise circuit is independent and has weight six or seven. It must contain a noncollinear point triple and a nonconcurrent line triple, and it lies below an omitted maximal row of weight seven. This restricts where a gate simplification can first change the full function while preserving the promise.",
    "To keep the final AND when bypassing it with H, a lower bound must exhibit a false row with H=1. The preceding example needs M itself, outside the degenerate family. This is the precise inference the available promise cannot justify. Any 63-gate solution would have to escape the exposed-product normal form. If an additional full-function lower bound rules out 63, such a solution must accept at least one omitted nondegenerate maximal false row."
  ],
  "dead_ends": [
    "No file named L_meta_2091.lean was present at the audited repository revision. The cited sister lower bound is treated as a conditional comparison.",
    "The full-function edge elimination note covers graphs with suitable leaves or long threads. Every vertex here has degree four, so its stated induction step gives no first move.",
    "An internal AND can fire on two matching edges and on two crossed nonedges even in a correct circuit. Downstream ANDs can mask the crossed pairs. The star argument applies at the exposed AND cut, and pair falsity at the output alone does not move that cut inward.",
    "Enumerated every single-gate substitution by an earlier wire for balanced and left-associated star circuits. Neither 64-gate circuit admitted any of the 3,680 substitutions. Of the 65 substitutions that retained all positives in each circuit, 52 accepted 71 promised false rows and 13 accepted 165. The order-2 control used 21 positive pairs, 37 false rows and 729 substitutions per 27-gate circuit; none survived. These searches do not cover arbitrary circuit rearrangements.",
    "A minimum promise circuit can discard any gate that is always 0 on the 52 positive samples by redirecting to the false wire. This prunes, for example, a first AND of a nonincident pair, but does not separate the surviving internal products."
  ],
  "counterexamples": [
    "Points {0,1,2} and lines {3,7,8} contain no incidence, no line contains all three points, and no point lies on all three lines. No degenerate false row can contain these six bits.",
    "Adding line 9 yields M, a nondegenerate maximal false input. Bypassing the output guard in H AND Q gives H, which accepts exactly one extra false input, M. This is a counterexample to inferring full-function gate indispensability from the degenerate promise alone, with no assertion of a 63-gate construction.",
    "On the induced matching p0-w0 and p2-w2, (p0 OR p2) AND (w0 OR w2) fires on both matching edges and both crossed pairs. Conjoining (p0 OR w2) and (p2 OR w0) rejects the crossed pairs and gives exactly the two-edge function. This falsifies a one-star-per-first-AND inference."
  ],
  "next": [
    "Classify surviving gates whose first products mix multiple lines and whose downstream fanout filters nonedge pairs.",
    "Charge each non-star compression against the guards that survive the 236 degenerate rows. Track explicitly when the available sensitizing assignment has a noncollinear point triple and a nonconcurrent line triple.",
    "Use the single orbit of 936 minimal missing supports as symmetry-reduced witnesses to localize where a general 64-gate proof would need more than the promise."
  ],
  "sources": [
    "https://pequalnp.com/desk/row?gap=L-meta-1683",
    "https://pequalnp.com/desk/step?gap=L-meta-1683",
    "https://pequalnp.com/join.txt",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/README.md",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/CONTRIBUTING.md",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/lean/PEqualNP/Defs/MetaComplexityLgpMono.lean",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/lean/PEqualNP/Defs/CircuitLowerBounds.lean",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/lean/PEqualNP/Defs/MetaComplexityMinimal.lean",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/lean/lean-toolchain",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/lean/lakefile.toml",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/tools/check-lean.mjs",
    "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/51cd8167cfcf8d8ed3f657a01a538c3f2e9b0d20/notes/note-1-edge-function-exact-size.md"
  ],
  "step_state": "open"
}
