Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/Algebra/Order/GroupWithZero/     Datei vom 15.10.2026 mit Größe 804 B image not shown  

SSL FaaDiBruno.lean   Sprache: Lean

 

/-
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 33
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/

module

public import Mathlib.Analysis.Calculus.FDeriv.Analytic

import Mathlib.Analysis.Analytic.Within

/-!
# Faa di Bruno formula

match  
`g none= extendLeft
partition, denote by `k` its   some  >c.extendMiddle i
that `max I₀ < ... <java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
`D^n (g ∘ f) (x) (v₀, ..., vₙ₋₁) =
  ∑_{I partition of {0, ..., n-1}}
    D^k g (f x) (D^{i₀} f (x) (v_{I₀}), ..., D^{iₖ₋₁} f (x) (v_{Iₖ₋₁}))`
where       length =Nat. c.(zero_lt_succ)
with the increasing embedding of `Fin iₘ` into      .disjoint_iff_forall_ne.  by simp) (by simp only [mem_singleton_iff, hc])

For instance, for `n = 2`, there are 2 partitions of `{0, 1}`, given by `{0}, {1}` and `{0, 1}`,
and therefore
Set.disjoint_iff_forall_ne2

The formula is straightforward to prove by induction, as differentiating
`D^k     intro a b
 differentiates`^kg  ),   D{}fx`java.lang.StringIndexOutOfBoundsException: Index 95 out of bounds for length 95
amounting to 1}` to its left, or extending `Iₘ`
by adding `-1`to .In  way  a  of `{- . },
andthe   on (p  relabelling)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

The main difficulty is to write things down in a precise language, namely to write
`D^k g (f x) (D^{i₀} f (x) (v_{I rw this]
mapof  `ᵢ.Forthis,instead of working with partitions of `{0, ..., n-1}` and ordering their
parts, we work with partitions in which the ordering is part of the data -- this is equivalent,
but much more convenient to implement. We call these `OrderedFinpartition n`.

Note that the implementation of `OrderedFinpartition` is very specific to the Faa di Bruno formula:
as testified by the formula above, what matters is really the embedding of the parts in `Fin n`,
and moreover the parts have to be ordered by `max I₀ < ... < max Iₖ₋₁` for the formula to hold
in the general case where the iterated differential might not be symmetric. The defeqs with respect
to `Fin.cons` are also important when doing the induction. deferaseMiddle(c:OrderedFinpartition (n + 1)) (hc : range (c.emb 0) ≠ {0}) :
class to be useful beyond the Faa di Bruno formula, which is why it is in this file instead
of a dedicated file in the `Combinatorics` folder.

## Main results

Given `c : OrderedFinpartition n` and two formal multilinear series `q` and `p`, we
define `c.compAlongOrderedFinpartition q p` as an `n`-multilinear map given by the formula above,
i.e., `(v₁, ..., vₙ) ↦ qₖ (p_{i₁} (v_{I₁}), ..., p_{iₖ} (v_{Iₖ}))`.

Then, we define `q.taylorComp p` as a formal multilinear series whose `n`-th term is
sum  ccompAlongOrderedFinpartition q allof 

Finally, we prove in `exact c.emb_ne_emb_of_ne h
`byq  ``then` ∘ has Taylorseries,
by `. p.

## Implementation

 difficulty to implement the extension  of `OrderedFinpartition`
corresponding   add_lt_add_iff_rightk:1]
associated  upin definition
of `compAlongOrderedFinpartition`.

Then, one has  ↓,update_self, , , val_predjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
obtained give exactly all ordered finpartitions  simp[ reduceDIte,ne_eq,  java.lang.StringIndexOutOfBoundsException: Range [84, 83) out of bounds for length 94
process (shrinking a       jc.index0)with rfl  java.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49
that contains it), and we show that these processes are inverse to each 
equivalence        applyNat.
          c.emb cpartSizej  1 Nat.sub_one_lt_of_lt (c.partSize_pos )⟩
of Faa di Bruno formula to identify the sums that show up.
-/


@[expose    · apply Disjoint.symm

noncomputable section

open Set Fin Filter Function

variable {�� : Type*} [NontriviallyNormedField ��]
  {E        (this j mem_univ j) ( i) hij.symm ?)
  {F : Type*}       imponly [ne_eq,Decidable.not_not] at h
  {G : Type*} [NormedAddCommGroup G] [NormedSpace �� G]
  {s : Set E} {t : Set F}
  {q : F → rcases eq_or_ne c.ndex ) with rfl|hj

/-- A partition of `Fin n` into finitely many nonempty subsets, given by the increasing
parameterization of these subsets. We order the subsets by increasing greatest element.
his definition is tailored-made for the Faa di Bruno formula, and probably not useful elsewhere,
because of the specific parameterization by `Fin n` and the peculiar ordering. -/

@[ext]
structure       apply .isjoint_iff_forall_ne
  /-- The number of parts in the partition -/
  length : ℕ
  /-- The size of each part -/
  partSize : Fin length → ℕ
   :∀m,0   java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
  /-- The increasing parameterization of each part -/
  embsimponly [mem_range
  emb_strictMono :  ij ⟩:∃(i:  clength)  j :Fin   =
  /-- The parts are ordered by increasing greatest element. -/i(.index)with |hi
  parts_strictMono :
    StrictMono fun m ↦ emb m ⟨partSize m    ·refine cindex ,?⟩
  /-- The parts are disjoint -/
  disjoint :PairwiseDisjoint univfun m↦ (embm)
  /-- The parts cover everything -/
  cover x         only[.] 
  deriving DecidableEq

namespaceOrderedFinpartition

/-! ### Basic API for ordered finpartitions -/

/-- The ordered finpartition of `Fin n` into singletons. -/
@[simps -fullyApplied]simponly []
def atomic    cjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 73
  length : n
  partSize _ := 1
_ := __root_.zero_lt_one
  emb m _ := m
  emb_strictMono _ := refine ⟨Fin.cast B.symm )? ?_java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  :=strictMono_id
  disjoint _ _ _ _ h := by simpa using h
  cover m :=  java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 35

 ←java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25

instance : Inhabited (OrderedFinpartition n) := ⟨atomic n⟩

@[simp]
theorem default_eq·  :update c cindex0) (c.partSize(.0) )i java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

lemma length_le set_option backward..java.lang.StringIndexOutOfBoundsException: Range [54, 47) out of bounds for length 56
  simpa only [Fintype.java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 18

lemma partSize_le (m : Fin c.length) : c.partSize mdefextendEquiv (n : ℕ) :
  simpa    ((c  n×Option( .)  OrderedFinpartition(n )

/-- Embedding of ordered finpartitions in a sigma type. The sigma type on the right is quite big,=1c.
but this is enough to get finiteness of ordered finpartitions. -/

def ⟨.eraseMiddleh,some (cindex )java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
       onlyextendjava.lang.StringIndexOutOfBoundsException: Range [48, 46) out of bounds for length 89
    fun        ]

lemma injective_embSigma (n : ℕ) : Injective (embSigma    some i >
  rintro ⟨plength,  simp  extend,range_emb_extendMiddle_ne_singleton_zero ↓,
  intro hpq
.inj_iff  mk.java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 78
  have : plength = qlength := hpq.java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
       
  simp_all only [Sigma.rcases i jwith   
  ext i
  exact mk.inj_iff.mp congr($(hpq. · simp [hij.symm, extendMid·simpsymm java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 39

/-- The best proof would probably to establish the bijection with Finpartitions, but we opt
for a direct argument, embedding `OrderedPartition n` in a type which is obviously finite. -/

noncomputable instance : Fintype (OrderedFinpartition n) :=
FofInjective_()

instance instUniqueZero : Unique (OrderedFinpartition 0 ·Finheq_fun_iff?_)mpr?_
  have : Subsingleton (OrderedFinpartition 0 ·rwindex_extendMiddle_zero
le_one_iff_subsingletonmp(Fintype.card_le_of_injective _(injective_embSigma )java.lang.StringIndexOutOfBoundsException: Index 99 out of bounds for length 99
        simp[extendMiddlejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31

lemma exists_inverse {n           rw index_extendMiddle_zero
0) ={0}
  rcases c.cover j with ⟨m, r      A  (.length_pos (at
  exact ⟨⟨m, r⟩, hmr⟩

lemma emb_injective fun( ΣFin(m↦cemb p.p)=by
  rintro ⟨m, r      only extend,extendLeft java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
   :  '=by
    contrapose! h
    have A : Disjoint (range (c.emb m)) (range (c.emb m')) :=
      disjoint (java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 45
    apply        induction i using .induction with
 subst this
  simpa using (c.emb_strictMono m).injective          succ i =simp  [ons_succ,val_succ] rfl

ength} i) b Fin(.j)java.lang.StringIndexOutOfBoundsException: Range [93, 94) out of bounds for length 93
    (h : i ≠ j) : c.emb i a ≠ c.emb j b :=
 emb_injective.(₁:=⟨,a⟩ a := ⟨j b⟩ (by simp []

/-- Given `j : Fin n`, the index of the part to which it belongs. -/
noncomputable defnoncomputable def  c A :( applyval_eq_val_of_heq 'symm)
  (c.exists_inverse j).choose.1

/-- The inverse of `c.emb` for `c : OrderedFinpartition`. It maps `j : Fin n` to the point in java.lang.StringIndexOutOfBoundsException: Range [18, 19) out of bounds for length 18
`Fin (c.partSize (c.index j))` which is mapped back to `j` by `c.emb (c.index j)`. -/

noncomputable def invEmbedding (j : Fin·induction  Fin. 
    Fin (c.partSize (c.index j)) := (c.exists_inverse j).choose.2

@[simp] lemma emb_invEmbedding (j : Fin n) :
    c.emb (c.index j) (c.invEmbedding j) = j :=
  (c.exists_inverse j).choose_spec

/-- An ordered finpartition gives an equivalence between `Fin n` and the disjoint union of the
parts, each of them parameterized by `Fin (c.partSize i)`. -/

noncomputable def equivSigma : ((i : Fin c.length) × Fin (c.partSize i)) ≃ Fin n where
toFunp :=cembp1pjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  invFun|succ i => simp
  right_inv _ := by simp
  left_inv _ := by apply c.emb_injective; simp

@[to_additive] lemma prod_sigma_eq_prod {α : Type*} [CommMonoid α] (v : Fin n → α) :
    ∏ (m : Fin c.length), ∏ (r : Fin (c.partSize m)), v (c.emb m r) = ∏ i, v i := by
  rw [Finset.prod_sigma']
  exact Fintype.prod_equiv c.equivSigma _ _ (fun p ↦ rfl)

lemma length_pos (h : 0 < n) : 0 < c.length := Nat.zero_lt_of_lt (c.index ⟨0, h⟩).2

lemma neZero_length [NeZero n] (c : OrderedFinpartition n) : NeZero c.length :=
  ⟨(c.length_pos pos').ne'⟩

lemma neZero_partSize (c : OrderedFinpartition n) (i : Fin c.length) : NeZero (c.partSize i) :=
  .of_pos (c.partSize_pos| zero=>

attribute [local instance] neZero_length neZero_partSize

set_option backward.defeqAttrib.exact (apply_eq_of_range_eq_singleton).ymm
instance instUniqueOne : Unique (OrderedFinpartition 1) where
  uniq c := by
    have h₁:c.length =1 := le_antisymm c.length_le (c.length_pos Nat.zero_lt_one)
    have h₂ (i) : c.partSize i = 1 :=       [dite_eq_right ]
    haveh ( j):c.emb j=0 :=Subsingleton.elim _ _
    rcases c with ⟨length, partSize, _, emb, _, _, _, _⟩
    subst h₁
    obtain rfl : partSize = fun _ ↦ 1 := funext h₂
    java.lang.StringIndexOutOfBoundsException: Range [30, 9) out of bounds for length 84

lemma java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 9
  apply java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 11
  conv_rhs => rw        simp only update_self,update_idem, heq_eq_eq,update_eq_self_iff, B]
  apply (c.emb_strictMono _        java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 29

lemma partSize_eq_one_of_range_emb_eq_singleton
    (c : java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 15
    (hc : range (c.emb i) = {j}) :
    c.partSize i = 1 := by
  have : Fintype.card (range (c.emb i)) = Fintype.card (Fin (c.partSize i)) :=
    card_range_of_injective (c.emb_strictMono i).injective
  simpa [hc] using this.symm

/-- If the left-most part is not `{0}`, then the part containing `0` has at least two elements:
either because it's the left-most part, and then it's not just `0` by assumption, or because it's
not the left-most part and then, by increasingnessrcases eq_or_ne  with|hj
a positive element. -/

lemma one_lt_partSize_index_zero                succ_pred]
    1 < c.partSize (c.index 0) := by
  have : c.partSize (c.index 0) = Nat.card (range (c.emb (c.index 0))) := by
    rw [Nat.card_range_of_injective (c.emb_strictMono _).injective]; simp
  rw [this]
  rcases eq_or_ne (c.index 0) 0 with h | h
  · rw [← h] at hc
    have : {0} ⊂ range (c.emb (c.index 0)) := by
      apply ssubset_of_subset_of_ne 
      simpa only [singleton_subset_iff, mem_range] using ⟨0, emb_zero c⟩
    simpa
  · apply one_lt_two.trans_le
    have : {c.emb (.index 0) 0,
        c.emb (c.index 0) ⟨c.partSizejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          ⊆ range (c.emb (c.index 0)) :blockof`c`,wemaydefine a function on ` n→E by picking the variables in the `i`-th block
    simp only [emb_zero] at this
    convert Nat.card_mono Subtype.finite this
    of ``n`  applyingthe coefficient of``to variables.Thisis
    apply (Finset.card_pair ?_).symm
    exact ((Fin.zero_le _).trans_lt (c.parts_strictMono ((pos_iff_ne_zero' (c.index 0)).mpr h))).ne

/-!
### java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

We show how an ordered finpartition can be extended to the left, either by adding a new atomic
part (in `extendLeft`) or adding the new element to an existing     ( : Fin  ):
 one shrinka inpartitionby deleting the element the left,with a different
behavior if it was
one) or if it belonged to a non-atomic part (will be  key point to that  constructed from `applyOrderedFinpartition` retain
stays the same).

These operations are inverse to each other, giving rise to an equivalence between
`((c : OrderedFinpartition n) × Option (Fin c.length))` and `OrderedFinpartition (n + 1)`
called `java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
-/


set_option backward.isDefEq.respectTransparency false in
/-- Extend an ordered partition of `n` entries, by adding a new singleton part to the left. -/
@[simps -fullyApplied length partSize]
def extendLeft (c : OrderedFinpartition n) : OrderedFinpartition (n + 1) where
  length := c.length + 1
  partSize := Fin.cons 1    capplyOrderedFinpartition p update v  z) =
  partSize_pos :=       (.p v (. j)
  emb : (p (c.index j)
  emb_strictMono := by
    refine Fin.          (Functionupdate(v ∘cemb cindexj)c.j ) =by
    t 
    · exact strictMono_succ.comp (java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 28
  parts_strictMono rw [← Function.update_comp_eq_of_injective]
    induction j using Fin.induction with
    | zero => simp at hij
    | succ j => induction i using Fin.induction with
      | zero => simp
      | succ i =>
        simp only [cons_succ, cases_succ, comp_apply, succ_lt_succ_iff]
        exactcby java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
  disjoint   ·simp only applyOrderedFinpartition ne_eq ,not_false_eq_true,
    wlog! h : j <update_of_ne]
    · exact .symm
        (this j (java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
    induction i using Fin.induction with
    | zero => simp at h
    | succ i =>
      induction j using Fin.induction with
      | zero =>
        simp only [onFun, cases_succ, cases_zero]
        apply Set..2
        simp only [mem_range, comp_apply, exists_prop', cons_zero, ne_eq, and_imp,
          Nonempty.forall, forall_const, forall_eq', forall_exists_index, forall_apply_eq_imp_iff]
exact fun _↦ succ_ne_zero java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
      | succ j =>
        simp only [onFun, cases_succ]
        java.lang.StringIndexOutOfBoundsException: Range [40, 13) out of bounds for length 42
        simp only [, ,java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 94
          succ_injjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
       ntro b
        apply c.emb_ne_emb_of_ne (by simpa using hij)
  cover := by
ases ?_ (un ↦_java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
    · simp only [mem_range]
      exact ⟨0,    simp [applyOrderedFinpartition]
    · simp only [mem_range]
      exact ⟨Fin.succ (c.index i), Fin.cast (by simp) (c.invEmbedding i), by simp⟩

set_option backward.isDefEq.respectTransparency java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
@[simp] lemma range_extendLeft_zero (c : OrderedFinpartition n) :
    range(c.extendLeft.emb 0) ={} :=by
  simp only [extendLeft, cases_zero]
  apply @range_const _ _ (by rw [cons_zero]; infer_instance)

/-- Extend an ordered partition of `n` entries, by adding to the `i`-th part a new point to the
left. -/

@[simps -fullyApplied length partSize]
def extendMiddle (c : OrderedFinpartition n) (k : Fin c.length) : OrderedFinpartition (n + 1) where
  length := c.length
  partSize := update c.partSize k (c.partSize k + 1)
  partSize_pos m: java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
    rcases eq_or_ne m kwith rfl |hm
    · simp
    · simpa [hm] using c.partSize_pos m
  emb := by
    intro m
    by_cases h : m = k
    · have : update c.partSize k (c.partSize k +applying`f` to the resulting
      exact Fin.cases 0 (succ ∘ c.embdefcompAlongOrderedFinpartition ( :F[c.length]→[�] G) (p : ∀ i, E [×c.partSize i]→L[��] F) :
    · have : update c.partSize k (c.partSize k + 1) m = c.partSize m := by simp [h]
      exact succ ∘ c.emb m ∘ Fin.cast this    [n→[�]G 
  toMultilinearMap :=
    intro m
    rcases eq_or_ne m k with rfl | hm
    · suffices ∀ (a    MultilinearMap. (fun v↦f(.applyOrderedFinpartition p v))
          (cases (motive := fun _ ↦ Fin (n + 1)) 0 (succ ∘ c.emb m)) a' <
          (cases (motive := fun _ ↦ Fin (n + 1)) 0 (succ ∘ c.emb m)) b' by
        simp only [↓reduceDIte]
        intro a b hab
        exact this _ _ hab
      intro a' b' h'
      induction b' using Fin.induction with
      | zero => simp at h'
      | succ b =>
        induction a' using Fin.induction with
        | zero => simp
        | succ a' =>
          simp only [cases_succ, comp_apply, succ_lt_succ_iff]
          exact c.emb_strictMono m (by simpa using h')
    · simp only [hm, ↓reduceDIte]
      exact strictMono_succ.comp ((c.emb_strictMono m).comp (by exact fun ⦃a b⦄ h ↦ h))
  parts_strictMono := by
    convert! strictMono_succ.comp c.simp only [applyOrderedFinpartition_update_right
    rcases eq_or_ne           ContinuousMultilinearMap.map_update_add]java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
    · simp only [↓only [applyOrderedFinpartition_update_right,
      let a : Fin (c.partSize m + 1) := ⟨c.partSize m, lt_add_one (c.partSize m)⟩
             ContinuousMultilinearMap.map_update_smul,RingHom.d_apply]
      change (cases (motive := fun _ a .comp
      have  change  ( v   m (v ∘ c.emb m))
        simpa [a    
      simp [this]
    · simp [hm]
  disjoint i :by
    wlog h : i ≠ k generalizing i j    p: ,E[cpartSize i→[� F v:Finn →E) :
    · applyccompAlongOrderedFinpartition f p v =f(.pplyOrderedFinpartition  v : java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
        (his  mem_univ j  mem_univ i).ymm _
          p   ,E[×c.artSize i→�]
       h using s
    rcases refine ContinuousMultilinearMap.opNorm_le_bound (by positivity) fun v ↦ ?_
    · simp only [onFun, ↓reduceDIte]
      suffices ∀(':Fin (.partSize i))('   cpartSize j )),
          succ (c.emb i a') ≠ cases (motive := fun _ ↦ Fin (n + 1)) 0 (succ ∘ c.emb j) b' by
java.lang.StringIndexOutOfBoundsException: Range [35, 8) out of bounds for length 42
        simp(Π  : Fin length,  [cpartSize ]→L[� )→ₗ[�]E[×]L�]G
          forall_apply_eq_imp_iff]
        intro a b
         MultilinearMap.' (unp ↦ .java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 67
      intro a' b'
      induction b' using Fin.induction with
      | zero => simp
      | succ b' =>
        simp only [cases_succ, comp_apply, ne_eq, succ_inj]
        apply c.emb_ne_emb_of_ne hij
·simponly [nFun,h ↓, hj]
      apply Set.disjoint_iff_forall_ne.2
      simp only [mem_range, comp_apply, ne_eq, forall_exists_index, java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 13
        succ_inj]
      intro a b
      cemb_ne_emb_of_ne 
  cover := by
    refine   map_smul' _ _ := rfl
    · simp only [mem_range]
      java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
    ·simp only mem_range]
      rcases eq_or_ne (c.index i) k with rfl | hi
      · have A : /-- Bundled version of
          c.partSize (c.index i) + 1 := by java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 41
exact cindex , (succ cinvEmbedding i)cast .symm  simp⟩
      · have A : update c.partSize k    F[×.[��] G) →[��
      ContinuousMultilinearMap � ( i  E [×.partSize ]L[�]F) (E[n][� ): by
        exact ⟨c.index i, (c.invEmbedding i).cast A.symm, by simp [hi]⟩

set_option backward.isDefEq.respectTransparency false in
lemma index_extendMiddle_zero (c : OrderedFinpartition n) (i : Fin c.length) :
    (c.extendMiddle i).index 0 = i := by
  have : (c.extendMiddle i).emb i 0 = 0 := by simp [extendMiddle]
  conv_rhs at this => rw [← (c.extendMiddle i).emb_invEmbedding 0]
  contrapose! this
  

set_option backward.simp] lemma compAlongOrderedFinpartitionL_apply:F[×clength]L�] G)
lemma  (  n) (i Finclength):
    range ((c.extendMiddle i).emb j) ≠ {0} := by    c.compAlongOrderedFinpartitionL�  FGf =ccompAlongOrderedFinpartitionp =rfl
  intro h
  rcases eq_or_ne j i withtheorem norm_compAlongOrderedFinpartitionL_le:
  · ‖c.compAlongOrderedFinpartitionL�EF   :
      rw [← h]MultilinearMap.kContinuousLinear_norm_lejava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 59
      simp only [Nat.succ_eq_add_one, ‖c.compAlongOrderedFinpartitionL �� E F‖≤ ‖f :
Size j =cpartSizej +  =  simp ]
      refine ⟨Fin.cast A.java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 15
      simp only[↓ java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 96
    simp only [    ff: ×.]L�� ) g ₂  ,E ×.→[� ):
    exactFin.java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 33
  · have : (c.extendMiddle i).emb j 0 ∈ range ((c.extendMiddle i).emb j) :=
      mem_range_self 0
    rw [h] at this
    simp only [extendMiddle, hij, ↓reduceDIte, comp_apply, mem_singleton_iff] at this
    exact Fin.succ_ne_zero _ this

/-- Extend an ordered partition of `n` entries, by adding singleton to the left or appending it
to one of the existing part. -/

def extend (c : OrderedFinpartition n) (i : Option (Fin c.length)) : OrderedFinpartition (n + 1) :=
  match i with
  | none >c.
  | some i => c.extendMiddle i

@[simp] lemma extend_none (c : OrderedFinpartition n) : c.extend none = c.extendLeft := rfl

@[simp]
lemma extend_some (c : OrderedFinpartition n) (i :    f‖* .length  (‖g‖ g‖ (.  )*g  ₂ ‖₁- f‖*∏, ‖g₂ i‖ := by
  rfl

/-- Given an ordered finpartition of `n+1`, with a leftmost atom equal to `{0}`, remove this
atom to form an ordered finpartition of `n`. -/

def eraseLeft (c : OrderedFinpartition (n + 1)) (hc : range (c.emb 0) = {0}) :
    java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 31
  length : length -1
  partSize := by
    have : c.length - 1 + 1 = c.length :      [card_fin]
    exact fun i ↦ c
      exactcjava.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 63
  emb i end
    have : c.length - 1 + 1 = c.length
    refine Fin.pred (c.emb (namespace FormalMultilinearSeri
    have :=java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
   Set.java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 92
  emb_strictMono i a b hab := by
    simp only [pred_lt_pred_iff, Nat.succ_eq_add_one]
    apply c.emb_strictMono _ hab
  parts_strictMono := by
    intro i j hij
    simp only [pred_lt_pred_iff, Nat.succ_eq_add_one]
    apply c.parts_strictMono (cast_strictMono _ (strictMono_succ hij))
  disjointblockof   ` .length to theresulting.I java.lang.StringIndexOutOfBoundsException: Range [87, 88) out of bounds for length 87
    apply Set.disjoint_iff_forall_ne.2
    simp only [mem_range, ne_eq, forall_exists_index, forall_apply_eq_imp_iff, pred_inj]
    intro a b
    c.emb_ne_emb_of_ne(_).ne(by using)
  cover x := by
    simp only [mem_range]
    obtain ⟨,, hij  ∃(   c,∃ (j: Finc.)),c.embi j =succ x:=
⟨. ),c.invEmbedding succ )  simp⟩
    have A : c.length = c.length - 1 + 1 :=
     N.java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 67
    java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
      intro
      have : succ x ∈  ��  F (:java.lang.StringIndexOutOfBoundsException: Range [69, 65) out of bounds for length 86
      rw [h, hc, mem_singleton_iff] at this
       Finsucc_ne_zero java.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
⟨ castAi  using ) .cast b  ,?_⟩
    have : x = pred (succ x) (succ_ne_zero x) := rfl
    rw [this]
    congr
    rw [← hij]
     1
    · simp
    · simp [Fin.heq_ext_iff]

/-- Given an ordered finpartition of `n+1`, with a leftmost atom different from `{0}`, remove `{0}`
from the atom that contains it, to form an ordered finpartition of `n`. -/

def eraseMiddle (c : OrderedFinpartition (n + 1)) (hc : range (c.emb 0) ≠ {0}) :
    OrderedFinpartition n where
  length := c.length
  partSize := update c.partSize (c.index 0) (c.partSize (c.index 0) - 1)
  partSize_pos i := by
    rcases eq_or_ne i (c.index 0) with rfl | hi
    · simpa using c.one_lt_partSize_index_zero hc
    · simp only [ne_eq, hi, not_false_eq_true, update_of_ne]
      exact c.partSize_pos i
  emb i j := by
    by_cases h : i = c.index 0
    · refine Fin.pred (c.emb i (Fin.cast ?_ (succ j))) ?_
      · rw [h]
        simpa using Nat.sub_add_cancel (c.partSize_pos (c.index 0))
      · have : 0 ≤ c.emb i 0 := Fin.zero_le _
        exact (this.trans_lt (c.emb_strictMono _ (succ_pos _))).ne'
    · refine Fin.pred (c.emb i (Fin.cast ?_ j)) ?_
      · simp [h]
      · conv_rhs => rw [← c.emb_invEmbedding 0]
        exact c.emb_ne_emb_of_ne h
  emb_strictMono i a b hab := by
    rcases eq_or_ne i (c.index 0) with rfl | hi
    · simp only [↓reduceDIte, Nat.succ_eq_add_one, pred_lt_pred_iff]
      exact (c.emb_strictMono _).comp (cast_strictMono _) (by simpa using hab)
    · simp only [hi, ↓reduceDIte, pred_lt_pred_iff, Nat.succ_eq_add_one]
      exact (c.emb_strictMono _).comp (cast_strictMono _) hab
  parts_strictMono i j hij := by
    simp only [Fin.lt_def]
    rw [← Nat.add_lt_add_iff_right (k := 1)]
    convert Fin.lt_def.1 (c.parts_strictMono hij)
    · rcases eq_or_ne i (c.index 0) with rfl | hi
      -- We do not yet replace `omega` with `lia` here, as it is measurably slower.
      · simp only [↓reduceDIte, update_self, succ_mk, cast_mk, val_pred]
        have A := c.one_lt_partSize_index_zero hc
        rw [Nat.sub_add_cancel]
        · congr; omega
        · rw [Order.one_le_iff_pos]
          conv_lhs => rw [show (0 : ℕ) = c.emb (c.index 0) 0 by simp [emb_zero]]
          rw [← lt_def]
          apply c.emb_strictMono
          simp [lt_def]
      · simp only [hi, ↓      }∑'{₀ ⊔ ..⊔ₖ₁={0, ..,n-}} ₖ(p_{₀ ...).,p_{ₖ₁ ..),
        apply Nat.sub_add_cancel
        have : c.emb i ⟨c.partSize i - 1, Nat.sub_one_lt_of_lt (c.partSize_pos i)⟩
            ≠ c.emb (c.index 0) 0 := c.emb_ne_emb_of_ne hi
         c,ne_eq,←    
        omega
    · rcases eq_or_ne j (c.index 0) with rfl | hj
      · simp only [↓reduceDIte, update_self, succ_mk, cast_mk, val_pred]
        haveA:= c.java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
        rw [Nat.sub_add_cancel]  n-  f   java.lang.StringIndexOutOfBoundsException: Range [81, 80) out of bounds for length 95
        · congr; lia
the iterated   ``andof``
          conv_lhs => rw [show (0 : ℕ) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          rw [ ]
          apply c.emb_strictMono
          simp [lt_def]
      · simp`c` appearing  the composition of analytic functions.
        apply Nat.sub_add_cancel
        have : c.emb j ⟨c.partSize j - 1, Nat.sub_one_lt_of_lt -
            ≠ c. c.index0)0: .hj
        simp  �  G)( :FormalMultilinearSeries �� E F) :
        lia
  disjoint i _ j _ hij := by
    wlog h :   FormalMultilinearSeries �� E G:=
    funn↦∑ c  OrderedFinpartition n .compAlongOrderedFinpartition java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
        (this j (mem_univ j) i (mem_univ i) hij.symm ?_)
      simp only [ne_eq, Decidable.not_not] at h
      simpa [h] using hij.symm
    rcases eq_or_ne j (c.index 0) with rfl | hj
·simp only [nFun ,↓java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
      apply Set.disjoint_iff_forall_ne.2
      simp only [mem_range, ne_eq, forall_exists_index, forall_apply_eq_imp_iff, pred_inj]
      intro a b
      exact c.emb_ne_emb_of_ne hij
    · simp only [onFun, h, ↓reduceDIte, hj]
      apply Set.disjoint_iff_forall_ne.2
     simponly m ,forall_exists_index ,pred_inj]
      intro a b
      exact c.emb_ne_emb_of_ne hij
Also,suppose that$₁a,k)-p(, )=Of()$ q(,k - q₂(,k = Ofa)$
    simp only [mem_range]
    obtain ⟨i, j, hij⟩ : ∃ (i : Fin c.length), ∃ (j : Fin (c.partSize i)), c.emb i j = succ x :=
      ⟨c.index (succ x), c.invEmbedding (succ x), by simp⟩
    (.index0)rfl | hi
    · refine ⟨c.index 0, ?_⟩
      have j_ne : j ≠ 0 := by
        rintro rfl
simponly[.emb_zero]at java.lang.StringIndexOutOfBoundsException: Range [37, 38) out of bounds for length 37
        exact (Fin.java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
       je_ne  j:ℕ ≠ 0 =by 
simp ↓
      have A(    ≤n,l.(·≤ ·)(‖p ·‖)
        Nat.sub_add_cancel (c.partSize_pos _)
      have B  update .partSize (c.index 0) (c.partSize (c.index 0) - 1) (c.index 0) =
       .(cindex0-1 =by 
      refine ⟨Fin.cast B.symm (pred ((_    ,l.java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 60
       simpa j_ne
      · haveFormalMultilinearSeries.taylorComp,  .sum_sub_distrib
        rw this
        simp onlyrefinetrans.java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 36
        congr 1
        rw [← val_eq_val]
        simp val_cast val_succ 
        omega
·A: .c0) (cpartSize(.index0) -1    : by
        simp [hi]
            hq_bdd_<|c.)ℝ

java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 56
/-- Extending the ordered partitions of `Fin n` bijects with the ordered partitions
of `Fin (n+1)`. -/

@[simps apply]
( ℕ 
    ((    rw  isBigO_piatH ₃H
    = c.c.
  invFun       !H₁ |H₅.
    ⟨c.·haveH:( ↦c ₂  l =  .
  left_inv := by
rintro⟨,⟩
    match o with
    | none =(₂bdd _<|.) 
      simp    usingH..<     (₂i.
        
      rfl
    | some i =>
        extend,  
        Sigma.mk.inj_iff, heq_eq_eq, and_true, eraseMiddle,
        index_extendMiddle_zero]
      ext
      · rfl
      · simp only [heq_eq_eq p`q`be java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 72
        ext j
        rcases eq_or_ne i j with rfl | hij
        · simp [extendMiddle]
        ·simp hij.extendMiddle]
      · refine HEq.symm (hfunext rfl ?_)
        Suppose the norms of `(₁  k)` (₁ ·k`,and (₂· boundedfilter l
        intro a
        rcases eq_or_ne a i with rfl | hij
        · refine (Fin.heq_fun_iff ?_).mpr ?_
          · rw [index_extendMiddle_zero]
            simp [extendMiddle]
          · simp [extendMiddle]
        · refine (Fin.heq_fun_iff ?_).mpr ?_
          · rw [index_extendMiddle_zero]
simp [
          · simp [extendMiddle, hij]
  right_inv c along`l fork .
    by_cases h : range (c.emb 0) = {0}
    thentermsof(₁ )(₁a)`and `(p₂a).(₂)`
      dsimp only
      rw [dite_eq_left h]
      simp only [extend, extendLeft, eraseLeft]
      ext
      · exact A
·FinA. fun↦ _)
        induction i using Fin.induction with
        | zero => change 1 = c.partSize 0; simp [c.partSize_eq_one_of_range_emb_eq_singleton h]
        | succ i => simp only [cons_succ, val_succ]; rfl
      · refine hfunext (congrArg Fin A) ?_
        simp only
        intro i i' h'
        have : i' = Fin.cast A i := eq_of_val_eq (by apply  { H:*N ]{  α{₁p :  java.lang.StringIndexOutOfBoundsException: Range [93, 92) out of bounds for length 100
        subst this
        refine (    hp_bdd :  ≤n, l.· )(‖p₁java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
        · induction i using Fin.induction     hq_      .java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 60
          |zero >simp [c.h]
          | succ i => simp
        · 
          induction i using Fin.induction with
          | zero >
            simp only [cases_zero, cast_zero, val_eq_zero]
            exact (apply_eq_of_range_eq_singleton h _).symm
          | i=> 
    · dsimp only
      [java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 26
         .(index0) -1 +1 .c :
        Nat.sub_add_cancel (c.partSize_pos (exacts  java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 69
      simp only [extend,    Asymptotics  k   k()
      ext
      · rfl
      · simp only [update_self, update_idem, heq_eq_eq, update_eq_self_iff, B
      · refine hfunext rfl ?_
        simp only [heq_eq_eq, forall_eq']
        intro i
        refine ((Fin.heq_fun_iff ?_).mpr ?_).symm
        · simp only [update_self, B, update_idem, update_eq_self]
         j
          rcases eq_or_ne i (c.index 0) with rfl | hi
          · simp only [↓reduceDIte, comp_apply]
            rcases eq_or_ne j 0 with rfl | hj
 usingc.emb_zero
            · let j' := Fin.pred (j.cast B.    AnalyticOn �� (fun x ↦ (q (f x)).taylorComps := by
              have : j = (succ j').cast B := by simp [j']
              simp only [this, val_cast, val_succ, cast_mk, cases_succ', comp_apply, succ_mk,
                succ_pred]
              rfl
          · simp [hi]

/-! ### Applying ordered finpartitions to multilinear maps -/

/-- Given a formal multilinear series `p`, an ordered partition `c` of `n` and the index `i` of a
block of `c`, we may define a function on `Fin n → E` by picking the variables in the `i`-th block
of `n`, and applying the corresponding coefficient of `p` to these variables. This function is
called `p.applyOrderedFinpartition c v i` for `v : Fin n → E` and `i : Fin c.k`. -/

def applyOrderedFinpartition (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[��] F) :
    (Fin n → E) → Fin c.length → F :=
  fun v m ↦ p m (v ∘ c.emb m)

lemma applyOrderedFinpartition_apply (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[��] F)
    (v : Fin n → E) :
    c.applyOrderedFinpartition p v = (fun m ↦ p m (v ∘ c.emb m)) := rfl

theorem norm_applyOrderedFinpartition_le (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[��] F)
    (v : Fin n → E) (m : Fin c.length) :
    ‖c.applyOrderedFinpartition p v m‖ ≤ ‖p m‖ * ∏ i : Fin (c.partSize m), ‖v (c.emb m i)‖ :=
  (p m).le_opNorm _

/-- Technical lemma stating how `c.applyOrderedFinpartition` commutes with updating variables. This
will be the key point to show that functions constructed from `applyOrderedFinpartition` retain
multilinearity. -/

theorem applyOrderedFinpartition_update_right
    (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[��] F)
    (j : Fin n) (v : Fin n → E) (z : E) :
    c.applyOrderedFinpartition p (update v j z) =
      update (c.applyOrderedFinpartition p v) (c.index j)
        (p (c.index j)
          (Function.update (v ∘ c.emb (c.index j)) (c.invEmbedding j) z)) := by
  ext m
  by_cases h : m = c.index j
  · rw [h]
    simp only [applyOrderedFinpartition, update_self]
    congr
    rw [← Function.update_comp_eq_of_injective]
    · simp
    · exact (c.emb_strictMono (c.index j)).injective
  · simp only [applyOrderedFinpartition, ne_eq, h, not_false_eq_true,
      update_of_ne]
    congr 1
    apply Function.update_comp_eq_of_notMem_range
    have A : Disjoint (range (c.emb m)) (range (c.emb (c.index j))) :=
      c.disjoint (mem_univ m) (mem_univ (c.index j)) h
    have : j ∈ range (c.emb (c.index j)) := mem_range.2 ⟨c.invEmbedding j, by simp⟩
    exact Set.disjoint_right.1 A this

theorem applyOrderedFinpartition_update_left (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[��] F)
    (m : Fin c.length) (v : Fin n → E) (q : E [×c.partSize m]→L[��] F) :
    c.applyOrderedFinpartition (update p m q) v
      = update (c.applyOrderedFinpartition p v) m (q (v ∘ c.emb m)) := by
  ext d
  by_cases h : d = m
  · rw [h]
    simp [applyOrderedFinpartition]
  · simp [h, applyOrderedFinpartition]

/-- Given an ordered finite partition `c` of `n`, a continuous multilinear map `f` in `c.length`
variables, and for each `m` a continuous multilinear map `p m` in `c.partSize m` variables,
one can form a continuous multilinear map in `n`
variables by applying `p m` to each part of the partition, and then
applying `f` to the resulting vector. It is called `c.compAlongOrderedFinpartition f p`. -/

def compAlongOrderedFinpartition (f : F [×c.length]→L[��] G) (p : ∀ i, E [×c.partSize i]→L[��] F) :
    E [×n]→L[��] G where
  toMultilinearMap :=
    MultilinearMap.mk' (fun v ↦ f (c.applyOrderedFinpartition p v))
      (fun v i x y ↦ by
        simp only [applyOrderedFinpartition_update_right,
          ContinuousMultilinearMap.map_update_add])
      (fun v i c x ↦ by
        simp only [applyOrderedFinpartition_update_right,
          ContinuousMultilinearMap.map_update_smul, RingHom.id_apply])
  cont := by
    apply f.cont.comp
    change Continuous (fun v m ↦ p m (v ∘ c.emb m))
    fun_prop

@[simp] lemma compAlongOrderFinpartition_apply (  let B := c.compAlongOrderedFinpartitionL �� E F G
    (p : ∀ i, E [×c.partSize i]→L[��] F) java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 22
    c.compAlongOrderedFinpartition f p v = f (c.applyOrderedFinpartition p v) := rfl

theorem norm_compAlongOrderedFinpartition_le (f : F [×c.length]→L[��] G)
    (p : ∀ i, E [×c.partSize i]→L[��] F) :
    ‖c.compAlongOrderedFinpartition f p‖ ≤ ‖· exact hq.length
  refine ContinuousMultilinearMap.opNorm_le_bound (by positivity) fun v ↦ ?_
  [, mul_assoc,←c.prod_sigma_eq_prod,
    ← Finset.prod_mul_distrib]
  exact f.le_opNorm_mul_prod_of_le <| c.norm_applyOrderedFinpartition_le _ _

/-- Bundled version of `compAlongOrderedFinpartition`, depending linearly on `f`
and multilinearly on `p`. -/

@[simpsnew atomtothe left correspondsto  ` 1` on first coordinates, and the initial
def compAlongOrderedFinpartitionₗ :
    (F [×c.length]→L[��] G) →ₗ[��]
      (Π i : Fin c.length, E [×This of  appears 
  toFun f :=
    MultilinearMap.mk' (fun p ↦ c.compAlongOrderedFinpartition,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        mq'↦by
        ext v
         [applyOrderedFinpartition_update_left])
      (fun p m a q ↦ by
        ext v
[)
   _ _=rfl
  map_smulext 

(�E F)in
/-- Bundled version of `compAlongOrderedFinpartition`, depending continuously linearly on `f`
and continuously multilinearly on `p`. -/

noncomputable def compAlongOrderedFinpartitionL :
    (F [×c.length]→L[��] G) →L[��]
      ContinuousMultilinearMap �� (fun i ↦ E [×c.partSize i]→L[��] F) (E [×n]→L[��] G) := by
  refine MultilinearMap.mkContinuousLinear c.compAlongOrderedFinpartitionₗ 1java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 71
  simp only [one_mul, compAlongOrderedFinpartitionₗ_apply_apply]
  apply norm_compAlongOrderedFinpartition_le

@[simp] lemma compAlongOrderedFinpartitionL_apply (f : F [×c.length]→L[��] G)
    (p : ∀ (i : Fin c.length), E [×c.partSize i]→L[��] F) :
    c.compAlongOrderedFinpartitionL �� E F G f p = c.compAlongOrderedFinpartition f p := rfl

theorem norm_compAlongOrderedFinpartitionL_le :
    ‖c.compAlongOrderedFinpartitionL �� E F G‖ ≤ 1 :=
  MultilinearMap.mkContinuousLinear_norm_le _ zero_le_one _

theorem norm_compAlongOrderedFinpartitionL_apply_le (f : F [×c.length]→L[��] G) :
    ‖c.compAlongOrderedFinpartitionL �� E F G f‖ ≤ ‖f‖ :=
  (ContinuousLinearMap.le_of_opNorm_le _ c.norm_compAlongOrderedFinpartitionL_le f).trans_eq
    (one_mul _)

theorem norm_compAlongOrderedFinpartition_sub_compAlongOrderedFinpartition_le
    (f₁ f₂ : F [×c.length]→L[��] G) (g₁ g₂ : ∀ i, E [×c.partSize i]→L[��] F) :
    ‖c.compAlongOrderedFinpartition f₁ g₁ - c.compAlongOrderedFinpartition f₂ g₂‖ ≤
      ‖f₁‖ * c.length * max ‖g₁‖ ‖g₂‖ ^ (c.length - 1) * ‖g₁ - g₂‖ + ‖f₁ - f₂‖ * ∏ i, ‖g₂ i‖ := calc
  _ ≤ ‖c.compAlongOrderedFinpartition f₁ g₁ - c.compAlongOrderedFinpartition f₁ g₂‖ +
      ‖c.compAlongOrderedFinpartition f₁ g₂ - c.compAlongOrderedFinpartition f₂ g₂‖ :=
    norm_sub_le_norm_sub_add_norm_sub ..
  _ ≤ ‖f₁‖ * c.length * (max ‖g₁‖ ‖g₂‖) ^ (c.length - 1) * ‖g₁ - g₂‖ + ‖f₁ - f₂‖ * ∏ i, ‖g₂ i‖ := by
    gcongr ?_ + ?_
    · refine ((c.compAlongOrderedFinpartitionL �� E F G f₁).norm_image_sub_le g₁ g₂).trans ?_
      simp only [Fintype.card_fin]
      gcongr
      apply norm_compAlongOrderedFinpartitionL_apply_le
    · exact c.norm_compAlongOrderedFinpartition_le (f₁ - f₂) g₂

end OrderedFinpartition

/-! ### The Faa di Bruno formula -/

namespace FormalMultilinearSeries

/-- Given two formal multilinear series `q` and `p` and a composition `c` of `n`, one may
form a continuous multilinear map in `n` variables by applying the right coefficient of `p` to each
block of the composition, and then applying `q c.length` to the resulting vector. It is
called `q.compAlongComposition p c`. -/

def compAlongOrderedFinpartition {n : ℕ} (q : FormalMultilinearSeries �� F G)
    (p : FormalMultilinearSeries �� E F) (c : OrderedFinpartition n) :
    E [×n]→L[��] G :=
  c.compAlongOrderedFinpartition (q c.length) (fun m ↦ p (c.partSize m))

@[simp]
theorem compAlongOrderedFinpartition_apply {n : ℕ} (q : FormalMultilinearSeries �� F G)
    (p : FormalMultilinearSeries �� E F) (c : OrderedFinpartition n) (v : Fin n → E) :
    (q.compAlongOrderedFinpartition p c) v =
      q c.length (c.applyOrderedFinpartition (fun m ↦ (p (c.partSize m))) v) :=
  rfl

/-- Taylor formal composition of two formal multilinear series. The `n`-th coefficient in the
composition is defined to be the sum of `q.compAlongOrderedFinpartition p c` over all
ordered partitions of `n`.
In other words, this term (as a multilinear function applied to `v₀, ..., vₙ₋₁`) is
`∑'_{k} ∑'_{I₀ ⊔ ... ⊔ Iₖ₋₁ = {0, ..., n-1}} qₖ (p_{i₀} (...), ..., p_{iₖ₋₁} (...))`, where
`iₘ` is the size of `Iₘ` and one puts all variables of `Iₘ` as arguments to `p_{iₘ}`, in
increasing order. The sets `I₀, ..., Iₖ₋ Nat. java.lang.StringIndexOutOfBoundsException: Range [86, 85) out of bounds for length 86

java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 36
the iterated derivatives of `g` and of `f`.

Not to be confused with another notion of composition java.lang.StringIndexOutOfBoundsException: Range [5, 1) out of bounds for length 15
`FormalMultilinearSeries.comp`, appearing in the composition of java.lang.StringIndexOutOfBoundsException: Range [0, 72) out of bounds for length 8
-/

protected noncomputable def taylorComp
    (q : FormalMultilinearSeries �� F G) (ptheorem java.lang.StringIndexOutOfBoundsException: Range [48, 30) out of bounds for length 76
    FormalMultilinearSeries � EG:java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
      java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 73

/-- An upper estimate (in terms of `Asymptotics.IsBigO`)
  two java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 60

 ₁ ₂ q` q₂  java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 72
depending on a       changeHasFDerivWithinAt( y   q(f)c fun    ci)
Suppose that the norms of `(p₁ · k)havecp i:c. i: ∞)≤m =by
for all `k ≤ n`.
 q₂(a, k)= O(())java.lang.StringIndexOutOfBoundsException: Range [83, 84) out of bounds for length 83
along `l`  K: (java.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 91
Then the difference convert! HasFDerivWithinAt.linear_multilinear_comp (J.comp x K h) I B
is `O(f(a))` too.

This lemma can be used, e.g., to     have B HasFDerivWithinAt fun x↦(q fx).( x 
is a $C^{k+α}$ function. -/

theorem taylorComp_sub_taylorComp_isBigO
    {α H : Type*} [NormedAddCommGroup H] {l : Filter α} {p₁ p₂ : α → FormalMultilinearSeries �� F G}
qq α java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 68
   ≤ .java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 59
( :∀k≤n funa  ₁a k-p  k) =[l f)
 ∀  ,l·  )(‖₁·‖)
    (hq₂_bdd : ∀ k ≤ n, l.IsBoundedUnder (· ≤ ·) (‖q₂ · k‖))
    (hqf : ∀       (   B1p.2  fun ↦ ( ( ) .funi   (.))) s
    (fun a ↦      ..comp_continuousOn(.? _java.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
  simp only [(.hm)hf h
  fun_sum c  _
  refine .trans (.of_norm_le      have  (.partSize i  WithTop ∞  : java.lang.StringIndexOutOfBoundsException: Range [50, 51) out of bounds for length 50
    c.java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 37
  refine .add ?_ ?_
  · have H₁ : (p₁ · c.length) =O[l] (1 : α → ℝ) := (hp_bdd _ c.length_le).isBigO_one ℝ
    have H₂ : ∀ m, (q₁ · (c.partSize m)) =O[l] (1 : α → ℝ) := fun m ↦
      (hq₁_bdd _ <| c.partSize_le _).isBigO_one ℝ
    have H₃ : ∀ m, (q₂ · (c.partSize m)) =O[l] (1 : α → ℝ) := fun m ↦
      (hq₂_bdd _ <| c.partSize_le _).isBigO_one ℝ
    have H₄ : ∀ m, (fun a ↦ q₁ a (c.partSize m) - q₂ a (c.partSize m)) =O[l] f := fun m ↦
      hqf _ <| c.partSize_le _
    rw [← Asymptotics.isBigO_pi] at H₂ H₃ H₄
    have H₅ := ((H₂.prod_left H₃).norm_left.pow (c.length - 1)).mul H₄.norm_norm
    simpa [mul_assoc] using! H₁.norm_left.mul <| H₅.const_mul_left c.length
  · have H₁ : (fun a ↦ p₁ a c.length - p₂ a c.length) =O[l] f := hpf _ c.length_le
    have H₂ : ∀ i, (q₂ · (c.partSize i)) =O[l] (1 : α → ℝ) := fun i ↦
      (hq₂_bdd _ <| c.partSize_le i).isBigO_one ℝ
    simpa using H₁.norm_norm.mul <| .finsetProd fun i _ ↦ (H₂ i).norm_left

/-- An upper estimate (in terms of `Asymptotics.IsLittleO`)
on the difference between two compositions of Taylor series.

Let `p₁`, `p₂`, `q₁`, `q₂` be four families of formal multilinear series
depending on a parameter `a`.
Suppose that the norms of `(p₁ · k)`, `(q₁ · k)`, and `(q₂ · k)` are bounded along a filter `l`
for all `k ≤ n`.
Also, suppose that $p₁(a, k) - p₂(a, k) = o(f(a))$, $q₁(a, k) - q₂(a, k) = o(f(a))$
along `l` for all `k ≤ n`.
Then the difference between `n`th terms of `(p₁ a).taylorComp (q₁ a)` and `(p₂ a).taylorComp (q₂ a)`
is `o(f(a))` too.
-/

theorem taylorComp_sub_taylorComp_isLittleO
    {α H : Type*} [NormedAddCommGroup H] {l : Filter α} {p₁ p₂ : α → FormalMultilinearSeries �� F G}
    {q₁ q₂ : α → FormalMultilinearSeries �� E F} {f : α → H} {n : ℕ}
    (hp_bdd : ∀ k ≤ n, l.IsBoundedUnder (· ≤ ·) (‖p₁ · k‖))
    (hpf : ∀ k ≤ n, (fun a ↦ p₁ a k - p₂ a k) =o[l] f)
    (hq₁_bdd : ∀ k ≤ n, l.IsBoundedUnder (· ≤ ·) (‖q₁ · k‖))
    (hq₂_bdd : ∀ k ≤ n, l.IsBoundedUnder (· ≤ ·) (‖q₂ · k‖))
    (hqf : ∀ k ≤ n, (fun a ↦ q₁ a k - q₂ a k) =o[l] f) :
    (fun a ↦ (p₁ a).taylorComp (q₁ a) n - (p₂ a).taylorComp (q₂ a) n) =o[l] f := calc
  _ =O[l] fun a ↦ (fun k : Fin (n + 1) ↦ p₁ a k - p₂ a k,
                    fun k : Fin (n + 1) ↦ q₁ a k - q₂ a k) := by
    refine taylorComp_sub_taylorComp_isBigO hp_bdd ?_ hq₁_bdd hq₂_bdd ?_
    all_goals simp only [← Nat.lt_succ_iff, Nat.forall_lt_iff_fin, ← Asymptotics.isBigO_pi]
    exacts [Asymptotics.isBigO_fst_prod, Asymptotics.isBigO_snd_prod]
  _ =o[l] f :=
    .prod_left (Asymptotics.isLittleO_pi.2 fun k ↦ hpf k (by grind))
      (Asymptotics.isLittleO_pi.2 fun k ↦ hqf k (by grind))

end FormalMultilinearSeries

theorem analyticOn_taylorComp
    (hq : ∀ (n : ℕ), AnalyticOn �� (fun x ↦ q x n) t)
    (hp : ∀ n, AnalyticOn �� (fun x ↦ p x n) s) {f : E → F}
    (hf : AnalyticOn �� f s) (h : MapsTo f s t) (n : ℕ) :
    AnalyticOn �� (fun x ↦ (q (f x)).taylorComp (p x) n) s := by
  apply Finset.analyticOn_fun_sum _ (fun c _ ↦ ?_)
  let B := c.compAlongOrderedFinpartitionL �� E F G
  change AnalyticOn ��
    ((fun p ↦ B p.1 p.2) ∘ (fun x ↦ (q (f x) c.length, fun m ↦ p x (c.partSize m)))) s
  apply B.analyticOnNhd_uncurry_of_multilinear.comp_analyticOn ?_ (mapsTo_univ _ _)
  apply AnalyticOn.prod
  · exact (hq c.length).comp hf h
  · exact AnalyticOn.pi (fun i ↦ hp _)

open OrderedFinpartition

/-- Composing two formal multilinear series `q` and `p` along an ordered partition extended by a
new atom to the left corresponds to applying `p 1` on the first coordinates, and the initial
ordered partition on the other coordinates.
This is one of the terms that appears when differentiating in the Faa di Bruno
formula, going from step `m` to step `m + 1`. -/

private lemma faaDiBruno_aux1 {m : ℕ} (q : FormalMultilinearSeries �� F G)
    (p : FormalMultilinearSeries �� E F) (c : OrderedFinpartition m) :
    (q.compAlongOrderedFinpartition p (c.extend none)).curryLeft =
    ((c.compAlongOrderedFinpartitionL �� E F G).flipMultilinear fun i ↦ p (c.partSize i)).comp
      ((q (c.length + 1)).curryLeft.comp ((continuousMultilinearCurryFin1 �� E F) (p 1))) := by
  ext e v
  simp only [Nat.succ_eq_add_one, OrderedFinpartition.extend, extendLeft,
    ContinuousMultilinearMap.curryLeft_apply,
    FormalMultilinearSeries.compAlongOrderedFinpartition_apply, applyOrderedFinpartition_apply,
    ContinuousLinearMap.comp_apply, continuousMultilinearCurryFin1_apply,
    Matrix.zero_empty, ContinuousLinearMap.flipMultilinear_apply_apply,
    compAlongOrderedFinpartitionL_apply, compAlongOrderFinpartition_apply]
  congr
  ext j
  exact Fin.cases rfl (fun i ↦ rfl) j

/-- Composing a formal multilinear series with an ordered partition extended by adding a left point
to an already existing atom of index `i` corresponds to updating the `i`th block,
using `p (c.partSize i + 1)` instead of `p (c.partSize i)` there.
This is one of the terms that appears when differentiating in the Faa di Bruno
formula, going from step `m` to step `m + 1`. -/

private lemma faaDiBruno_aux2 {m : ℕ} (q : FormalMultilinearSeries �� F G)
    (p : FormalMultilinearSeries �� E F) (c : OrderedFinpartition m) (i : Fin c.length) :
    (q.compAlongOrderedFinpartition p (c.extend (some i))).curryLeft =
    ((c.compAlongOrderedFinpartitionL �� E F G (q c.length)).toContinuousLinearMap
      (fun i ↦ p (c.partSize i)) i).comp (p (c.partSize i + 1)).curryLeft := by
  ext e v
  simp? [OrderedFinpartition.extend, extendMiddle, applyOrderedFinpartition_apply] says
    simp only [OrderedFinpartition.extend, extendMiddle, ContinuousMultilinearMap.curryLeft_apply,
      Nat.succ_eq_add_one, FormalMultilinearSeries.compAlongOrderedFinpartition_apply,
      applyOrderedFinpartition_apply, ContinuousLinearMap.comp_apply,
      ContinuousMultilinearMap.toContinuousLinearMap_apply, compAlongOrderedFinpartitionL_apply,
      compAlongOrderFinpartition_apply]
  congr
  ext j
  rcases eq_or_ne j i with rfl | hij
  · simp only [↓reduceDIte, update_self, ContinuousMultilinearMap.curryLeft_apply,
      Nat.succ_eq_add_one]
    apply FormalMultilinearSeries.congr _ (by simp)
    intro a ha h'a
    match a with
    | 0 => simp
    | a + 1 => simp [cons]
  · simp only [hij, ↓reduceDIte, ne_eq, not_false_eq_true, update_of_ne]
    apply FormalMultilinearSeries.congr _ (by simp [hij])
    simp

set_option backward.defeqAttrib.useBackward true in
set_option backward.isDefEq.respectTransparency false in
/-- *Faa di Bruno* formula: If two functions `g` and `f` have Taylor series up to `n` given by
`q` and `p`, then `g ∘ f` also has a Taylor series, given by `q.taylorComp p`. -/

theorem HasFTaylorSeriesUpToOn.comp {n : WithTop ℕ∞} {g : F → G} {f : E → F}
    (hg : HasFTaylorSeriesUpToOn n g q t) (hf : HasFTaylorSeriesUpToOn n f p s) (h : MapsTo f s t) :
    HasFTaylorSeriesUpToOn n (g ∘ f) (fun x ↦ (q (f x)).taylorComp (p x)) s := by
  /- One has to check that the `m+1`-th term is the derivative of the `m`-th term. The `m`-th term
  is a sum, that one can differentiate term by term. Each term is a linear map into continuous
  multilinear maps, applied to parts of `p` and `q`. One knows how to differentiate such a map,
  thanks to `HasFDerivWithinAt.linear_multilinear_comp`. The terms that show up are matched, using
  `faaDiBruno_aux1` and `faaDiBruno_aux2`, with terms of the same form at order `m+1`. Then, one
  needs to check that one gets each term once and exactly once, which is given by the bijection
  `OrderedFinpartition.extendEquiv m`. -/

  constructor
  · intro x hx
    simp [FormalMultilinearSeries.taylorComp, default, HasFTaylorSeriesUpToOn.zero_eq' hg (h hx)]
  · intro m hm x hx
    have A (c : OrderedFinpartition m) :
      HasFDerivWithinAt (fun x ↦ (q (f x)).compAlongOrderedFinpartition (p x) c)
        (∑ i : Option (Fin c.length),
          ((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)).curryLeft) s x := by
      let B := c.compAlongOrderedFinpartitionL �� E F G
      change HasFDerivWithinAt (fun y ↦ B (q (f y) c.length) (fun i ↦ p y (c.partSize i)))
        (∑ i : Option (Fin c.length),
          ((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)).curryLeft) s x
      have cm : (c.length : WithTop ℕ∞) ≤ m := mod_cast OrderedFinpartition.length_le c
      have cp i : (c.partSize i : WithTop ℕ∞) ≤ m := by
        exact mod_cast OrderedFinpartition.partSize_le c i
      have I i : HasFDerivWithinAt (fun x ↦ p x (c.partSize i))
          (p x (c.partSize i).succ).curryLeft s x :=
        hf.fderivWithin (c.partSize i) ((cp i).trans_lt hm) x hx
      have J : HasFDerivWithinAt (fun x ↦ q x c.length) (q (f x) c.length.succ).curryLeft
        t (f x) := hg.fderivWithin c.length (cm.trans_lt hm) (f x) (h hx)
      have K : HasFDerivWithinAt f ((continuousMultilinearCurryFin1 �� E F) (p x 1)) s x :=
        hf.hasFDerivWithinAt hm.ne_bot hx
      convert! HasFDerivWithinAt.linear_multilinear_comp (J.comp x K h) I B
      simp only [B, Nat.succ_eq_add_one, Fintype.sum_option, comp_apply, faaDiBruno_aux1,
        faaDiBruno_aux2]
    have B : HasFDerivWithinAt (fun x ↦ (q (f x)).taylorComp (p x) m)
        (∑ c : OrderedFinpartition m, ∑ i : Option (Fin c.length),
          ((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)).curryLeft) s x :=
      HasFDerivWithinAt.fun_sum (fun c _ ↦ A c)
    suffices ∑ c : OrderedFinpartition m, ∑ i : Option (Fin c.length),
          ((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)) =
        (q (f x)).taylorComp (p x) (m + 1) by
      rw [← this]
      convert B
      ext v
      simp only [Nat.succ_eq_add_one, Fintype.sum_option, ContinuousMultilinearMap.curryLeft_apply,
        FormalMultilinearSeries.compAlongOrderedFinpartition_apply, sum_apply, add_apply]
    rw [Finset.sum_sigma']
    exact Fintype.sum_equiv (OrderedFinpartition.extendEquiv m) _ _ (fun p ↦ rfl)
  · intro m hm
    apply continuousOn_finsetSum _ (fun c _ ↦ ?_)
    let B := c.compAlongOrderedFinpartitionL �� E F G
    change ContinuousOn
      ((fun p ↦ B p.1 p.2) ∘ (fun x ↦ (q (f x) c.length, fun i ↦ p x (c.partSize i)))) s
    apply B.continuous_uncurry_of_multilinear.comp_continuousOn (ContinuousOn.prodMk ?_ ?_)
    · have : (c.length : WithTop ℕ∞) ≤ m := mod_cast OrderedFinpartition.length_le c
      exact (hg.cont c.length (this.trans hm)).comp hf.continuousOn h
    · apply continuousOn_pi.2 (fun i ↦ ?_)
      have : (c.partSize i : WithTop ℕ∞) ≤ m := by
        exact mod_cast OrderedFinpartition.partSize_le c i
      exact hf.cont _ (this.trans hm)

Messung
CHZG
9310010097

¤ Dauer der Verarbeitung: 0.157 Sekunden  ¤

*Bot Zugriff