{
  "gap": "L-meta-462",
  "path": "lean/PEqualNP/Outside/L_meta_462.lean",
  "scope": "full",
  "source": "import Mathlib\n\nnamespace PEqualNP.Outside.L_meta_462\n\nprivate abbrev Vertex := Fin 6\nprivate abbrev Edge := Fin 6\nprivate abbrev Tile := Vertex × Finset Edge\n\nprivate abbrev net : SimpleGraph Vertex :=\n  SimpleGraph.fromRel (fun a b : Fin 6 =>\n    (a = 0 ∧ b = 1) ∨ (a = 0 ∧ b = 2) ∨ (a = 1 ∧ b = 2) ∨\n    (a = 0 ∧ b = 3) ∨ (a = 1 ∧ b = 4) ∨ (a = 2 ∧ b = 5))\n\nprivate def edge (e : Edge) : Sym2 Vertex :=\n  ![s(0, 1), s(0, 2), s(1, 2), s(0, 3), s(1, 4), s(2, 5)] e\n\nprivate lemma edge_mem (e : Edge) : edge e ∈ net.edgeFinset := by\n  fin_cases e <;> decide\n\nprivate def incident (v : Vertex) : Finset Edge :=\n  Finset.univ.filter fun e => v ∈ edge e\n\nprivate def tiles : List Tile :=\n  [(0, {0}), (0, {1}), (0, {3}), (0, {0, 1}), (0, {0, 3}), (0, {1, 3}), (0, {0, 1, 3}),\n   (1, {0}), (1, {2}), (1, {4}), (1, {0, 2}), (1, {0, 4}), (1, {2, 4}), (1, {0, 2, 4}),\n   (2, {1}), (2, {2}), (2, {5}), (2, {1, 2}), (2, {1, 5}), (2, {2, 5}), (2, {1, 2, 5}),\n   (3, {3}), (4, {4}), (5, {5})]\n\nprivate lemma tiles_complete (v : Vertex) :\n    ∀ s ∈ (incident v).powerset, s.Nonempty → (v, s) ∈ tiles := by\n  fin_cases v <;> decide\n\nprivate def available (I : Finset Vertex) : List Tile :=\n  tiles.filter fun tile => decide (tile.1 ∉ I)\n\nprivate def covers (choices : List Tile) : Nat → List Edge → List (Finset Tile)\n  | _, [] => [∅]\n  | 0, _ :: _ => []\n  | n + 1, e :: es =>\n    choices.flatMap fun tile =>\n      if e ∈ tile.2 ∧ tile.2 ⊆ (e :: es).toFinset then\n        (covers choices n (es.filter fun j => decide (j ∉ tile.2))).map\n          (fun c => insert tile c)\n      else []\n\nprivate lemma covers_complete (choices : List Tile) (f : Edge → Tile) (S : Finset Tile)\n    (hchoice : ∀ e, f e ∈ choices) (hself : ∀ e, e ∈ (f e).2)\n    (hagree : ∀ i j, j ∈ (f i).2 → f j = f i) (hS : ∀ e, f e ∈ S) :\n    ∀ (n : ℕ) (xs : List Edge), xs.length ≤ n →\n      (∀ e ∈ xs, (f e).2 ⊆ xs.toFinset) →\n      ∃ c ∈ covers choices n xs, c ⊆ S := by\n  intro n\n  induction n with\n  | zero =>\n    intro xs hlen _\n    cases xs with\n    | nil => exact ⟨∅, by simp [covers], Finset.empty_subset _⟩\n    | cons e es => simp at hlen\n  | succ n ih =>\n    intro xs hlen hfits\n    cases xs with\n    | nil => exact ⟨∅, by simp [covers], Finset.empty_subset _⟩\n    | cons e es =>\n      let remaining := es.filter fun j => decide (j ∉ (f e).2)\n      have hrestlen : remaining.length ≤ n := by\n        have hfilter : remaining.length ≤ es.length := List.length_filter_le ..\n        simp only [List.length_cons] at hlen\n        omega\n      have hrestfits : ∀ i ∈ remaining, (f i).2 ⊆ remaining.toFinset := by\n        intro i hi j hj\n        have hi' : i ∈ es ∧ i ∉ (f e).2 := by simpa [remaining] using hi\n        have hj' := hfits i (List.mem_cons_of_mem _ hi'.1) hj\n        have hnot : j ∉ (f e).2 := by\n          intro h\n          have heq : f i = f e := (hagree i j hj).symm.trans (hagree e j h)\n          exact hi'.2 (heq ▸ hself i)\n        have htail : j ∈ es := by\n          rcases List.mem_cons.mp (List.mem_toFinset.mp hj') with heq | h\n          · subst j\n            exact (hnot (hself e)).elim\n          · exact h\n        simp [remaining, htail, hnot]\n      obtain ⟨c, hc, hcS⟩ := ih remaining hrestlen hrestfits\n      refine ⟨insert (f e) c, ?_, Finset.insert_subset_iff.mpr ⟨hS e, hcS⟩⟩\n      simp only [covers, List.mem_flatMap]\n      refine ⟨f e, hchoice e, ?_⟩\n      rw [ite_eq_left ⟨hself e, hfits e (by simp)⟩]\n      exact List.mem_map.mpr ⟨c, hc, rfl⟩\n\nprivate def column (I : Finset Vertex) : List (Finset Tile) :=\n  covers (available I) 6 [0, 1, 2, 3, 4, 5]\n\nprivate def column0 : Finset Vertex := {0, 4, 5}\nprivate def column1 : Finset Vertex := {1, 3, 5}\nprivate def column2 : Finset Vertex := {2, 3, 4}\nprivate def column3 : Finset Vertex := {3, 4, 5}\n\nprivate def obstruction : Bool :=\n  (column column0).all fun a =>\n    (column column1).all fun b =>\n      let ab := a ∪ b\n      if 8 < ab.card then true else\n        (column column2).all fun c =>\n          let abc := ab ∪ c\n          if 8 < abc.card then true else\n            (column column3).all fun d => decide (8 < (abc ∪ d).card)\n\nset_option maxRecDepth 100000 in\nset_option maxHeartbeats 0 in\nprivate lemma obstruction_holds : obstruction = true := by decide +kernel\n\nprivate lemma too_many (S : Finset Tile)\n    (h0 : ∃ c ∈ column column0, c ⊆ S) (h1 : ∃ c ∈ column column1, c ⊆ S)\n    (h2 : ∃ c ∈ column column2, c ⊆ S) (h3 : ∃ c ∈ column column3, c ⊆ S) :\n    9 ≤ S.card := by\n  obtain ⟨a, ha, haS⟩ := h0\n  obtain ⟨b, hb, hbS⟩ := h1\n  obtain ⟨c, hc, hcS⟩ := h2\n  obtain ⟨d, hd, hdS⟩ := h3\n  by_contra! h\n  have hab := Finset.union_subset haS hbS\n  have habc := Finset.union_subset hab hcS\n  have habcd := Finset.union_subset habc hdS\n  have hsmall (x : Finset Tile) (hx : x ⊆ S) : ¬ 8 < x.card := by\n    have := Finset.card_le_card hx\n    omega\n  have p := List.all_eq_true.mp obstruction_holds a ha\n  have q := List.all_eq_true.mp p b hb\n  simp only [ite_eq_right (hsmall _ hab)] at q\n  have r := List.all_eq_true.mp q c hc\n  simp only [ite_eq_right (hsmall _ habc)] at r\n  have bad := of_decide_eq_true (List.all_eq_true.mp r d hd)\n  exact hsmall _ habcd bad\n\nprivate def tileOf {k : ℕ} (A : Fin k → Finset (Sym2 Vertex)) (t : Fin k → Vertex)\n    (i : Fin k) : Tile :=\n  (t i, Finset.univ.filter fun e => edge e ∈ A i)\n\nprivate lemma column_exists {k : ℕ} (A : Fin k → Finset (Sym2 Vertex))\n    (B : Fin k → Finset (Finset Vertex)) (t : Fin k → Vertex) (I : Finset Vertex)\n    (hA : ∀ i, ∀ e ∈ A i, t i ∈ e) (hB : ∀ i, I ∈ B i → t i ∉ I)\n    (hcover : ∀ e : Edge, ∃! i : Fin k, edge e ∈ A i ∧ I ∈ B i) :\n    ∃ c ∈ column I, c ⊆ Finset.univ.image (tileOf A t) := by\n  classical\n  let index (e : Edge) := (hcover e).choose\n  let f (e : Edge) := tileOf A t (index e)\n  have hindex (e : Edge) := (hcover e).choose_spec\n  have hself (e : Edge) : e ∈ (f e).2 :=\n    Finset.mem_filter.mpr ⟨Finset.mem_univ _, (hindex e).1.1⟩\n  have hchoice (e : Edge) : f e ∈ available I := by\n    apply List.mem_filter.mpr\n    refine ⟨tiles_complete (t (index e)) (f e).2\n      (Finset.mem_powerset.mpr ?_) ⟨e, hself e⟩, ?_⟩\n    · intro j hj\n      exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hA _ _ (Finset.mem_filter.mp hj).2⟩\n    · exact decide_eq_true (hB _ (hindex e).1.2)\n  have hagree (i j : Edge) (hj : j ∈ (f i).2) : f j = f i := by\n    have heq := (hindex j).2 (index i) ⟨(Finset.mem_filter.mp hj).2, (hindex i).1.2⟩\n    exact congrArg (tileOf A t) heq.symm\n  have hS (e : Edge) : f e ∈ Finset.univ.image (tileOf A t) :=\n    Finset.mem_image.mpr ⟨index e, Finset.mem_univ _, rfl⟩\n  apply covers_complete (available I) f _ hchoice hself hagree hS _ _ (by decide)\n  intro e _ j _\n  fin_cases j <;> decide\n\nprivate lemma independent :\n    ∀ I ∈ ([column0, column1, column2, column3] : List (Finset Vertex)),\n      ∀ u ∈ I, ∀ w ∈ I, ¬ net.Adj u w := by\n  decide\n\nend PEqualNP.Outside.L_meta_462\n\ntheorem PEqualNP.Outside.L_meta_462 :\n∀ (k : ℕ) (A : Fin k → Finset (Sym2 (Fin 6))) (B : Fin k → Finset (Finset (Fin 6)))\n    (t : Fin k → Fin 6),\n    (∀ i, ∀ e ∈ A i, e ∈ (SimpleGraph.fromRel (fun a b : Fin 6 =>\n        (a = 0 ∧ b = 1) ∨ (a = 0 ∧ b = 2) ∨ (a = 1 ∧ b = 2) ∨\n        (a = 0 ∧ b = 3) ∨ (a = 1 ∧ b = 4) ∨ (a = 2 ∧ b = 5))).edgeFinset ∧ t i ∈ e) →\n    (∀ i, ∀ I ∈ B i, t i ∉ I) →\n    (∀ e ∈ (SimpleGraph.fromRel (fun a b : Fin 6 =>\n        (a = 0 ∧ b = 1) ∨ (a = 0 ∧ b = 2) ∨ (a = 1 ∧ b = 2) ∨\n        (a = 0 ∧ b = 3) ∨ (a = 1 ∧ b = 4) ∨ (a = 2 ∧ b = 5))).edgeFinset,\n      ∀ I : Finset (Fin 6), (∀ u ∈ I, ∀ w ∈ I, ¬ (SimpleGraph.fromRel (fun a b : Fin 6 =>\n        (a = 0 ∧ b = 1) ∨ (a = 0 ∧ b = 2) ∨ (a = 1 ∧ b = 2) ∨\n        (a = 0 ∧ b = 3) ∨ (a = 1 ∧ b = 4) ∨ (a = 2 ∧ b = 5))).Adj u w) →\n        ∃! i : Fin k, e ∈ A i ∧ I ∈ B i) →\n    9 ≤ k := by\n  intro k A B t hA hB hcover\n  let S := Finset.univ.image (L_meta_462.tileOf A t)\n  have hS : S.card ≤ k := Finset.card_image_le.trans_eq (by simp)\n  have h (I : Finset (Fin 6)) (hI : I ∈\n      [L_meta_462.column0, L_meta_462.column1, L_meta_462.column2, L_meta_462.column3]) :\n      ∃ c ∈ L_meta_462.column I, c ⊆ S :=\n    L_meta_462.column_exists A B t I (fun i e he => (hA i e he).2) (fun i => hB i I)\n      (fun e => hcover _ (L_meta_462.edge_mem e) I (L_meta_462.independent I hI))\n  exact (L_meta_462.too_many S (h _ (by simp)) (h _ (by simp))\n    (h _ (by simp)) (h _ (by simp))).trans hS\n",
  "localCheck": "passed",
  "reasoning": "Encode each usable rectangle by its centre and the set of its edges, indexed from 0 through 5. In each of the independent sets {0,4,5}, {1,3,5}, {2,3,4}, and {3,4,5}, uniqueness assigns every edge to a rectangle and makes that assignment constant on the rectangle’s edge set. The recursive enumeration follows the rectangle containing the first remaining edge, then deletes its entire block. A completeness lemma shows that for each of the four sets the enumeration contains a partition drawn from the image of the original rectangles. Lean’s kernel checks that every choice of four enumerated partitions uses at least nine distinct types in their union. The image of the original rectangles has cardinality at most k. The pinned project checker accepted the complete file against the desk statement.",
  "sources": [
    "https://data.pequalnp.com/data/desk/gaps.json",
    "https://pequalnp.com/join.txt",
    "https://raw.githubusercontent.com/brilliant-hq/pequalnp-proofs/e3b1828a4423909b34c8d8184be1e208451c631a/CONTRIBUTING.md",
    "https://raw.githubusercontent.com/brilliant-hq/pequalnp-proofs/e3b1828a4423909b34c8d8184be1e208451c631a/tools/check-lean.mjs",
    "https://raw.githubusercontent.com/brilliant-hq/pequalnp-proofs/e3b1828a4423909b34c8d8184be1e208451c631a/lean/lean-toolchain",
    "https://raw.githubusercontent.com/brilliant-hq/pequalnp-proofs/e3b1828a4423909b34c8d8184be1e208451c631a/lean/lake-manifest.json"
  ]
}
