{
  "summary": "MP05 proved in Lean that, at every gate budget, a circuit for the target exists iff one exists with sorted distinct earlier inputs at each binary AND/OR gate, a last-gate output, and correct values on 6 true and 15 false boundary assignments. Induction on the evaluator fold preserves coverage of each original wire by a retained wire or constant without increasing gate count. A separate 14-gate row-factor circuit and its distinct boundary signatures were kernel-checked. The build, axiom report and both guards passed. The official verifier exited 137 during supporting replay. The official verifier also exited 137 during the exact target comparison. The pinned leanchecker replay passed. Bounded gate deletion and rerouting found zero witnesses. The 13-gate bound remains unresolved.",
  "agentId": "MP05",
  "strategyId": "invariant-preservation",
  "status": "supporting-lemma",
  "target": {
    "id": "L-meta-17390",
    "file": "lean/PEqualNP/Outside/L_meta_17390.lean",
    "module": "PEqualNP.Outside.L_meta_17390",
    "publicKind": "helper",
    "checkerMode": "check",
    "kindNote": "The public record uses helper. check is the checker mode for a proof.",
    "capsuleSha256": "6063abcf25b0ece8209fd6a47d5d78a7df697fbdd937474081d3f19b54e10e53",
    "statementUtf8Sha256": "3a6b7a3a820272375169fb191a04fd1ac8594fdc1849ed746eaaf0eefe286e6a",
    "bytes": 286,
    "sources": [
      "https://api.imd.fun/artifacts/6063abcf25b0ece8209fd6a47d5d78a7df697fbdd937474081d3f19b54e10e53",
      "https://data.pequalnp.com/data/lemma/L-meta-17390.626422f1ae76.json"
    ]
  },
  "env": {
    "commit": "8dec1cacf8aab169f12858fff3a2e945fea7a880",
    "tree": "080acdc0fbdcfef492096d21ac1ac4f6a4b64515",
    "pins": {
      "lean": "leanprover/lean4:v4.36.0",
      "leanRuntimeCommit": "611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9",
      "leanAssetUrl": "https://github.com/leanprover/lean4/releases/download/v4.36.0/lean-4.36.0-linux.tar.zst",
      "leanAssetSha256": "2b7ab1ed8b92d2e6abfaf41344823b510064dbc9c0260cac73eb496ab2dea6eb",
      "repoArchiveUrl": "https://codeload.github.com/open-goat/pequalnp-proofs/tar.gz/8dec1cacf8aab169f12858fff3a2e945fea7a880",
      "repoArchiveSha256": "cd80eb8ab2449a0cccb22ebae597d1211ef508b48cf63a23c732c518a1aea3d9",
      "packages": {
        "mathlib": "fc4f59e577feb1a4956671bc04ac18aaaf8cd842",
        "plausible": "054b228ce0ac61d767c6e71ba73a24728f191b72",
        "LeanSearchClient": "4fb58e749ef3fc0395fe274f6cab70c2ea85f1c9",
        "importGraph": "8370c640afcd1cc3fb1cb9bf1560cc66eafee5e0",
        "proofwidgets": "2f0f3520daeac2d9310ff25b7a877a0e5cdaa203",
        "aesop": "66ff77cf0c4c898799e4b94d14db55f7a02d0c5a",
        "Qq": "ff055a2fcc835935e0ae607339b455a5f5896b4b",
        "batteries": "b4b25a3886a16daacaf6615c2eea7170a6e8f458",
        "Cli": "50810f72af7618bee62fe9800dc26e806c188703"
      },
      "trackedSourcesSha256": {
        "lean/lean-toolchain": "582a63f8f9c5128067b688778c1051cf1464c3ca9d57b9325025c051c29b774a",
        "lean/lakefile.toml": "ee756ab61cf24d2fd5f561d89080cf162e34f35b06d9b6101bc680ef1619a7bf",
        "lean/lake-manifest.json": "d0af863cde532caaef1b1bee0d63ec47100208e33e488309cb80abc88b8f1509",
        "lean/PEqualNP/Defs/CircuitLowerBounds.lean": "695e454d3e424e2cae4fa4677741681eac11de0462d0d9bc087a0e6a6ba03f69",
        "lean/PEqualNP/Defs/MetaComplexityLgpMono.lean": "dfecf7726cea5a2adbf2976c6e4aac2a4fe5c968713ba6ec84b267753b55c969",
        ".github/scripts/outside-guard.mjs": "738adeb889cb829a2dc359d970249e7723d5698d87ccd6819b2f82c6a83bf535",
        "tools/check-lean.mjs": "c8fc4b209e678f76adc3cf4e988be55675ef9384e44cd388203c95c6afb68846",
        "tools/check-lean-memory.mjs": "830f1cd590480fee8ee79157d1e3c3f275159e7d826d8bc726917cecebd42da8",
        "tools/bin/lake": "cb93d28f2d24e6fbff5fcd5bd408b54184119040b254a5e25c11cfb9e41a1cac",
        "tools/build.sh": "0ddbc90616593ec69d54a4154be17af1f79b876db03cb3f0f16f691e3ca693a3",
        "lean/CheckLemma.lean": "86997b026ef2b80d738df77f4c214166cf5b0b2ea8cc98d4bd3c8b5e420dbdd5"
      },
      "cacheDownloaderSha256": "83a56256434a3d3f6edbdad2cbdb1f23a44fe8fd52968d18ab57763fdc0afba0"
    },
    "clean-run source": "#!/bin/sh\nset -eu\nroot=$(CDPATH= cd -- \"$(dirname -- \"$0\")\" && pwd)\nmkdir -p \"$root/runtime-home\" \"$root/tmp\" \"$root/cache\" \"$root/queue\"\nexec env -i PATH=\"$root/runtime/bin:/usr/local/bin:/usr/bin:/bin\" \\\n  HOME=\"$root/runtime-home\" TMPDIR=\"$root/tmp\" MATHLIB_CACHE_DIR=\"$root/cache\" \\\n  GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null \\\n  PEQUALNP_REAL_LAKE=\"$root/runtime/bin/lake\" PEQUALNP_HOME=\"$root/queue\" \\\n  LEAN_NUM_THREADS=4 LC_ALL=C.UTF-8 \"$@\"\n",
    "network-run source": "#!/usr/bin/python3\nimport os, pathlib, sys\nroot=pathlib.Path(__file__).resolve().parent\nextra={key:os.environ[key] for key in ('http_proxy','https_proxy','all_proxy','no_proxy',\n    'HTTP_PROXY','HTTPS_PROXY','ALL_PROXY','NO_PROXY') if key in os.environ}\nextra.update(PATH=f'{root}/runtime/bin:/usr/local/bin:/usr/bin:/bin',\n    HOME=f'{root}/runtime-home', TMPDIR=f'{root}/tmp', MATHLIB_CACHE_DIR=f'{root}/cache',\n    GIT_CONFIG_NOSYSTEM='1', GIT_CONFIG_GLOBAL='/dev/null', LEAN_NUM_THREADS='4', LC_ALL='C.UTF-8')\nos.execvpe(sys.argv[1], sys.argv[1:], extra)\n",
    "pin-fetch source": "import concurrent.futures, json, os, pathlib, subprocess\nrepo=pathlib.Path('repo/lean')\ndef install(pin):\n    dst=repo / '.lake/packages' / pin['name']\n    dst.mkdir(exist_ok=True, parents=True)\n    def git(*args):\n        return subprocess.check_output(['git','-C',dst,*args],text=True).strip()\n    git('init','-q')\n    if not git('remote'):\n        git('remote','add','origin',pin['url'])\n    git('fetch','--depth=1','origin',pin['rev'])\n    git('checkout','--quiet','--detach','FETCH_HEAD')\n    head=git('rev-parse','HEAD')\n    assert head==pin['rev']\n    return pin['name'],head\nwith concurrent.futures.ThreadPoolExecutor(max_workers=9) as pool:\n    for name,head in pool.map(install,json.loads((repo/'lake-manifest.json').read_text())['packages']):\n        print(name,head,flush=True)\n",
    "axioms-check source": "import PEqualNP.Outside.L_meta_17390\n#print axioms PEqualNP.Outside.L_meta_17390\n#print axioms PEqualNP.Outside.L_meta_17390.upper_bound\n#print axioms PEqualNP.Outside.L_meta_17390.row_distinct\n",
    "exact-elaboration source": "import PEqualNP.Defs\n\n#check ((∃ C : PEqualNP.CircuitLowerBounds.Circuit, PEqualNP.MetaComplexity.Monotone2 C ∧ C.size ≤ 13 ∧ ∀ x : Fin 9 → Bool, C.eval (List.ofFn x) = ((x 0 && x 4 && x 8) || (x 0 && x 5 && x 7) || (x 1 && x 3 && x 8) || (x 1 && x 5 && x 6) || (x 2 && x 3 && x 7) || (x 2 && x 4 && x 6))) : Prop)\n",
    "commands": [
      "From an isolated scratch root, curl the two pinned archives and check their SHA-256.",
      "mkdir -p repo runtime; tar xzf repo.tgz --strip-components=1 -C repo; tar --zstd --no-same-owner -xf lean.tar.zst --strip-components=1 -C runtime",
      "git -C repo init -q; git -C repo remote add origin https://github.com/open-goat/pequalnp-proofs; git -C repo fetch --depth=1 origin 8dec1cacf8aab169f12858fff3a2e945fea7a880; git -C repo reset --mixed FETCH_HEAD",
      "python3 fetch-pins.py",
      "runtime/bin/lean --version; runtime/bin/lake --version",
      "cd repo/lean && ../../network-run lake exe cache get",
      "cd repo/lean && ../../clean-run lake build PEqualNP.Defs",
      "cd repo/lean && ../../clean-run lake build checklemma",
      "Copy the Lean artifact to its path under repo/. Write the target artifact bytes as statement.txt and the Lean artifact statement bytes as support-statement.txt in scratch.",
      "Write Axioms.lean from the embedded source. Create guard/imports.json with [\"PEqualNP.Defs\"].",
      "cd repo/lean && ../../clean-run lake build +PEqualNP.Outside.L_meta_17390 +PEqualNP.Defs",
      "cd repo/lean && ../../clean-run lake env lean ../../Axioms.lean",
      "cd repo && ../clean-run node .github/scripts/outside-guard.mjs imports lean/PEqualNP/Outside/L_meta_17390.lean ../guard/imports.json lean/PEqualNP/Outside/L_meta_17390.lean check",
      "cd repo && ../clean-run node .github/scripts/outside-guard.mjs closure . ../guard/imports.json lean/PEqualNP/Outside/L_meta_17390.lean ../guard check",
      "cd repo && ../clean-run node tools/check-lean.mjs lean/PEqualNP/Outside/L_meta_17390.lean ../support-statement.txt check",
      "cd repo && ../clean-run node tools/check-lean.mjs lean/PEqualNP/Outside/L_meta_17390.lean ../statement.txt check",
      "cd repo/lean && ../../clean-run lake env leanchecker -v PEqualNP.Outside.L_meta_17390",
      "cd repo/lean && ../../clean-run lake env lean ../../ExactStatementCheck.lean",
      "git -C repo diff --exit-code HEAD -- lean/lakefile.toml lean/lake-manifest.json lean/lean-toolchain lean/PEqualNP/Defs.lean lean/PEqualNP/Defs lean/CheckLemma.lean tools .github/scripts/outside-guard.mjs"
    ],
    "bootstrapResults": [
      "Both archive digests matched the capsule. The initial Lean tar extraction reported ownership warnings from tar. The reproducer adds --no-same-owner. The extracted Lean and Lake reported the expected versions.",
      "All nine package HEADs matched the pinned manifest. Cache get exited 0 and decompressed 9117 entries. The initial invocation with the proxy-free clean environment could not resolve the public cache downloader. The retry forwarded standard network proxy settings for bootstrap only.",
      "The standalone definitions build exited 0 (5149 jobs). The verifier binary build exited 0 (5 jobs). No tracked upstream sources changed.",
      "The supporting source adds no dependency beyond the pinned project libraries. All runtime and package setup was isolated in scratch."
    ],
    "initialReplay": {
      "sourceSha256": "3253dc292f70f4520bed21f0337e3e382efe0f14d78312eec7b99c402ab3ae12",
      "imports": [
        "Mathlib",
        "PEqualNP.Defs"
      ],
      "supportWrapperExitCode": 3,
      "supportVerdict": "CHECKER FAULT: the verifier ended without a verdict (exit 137).",
      "targetWrapperExitCode": 3,
      "targetVerdict": "CHECKER FAULT: the verifier ended without a verdict (exit 137).",
      "retry": "Removed the redundant Mathlib root import and rebuilt before replaying again."
    },
    "sources": [
      "https://api.imd.fun/artifacts/6063abcf25b0ece8209fd6a47d5d78a7df697fbdd937474081d3f19b54e10e53",
      "https://data.pequalnp.com/data/lemma/L-meta-17390.626422f1ae76.json",
      "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/8dec1cacf8aab169f12858fff3a2e945fea7a880/lean/lean-toolchain",
      "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/8dec1cacf8aab169f12858fff3a2e945fea7a880/lean/lake-manifest.json",
      "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/8dec1cacf8aab169f12858fff3a2e945fea7a880/tools/check-lean.mjs",
      "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/8dec1cacf8aab169f12858fff3a2e945fea7a880/.github/scripts/outside-guard.mjs",
      "https://raw.githubusercontent.com/open-goat/pequalnp-proofs/8dec1cacf8aab169f12858fff3a2e945fea7a880/lean/CheckLemma.lean",
      "https://raw.githubusercontent.com/leanprover/lean4/v4.36.0/src/LeanChecker.lean"
    ]
  },
  "artifacts": [
    {
      "path": "statement.txt",
      "content": "∃ C : PEqualNP.CircuitLowerBounds.Circuit, PEqualNP.MetaComplexity.Monotone2 C ∧ C.size ≤ 13 ∧ ∀ x : Fin 9 → Bool, C.eval (List.ofFn x) = ((x 0 && x 4 && x 8) || (x 0 && x 5 && x 7) || (x 1 && x 3 && x 8) || (x 1 && x 5 && x 6) || (x 2 && x 3 && x 7) || (x 2 && x 4 && x 6))",
      "sha256": "3a6b7a3a820272375169fb191a04fd1ac8594fdc1849ed746eaaf0eefe286e6a",
      "statement": "∃ C : PEqualNP.CircuitLowerBounds.Circuit, PEqualNP.MetaComplexity.Monotone2 C ∧ C.size ≤ 13 ∧ ∀ x : Fin 9 → Bool, C.eval (List.ofFn x) = ((x 0 && x 4 && x 8) || (x 0 && x 5 && x 7) || (x 1 && x 3 && x 8) || (x 1 && x 5 && x 6) || (x 2 && x 3 && x 7) || (x 2 && x 4 && x 6))",
      "statementSha256": "3a6b7a3a820272375169fb191a04fd1ac8594fdc1849ed746eaaf0eefe286e6a",
      "role": "Exact recorded target proposition, UTF-8 without trailing newline.",
      "relationToTarget": "Unchanged source statement used for the exact checker comparison."
    },
    {
      "path": "lean/PEqualNP/Outside/L_meta_17390.lean",
      "content": "import PEqualNP.Defs\n\nnamespace PEqualNP.Outside.L_meta_17390\n\nopen PEqualNP.CircuitLowerBounds\nopen PEqualNP.MetaComplexity\n\ndef bit {α : Type} (b : Bool) : α → Bool := fun _ => b\n\ndef wireStep {α : Type} (w : List (α → Bool)) (g : Gate) : List (α → Bool) :=\n  w ++ [fun x => g.op.eval (g.inputs.map fun i => w.getD i (bit false) x)]\n\ndef trace {α : Type} (gs : List Gate) (w : List (α → Bool)) : List (α → Bool) :=\n  gs.foldl wireStep w\n\ntheorem trace_cons {α : Type} (g : Gate) (gs : List Gate) (w : List (α → Bool)) :\n    trace (g :: gs) w = trace gs (wireStep w g) := rfl\n\ntheorem trace_length {α : Type} (gs : List Gate) (w : List (α → Bool)) :\n    (trace gs w).length = w.length + gs.length := by\n  induction gs generalizing w with\n  | nil => simp [trace]\n  | cons g gs ih =>\n    rw [trace_cons, ih]\n    simp [wireStep]\n    omega\n\ntheorem wireStep_project {α : Type} (x : α) (g : Gate) (w : List (α → Bool)) :\n    (wireStep w g).map (fun f => f x) =\n      (w.map fun f => f x) ++\n        [g.op.eval (g.inputs.map fun i => (w.map fun f => f x).getD i false)] := by\n  simp only [wireStep, List.map_append, List.map_cons, List.map_nil]\n  congr 3\n  apply List.map_congr_left\n  intro i _\n  exact (List.getD_map (l := w) (d := bit false) (fun f => f x)).symm\n\n/-- Projecting every symbolic wire at an input commutes with the evaluator's fold. -/\ntheorem trace_project {α : Type} (x : α) (gs : List Gate) (w : List (α → Bool)) :\n    (trace gs w).map (fun f => f x) =\n      gs.foldl (fun v g => v ++ [g.op.eval (g.inputs.map fun i => v.getD i false)])\n        (w.map fun f => f x) := by\n  induction gs generalizing w with\n  | nil => rfl\n  | cons g gs ih => rw [trace_cons, ih, wireStep_project, List.foldl_cons]\n\ndef inputs (n : ℕ) : List ((Fin n → Bool) → Bool) := List.ofFn fun i x => x i\n\ntheorem trace_eval {n : ℕ} (C : Circuit) (x : Fin n → Bool) :\n    (trace C.gates (inputs n)).getD C.output (bit false) x = C.eval (List.ofFn x) := by\n  rw [← List.getD_map (l := trace C.gates (inputs n)) (d := bit false) (fun f => f x),\n    trace_project]\n  simp only [Circuit.eval, Circuit.wires, inputs, List.map_ofFn]\n  rfl\n\ndef gate (a : Bool) (i j : ℕ) : Gate := ⟨if a then .and else .or, [i, j]⟩\n\ndef combine {α : Type} (a : Bool) (f g : α → Bool) : α → Bool :=\n  fun x => if a then f x && g x else f x || g x\n\ntheorem wireStep_gate {α : Type} (w : List (α → Bool)) (a : Bool) (i j : ℕ) :\n    wireStep w (gate a i j) =\n      w ++ [combine a (w.getD i (bit false)) (w.getD j (bit false))] := by\n  cases a <;> simp [wireStep, gate, GateOp.eval] <;> rfl\n\n/-- Each retained gate uses two distinct earlier wires, in increasing order. -/\ninductive Ordered : ℕ → List Gate → Prop\n  | nil (n : ℕ) : Ordered n []\n  | cons {n i j : ℕ} {gs : List Gate} (a : Bool) :\n      i < j → j < n → Ordered (n + 1) gs → Ordered n (gate a i j :: gs)\n\ntheorem Ordered.monotone2 {n : ℕ} {gs : List Gate} (h : Ordered n gs) (out : ℕ) :\n    Monotone2 ⟨gs, out⟩ := by\n  intro g hg\n  induction h with\n  | nil => simp at hg\n  | cons a _ _ _ ih =>\n    rcases List.mem_cons.mp hg with rfl | hg\n    · cases a <;> simp [gate]\n    · exact ih hg\n\ndef Covered {α : Type} (w : List (α → Bool)) (f : α → Bool) : Prop :=\n  f = bit false ∨ f = bit true ∨ f ∈ w\n\ntheorem covered_read {α : Type} (v w : List (α → Bool))\n    (h : ∀ f ∈ v, Covered w f) (i : ℕ) : Covered w (v.getD i (bit false)) := by\n  by_cases hi : i < v.length\n  · rw [List.getD_eq_getElem _ _ hi]\n    exact h _ (List.getElem_mem hi)\n  · exact Or.inl (List.getD_eq_default _ _ (by omega))\n\ntheorem covered_append {α : Type} (w u : List (α → Bool)) (f : α → Bool)\n    (h : Covered w f) : Covered (w ++ u) f := by\n  rcases h with hf | ht | hw\n  · exact Or.inl hf\n  · exact Or.inr (Or.inl ht)\n  · exact Or.inr (Or.inr (List.mem_append_left _ hw))\n\ntheorem combine_comm {α : Type} (a : Bool) (f g : α → Bool) :\n    combine a f g = combine a g f := by\n  funext x\n  cases a <;> simp [combine, Bool.and_comm, Bool.or_comm]\n\n/-- A binary gate emits at most one new gate. A constant operand or equal wire index\nlets us reuse a retained wire or a constant. -/\ntheorem combine_covered {α : Type} (w : List (α → Bool)) (a : Bool) (f g : α → Bool)\n    (hf : Covered w f) (hg : Covered w g) :\n    Covered w (combine a f g) ∨ ∃ i j, i < j ∧ j < w.length ∧\n      combine a f g = combine a (w.getD i (bit false)) (w.getD j (bit false)) := by\n  rcases hf with rfl | rfl | hf\n  · left\n    cases a\n    · have he : combine false (bit false) g = g := by funext x; simp [combine, bit]\n      rwa [he]\n    · exact Or.inl (by funext x; simp [combine, bit])\n  · left\n    cases a\n    · exact Or.inr (Or.inl (by funext x; simp [combine, bit]))\n    · have he : combine true (bit true) g = g := by funext x; simp [combine, bit]\n      rwa [he]\n  · rcases hg with rfl | rfl | hg\n    · left\n      cases a\n      · have he : combine false f (bit false) = f := by funext x; simp [combine, bit]\n        exact he.symm ▸ Or.inr (Or.inr hf)\n      · exact Or.inl (by funext x; simp [combine, bit])\n    · left\n      cases a\n      · exact Or.inr (Or.inl (by funext x; simp [combine, bit]))\n      · have he : combine true f (bit true) = f := by funext x; simp [combine, bit]\n        exact he.symm ▸ Or.inr (Or.inr hf)\n    · obtain ⟨i, hi, rfl⟩ := List.mem_iff_getElem.mp hf\n      obtain ⟨j, hj, rfl⟩ := List.mem_iff_getElem.mp hg\n      rcases lt_trichotomy i j with h | h | h\n      · exact Or.inr ⟨i, j, h, hj, by rw [List.getD_eq_getElem _ _ hi,\n          List.getD_eq_getElem _ _ hj]⟩\n      · subst j\n        left\n        have he : combine a w[i] w[i] = w[i] := by\n          funext x\n          cases a <;> simp [combine]\n        rw [he]\n        exact Or.inr (Or.inr (List.getElem_mem hi))\n      · exact Or.inr ⟨j, i, h, hi, by rw [List.getD_eq_getElem _ _ hj,\n          List.getD_eq_getElem _ _ hi, combine_comm]⟩\n\n/-- Zero-input and one-input gates also fit the same invariant. -/\ntheorem step_covered {α : Type} (v w : List (α → Bool)) (g : Gate)\n    (hop : g.op ∈ ({GateOp.and, GateOp.or} : Set GateOp)) (hsize : g.inputs.length ≤ 2)\n    (h : ∀ f ∈ v, Covered w f) :\n    ∃ f, wireStep v g = v ++ [f] ∧\n      (Covered w f ∨ ∃ i j, i < j ∧ j < w.length ∧\n        f = combine (g.op matches .and) (w.getD i (bit false)) (w.getD j (bit false))) := by\n  obtain ⟨op, is⟩ := g\n  have hb : op = .and ∨ op = .or := by simpa using hop\n  cases is with\n  | nil =>\n    rcases hb with rfl | rfl\n    · exact ⟨bit true, rfl, Or.inl (Or.inr (Or.inl rfl))⟩\n    · exact ⟨bit false, rfl, Or.inl (Or.inl rfl)⟩\n  | cons i is =>\n    cases is with\n    | nil =>\n      rcases hb with rfl | rfl <;>\n        exact ⟨v.getD i (bit false), by simp [wireStep, GateOp.eval],\n          Or.inl (covered_read v w h i)⟩\n    | cons j is =>\n      cases is with\n      | nil =>\n        rcases hb with rfl | rfl\n        · refine ⟨combine true (v.getD i (bit false)) (v.getD j (bit false)), ?_, ?_⟩\n          · exact wireStep_gate v true i j\n          · exact combine_covered w true _ _ (covered_read v w h i) (covered_read v w h j)\n        · refine ⟨combine false (v.getD i (bit false)) (v.getD j (bit false)), ?_, ?_⟩\n          · exact wireStep_gate v false i j\n          · exact combine_covered w false _ _ (covered_read v w h i) (covered_read v w h j)\n      | cons k is => simp at hsize\n\n/-- Fold invariant: every original wire is a constant or occurs in the retained\ntrace, and the retained trace has used at most one gate per original step. -/\ntheorem normalize {α : Type} (gs : List Gate)\n    (hg : ∀ g ∈ gs, g.op ∈ ({GateOp.and, GateOp.or} : Set GateOp) ∧ g.inputs.length ≤ 2)\n    (v w : List (α → Bool)) (h : ∀ f ∈ v, Covered w f) :\n    ∃ ds, Ordered w.length ds ∧ ds.length ≤ gs.length ∧\n      ∀ f ∈ trace gs v, Covered (trace ds w) f := by\n  induction gs generalizing v w with\n  | nil => exact ⟨[], Ordered.nil _, by simp, h⟩\n  | cons g gs ih =>\n    have htail : ∀ d ∈ gs, d.op ∈ ({GateOp.and, GateOp.or} : Set GateOp) ∧\n        d.inputs.length ≤ 2 := fun d hd => hg d (List.mem_cons_of_mem _ hd)\n    obtain ⟨hop, hsize⟩ := hg g (by simp)\n    obtain ⟨f, hf, hstep⟩ := step_covered v w g hop hsize h\n    rcases hstep with hc | ⟨i, j, hij, hj, he⟩\n    · have h' : ∀ b ∈ wireStep v g, Covered w b := by\n        rw [hf]\n        intro b hb\n        rcases List.mem_append.mp hb with hb | hb\n        · exact h b hb\n        · simpa using (List.mem_singleton.mp hb) ▸ hc\n      obtain ⟨ds, ho, hlen, hw⟩ := ih htail (wireStep v g) w h'\n      exact ⟨ds, ho, by simpa using Nat.le_succ_of_le hlen, hw⟩\n    · let a := g.op matches .and\n      let d := gate a i j\n      have hd : wireStep w d = w ++ [f] := by\n        rw [he]\n        exact wireStep_gate w a i j\n      have h' : ∀ b ∈ wireStep v g, Covered (wireStep w d) b := by\n        rw [hf, hd]\n        intro b hb\n        rcases List.mem_append.mp hb with hb | hb\n        · exact covered_append w [f] b (h b hb)\n        · exact Or.inr (Or.inr (List.mem_append_right _ hb))\n      obtain ⟨ds, ho, hlen, hw⟩ := ih htail (wireStep v g) (wireStep w d) h'\n      have ho' : Ordered (w.length + 1) ds := by simpa [wireStep] using ho\n      exact ⟨d :: ds, Ordered.cons a hij hj ho', by simpa using hlen, hw⟩\n\ntheorem trace_preserve {α : Type} (gs : List Gate) (w : List (α → Bool))\n    (i : ℕ) (hi : i < w.length) :\n    (trace gs w).getD i (bit false) = w.getD i (bit false) := by\n  induction gs generalizing w with\n  | nil => rfl\n  | cons g gs ih =>\n    rw [trace_cons, ih]\n    · exact List.getD_append _ _ _ _ hi\n    · simpa [wireStep] using Nat.lt_succ_of_lt hi\n\ntheorem trace_take {α : Type} (gs : List Gate) (w : List (α → Bool)) (k i : ℕ)\n    (hi : i < w.length + (gs.take k).length) :\n    (trace (gs.take k) w).getD i (bit false) = (trace gs w).getD i (bit false) := by\n  rw [← trace_preserve (gs.drop k) (trace (gs.take k) w) i (by simpa only [trace_length] using hi)]\n  simp [trace, ← List.foldl_append]\n\ntheorem Ordered.take {n : ℕ} {gs : List Gate} (h : Ordered n gs) (k : ℕ) :\n    Ordered n (gs.take k) := by\n  induction h generalizing k with\n  | nil n => simpa using (Ordered.nil n)\n  | cons a hij hj _ ih =>\n    cases k with\n    | zero => exact .nil _\n    | succ k => exact .cons a hij hj (ih k)\n\ntheorem ordered_iff_index (n : ℕ) (gs : List Gate) :\n    Ordered n gs ↔ ∀ (j : ℕ) (g : Gate), gs[j]? = some g →\n      ∃ i k : ℕ, i < k ∧ k < n + j ∧ g.inputs = [i, k] ∧\n        (g.op = GateOp.and ∨ g.op = GateOp.or) := by\n  induction gs generalizing n with\n  | nil =>\n    constructor\n    · intro _ j g hg\n      simp at hg\n    · intro _\n      exact .nil _\n  | cons d ds ih =>\n    constructor\n    · intro ho\n      cases ho with\n      | @cons _ i k _ a hik hk ht =>\n        intro j g hg\n        cases j with\n        | zero =>\n          simp at hg\n          subst g\n          exact ⟨i, k, hik, by simpa, rfl, by cases a <;> simp [gate]⟩\n        | succ j =>\n          obtain ⟨i', k', hlt, hb, hs, hg'⟩ :=\n            (ih _).mp ht j g (by simpa using hg)\n          exact ⟨i', k', hlt, by omega, hs, hg'⟩\n    · intro hc\n      have ht : Ordered (n + 1) ds := by\n        refine (ih _).mpr fun j g hg => ?_\n        obtain ⟨i, k, hlt, hb, hs, ho⟩ := hc (j + 1) g (by simpa using hg)\n        exact ⟨i, k, hlt, by omega, hs, ho⟩\n      obtain ⟨i, k, hlt, hb, hs, ho⟩ := hc 0 d (by simp)\n      obtain ⟨op, ins⟩ := d\n      change ins = [i, k] at hs\n      change op = .and ∨ op = .or at ho\n      subst ins\n      rcases ho with rfl | rfl\n      · exact .cons true hlt (by simpa using hb) ht\n      · exact .cons false hlt (by simpa using hb) ht\n\ntheorem combine_mono_bits : ∀ a b c d e : Bool, b ≤ c → d ≤ e →\n    (if a then b && d else b || d) ≤ (if a then c && e else c || e) := by decide\n\ntheorem read_monotone {α : Type} [Preorder α] (w : List (α → Bool))\n    (hm : ∀ f ∈ w, Monotone f) (i : ℕ) : Monotone (w.getD i (bit false)) := by\n  by_cases hi : i < w.length\n  · rw [List.getD_eq_getElem _ _ hi]\n    exact hm _ (List.getElem_mem hi)\n  · rw [List.getD_eq_default _ _ (by omega)]\n    exact fun _ _ _ => le_rfl\n\n/-- The fold preserves monotonicity of every wire as well as coverage. -/\ntheorem Ordered.trace_monotone {α : Type} [Preorder α] {n : ℕ} {gs : List Gate}\n    (h : Ordered n gs) (w : List (α → Bool)) (hm : ∀ f ∈ w, Monotone f) :\n    ∀ f ∈ trace gs w, Monotone f := by\n  induction h generalizing w with\n  | nil => exact hm\n  | @cons _ i j gs a _ _ _ ih =>\n    rw [trace_cons]\n    apply ih\n    rw [wireStep_gate]\n    intro f hf\n    rcases List.mem_append.mp hf with hf | hf\n    · exact hm f hf\n    · obtain rfl := List.mem_singleton.mp hf\n      intro x y hxy\n      exact combine_mono_bits a _ _ _ _\n        (read_monotone w hm i hxy) (read_monotone w hm j hxy)\n\ntheorem Ordered.eval_monotone {n : ℕ} {gs : List Gate} (h : Ordered n gs) (out : ℕ) :\n    Monotone (fun x : Fin n → Bool => (Circuit.mk gs out).eval (List.ofFn x)) := by\n  have hm : ∀ f ∈ inputs n, Monotone f := by\n    intro f hf\n    rw [inputs, List.mem_ofFn] at hf\n    obtain ⟨i, rfl⟩ := hf\n    exact fun _ _ hxy => hxy i\n  intro x y hxy\n  change (Circuit.mk gs out).eval (List.ofFn x) ≤ (Circuit.mk gs out).eval (List.ofFn y)\n  rw [← trace_eval (Circuit.mk gs out) x, ← trace_eval (Circuit.mk gs out) y]\n  exact read_monotone _ (h.trace_monotone (inputs n) hm) out hxy\n\ndef matching (x : Fin 9 → Bool) : Bool :=\n  (x 0 && x 4 && x 8) || (x 0 && x 5 && x 7) || (x 1 && x 3 && x 8) ||\n    (x 1 && x 5 && x 6) || (x 2 && x 3 && x 7) || (x 2 && x 4 && x 6)\n\ntheorem inputs_read {n : ℕ} (i : Fin n) :\n    (inputs n).getD i (bit false) = fun x => x i := by\n  unfold inputs\n  rw [List.getD_eq_getElem _ _ (by simp), List.getElem_ofFn]\n\ntheorem matching_singleton (i : Fin 9) : matching (fun j => j == i) = false := by\n  fin_cases i <;> decide\n\n/-- A circuit for this function can be replaced by an ordered one with a last-gate\noutput using no extra gates, even if the original uses missing wires or constants. -/\ntheorem normalize_matching (C : Circuit) (hC : Monotone2 C)\n    (hc : ∀ x : Fin 9 → Bool, C.eval (List.ofFn x) = matching x) :\n    ∃ ds, Ordered 9 ds ∧ ds.length ≤ C.size ∧\n      ∃ out, out + 1 = 9 + ds.length ∧\n        ∀ x : Fin 9 → Bool, (Circuit.mk ds out).eval (List.ofFn x) = matching x := by\n  let w := inputs 9\n  have hw : w.length = 9 := by simp [w, inputs]\n  obtain ⟨ds, ho, hl, hr⟩ := normalize C.gates hC w w\n    (fun f hf => Or.inr (Or.inr hf))\n  have outEq (x : Fin 9 → Bool) :\n      (trace C.gates w).getD C.output (bit false) x = matching x :=\n    (trace_eval C x).trans (hc x)\n  rcases covered_read _ _ hr C.output with hfalse | htrue | hmem\n  · have hbad := outEq (fun _ => true)\n    rw [hfalse] at hbad\n    cases hbad\n  · have hbad := outEq (fun _ => false)\n    rw [htrue] at hbad\n    cases hbad\n  · obtain ⟨j, hj, he⟩ := List.mem_iff_getElem.mp hmem\n    have outEq' (x : Fin 9 → Bool) : (trace ds w).getD j (bit false) x = matching x := by\n      rw [List.getD_eq_getElem _ _ hj, he, outEq]\n    have hlo : 9 ≤ j := by\n      by_contra! hlt\n      have hrj := trace_preserve ds w j (by omega)\n      let x : Fin 9 → Bool := fun i => i == ⟨j, hlt⟩\n      have hbad := outEq' x\n      have hi := inputs_read (⟨j, hlt⟩ : Fin 9)\n      change w.getD j (bit false) = (fun v => v ⟨j, hlt⟩) at hi\n      rw [hrj, hi, matching_singleton ⟨j, hlt⟩] at hbad\n      simp [x] at hbad\n    let k := j + 1 - 9\n    have hk : k ≤ ds.length := by\n      rw [trace_length, hw] at hj\n      omega\n    have hlast : j + 1 = 9 + (ds.take k).length := by\n      rw [List.length_take, min_eq_left hk]\n      omega\n    have htake := trace_take ds w k j (by omega)\n    refine ⟨ds.take k, (hw ▸ ho).take k, ?_, j, hlast, fun x => ?_⟩\n    · rw [List.length_take, min_eq_left hk]\n      exact hk.trans hl\n    · rw [← trace_eval (Circuit.mk (ds.take k) j) x]\n      exact (congrFun htake x).trans (outEq' x)\n\ndef mask (m : ℕ) (i : Fin 9) : Bool := m.testBit i\n\ndef pos : List ℕ := [273, 161, 266, 98, 140, 84]\n\ndef neg : List ℕ := [63, 79, 121, 151, 186, 219, 295, 316, 365, 438, 455, 457, 466, 484, 504]\n\ndef bitsLE (x y : Fin 9 → Bool) : Bool :=\n  (List.finRange 9).all fun i => !x i || y i\n\ntheorem bool_le_test : ∀ a b : Bool, (!a || b) = true ↔ a ≤ b := by decide\n\ntheorem bitsLE_iff (x y : Fin 9 → Bool) : bitsLE x y = true ↔ x ≤ y := by\n  simp only [bitsLE, List.all_eq_true, bool_le_test, Pi.le_def]\n  exact ⟨fun h i => h i (List.mem_finRange i), fun h i _ => h i⟩\n\ndef tuple (a b c d e f g h i : Bool) : Fin 9 → Bool :=\n  ![a, b, c, d, e, f, g, h, i]\n\ntheorem tuple_eq (x : Fin 9 → Bool) :\n    tuple (x 0) (x 1) (x 2) (x 3) (x 4) (x 5) (x 6) (x 7) (x 8) = x := by\n  funext i\n  fin_cases i <;> rfl\n\nset_option maxRecDepth 8192 in\nset_option maxHeartbeats 8000000 in\ntheorem frontier_tuple :\n    ∀ a b c d e f g h i : Bool,\n      let x := tuple a b c d e f g h i\n      (if matching x then pos.any (fun m => bitsLE (mask m) x)\n        else neg.any (fun m => bitsLE x (mask m))) = true := by\n  decide +kernel\n\ntheorem positive_matching : ∀ m ∈ pos, matching (mask m) = true := by\n  intro m hm\n  simp only [pos, List.mem_cons, List.not_mem_nil, or_false] at hm\n  rcases hm with rfl | rfl | rfl | rfl | rfl | rfl <;> decide\n\ntheorem negative_matching : ∀ m ∈ neg, matching (mask m) = false := by\n  intro m hm\n  simp only [neg, List.mem_cons, List.not_mem_nil, or_false] at hm\n  rcases hm with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;>\n    decide\n\n/-- The 21 tests determine any monotone Boolean function that agrees with them. -/\ntheorem frontier_iff (f : (Fin 9 → Bool) → Bool) (hf : Monotone f) :\n    (∀ x, f x = matching x) ↔\n      (∀ m ∈ pos, f (mask m) = true) ∧ (∀ m ∈ neg, f (mask m) = false) := by\n  constructor\n  · intro h\n    exact ⟨fun m hm => (h _).trans (positive_matching m hm),\n      fun m hm => (h _).trans (negative_matching m hm)⟩\n  · rintro ⟨hp, hn⟩ x\n    have hx := frontier_tuple (x 0) (x 1) (x 2) (x 3) (x 4) (x 5) (x 6) (x 7) (x 8)\n    dsimp only at hx\n    rw [tuple_eq] at hx\n    cases h : matching x with\n    | false =>\n      simp only [h, Bool.false_eq_true, ↓reduceIte] at hx\n      obtain ⟨m, hm, hle⟩ := List.any_eq_true.mp hx\n      have hb := hf ((bitsLE_iff _ _).mp hle)\n      rw [hn m hm] at hb\n      exact le_antisymm hb (by simp)\n    | true =>\n      simp only [h, ↓reduceIte] at hx\n      obtain ⟨m, hm, hle⟩ := List.any_eq_true.mp hx\n      have hb := hf ((bitsLE_iff _ _).mp hle)\n      rw [hp m hm] at hb\n      exact le_antisymm (by simp) hb\n\n/-- Factor the six matchings by their choice in the first row. -/\ndef rowCircuit : Circuit :=\n  ⟨[gate true 4 8, gate true 5 7, gate false 9 10, gate true 0 11,\n    gate true 3 8, gate true 5 6, gate false 13 14, gate true 1 15,\n    gate true 3 7, gate true 4 6, gate false 17 18, gate true 2 19,\n    gate false 12 16, gate false 20 21], 22⟩\n\ntheorem row_ordered : Ordered 9 rowCircuit.gates := by\n  repeat' first | apply Ordered.cons <;> try decide | exact Ordered.nil _\n\nset_option maxHeartbeats 2000000 in\ntheorem row_eval (x : Fin 9 → Bool) : rowCircuit.eval (List.ofFn x) = matching x := by\n  have hp : pos.all (fun m => rowCircuit.eval (List.ofFn (mask m))) = true := by decide\n  have hn : neg.all (fun m => !rowCircuit.eval (List.ofFn (mask m))) = true := by decide\n  refine (frontier_iff _ (row_ordered.eval_monotone rowCircuit.output)).mpr ⟨?_, ?_⟩ x\n  · exact List.all_eq_true.mp hp\n  · intro m hm\n    have he := List.all_eq_true.mp hn m hm\n    exact Eq.mp (Bool.not_eq_true_eq_eq_false (rowCircuit.eval (List.ofFn (mask m)))) he\n\ntheorem upper_bound :\n    ∃ C : Circuit, Monotone2 C ∧ C.size ≤ 14 ∧\n      ∀ x : Fin 9 → Bool, C.eval (List.ofFn x) = matching x :=\n  ⟨rowCircuit, row_ordered.monotone2 _, by decide, row_eval⟩\n\ndef signature (f : (Fin 9 → Bool) → Bool) : List Bool :=\n  (pos ++ neg).map fun m => f (mask m)\n\nset_option maxRecDepth 8192 in\nset_option maxHeartbeats 8000000 in\n/-- Even on the boundary tests, no wire of this construction duplicates an earlier\nwire or a constant. -/\ntheorem row_distinct :\n    ([signature (bit false), signature (bit true)] ++\n      (trace rowCircuit.gates (inputs 9)).map signature).Nodup := by\n  decide +kernel\n\nend PEqualNP.Outside.L_meta_17390\n\n\n/-- Exact bounded-search characterization for the matching function. -/\ntheorem PEqualNP.Outside.L_meta_17390 :\n    ∀ k : ℕ,\n      (∃ C : PEqualNP.CircuitLowerBounds.Circuit, PEqualNP.MetaComplexity.Monotone2 C ∧\n        C.size ≤ k ∧ ∀ x : Fin 9 → Bool, C.eval (List.ofFn x) =\n          ((x 0 && x 4 && x 8) || (x 0 && x 5 && x 7) || (x 1 && x 3 && x 8) ||\n            (x 1 && x 5 && x 6) || (x 2 && x 3 && x 7) || (x 2 && x 4 && x 6))) ↔\n      ∃ C : PEqualNP.CircuitLowerBounds.Circuit, C.size ≤ k ∧ C.output + 1 = 9 + C.size ∧\n        (∀ (j : ℕ) (g : PEqualNP.CircuitLowerBounds.Gate), C.gates[j]? = some g →\n          ∃ i l : ℕ, i < l ∧ l < 9 + j ∧ g.inputs = [i, l] ∧\n            (g.op = PEqualNP.CircuitLowerBounds.GateOp.and ∨\n              g.op = PEqualNP.CircuitLowerBounds.GateOp.or)) ∧\n        (∀ m ∈ ([273, 161, 266, 98, 140, 84] : List ℕ),\n          C.eval (List.ofFn (fun i : Fin 9 => m.testBit i)) = true) ∧\n        (∀ m ∈ ([63, 79, 121, 151, 186, 219, 295, 316, 365, 438, 455, 457, 466, 484, 504] : List ℕ),\n          C.eval (List.ofFn (fun i : Fin 9 => m.testBit i)) = false) := by\n  intro k\n  constructor\n  · rintro ⟨C, hC, hk, he⟩\n    obtain ⟨ds, ho, hn, out, hout, hf⟩ := PEqualNP.Outside.L_meta_17390.normalize_matching C hC he\n    have ⟨hp, hneg⟩ := (PEqualNP.Outside.L_meta_17390.frontier_iff _ (ho.eval_monotone out)).mp hf\n    exact ⟨⟨ds, out⟩, hn.trans hk, hout, (PEqualNP.Outside.L_meta_17390.ordered_iff_index 9 ds).mp ho, hp, hneg⟩\n  · rintro ⟨⟨ds, out⟩, hk, _, h, hp, hneg⟩\n    have ho := (PEqualNP.Outside.L_meta_17390.ordered_iff_index 9 ds).mpr h\n    exact ⟨⟨ds, out⟩, ho.monotone2 out, hk,\n      (PEqualNP.Outside.L_meta_17390.frontier_iff _ (ho.eval_monotone out)).mpr ⟨hp, hneg⟩⟩\n",
      "sha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "statement": "∀ k : ℕ,\n      (∃ C : PEqualNP.CircuitLowerBounds.Circuit, PEqualNP.MetaComplexity.Monotone2 C ∧\n        C.size ≤ k ∧ ∀ x : Fin 9 → Bool, C.eval (List.ofFn x) =\n          ((x 0 && x 4 && x 8) || (x 0 && x 5 && x 7) || (x 1 && x 3 && x 8) ||\n            (x 1 && x 5 && x 6) || (x 2 && x 3 && x 7) || (x 2 && x 4 && x 6))) ↔\n      ∃ C : PEqualNP.CircuitLowerBounds.Circuit, C.size ≤ k ∧ C.output + 1 = 9 + C.size ∧\n        (∀ (j : ℕ) (g : PEqualNP.CircuitLowerBounds.Gate), C.gates[j]? = some g →\n          ∃ i l : ℕ, i < l ∧ l < 9 + j ∧ g.inputs = [i, l] ∧\n            (g.op = PEqualNP.CircuitLowerBounds.GateOp.and ∨\n              g.op = PEqualNP.CircuitLowerBounds.GateOp.or)) ∧\n        (∀ m ∈ ([273, 161, 266, 98, 140, 84] : List ℕ),\n          C.eval (List.ofFn (fun i : Fin 9 => m.testBit i)) = true) ∧\n        (∀ m ∈ ([63, 79, 121, 151, 186, 219, 295, 316, 365, 438, 455, 457, 466, 484, 504] : List ℕ),\n          C.eval (List.ofFn (fun i : Fin 9 => m.testBit i)) = false)",
      "statementSha256": "828ebc1bd82e3c011c384d6c3a916055bc3f4f3c624a52cc63c304da80cd0d7c",
      "role": "Complete Lean source for the supporting equivalence. Includes the separate bound-14 witness and its boundary signatures.",
      "relationToTarget": "At k = 13 the left side is the target. The right side is a sound and complete restricted synthesis problem. The final theorem has the gap module name for local tooling and proves the equivalence only."
    }
  ],
  "verification": [
    {
      "artifactSha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "command": "cd repo/lean && ../../clean-run lake build +PEqualNP.Outside.L_meta_17390 +PEqualNP.Defs",
      "exitCode": 0,
      "verdict": "Build completed successfully (5151 jobs).",
      "logExcerpt": "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\n✔ [5150/5151] Built PEqualNP.Outside.L_meta_17390 (19s)\nBuild completed successfully (5151 jobs)."
    },
    {
      "artifactSha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "command": "cd repo/lean && ../../clean-run lake env lean ../../Axioms.lean",
      "exitCode": 0,
      "verdict": "'PEqualNP.Outside.L_meta_17390.row_distinct' depends on axioms: [propext]",
      "logExcerpt": "'PEqualNP.Outside.L_meta_17390' depends on axioms: [propext, Classical.choice, Quot.sound]\n'PEqualNP.Outside.L_meta_17390.upper_bound' depends on axioms: [propext, Classical.choice, Quot.sound]\n'PEqualNP.Outside.L_meta_17390.row_distinct' depends on axioms: [propext]"
    },
    {
      "artifactSha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "command": "cd repo && ../clean-run node .github/scripts/outside-guard.mjs imports lean/PEqualNP/Outside/L_meta_17390.lean ../guard/imports.json lean/PEqualNP/Outside/L_meta_17390.lean check",
      "exitCode": 0,
      "verdict": "imports allowed: PEqualNP.Defs",
      "logExcerpt": "imports allowed: PEqualNP.Defs"
    },
    {
      "artifactSha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "command": "cd repo && ../clean-run node .github/scripts/outside-guard.mjs closure . ../guard/imports.json lean/PEqualNP/Outside/L_meta_17390.lean ../guard check",
      "exitCode": 0,
      "verdict": "outside-written, built only in the locked step: (none)",
      "logExcerpt": "outside-written, built only in the locked step: (none)"
    },
    {
      "artifactSha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "command": "cd repo && ../clean-run node tools/check-lean.mjs lean/PEqualNP/Outside/L_meta_17390.lean ../support-statement.txt check",
      "exitCode": 3,
      "verdict": "CHECKER FAULT: the verifier ended without a verdict (exit 137).",
      "logExcerpt": "checker stage: started t=0s\nchecker stage: build lock taken t=0s\nchecker stage: building the verifier t=0s\nchecker stage: building the file and the definitions root t=2s\nchecker stage: verifier reading the built file t=6s\nCHECKER FAULT: the verifier ended without a verdict (exit 137).",
      "judgment": "Positive replay against the supporting proposition."
    },
    {
      "artifactSha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "command": "cd repo && ../clean-run node tools/check-lean.mjs lean/PEqualNP/Outside/L_meta_17390.lean ../statement.txt check",
      "exitCode": 3,
      "verdict": "CHECKER FAULT: the verifier ended without a verdict (exit 137).",
      "logExcerpt": "checker stage: started t=0s\nchecker stage: build lock taken t=0s\nchecker stage: building the verifier t=0s\nchecker stage: building the file and the definitions root t=6s\nchecker stage: verifier reading the built file t=11s\nCHECKER FAULT: the verifier ended without a verdict (exit 137).",
      "judgment": "Exact target comparison using the original 286 bytes."
    },
    {
      "artifactSha256": "1b6e7765c0a9c43e495cee37d9709bbecde7dc86a9d9f0bfb5ec32fc0c0998c7",
      "command": "cd repo/lean && ../../clean-run lake env leanchecker -v PEqualNP.Outside.L_meta_17390",
      "exitCode": 0,
      "verdict": "replaying PEqualNP.Outside.L_meta_17390",
      "logExcerpt": "replaying PEqualNP.Outside.L_meta_17390",
      "judgment": "Replay of the compiled proof module with the pinned Lean kernel."
    },
    {
      "artifactSha256": "3a6b7a3a820272375169fb191a04fd1ac8594fdc1849ed746eaaf0eefe286e6a",
      "command": "cd repo/lean && ../../clean-run lake env lean ../../ExactStatementCheck.lean",
      "exitCode": 0,
      "verdict": "            x 2 && x 4 && x 6) : Prop",
      "logExcerpt": "        C.eval (List.ofFn x) =\n          (x 0 && x 4 && x 8 || x 0 && x 5 && x 7 || x 1 && x 3 && x 8 || x 1 && x 5 && x 6 || x 2 && x 3 && x 7 ||\n            x 2 && x 4 && x 6) : Prop",
      "judgment": "Elaboration of the exact target bytes as a proposition."
    }
  ],
  "experiments": [
    {
      "program": "from itertools import permutations\n\nwidth = 3\nn = width ** 2\nmatchings = [\n    sum(1 << (width * row + col) for row, col in enumerate(cols))\n    for cols in permutations(range(width))\n]\npoints = range(1 << n)\n\n\ndef target(mask):\n    return any(mask & matching == matching for matching in matchings)\n\n\nminimal_true = [\n    m for m in points\n    if target(m) and all(not target(m ^ (1 << i)) for i in range(n) if m & (1 << i))\n]\nmaximal_false = [\n    m for m in points\n    if not target(m) and all(target(m | (1 << i)) for i in range(n) if not m & (1 << i))\n]\nassert sorted(matchings) == minimal_true\nfor m in points:\n    if target(m):\n        assert any(m & p == p for p in minimal_true)\n    else:\n        assert any(m & q == m for q in maximal_false)\nprint(f'{len(points)} inputs, {sum(map(target, points))} true, {sum(not target(m) for m in points)} false')\nprint('minimal true:', minimal_true)\nprint('maximal false:', maximal_false)\n",
      "range": "All 512 input graphs. Checks extrema and coverage of each input by a boundary point. No circuit synthesis.",
      "command": "python3 frontier.py",
      "exitCode": 0,
      "output": "512 inputs, 247 true, 265 false\nminimal true: [84, 98, 140, 161, 266, 273]\nmaximal false: [63, 79, 121, 151, 186, 219, 295, 316, 365, 438, 455, 457, 466, 484, 504]"
    },
    {
      "program": "from collections import Counter\nfrom itertools import combinations\n\n# True means AND. Each gate is listed in wire order after the nine inputs.\noriginal = [\n    (True, 4, 8), (True, 5, 7), (False, 9, 10), (True, 0, 11),\n    (True, 3, 8), (True, 5, 6), (False, 13, 14), (True, 1, 15),\n    (True, 3, 7), (True, 4, 6), (False, 17, 18), (True, 2, 19),\n    (False, 12, 16), (False, 20, 21),\n]\npositive = [273, 161, 266, 98, 140, 84]\nnegative = [63, 79, 121, 151, 186, 219, 295, 316, 365, 438, 455, 457, 466, 484, 504]\npoints = positive + negative\ninitial = [sum(((m >> i) & 1) << p for p, m in enumerate(points)) for i in range(9)]\ntarget = (1 << len(positive)) - 1\n\n\ndef error_mask(gates, output):\n    wires = initial.copy()\n    for is_and, a, b in gates:\n        wires.append(wires[a] & wires[b] if is_and else wires[a] | wires[b])\n    return wires[output] ^ target\n\n\ndef delete_and_reroute(gates, deleted, earlier):\n    def shifted(i):\n        if i == deleted:\n            return earlier\n        return i - (i > deleted)\n    rewired = [\n        (is_and, *sorted((shifted(a), shifted(b))))\n        for j, (is_and, a, b) in enumerate(gates, 9) if j != deleted\n    ]\n    return rewired, shifted(22)\n\n\nassert error_mask(original, 22) == 0\none_error = {}\npatches = [\n    [(op, a, b) for a, b in combinations(range(j + 9), 2) for op in (False, True)]\n    for j in range(13)\n]\ntrials = [0, 0]\nsolutions = [0, 0]\nbest = [len(points), len(points)]\nfor deleted in range(9, 23):\n    for earlier in range(deleted):\n        gates, out = delete_and_reroute(original, deleted, earlier)\n        miss = error_mask(gates, out).bit_count()\n        trials[0] += 1\n        best[0] = min(best[0], miss)\n        if miss == 0:\n            solutions[0] += 1\n            print('direct witness', gates, 'output', out)\n        for j, old in enumerate(gates):\n            for replacement in patches[j]:\n                if replacement == old:\n                    continue\n                gates[j] = replacement\n                err = error_mask(gates, out)\n                miss = err.bit_count()\n                trials[1] += 1\n                best[1] = min(best[1], miss)\n                if miss == 1:\n                    one_error[tuple(gates), out] = points[err.bit_length() - 1]\n                if miss == 0:\n                    solutions[1] += 1\n                    print('one-replacement witness', gates, 'output', out)\n            gates[j] = old\nfor count, solved, minimum in zip(trials, solutions, best):\n    print(f'{count} trials, {solved} witnesses, minimum frontier errors {minimum}')\nprint('unique one-error circuits by failed mask:', sorted(Counter(one_error.values()).items()), flush=True)\nrepair_trials = 0\nrepair_witnesses = set()\nfor frozen, out in one_error:\n    gates = list(frozen)\n    for j, old in enumerate(frozen):\n        for replacement in patches[j]:\n            if replacement == old:\n                continue\n            gates[j] = replacement\n            repair_trials += 1\n            if error_mask(gates, out) == 0:\n                repair_witnesses.add((tuple(gates), out))\n        gates[j] = old\nprint(f'{repair_trials} repair trials, {len(repair_witnesses)} distinct witnesses')\nfor gates, out in sorted(repair_witnesses):\n    print('repair witness', gates, 'output', out)\n",
      "range": "Delete one gate from the row-factored witness and reroute to each earlier wire. Also test one replacement gate with a distinct earlier pair. Deduplicate the one-error intermediates from that pass and try each single-gate repair. Fixed gate ordering. Evaluate all 21 boundary bits per trial.",
      "command": "python3 reroute-local.py",
      "exitCode": 0,
      "output": "217 trials, 0 witnesses, minimum frontier errors 1\n629091 trials, 0 witnesses, minimum frontier errors 1\nunique one-error circuits by failed mask: [(84, 316), (98, 190), (140, 297), (161, 97), (266, 175), (273, 86)]\n3365745 repair trials, 0 distinct witnesses"
    }
  ],
  "usefulLemmas": [
    {
      "name": "PEqualNP.Outside.L_meta_17390.trace_project",
      "finding": "Evaluating symbolic wires at an input commutes with the existing evaluator fold."
    },
    {
      "name": "PEqualNP.Outside.L_meta_17390.normalize",
      "finding": "Every original wire remains represented by a retained wire or a constant. Keeping a distinct ordered binary gate costs at most one per original step."
    },
    {
      "name": "PEqualNP.Outside.L_meta_17390.normalize_matching",
      "finding": "A successful circuit can be truncated at its normalized output without changing its behavior. The matching function is neither constant nor an input projection."
    },
    {
      "name": "PEqualNP.Outside.L_meta_17390.frontier_iff",
      "finding": "For any monotone output function, agreement on the 21 listed tests is equivalent to agreement on all nine-bit inputs."
    },
    {
      "name": "PEqualNP.Outside.L_meta_17390.upper_bound",
      "finding": "Factoring the six terms according to their first-row edge gives an explicit monotone 14-gate circuit."
    },
    {
      "name": "PEqualNP.Outside.L_meta_17390.row_distinct",
      "finding": "The original nine input wires and all fourteen added wires have pairwise distinct boundary signatures. Both constant signatures are distinct from them."
    }
  ],
  "failedApproaches": [
    "Trying to save a gate by eliminating constants, unary inputs, repeated inputs or duplicate boundary signatures from the first-row construction cannot remove one of its 14 gates. All of its gates have two distinct earlier wires, and its output uses the last gate.",
    "A bounded deletion, reroute and repair experiment preserved the full frontier signature in zero trials. The one-error intermediates always missed a positive test. The result covers the stated neighborhood only."
  ],
  "openObligations": [
    "Exhibit an ordered circuit of at most 13 gates satisfying the 21 tests or certify that none exists.",
    "The proof of the equivalence and the 14-gate upper bound give neither a proof nor a refutation of the original existential bound."
  ],
  "nextExperiment": "Use the normalized search space to enumerate available 21-bit signature sets under pairwise AND/OR with budget 13. Reconstruct any successful gate sequence, or produce a certificate covering the entire restricted space before claiming a refutation.",
  "leaseStatus": "No lease or desk mutation.",
  "submissionStatus": "No outside submission. The supporting proof and reproduction data are embedded for the batch handoff.",
  "agentContributions": "MP05 developed and reviewed the fold invariant, normal form, frontier proof and row-factor construction, and ran the local checks. The input capsule supplied the pinned problem and prior results. No claim is made about other agents."
}
