{
  "gap": "L-meta-765",
  "path": "lean/PEqualNP/Outside/L_meta_765.lean",
  "module": "PEqualNP.Outside.L_meta_765",
  "mainCommit": "45c3c16fcc7da37eb750c3f3deee82d8342c3668",
  "deskStatus": {
    "status": "open",
    "updated_at": "2026-11-24T00:41:19.037Z"
  },
  "changed": true,
  "localCheck": "accepted",
  "axioms": [
    "propext",
    "Quot.sound",
    "Classical.choice"
  ],
  "guard": "pass",
  "source": "import PEqualNP.Defs\nimport PEqualNP.MetaComplexity.L112\nimport PEqualNP.MetaComplexity.L153\n\nopen PEqualNP.CircuitLowerBounds PEqualNP.MetaComplexity\n\nnamespace PEqualNP.Outside.L_meta_765\n\ndef f6 : (Fin 6 → Bool) → Bool := fun x =>\n  (x 0 && x 1) || (x 2 && x 3) || (x 3 && x 4) || (x 4 && x 5) || (x 5 && x 2)\n\ndef g4 : (Fin 4 → Bool) → Bool := fun x =>\n  (x 0 && x 1) || (x 1 && x 2) || (x 2 && x 3) || (x 3 && x 0)\n\ndef pt (k : ℕ) : Fin 6 → Bool := fun i => decide (i.val / 2 = k)\n\ntheorem getD_app (x : List Bool) (v : Bool) (o : ℕ) :\n    (x ++ [v]).getD o false =\n      if o < x.length then x.getD o false else if o = x.length then v else false := by\n  by_cases h1 : o < x.length\n  · rw [ite_eq_left h1]\n    simp [List.getD_eq_getElem?_getD, List.getElem?_append_left h1]\n  · rw [ite_eq_right h1]\n    by_cases h2 : o = x.length\n    · rw [ite_eq_left h2]\n      subst h2\n      simp [List.getD_eq_getElem?_getD]\n    · rw [ite_eq_right h2]\n      have h3 : (x ++ [v])[o]? = none := by\n        rw [List.getElem?_eq_none]\n        simp\n        omega\n      simp [List.getD_eq_getElem?_getD, h3]\n\ntheorem ofFn_getD (x : Fin 6 → Bool) (i : ℕ) (h : i < 6) :\n    (List.ofFn x).getD i false = x ⟨i, h⟩ := by\n  simp only [List.getD_eq_getElem?_getD, List.getElem?_ofFn, dite_eq_left h,\n    Option.getD_some]\n\ntheorem ofFn_getD_ge (x : Fin 6 → Bool) (i : ℕ) (h : 6 ≤ i) :\n    (List.ofFn x).getD i false = false := by\n  have h3 : (List.ofFn x)[i]? = none := by\n    rw [List.getElem?_eq_none]\n    simp\n    omega\n  simp only [List.getD_eq_getElem?_getD, h3, Option.getD_none]\n\ntheorem eval_one (g : Gate) (o : ℕ) (x : List Bool) :\n    Circuit.eval ⟨[g], o⟩ x =\n      (x ++ [g.op.eval (g.inputs.map fun i => x.getD i false)]).getD o false := rfl\n\ntheorem dep (C : Circuit) (hs : C.size ≤ 1) (hI : ∀ g ∈ C.gates, g.inputs.length ≤ 2) (n : ℕ) :\n    ∃ a b : ℕ, ∀ x y : List Bool, x.length = n → y.length = n →\n      x.getD a false = y.getD a false → x.getD b false = y.getD b false →\n        C.eval x = C.eval y := by\n  obtain ⟨gates, o⟩ := C\n  rcases gates with _ | ⟨g, _ | ⟨g', t⟩⟩\n  · exact ⟨o, o, fun x y _ _ h _ => h⟩\n  · have hg : g.inputs.length ≤ 2 := hI g (by simp)\n    by_cases ho : o < n\n    · refine ⟨o, o, fun x y hx hy h _ => ?_⟩\n      rw [eval_one, eval_one, getD_app, getD_app, hx, hy, ite_eq_left ho, ite_eq_left ho]\n      exact h\n    · by_cases ho2 : o = n\n      · rcases hl : g.inputs with _ | ⟨i, _ | ⟨j, _ | ⟨k, r⟩⟩⟩\n        · refine ⟨0, 0, fun x y hx hy _ _ => ?_⟩\n          rw [eval_one, eval_one, getD_app, getD_app, hx, hy, ite_eq_right ho, ite_eq_right ho,\n            ite_eq_left ho2, ite_eq_left ho2]\n          simp only [hl, List.map_nil]\n        · refine ⟨i, i, fun x y hx hy h _ => ?_⟩\n          rw [eval_one, eval_one, getD_app, getD_app, hx, hy, ite_eq_right ho, ite_eq_right ho,\n            ite_eq_left ho2, ite_eq_left ho2]\n          simp only [hl, List.map_cons, List.map_nil, h]\n        · refine ⟨i, j, fun x y hx hy h h' => ?_⟩\n          rw [eval_one, eval_one, getD_app, getD_app, hx, hy, ite_eq_right ho, ite_eq_right ho,\n            ite_eq_left ho2, ite_eq_left ho2]\n          simp only [hl, List.map_cons, List.map_nil, h, h']\n        · rw [hl] at hg\n          simp only [List.length_cons] at hg\n          omega\n      · refine ⟨0, 0, fun x y hx hy _ _ => ?_⟩\n        rw [eval_one, eval_one, getD_app, getD_app, hx, hy, ite_eq_right ho, ite_eq_right ho,\n          ite_eq_right ho2, ite_eq_right ho2]\n  · exfalso\n    have h2 : (g :: g' :: t).length ≤ 1 := hs\n    simp only [List.length_cons] at h2\n    omega\n\ntheorem agree (k a : ℕ) (h1 : a / 2 ≠ k) :\n    (List.ofFn (pt k)).getD a false = (List.ofFn (fun _ : Fin 6 => false)).getD a false := by\n  by_cases ha : a < 6\n  · rw [ofFn_getD _ a ha, ofFn_getD _ a ha]\n    simp [pt, h1]\n  · rw [ofFn_getD_ge _ a (by omega), ofFn_getD_ge _ a (by omega)]\n\ntheorem small (s : ℕ) (hs : s < 2) : ¬ HasCircuitSize 6 f6 s := by\n  rintro ⟨C, hF, hsz, hev⟩\n  have hI : ∀ g ∈ C.gates, g.inputs.length ≤ 2 := fun g hg => (hF g hg).2\n  have hsz1 : C.size ≤ 1 := by omega\n  obtain ⟨a, b, hab⟩ := dep C hsz1 hI 6\n  have hz : f6 (fun _ => false) = false := by decide\n  have key : ∀ k : ℕ, f6 (pt k) = true → a / 2 = k ∨ b / 2 = k := by\n    intro k hk\n    by_contra hcon\n    have h1 : a / 2 ≠ k := fun h => hcon (Or.inl h)\n    have h2 : b / 2 ≠ k := fun h => hcon (Or.inr h)\n    have h3 := hab (List.ofFn (pt k)) (List.ofFn (fun _ : Fin 6 => false)) (by simp) (by simp)\n      (agree k a h1) (agree k b h2)\n    rw [hev, hev, hk, hz] at h3\n    exact absurd h3 (by decide)\n  have p0 : f6 (pt 0) = true := by decide\n  have p1 : f6 (pt 1) = true := by decide\n  have p2 : f6 (pt 2) = true := by decide\n  have k0 := key 0 p0\n  have k1 := key 1 p1\n  have k2 := key 2 p2\n  omega\n\ntheorem hnc4 : ∃ y y' : Fin 4 → Bool, g4 y ≠ g4 y' :=\n  ⟨fun _ => false, fun _ => true, by decide⟩\n\ntheorem bool6 : ∀ a b c d e f : Bool,\n    ((a && b) || ((c && d) || (d && e) || (e && f) || (f && c))) =\n      ((a && b) || (c && d) || (d && e) || (e && f) || (f && c)) := by\n  decide\n\ntheorem key (t : ℕ) : HasCircuitSize 6 f6 (t + 2) ↔ HasCircuitSize 4 g4 t := by\n  have h := PEqualNP.MetaComplexity.L153 4 t g4 hnc4\n  have e : (fun x : Fin (2 + 4) → Bool =>\n      (x (Fin.castAdd 4 0) && x (Fin.castAdd 4 1)) || g4 (fun j : Fin 4 => x (Fin.natAdd 2 j)))\n      = f6 := by\n    funext x\n    exact bool6 (x 0) (x 1) (x 2) (x 3) (x 4) (x 5)\n  rw [e] at h\n  exact h\n\ntheorem main (s : ℕ) : HasCircuitSize 6 f6 s ↔ 5 ≤ s := by\n  constructor\n  · intro h\n    rcases Nat.lt_or_ge s 2 with hs | hs\n    · exact absurd h (small s hs)\n    · obtain ⟨t, rfl⟩ : ∃ t, s = t + 2 := ⟨s - 2, by omega⟩\n      have h1 : HasCircuitSize 4 g4 t := (key t).1 h\n      have h2 : 3 ≤ t := (PEqualNP.MetaComplexity.L112 t).1 h1\n      omega\n  · intro h\n    obtain ⟨t, rfl⟩ : ∃ t, s = t + 2 := ⟨s - 2, by omega⟩\n    exact (key t).2 ((PEqualNP.MetaComplexity.L112 t).2 (by omega))\n\nend PEqualNP.Outside.L_meta_765\n\ntheorem PEqualNP.Outside.L_meta_765 : ∀ s : ℕ, PEqualNP.MetaComplexity.HasCircuitSize 6 (fun x : Fin 6 → Bool => (x 0 && x 1) || (x 2 && x 3) || (x 3 && x 4) || (x 4 && x 5) || (x 5 && x 2)) s ↔ 5 ≤ s :=\n  fun s => PEqualNP.Outside.L_meta_765.main s\n",
  "reasoning": "Cloned the main branch when work began; mainCommit is that clone's HEAD. The initial desk snapshot was updated_at 2026-11-24T00:37:48.648Z. The final snapshot recorded in deskStatus still lists this id under gaps, not checked or withdrawn, with the same exact statement and permitted imports. Installed pinned Lean 4.36.0 and ran lake exe cache get against the committed Mathlib revision fc4f59e577feb1a4956671bc04ac18aaaf8cd842; after successful decompression, deleted all 9117 downloaded .ltar archives. Ran the unchanged handed source through node tools/check-lean.mjs lean/PEqualNP/Outside/L_meta_765.lean ../statement.txt check from the cloned repository root, using a writable scratch TMPDIR. It ended REJECTED (does-not-compile). Direct Lean diagnostics identified exactly two errors: ofFn_getD left an arbitrary-index lookup into the expanded six-element list unproved, and ofFn_getD_ge failed to apply its out-of-range lookup fact after that same list expansion. Repaired ofFn_getD with simp only using List.getD_eq_getElem?_getD, List.getElem?_ofFn, dite_eq_left, and Option.getD_some. Repaired ofFn_getD_ge with simp only using the explicit none lookup fact and Option.getD_none. This prevents unrestricted simplification from expanding List.ofFn first. Also replaced deprecated if_pos/if_neg with ite_eq_left/ite_eq_right and removed two unreachable fallback branches in key. The original dep case analysis and small pigeonhole via omega needed no changes and are checked. Budgets below two are excluded by the three disjoint input pairs; budgets at least two use L153 at k = 4 and L112 exactly as the posted sketch requests. The final theorem statement is byte-for-byte the posted statement; its fully qualified declaration is last. All helpers stay in the file's own namespace. Direct Lean compilation of the repaired file exited 0 without diagnostics. The original project checker was rerun with the same command, exited 0, and ended ACCEPTED (check): PEqualNP.Outside.L_meta_765; axioms [propext, Quot.sound, Classical.choice]; kernel re-checked 1546 constants. The checker's MANIFEST hashes the returned source as SHA-256 19a4b75cedf8452ff0ba00d50a2a8cf12e8d0c008975bceda7001c725f7410c9, which was independently matched against source in this result. The main-commit outside-guard gap, imports/plain-file/own-namespace, and import-closure commands all passed; the closure contains no outside-written dependencies. No project build configuration or existing project source was edited. No unresolved Lean error or missing lemma remains. This is the local checker verdict, not a claim of a maintainer check or merge."
}
