Lean / Reader
Lean reader

RealProof.lean

71 lines9 declarationsno sorryimports Bond8 Mathlib.Algebra.Polynomial.Splits Mathlib.Algebra.Polynomial.Derivative Mathlib.Data.Real.Basic Mathlib.Tactic.Ring Mathlib.Tactic.NormNum +1

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports Bond8, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import Bond8
  2. import Mathlib.Algebra.Polynomial.Splits
  3. import Mathlib.Algebra.Polynomial.Derivative
  4. import Mathlib.Data.Real.Basic
  5. import Mathlib.Tactic.Ring
  6. import Mathlib.Tactic.NormNum
  7. import Mathlib.Tactic.Linarith
  8. namespace Bond8
  9. open Polynomial
  10. noncomputable def realPoly : List Int → ℝ[X]
  11. | [] => 0
  12. | a::as => C (a : ℝ) + X * realPoly as
  13. noncomputable def lag (p : ℝ[X]) (u : ℝ) : ℝ :=
  14. p.derivative.eval u ^ 2 - p.eval u * p.derivative.derivative.eval u
  15. private theorem lag_mul (p q : ℝ[X]) (u : ℝ) :
  16. lag (p*q) u = (p.eval u)^2 * lag q u + (q.eval u)^2 * lag p u := by
  17. simp only [lag, derivative_mul, derivative_add, eval_mul, eval_add]
  18. ring
  19. private theorem lag_nonnegative (p : ℝ[X]) (u : ℝ) (hp : p.Splits (RingHom.id ℝ)) :
  20. 0 ≤ lag p u := by
  21. obtain ⟨s,h⟩ := (splits_iff_exists_multiset _).1 hp
  22. simp only [map_id, RingHom.id_apply] at h
  23. have positive : ∀ l : Multiset ℝ, 0 ≤ lag ((l.map (fun r : ℝ => X - C r)).prod) u := by
  24. intro l
  25. induction l using Multiset.induction_on with
  26. | empty => simp [lag]
  27. | cons a l ih =>
  28. rw [Multiset.map_cons, Multiset.prod_cons, lag_mul]
  29. have lin : lag (X-C a) u = 1 := by simp [lag]
  30. rw [lin, mul_one]
  31. exact add_nonneg (mul_nonneg (sq_nonneg _) ih) (sq_nonneg _)
  32. conv_rhs => rw [h]
  33. rw [lag_mul]
  34. have hc : lag (C p.leadingCoeff) u = 0 := by simp [lag]
  35. rw [hc,mul_zero,add_zero]
  36. exact mul_nonneg (sq_nonneg _) (positive s)
  37. theorem witness_does_not_split : ¬ (realPoly difference).Splits (RingHom.id ℝ) := by
  38. intro h
  39. have bad := lag_nonnegative _ (-3/2) h
  40. rw [coefficients_correct] at bad
  41. norm_num [realPoly,lag,derivative_mul,derivative_add] at bad
  42. -- Restrict a universal spanning-pair assertion to disjoint connected components
  43. -- of sizes 3 and 5. Proposition 2.2 of the source gives the component product.
  44. def valid (n : Nat) (g : Graph) : Prop :=
  45. (g.all (fun e => decide (e.1 < n ∧ e.2 < n ∧ e.1 ≠ e.2))) = true ∧
  46. connected g (List.range n) = true
  47. def contained (a b : Graph) : Prop := a.all b.contains = true
  48. def componentDifference (a b h k : Graph) : List Int :=
  49. List.zipWith (·-·) (product (coeffs 3 a) (coeffs 5 b))
  50. (product (coeffs 3 h) (coeffs 5 k))
  51. theorem not_all_spanning_pairs_split :
  52. ¬ (∀ a b h k : Graph, valid 3 a → valid 5 b → valid 3 h → valid 5 k →
  53. contained h a → contained k b →
  54. (realPoly (componentDifference a b h k)).Splits (RingHom.id ℝ)) := by
  55. intro allPairs
  56. apply witness_does_not_split
  57. apply allPairs triangle chorded path cycle <;>
  58. first | (unfold valid; constructor <;> decide) | (unfold contained; decide)
  59. end Bond8