{
 "unit": "L-pcx-407",
 "title": "The accuracy budget for graph pigeonhole clause search under correlated sources with bounded neighboring mass ratios",
 "level": null,
 "weight": 100,
 "state": "open",
 "file": "lean/PEqualNP/Outside/L_pcx_407.lean",
 "module": "PEqualNP.Outside.L_pcx_407",
 "imports": [
  "PEqualNP.Defs"
 ],
 "statement_sha256": "4714e1334c59fee69ab2d8eddfc3f02c23c2fbb8e24b9b9dbe40ee6ad7560bcf",
 "proved": false,
 "lean": "import Mathlib\nimport PEqualNP.Defs\n\nnamespace PEqualNP.Outside.L_pcx_407\n\nopen Finset PEqualNP.Expanders\n\n/-- The path graph: pigeon `i` may sit in hole `i` or hole `i-1`. Every proper subfamily of its\npigeon clauses is satisfiable, so it has no small unsatisfiable core. -/\ndef pathG (n : ℕ) : BipGraph (n+1) n :=\n  fun i => univ.filter (fun j : Fin n => j.val = i.val ∨ j.val + 1 = i.val)\n\nlemma pathG_left (n : ℕ) : LeftDegLe (pathG n) 2 := by\n  intro i\n  unfold pathG\n  rw [filter_or]\n  refine (card_union_le _ _).trans ?_\n  have h1 : (univ.filter (fun j : Fin n => j.val = i.val)).card ≤ 1 := by\n    rw [card_le_one]\n    intro a ha b hb\n    simp only [mem_filter, mem_univ, true_and] at ha hb\n    exact Fin.ext (by omega)\n  have h2 : (univ.filter (fun j : Fin n => j.val + 1 = i.val)).card ≤ 1 := by\n    rw [card_le_one]\n    intro a ha b hb\n    simp only [mem_filter, mem_univ, true_and] at ha hb\n    exact Fin.ext (by omega)\n  omega\n\nlemma pathG_right (n : ℕ) : RightDegLe (pathG n) 2 := by\n  intro j\n  have e : rightNbrs (pathG n) j =\n      univ.filter (fun i : Fin (n+1) => j.val = i.val ∨ j.val + 1 = i.val) := by\n    ext i\n    simp [rightNbrs, pathG]\n  rw [e, filter_or]\n  refine (card_union_le _ _).trans ?_\n  have h1 : (univ.filter (fun i : Fin (n+1) => j.val = i.val)).card ≤ 1 := by\n    rw [card_le_one]\n    intro a ha b hb\n    simp only [mem_filter, mem_univ, true_and] at ha hb\n    exact Fin.ext (by omega)\n  have h2 : (univ.filter (fun i : Fin (n+1) => j.val + 1 = i.val)).card ≤ 1 := by\n    rw [card_le_one]\n    intro a ha b hb\n    simp only [mem_filter, mem_univ, true_and] at ha hb\n    exact Fin.ext (by omega)\n  omega\n\nvariable {V : Type} [Fintype V] [DecidableEq V]\n\ndef flip (v : V) (x : V → Bool) : V → Bool := Function.update x v (!(x v))\n\nomit [Fintype V] in\nlemma flip_flip (v : V) (x : V → Bool) : flip v (flip v x) = x := by\n  funext u\n  by_cases h : u = v\n  · subst h; simp [flip]\n  · simp [flip, h]\n\nomit [Fintype V] in\nlemma flip_same (v : V) (x : V → Bool) : flip v x v = !(x v) := by simp [flip]\n\nomit [Fintype V] in\nlemma flip_other (v : V) (x : V → Bool) {u : V} (h : u ≠ v) : flip v x u = x u := by\n  simp [flip, h]\n\n/-- One pinned coordinate costs a factor `R` against the neighbouring half. -/\nlemma flip_sum (μ : (V → Bool) → ℝ) (R : ℝ)\n    (hsm : ∀ x v, μ x ≤ R * μ (Function.update x v (!(x v))))\n    (a : V → Bool) (P : Finset V) (v : V) (hv : v ∉ P) :\n    ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v ≠ a v), μ x ≤\n      R * ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v = a v), μ x := by\n  rw [Finset.mul_sum]\n  calc ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v ≠ a v), μ x\n      ≤ ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v ≠ a v),\n          R * μ (flip v x) := Finset.sum_le_sum fun x _ => hsm x v\n    _ = _ := by\n        apply Finset.sum_nbij' (flip v) (flip v)\n        · intro x hx\n          simp only [mem_filter, mem_univ, true_and] at hx ⊢\n          refine ⟨fun u hu => ?_, ?_⟩\n          · rw [flip_other v x (fun h => hv (h ▸ hu))]; exact hx.1 u hu\n          · rw [flip_same]\n            have := hx.2\n            revert this\n            cases x v <;> cases a v <;> simp\n        · intro x hx\n          simp only [mem_filter, mem_univ, true_and] at hx ⊢\n          refine ⟨fun u hu => ?_, ?_⟩\n          · rw [flip_other v x (fun h => hv (h ▸ hu))]; exact hx.1 u hu\n          · rw [flip_same, hx.2]\n            cases a v <;> simp\n        · intro x _; exact flip_flip v x\n        · intro x _; exact flip_flip v x\n        · intro x _; rfl\n\n/-- Subcube mass: under a source whose neighbouring masses differ by a factor at most `R`,\npinning the coordinates in `P` keeps at least a `(R+1)^(-|P|)` fraction of the mass. -/\nlemma pin_mass (μ : (V → Bool) → ℝ) (R : ℝ) (hR : 0 ≤ R) (hμ0 : ∀ x, 0 ≤ μ x)\n    (hsm : ∀ x v, μ x ≤ R * μ (Function.update x v (!(x v))))\n    (a : V → Bool) (P : Finset V) :\n    ∑ x, μ x ≤ (R + 1) ^ P.card *\n      ∑ x ∈ univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u), μ x := by\n  induction P using Finset.induction_on with\n  | empty => simp\n  | insert v P hv ih =>\n    rw [card_insert_of_notMem hv]\n    have hsplit : ∑ x ∈ univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u), μ x =\n        ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v = a v), μ x +\n        ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v ≠ a v), μ x := by\n      rw [← Finset.sum_filter_add_sum_filter_not\n        (univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u)) (fun x => x v = a v)]\n      simp only [Finset.filter_filter]\n    have hins : univ.filter (fun x : V → Bool => ∀ u ∈ insert v P, x u = a u) =\n        univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v = a v) := by\n      ext x\n      simp only [mem_filter, mem_univ, true_and, mem_insert, forall_eq_or_imp]\n      tauto\n    have hf := flip_sum μ R hsm a P v hv\n    have hnn : 0 ≤ ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v = a v), μ x :=\n      Finset.sum_nonneg fun x _ => hμ0 x\n    rw [hins]\n    calc ∑ x, μ x ≤ (R + 1) ^ P.card *\n          ∑ x ∈ univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u), μ x := ih\n      _ ≤ (R + 1) ^ P.card * ((R + 1) *\n          ∑ x ∈ univ.filter (fun x : V → Bool => (∀ u ∈ P, x u = a u) ∧ x v = a v), μ x) := by\n          apply mul_le_mul_of_nonneg_left _ (pow_nonneg (by linarith) _)\n          rw [hsplit]; linarith\n      _ = _ := by rw [pow_succ, mul_assoc]\n\n/-- Consequence for accuracy: if the set of failures contains the subcube pinned on `P` and\n`(R+1)^|P| < 2^h`, no smooth source is `2^-h` accurate. This is the capacity branch of the\nlower bound. -/\nlemma not_accurate (μ : (V → Bool) → ℝ) (R h : ℕ) (hμ0 : ∀ x, 0 ≤ μ x) (hpos : 0 < ∑ x, μ x)\n    (hsm : ∀ x v, μ x ≤ (R : ℝ) * μ (Function.update x v (!(x v))))\n    (a : V → Bool) (P : Finset V) (bad : Finset (V → Bool))\n    (hbad : ∀ x : V → Bool, (∀ u ∈ P, x u = a u) → x ∈ bad)\n    (hlt : (R + 1) ^ P.card < 2 ^ h) :\n    ¬ ((2 : ℝ) ^ h * (∑ x ∈ bad, μ x) ≤ ∑ x, μ x) := by\n  intro hacc\n  have h1 := pin_mass μ (R : ℝ) (Nat.cast_nonneg R) hμ0 hsm a P\n  have h2 : ∑ x ∈ univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u), μ x ≤ ∑ x ∈ bad, μ x := by\n    apply Finset.sum_le_sum_of_subset_of_nonneg\n    · intro x hx\n      rw [mem_filter] at hx\n      exact hbad x hx.2\n    · intro x _ _; exact hμ0 x\n  have hb : 0 < ∑ x ∈ bad, μ x := by\n    by_contra hneg\n    have h0 : ∑ x ∈ univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u), μ x ≤ 0 := by linarith\n    have : (((R : ℝ) + 1) ^ P.card) *\n        ∑ x ∈ univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u), μ x ≤ 0 :=\n      mul_nonpos_of_nonneg_of_nonpos (by positivity) h0\n    linarith\n  have hlt' : ((R : ℝ) + 1) ^ P.card < (2 : ℝ) ^ h := by exact_mod_cast hlt\n  have h3 : ((R : ℝ) + 1) ^ P.card * ∑ x ∈ bad, μ x < (2 : ℝ) ^ h * ∑ x ∈ bad, μ x :=\n    mul_lt_mul_of_pos_right hlt' hb\n  have h4 : ((R : ℝ) + 1) ^ P.card *\n      ∑ x ∈ univ.filter (fun x : V → Bool => ∀ u ∈ P, x u = a u), μ x ≤\n      ((R : ℝ) + 1) ^ P.card * ∑ x ∈ bad, μ x :=\n    mul_le_mul_of_nonneg_left h2 (by positivity)\n  linarith\n\nend PEqualNP.Outside.L_pcx_407\n",
 "lean_sha256": "7f4ac43427dd5a4063f37839e4c568c9984e4af2e447e2e5cb56d1fbecf8dd25",
 "build": {
  "command": "lake build PEqualNP.Outside.L_pcx_407",
  "exit": 124,
  "seconds": 420
 },
 "axioms": [],
 "upstream_commit": "1d812430ac44fdcafedd4cc5a2405c3c1c0eb5cc",
 "approach": "Not proved. Read the row, Defs/Expanders, Defs/CircuitLowerBounds, Defs/ProofComplexity, NestedCoverCircuit.ReadsBack and siblings L_pcx_401 (2286 lines, same circuit model: region made affine by the AND/OR gates) and L_pcx_406 (378 lines, the syndrome lemma). Small cases by hand: (a) empty graph or any pigeon of degree 0 gives an empty pigeon clause, one clause is then exact search and the lower bound fails, so G needs minimum left degree 1; (b) the degree-1 graph (pigeon i to hole i, pigeon n to hole 0) has a 3-clause unsatisfiable core read from 2 bits, so the lower bound fails again; G must have no small unsatisfiable core. Chosen G: the path graph, pigeon i adjacent to holes i and i-1 (degrees at most 2); dropping any one pigeon clause leaves a satisfiable formula. (c) h=0 or b=0: both parts hold trivially with the empty circuit and picks on the two constant wires. (d) one message with k pigeon clauses and a product source biased R:1 to zero gives error about (R+1)^(-k), matching h of order L*k, so the stated scales look right; I found no counterexample. Plan: lower bound, capacity branch (B = sum of caps): fewer than n listed clauses have a common satisfying input, pin one literal per clause, the pinned subcube lies in the failure set and keeps a (R+1)^(-k) share of any smooth mass. Lower bound, T + max cap + flat branch: needs the affine-region argument of L_pcx_401 plus the syndrome lemma of L_pcx_406 re-proved inside this file. Upper bound: with C large, one of max cap, flat, T is at least a third of C*m; use a constant message listing clauses, or a parity-only circuit sending the tested rows into the flat, or a one-hot first-all-zero-row circuit XOR-encoded into S. Formalized and checked (no sorry): pathG with LeftDegLe 2 and RightDegLe 2; flip_sum; pin_mass (pinning P keeps a (R+1)^(-|P|) share of smooth mass); not_accurate (a pinned subcube inside the failure set with (R+1)^|P| < 2^h rules out 2^-h accuracy). Where it broke: time. The affine-region branch and the three circuit constructions are each hundreds to thousands of lines by the size of the siblings, and the file would also pass the 40,000 character limit. Machine notes: lake build of the module was stopped by my timeouts three times (exit 124) while Defs compiled and Mathlib loaded from a cold disk; the partial file then elaborated with lake env lean, exit 0 in 177 s, no errors. The lean field is that partial file: it has helper lemmas only and does not contain the final theorem, so no axiom check was run.",
 "reason": "out_of_time",
 "skipped": []
}