/- Copyright (c) 2020 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 analysis.normed_space.complemented /-! # Implicit function theorem We prove three versions of the implicit function theorem. First we define a structure `implicit_function_data` that holds arguments for the most general version of the implicit function theorem, see `implicit_function_data.implicit_function` and `implicit_function_data.to_implicit_function`. This version allows a user to choose a specific implicit function but provides only a little convenience over the inverse function theorem. Then we define `implicit_function_of_complemented`: implicit function defined by `f (g z y) = z`, where `f : E โ†’ F` is a function strictly differentiable at `a` such that its derivative `f'` is surjective and has a `complemented` kernel. Finally, if the codomain of `f` is a finite dimensional space, then we can automatically prove that the kernel of `f'` is complemented, hence the only assumptions are `has_strict_fderiv_at` and `f'.range = โŠค`. This version is named `implicit_function`. ## TODO * Add a version for a function `f : E ร— F โ†’ G` such that $$\frac{\partial f}{\partial y}$$ is invertible. * Add a version for `f : ๐•œ ร— ๐•œ โ†’ ๐•œ` proving `has_strict_deriv_at` and `deriv ฯ† = ...`. * Prove that in a real vector space the implicit function has the same smoothness as the original one. * If the original function is differentiable in a neighborhood, then the implicit function is differentiable in a neighborhood as well. Current setup only proves differentiability at one point for the implicit function constructed in this file (as opposed to an unspecified implicit function). One of the ways to overcome this difficulty is to use uniqueness of the implicit function in the general version of the theorem. Another way is to prove that *any* implicit function satisfying some predicate is strictly differentiable. ## Tags implicit function, inverse function -/ noncomputable theory open_locale topological_space open filter open continuous_linear_map (fst snd smul_right ker_prod) open continuous_linear_equiv (of_bijective) /-! ### General version Consider two functions `f : E โ†’ F` and `g : E โ†’ G` and a point `a` such that * both functions are strictly differentiable at `a`; * the derivatives are surjective; * the kernels of the derivatives are complementary subspaces of `E`. Note that the map `x โ†ฆ (f x, g x)` has a bijective derivative, hence it is a local homeomorphism between `E` and `F ร— G`. We use this fact to define a function `ฯ† : F โ†’ G โ†’ E` (see `implicit_function_data.implicit_function`) such that for `(y, z)` close enough to `(f a, g a)` we have `f (ฯ† y z) = y` and `g (ฯ† y z) = z`. We also prove a formula for $$\frac{\partial\varphi}{\partial z}.$$ Though this statement is almost symmetric with respect to `F`, `G`, we interpret it in the following way. Consider a family of surfaces `{x | f x = y}`, `y โˆˆ ๐“ (f a)`. Each of these surfaces is parametrized by `ฯ† y`. There are many ways to choose a (differentiable) function `ฯ†` such that `f (ฯ† y z) = y` but the extra condition `g (ฯ† y z) = z` allows a user to select one of these functions. If we imagine that the level surfaces `f = const` form a local horizontal foliation, then the choice of `g` fixes a transverse foliation `g = const`, and `ฯ†` is the inverse function of the projection of `{x | f x = y}` along this transverse foliation. This version of the theorem is used to prove the other versions and can be used if a user needs to have a complete control over the choice of the implicit function. -/ /-- Data for the general version of the implicit function theorem. It holds two functions `f : E โ†’ F` and `g : E โ†’ G` (named `left_fun` and `right_fun`) and a point `a` (named `pt`) such that * both functions are strictly differentiable at `a`; * the derivatives are surjective; * the kernels of the derivatives are complementary subspaces of `E`. -/ @[nolint has_inhabited_instance] structure implicit_function_data (๐•œ : Type*) [nontrivially_normed_field ๐•œ] (E : Type*) [normed_add_comm_group E] [normed_space ๐•œ E] [complete_space E] (F : Type*) [normed_add_comm_group F] [normed_space ๐•œ F] [complete_space F] (G : Type*) [normed_add_comm_group G] [normed_space ๐•œ G] [complete_space G] := (left_fun : E โ†’ F) (left_deriv : E โ†’L[๐•œ] F) (right_fun : E โ†’ G) (right_deriv : E โ†’L[๐•œ] G) (pt : E) (left_has_deriv : has_strict_fderiv_at left_fun left_deriv pt) (right_has_deriv : has_strict_fderiv_at right_fun right_deriv pt) (left_range : left_deriv.range = โŠค) (right_range : right_deriv.range = โŠค) (is_compl_ker : is_compl left_deriv.ker right_deriv.ker) namespace implicit_function_data variables {๐•œ : Type*} [nontrivially_normed_field ๐•œ] {E : Type*} [normed_add_comm_group E] [normed_space ๐•œ E] [complete_space E] {F : Type*} [normed_add_comm_group F] [normed_space ๐•œ F] [complete_space F] {G : Type*} [normed_add_comm_group G] [normed_space ๐•œ G] [complete_space G] (ฯ† : implicit_function_data ๐•œ E F G) /-- The function given by `x โ†ฆ (left_fun x, right_fun x)`. -/ def prod_fun (x : E) : F ร— G := (ฯ†.left_fun x, ฯ†.right_fun x) @[simp] lemma prod_fun_apply (x : E) : ฯ†.prod_fun x = (ฯ†.left_fun x, ฯ†.right_fun x) := rfl protected lemma has_strict_fderiv_at : has_strict_fderiv_at ฯ†.prod_fun (ฯ†.left_deriv.equiv_prod_of_surjective_of_is_compl ฯ†.right_deriv ฯ†.left_range ฯ†.right_range ฯ†.is_compl_ker : E โ†’L[๐•œ] F ร— G) ฯ†.pt := ฯ†.left_has_deriv.prod ฯ†.right_has_deriv /-- Implicit function theorem. If `f : E โ†’ F` and `g : E โ†’ G` are two maps strictly differentiable at `a`, their derivatives `f'`, `g'` are surjective, and the kernels of these derivatives are complementary subspaces of `E`, then `x โ†ฆ (f x, g x)` defines a local homeomorphism between `E` and `F ร— G`. In particular, `{x | f x = f a}` is locally homeomorphic to `G`. -/ def to_local_homeomorph : local_homeomorph E (F ร— G) := ฯ†.has_strict_fderiv_at.to_local_homeomorph _ /-- Implicit function theorem. If `f : E โ†’ F` and `g : E โ†’ G` are two maps strictly differentiable at `a`, their derivatives `f'`, `g'` are surjective, and the kernels of these derivatives are complementary subspaces of `E`, then `implicit_function_of_is_compl_ker` is the unique (germ of a) map `ฯ† : F โ†’ G โ†’ E` such that `f (ฯ† y z) = y` and `g (ฯ† y z) = z`. -/ def implicit_function : F โ†’ G โ†’ E := function.curry $ ฯ†.to_local_homeomorph.symm @[simp] lemma to_local_homeomorph_coe : โ‡‘(ฯ†.to_local_homeomorph) = ฯ†.prod_fun := rfl lemma to_local_homeomorph_apply (x : E) : ฯ†.to_local_homeomorph x = (ฯ†.left_fun x, ฯ†.right_fun x) := rfl lemma pt_mem_to_local_homeomorph_source : ฯ†.pt โˆˆ ฯ†.to_local_homeomorph.source := ฯ†.has_strict_fderiv_at.mem_to_local_homeomorph_source lemma map_pt_mem_to_local_homeomorph_target : (ฯ†.left_fun ฯ†.pt, ฯ†.right_fun ฯ†.pt) โˆˆ ฯ†.to_local_homeomorph.target := ฯ†.to_local_homeomorph.map_source $ ฯ†.pt_mem_to_local_homeomorph_source lemma prod_map_implicit_function : โˆ€แถ  (p : F ร— G) in ๐“ (ฯ†.prod_fun ฯ†.pt), ฯ†.prod_fun (ฯ†.implicit_function p.1 p.2) = p := ฯ†.has_strict_fderiv_at.eventually_right_inverse.mono $ ฮป โŸจz, yโŸฉ h, h lemma left_map_implicit_function : โˆ€แถ  (p : F ร— G) in ๐“ (ฯ†.prod_fun ฯ†.pt), ฯ†.left_fun (ฯ†.implicit_function p.1 p.2) = p.1 := ฯ†.prod_map_implicit_function.mono $ ฮป z, congr_arg prod.fst lemma right_map_implicit_function : โˆ€แถ  (p : F ร— G) in ๐“ (ฯ†.prod_fun ฯ†.pt), ฯ†.right_fun (ฯ†.implicit_function p.1 p.2) = p.2 := ฯ†.prod_map_implicit_function.mono $ ฮป z, congr_arg prod.snd lemma implicit_function_apply_image : โˆ€แถ  x in ๐“ ฯ†.pt, ฯ†.implicit_function (ฯ†.left_fun x) (ฯ†.right_fun x) = x := ฯ†.has_strict_fderiv_at.eventually_left_inverse lemma map_nhds_eq : map ฯ†.left_fun (๐“ ฯ†.pt) = ๐“ (ฯ†.left_fun ฯ†.pt) := show map (prod.fst โˆ˜ ฯ†.prod_fun) (๐“ ฯ†.pt) = ๐“ (ฯ†.prod_fun ฯ†.pt).1, by rw [โ† map_map, ฯ†.has_strict_fderiv_at.map_nhds_eq_of_equiv, map_fst_nhds] lemma implicit_function_has_strict_fderiv_at (g'inv : G โ†’L[๐•œ] E) (hg'inv : ฯ†.right_deriv.comp g'inv = continuous_linear_map.id ๐•œ G) (hg'invf : ฯ†.left_deriv.comp g'inv = 0) : has_strict_fderiv_at (ฯ†.implicit_function (ฯ†.left_fun ฯ†.pt)) g'inv (ฯ†.right_fun ฯ†.pt) := begin have := ฯ†.has_strict_fderiv_at.to_local_inverse, simp only [prod_fun] at this, convert this.comp (ฯ†.right_fun ฯ†.pt) ((has_strict_fderiv_at_const _ _).prod (has_strict_fderiv_at_id _)), simp only [continuous_linear_map.ext_iff, continuous_linear_map.coe_comp', function.comp_app] at hg'inv hg'invf โŠข, simp [continuous_linear_equiv.eq_symm_apply, *] end end implicit_function_data namespace has_strict_fderiv_at section complemented /-! ### Case of a complemented kernel In this section we prove the following version of the implicit function theorem. Consider a map `f : E โ†’ F` and a point `a : E` such that `f` is strictly differentiable at `a`, its derivative `f'` is surjective and the kernel of `f'` is a complemented subspace of `E` (i.e., it has a closed complementary subspace). Then there exists a function `ฯ† : F โ†’ ker f' โ†’ E` such that for `(y, z)` close to `(f a, 0)` we have `f (ฯ† y z) = y` and the derivative of `ฯ† (f a)` at zero is the embedding `ker f' โ†’ E`. Note that a map with these properties is not unique. E.g., different choices of a subspace complementary to `ker f'` lead to different maps `ฯ†`. -/ variables {๐•œ : Type*} [nontrivially_normed_field ๐•œ] {E : Type*} [normed_add_comm_group E] [normed_space ๐•œ E] [complete_space E] {F : Type*} [normed_add_comm_group F] [normed_space ๐•œ F] [complete_space F] {f : E โ†’ F} {f' : E โ†’L[๐•œ] F} {a : E} section defs variables (f f') /-- Data used to apply the generic implicit function theorem to the case of a strictly differentiable map such that its derivative is surjective and has a complemented kernel. -/ @[simp] def implicit_function_data_of_complemented (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : implicit_function_data ๐•œ E F f'.ker := { left_fun := f, left_deriv := f', right_fun := ฮป x, classical.some hker (x - a), right_deriv := classical.some hker, pt := a, left_has_deriv := hf, right_has_deriv := (classical.some hker).has_strict_fderiv_at.comp a ((has_strict_fderiv_at_id a).sub_const a), left_range := hf', right_range := linear_map.range_eq_of_proj (classical.some_spec hker), is_compl_ker := linear_map.is_compl_of_proj (classical.some_spec hker) } /-- A local homeomorphism between `E` and `F ร— f'.ker` sending level surfaces of `f` to vertical subspaces. -/ def implicit_to_local_homeomorph_of_complemented (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : local_homeomorph E (F ร— f'.ker) := (implicit_function_data_of_complemented f f' hf hf' hker).to_local_homeomorph /-- Implicit function `g` defined by `f (g z y) = z`. -/ def implicit_function_of_complemented (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : F โ†’ f'.ker โ†’ E := (implicit_function_data_of_complemented f f' hf hf' hker).implicit_function end defs @[simp] lemma implicit_to_local_homeomorph_of_complemented_fst (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) (x : E) : (hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker x).fst = f x := rfl lemma implicit_to_local_homeomorph_of_complemented_apply (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) (y : E) : hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker y = (f y, classical.some hker (y - a)) := rfl @[simp] lemma implicit_to_local_homeomorph_of_complemented_apply_ker (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) (y : f'.ker) : hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker (y + a) = (f (y + a), y) := by simp only [implicit_to_local_homeomorph_of_complemented_apply, add_sub_cancel, classical.some_spec hker] @[simp] lemma implicit_to_local_homeomorph_of_complemented_self (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker a = (f a, 0) := by simp [hf.implicit_to_local_homeomorph_of_complemented_apply] lemma mem_implicit_to_local_homeomorph_of_complemented_source (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : a โˆˆ (hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker).source := mem_to_local_homeomorph_source _ lemma mem_implicit_to_local_homeomorph_of_complemented_target (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : (f a, (0 : f'.ker)) โˆˆ (hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker).target := by simpa only [implicit_to_local_homeomorph_of_complemented_self] using ((hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker).map_source $ (hf.mem_implicit_to_local_homeomorph_of_complemented_source hf' hker)) /-- `implicit_function_of_complemented` sends `(z, y)` to a point in `f โปยน' z`. -/ lemma map_implicit_function_of_complemented_eq (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : โˆ€แถ  (p : F ร— f'.ker) in ๐“ (f a, 0), f (hf.implicit_function_of_complemented f f' hf' hker p.1 p.2) = p.1 := ((hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker).eventually_right_inverse $ hf.mem_implicit_to_local_homeomorph_of_complemented_target hf' hker).mono $ ฮป โŸจz, yโŸฉ h, congr_arg prod.fst h /-- Any point in some neighborhood of `a` can be represented as `implicit_function` of some point. -/ lemma eq_implicit_function_of_complemented (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : โˆ€แถ  x in ๐“ a, hf.implicit_function_of_complemented f f' hf' hker (f x) (hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker x).snd = x := (implicit_function_data_of_complemented f f' hf hf' hker).implicit_function_apply_image @[simp] lemma implicit_function_of_complemented_apply_image (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : hf.implicit_function_of_complemented f f' hf' hker (f a) 0 = a := begin convert (hf.implicit_to_local_homeomorph_of_complemented f f' hf' hker).left_inv (hf.mem_implicit_to_local_homeomorph_of_complemented_source hf' hker), exact congr_arg prod.snd (hf.implicit_to_local_homeomorph_of_complemented_self hf' hker).symm end lemma to_implicit_function_of_complemented (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (hker : f'.ker.closed_complemented) : has_strict_fderiv_at (hf.implicit_function_of_complemented f f' hf' hker (f a)) f'.ker.subtypeL 0 := by convert (implicit_function_data_of_complemented f f' hf hf' hker).implicit_function_has_strict_fderiv_at f'.ker.subtypeL _ _; [skip, ext, ext]; simp [classical.some_spec hker] end complemented /-! ### Finite dimensional case In this section we prove the following version of the implicit function theorem. Consider a map `f : E โ†’ F` from a Banach normed space to a finite dimensional space. Take a point `a : E` such that `f` is strictly differentiable at `a` and its derivative `f'` is surjective. Then there exists a function `ฯ† : F โ†’ ker f' โ†’ E` such that for `(y, z)` close to `(f a, 0)` we have `f (ฯ† y z) = y` and the derivative of `ฯ† (f a)` at zero is the embedding `ker f' โ†’ E`. This version deduces that `ker f'` is a complemented subspace from the fact that `F` is a finite dimensional space, then applies the previous version. Note that a map with these properties is not unique. E.g., different choices of a subspace complementary to `ker f'` lead to different maps `ฯ†`. -/ section finite_dimensional variables {๐•œ : Type*} [nontrivially_normed_field ๐•œ] [complete_space ๐•œ] {E : Type*} [normed_add_comm_group E] [normed_space ๐•œ E] [complete_space E] {F : Type*} [normed_add_comm_group F] [normed_space ๐•œ F] [finite_dimensional ๐•œ F] (f : E โ†’ F) (f' : E โ†’L[๐•œ] F) {a : E} /-- Given a map `f : E โ†’ F` to a finite dimensional space with a surjective derivative `f'`, returns a local homeomorphism between `E` and `F ร— ker f'`. -/ def implicit_to_local_homeomorph (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : local_homeomorph E (F ร— f'.ker) := by haveI := finite_dimensional.complete ๐•œ F; exact hf.implicit_to_local_homeomorph_of_complemented f f' hf' f'.ker_closed_complemented_of_finite_dimensional_range /-- Implicit function `g` defined by `f (g z y) = z`. -/ def implicit_function (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : F โ†’ f'.ker โ†’ E := function.curry $ (hf.implicit_to_local_homeomorph f f' hf').symm variables {f f'} @[simp] lemma implicit_to_local_homeomorph_fst (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (x : E) : (hf.implicit_to_local_homeomorph f f' hf' x).fst = f x := rfl @[simp] lemma implicit_to_local_homeomorph_apply_ker (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) (y : f'.ker) : hf.implicit_to_local_homeomorph f f' hf' (y + a) = (f (y + a), y) := by apply implicit_to_local_homeomorph_of_complemented_apply_ker @[simp] lemma implicit_to_local_homeomorph_self (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : hf.implicit_to_local_homeomorph f f' hf' a = (f a, 0) := by apply implicit_to_local_homeomorph_of_complemented_self lemma mem_implicit_to_local_homeomorph_source (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : a โˆˆ (hf.implicit_to_local_homeomorph f f' hf').source := mem_to_local_homeomorph_source _ lemma mem_implicit_to_local_homeomorph_target (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : (f a, (0 : f'.ker)) โˆˆ (hf.implicit_to_local_homeomorph f f' hf').target := by apply mem_implicit_to_local_homeomorph_of_complemented_target lemma tendsto_implicit_function (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) {ฮฑ : Type*} {l : filter ฮฑ} {gโ‚ : ฮฑ โ†’ F} {gโ‚‚ : ฮฑ โ†’ f'.ker} (hโ‚ : tendsto gโ‚ l (๐“ $ f a)) (hโ‚‚ : tendsto gโ‚‚ l (๐“ 0)) : tendsto (ฮป t, hf.implicit_function f f' hf' (gโ‚ t) (gโ‚‚ t)) l (๐“ a) := begin refine ((hf.implicit_to_local_homeomorph f f' hf').tendsto_symm (hf.mem_implicit_to_local_homeomorph_source hf')).comp _, rw [implicit_to_local_homeomorph_self], exact hโ‚.prod_mk_nhds hโ‚‚ end alias tendsto_implicit_function โ† _root_.filter.tendsto.implicit_function /-- `implicit_function` sends `(z, y)` to a point in `f โปยน' z`. -/ lemma map_implicit_function_eq (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : โˆ€แถ  (p : F ร— f'.ker) in ๐“ (f a, 0), f (hf.implicit_function f f' hf' p.1 p.2) = p.1 := by apply map_implicit_function_of_complemented_eq @[simp] lemma implicit_function_apply_image (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : hf.implicit_function f f' hf' (f a) 0 = a := by apply implicit_function_of_complemented_apply_image /-- Any point in some neighborhood of `a` can be represented as `implicit_function` of some point. -/ lemma eq_implicit_function (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : โˆ€แถ  x in ๐“ a, hf.implicit_function f f' hf' (f x) (hf.implicit_to_local_homeomorph f f' hf' x).snd = x := by apply eq_implicit_function_of_complemented lemma to_implicit_function (hf : has_strict_fderiv_at f f' a) (hf' : f'.range = โŠค) : has_strict_fderiv_at (hf.implicit_function f f' hf' (f a)) f'.ker.subtypeL 0 := by apply to_implicit_function_of_complemented end finite_dimensional end has_strict_fderiv_at