← Visual paper

HardnessBilevel/Smooth/Thm11.lean

d1032f4c70da9b037605c2f444ce2450900e5a76 · GitHub

  1. /-
  2. Blueprint §4.C — Theorem 1.1 (smooth data realize every lower semicontinuous function).
  3. Ids: `t11.T0` (construction `thm11P`, `thm11Q`), `t11.smooth` (`contDiff_thm11P`, `contDiff_thm11Q`),
  4. `t11.nonneg` (`thm11Q_nonneg`), `t11.case_finite` (`valueFun_thm11_of_ne_top`),
  5. `t11.case_top` (`argminSet_thm11Q_of_eq_top`, `valueFun_thm11_of_eq_top`),
  6. `t11.main` (`exists_smooth_of_lowerSemicontinuous`), `t11.main_paper`
  7. (`exists_smooth_of_lowerSemicontinuous_proper`), `t11.main_pess`
  8. (`exists_smooth_of_upperSemicontinuous`). `t11.whitney` is in `Smooth/Whitney.lean`;
  9. `t11.isClosed_realEpigraph` is `Bilevel.isClosed_realEpigraph` in `Framework/Semicont.lean`.
  10. Remark: the domain hypothesis is `IsClosed {x | f x ≠ ⊤}` and NOT "`{x | f x ∈ ℝ}` closed": the
  11. function `g` must vanish exactly on `{f < +∞}`. Values `-∞` are allowed; "proper" is not needed.
  12. Smoothness is `ContDiff ℝ ∞` (C^∞), never `ContDiff ℝ ⊤` (analytic; the theorem is false there).
  13. -/
  14. import HardnessBilevel.Smooth.Whitney
  15. import HardnessBilevel.Framework.Basic
  16. import HardnessBilevel.Framework.Value
  17. import HardnessBilevel.Framework.Semicont
  18. open scoped ContDiff
  19. namespace Bilevel
  20. variable {n : ℕ}
  21. /-- `t11.T0`: the leader objective `P(x,y) = y₀`. -/
  22. def thm11P : (Fin n → ℝ) → (Fin 3 → ℝ) → ℝ := fun _ y => y 0
  23. /-- `t11.T0`: the follower objective `Q(x,y) = h(x,y₀)² + (g(x) y₁)² + (1 - y₁ y₂)²`. -/
  24. def thm11Q (h : (Fin n → ℝ) × ℝ → ℝ) (g : (Fin n → ℝ) → ℝ) :
  25. (Fin n → ℝ) → (Fin 3 → ℝ) → ℝ :=
  26. fun x y => h (x, y 0) ^ 2 + (g x * y 1) ^ 2 + (1 - y 1 * y 2) ^ 2
  27. /-- `t11.smooth` (leader). -/
  28. theorem contDiff_thm11P : ContDiff ℝ ∞ (Function.uncurry (thm11P (n := n))) := by
  29. unfold thm11P Function.uncurry
  30. fun_prop
  31. /-- `t11.smooth` (follower). -/
  32. theorem contDiff_thm11Q {h : (Fin n → ℝ) × ℝ → ℝ} {g : (Fin n → ℝ) → ℝ}
  33. (hh : ContDiff ℝ ∞ h) (hg : ContDiff ℝ ∞ g) :
  34. ContDiff ℝ ∞ (Function.uncurry (thm11Q h g)) := by
  35. unfold thm11Q Function.uncurry
  36. fun_prop
  37. /-- `t11.nonneg`. -/
  38. theorem thm11Q_nonneg (h : (Fin n → ℝ) × ℝ → ℝ) (g : (Fin n → ℝ) → ℝ) (x : Fin n → ℝ)
  39. (y : Fin 3 → ℝ) : 0 ≤ thm11Q h g x y :=
  40. add_nonneg (add_nonneg (sq_nonneg _) (sq_nonneg _)) (sq_nonneg _)
  41. section Cases
  42. variable {f : (Fin n → ℝ) → EReal} {h : (Fin n → ℝ) × ℝ → ℝ} {g : (Fin n → ℝ) → ℝ}
  43. /-- `t11.case_finite`, step (iv): on `{f ≠ ⊤}` the follower's argmin is
  44. `Z = {y | f x ≤ y₀ ∧ y₁ y₂ = 1}`. -/
  45. theorem argminSet_thm11Q_of_ne_top (hh : ∀ p, h p = 0 ↔ f p.1 ≤ (p.2 : EReal))
  46. (hg : ∀ x, g x = 0 ↔ f x ≠ ⊤) {x : Fin n → ℝ} (hx : f x ≠ ⊤) :
  47. argminSet (thm11Q h g) Set.univ x = {y | f x ≤ ((y 0 : ℝ) : EReal) ∧ y 1 * y 2 = 1} := by
  48. have hg0 : g x = 0 := (hg x).2 hx
  49. have key : ∀ y : Fin 3 → ℝ,
  50. thm11Q h g x y = 0 ↔ f x ≤ ((y 0 : ℝ) : EReal) ∧ y 1 * y 2 = 1 := by
  51. intro y
  52. have e : thm11Q h g x y = h (x, y 0) ^ 2 + (1 - y 1 * y 2) ^ 2 := by
  53. simp only [thm11Q, hg0, zero_mul]; ring
  54. rw [e, add_eq_zero_iff_of_nonneg (sq_nonneg _) (sq_nonneg _), sq_eq_zero_iff, sq_eq_zero_iff,
  55. hh, sub_eq_zero, eq_comm]
  56. have hmem : thm11Q h g x ![(f x).toReal, 1, 1] = 0 := by
  57. rw [key]
  58. refine ⟨?_, ?_⟩
  59. · simp only [Matrix.cons_val_zero]
  60. exact EReal.le_coe_toReal hx
  61. · simp
  62. rw [argminSet_eq_zeroSet (fun y _ => thm11Q_nonneg h g x y) ⟨_, Set.mem_univ _, hmem⟩]
  63. ext y
  64. simp only [Set.mem_univ, true_and, Set.mem_ofPred_eq, key]
  65. /-- `t11.case_finite`: on `{f ≠ ⊤}` the optimistic value is `f x` (including `f x = ⊥`). -/
  66. theorem valueFun_thm11_of_ne_top (hh : ∀ p, h p = 0 ↔ f p.1 ≤ (p.2 : EReal))
  67. (hg : ∀ x, g x = 0 ↔ f x ≠ ⊤) {x : Fin n → ℝ} (hx : f x ≠ ⊤) :
  68. valueFun thm11P (thm11Q h g) Set.univ x = f x := by
  69. rw [valueFun, argminSet_thm11Q_of_ne_top hh hg hx]
  70. generalize he : f x = e at hx ⊢
  71. induction e using EReal.rec with
  72. | bot =>
  73. rw [EReal.eq_bot_iff_forall_lt]
  74. intro r
  75. calc _ ≤ ((thm11P x ![r - 1, 1, 1] : ℝ) : EReal) :=
  76. iInf₂_le (f := fun y (_ : y ∈ {y : Fin 3 → ℝ | (⊥ : EReal) ≤ ((y 0 : ℝ) : EReal) ∧
  77. y 1 * y 2 = 1}) => ((thm11P x y : ℝ) : EReal)) ![r - 1, 1, 1] ⟨bot_le, by simp⟩
  78. _ < (r : EReal) := by
  79. simp only [thm11P, Matrix.cons_val_zero]
  80. exact EReal.coe_lt_coe_iff.2 (by linarith)
  81. | coe r =>
  82. refine le_antisymm ?_ (le_iInf₂ fun y hy => hy.1)
  83. exact iInf₂_le (f := fun y (_ : y ∈ {y : Fin 3 → ℝ | ((r : ℝ) : EReal) ≤ ((y 0 : ℝ) : EReal) ∧
  84. y 1 * y 2 = 1}) => ((thm11P x y : ℝ) : EReal)) ![r, 1, 1] ⟨by simp, by simp⟩
  85. | top => exact absurd rfl hx
  86. /-- `t11.case_top`: off `{f ≠ ⊤}` the follower problem has no minimiser. -/
  87. theorem argminSet_thm11Q_of_eq_top (hg : ∀ x, g x = 0 ↔ f x ≠ ⊤) {x : Fin n → ℝ}
  88. (hx : f x = ⊤) : argminSet (thm11Q h g) Set.univ x = ∅ := by
  89. have hg0 : g x ≠ 0 := fun h0 => (hg x).1 h0 hx
  90. rw [argminSet_eq_empty_iff]
  91. intro y _
  92. set v := (g x * y 1) ^ 2 + (1 - y 1 * y 2) ^ 2 with hv
  93. have hvpos : 0 < v := by
  94. by_cases hy1 : y 1 = 0
  95. · simp [hv, hy1]
  96. · have : g x * y 1 ≠ 0 := mul_ne_zero hg0 hy1
  97. exact add_pos_of_pos_of_nonneg (by positivity) (sq_nonneg _)
  98. set ε := min 1 (v / (2 * (g x ^ 2 + 1))) with hεdef
  99. have hε : 0 < ε := lt_min one_pos (by positivity)
  100. have hε1 : ε ≤ 1 := min_le_left _ _
  101. have hε2 : ε ≤ v / (2 * (g x ^ 2 + 1)) := min_le_right _ _
  102. have hlt : (g x * ε) ^ 2 < v := by
  103. have hεε : ε ^ 2 ≤ ε := by nlinarith
  104. have h1 : (g x * ε) ^ 2 ≤ (g x ^ 2 + 1) * ε := by
  105. nlinarith [mul_le_mul_of_nonneg_left hεε (sq_nonneg (g x))]
  106. have h2 : ε * (2 * (g x ^ 2 + 1)) ≤ v := (le_div_iff₀ (by positivity)).1 hε2
  107. nlinarith
  108. refine ⟨![y 0, ε, 1 / ε], Set.mem_univ _, ?_⟩
  109. have e1 : thm11Q h g x ![y 0, ε, 1 / ε] = h (x, y 0) ^ 2 + (g x * ε) ^ 2 := by
  110. simp only [thm11Q, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two,
  111. Matrix.head_cons, Matrix.tail_cons]
  112. rw [mul_one_div_cancel hε.ne', sub_self]
  113. ring
  114. have e2 : thm11Q h g x y = h (x, y 0) ^ 2 + v := by
  115. simp only [thm11Q, hv]; ring
  116. rw [e1, e2]
  117. linarith
  118. /-- `t11.case_top`: off `{f ≠ ⊤}` the optimistic value is `⊤`. -/
  119. theorem valueFun_thm11_of_eq_top (hg : ∀ x, g x = 0 ↔ f x ≠ ⊤) {x : Fin n → ℝ}
  120. (hx : f x = ⊤) : valueFun thm11P (thm11Q h g) Set.univ x = ⊤ :=
  121. valueFun_eq_top_iff.2 (argminSet_thm11Q_of_eq_top hg hx)
  122. end Cases
  123. /-- `t11.main` (Theorem 1.1, strengthened): every lower semicontinuous `f : ℝⁿ → [-∞, +∞]` whose
  124. domain `{f ≠ ⊤}` is closed is the optimistic value function of a bilevel problem with `C^∞` data
  125. and lower-level feasible set `ℝ³`. -/
  126. theorem exists_smooth_of_lowerSemicontinuous {n : ℕ} (f : (Fin n → ℝ) → EReal)
  127. (hf : LowerSemicontinuous f) (hdom : IsClosed {x | f x ≠ ⊤}) :
  128. ∃ P Q : (Fin n → ℝ) → (Fin 3 → ℝ) → ℝ,
  129. ContDiff ℝ ∞ (Function.uncurry P) ∧ ContDiff ℝ ∞ (Function.uncurry Q) ∧
  130. valueFun P Q Set.univ = f := by
  131. obtain ⟨h, hhs, hh⟩ := exists_contDiff_zeroSet_eq (isClosed_realEpigraph hf)
  132. obtain ⟨g, hgs, hg⟩ := exists_contDiff_zeroSet_eq hdom
  133. refine ⟨thm11P, thm11Q h g, contDiff_thm11P, contDiff_thm11Q hhs hgs, ?_⟩
  134. funext x
  135. by_cases hx : f x = ⊤
  136. · rw [hx]
  137. exact valueFun_thm11_of_eq_top (h := h) hg hx
  138. · exact valueFun_thm11_of_ne_top hh hg hx
  139. /-- `t11.main_paper` (Theorem 1.1 as stated in the paper, for proper `f`). The extra hypotheses
  140. (`f` never `⊥`, `f` not identically `⊤`) are not needed. -/
  141. theorem exists_smooth_of_lowerSemicontinuous_proper {n : ℕ} (f : (Fin n → ℝ) → EReal)
  142. (hf : LowerSemicontinuous f) (hdom : IsClosed {x | f x ≠ ⊤})
  143. (_hbot : ∀ x, f x ≠ ⊥) (_hproper : ∃ x, f x ≠ ⊤) :
  144. ∃ P Q : (Fin n → ℝ) → (Fin 3 → ℝ) → ℝ,
  145. ContDiff ℝ ∞ (Function.uncurry P) ∧ ContDiff ℝ ∞ (Function.uncurry Q) ∧
  146. valueFun P Q Set.univ = f :=
  147. exists_smooth_of_lowerSemicontinuous f hf hdom
  148. /-- `t11.main_pess` (Theorem 1.1′, pessimistic twin): every upper semicontinuous
  149. `f : ℝⁿ → [-∞, +∞]` with `{f ≠ ⊥}` closed is the pessimistic value function of a bilevel problem
  150. with `C^∞` data and lower-level feasible set `ℝ³`. -/
  151. theorem exists_smooth_of_upperSemicontinuous {n : ℕ} (f : (Fin n → ℝ) → EReal)
  152. (hf : UpperSemicontinuous f) (hdom : IsClosed {x | f x ≠ ⊥}) :
  153. ∃ P Q : (Fin n → ℝ) → (Fin 3 → ℝ) → ℝ,
  154. ContDiff ℝ ∞ (Function.uncurry P) ∧ ContDiff ℝ ∞ (Function.uncurry Q) ∧
  155. pvalueFun P Q Set.univ = f := by
  156. have hf' : LowerSemicontinuous fun x => -f x :=
  157. (upperSemicontinuous_iff_lowerSemicontinuous_neg f).1 hf
  158. have hdom' : IsClosed {x | -f x ≠ ⊤} := by
  159. simpa only [ne_eq, EReal.neg_eq_top_iff] using hdom
  160. obtain ⟨P, Q, hP, hQ, hval⟩ := exists_smooth_of_lowerSemicontinuous (fun x => -f x) hf' hdom'
  161. refine ⟨fun x y => -P x y, Q, hP.neg, hQ, ?_⟩
  162. funext x
  163. rw [pvalueFun_eq_neg_valueFun_neg]
  164. simp only [neg_neg]
  165. rw [hval, neg_neg]
  166. end Bilevel