← Visual paper

HardnessBilevel/Framework/Basic.lean

d1032f4c70da9b037605c2f444ce2450900e5a76 · GitHub

  1. /-
  2. Copyright: HardnessBilevel project.
  3. # Framework: argmin sets and value functions (blueprint §4.A.1–§4.A.3)
  4. Implements blueprint §2.2 / §4.A:
  5. * definitions `argminSet`, `valueFun`, `pvalueFun`, `optVal` (§4.A.1);
  6. * argmin lemmas F1 (`mem_argminSet_iff`), F2 (`argminSet_subset`), `mem_argminSet_univ`,
  7. F3 (`argminSet_eq_empty_iff`), F4 (`argminSet_eq_zeroSet`), F4′ (`mem_argminSet_of_nonneg_zero`),
  8. F6 (`argminSet_mul_pos`, `argminSet_add_left`), F8 (`argminSet_isClosed`, `argminSet_isCompact`),
  9. `fw.argmin_empty_of_pos_inf` (§4.E.1, A2; `argminSet_empty_of_pos_inf`, stated for a general `S`);
  10. * value-function lemmas V1 (`valueFun_eq_top_iff`, twin `pvalueFun_eq_bot_iff`), V2
  11. (`valueFun_eq_of_isMinOn`, twin `pvalueFun_eq_of_isMaxOn`), F0 (`valueFun_eq_of_isLeast`, twin
  12. `pvalueFun_eq_of_isGreatest`), V5 (`valueFun_eq_of_const`, `pvalueFun_eq_of_const`), V5′
  13. (`valueFun_unique`), A5 (`valueFun_eq_bot_of_unbounded`, twin `pvalueFun_eq_top_of_unbounded`),
  14. the order helpers `valueFun_le_coe_of_mem`, `coe_le_valueFun_of_forall` (and twins);
  15. * `fw.value_shift_attained` (§4.G.1) as `value_shift_attained`.
  16. No assumption (A1–A3) is used.
  17. -/
  18. import Mathlib
  19. namespace Bilevel
  20. variable {X Y : Type*}
  21. /-- Θ(x): the set of lower-level minimisers (blueprint §4.A.1). -/
  22. def argminSet (Q : X → Y → ℝ) (S : Set Y) (x : X) : Set Y :=
  23. {y | y ∈ S ∧ ∀ y' ∈ S, Q x y ≤ Q x y'}
  24. /-- Optimistic value function φ_o; `⊤` if Θ(x) = ∅, `⊥` if `P x` is unbounded below on Θ(x)
  25. (blueprint §4.A.1). -/
  26. noncomputable def valueFun (P Q : X → Y → ℝ) (S : Set Y) (x : X) : EReal :=
  27. ⨅ y ∈ argminSet Q S x, ((P x y : ℝ) : EReal)
  28. /-- Pessimistic value function φ_p; `⊥` if Θ(x) = ∅ (blueprint §4.A.1). -/
  29. noncomputable def pvalueFun (P Q : X → Y → ℝ) (S : Set Y) (x : X) : EReal :=
  30. ⨆ y ∈ argminSet Q S x, ((P x y : ℝ) : EReal)
  31. /-- Optimal value of the whole bilevel problem over all upper-level points (blueprint §4.A.1). -/
  32. noncomputable def optVal (P Q : X → Y → ℝ) (S : Set Y) : EReal :=
  33. ⨅ x, valueFun P Q S x
  34. /-! ### Argmin sets -/
  35. section Argmin
  36. variable {Q : X → Y → ℝ} {S : Set Y} {x : X} {y : Y}
  37. /-- fw.mem_argmin_iff (F1). -/
  38. theorem mem_argminSet_iff : y ∈ argminSet Q S x ↔ y ∈ S ∧ IsMinOn (Q x) S y := by
  39. simp only [argminSet, isMinOn_iff, Set.mem_ofPred_eq]
  40. /-- fw.argmin_subset (F2). -/
  41. theorem argminSet_subset : argminSet Q S x ⊆ S := fun _ hy => hy.1
  42. /-- fw.mem_argmin_univ. -/
  43. @[simp]
  44. theorem mem_argminSet_univ : y ∈ argminSet Q Set.univ x ↔ ∀ y', Q x y ≤ Q x y' := by
  45. simp [argminSet]
  46. /-- fw.argmin_eq_empty_iff (F3). -/
  47. theorem argminSet_eq_empty_iff :
  48. argminSet Q S x = ∅ ↔ ∀ y ∈ S, ∃ y' ∈ S, Q x y' < Q x y := by
  49. simp only [Set.eq_empty_iff_forall_notMem, argminSet, Set.mem_ofPred_eq, not_and, not_forall,
  50. not_le, exists_prop]
  51. /-- fw.argmin_eq_zeroSet (F4). -/
  52. theorem argminSet_eq_zeroSet (hnn : ∀ y ∈ S, 0 ≤ Q x y) (hz : ∃ y₀ ∈ S, Q x y₀ = 0) :
  53. argminSet Q S x = {y ∈ S | Q x y = 0} := by
  54. obtain ⟨y₀, hy₀, hq₀⟩ := hz
  55. ext y
  56. constructor
  57. · rintro ⟨hy, hmin⟩
  58. exact ⟨hy, le_antisymm (hq₀ ▸ hmin y₀ hy₀) (hnn y hy)⟩
  59. · rintro ⟨hy, hq⟩
  60. exact ⟨hy, fun y' hy' => hq ▸ hnn y' hy'⟩
  61. /-- fw.mem_argmin_of_nonneg_zero (F4′). -/
  62. theorem mem_argminSet_of_nonneg_zero (hnn : ∀ y ∈ S, 0 ≤ Q x y) (hy : y ∈ S) (hq : Q x y = 0) :
  63. y ∈ argminSet Q S x :=
  64. ⟨hy, fun y' hy' => hq ▸ hnn y' hy'⟩
  65. /-- fw.argmin_mul_pos (F6). -/
  66. theorem argminSet_mul_pos {c : X → ℝ} (hc : 0 < c x) :
  67. argminSet (fun x y => c x * Q x y) S x = argminSet Q S x := by
  68. ext y
  69. simp only [argminSet, Set.mem_ofPred_eq, mul_le_mul_iff_right₀ hc]
  70. /-- fw.argmin_add_left (F6). -/
  71. theorem argminSet_add_left (a : X → ℝ) :
  72. argminSet (fun x y => a x + Q x y) S x = argminSet Q S x := by
  73. ext y
  74. simp only [argminSet, Set.mem_ofPred_eq, add_le_add_iff_left]
  75. /-- Θ(x) as an intersection of sublevel sets. -/
  76. theorem argminSet_eq_inter : argminSet Q S x = S ∩ ⋂ y' ∈ S, {y | Q x y ≤ Q x y'} := by
  77. ext y
  78. simp [argminSet]
  79. /-- fw.argmin_isClosed (F8). -/
  80. theorem argminSet_isClosed [TopologicalSpace Y] (hQ : Continuous (Q x)) (hS : IsClosed S) :
  81. IsClosed (argminSet Q S x) := by
  82. rw [argminSet_eq_inter]
  83. exact hS.inter (isClosed_biInter fun y' _ => isClosed_le hQ continuous_const)
  84. /-- fw.argmin_isCompact (F8). -/
  85. theorem argminSet_isCompact [TopologicalSpace Y] (hQ : Continuous (Q x)) (hS : IsCompact S) :
  86. IsCompact (argminSet Q S x) := by
  87. rw [argminSet_eq_inter]
  88. exact hS.inter_right (isClosed_biInter fun y' _ => isClosed_le hQ continuous_const)
  89. /-- fw.argmin_empty_of_pos_inf (§4.E.1, A2): a positive objective whose infimum over `S` is `0`
  90. has no minimiser. -/
  91. theorem argminSet_empty_of_pos_inf (hpos : ∀ y ∈ S, 0 < Q x y)
  92. (hinf : ∀ ε > 0, ∃ y ∈ S, Q x y < ε) : argminSet Q S x = ∅ := by
  93. rw [Set.eq_empty_iff_forall_notMem]
  94. rintro y ⟨hy, hmin⟩
  95. obtain ⟨y', hy', hlt⟩ := hinf (Q x y) (hpos y hy)
  96. exact absurd (hmin y' hy') (not_le.2 hlt)
  97. /-- fw.argmin_empty_of_pos_inf, the `S = univ` case. -/
  98. theorem argminSet_univ_empty_of_pos_inf (hpos : ∀ y, 0 < Q x y)
  99. (hinf : ∀ ε > 0, ∃ y, Q x y < ε) : argminSet Q Set.univ x = ∅ :=
  100. argminSet_empty_of_pos_inf (fun y _ => hpos y)
  101. (fun ε hε => (hinf ε hε).imp fun y hy => ⟨Set.mem_univ y, hy⟩)
  102. end Argmin
  103. /-! ### Value functions -/
  104. section Value
  105. variable {P Q : X → Y → ℝ} {S : Set Y} {x : X}
  106. /-- `valueFun ≤ ↑(P x y)` for every minimiser `y`. -/
  107. theorem valueFun_le_coe_of_mem {y : Y} (hy : y ∈ argminSet Q S x) :
  108. valueFun P Q S x ≤ ((P x y : ℝ) : EReal) :=
  109. iInf₂_le y hy
  110. /-- `↑(P x y) ≤ pvalueFun` for every minimiser `y`. -/
  111. theorem coe_le_pvalueFun_of_mem {y : Y} (hy : y ∈ argminSet Q S x) :
  112. ((P x y : ℝ) : EReal) ≤ pvalueFun P Q S x :=
  113. le_iSup₂ (f := fun y _ => ((P x y : ℝ) : EReal)) y hy
  114. /-- A real lower bound on `P x` over Θ(x) bounds `valueFun` from below. -/
  115. theorem coe_le_valueFun_of_forall {r : ℝ} (h : ∀ y ∈ argminSet Q S x, r ≤ P x y) :
  116. ((r : ℝ) : EReal) ≤ valueFun P Q S x :=
  117. le_iInf₂ fun y hy => EReal.coe_le_coe_iff.2 (h y hy)
  118. /-- A real upper bound on `P x` over Θ(x) bounds `pvalueFun` from above. -/
  119. theorem pvalueFun_le_coe_of_forall {r : ℝ} (h : ∀ y ∈ argminSet Q S x, P x y ≤ r) :
  120. pvalueFun P Q S x ≤ ((r : ℝ) : EReal) :=
  121. iSup₂_le fun y hy => EReal.coe_le_coe_iff.2 (h y hy)
  122. /-- fw.value_eq_top_iff (V1). -/
  123. theorem valueFun_eq_top_iff : valueFun P Q S x = ⊤ ↔ argminSet Q S x = ∅ := by
  124. constructor
  125. · intro h
  126. rw [Set.eq_empty_iff_forall_notMem]
  127. intro y hy
  128. have := valueFun_le_coe_of_mem (P := P) hy
  129. rw [h] at this
  130. exact absurd this (not_le.2 (EReal.coe_lt_top _))
  131. · intro h
  132. simp only [valueFun, h, iInf_emptyset]
  133. /-- fw.pvalue_eq_bot_iff (V1, pessimistic twin). -/
  134. theorem pvalueFun_eq_bot_iff : pvalueFun P Q S x = ⊥ ↔ argminSet Q S x = ∅ := by
  135. constructor
  136. · intro h
  137. rw [Set.eq_empty_iff_forall_notMem]
  138. intro y hy
  139. have := coe_le_pvalueFun_of_mem (P := P) hy
  140. rw [h] at this
  141. exact absurd this (not_le.2 (EReal.bot_lt_coe _))
  142. · intro h
  143. simp only [pvalueFun, h, iSup_emptyset]
  144. /-- fw.value_eq_of_isMinOn (V2). -/
  145. theorem valueFun_eq_of_isMinOn {y₀ : Y} (hy₀ : y₀ ∈ argminSet Q S x)
  146. (hmin : IsMinOn (P x) (argminSet Q S x) y₀) :
  147. valueFun P Q S x = ((P x y₀ : ℝ) : EReal) :=
  148. le_antisymm (valueFun_le_coe_of_mem hy₀)
  149. (coe_le_valueFun_of_forall fun _ hy => isMinOn_iff.1 hmin _ hy)
  150. /-- fw.value_eq_of_isMinOn (V2, pessimistic twin). -/
  151. theorem pvalueFun_eq_of_isMaxOn {y₀ : Y} (hy₀ : y₀ ∈ argminSet Q S x)
  152. (hmax : IsMaxOn (P x) (argminSet Q S x) y₀) :
  153. pvalueFun P Q S x = ((P x y₀ : ℝ) : EReal) :=
  154. le_antisymm (pvalueFun_le_coe_of_forall fun _ hy => isMaxOn_iff.1 hmax _ hy)
  155. (coe_le_pvalueFun_of_mem hy₀)
  156. /-- fw.value_eq_of_isLeast (F0): the main interface for construction directions. -/
  157. theorem valueFun_eq_of_isLeast {r : ℝ} (h : IsLeast (P x '' argminSet Q S x) r) :
  158. valueFun P Q S x = ((r : ℝ) : EReal) := by
  159. obtain ⟨⟨y₀, hy₀, rfl⟩, hlow⟩ := h
  160. exact valueFun_eq_of_isMinOn hy₀ (isMinOn_iff.2 fun y hy => hlow ⟨y, hy, rfl⟩)
  161. /-- fw.value_eq_of_isLeast (F0, pessimistic twin). -/
  162. theorem pvalueFun_eq_of_isGreatest {r : ℝ} (h : IsGreatest (P x '' argminSet Q S x) r) :
  163. pvalueFun P Q S x = ((r : ℝ) : EReal) := by
  164. obtain ⟨⟨y₀, hy₀, rfl⟩, hup⟩ := h
  165. exact pvalueFun_eq_of_isMaxOn hy₀ (isMaxOn_iff.2 fun y hy => hup ⟨y, hy, rfl⟩)
  166. /-- fw.value_eq_of_const (V5). -/
  167. theorem valueFun_eq_of_const {v : ℝ} (hne : (argminSet Q S x).Nonempty)
  168. (hc : ∀ y ∈ argminSet Q S x, P x y = v) : valueFun P Q S x = ((v : ℝ) : EReal) := by
  169. obtain ⟨y₀, hy₀⟩ := hne
  170. rw [← hc y₀ hy₀]
  171. exact valueFun_eq_of_isMinOn hy₀ (isMinOn_iff.2 fun y hy => (hc y hy).symm ▸ (hc y₀ hy₀).le)
  172. /-- fw.value_eq_of_const (V5, pessimistic form). -/
  173. theorem pvalueFun_eq_of_const {v : ℝ} (hne : (argminSet Q S x).Nonempty)
  174. (hc : ∀ y ∈ argminSet Q S x, P x y = v) : pvalueFun P Q S x = ((v : ℝ) : EReal) := by
  175. obtain ⟨y₀, hy₀⟩ := hne
  176. rw [← hc y₀ hy₀]
  177. exact pvalueFun_eq_of_isMaxOn hy₀ (isMaxOn_iff.2 fun y hy => (hc y hy).symm ▸ (hc y₀ hy₀).ge)
  178. /-- fw.value_unique (V5′). -/
  179. theorem valueFun_unique {y₀ : Y} (h : argminSet Q S x = {y₀}) :
  180. valueFun P Q S x = ((P x y₀ : ℝ) : EReal) ∧ pvalueFun P Q S x = ((P x y₀ : ℝ) : EReal) := by
  181. simp only [valueFun, pvalueFun, h, iInf_singleton, iSup_singleton, and_self]
  182. /-- fw.value_eq_bot_of_unbounded (§4.E.1, A5). -/
  183. theorem valueFun_eq_bot_of_unbounded (h : ∀ r : ℝ, ∃ y ∈ argminSet Q S x, P x y ≤ r) :
  184. valueFun P Q S x = ⊥ := by
  185. rw [EReal.eq_bot_iff_forall_lt]
  186. intro r
  187. obtain ⟨y, hy, hle⟩ := h (r - 1)
  188. calc valueFun P Q S x ≤ ((P x y : ℝ) : EReal) := valueFun_le_coe_of_mem hy
  189. _ < ((r : ℝ) : EReal) := EReal.coe_lt_coe_iff.2 (by linarith)
  190. /-- fw.value_eq_bot_of_unbounded (A5, pessimistic twin). -/
  191. theorem pvalueFun_eq_top_of_unbounded (h : ∀ r : ℝ, ∃ y ∈ argminSet Q S x, r ≤ P x y) :
  192. pvalueFun P Q S x = ⊤ := by
  193. rw [EReal.eq_top_iff_forall_lt]
  194. intro r
  195. obtain ⟨y, hy, hle⟩ := h (r + 1)
  196. calc ((r : ℝ) : EReal) < ((P x y : ℝ) : EReal) := EReal.coe_lt_coe_iff.2 (by linarith)
  197. _ ≤ pvalueFun P Q S x := coe_le_pvalueFun_of_mem hy
  198. end Value
  199. /-- fw.value_shift_attained (§4.G.1): shifting the upper objective by `g x` shifts an attained
  200. minimum. -/
  201. theorem value_shift_attained {P : X → Y → ℝ} {g : X → ℝ} {Θ : Set Y} {x : X} {r : ℝ}
  202. (h : IsLeast (P x '' Θ) r) : IsLeast ((fun y => P x y + g x) '' Θ) (r + g x) := by
  203. obtain ⟨⟨y₀, hy₀, rfl⟩, hlow⟩ := h
  204. refine ⟨⟨y₀, hy₀, rfl⟩, ?_⟩
  205. rintro _ ⟨y, hy, rfl⟩
  206. exact add_le_add_left (hlow ⟨y, hy, rfl⟩) _
  207. end Bilevel