import Mathlib.Data.Real.Basicimport Mathlib.Tactic.NormNumimport Mathlib.Tactic.Ringimport Mathlib.Tactic.Linarithimport Mathlib.Tactic.Positivityimport Mathlib.Data.Nat.Choose.Basicnamespace Bruhat6def lowerWord : List Nat := [2,3,4,2,3,0]def upperWord : List Nat := [2,3,4,0,1,2,3]def lowerRow : List Nat := [1,81,512,592,131,3]def upperRow : List Nat := [1,698,13492,44537,34836,6086,135]def exchange {α : Type} [Inhabited α] (x : List α) (i j : Nat) : List α :=(x.set i x[j]!).set j x[i]!def permutation (w : List Nat) := w.foldl (fun x i => exchange x i (i+1)) (List.range 6)def inversions (w : List Nat) : Nat :=((List.range 6).map (fun i => ((List.range 6).filter (fun j => i < j && w[i]! > w[j]!)).length)).foldl (·+·) 0theorem strong_cover_data :permutation lowerWord = [1,0,4,5,3,2] ∧ permutation upperWord = [1,3,4,5,0,2] ∧exchange (permutation lowerWord) 1 4 = permutation upperWord ∧inversions (permutation lowerWord) = lowerWord.length ∧inversions (permutation upperWord) = upperWord.length ∧upperWord.length = lowerWord.length + 1 := by decidedef keyEval (j : Nat) : List Nat → List Int → Int| [], x => x[0]!^(5*j) * x[1]!^(4*j) * x[2]!^(3*j) * x[3]!^(2*j) * x[4]!^j| i::w, x =>(x[i]! * keyEval j w x - x[i+1]! * keyEval j w (exchange x i (i+1))) /(x[i]! - x[i+1]!)def modulus : Nat := 2^64def specialized (w : List Nat) (j : Nat) : Int :=(keyEval j w ((List.range 6).map fun i => (1+(i+1)*modulus : Nat))) % (modulus : Int)def predicted (row : List Nat) (d j : Nat) :=((List.range row.length).map (fun h => if h ≤ j then row[h]! * (j+d-h).choose d else 0)).foldl (·+·) 0def checks (w row : List Nat) : Bool :=(List.range (w.length+2)).all fun j =>(2*(15*j+1)^w.length < modulus) &&(2*predicted row w.length j < modulus) &&(specialized w j == (predicted row w.length j : Int))set_option maxRecDepth 100000 inset_option maxHeartbeats 0 intheorem coefficient_transcripts : checks lowerWord lowerRow ∧ checks upperWord upperRow := by decidenoncomputable def P (x : ℝ) :=1 + x*(81 + x*(512 + x*(592 + x*(131 + x*3))))noncomputable def Q (x : ℝ) :=1 + x*(698 + x*(13492 + x*(44537 + x*(34836 + x*(6086 + x*135)))))/-- Alternating real linear factors in degrees five and six, with positive leading coefficients. -/def Interlaces56 (f g : ℝ → ℝ) : Prop :=∃ (b₀ b₁ b₂ b₃ b₄ b₅ a₀ a₁ a₂ a₃ a₄ k l : ℝ),b₀ ≤ a₀ ∧ a₀ ≤ b₁ ∧ b₁ ≤ a₁ ∧ a₁ ≤ b₂ ∧ b₂ ≤ a₂ ∧ a₂ ≤ b₃ ∧b₃ ≤ a₃ ∧ a₃ ≤ b₄ ∧ b₄ ≤ a₄ ∧ a₄ ≤ b₅ ∧ 0 < k ∧ 0 < l ∧(∀ x, f x = k*(x-a₀)*(x-a₁)*(x-a₂)*(x-a₃)*(x-a₄)) ∧(∀ x, g x = l*(x-b₀)*(x-b₁)*(x-b₂)*(x-b₃)*(x-b₄)*(x-b₅))theorem Q_positive_left (x : ℝ) (hx : x ≤ -116/3) : 0 < Q x := bylet u := -116 - 3*xhave hu : 0 ≤ u := by dsimp [u]; linarithhave h : (729:ℝ)*Q x =338723068929 + u*(2392665031554 + u*(106561375584 + u*(1901895357 +u*(16972284 + u*(75702 + u*135))))) := by dsimp [Q,u]; ringhave hpos : (0:ℝ) < 338723068929 + u*(2392665031554 + u*(106561375584 +u*(1901895357 + u*(16972284 + u*(75702 + u*135))))) := by positivitylinarith only [h,hpos]theorem numerators_do_not_interlace : ¬ Interlaces56 P Q := byrintro ⟨b₀,b₁,b₂,b₃,b₄,b₅,a₀,a₁,a₂,a₃,a₄,k,l,h₀,h₁,h₂,h₃,h₄,h₅,h₆,h₇,h₈,_,hk,_,hp,hq⟩have hzero : Q b₀ = 0 := by simpa using hq b₀have hleft : (-116:ℝ)/3 < b₀ := byby_contra! hexact (ne_of_gt (Q_positive_left b₀ h)) hzerolet r : ℝ := -116/3have j₀ : 0 < a₀-r := by dsimp [r]; linarithhave j₁ : 0 < a₁-r := by dsimp [r]; linarithhave j₂ : 0 < a₂-r := by dsimp [r]; linarithhave j₃ : 0 < a₃-r := by dsimp [r]; linarithhave j₄ : 0 < a₄-r := by dsimp [r]; linarithhave hprod : 0 < k*(a₀-r)*(a₁-r)*(a₂-r)*(a₃-r)*(a₄-r) := by positivityhave hneg : P r = -(k*(a₀-r)*(a₁-r)*(a₂-r)*(a₃-r)*(a₄-r)) := byrw [hp]; ringhave hval : 0 < P r := by norm_num [P,r]linarith only [hprod,hneg,hval]noncomputable def rowAt (row : List Nat) (x : ℝ) :=row.foldr (fun (a : Nat) (s : ℝ) => (a:ℝ)+x*s) 0def ReducedSix (w : List Nat) : Prop :=(w.all (fun i => i < 5)) ∧ inversions (permutation w) = w.length/-- A restricted universal consequence of Conjecture 6.4, negated by the witness.The interpretation of the finite coefficient transcript uses the degree andmagnitude bounds described in the accompanying proof. -/theorem not_every_certified_cover_interlaces :¬ (∀ (u v p q : List Nat), ReducedSix u → ReducedSix v →(∃ i j : Fin 6, exchange (permutation u) i j = permutation v) →v.length = u.length+1 → checks u p → checks v q →p.length = 6 → q.length = 7 → Interlaces56 (rowAt p) (rowAt q)) := byintro hhave bad := h lowerWord upperWord lowerRow upperRow (by unfold ReducedSix; decide) (by unfold ReducedSix; decide)⟨1,4,by decide⟩ (by decide) coefficient_transcripts.1 coefficient_transcripts.2 rfl rflhave hp : rowAt lowerRow = P := by funext x; simp [rowAt,lowerRow,P]have hq : rowAt upperRow = Q := by funext x; simp [rowAt,upperRow,Q]rw [hp,hq] at badexact numerators_do_not_interlace badend Bruhat6#print axioms Bruhat6.not_every_certified_cover_interlaces