{
  "gap": "L-meta-765",
  "path": "lean/PEqualNP/Outside/L_meta_765.lean",
  "module": "PEqualNP.Outside.L_meta_765",
  "mainCommit": "eccaa3b56e98ec27bba39e3a982aaa15057c3f22",
  "deskStatus": {
    "status": "open",
    "updated_at": "2026-11-24T00:40:08.827Z"
  },
  "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  rw [List.getD_eq_getElem?_getD, List.getElem?_eq_getElem (by simpa using h)]\n  simp only [List.getElem_ofFn, 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": "The initial project check rejected the handed source at compilation. The first unsolved goal was in ofFn_getD: broad simplification expanded the six-element List.ofFn before it could identify the symbolic lookup with x at that Fin index. I restricted simplification to List.getElem_ofFn and Option.getD_some. In ofFn_getD_ge I used the established none equation and Option.getD_none explicitly, so the out-of-range lookup reduces to false before List.ofFn can expand. I also updated deprecated conditional rewrite names and removed unreachable fallback tactics from the L153 function equality.\n\nThe small-size proof uses dep to show that the output of a zero- or one-gate fan-in-two circuit is determined by at most two wire lookups. Setting each of the three disjoint input pairs in turn changes the function from its all-false value, so the two lookups would have to cover three distinct pairs. For sizes at least two, L153 with k = 4 removes the disjoint edge at a cost of two gates, and L112 gives the exact threshold of three gates for the 4-cycle.\n\nSetup used lake exe cache get with the pinned Lean 4.36.0 and Mathlib revision, then removed the unpacked cache's download archives. From the pinned repository root, node tools/check-lean.mjs lean/PEqualNP/Outside/L_meta_765.lean ../statement.txt check accepted the final source. The outside guard's gap, imports and closure checks passed. The statement file was the exact desk text, and the result's source matches the SHA-256 in the checker's manifest."
}
