[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
⊢ M p
[PROOFSTEP]
have A : ∀ {n : ℕ} {a}, M (C a * X ^ n) := by
  intro n a
  induction' n with n ih
  · rw [pow_zero, mul_one]; exact h_C a
  · exact h_monomial _ _ ih
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
⊢ ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
[PROOFSTEP]
intro n a
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
n : ℕ
a : R
⊢ M (↑C a * X ^ n)
[PROOFSTEP]
induction' n with n ih
[GOAL]
case zero
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
a : R
⊢ M (↑C a * X ^ Nat.zero)
[PROOFSTEP]
rw [pow_zero, mul_one]
[GOAL]
case zero
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
a : R
⊢ M (↑C a)
[PROOFSTEP]
exact h_C a
[GOAL]
case succ
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
a : R
n : ℕ
ih : M (↑C a * X ^ n)
⊢ M (↑C a * X ^ Nat.succ n)
[PROOFSTEP]
exact h_monomial _ _ ih
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
⊢ M p
[PROOFSTEP]
have B : ∀ s : Finset ℕ, M (s.sum fun n : ℕ => C (p.coeff n) * X ^ n) :=
  by
  apply Finset.induction
  · convert h_C 0
    exact C_0.symm
  · intro n s ns ih
    rw [sum_insert ns]
    exact h_add _ _ A ih
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
⊢ ∀ (s : Finset ℕ), M (Finset.sum s fun n => ↑C (coeff p n) * X ^ n)
[PROOFSTEP]
apply Finset.induction
[GOAL]
case empty
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
⊢ M (Finset.sum ∅ fun n => ↑C (coeff p n) * X ^ n)
[PROOFSTEP]
convert h_C 0
[GOAL]
case h.e'_1
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
⊢ (Finset.sum ∅ fun n => ↑C (coeff p n) * X ^ n) = ↑C 0
[PROOFSTEP]
exact C_0.symm
[GOAL]
case insert
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
⊢ ∀ ⦃a : ℕ⦄ {s : Finset ℕ},
    ¬a ∈ s →
      M (Finset.sum s fun n => ↑C (coeff p n) * X ^ n) → M (Finset.sum (insert a s) fun n => ↑C (coeff p n) * X ^ n)
[PROOFSTEP]
intro n s ns ih
[GOAL]
case insert
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
n : ℕ
s : Finset ℕ
ns : ¬n ∈ s
ih : M (Finset.sum s fun n => ↑C (coeff p n) * X ^ n)
⊢ M (Finset.sum (insert n s) fun n => ↑C (coeff p n) * X ^ n)
[PROOFSTEP]
rw [sum_insert ns]
[GOAL]
case insert
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
n : ℕ
s : Finset ℕ
ns : ¬n ∈ s
ih : M (Finset.sum s fun n => ↑C (coeff p n) * X ^ n)
⊢ M (↑C (coeff p n) * X ^ n + Finset.sum s fun x => ↑C (coeff p x) * X ^ x)
[PROOFSTEP]
exact h_add _ _ A ih
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
B : ∀ (s : Finset ℕ), M (Finset.sum s fun n => ↑C (coeff p n) * X ^ n)
⊢ M p
[PROOFSTEP]
rw [← sum_C_mul_X_pow_eq p, Polynomial.sum]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A✝ : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_C : ∀ (a : R), M (↑C a)
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑C a * X ^ n) → M (↑C a * X ^ (n + 1))
A : ∀ {n : ℕ} {a : R}, M (↑C a * X ^ n)
B : ∀ (s : Finset ℕ), M (Finset.sum s fun n => ↑C (coeff p n) * X ^ n)
⊢ M (Finset.sum (support p) fun n => ↑C (coeff p n) * X ^ n)
[PROOFSTEP]
exact B (support p)
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑(monomial n) a)
n : ℕ
a : R
_h : M (↑C a * X ^ n)
⊢ M (↑C a * X ^ (n + 1))
[PROOFSTEP]
rw [C_mul_X_pow_eq_monomial]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a✝ b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r : R[X]
M : R[X] → Prop
p : R[X]
h_add : ∀ (p q : R[X]), M p → M q → M (p + q)
h_monomial : ∀ (n : ℕ) (a : R), M (↑(monomial n) a)
n : ℕ
a : R
_h : M (↑C a * X ^ n)
⊢ M (↑(monomial (n + 1)) a)
[PROOFSTEP]
exact h_monomial _ _
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p q r f : R[X]
I : Ideal R[X]
cf : ∀ (i : ℕ), ↑C (coeff f i) ∈ I
⊢ Ideal.span {g | ∃ i, g = ↑C (coeff f i)} ≤ I
[PROOFSTEP]
simp (config := { singlePass := true }) only [@eq_comm _ _ (C _)]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p q r f : R[X]
I : Ideal R[X]
cf : ∀ (i : ℕ), ↑C (coeff f i) ∈ I
⊢ Ideal.span {g | ∃ i, ↑C (coeff f i) = g} ≤ I
[PROOFSTEP]
exact (Ideal.span_le.trans range_subset_iff).mpr cf
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p q r f : R[X]
I : Ideal R[X]
⊢ f ∈ Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
let p := Ideal.span {g : R[X] | ∃ i : ℕ, g = C (coeff f i)}
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
⊢ f ∈ Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
nth_rw 1 [(sum_C_mul_X_pow_eq f).symm]
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
⊢ (sum f fun n a => ↑C a * X ^ n) ∈ Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
refine' Submodule.sum_mem _ fun n _hn => _
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
⊢ (fun n a => ↑C a * X ^ n) n (coeff f n) ∈ Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
dsimp
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
⊢ ↑C (coeff f n) * X ^ n ∈ Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
have : C (coeff f n) ∈ p := by
  apply subset_span
  rw [mem_setOf_eq]
  use n
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
⊢ ↑C (coeff f n) ∈ p
[PROOFSTEP]
apply subset_span
[GOAL]
case a
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
⊢ ↑C (coeff f n) ∈ {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
rw [mem_setOf_eq]
[GOAL]
case a
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
⊢ ∃ i, ↑C (coeff f n) = ↑C (coeff f i)
[PROOFSTEP]
use n
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
this : ↑C (coeff f n) ∈ p
⊢ ↑C (coeff f n) * X ^ n ∈ Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
have : monomial n (1 : R) • C (coeff f n) ∈ p := p.smul_mem _ this
[GOAL]
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
this✝ : ↑C (coeff f n) ∈ p
this : ↑(monomial n) 1 • ↑C (coeff f n) ∈ p
⊢ ↑C (coeff f n) * X ^ n ∈ Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
[PROOFSTEP]
convert this using 1
[GOAL]
case h.e'_4
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
this✝ : ↑C (coeff f n) ∈ p
this : ↑(monomial n) 1 • ↑C (coeff f n) ∈ p
⊢ ↑C (coeff f n) * X ^ n = ↑(monomial n) 1 • ↑C (coeff f n)
[PROOFSTEP]
simp only [monomial_mul_C, one_mul, smul_eq_mul]
[GOAL]
case h.e'_4
R : Type u
S : Type v
T : Type w
ι : Type x
k : Type y
A : Type z
a b : R
m n✝ : ℕ
inst✝ : Semiring R
p✝ q r f : R[X]
I : Ideal R[X]
p : Ideal R[X] := Ideal.span {g | ∃ i, g = ↑C (coeff f i)}
n : ℕ
_hn : n ∈ support f
this✝ : ↑C (coeff f n) ∈ p
this : ↑(monomial n) 1 • ↑C (coeff f n) ∈ p
⊢ ↑C (coeff f n) * X ^ n = ↑(monomial n) (coeff f n)
[PROOFSTEP]
rw [← C_mul_X_pow_eq_monomial]


[GOAL]
α : Type u
β : Type v
γ : Type w
p : α → Prop
a : α
l : List α
x✝ : ∃ x, x ∈ a :: l ∧ p x
x : α
h : x ∈ a :: l
px : p x
⊢ p a ∨ ∃ x, x ∈ l ∧ p x
[PROOFSTEP]
simp only [find?, mem_cons] at h
[GOAL]
α : Type u
β : Type v
γ : Type w
p : α → Prop
a : α
l : List α
x✝ : ∃ x, x ∈ a :: l ∧ p x
x : α
px : p x
h : x = a ∨ x ∈ l
⊢ p a ∨ ∃ x, x ∈ l ∧ p x
[PROOFSTEP]
cases' h with h h
[GOAL]
case inl
α : Type u
β : Type v
γ : Type w
p : α → Prop
a : α
l : List α
x✝ : ∃ x, x ∈ a :: l ∧ p x
x : α
px : p x
h : x = a
⊢ p a ∨ ∃ x, x ∈ l ∧ p x
[PROOFSTEP]
cases h
[GOAL]
case inl.refl
α : Type u
β : Type v
γ : Type w
p : α → Prop
a : α
l : List α
x✝ : ∃ x, x ∈ a :: l ∧ p x
px : p a
⊢ p a ∨ ∃ x, x ∈ l ∧ p x
[PROOFSTEP]
exact Or.inl px
[GOAL]
case inr
α : Type u
β : Type v
γ : Type w
p : α → Prop
a : α
l : List α
x✝ : ∃ x, x ∈ a :: l ∧ p x
x : α
px : p x
h : x ∈ l
⊢ p a ∨ ∃ x, x ∈ l ∧ p x
[PROOFSTEP]
exact Or.inr ⟨x, h, px⟩


[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y : V
x : V × V
hx1 : x.fst ≠ 0
hx2 : x.snd ≠ 0
⊢ ‖x.fst‖ * ‖x.snd‖ ≠ 0
[PROOFSTEP]
simp [hx1, hx2]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ : V
c : ℝ
hc : c ≠ 0
x y : V
⊢ angle (c • x) (c • y) = angle x y
[PROOFSTEP]
have : c * c ≠ 0 := mul_ne_zero hc hc
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ : V
c : ℝ
hc : c ≠ 0
x y : V
this : c * c ≠ 0
⊢ angle (c • x) (c • y) = angle x y
[PROOFSTEP]
rw [angle, angle, real_inner_smul_left, inner_smul_right, norm_smul, norm_smul, Real.norm_eq_abs,
  mul_mul_mul_comm _ ‖x‖, abs_mul_abs_self, ← mul_assoc c c, mul_div_mul_left _ _ this]
[GOAL]
V : Type u_1
inst✝⁵ : NormedAddCommGroup V
inst✝⁴ : InnerProductSpace ℝ V
x y : V
E : Type u_2
F : Type u_3
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace ℝ E
inst✝ : InnerProductSpace ℝ F
f : E →ₗᵢ[ℝ] F
u v : E
⊢ angle (↑f u) (↑f v) = angle u v
[PROOFSTEP]
rw [angle, angle, f.inner_map_map, f.norm_map, f.norm_map]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ angle x y = angle y x
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ arccos (inner x y / (‖x‖ * ‖y‖)) = arccos (inner y x / (‖y‖ * ‖x‖))
[PROOFSTEP]
rw [real_inner_comm, mul_comm]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ angle (-x) (-y) = angle x y
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ arccos (inner (-x) (-y) / (‖-x‖ * ‖-y‖)) = arccos (inner x y / (‖x‖ * ‖y‖))
[PROOFSTEP]
rw [inner_neg_neg, norm_neg, norm_neg]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ angle x (-y) = π - angle x y
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ arccos (inner x (-y) / (‖x‖ * ‖-y‖)) = π - arccos (inner x y / (‖x‖ * ‖y‖))
[PROOFSTEP]
rw [← Real.arccos_neg, norm_neg, inner_neg_right, neg_div]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ angle (-x) y = π - angle x y
[PROOFSTEP]
rw [← angle_neg_neg, neg_neg, angle_neg_right]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
⊢ angle 0 x = π / 2
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
⊢ arccos (inner 0 x / (‖0‖ * ‖x‖)) = π / 2
[PROOFSTEP]
rw [inner_zero_left, zero_div, Real.arccos_zero]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
⊢ angle x 0 = π / 2
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
⊢ arccos (inner x 0 / (‖x‖ * ‖0‖)) = π / 2
[PROOFSTEP]
rw [inner_zero_right, zero_div, Real.arccos_zero]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
hx : x ≠ 0
⊢ angle x x = 0
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
hx : x ≠ 0
⊢ arccos (inner x x / (‖x‖ * ‖x‖)) = 0
[PROOFSTEP]
rw [← real_inner_self_eq_norm_mul_norm, div_self (inner_self_ne_zero.2 hx : ⟪x, x⟫ ≠ 0), Real.arccos_one]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
hx : x ≠ 0
⊢ angle x (-x) = π
[PROOFSTEP]
rw [angle_neg_right, angle_self hx, sub_zero]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x : V
hx : x ≠ 0
⊢ angle (-x) x = π
[PROOFSTEP]
rw [angle_comm, angle_self_neg_of_nonzero hx]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
r : ℝ
hr : 0 < r
⊢ angle x (r • y) = angle x y
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
r : ℝ
hr : 0 < r
⊢ arccos (inner x (r • y) / (‖x‖ * ‖r • y‖)) = arccos (inner x y / (‖x‖ * ‖y‖))
[PROOFSTEP]
rw [inner_smul_right, norm_smul, Real.norm_eq_abs, abs_of_nonneg (le_of_lt hr), ← mul_assoc, mul_comm _ r, mul_assoc,
  mul_div_mul_left _ _ (ne_of_gt hr)]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
r : ℝ
hr : 0 < r
⊢ angle (r • x) y = angle x y
[PROOFSTEP]
rw [angle_comm, angle_smul_right_of_pos y x hr, angle_comm]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
r : ℝ
hr : r < 0
⊢ angle x (r • y) = angle x (-y)
[PROOFSTEP]
rw [← neg_neg r, neg_smul, angle_neg_right, angle_smul_right_of_pos x y (neg_pos_of_neg hr), angle_neg_right]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
r : ℝ
hr : r < 0
⊢ angle (r • x) y = angle (-x) y
[PROOFSTEP]
rw [angle_comm, angle_smul_right_of_neg y x hr, angle_comm]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ cos (angle x y) * (‖x‖ * ‖y‖) = inner x y
[PROOFSTEP]
rw [cos_angle, div_mul_cancel_of_imp]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ ‖x‖ * ‖y‖ = 0 → inner x y = 0
[PROOFSTEP]
simp (config := { contextual := true }) [or_imp]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ sin (angle x y) * (‖x‖ * ‖y‖) = sqrt (inner x x * inner y y - inner x y * inner x y)
[PROOFSTEP]
unfold angle
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ sin (arccos (inner x y / (‖x‖ * ‖y‖))) * (‖x‖ * ‖y‖) = sqrt (inner x x * inner y y - inner x y * inner x y)
[PROOFSTEP]
rw [Real.sin_arccos, ← Real.sqrt_mul_self (mul_nonneg (norm_nonneg x) (norm_nonneg y)), ←
  Real.sqrt_mul' _ (mul_self_nonneg _), sq, Real.sqrt_mul_self (mul_nonneg (norm_nonneg x) (norm_nonneg y)),
  real_inner_self_eq_norm_mul_norm, real_inner_self_eq_norm_mul_norm]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ sqrt ((1 - inner x y / (‖x‖ * ‖y‖) * (inner x y / (‖x‖ * ‖y‖))) * (‖x‖ * ‖y‖ * (‖x‖ * ‖y‖))) =
    sqrt (‖x‖ * ‖x‖ * (‖y‖ * ‖y‖) - inner x y * inner x y)
[PROOFSTEP]
by_cases h : ‖x‖ * ‖y‖ = 0
[GOAL]
case pos
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ * ‖y‖ = 0
⊢ sqrt ((1 - inner x y / (‖x‖ * ‖y‖) * (inner x y / (‖x‖ * ‖y‖))) * (‖x‖ * ‖y‖ * (‖x‖ * ‖y‖))) =
    sqrt (‖x‖ * ‖x‖ * (‖y‖ * ‖y‖) - inner x y * inner x y)
[PROOFSTEP]
rw [show ‖x‖ * ‖x‖ * (‖y‖ * ‖y‖) = ‖x‖ * ‖y‖ * (‖x‖ * ‖y‖) by ring, h, mul_zero, mul_zero, zero_sub]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ * ‖y‖ = 0
⊢ ‖x‖ * ‖x‖ * (‖y‖ * ‖y‖) = ‖x‖ * ‖y‖ * (‖x‖ * ‖y‖)
[PROOFSTEP]
ring
[GOAL]
case pos
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ * ‖y‖ = 0
⊢ sqrt 0 = sqrt (-(inner x y * inner x y))
[PROOFSTEP]
cases' eq_zero_or_eq_zero_of_mul_eq_zero h with hx hy
[GOAL]
case pos.inl
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ * ‖y‖ = 0
hx : ‖x‖ = 0
⊢ sqrt 0 = sqrt (-(inner x y * inner x y))
[PROOFSTEP]
rw [norm_eq_zero] at hx
[GOAL]
case pos.inl
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ * ‖y‖ = 0
hx : x = 0
⊢ sqrt 0 = sqrt (-(inner x y * inner x y))
[PROOFSTEP]
rw [hx, inner_zero_left, zero_mul, neg_zero]
[GOAL]
case pos.inr
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ * ‖y‖ = 0
hy : ‖y‖ = 0
⊢ sqrt 0 = sqrt (-(inner x y * inner x y))
[PROOFSTEP]
rw [norm_eq_zero] at hy
[GOAL]
case pos.inr
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ * ‖y‖ = 0
hy : y = 0
⊢ sqrt 0 = sqrt (-(inner x y * inner x y))
[PROOFSTEP]
rw [hy, inner_zero_right, zero_mul, neg_zero]
[GOAL]
case neg
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ¬‖x‖ * ‖y‖ = 0
⊢ sqrt ((1 - inner x y / (‖x‖ * ‖y‖) * (inner x y / (‖x‖ * ‖y‖))) * (‖x‖ * ‖y‖ * (‖x‖ * ‖y‖))) =
    sqrt (‖x‖ * ‖x‖ * (‖y‖ * ‖y‖) - inner x y * inner x y)
[PROOFSTEP]
field_simp [h]
[GOAL]
case neg
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ¬‖x‖ * ‖y‖ = 0
⊢ sqrt (‖x‖ * ‖y‖ * (‖x‖ * ‖y‖) - inner x y * inner x y) = sqrt (‖x‖ * ‖x‖ * (‖y‖ * ‖y‖) - inner x y * inner x y)
[PROOFSTEP]
ring_nf
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ angle x y = 0 ↔ x ≠ 0 ∧ ∃ r, 0 < r ∧ y = r • x
[PROOFSTEP]
rw [angle, ← real_inner_div_norm_mul_norm_eq_one_iff, Real.arccos_eq_zero, LE.le.le_iff_eq, eq_comm]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ inner x y / (‖x‖ * ‖y‖) ≤ 1
[PROOFSTEP]
exact (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).2
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ angle x y = π ↔ x ≠ 0 ∧ ∃ r, r < 0 ∧ y = r • x
[PROOFSTEP]
rw [angle, ← real_inner_div_norm_mul_norm_eq_neg_one_iff, Real.arccos_eq_pi, LE.le.le_iff_eq]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ -1 ≤ inner x y / (‖x‖ * ‖y‖)
[PROOFSTEP]
exact (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).1
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y z : V
h : angle x y = π
⊢ angle x z + angle y z = π
[PROOFSTEP]
rcases angle_eq_pi_iff.1 h with ⟨_, ⟨r, ⟨hr, rfl⟩⟩⟩
[GOAL]
case intro.intro.intro
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y x z : V
left✝ : x ≠ 0
r : ℝ
hr : r < 0
h : angle x (r • x) = π
⊢ angle x z + angle (r • x) z = π
[PROOFSTEP]
rw [angle_smul_left_of_neg x z hr, angle_neg_left, add_sub_cancel'_right]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ angle x y = π / 2 ↔ inner x y = 0
[PROOFSTEP]
simp (config := { contextual := true }) [angle, or_imp]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = π
⊢ inner x y = -(‖x‖ * ‖y‖)
[PROOFSTEP]
simp [← cos_angle_mul_norm_mul_norm, h]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = 0
⊢ inner x y = ‖x‖ * ‖y‖
[PROOFSTEP]
simp [← cos_angle_mul_norm_mul_norm, h]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
⊢ inner x y = -(‖x‖ * ‖y‖) ↔ angle x y = π
[PROOFSTEP]
refine' ⟨fun h => _, inner_eq_neg_mul_norm_of_angle_eq_pi⟩
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : inner x y = -(‖x‖ * ‖y‖)
⊢ angle x y = π
[PROOFSTEP]
have h₁ : ‖x‖ * ‖y‖ ≠ 0 := (mul_pos (norm_pos_iff.mpr hx) (norm_pos_iff.mpr hy)).ne'
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : inner x y = -(‖x‖ * ‖y‖)
h₁ : ‖x‖ * ‖y‖ ≠ 0
⊢ angle x y = π
[PROOFSTEP]
rw [angle, h, neg_div, div_self h₁, Real.arccos_neg_one]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
⊢ inner x y = ‖x‖ * ‖y‖ ↔ angle x y = 0
[PROOFSTEP]
refine' ⟨fun h => _, inner_eq_mul_norm_of_angle_eq_zero⟩
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : inner x y = ‖x‖ * ‖y‖
⊢ angle x y = 0
[PROOFSTEP]
have h₁ : ‖x‖ * ‖y‖ ≠ 0 := (mul_pos (norm_pos_iff.mpr hx) (norm_pos_iff.mpr hy)).ne'
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : inner x y = ‖x‖ * ‖y‖
h₁ : ‖x‖ * ‖y‖ ≠ 0
⊢ angle x y = 0
[PROOFSTEP]
rw [angle, h, div_self h₁, Real.arccos_one]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = π
⊢ ‖x - y‖ = ‖x‖ + ‖y‖
[PROOFSTEP]
rw [← sq_eq_sq (norm_nonneg (x - y)) (add_nonneg (norm_nonneg x) (norm_nonneg y)), norm_sub_pow_two_real,
  inner_eq_neg_mul_norm_of_angle_eq_pi h]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = π
⊢ ‖x‖ ^ 2 - 2 * -(‖x‖ * ‖y‖) + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
[PROOFSTEP]
ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = 0
⊢ ‖x + y‖ = ‖x‖ + ‖y‖
[PROOFSTEP]
rw [← sq_eq_sq (norm_nonneg (x + y)) (add_nonneg (norm_nonneg x) (norm_nonneg y)), norm_add_pow_two_real,
  inner_eq_mul_norm_of_angle_eq_zero h]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = 0
⊢ ‖x‖ ^ 2 + 2 * (‖x‖ * ‖y‖) + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
[PROOFSTEP]
ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = 0
⊢ ‖x - y‖ = |‖x‖ - ‖y‖|
[PROOFSTEP]
rw [← sq_eq_sq (norm_nonneg (x - y)) (abs_nonneg (‖x‖ - ‖y‖)), norm_sub_pow_two_real,
  inner_eq_mul_norm_of_angle_eq_zero h, sq_abs (‖x‖ - ‖y‖)]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : angle x y = 0
⊢ ‖x‖ ^ 2 - 2 * (‖x‖ * ‖y‖) + ‖y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
[PROOFSTEP]
ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
⊢ ‖x - y‖ = ‖x‖ + ‖y‖ ↔ angle x y = π
[PROOFSTEP]
refine' ⟨fun h => _, norm_sub_eq_add_norm_of_angle_eq_pi⟩
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = ‖x‖ + ‖y‖
⊢ angle x y = π
[PROOFSTEP]
rw [← inner_eq_neg_mul_norm_iff_angle_eq_pi hx hy]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = ‖x‖ + ‖y‖
⊢ inner x y = -(‖x‖ * ‖y‖)
[PROOFSTEP]
obtain ⟨hxy₁, hxy₂⟩ := norm_nonneg (x - y), add_nonneg (norm_nonneg x) (norm_nonneg y)
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = ‖x‖ + ‖y‖
hxy₁ : 0 ≤ ‖x - y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ inner x y = -(‖x‖ * ‖y‖)
[PROOFSTEP]
rw [← sq_eq_sq hxy₁ hxy₂, norm_sub_pow_two_real] at h
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h✝ : ‖x - y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
h : ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
hxy₁ : 0 ≤ ‖x - y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ inner x y = -(‖x‖ * ‖y‖)
[PROOFSTEP]
calc
  ⟪x, y⟫ = (‖x‖ ^ 2 + ‖y‖ ^ 2 - (‖x‖ + ‖y‖) ^ 2) / 2 := by linarith
  _ = -(‖x‖ * ‖y‖) := by ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h✝ : ‖x - y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
h : ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
hxy₁ : 0 ≤ ‖x - y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ inner x y = (‖x‖ ^ 2 + ‖y‖ ^ 2 - (‖x‖ + ‖y‖) ^ 2) / 2
[PROOFSTEP]
linarith
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h✝ : ‖x - y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
h : ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
hxy₁ : 0 ≤ ‖x - y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ (‖x‖ ^ 2 + ‖y‖ ^ 2 - (‖x‖ + ‖y‖) ^ 2) / 2 = -(‖x‖ * ‖y‖)
[PROOFSTEP]
ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
⊢ ‖x + y‖ = ‖x‖ + ‖y‖ ↔ angle x y = 0
[PROOFSTEP]
refine' ⟨fun h => _, norm_add_eq_add_norm_of_angle_eq_zero⟩
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x + y‖ = ‖x‖ + ‖y‖
⊢ angle x y = 0
[PROOFSTEP]
rw [← inner_eq_mul_norm_iff_angle_eq_zero hx hy]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x + y‖ = ‖x‖ + ‖y‖
⊢ inner x y = ‖x‖ * ‖y‖
[PROOFSTEP]
obtain ⟨hxy₁, hxy₂⟩ := norm_nonneg (x + y), add_nonneg (norm_nonneg x) (norm_nonneg y)
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x + y‖ = ‖x‖ + ‖y‖
hxy₁ : 0 ≤ ‖x + y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ inner x y = ‖x‖ * ‖y‖
[PROOFSTEP]
rw [← sq_eq_sq hxy₁ hxy₂, norm_add_pow_two_real] at h
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h✝ : ‖x + y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
h : ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
hxy₁ : 0 ≤ ‖x + y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ inner x y = ‖x‖ * ‖y‖
[PROOFSTEP]
calc
  ⟪x, y⟫ = ((‖x‖ + ‖y‖) ^ 2 - ‖x‖ ^ 2 - ‖y‖ ^ 2) / 2 := by linarith
  _ = ‖x‖ * ‖y‖ := by ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h✝ : ‖x + y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
h : ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
hxy₁ : 0 ≤ ‖x + y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ inner x y = ((‖x‖ + ‖y‖) ^ 2 - ‖x‖ ^ 2 - ‖y‖ ^ 2) / 2
[PROOFSTEP]
linarith
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h✝ : ‖x + y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
h : ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ + ‖y‖) ^ 2
hxy₁ : 0 ≤ ‖x + y‖
hxy₂ : 0 ≤ ‖x‖ + ‖y‖
⊢ ((‖x‖ + ‖y‖) ^ 2 - ‖x‖ ^ 2 - ‖y‖ ^ 2) / 2 = ‖x‖ * ‖y‖
[PROOFSTEP]
ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
⊢ ‖x - y‖ = |‖x‖ - ‖y‖| ↔ angle x y = 0
[PROOFSTEP]
refine' ⟨fun h => _, norm_sub_eq_abs_sub_norm_of_angle_eq_zero⟩
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
⊢ angle x y = 0
[PROOFSTEP]
rw [← inner_eq_mul_norm_iff_angle_eq_zero hx hy]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
⊢ inner x y = ‖x‖ * ‖y‖
[PROOFSTEP]
have h1 : ‖x - y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2 := by
  rw [h]
  exact sq_abs (‖x‖ - ‖y‖)
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
⊢ ‖x - y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
[PROOFSTEP]
rw [h]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
⊢ |‖x‖ - ‖y‖| ^ 2 = (‖x‖ - ‖y‖) ^ 2
[PROOFSTEP]
exact sq_abs (‖x‖ - ‖y‖)
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
h1 : ‖x - y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
⊢ inner x y = ‖x‖ * ‖y‖
[PROOFSTEP]
rw [norm_sub_pow_two_real] at h1
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
h1✝ : ‖x - y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
h1 : ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
⊢ inner x y = ‖x‖ * ‖y‖
[PROOFSTEP]
calc
  ⟪x, y⟫ = ((‖x‖ + ‖y‖) ^ 2 - ‖x‖ ^ 2 - ‖y‖ ^ 2) / 2 := by linarith
  _ = ‖x‖ * ‖y‖ := by ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
h1✝ : ‖x - y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
h1 : ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
⊢ inner x y = ((‖x‖ + ‖y‖) ^ 2 - ‖x‖ ^ 2 - ‖y‖ ^ 2) / 2
[PROOFSTEP]
linarith
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
hx : x ≠ 0
hy : y ≠ 0
h : ‖x - y‖ = |‖x‖ - ‖y‖|
h1✝ : ‖x - y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
h1 : ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 = (‖x‖ - ‖y‖) ^ 2
⊢ ((‖x‖ + ‖y‖) ^ 2 - ‖x‖ ^ 2 - ‖y‖ ^ 2) / 2 = ‖x‖ * ‖y‖
[PROOFSTEP]
ring
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ ‖x + y‖ = ‖x - y‖ ↔ angle x y = π / 2
[PROOFSTEP]
rw [← sq_eq_sq (norm_nonneg (x + y)) (norm_nonneg (x - y)), ← inner_eq_zero_iff_angle_eq_pi_div_two x y,
  norm_add_pow_two_real, norm_sub_pow_two_real]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 ↔ inner x y = 0
[PROOFSTEP]
constructor
[GOAL]
case mp
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2 → inner x y = 0
[PROOFSTEP]
intro h
[GOAL]
case mpr
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
⊢ inner x y = 0 → ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2
[PROOFSTEP]
intro h
[GOAL]
case mp
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2
⊢ inner x y = 0
[PROOFSTEP]
linarith
[GOAL]
case mpr
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x✝ y✝ x y : V
h : inner x y = 0
⊢ ‖x‖ ^ 2 + 2 * inner x y + ‖y‖ ^ 2 = ‖x‖ ^ 2 - 2 * inner x y + ‖y‖ ^ 2
[PROOFSTEP]
linarith
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ cos (angle x y) = 1 ↔ angle x y = 0
[PROOFSTEP]
rw [← cos_zero]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ cos (angle x y) = cos 0 ↔ angle x y = 0
[PROOFSTEP]
exact injOn_cos.eq_iff ⟨angle_nonneg x y, angle_le_pi x y⟩ (left_mem_Icc.2 pi_pos.le)
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ cos (angle x y) = 0 ↔ angle x y = π / 2
[PROOFSTEP]
rw [← cos_pi_div_two]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ cos (angle x y) = cos (π / 2) ↔ angle x y = π / 2
[PROOFSTEP]
apply injOn_cos.eq_iff ⟨angle_nonneg x y, angle_le_pi x y⟩
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ π / 2 ∈ Icc 0 π
[PROOFSTEP]
constructor
[GOAL]
case left
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ 0 ≤ π / 2
[PROOFSTEP]
linarith [pi_pos]
[GOAL]
case right
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ π / 2 ≤ π
[PROOFSTEP]
linarith [pi_pos]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ cos (angle x y) = -1 ↔ angle x y = π
[PROOFSTEP]
rw [← cos_pi]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ cos (angle x y) = cos π ↔ angle x y = π
[PROOFSTEP]
exact injOn_cos.eq_iff ⟨angle_nonneg x y, angle_le_pi x y⟩ (right_mem_Icc.2 pi_pos.le)
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ sin (angle x y) = 0 ↔ angle x y = 0 ∨ angle x y = π
[PROOFSTEP]
rw [sin_eq_zero_iff_cos_eq, cos_eq_one_iff_angle_eq_zero, cos_eq_neg_one_iff_angle_eq_pi]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
⊢ sin (angle x y) = 1 ↔ angle x y = π / 2
[PROOFSTEP]
refine' ⟨fun h => _, fun h => by rw [h, sin_pi_div_two]⟩
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
h : angle x y = π / 2
⊢ sin (angle x y) = 1
[PROOFSTEP]
rw [h, sin_pi_div_two]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
h : sin (angle x y) = 1
⊢ angle x y = π / 2
[PROOFSTEP]
rw [← cos_eq_zero_iff_angle_eq_pi_div_two, ← abs_eq_zero, abs_cos_eq_sqrt_one_sub_sin_sq, h]
[GOAL]
V : Type u_1
inst✝¹ : NormedAddCommGroup V
inst✝ : InnerProductSpace ℝ V
x y : V
h : sin (angle x y) = 1
⊢ sqrt (1 - 1 ^ 2) = 0
[PROOFSTEP]
simp


[GOAL]
n : Type u_1
inst✝⁴ : Fintype n
R : Type u_2
inst✝³ : Ring R
inst✝² : DecidableEq n
inst✝¹ : Nonempty n
p : ℕ
inst✝ : CharP R p
⊢ ∀ (x : ℕ), ↑x = 0 ↔ p ∣ x
[PROOFSTEP]
intro k
[GOAL]
n : Type u_1
inst✝⁴ : Fintype n
R : Type u_2
inst✝³ : Ring R
inst✝² : DecidableEq n
inst✝¹ : Nonempty n
p : ℕ
inst✝ : CharP R p
k : ℕ
⊢ ↑k = 0 ↔ p ∣ k
[PROOFSTEP]
rw [← CharP.cast_eq_zero_iff R p k, ← Nat.cast_zero, ← map_natCast <| scalar n]
[GOAL]
n : Type u_1
inst✝⁴ : Fintype n
R : Type u_2
inst✝³ : Ring R
inst✝² : DecidableEq n
inst✝¹ : Nonempty n
p : ℕ
inst✝ : CharP R p
k : ℕ
⊢ ↑(scalar n) ↑k = ↑0 ↔ ↑k = 0
[PROOFSTEP]
convert @scalar_inj n _ _ _ _ _ (@Nat.cast R NonAssocSemiring.toNatCast k) 0
[GOAL]
case h.e'_1.h.e'_3
n : Type u_1
inst✝⁴ : Fintype n
R : Type u_2
inst✝³ : Ring R
inst✝² : DecidableEq n
inst✝¹ : Nonempty n
p : ℕ
inst✝ : CharP R p
k : ℕ
⊢ ↑0 = ↑(scalar n) 0
[PROOFSTEP]
simp


[GOAL]
n : ℕ
h : 0 < n
m : ℕ := n / 2
⊢ m < n
[PROOFSTEP]
apply Nat.div_lt_self h
[GOAL]
n : ℕ
h : 0 < n
m : ℕ := n / 2
⊢ 1 < 2
[PROOFSTEP]
decide
[GOAL]
n : ℕ
⊢ Fin.ofNat 0 ≤ Fin.ofNat __do_lift✝
[PROOFSTEP]
simp [Fin.ofNat, LE.le]
[GOAL]
n : ℕ
⊢ 0 ≤ __do_lift✝ % (n + 1)
[PROOFSTEP]
exact Nat.zero_le _
[GOAL]
⊢ 0 < List.length (String.toList " 0123abcABC:,;`\\/")
[PROOFSTEP]
decide


[GOAL]
m n k l : ℕ
⊢ 1 < 0 ↔ 0 ≠ 0 ∧ 0 ≠ 1
[PROOFSTEP]
decide
[GOAL]
m n k l : ℕ
⊢ 1 < 1 ↔ 1 ≠ 0 ∧ 1 ≠ 1
[PROOFSTEP]
decide
[GOAL]
m n✝ k l n : ℕ
⊢ 1 < n + 2 ↔ n + 2 ≠ 0 ∧ n + 2 ≠ 1
[PROOFSTEP]
simp
[GOAL]
m n k l : ℕ
⊢ 0 = m * n ↔ m = 0 ∨ n = 0
[PROOFSTEP]
rw [eq_comm, Nat.mul_eq_zero]
[GOAL]
m n k l : ℕ
⊢ m + n = max m n ↔ m = 0 ∨ n = 0
[PROOFSTEP]
rw [← min_eq_zero_iff]
[GOAL]
m n k l : ℕ
⊢ m + n = max m n ↔ min m n = 0
[PROOFSTEP]
cases' le_total m n with H H
[GOAL]
case inl
m n k l : ℕ
H : m ≤ n
⊢ m + n = max m n ↔ min m n = 0
[PROOFSTEP]
simp [H]
[GOAL]
case inr
m n k l : ℕ
H : n ≤ m
⊢ m + n = max m n ↔ min m n = 0
[PROOFSTEP]
simp [H]
[GOAL]
m n k l : ℕ
⊢ m + n = min m n ↔ m = 0 ∧ n = 0
[PROOFSTEP]
rw [← max_eq_zero_iff]
[GOAL]
m n k l : ℕ
⊢ m + n = min m n ↔ max m n = 0
[PROOFSTEP]
cases' le_total m n with H H
[GOAL]
case inl
m n k l : ℕ
H : m ≤ n
⊢ m + n = min m n ↔ max m n = 0
[PROOFSTEP]
simp [H]
[GOAL]
case inr
m n k l : ℕ
H : n ≤ m
⊢ m + n = min m n ↔ max m n = 0
[PROOFSTEP]
simp [H]
[GOAL]
m n k l : ℕ
H : m * n = 1
⊢ n * ?m.12220 H = 1
[PROOFSTEP]
rwa [mul_comm]
[GOAL]
m n k l : ℕ
⊢ 2 ≤ 0 ↔ 0 ≠ 0 ∧ 0 ≠ 1
[PROOFSTEP]
simp
[GOAL]
m n k l : ℕ
⊢ 2 ≤ 1 ↔ 1 ≠ 0 ∧ 1 ≠ 1
[PROOFSTEP]
simp
[GOAL]
m n✝ k l n : ℕ
⊢ 2 ≤ n + 2 ↔ n + 2 ≠ 0 ∧ n + 2 ≠ 1
[PROOFSTEP]
simp
[GOAL]
m✝ n✝ k l m n : ℕ
⊢ 0 < m + n → 0 < m ∨ 0 < n
[PROOFSTEP]
intro h
[GOAL]
m✝ n✝ k l m n : ℕ
h : 0 < m + n
⊢ 0 < m ∨ 0 < n
[PROOFSTEP]
cases' m with m
[GOAL]
case zero
m n✝ k l n : ℕ
h : 0 < zero + n
⊢ 0 < zero ∨ 0 < n
[PROOFSTEP]
simp [zero_add] at h
[GOAL]
case zero
m n✝ k l n : ℕ
h : 0 < n
⊢ 0 < zero ∨ 0 < n
[PROOFSTEP]
exact Or.inr h
[GOAL]
case succ
m✝ n✝ k l n m : ℕ
h : 0 < succ m + n
⊢ 0 < succ m ∨ 0 < n
[PROOFSTEP]
exact Or.inl (succ_pos _)
[GOAL]
m✝ n✝ k l m n : ℕ
⊢ 0 < m ∨ 0 < n → 0 < m + n
[PROOFSTEP]
intro h
[GOAL]
m✝ n✝ k l m n : ℕ
h : 0 < m ∨ 0 < n
⊢ 0 < m + n
[PROOFSTEP]
cases' h with mpos npos
[GOAL]
case inl
m✝ n✝ k l m n : ℕ
mpos : 0 < m
⊢ 0 < m + n
[PROOFSTEP]
apply add_pos_left mpos
[GOAL]
case inr
m✝ n✝ k l m n : ℕ
npos : 0 < n
⊢ 0 < m + n
[PROOFSTEP]
apply add_pos_right _ npos
[GOAL]
m n k l : ℕ
⊢ m + n = 1 ↔ m = 0 ∧ n = 1 ∨ m = 1 ∧ n = 0
[PROOFSTEP]
cases n
[GOAL]
case zero
m k l : ℕ
⊢ m + zero = 1 ↔ m = 0 ∧ zero = 1 ∨ m = 1 ∧ zero = 0
[PROOFSTEP]
simp [succ_eq_add_one, ← add_assoc, succ_inj']
[GOAL]
case succ
m k l n✝ : ℕ
⊢ m + succ n✝ = 1 ↔ m = 0 ∧ succ n✝ = 1 ∨ m = 1 ∧ succ n✝ = 0
[PROOFSTEP]
simp [succ_eq_add_one, ← add_assoc, succ_inj']
[GOAL]
m n k l : ℕ
⊢ m + n = 2 ↔ m = 0 ∧ n = 2 ∨ m = 1 ∧ n = 1 ∨ m = 2 ∧ n = 0
[PROOFSTEP]
cases n
[GOAL]
case zero
m k l : ℕ
⊢ m + zero = 2 ↔ m = 0 ∧ zero = 2 ∨ m = 1 ∧ zero = 1 ∨ m = 2 ∧ zero = 0
[PROOFSTEP]
simp [(succ_ne_zero 1).symm, (show 2 = Nat.succ 1 from rfl), succ_eq_add_one, ← add_assoc, succ_inj', add_eq_one_iff]
[GOAL]
case succ
m k l n✝ : ℕ
⊢ m + succ n✝ = 2 ↔ m = 0 ∧ succ n✝ = 2 ∨ m = 1 ∧ succ n✝ = 1 ∨ m = 2 ∧ succ n✝ = 0
[PROOFSTEP]
simp [(succ_ne_zero 1).symm, (show 2 = Nat.succ 1 from rfl), succ_eq_add_one, ← add_assoc, succ_inj', add_eq_one_iff]
[GOAL]
m n k l : ℕ
⊢ m + n = 3 ↔ m = 0 ∧ n = 3 ∨ m = 1 ∧ n = 2 ∨ m = 2 ∧ n = 1 ∨ m = 3 ∧ n = 0
[PROOFSTEP]
cases n
[GOAL]
case zero
m k l : ℕ
⊢ m + zero = 3 ↔ m = 0 ∧ zero = 3 ∨ m = 1 ∧ zero = 2 ∨ m = 2 ∧ zero = 1 ∨ m = 3 ∧ zero = 0
[PROOFSTEP]
simp [(succ_ne_zero 1).symm, succ_eq_add_one, (show 3 = Nat.succ 2 from rfl), ← add_assoc, succ_inj', add_eq_two_iff]
[GOAL]
case succ
m k l n✝ : ℕ
⊢ m + succ n✝ = 3 ↔ m = 0 ∧ succ n✝ = 3 ∨ m = 1 ∧ succ n✝ = 2 ∨ m = 2 ∧ succ n✝ = 1 ∨ m = 3 ∧ succ n✝ = 0
[PROOFSTEP]
simp [(succ_ne_zero 1).symm, succ_eq_add_one, (show 3 = Nat.succ 2 from rfl), ← add_assoc, succ_inj', add_eq_two_iff]
[GOAL]
m n k l : ℕ
⊢ n ≤ m ∧ m ≤ n + 1 ↔ m = n ∨ m = n + 1
[PROOFSTEP]
rw [le_add_one_iff, and_or_left, ← le_antisymm_iff, eq_comm, and_iff_right_of_imp]
[GOAL]
m n k l : ℕ
⊢ m = n + 1 → n ≤ m
[PROOFSTEP]
rintro rfl
[GOAL]
n k l : ℕ
⊢ n ≤ n + 1
[PROOFSTEP]
exact n.le_succ
[GOAL]
m n k l : ℕ
hab : m < n
hcd : k < l
⊢ m + k + 1 < n + l
[PROOFSTEP]
rw [add_assoc]
[GOAL]
m n k l : ℕ
hab : m < n
hcd : k < l
⊢ m + (k + 1) < n + l
[PROOFSTEP]
exact add_lt_add_of_lt_of_le hab (Nat.succ_le_iff.2 hcd)
[GOAL]
m n k l : ℕ
⊢ m ≤ succ n → pred m ≤ n
[PROOFSTEP]
cases m
[GOAL]
case zero
n k l : ℕ
⊢ zero ≤ succ n → pred zero ≤ n
[PROOFSTEP]
exact fun _ => zero_le n
[GOAL]
case succ
n k l n✝ : ℕ
⊢ succ n✝ ≤ succ n → pred (succ n✝) ≤ n
[PROOFSTEP]
exact le_of_succ_le_succ
[GOAL]
m n k l : ℕ
⊢ OrderedSub ℕ
[PROOFSTEP]
constructor
[GOAL]
case tsub_le_iff_right
m n k l : ℕ
⊢ ∀ (a b c : ℕ), a - b ≤ c ↔ a ≤ c + b
[PROOFSTEP]
intro m n k
[GOAL]
case tsub_le_iff_right
m✝ n✝ k✝ l m n k : ℕ
⊢ m - n ≤ k ↔ m ≤ k + n
[PROOFSTEP]
induction' n with n ih generalizing k
[GOAL]
case tsub_le_iff_right.zero
m✝ n k✝¹ l m k✝ k : ℕ
⊢ m - zero ≤ k ↔ m ≤ k + zero
[PROOFSTEP]
simp
[GOAL]
case tsub_le_iff_right.succ
m✝ n✝ k✝¹ l m k✝ n : ℕ
ih : ∀ (k : ℕ), m - n ≤ k ↔ m ≤ k + n
k : ℕ
⊢ m - succ n ≤ k ↔ m ≤ k + succ n
[PROOFSTEP]
simp only [sub_succ, pred_le_iff, ih, succ_add, add_succ]
[GOAL]
m n k l : ℕ
h : k + l = m + n - 1
⊢ m ≤ k ∨ n ≤ l
[PROOFSTEP]
cases' le_or_lt m k with h' h' <;> [left; right]
[GOAL]
m n k l : ℕ
h : k + l = m + n - 1
⊢ m ≤ k ∨ n ≤ l
[PROOFSTEP]
cases' le_or_lt m k with h' h'
[GOAL]
case inl
m n k l : ℕ
h : k + l = m + n - 1
h' : m ≤ k
⊢ m ≤ k ∨ n ≤ l
[PROOFSTEP]
left
[GOAL]
case inr
m n k l : ℕ
h : k + l = m + n - 1
h' : k < m
⊢ m ≤ k ∨ n ≤ l
[PROOFSTEP]
right
[GOAL]
case inl.h
m n k l : ℕ
h : k + l = m + n - 1
h' : m ≤ k
⊢ m ≤ k
[PROOFSTEP]
exact h'
[GOAL]
case inr.h
m n k l : ℕ
h : k + l = m + n - 1
h' : k < m
⊢ n ≤ l
[PROOFSTEP]
replace h' := add_lt_add_right h' l
[GOAL]
case inr.h
m n k l : ℕ
h : k + l = m + n - 1
h' : k + l < m + l
⊢ n ≤ l
[PROOFSTEP]
rw [h] at h'
[GOAL]
case inr.h
m n k l : ℕ
h : k + l = m + n - 1
h' : m + n - 1 < m + l
⊢ n ≤ l
[PROOFSTEP]
cases' n.eq_zero_or_pos with hn hn
[GOAL]
case inr.h.inl
m n k l : ℕ
h : k + l = m + n - 1
h' : m + n - 1 < m + l
hn : n = 0
⊢ n ≤ l
[PROOFSTEP]
rw [hn]
[GOAL]
case inr.h.inl
m n k l : ℕ
h : k + l = m + n - 1
h' : m + n - 1 < m + l
hn : n = 0
⊢ 0 ≤ l
[PROOFSTEP]
exact zero_le l
[GOAL]
case inr.h.inr
m n k l : ℕ
h : k + l = m + n - 1
h' : m + n - 1 < m + l
hn : n > 0
⊢ n ≤ l
[PROOFSTEP]
rw [n.add_sub_assoc (Nat.succ_le_of_lt hn), add_lt_add_iff_left] at h'
[GOAL]
case inr.h.inr
m n k l : ℕ
h : k + l = m + n - 1
h' : n - succ 0 < l
hn : n > 0
⊢ n ≤ l
[PROOFSTEP]
exact Nat.le_of_pred_lt h'
[GOAL]
m n✝ k l n : ℕ
⊢ n + 1 ≤ (n + 1) * (n + 1)
[PROOFSTEP]
simp
[GOAL]
m n k l : ℕ
h : 0 < n
⊢ m ≤ n * m
[PROOFSTEP]
conv =>
  lhs
  rw [← one_mul m]
[GOAL]
m n k l : ℕ
h : 0 < n
| m ≤ n * m
[PROOFSTEP]
  lhs
  rw [← one_mul m]
[GOAL]
m n k l : ℕ
h : 0 < n
| m ≤ n * m
[PROOFSTEP]
  lhs
  rw [← one_mul m]
[GOAL]
m n k l : ℕ
h : 0 < n
| m ≤ n * m
[PROOFSTEP]
lhs
[GOAL]
m n k l : ℕ
h : 0 < n
| m
[PROOFSTEP]
rw [← one_mul m]
[GOAL]
m n k l : ℕ
h : 0 < n
⊢ 1 * m ≤ n * m
[PROOFSTEP]
exact mul_le_mul_of_nonneg_right h.nat_succ_le (zero_le _)
[GOAL]
m n k l : ℕ
h : 0 < n
⊢ m ≤ m * n
[PROOFSTEP]
conv =>
  lhs
  rw [← mul_one m]
[GOAL]
m n k l : ℕ
h : 0 < n
| m ≤ m * n
[PROOFSTEP]
  lhs
  rw [← mul_one m]
[GOAL]
m n k l : ℕ
h : 0 < n
| m ≤ m * n
[PROOFSTEP]
  lhs
  rw [← mul_one m]
[GOAL]
m n k l : ℕ
h : 0 < n
| m ≤ m * n
[PROOFSTEP]
lhs
[GOAL]
m n k l : ℕ
h : 0 < n
| m
[PROOFSTEP]
rw [← mul_one m]
[GOAL]
m n k l : ℕ
h : 0 < n
⊢ m * 1 ≤ m * n
[PROOFSTEP]
exact mul_le_mul_of_nonneg_left h.nat_succ_le (zero_le _)
[GOAL]
m n✝ k l n i : ℕ
hi : i ≠ 0
⊢ n ≤ i + (n - 1)
[PROOFSTEP]
refine le_trans ?_ add_tsub_le_assoc
[GOAL]
m n✝ k l n i : ℕ
hi : i ≠ 0
⊢ n ≤ i + n - 1
[PROOFSTEP]
simp [add_comm, Nat.add_sub_assoc, one_le_iff_ne_zero.2 hi]
[GOAL]
m n k l : ℕ
hm : m ≠ 0
hn : n ≠ 0
⊢ m + n - 1 ≤ m * n
[PROOFSTEP]
cases m
[GOAL]
case zero
n k l : ℕ
hn : n ≠ 0
hm : zero ≠ 0
⊢ zero + n - 1 ≤ zero * n
[PROOFSTEP]
cases hm rfl
[GOAL]
case succ
n k l : ℕ
hn : n ≠ 0
n✝ : ℕ
hm : succ n✝ ≠ 0
⊢ succ n✝ + n - 1 ≤ succ n✝ * n
[PROOFSTEP]
rw [succ_add, succ_sub_one, succ_mul]
[GOAL]
case succ
n k l : ℕ
hn : n ≠ 0
n✝ : ℕ
hm : succ n✝ ≠ 0
⊢ n✝ + n ≤ n✝ * n + n
[PROOFSTEP]
exact add_le_add_right (le_mul_of_one_le_right' $ succ_le_iff.2 $ pos_iff_ne_zero.2 hn) _
[GOAL]
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
⊢ P (a + 1) (b + 1)
[PROOFSTEP]
apply hd _ _ ((add_lt_add_iff_right _).1 h)
[GOAL]
case a
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
⊢ P (a + 1) b
[PROOFSTEP]
have this : a + 1 = b ∨ a + 1 < b := by rwa [← le_iff_eq_or_lt, ← Nat.lt_succ_iff]
[GOAL]
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
⊢ a + 1 = b ∨ a + 1 < b
[PROOFSTEP]
rwa [← le_iff_eq_or_lt, ← Nat.lt_succ_iff]
[GOAL]
case a
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
this : a + 1 = b ∨ a + 1 < b
⊢ P (a + 1) b
[PROOFSTEP]
have wf : (a + 1) + b < (a + 1) + (b + 1) := by simp
[GOAL]
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
this : a + 1 = b ∨ a + 1 < b
⊢ a + 1 + b < a + 1 + (b + 1)
[PROOFSTEP]
simp
[GOAL]
case a
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
this : a + 1 = b ∨ a + 1 < b
wf : a + 1 + b < a + 1 + (b + 1)
⊢ P (a + 1) b
[PROOFSTEP]
rcases this with (rfl | h)
[GOAL]
case a.inl
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a : ℕ
h : a + 1 < a + 1 + 1
wf : a + 1 + (a + 1) < a + 1 + (a + 1 + 1)
⊢ P (a + 1) (a + 1)
[PROOFSTEP]
exact ha _
[GOAL]
case a.inr
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h✝ : a + 1 < b + 1
wf : a + 1 + b < a + 1 + (b + 1)
h : a + 1 < b
⊢ P (a + 1) b
[PROOFSTEP]
apply diag_induction P ha hb hd (a + 1) b h
[GOAL]
case a
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
⊢ P a (b + 1)
[PROOFSTEP]
have _ : a + (b + 1) < (a + 1) + (b + 1) := by simp
[GOAL]
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
⊢ a + (b + 1) < a + 1 + (b + 1)
[PROOFSTEP]
simp
[GOAL]
case a
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
x✝ : a + (b + 1) < a + 1 + (b + 1)
⊢ P a (b + 1)
[PROOFSTEP]
apply diag_induction P ha hb hd a (b + 1)
[GOAL]
case a
m n k l : ℕ
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
a b : ℕ
h : a + 1 < b + 1
x✝ : a + (b + 1) < a + 1 + (b + 1)
⊢ a < b + 1
[PROOFSTEP]
apply lt_of_le_of_lt (Nat.le_succ _) h
[GOAL]
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
_x✝ : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1
a✝² :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y _x✝ →
      P y.1 y.2.1
x✝⁴ : ℕ
x✝³ : (x : ℕ) ×' x✝⁴ < x
a✝¹ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁴, snd := x✝³ } →
      P y.1 y.2.1
x✝² : ℕ
x✝¹ : x✝⁴ < x✝²
a✝ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁴, snd := { fst := x✝², snd := x✝¹ } } →
      P y.1 y.2.1
a b : ℕ
h✝ : a + 1 < b + 1
x✝ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := succ a, snd := { fst := succ b, snd := h✝ } } →
      P y.1 y.2.1
this : a + 1 = b ∨ a + 1 < b
wf : a + 1 + b < a + 1 + (b + 1)
h : a + 1 < b
⊢ (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
    { fst := a + 1, snd := { fst := b, snd := h } } { fst := succ a, snd := { fst := succ b, snd := h✝ } }
[PROOFSTEP]
{assumption
}
[GOAL]
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
_x✝ : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1
a✝² :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y _x✝ →
      P y.1 y.2.1
x✝⁴ : ℕ
x✝³ : (x : ℕ) ×' x✝⁴ < x
a✝¹ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁴, snd := x✝³ } →
      P y.1 y.2.1
x✝² : ℕ
x✝¹ : x✝⁴ < x✝²
a✝ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁴, snd := { fst := x✝², snd := x✝¹ } } →
      P y.1 y.2.1
a b : ℕ
h✝ : a + 1 < b + 1
x✝ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := succ a, snd := { fst := succ b, snd := h✝ } } →
      P y.1 y.2.1
this : a + 1 = b ∨ a + 1 < b
wf : a + 1 + b < a + 1 + (b + 1)
h : a + 1 < b
⊢ (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
    { fst := a + 1, snd := { fst := b, snd := h } } { fst := succ a, snd := { fst := succ b, snd := h✝ } }
[PROOFSTEP]
assumption
[GOAL]
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
_x✝ : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1
a✝³ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y _x✝ →
      P y.1 y.2.1
x✝⁵ : ℕ
x✝⁴ : (x : ℕ) ×' x✝⁵ < x
a✝² :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁵, snd := x✝⁴ } →
      P y.1 y.2.1
x✝³ : ℕ
x✝² : x✝⁵ < x✝³
a✝¹ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁵, snd := { fst := x✝³, snd := x✝² } } →
      P y.1 y.2.1
a b : ℕ
h : a + 1 < b + 1
x✝¹ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := succ a, snd := { fst := succ b, snd := h } } →
      P y.1 y.2.1
x✝ : a + (b + 1) < a + 1 + (b + 1)
a✝ : a < b + 1
⊢ (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
    { fst := a, snd := { fst := b + 1, snd := a✝ } } { fst := succ a, snd := { fst := succ b, snd := h } }
[PROOFSTEP]
{assumption
}
[GOAL]
P : ℕ → ℕ → Prop
ha : ∀ (a : ℕ), P (a + 1) (a + 1)
hb : ∀ (b : ℕ), P 0 (b + 1)
hd : ∀ (a b : ℕ), a < b → P (a + 1) b → P a (b + 1) → P (a + 1) (b + 1)
_x✝ : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1
a✝³ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y _x✝ →
      P y.1 y.2.1
x✝⁵ : ℕ
x✝⁴ : (x : ℕ) ×' x✝⁵ < x
a✝² :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁵, snd := x✝⁴ } →
      P y.1 y.2.1
x✝³ : ℕ
x✝² : x✝⁵ < x✝³
a✝¹ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := x✝⁵, snd := { fst := x✝³, snd := x✝² } } →
      P y.1 y.2.1
a b : ℕ
h : a + 1 < b + 1
x✝¹ :
  ∀ (y : (x : ℕ) ×' (x_1 : ℕ) ×' x < x_1),
    (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
        y { fst := succ a, snd := { fst := succ b, snd := h } } →
      P y.1 y.2.1
x✝ : a + (b + 1) < a + 1 + (b + 1)
a✝ : a < b + 1
⊢ (invImage (fun a => PSigma.casesOn a fun a snd => PSigma.casesOn snd fun b snd => a + b) instWellFoundedRelation).1
    { fst := a, snd := { fst := b + 1, snd := a✝ } } { fst := succ a, snd := { fst := succ b, snd := h } }
[PROOFSTEP]
assumption
[GOAL]
m n k l : ℕ
h : m ≤ k * n
k0 : k = 0
⊢ m / k ≤ n
[PROOFSTEP]
rw [k0, Nat.div_zero]
[GOAL]
m n k l : ℕ
h : m ≤ k * n
k0 : k = 0
⊢ 0 ≤ n
[PROOFSTEP]
apply zero_le
[GOAL]
m✝ n✝ k l m n : ℕ
n0 : n = 0
⊢ m / n ≤ m
[PROOFSTEP]
rw [n0, Nat.div_zero]
[GOAL]
m✝ n✝ k l m n : ℕ
n0 : n = 0
⊢ 0 ≤ m
[PROOFSTEP]
apply zero_le
[GOAL]
m n k l : ℕ
hn : 2 ≤ n
h : m ≤ m / n
⊢ n * m ≤ m
[PROOFSTEP]
rw [mul_comm]
[GOAL]
m n k l : ℕ
hn : 2 ≤ n
h : m ≤ m / n
⊢ m * n ≤ m
[PROOFSTEP]
exact (Nat.le_div_iff_mul_le' (lt_of_lt_of_le (by decide) hn)).1 h
[GOAL]
m n k l : ℕ
hn : 2 ≤ n
h : m ≤ m / n
⊢ 0 < 2
[PROOFSTEP]
decide
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hm0 : m = 0
⊢ m / k * n / m ≤ n / k
[PROOFSTEP]
simp [hm0]
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hm0 : ¬m = 0
⊢ m / k * n ≤ n * m / k
[PROOFSTEP]
rw [mul_comm]
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hm0 : ¬m = 0
⊢ n * (m / k) ≤ n * m / k
[PROOFSTEP]
exact mul_div_le_mul_div_assoc _ _ _
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hm0 : ¬m = 0
⊢ n * m / k / m = n / k
[PROOFSTEP]
{rw [Nat.div_div_eq_div_mul, mul_comm n, mul_comm k, Nat.mul_div_mul_left _ _ (Nat.pos_of_ne_zero hm0)]
}
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hm0 : ¬m = 0
⊢ n * m / k / m = n / k
[PROOFSTEP]
rw [Nat.div_div_eq_div_mul, mul_comm n, mul_comm k, Nat.mul_div_mul_left _ _ (Nat.pos_of_ne_zero hm0)]
[GOAL]
m n k l : ℕ
hmk : k ∣ m
hnl : l ∣ n
⊢ m * n / (k * l) = m / k * (n / l)
[PROOFSTEP]
rcases k.eq_zero_or_pos with (rfl | hk0)
[GOAL]
case inl
m n l : ℕ
hnl : l ∣ n
hmk : 0 ∣ m
⊢ m * n / (0 * l) = m / 0 * (n / l)
[PROOFSTEP]
simp
[GOAL]
case inr
m n k l : ℕ
hmk : k ∣ m
hnl : l ∣ n
hk0 : k > 0
⊢ m * n / (k * l) = m / k * (n / l)
[PROOFSTEP]
rcases l.eq_zero_or_pos with (rfl | hl0)
[GOAL]
case inr.inl
m n k : ℕ
hmk : k ∣ m
hk0 : k > 0
hnl : 0 ∣ n
⊢ m * n / (k * 0) = m / k * (n / 0)
[PROOFSTEP]
simp
[GOAL]
case inr.inr
m n k l : ℕ
hmk : k ∣ m
hnl : l ∣ n
hk0 : k > 0
hl0 : l > 0
⊢ m * n / (k * l) = m / k * (n / l)
[PROOFSTEP]
obtain ⟨_, rfl⟩ := hmk
[GOAL]
case inr.inr.intro
n k l : ℕ
hnl : l ∣ n
hk0 : k > 0
hl0 : l > 0
w✝ : ℕ
⊢ k * w✝ * n / (k * l) = k * w✝ / k * (n / l)
[PROOFSTEP]
obtain ⟨_, rfl⟩ := hnl
[GOAL]
case inr.inr.intro.intro
k l : ℕ
hk0 : k > 0
hl0 : l > 0
w✝¹ w✝ : ℕ
⊢ k * w✝¹ * (l * w✝) / (k * l) = k * w✝¹ / k * (l * w✝ / l)
[PROOFSTEP]
rw [mul_mul_mul_comm, Nat.mul_div_cancel_left _ hk0, Nat.mul_div_cancel_left _ hl0,
  Nat.mul_div_cancel_left _ (mul_pos hk0 hl0)]
[GOAL]
m n k l a b : ℕ
h : a / 2 < a - b
⊢ b ≤ a / 2
[PROOFSTEP]
rw [Nat.le_div_iff_mul_le two_pos]
[GOAL]
m n k l a b : ℕ
h : a / 2 < a - b
⊢ b * 2 ≤ a
[PROOFSTEP]
rw [Nat.div_lt_iff_lt_mul two_pos, Nat.mul_sub_right_distrib, lt_tsub_iff_right, mul_two a] at h
[GOAL]
m n k l a b : ℕ
h✝ : a < a * 2 - b * 2
h : a + b * 2 < a + a
⊢ b * 2 ≤ a
[PROOFSTEP]
exact le_of_lt (Nat.lt_of_add_lt_add_left h)
[GOAL]
m n k l a b : ℕ
h : a - b ≤ a / 2
⊢ a / 2 ≤ b
[PROOFSTEP]
rw [Nat.le_div_iff_mul_le two_pos, Nat.mul_sub_right_distrib, tsub_le_iff_right, mul_two, add_le_add_iff_left] at h
[GOAL]
m n k l a b : ℕ
h✝ : a * 2 - b * 2 ≤ a
h : a ≤ b * 2
⊢ a / 2 ≤ b
[PROOFSTEP]
rw [← Nat.mul_div_left b two_pos]
[GOAL]
m n k l a b : ℕ
h✝ : a * 2 - b * 2 ≤ a
h : a ≤ b * 2
⊢ a / 2 ≤ b * 2 / 2
[PROOFSTEP]
exact Nat.div_le_div_right h
[GOAL]
m n k l : ℕ
hn : n % 2 = 1
⊢ 2 * (n / 2) = n - 1
[PROOFSTEP]
conv =>
  rhs
  rw [← Nat.mod_add_div n 2, hn, @add_tsub_cancel_left]
[GOAL]
m n k l : ℕ
hn : n % 2 = 1
| 2 * (n / 2) = n - 1
[PROOFSTEP]
  rhs
  rw [← Nat.mod_add_div n 2, hn, @add_tsub_cancel_left]
[GOAL]
m n k l : ℕ
hn : n % 2 = 1
| 2 * (n / 2) = n - 1
[PROOFSTEP]
  rhs
  rw [← Nat.mod_add_div n 2, hn, @add_tsub_cancel_left]
[GOAL]
m n k l : ℕ
hn : n % 2 = 1
| 2 * (n / 2) = n - 1
[PROOFSTEP]
rhs
[GOAL]
m n k l : ℕ
hn : n % 2 = 1
| n - 1
[PROOFSTEP]
rw [← Nat.mod_add_div n 2, hn, @add_tsub_cancel_left]
[GOAL]
m n k l : ℕ
h : n ∣ m
hm : m ≠ 0
⊢ m / (m / n) = n
[PROOFSTEP]
rcases h with ⟨_, rfl⟩
[GOAL]
case intro
n k l w✝ : ℕ
hm : n * w✝ ≠ 0
⊢ n * w✝ / (n * w✝ / n) = n
[PROOFSTEP]
rw [mul_ne_zero_iff] at hm
[GOAL]
case intro
n k l w✝ : ℕ
hm : n ≠ 0 ∧ w✝ ≠ 0
⊢ n * w✝ / (n * w✝ / n) = n
[PROOFSTEP]
rw [mul_div_right _ (Nat.pos_of_ne_zero hm.1), mul_div_left _ (Nat.pos_of_ne_zero hm.2)]
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
⊢ m % (n * k) / n = m / n % k
[PROOFSTEP]
rcases Nat.eq_zero_or_pos n with (rfl | hn)
[GOAL]
case inl
m✝ n k✝ l m k : ℕ
⊢ m % (0 * k) / 0 = m / 0 % k
case inr m✝ n✝ k✝ l m n k : ℕ hn : n > 0 ⊢ m % (n * k) / n = m / n % k
[PROOFSTEP]
simp [mod_zero]
[GOAL]
case inr
m✝ n✝ k✝ l m n k : ℕ
hn : n > 0
⊢ m % (n * k) / n = m / n % k
[PROOFSTEP]
rcases Nat.eq_zero_or_pos k with (rfl | hk)
[GOAL]
case inr.inl
m✝ n✝ k l m n : ℕ
hn : n > 0
⊢ m % (n * 0) / n = m / n % 0
case inr.inr m✝ n✝ k✝ l m n k : ℕ hn : n > 0 hk : k > 0 ⊢ m % (n * k) / n = m / n % k
[PROOFSTEP]
simp [mod_zero]
[GOAL]
case inr.inr
m✝ n✝ k✝ l m n k : ℕ
hn : n > 0
hk : k > 0
⊢ m % (n * k) / n = m / n % k
[PROOFSTEP]
conv_rhs => rw [← mod_add_div m (n * k)]
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hn : n > 0
hk : k > 0
| m / n % k
[PROOFSTEP]
rw [← mod_add_div m (n * k)]
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hn : n > 0
hk : k > 0
| m / n % k
[PROOFSTEP]
rw [← mod_add_div m (n * k)]
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
hn : n > 0
hk : k > 0
| m / n % k
[PROOFSTEP]
rw [← mod_add_div m (n * k)]
[GOAL]
case inr.inr
m✝ n✝ k✝ l m n k : ℕ
hn : n > 0
hk : k > 0
⊢ m % (n * k) / n = (m % (n * k) + n * k * (m / (n * k))) / n % k
[PROOFSTEP]
rw [mul_assoc, add_mul_div_left _ _ hn, add_mul_mod_self_left,
  mod_eq_of_lt (Nat.div_lt_of_lt_mul (mod_lt _ (mul_pos hn hk)))]
[GOAL]
m✝ n✝ k✝ l m n k : ℕ
⊢ m % (k * n) / n = m / n % k
[PROOFSTEP]
rw [mul_comm k, mod_mul_right_div_self]
[GOAL]
m n k l : ℕ
h1 : 0 < n
h2 : n < m
⊢ ¬m ∣ n
[PROOFSTEP]
rintro ⟨k, rfl⟩
[GOAL]
case intro
m k✝ l k : ℕ
h1 : 0 < m * k
h2 : m * k < m
⊢ False
[PROOFSTEP]
rcases Nat.eq_zero_or_pos k with (rfl | hk)
[GOAL]
case intro.inl
m k l : ℕ
h1 : 0 < m * 0
h2 : m * 0 < m
⊢ False
[PROOFSTEP]
exact lt_irrefl 0 h1
[GOAL]
case intro.inr
m k✝ l k : ℕ
h1 : 0 < m * k
h2 : m * k < m
hk : k > 0
⊢ False
[PROOFSTEP]
exact not_lt.2 (le_mul_of_pos_right hk) h2
[GOAL]
m n k l : ℕ
h : m % k = n % k
⊢ (m - n) % k = 0
[PROOFSTEP]
rw [← Nat.mod_add_div m k, ← Nat.mod_add_div n k, ← h, tsub_add_eq_tsub_tsub, @add_tsub_cancel_left, ← mul_tsub k,
  Nat.mul_mod_right]
[GOAL]
m n k l : ℕ
⊢ (m + n) % k = if k ≤ m % k + n % k then m % k + n % k - k else m % k + n % k
[PROOFSTEP]
cases k
[GOAL]
case zero
m n l : ℕ
⊢ (m + n) % zero = if zero ≤ m % zero + n % zero then m % zero + n % zero - zero else m % zero + n % zero
case succ
m n l n✝ : ℕ
⊢ (m + n) % succ n✝ =
    if succ n✝ ≤ m % succ n✝ + n % succ n✝ then m % succ n✝ + n % succ n✝ - succ n✝ else m % succ n✝ + n % succ n✝
[PROOFSTEP]
simp [mod_zero]
[GOAL]
case succ
m n l n✝ : ℕ
⊢ (m + n) % succ n✝ =
    if succ n✝ ≤ m % succ n✝ + n % succ n✝ then m % succ n✝ + n % succ n✝ - succ n✝ else m % succ n✝ + n % succ n✝
[PROOFSTEP]
rw [Nat.add_mod]
[GOAL]
case succ
m n l n✝ : ℕ
⊢ (m % succ n✝ + n % succ n✝) % succ n✝ =
    if succ n✝ ≤ m % succ n✝ + n % succ n✝ then m % succ n✝ + n % succ n✝ - succ n✝ else m % succ n✝ + n % succ n✝
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
m n l n✝ : ℕ
h : succ n✝ ≤ m % succ n✝ + n % succ n✝
⊢ (m % succ n✝ + n % succ n✝) % succ n✝ = m % succ n✝ + n % succ n✝ - succ n✝
[PROOFSTEP]
rw [Nat.mod_eq_sub_mod h, Nat.mod_eq_of_lt]
[GOAL]
case pos
m n l n✝ : ℕ
h : succ n✝ ≤ m % succ n✝ + n % succ n✝
⊢ m % succ n✝ + n % succ n✝ - succ n✝ < succ n✝
[PROOFSTEP]
exact (tsub_lt_iff_right h).mpr (Nat.add_lt_add (m.mod_lt (zero_lt_succ _)) (n.mod_lt (zero_lt_succ _)))
[GOAL]
case neg
m n l n✝ : ℕ
h : ¬succ n✝ ≤ m % succ n✝ + n % succ n✝
⊢ (m % succ n✝ + n % succ n✝) % succ n✝ = m % succ n✝ + n % succ n✝
[PROOFSTEP]
exact Nat.mod_eq_of_lt (lt_of_not_ge h)
[GOAL]
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
exi1 : ∃ x, m = n * x
exi2 : ∃ y, k = l * y
hn : n = 0
⊢ m / n * (k / l) = m * k / (n * l)
[PROOFSTEP]
simp [hn]
[GOAL]
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
exi1 : ∃ x, m = n * x
exi2 : ∃ y, k = l * y
hn : ¬n = 0
this : 0 < n
hl : l = 0
⊢ m / n * (k / l) = m * k / (n * l)
[PROOFSTEP]
simp [hl]
[GOAL]
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
exi1 : ∃ x, m = n * x
exi2 : ∃ y, k = l * y
hn : ¬n = 0
this : 0 < n
hl : ¬l = 0
⊢ m / n * (k / l) = m * k / (n * l)
[PROOFSTEP]
have : 0 < l := Nat.pos_of_ne_zero hl
[GOAL]
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
exi1 : ∃ x, m = n * x
exi2 : ∃ y, k = l * y
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
⊢ m / n * (k / l) = m * k / (n * l)
[PROOFSTEP]
cases' exi1 with x hx
[GOAL]
case intro
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
exi2 : ∃ y, k = l * y
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
⊢ m / n * (k / l) = m * k / (n * l)
[PROOFSTEP]
cases' exi2 with y hy
[GOAL]
case intro.intro
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ m / n * (k / l) = m * k / (n * l)
[PROOFSTEP]
rw [hx, hy, Nat.mul_div_cancel_left, Nat.mul_div_cancel_left]
[GOAL]
case intro.intro
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ x * y = n * x * (l * y) / (n * l)
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < l
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n
[PROOFSTEP]
apply Eq.symm
[GOAL]
case intro.intro.h
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ n * x * (l * y) / (n * l) = x * y
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < l
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n
[PROOFSTEP]
apply Nat.div_eq_of_eq_mul_left
[GOAL]
case intro.intro.h.H1
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n * l
case intro.intro.h.H2
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ n * x * (l * y) = x * y * (n * l)
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < l
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n
[PROOFSTEP]
apply mul_pos
[GOAL]
case intro.intro.h.H1.ha
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n
case intro.intro.h.H1.hb
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < l
case intro.intro.h.H2
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ n * x * (l * y) = x * y * (n * l)
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < l
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n
[PROOFSTEP]
repeat'
  assumption
    -- Porting note: this line was `cc` in Lean3
[GOAL]
case intro.intro.h.H1.ha
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n
[PROOFSTEP]
assumption
  -- Porting note: this line was `cc` in Lean3
[GOAL]
case intro.intro.h.H1.hb
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < l
[PROOFSTEP]
assumption
  -- Porting note: this line was `cc` in Lean3
[GOAL]
case intro.intro.h.H2
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ n * x * (l * y) = x * y * (n * l)
[PROOFSTEP]
assumption
  -- Porting note: this line was `cc` in Lean3
[GOAL]
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < l
[PROOFSTEP]
assumption
  -- Porting note: this line was `cc` in Lean3
[GOAL]
case intro.intro.H
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ 0 < n
[PROOFSTEP]
assumption
  -- Porting note: this line was `cc` in Lean3
[GOAL]
case intro.intro.h.H2
m n k l : ℕ
hmn : n ∣ m
hkl : l ∣ k
hn : ¬n = 0
this✝ : 0 < n
hl : ¬l = 0
this : 0 < l
x : ℕ
hx : m = n * x
y : ℕ
hy : k = l * y
⊢ n * x * (l * y) = x * y * (n * l)
[PROOFSTEP]
simp only [mul_comm, mul_left_comm, mul_assoc]
[GOAL]
m n k l : ℕ
⊢ m / n = m ↔ m = 0 ∨ n = 1
[PROOFSTEP]
constructor
[GOAL]
case mp
m n k l : ℕ
⊢ m / n = m → m = 0 ∨ n = 1
[PROOFSTEP]
intro
[GOAL]
case mp
m n k l : ℕ
a✝ : m / n = m
⊢ m = 0 ∨ n = 1
[PROOFSTEP]
match n with
| 0 => simp_all
| 1 =>
  right
  rfl
| n + 2 =>
  left
  have : m / (n + 2) ≤ m / 2 := div_le_div_left (by simp) (by decide)
  refine eq_zero_of_le_half ?_
  simp_all
[GOAL]
m n k l : ℕ
a✝ : m / 0 = m
⊢ m = 0 ∨ 0 = 1
[PROOFSTEP]
simp_all
[GOAL]
m n k l : ℕ
a✝ : m / 1 = m
⊢ m = 0 ∨ 1 = 1
[PROOFSTEP]
right
[GOAL]
case h
m n k l : ℕ
a✝ : m / 1 = m
⊢ 1 = 1
[PROOFSTEP]
rfl
[GOAL]
m n✝ k l n : ℕ
a✝ : m / (n + 2) = m
⊢ m = 0 ∨ n + 2 = 1
[PROOFSTEP]
left
[GOAL]
case h
m n✝ k l n : ℕ
a✝ : m / (n + 2) = m
⊢ m = 0
[PROOFSTEP]
have : m / (n + 2) ≤ m / 2 := div_le_div_left (by simp) (by decide)
[GOAL]
m n✝ k l n : ℕ
a✝ : m / (n + 2) = m
⊢ 2 ≤ n + 2
[PROOFSTEP]
simp
[GOAL]
m n✝ k l n : ℕ
a✝ : m / (n + 2) = m
⊢ 0 < 2
[PROOFSTEP]
decide
[GOAL]
case h
m n✝ k l n : ℕ
a✝ : m / (n + 2) = m
this : m / (n + 2) ≤ m / 2
⊢ m = 0
[PROOFSTEP]
refine eq_zero_of_le_half ?_
[GOAL]
case h
m n✝ k l n : ℕ
a✝ : m / (n + 2) = m
this : m / (n + 2) ≤ m / 2
⊢ m ≤ m / 2
[PROOFSTEP]
simp_all
[GOAL]
case mpr
m n k l : ℕ
⊢ m = 0 ∨ n = 1 → m / n = m
[PROOFSTEP]
rintro (rfl | rfl)
[GOAL]
case mpr.inl
n k l : ℕ
⊢ 0 / n = 0
[PROOFSTEP]
simp
[GOAL]
case mpr.inr
m k l : ℕ
⊢ m / 1 = m
[PROOFSTEP]
simp
[GOAL]
m n k l : ℕ
⊢ m / n = (m - m % n) / n
[PROOFSTEP]
by_cases n0 : n = 0
[GOAL]
case pos
m n k l : ℕ
n0 : n = 0
⊢ m / n = (m - m % n) / n
[PROOFSTEP]
rw [n0, Nat.div_zero, Nat.div_zero]
[GOAL]
case neg
m n k l : ℕ
n0 : ¬n = 0
⊢ m / n = (m - m % n) / n
[PROOFSTEP]
have : m - m % n = n * (m / n) := by rw [tsub_eq_iff_eq_add_of_le (Nat.mod_le _ _), add_comm, mod_add_div]
[GOAL]
m n k l : ℕ
n0 : ¬n = 0
⊢ m - m % n = n * (m / n)
[PROOFSTEP]
rw [tsub_eq_iff_eq_add_of_le (Nat.mod_le _ _), add_comm, mod_add_div]
[GOAL]
case neg
m n k l : ℕ
n0 : ¬n = 0
this : m - m % n = n * (m / n)
⊢ m / n = (m - m % n) / n
[PROOFSTEP]
rw [this, mul_div_right _ (Nat.pos_of_ne_zero n0)]
[GOAL]
m n k l : ℕ
h1 : n * k < m
h2 : m < n * (k + 1)
⊢ ¬n ∣ m
[PROOFSTEP]
rintro ⟨d, rfl⟩
[GOAL]
case intro
n k l d : ℕ
h1 : n * k < n * d
h2 : n * d < n * (k + 1)
⊢ False
[PROOFSTEP]
exact Monotone.ne_of_lt_of_lt_nat (Covariant.monotone_of_const n) k h1 h2 d rfl
[GOAL]
m n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
h : ∃ n, p n
⊢ 0 < Nat.find h ↔ ¬p 0
[PROOFSTEP]
rw [pos_iff_ne_zero, Ne, Nat.find_eq_zero]
[GOAL]
m n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
⊢ Nat.find hₘ + n = Nat.find hₙ
[PROOFSTEP]
refine ((le_find_iff _ _).2 fun m hm hpm => hm.not_le ?_).antisymm ?_
[GOAL]
case refine_1
m✝ n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
m : ℕ
hm : m < Nat.find hₘ + n
hpm : p m
⊢ Nat.find hₘ + n ≤ m
[PROOFSTEP]
have hnm : n ≤ m := hn.trans (find_le hpm)
[GOAL]
case refine_1
m✝ n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
m : ℕ
hm : m < Nat.find hₘ + n
hpm : p m
hnm : n ≤ m
⊢ Nat.find hₘ + n ≤ m
[PROOFSTEP]
refine add_le_of_le_tsub_right_of_le hnm (find_le ?_)
[GOAL]
case refine_1
m✝ n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
m : ℕ
hm : m < Nat.find hₘ + n
hpm : p m
hnm : n ≤ m
⊢ p (m - n + n)
[PROOFSTEP]
rwa [tsub_add_cancel_of_le hnm]
[GOAL]
case refine_2
m n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
⊢ Nat.find hₙ ≤ Nat.find hₘ + n
[PROOFSTEP]
rw [← tsub_le_iff_right]
[GOAL]
case refine_2
m n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
⊢ Nat.find hₙ - n ≤ Nat.find hₘ
[PROOFSTEP]
refine (le_find_iff _ _).2 fun m hm hpm => hm.not_le ?_
[GOAL]
case refine_2
m✝ n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
m : ℕ
hm : m < Nat.find hₙ - n
hpm : p (m + n)
⊢ Nat.find hₙ - n ≤ m
[PROOFSTEP]
rw [tsub_le_iff_right]
[GOAL]
case refine_2
m✝ n k l : ℕ
p q : ℕ → Prop
inst✝¹ : DecidablePred p
inst✝ : DecidablePred q
hₘ : ∃ m, p (m + n)
hₙ : ∃ n, p n
hn : n ≤ Nat.find hₙ
m : ℕ
hm : m < Nat.find hₙ - n
hpm : p (m + n)
⊢ Nat.find hₙ ≤ m + n
[PROOFSTEP]
exact find_le hpm
[GOAL]
m n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
⊢ Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
[PROOFSTEP]
induction' k with k ihk generalizing m
[GOAL]
case zero
m✝ n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
m : ℕ
⊢ Nat.findGreatest P zero = m ↔ m ≤ zero ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ zero → ¬P n
[PROOFSTEP]
rw [eq_comm, Iff.comm]
[GOAL]
case zero
m✝ n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
m : ℕ
⊢ (m ≤ zero ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ zero → ¬P n) ↔ m = Nat.findGreatest P zero
[PROOFSTEP]
simp only [zero_eq, nonpos_iff_eq_zero, ne_eq, findGreatest_zero, and_iff_left_iff_imp]
[GOAL]
case zero
m✝ n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
m : ℕ
⊢ m = 0 → (¬m = 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n = 0 → ¬P n
[PROOFSTEP]
rintro rfl
[GOAL]
case zero
m n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
⊢ (¬0 = 0 → P 0) ∧ ∀ ⦃n : ℕ⦄, 0 < n → n = 0 → ¬P n
[PROOFSTEP]
exact ⟨fun h => (h rfl).elim, fun n hlt heq => (hlt.ne heq.symm).elim⟩
[GOAL]
case succ
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
⊢ Nat.findGreatest P (succ k) = m ↔ m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
by_cases hk : P (k + 1)
[GOAL]
case pos
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ Nat.findGreatest P (succ k) = m ↔ m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
rw [findGreatest_eq hk]
[GOAL]
case pos
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ k + 1 = m ↔ m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
constructor
[GOAL]
case pos.mp
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ k + 1 = m → m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
rintro rfl
[GOAL]
case pos.mp
m n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : P (k + 1)
⊢ k + 1 ≤ succ k ∧ (k + 1 ≠ 0 → P (k + 1)) ∧ ∀ ⦃n : ℕ⦄, k + 1 < n → n ≤ succ k → ¬P n
[PROOFSTEP]
exact ⟨le_rfl, fun _ => hk, fun n hlt hle => (hlt.not_le hle).elim⟩
[GOAL]
case pos.mpr
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ (m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n) → k + 1 = m
[PROOFSTEP]
rintro ⟨hle, h0, hm⟩
[GOAL]
case pos.mpr.intro.intro
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
hle : m ≤ succ k
h0 : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
⊢ k + 1 = m
[PROOFSTEP]
rcases Decidable.eq_or_lt_of_le hle with (rfl | hlt)
[GOAL]
case pos.mpr.intro.intro.inl
m n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : P (k + 1)
hle : succ k ≤ succ k
h0 : succ k ≠ 0 → P (succ k)
hm : ∀ ⦃n : ℕ⦄, succ k < n → n ≤ succ k → ¬P n
⊢ k + 1 = succ k
case pos.mpr.intro.intro.inr
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
hle : m ≤ succ k
h0 : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
hlt : m < succ k
⊢ k + 1 = m
[PROOFSTEP]
exacts [rfl, (hm hlt le_rfl hk).elim]
[GOAL]
case neg
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ Nat.findGreatest P (succ k) = m ↔ m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
rw [findGreatest_of_not hk, ihk]
[GOAL]
case neg
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n) ↔
    m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
constructor
[GOAL]
case neg.mp
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n) →
    m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
rintro ⟨hle, hP, hm⟩
[GOAL]
case neg.mp.intro.intro
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
⊢ m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
[PROOFSTEP]
refine ⟨hle.trans k.le_succ, hP, fun n hlt hle => ?_⟩
[GOAL]
case neg.mp.intro.intro
m✝ n✝ k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
n : ℕ
hlt : m < n
hle : n ≤ succ k
⊢ ¬P n
[PROOFSTEP]
rcases Decidable.eq_or_lt_of_le hle with (rfl | hlt')
[GOAL]
case neg.mp.intro.intro.inl
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hlt : m < succ k
hle : succ k ≤ succ k
⊢ ¬P (succ k)
case neg.mp.intro.intro.inr
m✝ n✝ k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
n : ℕ
hlt : m < n
hle : n ≤ succ k
hlt' : n < succ k
⊢ ¬P n
[PROOFSTEP]
exacts [hk, hm hlt <| lt_succ_iff.1 hlt']
[GOAL]
case neg.mpr
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ succ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n) →
    m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
[PROOFSTEP]
rintro ⟨hle, hP, hm⟩
[GOAL]
case neg.mpr.intro.intro
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ succ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
⊢ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
[PROOFSTEP]
refine ⟨lt_succ_iff.1 (hle.lt_of_ne ?_), hP, fun n hlt hle => hm hlt (hle.trans k.le_succ)⟩
[GOAL]
case neg.mpr.intro.intro
m✝ n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ succ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ succ k → ¬P n
⊢ m ≠ succ k
[PROOFSTEP]
rintro rfl
[GOAL]
case neg.mpr.intro.intro
m n k✝ l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
k : ℕ
ihk : ∀ {m : ℕ}, Nat.findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : ¬P (k + 1)
hle : succ k ≤ succ k
hP : succ k ≠ 0 → P (succ k)
hm : ∀ ⦃n : ℕ⦄, succ k < n → n ≤ succ k → ¬P n
⊢ False
[PROOFSTEP]
exact hk (hP k.succ_ne_zero)
[GOAL]
m n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
⊢ Nat.findGreatest P k = 0 ↔ ∀ ⦃n : ℕ⦄, 0 < n → n ≤ k → ¬P n
[PROOFSTEP]
simp [findGreatest_eq_iff]
[GOAL]
m n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
hmb : m ≤ n
hm : P m
⊢ P (Nat.findGreatest P n)
[PROOFSTEP]
by_cases h : Nat.findGreatest P n = 0
[GOAL]
case pos
m n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
hmb : m ≤ n
hm : P m
h : Nat.findGreatest P n = 0
⊢ P (Nat.findGreatest P n)
[PROOFSTEP]
cases m
[GOAL]
case pos.zero
n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
h : Nat.findGreatest P n = 0
hmb : zero ≤ n
hm : P zero
⊢ P (Nat.findGreatest P n)
[PROOFSTEP]
rwa [h]
[GOAL]
case pos.succ
n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
h : Nat.findGreatest P n = 0
n✝ : ℕ
hmb : succ n✝ ≤ n
hm : P (succ n✝)
⊢ P (Nat.findGreatest P n)
[PROOFSTEP]
exact ((findGreatest_eq_zero_iff.1 h) (zero_lt_succ _) hmb hm).elim
[GOAL]
case neg
m n k l : ℕ
P Q : ℕ → Prop
inst✝ : DecidablePred P
hmb : m ≤ n
hm : P m
h : ¬Nat.findGreatest P n = 0
⊢ P (Nat.findGreatest P n)
[PROOFSTEP]
exact (findGreatest_eq_iff.1 rfl).2.1 h
[GOAL]
m n k l : ℕ
P✝ Q : ℕ → Prop
inst✝¹ : DecidablePred P✝
P : ℕ → Prop
inst✝ : DecidablePred P
⊢ Monotone (Nat.findGreatest P)
[PROOFSTEP]
refine monotone_nat_of_le_succ fun n => ?_
[GOAL]
m n✝ k l : ℕ
P✝ Q : ℕ → Prop
inst✝¹ : DecidablePred P✝
P : ℕ → Prop
inst✝ : DecidablePred P
n : ℕ
⊢ Nat.findGreatest P n ≤ Nat.findGreatest P (n + 1)
[PROOFSTEP]
rw [findGreatest_succ]
[GOAL]
m n✝ k l : ℕ
P✝ Q : ℕ → Prop
inst✝¹ : DecidablePred P✝
P : ℕ → Prop
inst✝ : DecidablePred P
n : ℕ
⊢ Nat.findGreatest P n ≤ if P (n + 1) then n + 1 else Nat.findGreatest P n
[PROOFSTEP]
split_ifs
[GOAL]
case pos
m n✝ k l : ℕ
P✝ Q : ℕ → Prop
inst✝¹ : DecidablePred P✝
P : ℕ → Prop
inst✝ : DecidablePred P
n : ℕ
h✝ : P (n + 1)
⊢ Nat.findGreatest P n ≤ n + 1
[PROOFSTEP]
exact (findGreatest_le n).trans (le_succ _)
[GOAL]
case neg
m n✝ k l : ℕ
P✝ Q : ℕ → Prop
inst✝¹ : DecidablePred P✝
P : ℕ → Prop
inst✝ : DecidablePred P
n : ℕ
h✝ : ¬P (n + 1)
⊢ Nat.findGreatest P n ≤ Nat.findGreatest P n
[PROOFSTEP]
rfl
[GOAL]
m n k l : ℕ
P Q : ℕ → Prop
inst✝¹ : DecidablePred P
inst✝ : DecidablePred Q
hPQ : P ≤ Q
⊢ Nat.findGreatest P ≤ Nat.findGreatest Q
[PROOFSTEP]
intro n
[GOAL]
m n✝ k l : ℕ
P Q : ℕ → Prop
inst✝¹ : DecidablePred P
inst✝ : DecidablePred Q
hPQ : P ≤ Q
n : ℕ
⊢ Nat.findGreatest P n ≤ Nat.findGreatest Q n
[PROOFSTEP]
induction' n with n hn
[GOAL]
case zero
m n k l : ℕ
P Q : ℕ → Prop
inst✝¹ : DecidablePred P
inst✝ : DecidablePred Q
hPQ : P ≤ Q
⊢ Nat.findGreatest P zero ≤ Nat.findGreatest Q zero
[PROOFSTEP]
rfl
[GOAL]
case succ
m n✝ k l : ℕ
P Q : ℕ → Prop
inst✝¹ : DecidablePred P
inst✝ : DecidablePred Q
hPQ : P ≤ Q
n : ℕ
hn : Nat.findGreatest P n ≤ Nat.findGreatest Q n
⊢ Nat.findGreatest P (succ n) ≤ Nat.findGreatest Q (succ n)
[PROOFSTEP]
by_cases h : P (n + 1)
[GOAL]
case pos
m n✝ k l : ℕ
P Q : ℕ → Prop
inst✝¹ : DecidablePred P
inst✝ : DecidablePred Q
hPQ : P ≤ Q
n : ℕ
hn : Nat.findGreatest P n ≤ Nat.findGreatest Q n
h : P (n + 1)
⊢ Nat.findGreatest P (succ n) ≤ Nat.findGreatest Q (succ n)
[PROOFSTEP]
rw [findGreatest_eq h, findGreatest_eq (hPQ _ h)]
[GOAL]
case neg
m n✝ k l : ℕ
P Q : ℕ → Prop
inst✝¹ : DecidablePred P
inst✝ : DecidablePred Q
hPQ : P ≤ Q
n : ℕ
hn : Nat.findGreatest P n ≤ Nat.findGreatest Q n
h : ¬P (n + 1)
⊢ Nat.findGreatest P (succ n) ≤ Nat.findGreatest Q (succ n)
[PROOFSTEP]
rw [findGreatest_of_not h]
[GOAL]
case neg
m n✝ k l : ℕ
P Q : ℕ → Prop
inst✝¹ : DecidablePred P
inst✝ : DecidablePred Q
hPQ : P ≤ Q
n : ℕ
hn : Nat.findGreatest P n ≤ Nat.findGreatest Q n
h : ¬P (n + 1)
⊢ Nat.findGreatest P n ≤ Nat.findGreatest Q (succ n)
[PROOFSTEP]
exact hn.trans (Nat.findGreatest_mono_right _ <| le_succ _)
[GOAL]
m n k l : ℕ
h : bit0 m ≤ bit1 n
⊢ m ≤ n
[PROOFSTEP]
rwa [← Nat.lt_succ_iff, n.bit1_eq_succ_bit0, ← n.bit0_succ_eq, bit0_lt_bit0, Nat.lt_succ_iff] at h
[GOAL]
m n k l : ℕ
h : bit1 m ≤ bit0 n
⊢ m < n
[PROOFSTEP]
rwa [m.bit1_eq_succ_bit0, succ_le_iff, bit0_lt_bit0] at h
[GOAL]
m n k l lo hi : ℕ
P : ℕ → Prop
H : DecidablePred P
al : ∀ (x : ℕ), x < hi - lo → P (lo + x)
x : ℕ
hl : lo ≤ x
hh : x < hi
⊢ P x
[PROOFSTEP]
have := al (x - lo) ((tsub_lt_tsub_iff_right hl).mpr hh)
[GOAL]
m n k l lo hi : ℕ
P : ℕ → Prop
H : DecidablePred P
al : ∀ (x : ℕ), x < hi - lo → P (lo + x)
x : ℕ
hl : lo ≤ x
hh : x < hi
this : P (lo + (x - lo))
⊢ P x
[PROOFSTEP]
rwa [add_tsub_cancel_of_le hl] at this