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 : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
⊢ False
state_after: m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
hi :
  i ∈
    Option.casesOn (find fun i => p (i.castLT ⋯)) (if x : p (last n) then some (last n) else none) fun i =>
      some (i.castLT ⋯)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, 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 (i.castLT ⋯)) (if x : p (last n) then some (last n) else none) fun i =>
      some (i.castLT ⋯)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
⊢ False
state_after: 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 (i.castLT ⋯)) (if x : p (last n) then some (last n) else none) fun i =>
      some (i.castLT ⋯)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
⊢ False

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 (i.castLT ⋯)) (if x : p (last n) then some (last n) else none) fun i =>
      some (i.castLT ⋯)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
k : Fin n
h : (find fun i => p (i.castLT ⋯)) = some k
⊢ 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 (i.castLT ⋯)) (if x : p (last n) then some (last n) else none) fun i =>
      some (i.castLT ⋯)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
⊢ False
state_after: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hi : i ∈ if x : p (last n) then some (last n) else 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 : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hi : i ∈ if x : p (last n) then some (last n) else none
⊢ False
state_after: case pos
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hi : i ∈ some (last n)
⊢ False

case neg
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hl : ¬p (last n)
hi : i ∈ none
⊢ False

tactic: cases hi
state_before: case pos
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hi : i ∈ some (last n)
⊢ False
state_after: case pos.refl
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hj : ⟨j, hjn⟩ < last n
⊢ False

tactic: rw [find_eq_none_iff] at h
state_before: case pos.refl
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hj : ⟨j, hjn⟩ < last n
⊢ False
state_after: case pos.refl
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p ⟨j, hjn⟩
h : ∀ (i : Fin n), ¬p (i.castLT ⋯)
hl : p (last n)
hj : ⟨j, hjn⟩ < last n
⊢ False

tactic: exact h ⟨j, hj⟩ hpj
state_before: case pos.refl
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p ⟨j, hjn⟩
h : ∀ (i : Fin n), ¬p (i.castLT ⋯)
hl : p (last n)
hj : ⟨j, hjn⟩ < last n
⊢ False
state_after: no goals

tactic: exact Option.not_mem_none _ hi
state_before: case neg
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
h : (find fun i => p (i.castLT ⋯)) = none
hl : ¬p (last n)
hi : i ∈ none
⊢ False
state_after: no goals

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 (i.castLT ⋯)) (if x : p (last n) then some (last n) else none) fun i =>
      some (i.castLT ⋯)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
k : Fin n
h : (find fun i => p (i.castLT ⋯)) = some k
⊢ False
state_after: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
k : Fin n
hi : i ∈ Option.casesOn (some k) (if x : p (last n) then some (last n) else none) fun i => some (i.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = 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 : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
k : Fin n
hi : i ∈ Option.casesOn (some k) (if x : p (last n) then some (last n) else none) fun i => some (i.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some k
⊢ False
state_after: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
i : Fin (n + 1)
j : ℕ
hjn : j < n + 1
hj : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
k : Fin n
hi : i ∈ some (k.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = 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 : ⟨j, hjn⟩ < i
hpj : p ⟨j, hjn⟩
k : Fin n
hi : i ∈ some (k.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some k
⊢ False
state_after: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
x✝ : DecidablePred p
j : ℕ
hjn : j < n + 1
hpj : p ⟨j, hjn⟩
k : Fin n
h : (find fun i => p (i.castLT ⋯)) = some k
hj : ⟨j, hjn⟩ < k.castLT ⋯
hi : k.castLT ⋯ ∈ some (k.castLT ⋯)
⊢ 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 ⟨j, hjn⟩
k : Fin n
h : (find fun i => p (i.castLT ⋯)) = some k
hj : ⟨j, hjn⟩ < k.castLT ⋯
hi : k.castLT ⋯ ∈ some (k.castLT ⋯)
⊢ False
state_after: no goals