{
 "unit": "L-meta-27129",
 "title": "A circuit finds minimum-rank raw-key parities for affine cyclic histories and counts the joint terminal matches",
 "level": null,
 "weight": 97,
 "state": "open",
 "file": "lean/PEqualNP/Outside/L_meta_27129.lean",
 "module": "PEqualNP.Outside.L_meta_27129",
 "imports": [
  "PEqualNP.Defs"
 ],
 "statement_sha256": "d0f18fa87b72eaf3055988b87f9399bcfad22fd272d1a6537a8bf703ac21d486",
 "proved": false,
 "lean": "import Mathlib\nimport PEqualNP.Defs\n\nnamespace PEqualNP.Outside.L_meta_27129\nend PEqualNP.Outside.L_meta_27129\n\ntheorem PEqualNP.Outside.L_meta_27129 : (∀ (k r t p h : Nat) (hk : 0 < k),\n  let F := ZMod 2\n  let W := Fin k → F\n  let ix := fun n : Nat => (⟨n % k, Nat.mod_lt _ hk⟩ : Fin k)\n  let rot := fun (s : Nat) (x : W) (j : Fin k) => x (ix (j.val+k-s % k))\n  let gap := fun (b : Bool) => if b then 2 else 1\n  let start := fun (b : Bool) => if b then 3 else 1\n  let feed := fun (b : Bool) (t : Nat) => if b then 3*(t+1)+1 else 2*t\n  let closed := fun (N : Nat) (watch : Bool → Nat → Fin k → Bool) =>\n    ∀ (b : Bool) (t : Nat), t < N → ∀ j : Fin k, watch b (t+1) j = true →\n      ∀ e : Fin 3, let i := ix (j.val+e.val)\n        watch b t i = true ∧ watch b t (ix (i.val+gap b)) = true ∧\n        watch b t (ix (i.val+k-gap b % k)) = true\n  ∀ (watch : Bool → Nat → Fin k → Bool) (side : Fin t → Bool) (site : Fin t → Fin k),\n    closed (r+1) watch → (∀ i, watch (side i) (r+1) (site i) = true) →\n    let P := min k p\n    let H := min t h\n    let branch := if t ≤ h then 3 else\n      max 3 (((2 : Nat)^(H+1)-1)*(2^(min P (H+1)+1)-1))\n    let inputs := (2+2*(r+1))*k+t\n    ∃ (C : PEqualNP.CircuitLowerBounds.Circuit) (flag : Fin (inputs+C.size))\n      (maskWire : Fin P → Fin k → Fin (inputs+C.size))\n      (ans : Fin (k+1) → Fin (inputs+C.size)),\n      PEqualNP.MetaComplexity.FanInTwo C ∧ PEqualNP.MetaComplexity.NestedCover.ReadsBack inputs C ∧\n      C.output = flag.val ∧\n      C.size ≤ 2^60*(k+r+t+6)^22*((2*branch)^P + 2^(P+H)) ∧\n      ∀ (name : Bool → W) (c : Bool → Fin (r+1) → W) (target : Fin t → F),\n        let state := fun (b : Bool) (key : W) (n : Nat) =>\n          ((List.finRange (r+1)).take n).foldl (fun z tick =>\n            let y := fun i : Fin k =>\n              z i + z (ix (i.val+gap b)) + z (ix (i.val+k-gap b % k))\n            fun j : Fin k => y j + (1+y (ix (j.val+1)))*y (ix (j.val+2)) +\n              rot (feed b tick.val) key j + c b tick j) (rot (start b) key + name b)\n        let probe := fun (key : W) (i : Fin t) => state (side i) key (r+1) (site i)\n        let works := fun (Q : Fin P → W) =>\n          let D := {u : W // ∀ i, dotProduct (Q i) u = 0}\n          let polar := fun (a : W) (i : Fin t) (xy : D × D) =>\n            probe a i + probe (a+xy.1.val) i + probe (a+xy.2.val) i +\n              probe (a+xy.1.val+xy.2.val) i\n          (∀ (a : W) (b : Bool) (n : Nat), n ≤ r → ∀ j : Fin k, watch b n j = true →\n            ∀ x y : D, state b a n j + state b (a+x.val) n j + state b (a+y.val) n j +\n              state b (a+x.val+y.val) n j = 0) ∧\n          (∀ a : W, Module.finrank F (Submodule.span F (Set.range (polar a))) ≤ h)\n        let price := fun Q : Fin P → W => Module.finrank F (Submodule.span F (Set.range Q))\n        let pack := fun w : W => List.ofFn (fun j : Fin k => decide (w j ≠ 0))\n        let bits := pack (name false) ++ pack (name true) ++\n          (List.ofFn (fun i => pack (c false i))).flatten ++\n          (List.ofFn (fun i => pack (c true i))).flatten ++\n          List.ofFn (fun i : Fin t => decide (target i ≠ 0))\n        let wire := fun i : Fin (inputs+C.size) => (C.wires bits).getD i.val false\n        let chosen := fun a b => (if wire (maskWire a b) then 1 else 0 : F)\n        let count := ((Finset.univ : Finset W).filter (fun key => ∀ i, probe key i = target i)).card\n        (wire flag = true ↔ ∃ Q : Fin P → W, works Q) ∧\n          (wire flag = true → works chosen ∧ ∀ Q : Fin P → W, works Q → price chosen ≤ price Q) ∧\n          (∀ i : Fin (k+1), wire (ans i) = ((if wire flag then count else 0).testBit i.val))) := by\n  intro k r t p h hk\n  sorry\n",
 "lean_sha256": "90b370c7963bd2b30542d11864903f1ef18fe0ac69e09e506d4569bac878a0ba",
 "build": {
  "command": "lake build PEqualNP.Outside.L_meta_27129",
  "exit": 0,
  "seconds": 135,
  "note": "skeleton with sorry; not a proof"
 },
 "axioms": [
  "propext",
  "sorryAx",
  "Classical.choice",
  "Quot.sound"
 ],
 "upstream_commit": "a0fb543a724e744b99ee2816a5e20369bf855e86",
 "approach": "Took L-meta-27129 (step state open, reason paused_dead). Cloned pequalnp-proofs at a0fb543 and got the Lean 4.36/Mathlib cache. A skeleton with the exact statement elaborates: lake build exits 0, with only the expected sorry warning, in about 135 s including Defs. Small cases: a Python model of the round function shows the round-1 state is affine in the key only for k=1 and k=3. There the linear layer collapses, y is the same at every cell, and (1+y)y=0. For k=2,4,5 (random name/c, both sides) no cell is affine. So for r>=1 an empty Q (P=0) fails, and the circuit must really search for a minimum-rank Q. When P=k, Q = the standard basis gives D={0} and always works, so the flag is constantly true but the minimum price still has to be computed. With r=0, condition 1 holds trivially and the polar is a key-independent bilinear form. Then the count reduces to 2^t signed Gauss sums of quadratic forms, the method of sibling L_meta_25940. Where it broke: the closest proved sibling, L_meta_25940, is the easier variant where the key directions gen are given as circuit inputs. Its proof (Scheduled circuits, Gaussian elimination, Quad Gauss sums, counting) is a 354,548-byte file. This unit also needs an in-circuit search over Q, minimum-price selection and maskWire outputs. Only PEqualNP.Defs may be imported, so that machinery cannot be imported, and the delivered file is capped at 40,000 characters, so it cannot be copied in either. The site itself estimates 280 minutes. Not proved: no complete proof could be written and checked within the 75-minute limit and the size cap.",
 "reason": "out_of_time",
 "skipped": [
  {
   "id": "L-meta-32062",
   "state": "not_open"
  },
  {
   "id": "L-meta-33671",
   "state": "leased"
  }
 ]
}