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

tactic: rw [find] at hi
state_before: m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
hi : i ∈ find p
⊢ p i
state_after: m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : 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 ⋯)
⊢ p i

tactic: cases' h : find fun i : Fin n ↦ p (i.castLT (Nat.lt_succ_of_lt i.2)) with j
state_before: m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : 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 ⋯)
⊢ p i
state_after: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : 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 ⋯)
h : (find fun i => p (i.castLT ⋯)) = none
⊢ p i

case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : 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 : Fin n
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p i

tactic: rw [h] at hi
state_before: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : 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 ⋯)
h : (find fun i => p (i.castLT ⋯)) = none
⊢ p i
state_after: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
hi : i ∈ Option.casesOn none (if x : p (last n) then some (last n) else none) fun i => some (i.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = none
⊢ p i

tactic: dsimp at hi
state_before: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
hi : i ∈ Option.casesOn none (if x : p (last n) then some (last n) else none) fun i => some (i.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = none
⊢ p i
state_after: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
hi : i ∈ if p (last n) then some (last n) else none
h : (find fun i => p (i.castLT ⋯)) = none
⊢ p i

tactic: split_ifs at hi with hl
state_before: case none
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
hi : i ∈ if p (last n) then some (last n) else none
h : (find fun i => p (i.castLT ⋯)) = none
⊢ p i
state_after: case pos
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hi : i ∈ some (last n)
⊢ p i

case neg
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
h : (find fun i => p (i.castLT ⋯)) = none
hl : ¬p (last n)
hi : i ∈ none
⊢ p i

tactic: simp only [Option.mem_def, Option.some.injEq] at hi
state_before: case pos
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hi : i ∈ some (last n)
⊢ p i
state_after: case pos
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hi : last n = i
⊢ p i

tactic: exact hi ▸ hl
state_before: case pos
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
h : (find fun i => p (i.castLT ⋯)) = none
hl : p (last n)
hi : last n = i
⊢ p i
state_after: no goals

tactic: exact (Option.not_mem_none _ hi).elim
state_before: case neg
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
h : (find fun i => p (i.castLT ⋯)) = none
hl : ¬p (last n)
hi : i ∈ none
⊢ p i
state_after: no goals

tactic: rw [h] at hi
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : 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 : Fin n
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p i
state_after: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
j : Fin n
hi : i ∈ Option.casesOn (some j) (if x : p (last n) then some (last n) else none) fun i => some (i.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p i

tactic: dsimp at hi
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
j : Fin n
hi : i ∈ Option.casesOn (some j) (if x : p (last n) then some (last n) else none) fun i => some (i.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p i
state_after: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
j : Fin n
hi : i ∈ some (j.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p i

tactic: rw [← Option.some_inj.1 hi]
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
j : Fin n
hi : i ∈ some (j.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p i
state_after: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
j : Fin n
hi : i ∈ some (j.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p (j.castLT ⋯)

tactic: exact @find_spec n (fun i ↦ p (i.castLT (Nat.lt_succ_of_lt i.2))) _ _ h
state_before: case some
m n✝ n : ℕ
p : Fin (n + 1) → Prop
I : DecidablePred p
i : Fin (n + 1)
j : Fin n
hi : i ∈ some (j.castLT ⋯)
h : (find fun i => p (i.castLT ⋯)) = some j
⊢ p (j.castLT ⋯)
state_after: no goals