l3lab/ntp-mathlib huggingface dataset:
theorem contMDiffAt_iff_contDiffAt {f : E → E'} {x : E} :
    ContMDiffAt 𝓘(𝕜, E) 𝓘(𝕜, E') n f x ↔ ContDiffAt 𝕜 n f x := by
  

Proof state:
𝕜 : Type u_1
inst✝³² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝³¹ : NormedAddCommGroup E
inst✝³⁰ : NormedSpace 𝕜 E
H : Type u_3
inst✝²⁹ : TopologicalSpace H
I : ModelWithCorners 𝕜 E H
M : Type u_4
inst✝²⁸ : TopologicalSpace M
inst✝²⁷ : ChartedSpace H M
inst✝²⁶ : SmoothManifoldWithCorners I M
E' : Type u_5
inst✝²⁵ : NormedAddCommGroup E'
inst✝²⁴ : NormedSpace 𝕜 E'
H' : Type u_6
inst✝²³ : TopologicalSpace H'
I' : ModelWithCorners 𝕜 E' H'
M' : Type u_7
inst✝²² : TopologicalSpace M'
inst✝²¹ : ChartedSpace H' M'
inst✝²⁰ : SmoothManifoldWithCorners I' M'
F : Type u_8
inst✝¹⁹ : NormedAddCommGroup F
inst✝¹⁸ : NormedSpace 𝕜 F
G : Type u_9
inst✝¹⁷ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_10
inst✝¹⁶ : TopologicalSpace N
inst✝¹⁵ : ChartedSpace G N
inst✝¹⁴ : SmoothManifoldWithCorners J N
F' : Type u_11
inst✝¹³ : NormedAddCommGroup F'
inst✝¹² : NormedSpace 𝕜 F'
G' : Type u_12
inst✝¹¹ : TopologicalSpace G'
J' : ModelWithCorners 𝕜 F' G'
N' : Type u_13
inst✝¹⁰ : TopologicalSpace N'
inst✝⁹ : ChartedSpace G' N'
inst✝⁸ : SmoothManifoldWithCorners J' N'
F₁ : Type u_14
inst✝⁷ : NormedAddCommGroup F₁
inst✝⁶ : NormedSpace 𝕜 F₁
F₂ : Type u_15
inst✝⁵ : NormedAddCommGroup F₂
inst✝⁴ : NormedSpace 𝕜 F₂
F₃ : Type u_16
inst✝³ : NormedAddCommGroup F₃
inst✝² : NormedSpace 𝕜 F₃
F₄ : Type u_17
inst✝¹ : NormedAddCommGroup F₄
inst✝ : NormedSpace 𝕜 F₄
f✝ f₁ : M → M'
s t : Set M
x✝ : M
m n : ℕ∞
f : E → E'
x : E
⊢ ContMDiffAt 𝓘(𝕜, E) 𝓘(𝕜, E') n f x ↔ ContDiffAt 𝕜 n f x

Next tactic:
rw [← contMDiffWithinAt_univ, contMDiffWithinAt_iff_contDiffWithinAt, contDiffWithinAt_univ]
theorem contMDiffOn_iff_contDiffOn {f : E → E'} {s : Set E} :
    ContMDiffOn 𝓘(𝕜, E) 𝓘(𝕜, E') n f s ↔ ContDiffOn 𝕜 n f s :=
  forall_congr' <| by 

Proof state:
𝕜 : Type u_1
inst✝³² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝³¹ : NormedAddCommGroup E
inst✝³⁰ : NormedSpace 𝕜 E
H : Type u_3
inst✝²⁹ : TopologicalSpace H
I : ModelWithCorners 𝕜 E H
M : Type u_4
inst✝²⁸ : TopologicalSpace M
inst✝²⁷ : ChartedSpace H M
inst✝²⁶ : SmoothManifoldWithCorners I M
E' : Type u_5
inst✝²⁵ : NormedAddCommGroup E'
inst✝²⁴ : NormedSpace 𝕜 E'
H' : Type u_6
inst✝²³ : TopologicalSpace H'
I' : ModelWithCorners 𝕜 E' H'
M' : Type u_7
inst✝²² : TopologicalSpace M'
inst✝²¹ : ChartedSpace H' M'
inst✝²⁰ : SmoothManifoldWithCorners I' M'
F : Type u_8
inst✝¹⁹ : NormedAddCommGroup F
inst✝¹⁸ : NormedSpace 𝕜 F
G : Type u_9
inst✝¹⁷ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_10
inst✝¹⁶ : TopologicalSpace N
inst✝¹⁵ : ChartedSpace G N
inst✝¹⁴ : SmoothManifoldWithCorners J N
F' : Type u_11
inst✝¹³ : NormedAddCommGroup F'
inst✝¹² : NormedSpace 𝕜 F'
G' : Type u_12
inst✝¹¹ : TopologicalSpace G'
J' : ModelWithCorners 𝕜 F' G'
N' : Type u_13
inst✝¹⁰ : TopologicalSpace N'
inst✝⁹ : ChartedSpace G' N'
inst✝⁸ : SmoothManifoldWithCorners J' N'
F₁ : Type u_14
inst✝⁷ : NormedAddCommGroup F₁
inst✝⁶ : NormedSpace 𝕜 F₁
F₂ : Type u_15
inst✝⁵ : NormedAddCommGroup F₂
inst✝⁴ : NormedSpace 𝕜 F₂
F₃ : Type u_16
inst✝³ : NormedAddCommGroup F₃
inst✝² : NormedSpace 𝕜 F₃
F₄ : Type u_17
inst✝¹ : NormedAddCommGroup F₄
inst✝ : NormedSpace 𝕜 F₄
f✝ f₁ : M → M'
s✝ t : Set M
x : M
m n : ℕ∞
f : E → E'
s : Set E
⊢ ∀ (a : E), a ∈ s → ContMDiffWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') n f s a ↔ a ∈ s → ContDiffWithinAt 𝕜 n f s a

Next tactic:
simp [contMDiffWithinAt_iff_contDiffWithinAt]
theorem contMDiff_iff_contDiff {f : E → E'} : ContMDiff 𝓘(𝕜, E) 𝓘(𝕜, E') n f ↔ ContDiff 𝕜 n f := by
  

Proof state:
𝕜 : Type u_1
inst✝³² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝³¹ : NormedAddCommGroup E
inst✝³⁰ : NormedSpace 𝕜 E
H : Type u_3
inst✝²⁹ : TopologicalSpace H
I : ModelWithCorners 𝕜 E H
M : Type u_4
inst✝²⁸ : TopologicalSpace M
inst✝²⁷ : ChartedSpace H M
inst✝²⁶ : SmoothManifoldWithCorners I M
E' : Type u_5
inst✝²⁵ : NormedAddCommGroup E'
inst✝²⁴ : NormedSpace 𝕜 E'
H' : Type u_6
inst✝²³ : TopologicalSpace H'
I' : ModelWithCorners 𝕜 E' H'
M' : Type u_7
inst✝²² : TopologicalSpace M'
inst✝²¹ : ChartedSpace H' M'
inst✝²⁰ : SmoothManifoldWithCorners I' M'
F : Type u_8
inst✝¹⁹ : NormedAddCommGroup F
inst✝¹⁸ : NormedSpace 𝕜 F
G : Type u_9
inst✝¹⁷ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_10
inst✝¹⁶ : TopologicalSpace N
inst✝¹⁵ : ChartedSpace G N
inst✝¹⁴ : SmoothManifoldWithCorners J N
F' : Type u_11
inst✝¹³ : NormedAddCommGroup F'
inst✝¹² : NormedSpace 𝕜 F'
G' : Type u_12
inst✝¹¹ : TopologicalSpace G'
J' : ModelWithCorners 𝕜 F' G'
N' : Type u_13
inst✝¹⁰ : TopologicalSpace N'
inst✝⁹ : ChartedSpace G' N'
inst✝⁸ : SmoothManifoldWithCorners J' N'
F₁ : Type u_14
inst✝⁷ : NormedAddCommGroup F₁
inst✝⁶ : NormedSpace 𝕜 F₁
F₂ : Type u_15
inst✝⁵ : NormedAddCommGroup F₂
inst✝⁴ : NormedSpace 𝕜 F₂
F₃ : Type u_16
inst✝³ : NormedAddCommGroup F₃
inst✝² : NormedSpace 𝕜 F₃
F₄ : Type u_17
inst✝¹ : NormedAddCommGroup F₄
inst✝ : NormedSpace 𝕜 F₄
f✝ f₁ : M → M'
s t : Set M
x : M
m n : ℕ∞
f : E → E'
⊢ ContMDiff 𝓘(𝕜, E) 𝓘(𝕜, E') n f ↔ ContDiff 𝕜 n f

Next tactic:
rw [← contDiffOn_univ, ← contMDiffOn_univ, contMDiffOn_iff_contDiffOn]
theorem ContMDiffWithinAt.clm_apply {g : M → F₁ →L[𝕜] F₂} {f : M → F₁} {s : Set M} {x : M}
    (hg : ContMDiffWithinAt I 𝓘(𝕜, F₁ →L[𝕜] F₂) n g s x)
    (hf : ContMDiffWithinAt I 𝓘(𝕜, F₁) n f s x) :
    ContMDiffWithinAt I 𝓘(𝕜, F₂) n (fun x => g x (f x)) s x :=
  @ContDiffWithinAt.comp_contMDiffWithinAt _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    (fun x : (F₁ →L[𝕜] F₂) × F₁ => x.1 x.2) (fun x => (g x, f x)) s _ x
    (by 

Proof state:
𝕜 : Type u_1
inst✝³² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝³¹ : NormedAddCommGroup E
inst✝³⁰ : NormedSpace 𝕜 E
H : Type u_3
inst✝²⁹ : TopologicalSpace H
I : ModelWithCorners 𝕜 E H
M : Type u_4
inst✝²⁸ : TopologicalSpace M
inst✝²⁷ : ChartedSpace H M
inst✝²⁶ : SmoothManifoldWithCorners I M
E' : Type u_5
inst✝²⁵ : NormedAddCommGroup E'
inst✝²⁴ : NormedSpace 𝕜 E'
H' : Type u_6
inst✝²³ : TopologicalSpace H'
I' : ModelWithCorners 𝕜 E' H'
M' : Type u_7
inst✝²² : TopologicalSpace M'
inst✝²¹ : ChartedSpace H' M'
inst✝²⁰ : SmoothManifoldWithCorners I' M'
F : Type u_8
inst✝¹⁹ : NormedAddCommGroup F
inst✝¹⁸ : NormedSpace 𝕜 F
G : Type u_9
inst✝¹⁷ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_10
inst✝¹⁶ : TopologicalSpace N
inst✝¹⁵ : ChartedSpace G N
inst✝¹⁴ : SmoothManifoldWithCorners J N
F' : Type u_11
inst✝¹³ : NormedAddCommGroup F'
inst✝¹² : NormedSpace 𝕜 F'
G' : Type u_12
inst✝¹¹ : TopologicalSpace G'
J' : ModelWithCorners 𝕜 F' G'
N' : Type u_13
inst✝¹⁰ : TopologicalSpace N'
inst✝⁹ : ChartedSpace G' N'
inst✝⁸ : SmoothManifoldWithCorners J' N'
F₁ : Type u_14
inst✝⁷ : NormedAddCommGroup F₁
inst✝⁶ : NormedSpace 𝕜 F₁
F₂ : Type u_15
inst✝⁵ : NormedAddCommGroup F₂
inst✝⁴ : NormedSpace 𝕜 F₂
F₃ : Type u_16
inst✝³ : NormedAddCommGroup F₃
inst✝² : NormedSpace 𝕜 F₃
F₄ : Type u_17
inst✝¹ : NormedAddCommGroup F₄
inst✝ : NormedSpace 𝕜 F₄
f✝ f₁ : M → M'
s✝ t : Set M
x✝ : M
m n : ℕ∞
g : M → F₁ →L[𝕜] F₂
f : M → F₁
s : Set M
x : M
hg : ContMDiffWithinAt I 𝓘(𝕜, F₁ →L[𝕜] F₂) n g s x
hf : ContMDiffWithinAt I 𝓘(𝕜, F₁) n f s x
⊢ ContDiffWithinAt 𝕜 n (fun x => x.1 x.2) (?m.112661 hg hf) ((fun x => (g x, f x)) x)

Next tactic:
apply ContDiff.contDiffAt
theorem ContMDiffWithinAt.clm_apply {g : M → F₁ →L[𝕜] F₂} {f : M → F₁} {s : Set M} {x : M}
    (hg : ContMDiffWithinAt I 𝓘(𝕜, F₁ →L[𝕜] F₂) n g s x)
    (hf : ContMDiffWithinAt I 𝓘(𝕜, F₁) n f s x) :
    ContMDiffWithinAt I 𝓘(𝕜, F₂) n (fun x => g x (f x)) s x :=
  @ContDiffWithinAt.comp_contMDiffWithinAt _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    (fun x : (F₁ →L[𝕜] F₂) × F₁ => x.1 x.2) (fun x => (g x, f x)) s _ x
    (by apply ContDiff.contDiffAt; 

Proof state:
case h
𝕜 : Type u_1
inst✝³² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝³¹ : NormedAddCommGroup E
inst✝³⁰ : NormedSpace 𝕜 E
H : Type u_3
inst✝²⁹ : TopologicalSpace H
I : ModelWithCorners 𝕜 E H
M : Type u_4
inst✝²⁸ : TopologicalSpace M
inst✝²⁷ : ChartedSpace H M
inst✝²⁶ : SmoothManifoldWithCorners I M
E' : Type u_5
inst✝²⁵ : NormedAddCommGroup E'
inst✝²⁴ : NormedSpace 𝕜 E'
H' : Type u_6
inst✝²³ : TopologicalSpace H'
I' : ModelWithCorners 𝕜 E' H'
M' : Type u_7
inst✝²² : TopologicalSpace M'
inst✝²¹ : ChartedSpace H' M'
inst✝²⁰ : SmoothManifoldWithCorners I' M'
F : Type u_8
inst✝¹⁹ : NormedAddCommGroup F
inst✝¹⁸ : NormedSpace 𝕜 F
G : Type u_9
inst✝¹⁷ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_10
inst✝¹⁶ : TopologicalSpace N
inst✝¹⁵ : ChartedSpace G N
inst✝¹⁴ : SmoothManifoldWithCorners J N
F' : Type u_11
inst✝¹³ : NormedAddCommGroup F'
inst✝¹² : NormedSpace 𝕜 F'
G' : Type u_12
inst✝¹¹ : TopologicalSpace G'
J' : ModelWithCorners 𝕜 F' G'
N' : Type u_13
inst✝¹⁰ : TopologicalSpace N'
inst✝⁹ : ChartedSpace G' N'
inst✝⁸ : SmoothManifoldWithCorners J' N'
F₁ : Type u_14
inst✝⁷ : NormedAddCommGroup F₁
inst✝⁶ : NormedSpace 𝕜 F₁
F₂ : Type u_15
inst✝⁵ : NormedAddCommGroup F₂
inst✝⁴ : NormedSpace 𝕜 F₂
F₃ : Type u_16
inst✝³ : NormedAddCommGroup F₃
inst✝² : NormedSpace 𝕜 F₃
F₄ : Type u_17
inst✝¹ : NormedAddCommGroup F₄
inst✝ : NormedSpace 𝕜 F₄
f✝ f₁ : M → M'
s✝ t : Set M
x✝ : M
m n : ℕ∞
g : M → F₁ →L[𝕜] F₂
f : M → F₁
s : Set M
x : M
hg : ContMDiffWithinAt I 𝓘(𝕜, F₁ →L[𝕜] F₂) n g s x
hf : ContMDiffWithinAt I 𝓘(𝕜, F₁) n f s x
⊢ ContDiff 𝕜 n fun x => x.1 x.2

Next tactic:
exact contDiff_fst.clm_apply contDiff_snd
theorem ContMDiffWithinAt.clm_apply {g : M → F₁ →L[𝕜] F₂} {f : M → F₁} {s : Set M} {x : M}
    (hg : ContMDiffWithinAt I 𝓘(𝕜, F₁ →L[𝕜] F₂) n g s x)
    (hf : ContMDiffWithinAt I 𝓘(𝕜, F₁) n f s x) :
    ContMDiffWithinAt I 𝓘(𝕜, F₂) n (fun x => g x (f x)) s x :=
  @ContDiffWithinAt.comp_contMDiffWithinAt _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    (fun x : (F₁ →L[𝕜] F₂) × F₁ => x.1 x.2) (fun x => (g x, f x)) s _ x
    (by apply ContDiff.contDiffAt; exact contDiff_fst.clm_apply contDiff_snd) (hg.prod_mk_space hf)
    (by 

Proof state:
𝕜 : Type u_1
inst✝³² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝³¹ : NormedAddCommGroup E
inst✝³⁰ : NormedSpace 𝕜 E
H : Type u_3
inst✝²⁹ : TopologicalSpace H
I : ModelWithCorners 𝕜 E H
M : Type u_4
inst✝²⁸ : TopologicalSpace M
inst✝²⁷ : ChartedSpace H M
inst✝²⁶ : SmoothManifoldWithCorners I M
E' : Type u_5
inst✝²⁵ : NormedAddCommGroup E'
inst✝²⁴ : NormedSpace 𝕜 E'
H' : Type u_6
inst✝²³ : TopologicalSpace H'
I' : ModelWithCorners 𝕜 E' H'
M' : Type u_7
inst✝²² : TopologicalSpace M'
inst✝²¹ : ChartedSpace H' M'
inst✝²⁰ : SmoothManifoldWithCorners I' M'
F : Type u_8
inst✝¹⁹ : NormedAddCommGroup F
inst✝¹⁸ : NormedSpace 𝕜 F
G : Type u_9
inst✝¹⁷ : TopologicalSpace G
J : ModelWithCorners 𝕜 F G
N : Type u_10
inst✝¹⁶ : TopologicalSpace N
inst✝¹⁵ : ChartedSpace G N
inst✝¹⁴ : SmoothManifoldWithCorners J N
F' : Type u_11
inst✝¹³ : NormedAddCommGroup F'
inst✝¹² : NormedSpace 𝕜 F'
G' : Type u_12
inst✝¹¹ : TopologicalSpace G'
J' : ModelWithCorners 𝕜 F' G'
N' : Type u_13
inst✝¹⁰ : TopologicalSpace N'
inst✝⁹ : ChartedSpace G' N'
inst✝⁸ : SmoothManifoldWithCorners J' N'
F₁ : Type u_14
inst✝⁷ : NormedAddCommGroup F₁
inst✝⁶ : NormedSpace 𝕜 F₁
F₂ : Type u_15
inst✝⁵ : NormedAddCommGroup F₂
inst✝⁴ : NormedSpace 𝕜 F₂
F₃ : Type u_16
inst✝³ : NormedAddCommGroup F₃
inst✝² : NormedSpace 𝕜 F₃
F₄ : Type u_17
inst✝¹ : NormedAddCommGroup F₄
inst✝ : NormedSpace 𝕜 F₄
f✝ f₁ : M → M'
s✝ t : Set M
x✝ : M
m n : ℕ∞
g : M → F₁ →L[𝕜] F₂
f : M → F₁
s : Set M
x : M
hg : ContMDiffWithinAt I 𝓘(𝕜, F₁ →L[𝕜] F₂) n g s x
hf : ContMDiffWithinAt I 𝓘(𝕜, F₁) n f s x
⊢ s ⊆ (fun x => (g x, f x)) ⁻¹' univ

Next tactic:
simp_rw [preimage_univ, subset_univ]
theorem dist_comm (n m : ℕ) : dist n m = dist m n := by 

Proof state:
n m : ℕ
⊢ dist n m = dist m n

Next tactic:
simp [dist.def, add_comm]
@[simp]
theorem dist_self (n : ℕ) : dist n n = 0 := by 

Proof state:
n : ℕ
⊢ dist n n = 0

Next tactic:
simp [dist.def, tsub_self]
theorem dist_eq_zero {n m : ℕ} (h : n = m) : dist n m = 0 := by 

Proof state:
n m : ℕ
h : n = m
⊢ dist n m = 0

Next tactic:
rw [h, dist_self]
theorem dist_eq_sub_of_le {n m : ℕ} (h : n ≤ m) : dist n m = m - n := by
  

Proof state:
n m : ℕ
h : n ≤ m
⊢ dist n m = m - n

Next tactic:
rw [dist.def, tsub_eq_zero_iff_le.mpr h, zero_add]
theorem dist_eq_sub_of_le_right {n m : ℕ} (h : m ≤ n) : dist n m = n - m :=
  by 

Proof state:
n m : ℕ
h : m ≤ n
⊢ dist n m = n - m

Next tactic:
rw [dist_comm]
theorem dist_eq_sub_of_le_right {n m : ℕ} (h : m ≤ n) : dist n m = n - m :=
  by rw [dist_comm]; 

Proof state:
n m : ℕ
h : m ≤ n
⊢ dist m n = n - m

Next tactic:
apply dist_eq_sub_of_le h
theorem dist_tri_right (n m : ℕ) : m ≤ n + dist n m := by 

Proof state:
n m : ℕ
⊢ m ≤ n + dist n m

Next tactic:
rw [add_comm]
theorem dist_tri_right (n m : ℕ) : m ≤ n + dist n m := by rw [add_comm]; 

Proof state:
n m : ℕ
⊢ m ≤ dist n m + n

Next tactic:
apply dist_tri_left
theorem dist_tri_left' (n m : ℕ) : n ≤ dist n m + m := by 

Proof state:
n m : ℕ
⊢ n ≤ dist n m + m

Next tactic:
rw [dist_comm]
theorem dist_tri_left' (n m : ℕ) : n ≤ dist n m + m := by rw [dist_comm]; 

Proof state:
n m : ℕ
⊢ n ≤ dist m n + m

Next tactic:
apply dist_tri_left
theorem dist_tri_right' (n m : ℕ) : n ≤ m + dist n m := by 

Proof state:
n m : ℕ
⊢ n ≤ m + dist n m

Next tactic:
rw [dist_comm]
theorem dist_tri_right' (n m : ℕ) : n ≤ m + dist n m := by rw [dist_comm]; 

Proof state:
n m : ℕ
⊢ n ≤ m + dist m n

Next tactic:
apply dist_tri_right
theorem dist_add_add_right (n k m : ℕ) : dist (n + k) (m + k) = dist n m :=
  calc
    dist (n + k) (m + k) = n + k - (m + k) + (m + k - (n + k)) := rfl
    _ = n - m + (m + k - (n + k)) := by 

Proof state:
n k m : ℕ
⊢ n + k - (m + k) + (m + k - (n + k)) = n - m + (m + k - (n + k))

Next tactic:
rw [@add_tsub_add_eq_tsub_right]
theorem dist_add_add_right (n k m : ℕ) : dist (n + k) (m + k) = dist n m :=
  calc
    dist (n + k) (m + k) = n + k - (m + k) + (m + k - (n + k)) := rfl
    _ = n - m + (m + k - (n + k)) := by rw [@add_tsub_add_eq_tsub_right]
    _ = n - m + (m - n) := by 

Proof state:
n k m : ℕ
⊢ n - m + (m + k - (n + k)) = n - m + (m - n)

Next tactic:
rw [@add_tsub_add_eq_tsub_right]
theorem dist_add_add_left (k n m : ℕ) : dist (k + n) (k + m) = dist n m := by
  

Proof state:
k n m : ℕ
⊢ dist (k + n) (k + m) = dist n m

Next tactic:
rw [add_comm k n, add_comm k m]
theorem dist_add_add_left (k n m : ℕ) : dist (k + n) (k + m) = dist n m := by
  rw [add_comm k n, add_comm k m]; 

Proof state:
k n m : ℕ
⊢ dist (n + k) (m + k) = dist n m

Next tactic:
apply dist_add_add_right
theorem dist_eq_intro {n m k l : ℕ} (h : n + m = k + l) : dist n k = dist l m :=
  calc
    dist n k = dist (n + m) (k + m) := by 

Proof state:
n m k l : ℕ
h : n + m = k + l
⊢ dist n k = dist (n + m) (k + m)

Next tactic:
rw [dist_add_add_right]
theorem dist_eq_intro {n m k l : ℕ} (h : n + m = k + l) : dist n k = dist l m :=
  calc
    dist n k = dist (n + m) (k + m) := by rw [dist_add_add_right]
    _ = dist (k + l) (k + m) := by 

Proof state:
n m k l : ℕ
h : n + m = k + l
⊢ dist (n + m) (k + m) = dist (k + l) (k + m)

Next tactic:
rw [h]
theorem dist_eq_intro {n m k l : ℕ} (h : n + m = k + l) : dist n k = dist l m :=
  calc
    dist n k = dist (n + m) (k + m) := by rw [dist_add_add_right]
    _ = dist (k + l) (k + m) := by rw [h]
    _ = dist l m := by 

Proof state:
n m k l : ℕ
h : n + m = k + l
⊢ dist (k + l) (k + m) = dist l m

Next tactic:
rw [dist_add_add_left]
theorem dist.triangle_inequality (n m k : ℕ) : dist n k ≤ dist n m + dist m k := by
  

Proof state:
n m k : ℕ
⊢ dist n k ≤ dist n m + dist m k

Next tactic:
have : dist n m + dist m k = n - m + (m - k) + (k - m + (m - n)) := by
    simp [dist.def, add_comm, add_left_comm, add_assoc]
theorem dist.triangle_inequality (n m k : ℕ) : dist n k ≤ dist n m + dist m k := by
  have : dist n m + dist m k = n - m + (m - k) + (k - m + (m - n)) := by
    

Proof state:
n m k : ℕ
⊢ dist n m + dist m k = n - m + (m - k) + (k - m + (m - n))

Next tactic:
simp [dist.def, add_comm, add_left_comm, add_assoc]
theorem dist.triangle_inequality (n m k : ℕ) : dist n k ≤ dist n m + dist m k := by
  have : dist n m + dist m k = n - m + (m - k) + (k - m + (m - n)) := by
    simp [dist.def, add_comm, add_left_comm, add_assoc]
  

Proof state:
n m k : ℕ
this : dist n m + dist m k = n - m + (m - k) + (k - m + (m - n))
⊢ dist n k ≤ dist n m + dist m k

Next tactic:
rw [this, dist.def]
theorem dist.triangle_inequality (n m k : ℕ) : dist n k ≤ dist n m + dist m k := by
  have : dist n m + dist m k = n - m + (m - k) + (k - m + (m - n)) := by
    simp [dist.def, add_comm, add_left_comm, add_assoc]
  rw [this, dist.def]
  

Proof state:
n m k : ℕ
this : dist n m + dist m k = n - m + (m - k) + (k - m + (m - n))
⊢ n - k + (k - n) ≤ n - m + (m - k) + (k - m + (m - n))

Next tactic:
exact add_le_add tsub_le_tsub_add_tsub tsub_le_tsub_add_tsub
theorem dist_mul_right (n k m : ℕ) : dist (n * k) (m * k) = dist n m * k := by
  

Proof state:
n k m : ℕ
⊢ dist (n * k) (m * k) = dist n m * k

Next tactic:
rw [dist.def, dist.def, right_distrib, tsub_mul n, tsub_mul m]
theorem dist_mul_left (k n m : ℕ) : dist (k * n) (k * m) = k * dist n m := by
  

Proof state:
k n m : ℕ
⊢ dist (k * n) (k * m) = k * dist n m

Next tactic:
rw [mul_comm k n, mul_comm k m, dist_mul_right, mul_comm]
theorem dist_eq_max_sub_min {i j : ℕ} : dist i j = (max i j) - min i j :=
  Or.elim (lt_or_ge i j)
  (by 

Proof state:
i j : ℕ
⊢ i < j → dist i j = max i j - min i j

Next tactic:
intro h
theorem dist_eq_max_sub_min {i j : ℕ} : dist i j = (max i j) - min i j :=
  Or.elim (lt_or_ge i j)
  (by intro h; 

Proof state:
i j : ℕ
h : i < j
⊢ dist i j = max i j - min i j

Next tactic:
rw [max_eq_right_of_lt h, min_eq_left_of_lt h, dist_eq_sub_of_le (Nat.le_of_lt h)]
theorem dist_eq_max_sub_min {i j : ℕ} : dist i j = (max i j) - min i j :=
  Or.elim (lt_or_ge i j)
  (by intro h; rw [max_eq_right_of_lt h, min_eq_left_of_lt h, dist_eq_sub_of_le (Nat.le_of_lt h)])
  (by 

Proof state:
i j : ℕ
⊢ i ≥ j → dist i j = max i j - min i j

Next tactic:
intro h
theorem dist_eq_max_sub_min {i j : ℕ} : dist i j = (max i j) - min i j :=
  Or.elim (lt_or_ge i j)
  (by intro h; rw [max_eq_right_of_lt h, min_eq_left_of_lt h, dist_eq_sub_of_le (Nat.le_of_lt h)])
  (by intro h; 

Proof state:
i j : ℕ
h : i ≥ j
⊢ dist i j = max i j - min i j

Next tactic:
rw [max_eq_left h, min_eq_right h, dist_eq_sub_of_le_right h]
theorem dist_succ_succ {i j : Nat} : dist (succ i) (succ j) = dist i j := by
  

Proof state:
i j : ℕ
⊢ dist (succ i) (succ j) = dist i j

Next tactic:
simp [dist.def, succ_sub_succ]
theorem dist_pos_of_ne {i j : Nat} : i ≠ j → 0 < dist i j := fun hne =>
  Nat.ltByCases
    (fun h : i < j => by 

Proof state:
i j : ℕ
hne : i ≠ j
h : i < j
⊢ 0 < dist i j

Next tactic:
rw [dist_eq_sub_of_le (le_of_lt h)]
theorem dist_pos_of_ne {i j : Nat} : i ≠ j → 0 < dist i j := fun hne =>
  Nat.ltByCases
    (fun h : i < j => by rw [dist_eq_sub_of_le (le_of_lt h)]; 

Proof state:
i j : ℕ
hne : i ≠ j
h : i < j
⊢ 0 < j - i

Next tactic:
apply tsub_pos_of_lt h
theorem dist_pos_of_ne {i j : Nat} : i ≠ j → 0 < dist i j := fun hne =>
  Nat.ltByCases
    (fun h : i < j => by rw [dist_eq_sub_of_le (le_of_lt h)]; apply tsub_pos_of_lt h)
    (fun h : i = j => by 

Proof state:
i j : ℕ
hne : i ≠ j
h : i = j
⊢ 0 < dist i j

Next tactic:
contradiction
theorem dist_pos_of_ne {i j : Nat} : i ≠ j → 0 < dist i j := fun hne =>
  Nat.ltByCases
    (fun h : i < j => by rw [dist_eq_sub_of_le (le_of_lt h)]; apply tsub_pos_of_lt h)
    (fun h : i = j => by contradiction) fun h : i > j => by
    

Proof state:
i j : ℕ
hne : i ≠ j
h : i > j
⊢ 0 < dist i j

Next tactic:
rw [dist_eq_sub_of_le_right (le_of_lt h)]
theorem dist_pos_of_ne {i j : Nat} : i ≠ j → 0 < dist i j := fun hne =>
  Nat.ltByCases
    (fun h : i < j => by rw [dist_eq_sub_of_le (le_of_lt h)]; apply tsub_pos_of_lt h)
    (fun h : i = j => by contradiction) fun h : i > j => by
    rw [dist_eq_sub_of_le_right (le_of_lt h)]; 

Proof state:
i j : ℕ
hne : i ≠ j
h : i > j
⊢ 0 < i - j

Next tactic:
apply tsub_pos_of_lt h
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
    leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
  

Proof state:
Ω : Type u_1
m0 : MeasurableSpace Ω
μ : Measure Ω
ℱ : Filtration ℕ m0
f : ℕ → Ω → ℝ
ω✝ : Ω
π : Ω → ℕ
r : ℝ
ω : Ω
n : ℕ
hπn : ∀ (ω : Ω), π ω ≤ n
⊢ leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω)

Next tactic:
classical
  refine' le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) _
  by_cases hle : π ω ≤ leastGE f r n ω
  · rw [min_eq_left hle, leastGE]
    by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
    · refine' hle.trans (Eq.le _)
      rw [leastGE, ← hitting_eq_hitting_of_exists (hπn ω) h]
    · simp only [hitting, if_neg h, le_rfl]
  · rw [min_eq_right (not_le.1 hle).le, leastGE, leastGE, ←
      hitting_eq_hitting_of_exists (hπn ω) _]
    rw [not_le, leastGE, hitting_lt_iff _ (hπn ω)] at hle
    exact
      let ⟨j, hj₁, hj₂⟩ := hle
      ⟨j, ⟨hj₁.1, hj₁.2.le⟩, hj₂⟩
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
    leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
  classical
  

Proof state:
Ω : Type u_1
m0 : MeasurableSpace Ω
μ : Measure Ω
ℱ : Filtration ℕ m0
f : ℕ → Ω → ℝ
ω✝ : Ω
π : Ω → ℕ
r : ℝ
ω : Ω
n : ℕ
hπn : ∀ (ω : Ω), π ω ≤ n
⊢ leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω)

Next tactic:
refine' le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) _
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
    leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
  classical
  refine' le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) _
  

Proof state:
Ω : Type u_1
m0 : MeasurableSpace Ω
μ : Measure Ω
ℱ : Filtration ℕ m0
f : ℕ → Ω → ℝ
ω✝ : Ω
π : Ω → ℕ
r : ℝ
ω : Ω
n : ℕ
hπn : ∀ (ω : Ω), π ω ≤ n
⊢ min (π ω) (leastGE f r n ω) ≤ leastGE f r (π ω) ω

Next tactic:
by_cases hle : π ω ≤ leastGE f r n ω
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
    leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
  classical
  refine' le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) _
  by_cases hle : π ω ≤ leastGE f r n ω
  · 

Proof state:
case pos
Ω : Type u_1
m0 : MeasurableSpace Ω
μ : Measure Ω
ℱ : Filtration ℕ m0
f : ℕ → Ω → ℝ
ω✝ : Ω
π : Ω → ℕ
r : ℝ
ω : Ω
n : ℕ
hπn : ∀ (ω : Ω), π ω ≤ n
hle : π ω ≤ leastGE f r n ω
⊢ min (π ω) (leastGE f r n ω) ≤ leastGE f r (π ω) ω

Next tactic:
rw [min_eq_left hle, leastGE]
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
    leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
  classical
  refine' le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) _
  by_cases hle : π ω ≤ leastGE f r n ω
  · rw [min_eq_left hle, leastGE]
    

Proof state:
case pos
Ω : Type u_1
m0 : MeasurableSpace Ω
μ : Measure Ω
ℱ : Filtration ℕ m0
f : ℕ → Ω → ℝ
ω✝ : Ω
π : Ω → ℕ
r : ℝ
ω : Ω
n : ℕ
hπn : ∀ (ω : Ω), π ω ≤ n
hle : π ω ≤ leastGE f r n ω
⊢ π ω ≤ hitting f (Set.Ici r) 0 (π ω) ω

Next tactic:
by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
    leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
  classical
  refine' le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) _
  by_cases hle : π ω ≤ leastGE f r n ω
  · rw [min_eq_left hle, leastGE]
    by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
    · 

Proof state:
case pos
Ω : Type u_1
m0 : MeasurableSpace Ω
μ : Measure Ω
ℱ : Filtration ℕ m0
f : ℕ → Ω → ℝ
ω✝ : Ω
π : Ω → ℕ
r : ℝ
ω : Ω
n : ℕ
hπn : ∀ (ω : Ω), π ω ≤ n
hle : π ω ≤ leastGE f r n ω
h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
⊢ π ω ≤ hitting f (Set.Ici r) 0 (π ω) ω

Next tactic:
refine' hle.trans (Eq.le _)
theorem leastGE_eq_min (π : Ω → ℕ) (r : ℝ) (ω : Ω) {n : ℕ} (hπn : ∀ ω, π ω ≤ n) :
    leastGE f r (π ω) ω = min (π ω) (leastGE f r n ω) := by
  classical
  refine' le_antisymm (le_min (leastGE_le _) (leastGE_mono (hπn ω) r ω)) _
  by_cases hle : π ω ≤ leastGE f r n ω
  · rw [min_eq_left hle, leastGE]
    by_cases h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
    · refine' hle.trans (Eq.le _)
      

Proof state:
case pos
Ω : Type u_1
m0 : MeasurableSpace Ω
μ : Measure Ω
ℱ : Filtration ℕ m0
f : ℕ → Ω → ℝ
ω✝ : Ω
π : Ω → ℕ
r : ℝ
ω : Ω
n : ℕ
hπn : ∀ (ω : Ω), π ω ≤ n
hle : π ω ≤ leastGE f r n ω
h : ∃ j ∈ Set.Icc 0 (π ω), f j ω ∈ Set.Ici r
⊢ leastGE f r n ω = hitting f (Set.Ici r) 0 (π ω) ω

Next tactic:
rw [leastGE, ← hitting_eq_hitting_of_exists (hπn ω) h]