Lean / Reader
Lean reader

LiNesetrilYang36.lean

88 lines16 declarationsno sorryimports Std
  1. import Std
  2. /-! Li, Nešetřil and Yang, arXiv:2611.33681v1, §3.2, Problem 3.6.
  3. Finite simple graphs are edge lists on `Fin n`, with each edge listed once,
  4. smaller endpoint first. An orientation chooses a direction independently on
  5. each edge. An order is a permutation listed from least to greatest. -/
  6. namespace LongtailProofs.LiNesetrilYang36
  7. abbrev Edges (n : Nat) := List (Fin n × Fin n)
  8. def orientations {n} : Edges n → List (Edges n)
  9. | [] => [[]]
  10. | (u,v) :: es => (orientations es).flatMap fun t => [(u,v)::t, (v,u)::t]
  11. def insertEverywhere (x : α) : List α → List (List α)
  12. | [] => [[x]]
  13. | y :: ys => (x :: y :: ys) :: (insertEverywhere x ys).map (y :: ·)
  14. def orders : List α → List (List α)
  15. | [] => [[]]
  16. | x :: xs => (orders xs).flatMap (insertEverywhere x)
  17. /-- Is there a simple directed path of at most `fuel` more arcs from `cur` to
  18. `x`? `seen` contains cur and its predecessors. Only intermediate vertices
  19. need pass `internalOK`; the caller separately compares the two endpoints. -/
  20. def pathTo {n} (arcs : Edges n) (internalOK : Fin n → Bool) (x : Fin n) :
  21. Nat → Fin n → List (Fin n) → Bool
  22. | 0, cur, _ => cur == x
  23. | fuel+1, cur, seen => cur == x || arcs.any fun (u,v) =>
  24. u == cur && !seen.contains v && (v == x || internalOK v) &&
  25. pathTo arcs internalOK x fuel v (v :: seen)
  26. /-- `strong=false` selects weak reachability. `two=true` takes the union
  27. of outgoing and incoming paths before counting reachable endpoints. -/
  28. def reachable {n} (arcs : Edges n) (order : List (Fin n)) (k : Nat)
  29. (strong two : Bool) (y x : Fin n) : Bool :=
  30. let rank := order.idxOf
  31. let ok := fun v => decide (rank x ≤ rank v) && (!strong || decide (rank y < rank v))
  32. decide (rank x ≤ rank y) && (pathTo arcs ok x k y [y] ||
  33. (two && pathTo (arcs.map Prod.swap) ok x k y [y]))
  34. def directedNumber {n} (arcs : Edges n) (k : Nat) (strong two : Bool) : Nat :=
  35. let vs := List.finRange n
  36. ((orders vs).map fun order =>
  37. (vs.map fun y => vs.countP (reachable arcs order k strong two y)).foldl max 0).foldl min n
  38. def graphNumber {n} (edges : Edges n) (k : Nat) (strong : Bool) : Nat :=
  39. ((orientations edges).map fun d => directedNumber d k strong true).foldl max 0
  40. def halfUp (a : Nat) := (a+1)/2
  41. /-- The simultaneous-existence assertion of Problem 3.6. -/
  42. def Problem36 : Prop := ∀ (n : Nat) (edges : Edges n), edges.Nodup →
  43. (∀ e ∈ edges, e.1 < e.2) → ∀ k, 1 ≤ k → ∃ d ∈ orientations edges,
  44. directedNumber d k true false = halfUp (graphNumber edges k true) ∧
  45. directedNumber d k false false = halfUp (graphNumber edges k false)
  46. def p4 : Edges 4 := [(0,1), (1,2), (2,3)]
  47. set_option maxHeartbeats 5000000
  48. theorem enumeration_sizes : (orientations p4).Nodup ∧ (orientations p4).length = 8 ∧
  49. (orders (List.finRange 4)).Nodup ∧ (orders (List.finRange 4)).length = 24 := by decide
  50. /-- `p4` as an arc list is the coherent orientation 0 → 1 → 2 → 3. -/
  51. theorem coherent_weak : directedNumber p4 3 false true = 3 := by decide
  52. theorem graph_values : graphNumber p4 3 true = 2 ∧ graphNumber p4 3 false = 3 := by decide
  53. theorem plus_values : ∀ d ∈ orientations p4,
  54. directedNumber d 3 true false = 1 ∧ directedNumber d 3 false false = 1 := by
  55. have h : (orientations p4).all (fun d => decide (directedNumber d 3 true false = 1 ∧
  56. directedNumber d 3 false false = 1)) = true := by decide
  57. intro d hd
  58. exact of_decide_eq_true (List.all_eq_true.mp h d hd)
  59. theorem not_problem36 : ¬ Problem36 := by
  60. intro h
  61. have hlt : ∀ e ∈ p4, e.1 < e.2 := by simp [p4]
  62. obtain ⟨d, hd, _, hw⟩ := h 4 p4 (by decide) hlt 3 (by decide)
  63. rw [(plus_values d hd).2, graph_values.2] at hw
  64. exact (by decide : ¬ (1 = halfUp 3)) hw
  65. #print axioms graph_values
  66. #print axioms plus_values
  67. #print axioms not_problem36
  68. end LongtailProofs.LiNesetrilYang36