Theorem: Fin.find_min
File: Mathlib/Data/Fin/Tuple/Basic.lean

tactic: rw [find] at hi
state_before: m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
hi : i ∈ find p
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
⊢ False

tactic: cases' h : find fun i : Fin n ↦ p (i.castLT (Nat.lt_succ_of_lt i.2)) with k
state_before: m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
hi :
  i ∈
    Option.casesOn (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) (if x : p (last n) then some (last n) else none)
      fun i => some (castLT i (_ : ↑i < Nat.succ n))
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
⊢ False

tactic: simp only [h] at hi
state_before: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
hi :
  i ∈
    Option.casesOn (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) (if x : p (last n) then some (last n) else none)
      fun i => some (castLT i (_ : ↑i < Nat.succ n))
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = none
⊢ False

tactic: split_ifs at hi with hl
state_before: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = none
hi : i ∈ if x : p (last n) then some (last n) else none
⊢ False

tactic: cases hi
state_before: case none.inl
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = none
hl : p (last n)
hi : i ∈ some (last n)
⊢ False

tactic: rw [find_eq_none_iff] at h
state_before: case none.inl.refl
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p { val := j, isLt := hjn }
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = none
hl : p (last n)
hj : { val := j, isLt := hjn } < last n
⊢ False

tactic: refine h ⟨j, hj⟩ hpj
state_before: case none.inl.refl
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p { val := j, isLt := hjn }
h : ∀ (i : Fin n), ¬p (castLT i (_ : ↑i < Nat.succ n))
hl : p (last n)
hj : { val := j, isLt := hjn } < last n
⊢ False

tactic: exact Option.not_mem_none _ hi
state_before: case none.inr
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = none
hl : ¬p (last n)
hi : i ∈ none
⊢ False

tactic: rw [h] at hi
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
hi :
  i ∈
    Option.casesOn (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) (if x : p (last n) then some (last n) else none)
      fun i => some (castLT i (_ : ↑i < Nat.succ n))
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
k : Fin n
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = some k
⊢ False

tactic: dsimp at hi
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
k : Fin n
hi :
  i ∈
    Option.casesOn (some k) (if x : p (last n) then some (last n) else none) fun i =>
      some (castLT i (_ : ↑i < Nat.succ n))
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = some k
⊢ False

tactic: obtain rfl := Option.some_inj.1 hi
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : { val := j, isLt := hjn } < i
hpj : p { val := j, isLt := hjn }
k : Fin n
hi : i ∈ some (castLT k (_ : ↑k < Nat.succ n))
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = some k
⊢ False

tactic: exact find_min h (show (⟨j, lt_trans hj k.2⟩ : Fin n) < k from hj) hpj
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p { val := j, isLt := hjn }
k : Fin n
h : (find fun i => p (castLT i (_ : ↑i < Nat.succ n))) = some k
hj : { val := j, isLt := hjn } < castLT k (_ : ↑k < Nat.succ n)
hi : castLT k (_ : ↑k < Nat.succ n) ∈ some (castLT k (_ : ↑k < Nat.succ n))
⊢ False