Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
File size: 7,946 Bytes
4365a98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import analysis.calculus.inverse
import linear_algebra.dual

/-!
# Lagrange multipliers

In this file we formalize the
[Lagrange multipliers](https://en.wikipedia.org/wiki/Lagrange_multiplier) method of solving
conditional extremum problems: if a function `Ο†` has a local extremum at `xβ‚€` on the set
`f ⁻¹' {f xβ‚€}`, `f x = (fβ‚€ x, ..., fₙ₋₁ x)`, then the differentials of `fβ‚–` and `Ο†` are linearly
dependent. First we formulate a geometric version of this theorem which does not rely on the
target space being `ℝⁿ`, then restate it in terms of coordinates.

## TODO

Formalize Karush-Kuhn-Tucker theorem

## Tags

lagrange multiplier, local extremum

-/

open filter set
open_locale topological_space filter big_operators
variables {E F : Type*} [normed_add_comm_group E] [normed_space ℝ E] [complete_space E]
  [normed_add_comm_group F] [normed_space ℝ F] [complete_space F]
  {f : E β†’ F} {Ο† : E β†’ ℝ} {xβ‚€ : E} {f' : E β†’L[ℝ] F} {Ο†' : E β†’L[ℝ] ℝ}

/-- Lagrange multipliers theorem: if `Ο† : E β†’ ℝ` has a local extremum on the set `{x | f x = f xβ‚€}`
at `xβ‚€`, both `f : E β†’ F` and `Ο†` are strictly differentiable at `xβ‚€`, and the codomain of `f` is
a complete space, then the linear map `x ↦ (f' x, Ο†' x)` is not surjective. -/
lemma is_local_extr_on.range_ne_top_of_has_strict_fderiv_at
  (hextr : is_local_extr_on Ο† {x | f x = f xβ‚€} xβ‚€) (hf' : has_strict_fderiv_at f f' xβ‚€)
  (hφ' : has_strict_fderiv_at φ φ' x₀) :
  (f'.prod Ο†').range β‰  ⊀ :=
begin
  intro htop,
  set fφ := λ x, (f x, φ x),
  have A : map Ο† (𝓝[f ⁻¹' {f xβ‚€}] xβ‚€) = 𝓝 (Ο† xβ‚€),
  { change map (prod.snd ∘ fΟ†) (𝓝[fΟ† ⁻¹' {p | p.1 = f xβ‚€}] xβ‚€) = 𝓝 (Ο† xβ‚€),
    rw [← map_map, nhds_within, map_inf_principal_preimage,
      (hf'.prod hφ').map_nhds_eq_of_surj htop],
    exact map_snd_nhds_within _ },
  exact hextr.not_nhds_le_map A.ge
end

/-- Lagrange multipliers theorem: if `Ο† : E β†’ ℝ` has a local extremum on the set `{x | f x = f xβ‚€}`
at `xβ‚€`, both `f : E β†’ F` and `Ο†` are strictly differentiable at `xβ‚€`, and the codomain of `f` is
a complete space, then there exist `Ξ› : dual ℝ F` and `Ξ›β‚€ : ℝ` such that `(Ξ›, Ξ›β‚€) β‰  0` and
`Ξ› (f' x) + Ξ›β‚€ β€’ Ο†' x = 0` for all `x`. -/
lemma is_local_extr_on.exists_linear_map_of_has_strict_fderiv_at
  (hextr : is_local_extr_on Ο† {x | f x = f xβ‚€} xβ‚€) (hf' : has_strict_fderiv_at f f' xβ‚€)
  (hφ' : has_strict_fderiv_at φ φ' x₀) :
  βˆƒ (Ξ› : module.dual ℝ F) (Ξ›β‚€ : ℝ), (Ξ›, Ξ›β‚€) β‰  0 ∧ βˆ€ x, Ξ› (f' x) + Ξ›β‚€ β€’ Ο†' x = 0 :=
begin
  rcases submodule.exists_le_ker_of_lt_top _
    (lt_top_iff_ne_top.2 $ hextr.range_ne_top_of_has_strict_fderiv_at hf' hΟ†') with βŸ¨Ξ›', h0, hΞ›'⟩,
  set e : ((F β†’β‚—[ℝ] ℝ) Γ— ℝ) ≃ₗ[ℝ] (F Γ— ℝ β†’β‚—[ℝ] ℝ) :=
    ((linear_equiv.refl ℝ (F β†’β‚—[ℝ] ℝ)).prod (linear_map.ring_lmap_equiv_self ℝ ℝ ℝ).symm).trans
      (linear_map.coprod_equiv ℝ),
  rcases e.surjective Ξ›' with βŸ¨βŸ¨Ξ›, Ξ›β‚€βŸ©, rfl⟩,
  refine βŸ¨Ξ›, Ξ›β‚€, e.map_ne_zero_iff.1 h0, Ξ» x, _⟩,
  convert linear_map.congr_fun (linear_map.range_le_ker_iff.1 hΞ›') x using 1,
  -- squeezed `simp [mul_comm]` to speed up elaboration
  simp only [linear_map.coprod_equiv_apply, linear_equiv.refl_apply,
    linear_map.ring_lmap_equiv_self_symm_apply, linear_map.comp_apply,
    continuous_linear_map.coe_coe, continuous_linear_map.prod_apply,
    linear_equiv.trans_apply, linear_equiv.prod_apply, linear_map.coprod_apply,
    linear_map.smul_right_apply, linear_map.one_apply, smul_eq_mul, mul_comm]
end

/-- Lagrange multipliers theorem: if `Ο† : E β†’ ℝ` has a local extremum on the set `{x | f x = f xβ‚€}`
at `xβ‚€`, and both `f : E β†’ ℝ` and `Ο†` are strictly differentiable at `xβ‚€`, then there exist
`a b : ℝ` such that `(a, b) β‰  0` and `a β€’ f' + b β€’ Ο†' = 0`. -/
lemma is_local_extr_on.exists_multipliers_of_has_strict_fderiv_at_1d
  {f : E β†’ ℝ} {f' : E β†’L[ℝ] ℝ}
  (hextr : is_local_extr_on Ο† {x | f x = f xβ‚€} xβ‚€) (hf' : has_strict_fderiv_at f f' xβ‚€)
  (hφ' : has_strict_fderiv_at φ φ' x₀) :
  βˆƒ (a b : ℝ), (a, b) β‰  0 ∧ a β€’ f' + b β€’ Ο†' = 0 :=
begin
  obtain βŸ¨Ξ›, Ξ›β‚€, hΞ›, hfΞ›βŸ© := hextr.exists_linear_map_of_has_strict_fderiv_at hf' hΟ†',
  refine βŸ¨Ξ› 1, Ξ›β‚€, _, _⟩,
  { contrapose! hΞ›,
    simp only [prod.mk_eq_zero] at ⊒ hΞ›,
    refine ⟨linear_map.ext (Ξ» x, _), hΞ›.2⟩,
    simpa [hΞ›.1] using Ξ›.map_smul x 1 },
  { ext x,
    have H₁ : Ξ› (f' x) = f' x * Ξ› 1,
    { simpa only [mul_one, algebra.id.smul_eq_mul] using Ξ›.map_smul (f' x) 1 },
    have Hβ‚‚ : f' x * Ξ› 1  + Ξ›β‚€ * Ο†' x = 0,
    { simpa only [algebra.id.smul_eq_mul, H₁] using hfΞ› x },
    simpa [mul_comm] using Hβ‚‚ }
end

/-- Lagrange multipliers theorem, 1d version. Let `f : ΞΉ β†’ E β†’ ℝ` be a finite family of functions.
Suppose that `Ο† : E β†’ ℝ` has a local extremum on the set `{x | βˆ€ i, f i x = f i xβ‚€}` at `xβ‚€`.
Suppose that all functions `f i` as well as `Ο†` are strictly differentiable at `xβ‚€`.
Then the derivatives `f' i : E β†’ L[ℝ] ℝ` and `Ο†' : E β†’L[ℝ] ℝ` are linearly dependent:
there exist `Ξ› : ΞΉ β†’ ℝ` and `Ξ›β‚€ : ℝ`, `(Ξ›, Ξ›β‚€) β‰  0`, such that `βˆ‘ i, Ξ› i β€’ f' i + Ξ›β‚€ β€’ Ο†' = 0`.

See also `is_local_extr_on.linear_dependent_of_has_strict_fderiv_at` for a version that
states `Β¬linear_independent ℝ _` instead of existence of `Ξ›` and `Ξ›β‚€`. -/
lemma is_local_extr_on.exists_multipliers_of_has_strict_fderiv_at {ΞΉ : Type*} [fintype ΞΉ]
  {f : ΞΉ β†’ E β†’ ℝ} {f' : ΞΉ β†’ E β†’L[ℝ] ℝ}
  (hextr : is_local_extr_on Ο† {x | βˆ€ i, f i x = f i xβ‚€} xβ‚€)
  (hf' : βˆ€ i, has_strict_fderiv_at (f i) (f' i) xβ‚€)
  (hφ' : has_strict_fderiv_at φ φ' x₀) :
  βˆƒ (Ξ› : ΞΉ β†’ ℝ) (Ξ›β‚€ : ℝ), (Ξ›, Ξ›β‚€) β‰  0 ∧ βˆ‘ i, Ξ› i β€’ f' i + Ξ›β‚€ β€’ Ο†' = 0 :=
begin
  letI := classical.dec_eq ΞΉ,
  replace hextr : is_local_extr_on Ο† {x | (Ξ» i, f i x) = (Ξ» i, f i xβ‚€)} xβ‚€,
    by simpa only [function.funext_iff] using hextr,
  rcases hextr.exists_linear_map_of_has_strict_fderiv_at
    (has_strict_fderiv_at_pi.2 (λ i, hf' i)) hφ'
    with βŸ¨Ξ›, Ξ›β‚€, h0, hsum⟩,
  rcases (linear_equiv.pi_ring ℝ ℝ ΞΉ ℝ).symm.surjective Ξ› with βŸ¨Ξ›, rfl⟩,
  refine βŸ¨Ξ›, Ξ›β‚€, _, _⟩,
  { simpa only [ne.def, prod.ext_iff, linear_equiv.map_eq_zero_iff, prod.fst_zero] using h0 },
  { ext x, simpa [mul_comm] using hsum x }
end

/-- Lagrange multipliers theorem. Let `f : ΞΉ β†’ E β†’ ℝ` be a finite family of functions.
Suppose that `Ο† : E β†’ ℝ` has a local extremum on the set `{x | βˆ€ i, f i x = f i xβ‚€}` at `xβ‚€`.
Suppose that all functions `f i` as well as `Ο†` are strictly differentiable at `xβ‚€`.
Then the derivatives `f' i : E β†’ L[ℝ] ℝ` and `Ο†' : E β†’L[ℝ] ℝ` are linearly dependent.

See also `is_local_extr_on.exists_multipliers_of_has_strict_fderiv_at` for a version that
that states existence of Lagrange multipliers `Ξ›` and `Ξ›β‚€` instead of using
`Β¬linear_independent ℝ _` -/
lemma is_local_extr_on.linear_dependent_of_has_strict_fderiv_at {ΞΉ : Type*} [fintype ΞΉ]
  {f : ΞΉ β†’ E β†’ ℝ} {f' : ΞΉ β†’ E β†’L[ℝ] ℝ}
  (hextr : is_local_extr_on Ο† {x | βˆ€ i, f i x = f i xβ‚€} xβ‚€)
  (hf' : βˆ€ i, has_strict_fderiv_at (f i) (f' i) xβ‚€)
  (hφ' : has_strict_fderiv_at φ φ' x₀) :
  Β¬linear_independent ℝ (option.elim Ο†' f' : option ΞΉ β†’ E β†’L[ℝ] ℝ) :=
begin
  rw [fintype.linear_independent_iff], push_neg,
  rcases hextr.exists_multipliers_of_has_strict_fderiv_at hf' hΟ†' with βŸ¨Ξ›, Ξ›β‚€, hΞ›, hΞ›f⟩,
  refine ⟨option.elim Ξ›β‚€ Ξ›, _, _⟩,
  { simpa [add_comm] using hΞ›f },
  { simpa [function.funext_iff, not_and_distrib, or_comm, option.exists] using hΞ› }
end