Theorem: Fermat42.exists_minimal
File: Mathlib/NumberTheory/Fermat4.lean

tactic: let S : Set ℕ := { n | ∃ s : ℤ × ℤ × ℤ, Fermat42 s.1 s.2.1 s.2.2 ∧ n = Int.natAbs s.2.2 }
state_before: a b c : ℤ
h : Fermat42 a b c
⊢ ∃ a0 b0 c0, Minimal a0 b0 c0

tactic: have S_nonempty : S.Nonempty := by
  use Int.natAbs c
  rw [Set.mem_setOf_eq]
  use ⟨a, ⟨b, c⟩⟩
  tauto
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
⊢ ∃ a0 b0 c0, Minimal a0 b0 c0

tactic: let m : ℕ := Nat.find S_nonempty
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
⊢ ∃ a0 b0 c0, Minimal a0 b0 c0

tactic: have m_mem : m ∈ S := Nat.find_spec S_nonempty
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
⊢ ∃ a0 b0 c0, Minimal a0 b0 c0

tactic: rcases m_mem with ⟨s0, hs0, hs1⟩
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
m_mem : m ∈ S
⊢ ∃ a0 b0 c0, Minimal a0 b0 c0

tactic: use s0.1, s0.2.1, s0.2.2, hs0
state_before: case intro.intro
a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
s0 : ℤ × ℤ × ℤ
hs0 : Fermat42 s0.fst s0.snd.fst s0.snd.snd
hs1 : m = Int.natAbs s0.snd.snd
⊢ ∃ a0 b0 c0, Minimal a0 b0 c0

tactic: intro a1 b1 c1 h1
state_before: case intro.intro
a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
s0 : ℤ × ℤ × ℤ
hs0 : Fermat42 s0.fst s0.snd.fst s0.snd.snd
hs1 : m = Int.natAbs s0.snd.snd
⊢ ∀ (a1 b1 c1 : ℤ), Fermat42 a1 b1 c1 → Int.natAbs s0.snd.snd ≤ Int.natAbs c1

tactic: rw [← hs1]
state_before: case intro.intro
a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
s0 : ℤ × ℤ × ℤ
hs0 : Fermat42 s0.fst s0.snd.fst s0.snd.snd
hs1 : m = Int.natAbs s0.snd.snd
a1 b1 c1 : ℤ
h1 : Fermat42 a1 b1 c1
⊢ Int.natAbs s0.snd.snd ≤ Int.natAbs c1

tactic: apply Nat.find_min'
state_before: case intro.intro
a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
s0 : ℤ × ℤ × ℤ
hs0 : Fermat42 s0.fst s0.snd.fst s0.snd.snd
hs1 : m = Int.natAbs s0.snd.snd
a1 b1 c1 : ℤ
h1 : Fermat42 a1 b1 c1
⊢ m ≤ Int.natAbs c1

tactic: use ⟨a1, ⟨b1, c1⟩⟩
state_before: case intro.intro.h
a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
s0 : ℤ × ℤ × ℤ
hs0 : Fermat42 s0.fst s0.snd.fst s0.snd.snd
hs1 : m = Int.natAbs s0.snd.snd
a1 b1 c1 : ℤ
h1 : Fermat42 a1 b1 c1
⊢ Int.natAbs c1 ∈ S

tactic: tauto
state_before: case intro.intro.h
a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
S_nonempty : Set.Nonempty S
m : ℕ := Nat.find S_nonempty
s0 : ℤ × ℤ × ℤ
hs0 : Fermat42 s0.fst s0.snd.fst s0.snd.snd
hs1 : m = Int.natAbs s0.snd.snd
a1 b1 c1 : ℤ
h1 : Fermat42 a1 b1 c1
⊢ Fermat42 (a1, b1, c1).fst (a1, b1, c1).snd.fst (a1, b1, c1).snd.snd ∧ Int.natAbs c1 = Int.natAbs (a1, b1, c1).snd.snd

tactic: use Int.natAbs c
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
⊢ Set.Nonempty S

tactic: rw [Set.mem_setOf_eq]
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
⊢ Int.natAbs c ∈ S

tactic: use ⟨a, ⟨b, c⟩⟩
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
⊢ ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ Int.natAbs c = Int.natAbs s.snd.snd

tactic: tauto
state_before: a b c : ℤ
h : Fermat42 a b c
S : Set ℕ := {n | ∃ s, Fermat42 s.fst s.snd.fst s.snd.snd ∧ n = Int.natAbs s.snd.snd}
⊢ Fermat42 (a, b, c).fst (a, b, c).snd.fst (a, b, c).snd.snd ∧ Int.natAbs c = Int.natAbs (a, b, c).snd.snd