← Visual paper

HardnessBilevel/Convex/Lemma219.lean

d1032f4c70da9b037605c2f444ce2450900e5a76 · GitHub

  1. import HardnessBilevel.Convex.Toolkit
  2. /-!
  3. # Lemma 2.19 (simplified gadget, blueprint §4.G.2) — id `t219.main`
  4. For a basic set `S = {x | P(x) = 0 ∧ ∀ j, 0 < Q_j(x)}` (`basicSet P Q`), lower variable `y : Unit ⊕ J → ℝ`
  5. (`t = y (inl ())`, `u j = y (inr j)`), box `gadY J = ℝ × [0,∞)^J` and
  6. * `gadQ P Q x y = (1 - t P(x))^2 + ∑ j (1 - Q_j(x) u_j)^2`,
  7. * `gadP P Q x y = (1 - t P(x)) * ∏ j (Q_j(x) u_j)`,
  8. the lower level is polynomial and convex, the box is unbounded (because of the free coordinate `t`, even if
  9. `J = ∅`), every argmin is nonempty, and `gadP` is **constant** on the argmin with value `1_S x`; hence
  10. `valueFun = pvalueFun = ↑(1_S x)` (`lemma219`, `lemma219_exists`).
  11. -/
  12. namespace Bilevel
  13. open Set MvPolynomial
  14. section Lemma219
  15. variable {n : ℕ} {J : Type*} [Fintype J]
  16. /-- The basic semialgebraic set `{x | P(x) = 0 ∧ ∀ j, 0 < Q_j(x)}`. -/
  17. def basicSet (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) : Set (Fin n → ℝ) :=
  18. {x | eval x P = 0 ∧ ∀ j, 0 < eval x (Q j)}
  19. /-- Lower-level objective `Q'` of the Lemma 2.19 gadget. -/
  20. noncomputable def gadQ (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) :
  21. (Fin n → ℝ) → (Unit ⊕ J → ℝ) → ℝ :=
  22. fun x y => (1 - y (Sum.inl ()) * eval x P) ^ 2 + ∑ j, (1 - eval x (Q j) * y (Sum.inr j)) ^ 2
  23. /-- Upper-level objective `P'` of the Lemma 2.19 gadget. -/
  24. noncomputable def gadP (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) :
  25. (Fin n → ℝ) → (Unit ⊕ J → ℝ) → ℝ :=
  26. fun x y => (1 - y (Sum.inl ()) * eval x P) * ∏ j, (eval x (Q j) * y (Sum.inr j))
  27. /-- The box `ℝ × [0,∞)^J` of the Lemma 2.19 gadget. -/
  28. def gadY (J : Type*) : Set (Unit ⊕ J → ℝ) :=
  29. Set.pi Set.univ (Sum.elim (fun _ => Set.univ) (fun _ => Set.Ici 0))
  30. theorem mem_argminSet_gadQ_iff (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ)
  31. (x : Fin n → ℝ) (y : Unit ⊕ J → ℝ) :
  32. y ∈ argminSet (gadQ P Q) (gadY J) x ↔
  33. (∀ t, (1 - eval x P * y (Sum.inl ())) ^ 2 ≤ (1 - eval x P * t) ^ 2) ∧
  34. ∀ j, 0 ≤ y (Sum.inr j) ∧
  35. ∀ u, 0 ≤ u → (1 - eval x (Q j) * y (Sum.inr j)) ^ 2 ≤ (1 - eval x (Q j) * u) ^ 2 := by
  36. let g : (Fin n → ℝ) → (Unit ⊕ J) → ℝ → ℝ := fun x =>
  37. Sum.elim (fun _ v => (1 - eval x P * v) ^ 2) (fun j v => (1 - eval x (Q j) * v) ^ 2)
  38. have hQ : gadQ P Q = fun x y => ∑ c, g x c (y c) := by
  39. funext x y
  40. simp [gadQ, g, Fintype.sum_sum_type, mul_comm]
  41. rw [hQ, gadY, argminSet_pi_sum]
  42. simp only [Set.mem_pi, Set.mem_univ, true_implies, Sum.forall, argminSet, Set.mem_ofPred_eq,
  43. Sum.elim_inl, Sum.elim_inr, g, Set.mem_Ici, true_and]
  44. exact ⟨fun ⟨h1, h2⟩ => ⟨h1 (), h2⟩, fun ⟨h1, h2⟩ => ⟨fun _ => h1, h2⟩⟩
  45. /-- Witness of a minimiser of the gadget. -/
  46. noncomputable def gadMin (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ)
  47. (x : Fin n → ℝ) : Unit ⊕ J → ℝ :=
  48. Sum.elim (fun _ => if eval x P = 0 then 0 else (eval x P)⁻¹)
  49. (fun j => if 0 < eval x (Q j) then (eval x (Q j))⁻¹ else 0)
  50. theorem gadMin_mem (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) (x : Fin n → ℝ) :
  51. gadMin P Q x ∈ argminSet (gadQ P Q) (gadY J) x := by
  52. rw [mem_argminSet_gadQ_iff]
  53. exact ⟨isMin_univ_witness _, fun j => isMin_Ici_witness _⟩
  54. theorem argminSet_gadQ_nonempty (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ)
  55. (x : Fin n → ℝ) : (argminSet (gadQ P Q) (gadY J) x).Nonempty :=
  56. ⟨_, gadMin_mem P Q x⟩
  57. /-- `t219.main`, core: `P'` is constant on the argmin, equal to `1_S x`. -/
  58. theorem gadP_eq_indicator (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ)
  59. {x : Fin n → ℝ} {y : Unit ⊕ J → ℝ} (hy : y ∈ argminSet (gadQ P Q) (gadY J) x) :
  60. gadP P Q x y = (basicSet P Q).indicator 1 x := by
  61. classical
  62. rw [mem_argminSet_gadQ_iff] at hy
  63. obtain ⟨h1, h2⟩ := hy
  64. have e1 := mul_eq_of_isMin_univ h1
  65. have e2 : ∀ j, eval x (Q j) * y (Sum.inr j) = if 0 < eval x (Q j) then 1 else 0 :=
  66. fun j => mul_eq_of_isMin_Ici (h2 j).1 (h2 j).2
  67. have hP : gadP P Q x y = (1 - (if eval x P = 0 then 0 else 1)) *
  68. ∏ j, (if 0 < eval x (Q j) then (1 : ℝ) else 0) := by
  69. simp only [gadP, e2, mul_comm (y (Sum.inl ())), e1]
  70. rw [hP]
  71. by_cases hx : x ∈ basicSet P Q
  72. · rw [Set.indicator_of_mem hx]
  73. obtain ⟨hx1, hx2⟩ := hx
  74. simp [hx1, hx2]
  75. · rw [Set.indicator_of_notMem hx]
  76. simp only [basicSet, Set.mem_ofPred_eq, not_and_or, not_forall] at hx
  77. rcases hx with hx | ⟨j, hj⟩
  78. · simp [hx]
  79. · rw [Finset.prod_eq_zero (Finset.mem_univ j) (by simp [hj]), mul_zero]
  80. theorem isPolyFun_gadQ (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) :
  81. IsPolyFun (gadQ P Q) := by
  82. unfold gadQ
  83. exact (((isPolyFun_const 1).sub ((isPolyFun_y (Sum.inl ())).mul
  84. (IsPolyFun.of_upper_only P))).pow 2).add
  85. (isPolyFun_finset_sum Finset.univ fun j _ => ((isPolyFun_const 1).sub
  86. ((IsPolyFun.of_upper_only (Q j)).mul (isPolyFun_y (Sum.inr j)))).pow 2)
  87. theorem isPolyFun_gadP (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) :
  88. IsPolyFun (gadP P Q) := by
  89. unfold gadP
  90. exact ((isPolyFun_const 1).sub ((isPolyFun_y (Sum.inl ())).mul
  91. (IsPolyFun.of_upper_only P))).mul
  92. (isPolyFun_finset_prod Finset.univ fun j _ =>
  93. (IsPolyFun.of_upper_only (Q j)).mul (isPolyFun_y (Sum.inr j)))
  94. theorem convexLower_gadQ (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) :
  95. ConvexLower (gadQ P Q) := fun x =>
  96. ((convexOn_sq_one_sub_mul_coord (eval x P) (Sum.inl ())).add
  97. (convexOn_finset_sum convex_univ Finset.univ fun j _ =>
  98. convexOn_sq_one_sub_mul_coord (eval x (Q j)) (Sum.inr j))).congr
  99. (fun y _ => by simp [gadQ, mul_comm])
  100. theorem isUnboundedBox_gadY (J : Type*) : IsUnboundedBox (gadY J) :=
  101. isUnboundedBox_sum_univ_Ici
  102. /-- **Lemma 2.19** (`t219.main`, simplified gadget). -/
  103. theorem lemma219 (P : MvPolynomial (Fin n) ℝ) (Q : J → MvPolynomial (Fin n) ℝ) :
  104. IsPolyFun (gadP P Q) ∧ IsPolyFun (gadQ P Q) ∧ ConvexLower (gadQ P Q) ∧ IsUnboundedBox (gadY J) ∧
  105. (∀ x, (argminSet (gadQ P Q) (gadY J) x).Nonempty ∧
  106. ∀ y ∈ argminSet (gadQ P Q) (gadY J) x, gadP P Q x y = (basicSet P Q).indicator 1 x) ∧
  107. valueFun (gadP P Q) (gadQ P Q) (gadY J) = (fun x => (((basicSet P Q).indicator 1 x : ℝ) : EReal)) ∧
  108. pvalueFun (gadP P Q) (gadQ P Q) (gadY J) = (fun x => (((basicSet P Q).indicator 1 x : ℝ) : EReal)) :=
  109. ⟨isPolyFun_gadP P Q, isPolyFun_gadQ P Q, convexLower_gadQ P Q, isUnboundedBox_gadY J,
  110. fun x => ⟨argminSet_gadQ_nonempty P Q x, fun _ hy => gadP_eq_indicator P Q hy⟩,
  111. funext fun x => valueFun_eq_of_const (argminSet_gadQ_nonempty P Q x)
  112. (fun _ hy => gadP_eq_indicator P Q hy),
  113. funext fun x => pvalueFun_eq_of_const (argminSet_gadQ_nonempty P Q x)
  114. (fun _ hy => gadP_eq_indicator P Q hy)⟩
  115. /-- **Lemma 2.19**, existential form (paper statement, with constancy of `P'` on the argmin). -/
  116. theorem lemma219_exists {J : Type} [Fintype J] (P : MvPolynomial (Fin n) ℝ)
  117. (Q : J → MvPolynomial (Fin n) ℝ) :
  118. ∃ (ι : Type) (_ : Fintype ι) (P' Q' : (Fin n → ℝ) → (ι → ℝ) → ℝ) (Y : Set (ι → ℝ)),
  119. IsPolyFun P' ∧ IsPolyFun Q' ∧ ConvexLower Q' ∧ IsUnboundedBox Y ∧
  120. (∀ x, (argminSet Q' Y x).Nonempty ∧
  121. ∀ y ∈ argminSet Q' Y x, P' x y = (basicSet P Q).indicator 1 x) ∧
  122. valueFun P' Q' Y = (fun x => (((basicSet P Q).indicator 1 x : ℝ) : EReal)) ∧
  123. pvalueFun P' Q' Y = (fun x => (((basicSet P Q).indicator 1 x : ℝ) : EReal)) :=
  124. ⟨Unit ⊕ J, inferInstance, gadP P Q, gadQ P Q, gadY J, lemma219 P Q⟩
  125. end Lemma219
  126. end Bilevel