l3lab/ntp-mathlib huggingface dataset:
/-- Picard-Lindelöf (Cauchy-Lipschitz) theorem. -/
theorem IsPicardLindelof.exists_forall_hasDerivWithinAt_Icc_eq [CompleteSpace E] {v : ℝ → E → E}
    {tMin t₀ tMax : ℝ} (x₀ : E) {C R : ℝ} {L : ℝ≥0}
    (hpl : IsPicardLindelof v tMin t₀ tMax x₀ L R C) :
    ∃ f : ℝ → E, f t₀ = x₀ ∧
      ∀ t ∈ Icc tMin tMax, HasDerivWithinAt f (v t (f t)) (Icc tMin tMax) t := by
  lift C to ℝ≥0 using (norm_nonneg _).trans hpl.norm_le₀
  lift t₀ to Icc tMin tMax using hpl.ht₀
  

Proof state:
case intro.intro
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
v : ℝ → E → E
tMin tMax : ℝ
x₀ : E
R : ℝ
L C : ℝ≥0
t₀ : { x // x ∈ Icc tMin tMax }
hpl : IsPicardLindelof v tMin (↑t₀) tMax x₀ L R ↑C
⊢ ∃ f, f ↑t₀ = x₀ ∧ ∀ t ∈ Icc tMin tMax, HasDerivWithinAt f (v t (f t)) (Icc tMin tMax) t

Next tactic:
exact PicardLindelof.exists_solution
    ⟨v, tMin, tMax, t₀, x₀, C, ⟨R, hpl.hR⟩, L, { hpl with ht₀ := t₀.property }⟩
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
⊢ ∃ ε > 0, ∃ L R C, IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C

Next tactic:
obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  

Proof state:
case intro.intro.intro
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
⊢ ∃ ε > 0, ∃ L R C, IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C

Next tactic:
obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  

Proof state:
case intro.intro.intro.intro.intro
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
⊢ ∃ ε > 0, ∃ L R C, IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C

Next tactic:
obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
⊢ ∃ ε > 0, ∃ L R C, IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C

Next tactic:
have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
hbdd' : ∀ x ∈ ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖
⊢ ∃ ε > 0, ∃ L R C, IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C

Next tactic:
set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
  set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
hbdd' : ∀ x ∈ ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖
ε : ℝ := min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε : ε = min R₁ R₂ / 2 / (1 + ‖v x₀‖)
⊢ ∃ ε > 0, ∃ L R C, IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C

Next tactic:
have hε0 : 0 < ε := hε ▸ div_pos (half_pos <| lt_min hR₁ hR₂)
    (add_pos_of_pos_of_nonneg zero_lt_one (norm_nonneg _))
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
  set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
  have hε0 : 0 < ε := hε ▸ div_pos (half_pos <| lt_min hR₁ hR₂)
    (add_pos_of_pos_of_nonneg zero_lt_one (norm_nonneg _))
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
hbdd' : ∀ x ∈ ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖
ε : ℝ := min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε : ε = min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε0 : 0 < ε
⊢ ∃ ε > 0, ∃ L R C, IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C

Next tactic:
refine' ⟨ε, hε0, L, min R₁ R₂ / 2, 1 + ‖v x₀‖, _⟩
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
  set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
  have hε0 : 0 < ε := hε ▸ div_pos (half_pos <| lt_min hR₁ hR₂)
    (add_pos_of_pos_of_nonneg zero_lt_one (norm_nonneg _))
  refine' ⟨ε, hε0, L, min R₁ R₂ / 2, 1 + ‖v x₀‖, _⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
hbdd' : ∀ x ∈ ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖
ε : ℝ := min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε : ε = min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε0 : 0 < ε
⊢ IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L (min R₁ R₂ / 2) (1 + ‖v x₀‖)

Next tactic:
exact
    { ht₀ := Real.closedBall_eq_Icc ▸ mem_closedBall_self hε0.le
      hR := by positivity
      lipschitz := fun _ _ => hlip.mono <|
        (closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
        (Metric.ball_subset_ball <| min_le_left _ _).trans hball
      cont := fun _ _ => continuousOn_const
      norm_le := fun _ _ x hx => hbdd' x <| mem_of_mem_of_subset hx <|
        (closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
        (Metric.ball_subset_ball <| min_le_right _ _).trans (subset_refl _)
      C_mul_le_R := by
        rw [add_sub_cancel', sub_sub_cancel, max_self, hε, mul_div_left_comm, div_self, mul_one]
        exact ne_of_gt <| add_pos_of_pos_of_nonneg zero_lt_one <| norm_nonneg _ }
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
  set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
  have hε0 : 0 < ε := hε ▸ div_pos (half_pos <| lt_min hR₁ hR₂)
    (add_pos_of_pos_of_nonneg zero_lt_one (norm_nonneg _))
  refine' ⟨ε, hε0, L, min R₁ R₂ / 2, 1 + ‖v x₀‖, _⟩
  exact
    { ht₀ := Real.closedBall_eq_Icc ▸ mem_closedBall_self hε0.le
      hR := by 

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
hbdd' : ∀ x ∈ ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖
ε : ℝ := min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε : ε = min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε0 : 0 < ε
⊢ 0 ≤ min R₁ R₂ / 2

Next tactic:
positivity
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
  set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
  have hε0 : 0 < ε := hε ▸ div_pos (half_pos <| lt_min hR₁ hR₂)
    (add_pos_of_pos_of_nonneg zero_lt_one (norm_nonneg _))
  refine' ⟨ε, hε0, L, min R₁ R₂ / 2, 1 + ‖v x₀‖, _⟩
  exact
    { ht₀ := Real.closedBall_eq_Icc ▸ mem_closedBall_self hε0.le
      hR := by positivity
      lipschitz := fun _ _ => hlip.mono <|
        (closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
        (Metric.ball_subset_ball <| min_le_left _ _).trans hball
      cont := fun _ _ => continuousOn_const
      norm_le := fun _ _ x hx => hbdd' x <| mem_of_mem_of_subset hx <|
        (closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
        (Metric.ball_subset_ball <| min_le_right _ _).trans (subset_refl _)
      C_mul_le_R := by
        

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
hbdd' : ∀ x ∈ ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖
ε : ℝ := min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε : ε = min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε0 : 0 < ε
⊢ (1 + ‖v x₀‖) * max (t₀ + ε - t₀) (t₀ - (t₀ - ε)) ≤ min R₁ R₂ / 2

Next tactic:
rw [add_sub_cancel', sub_sub_cancel, max_self, hε, mul_div_left_comm, div_self, mul_one]
/-- A time-independent, continuously differentiable ODE satisfies the hypotheses of the
  Picard-Lindelöf theorem. -/
theorem exists_isPicardLindelof_const_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ), ∃ L R C, IsPicardLindelof (fun _ => v) (t₀ - ε) t₀ (t₀ + ε) x₀ L R C := by
  obtain ⟨L, s, hs, hlip⟩ := hv.exists_lipschitzOnWith
  obtain ⟨R₁, hR₁ : 0 < R₁, hball⟩ := Metric.mem_nhds_iff.mp hs
  obtain ⟨R₂, hR₂ : 0 < R₂, hbdd⟩ := Metric.continuousAt_iff.mp hv.continuousAt.norm 1 zero_lt_one
  have hbdd' : ∀ x ∈ Metric.ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖ := fun _ hx =>
    sub_le_iff_le_add.mp <| le_of_lt <| lt_of_abs_lt <| Real.dist_eq _ _ ▸ hbdd hx
  set ε := min R₁ R₂ / 2 / (1 + ‖v x₀‖) with hε
  have hε0 : 0 < ε := hε ▸ div_pos (half_pos <| lt_min hR₁ hR₂)
    (add_pos_of_pos_of_nonneg zero_lt_one (norm_nonneg _))
  refine' ⟨ε, hε0, L, min R₁ R₂ / 2, 1 + ‖v x₀‖, _⟩
  exact
    { ht₀ := Real.closedBall_eq_Icc ▸ mem_closedBall_self hε0.le
      hR := by positivity
      lipschitz := fun _ _ => hlip.mono <|
        (closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
        (Metric.ball_subset_ball <| min_le_left _ _).trans hball
      cont := fun _ _ => continuousOn_const
      norm_le := fun _ _ x hx => hbdd' x <| mem_of_mem_of_subset hx <|
        (closedBall_subset_ball <| half_lt_self <| lt_min hR₁ hR₂).trans <|
        (Metric.ball_subset_ball <| min_le_right _ _).trans (subset_refl _)
      C_mul_le_R := by
        rw [add_sub_cancel', sub_sub_cancel, max_self, hε, mul_div_left_comm, div_self, mul_one]
        

Proof state:
E : Type u_1
inst✝¹ : NormedAddCommGroup E
inst✝ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
hv : ContDiffAt ℝ 1 v x₀
L : ℝ≥0
s : Set E
hs : s ∈ 𝓝 x₀
hlip : LipschitzOnWith L v s
R₁ : ℝ
hR₁ : 0 < R₁
hball : ball x₀ R₁ ⊆ s
R₂ : ℝ
hR₂ : 0 < R₂
hbdd : ∀ {x : E}, dist x x₀ < R₂ → dist ‖v x‖ ‖v x₀‖ < 1
hbdd' : ∀ x ∈ ball x₀ R₂, ‖v x‖ ≤ 1 + ‖v x₀‖
ε : ℝ := min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε : ε = min R₁ R₂ / 2 / (1 + ‖v x₀‖)
hε0 : 0 < ε
⊢ 1 + ‖v x₀‖ ≠ 0

Next tactic:
exact ne_of_gt <| add_pos_of_pos_of_nonneg zero_lt_one <| norm_nonneg _
/-- A time-independent, continuously differentiable ODE admits a solution in some open interval. -/
theorem exists_forall_hasDerivAt_Ioo_eq_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ),
      ∃ f : ℝ → E, f t₀ = x₀ ∧ ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t := by
  

Proof state:
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
inst✝ : CompleteSpace E
hv : ContDiffAt ℝ 1 v x₀
⊢ ∃ ε > 0, ∃ f, f t₀ = x₀ ∧ ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t

Next tactic:
obtain ⟨ε, hε, _, _, _, hpl⟩ := exists_isPicardLindelof_const_of_contDiffAt t₀ hv
/-- A time-independent, continuously differentiable ODE admits a solution in some open interval. -/
theorem exists_forall_hasDerivAt_Ioo_eq_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ),
      ∃ f : ℝ → E, f t₀ = x₀ ∧ ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t := by
  obtain ⟨ε, hε, _, _, _, hpl⟩ := exists_isPicardLindelof_const_of_contDiffAt t₀ hv
  

Proof state:
case intro.intro.intro.intro.intro
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
inst✝ : CompleteSpace E
hv : ContDiffAt ℝ 1 v x₀
ε : ℝ
hε : ε > 0
w✝² : ℝ≥0
w✝¹ w✝ : ℝ
hpl : IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ w✝² w✝¹ w✝
⊢ ∃ ε > 0, ∃ f, f t₀ = x₀ ∧ ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t

Next tactic:
obtain ⟨f, hf1, hf2⟩ := hpl.exists_forall_hasDerivWithinAt_Icc_eq x₀
/-- A time-independent, continuously differentiable ODE admits a solution in some open interval. -/
theorem exists_forall_hasDerivAt_Ioo_eq_of_contDiffAt (hv : ContDiffAt ℝ 1 v x₀) :
    ∃ ε > (0 : ℝ),
      ∃ f : ℝ → E, f t₀ = x₀ ∧ ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t := by
  obtain ⟨ε, hε, _, _, _, hpl⟩ := exists_isPicardLindelof_const_of_contDiffAt t₀ hv
  obtain ⟨f, hf1, hf2⟩ := hpl.exists_forall_hasDerivWithinAt_Icc_eq x₀
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
v : E → E
t₀ : ℝ
x₀ : E
inst✝ : CompleteSpace E
hv : ContDiffAt ℝ 1 v x₀
ε : ℝ
hε : ε > 0
w✝² : ℝ≥0
w✝¹ w✝ : ℝ
hpl : IsPicardLindelof (fun x => v) (t₀ - ε) t₀ (t₀ + ε) x₀ w✝² w✝¹ w✝
f : ℝ → E
hf1 : f t₀ = x₀
hf2 : ∀ t ∈ Icc (t₀ - ε) (t₀ + ε), HasDerivWithinAt f (v (f t)) (Icc (t₀ - ε) (t₀ + ε)) t
⊢ ∃ ε > 0, ∃ f, f t₀ = x₀ ∧ ∀ t ∈ Ioo (t₀ - ε) (t₀ + ε), HasDerivAt f (v (f t)) t

Next tactic:
exact ⟨ε, hε, f, hf1, fun t ht =>
    (hf2 t (Ioo_subset_Icc_self ht)).hasDerivAt (Icc_mem_nhds ht.1 ht.2)⟩
/-- Replacing `ψ` by `mulShift ψ a` and multiplying the Gauss sum by `χ a` does not change it. -/
theorem gaussSum_mulShift (χ : MulChar R R') (ψ : AddChar R R') (a : Rˣ) :
    χ a * gaussSum χ (mulShift ψ a) = gaussSum χ ψ := by
  

Proof state:
R : Type u
inst✝² : CommRing R
inst✝¹ : Fintype R
R' : Type v
inst✝ : CommRing R'
χ : MulChar R R'
ψ : AddChar R R'
a : Rˣ
⊢ χ ↑a * gaussSum χ (mulShift ψ ↑a) = gaussSum χ ψ

Next tactic:
simp only [gaussSum, mulShift_apply, Finset.mul_sum]
/-- Replacing `ψ` by `mulShift ψ a` and multiplying the Gauss sum by `χ a` does not change it. -/
theorem gaussSum_mulShift (χ : MulChar R R') (ψ : AddChar R R') (a : Rˣ) :
    χ a * gaussSum χ (mulShift ψ a) = gaussSum χ ψ := by
  simp only [gaussSum, mulShift_apply, Finset.mul_sum]
  

Proof state:
R : Type u
inst✝² : CommRing R
inst✝¹ : Fintype R
R' : Type v
inst✝ : CommRing R'
χ : MulChar R R'
ψ : AddChar R R'
a : Rˣ
⊢ ∑ x : R, χ ↑a * (χ x * ψ (↑a * x)) = ∑ a : R, χ a * ψ a

Next tactic:
simp_rw [← mul_assoc, ← map_mul]
/-- Replacing `ψ` by `mulShift ψ a` and multiplying the Gauss sum by `χ a` does not change it. -/
theorem gaussSum_mulShift (χ : MulChar R R') (ψ : AddChar R R') (a : Rˣ) :
    χ a * gaussSum χ (mulShift ψ a) = gaussSum χ ψ := by
  simp only [gaussSum, mulShift_apply, Finset.mul_sum]
  simp_rw [← mul_assoc, ← map_mul]
  

Proof state:
R : Type u
inst✝² : CommRing R
inst✝¹ : Fintype R
R' : Type v
inst✝ : CommRing R'
χ : MulChar R R'
ψ : AddChar R R'
a : Rˣ
⊢ ∑ x : R, χ (↑a * x) * ψ (↑a * x) = ∑ a : R, χ a * ψ a

Next tactic:
exact Fintype.sum_bijective _ a.mulLeft_bijective _ _ fun x => rfl
private theorem gaussSum_mul_aux {χ : MulChar R R'} (hχ : IsNontrivial χ) (ψ : AddChar R R')
    (b : R) : ∑ a, χ (a * b⁻¹) * ψ (a - b) = ∑ c, χ c * ψ (b * (c - 1)) := by
  

Proof state:
R : Type u
inst✝³ : Field R
inst✝² : Fintype R
R' : Type v
inst✝¹ : CommRing R'
inst✝ : IsDomain R'
χ : MulChar R R'
hχ : MulChar.IsNontrivial χ
ψ : AddChar R R'
b : R
⊢ ∑ a : R, χ (a * b⁻¹) * ψ (a - b) = ∑ c : R, χ c * ψ (b * (c - 1))

Next tactic:
rcases eq_or_ne b 0 with hb | hb
private theorem gaussSum_mul_aux {χ : MulChar R R'} (hχ : IsNontrivial χ) (ψ : AddChar R R')
    (b : R) : ∑ a, χ (a * b⁻¹) * ψ (a - b) = ∑ c, χ c * ψ (b * (c - 1)) := by
  rcases eq_or_ne b 0 with hb | hb
  · -- case `b = 0`
    

Proof state:
case inl
R : Type u
inst✝³ : Field R
inst✝² : Fintype R
R' : Type v
inst✝¹ : CommRing R'
inst✝ : IsDomain R'
χ : MulChar R R'
hχ : MulChar.IsNontrivial χ
ψ : AddChar R R'
b : R
hb : b = 0
⊢ ∑ a : R, χ (a * b⁻¹) * ψ (a - b) = ∑ c : R, χ c * ψ (b * (c - 1))

Next tactic:
simp only [hb, inv_zero, mul_zero, MulChar.map_zero, zero_mul,
      Finset.sum_const_zero, map_zero_one, mul_one]
private theorem gaussSum_mul_aux {χ : MulChar R R'} (hχ : IsNontrivial χ) (ψ : AddChar R R')
    (b : R) : ∑ a, χ (a * b⁻¹) * ψ (a - b) = ∑ c, χ c * ψ (b * (c - 1)) := by
  rcases eq_or_ne b 0 with hb | hb
  · -- case `b = 0`
    simp only [hb, inv_zero, mul_zero, MulChar.map_zero, zero_mul,
      Finset.sum_const_zero, map_zero_one, mul_one]
    

Proof state:
case inl
R : Type u
inst✝³ : Field R
inst✝² : Fintype R
R' : Type v
inst✝¹ : CommRing R'
inst✝ : IsDomain R'
χ : MulChar R R'
hχ : MulChar.IsNontrivial χ
ψ : AddChar R R'
b : R
hb : b = 0
⊢ 0 = ∑ x : R, χ x

Next tactic:
exact (hχ.sum_eq_zero).symm
private theorem gaussSum_mul_aux {χ : MulChar R R'} (hχ : IsNontrivial χ) (ψ : AddChar R R')
    (b : R) : ∑ a, χ (a * b⁻¹) * ψ (a - b) = ∑ c, χ c * ψ (b * (c - 1)) := by
  rcases eq_or_ne b 0 with hb | hb
  · -- case `b = 0`
    simp only [hb, inv_zero, mul_zero, MulChar.map_zero, zero_mul,
      Finset.sum_const_zero, map_zero_one, mul_one]
    exact (hχ.sum_eq_zero).symm
  · -- case `b ≠ 0`
    

Proof state:
case inr
R : Type u
inst✝³ : Field R
inst✝² : Fintype R
R' : Type v
inst✝¹ : CommRing R'
inst✝ : IsDomain R'
χ : MulChar R R'
hχ : MulChar.IsNontrivial χ
ψ : AddChar R R'
b : R
hb : b ≠ 0
⊢ ∑ a : R, χ (a * b⁻¹) * ψ (a - b) = ∑ c : R, χ c * ψ (b * (c - 1))

Next tactic:
refine' (Fintype.sum_bijective _ (mulLeft_bijective₀ b hb) _ _ fun x => _).symm
private theorem gaussSum_mul_aux {χ : MulChar R R'} (hχ : IsNontrivial χ) (ψ : AddChar R R')
    (b : R) : ∑ a, χ (a * b⁻¹) * ψ (a - b) = ∑ c, χ c * ψ (b * (c - 1)) := by
  rcases eq_or_ne b 0 with hb | hb
  · -- case `b = 0`
    simp only [hb, inv_zero, mul_zero, MulChar.map_zero, zero_mul,
      Finset.sum_const_zero, map_zero_one, mul_one]
    exact (hχ.sum_eq_zero).symm
  · -- case `b ≠ 0`
    refine' (Fintype.sum_bijective _ (mulLeft_bijective₀ b hb) _ _ fun x => _).symm
    

Proof state:
case inr
R : Type u
inst✝³ : Field R
inst✝² : Fintype R
R' : Type v
inst✝¹ : CommRing R'
inst✝ : IsDomain R'
χ : MulChar R R'
hχ : MulChar.IsNontrivial χ
ψ : AddChar R R'
b : R
hb : b ≠ 0
x : R
⊢ χ x * ψ (b * (x - 1)) = χ (b * x * b⁻¹) * ψ (b * x - b)

Next tactic:
rw [mul_assoc, mul_comm x, ← mul_assoc, mul_inv_cancel hb, one_mul, mul_sub, mul_one]
/-- We have `gaussSum χ ψ * gaussSum χ⁻¹ ψ⁻¹ = Fintype.card R`
when `χ` is nontrivial and `ψ` is primitive (and `R` is a field). -/
theorem gaussSum_mul_gaussSum_eq_card {χ : MulChar R R'} (hχ : IsNontrivial χ) {ψ : AddChar R R'}
    (hψ : IsPrimitive ψ) : gaussSum χ ψ * gaussSum χ⁻¹ ψ⁻¹ = Fintype.card R := by
  

Proof state:
R : Type u
inst✝³ : Field R
inst✝² : Fintype R
R' : Type v
inst✝¹ : CommRing R'
inst✝ : IsDomain R'
χ : MulChar R R'
hχ : MulChar.IsNontrivial χ
ψ : AddChar R R'
hψ : IsPrimitive ψ
⊢ gaussSum χ ψ * gaussSum χ⁻¹ ψ⁻¹ = ↑(Fintype.card R)

Next tactic:
simp only [gaussSum, AddChar.inv_apply, Finset.sum_mul, Finset.mul_sum, MulChar.inv_apply']