Theorem: Nat.rfindOpt_dom
File: Mathlib/Computability/Partrec.lean

tactic: have h' : ∃ n, (f n).isSome := h.imp fun n => Option.isSome_iff_exists.2
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
⊢ (rfindOpt f).Dom

tactic: have s := Nat.find_spec h'
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
⊢ (rfindOpt f).Dom

tactic: have fd : (rfind fun n => (f n).isSome).Dom :=
  ⟨Nat.find h', by simpa using s.symm, fun _ _ => trivial⟩
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
⊢ (rfindOpt f).Dom

tactic: refine' ⟨fd, _⟩
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
fd : (rfind fun n => ↑(Option.some (Option.isSome (f n)))).Dom
⊢ (rfindOpt f).Dom

tactic: have := rfind_spec (get_mem fd)
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
fd : (rfind fun n => ↑(Option.some (Option.isSome (f n)))).Dom
⊢ ((fun b => (fun n => ↑(f n)) (Part.get (rfind fun n => ↑(Option.some (Option.isSome (f n)))) b)) fd).Dom

tactic: simp at this⊢
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
fd : (rfind fun n => ↑(Option.some (Option.isSome (f n)))).Dom
this : true ∈ ↑(Option.some (Option.isSome (f (Part.get (rfind fun n => ↑(Option.some (Option.isSome (f n)))) fd))))
⊢ ((fun b => (fun n => ↑(f n)) (Part.get (rfind fun n => ↑(Option.some (Option.isSome (f n)))) b)) fd).Dom

tactic: cases' Option.isSome_iff_exists.1 this.symm with a e
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
fd : (rfind fun n => ↑(Option.some (Option.isSome (f n)))).Dom
this :
  true =
    Option.isSome
      (f
        (Part.get (rfind fun n => Part.some (Option.isSome (f n)))
          (_ : (rfind fun n => Part.some (Option.isSome (f n))).Dom)))
⊢ Option.isSome
      (f
        (Part.get (rfind fun n => Part.some (Option.isSome (f n)))
          (_ : (rfind fun n => Part.some (Option.isSome (f n))).Dom))) =
    true

tactic: rw [e]
state_before: case intro
α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
fd : (rfind fun n => ↑(Option.some (Option.isSome (f n)))).Dom
this :
  true =
    Option.isSome
      (f
        (Part.get (rfind fun n => Part.some (Option.isSome (f n)))
          (_ : (rfind fun n => Part.some (Option.isSome (f n))).Dom)))
a : α
e :
  f
      (Part.get (rfind fun n => Part.some (Option.isSome (f n)))
        (_ : (rfind fun n => Part.some (Option.isSome (f n))).Dom)) =
    Option.some a
⊢ Option.isSome
      (f
        (Part.get (rfind fun n => Part.some (Option.isSome (f n)))
          (_ : (rfind fun n => Part.some (Option.isSome (f n))).Dom))) =
    true

tactic: trivial
state_before: case intro
α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
fd : (rfind fun n => ↑(Option.some (Option.isSome (f n)))).Dom
this :
  true =
    Option.isSome
      (f
        (Part.get (rfind fun n => Part.some (Option.isSome (f n)))
          (_ : (rfind fun n => Part.some (Option.isSome (f n))).Dom)))
a : α
e :
  f
      (Part.get (rfind fun n => Part.some (Option.isSome (f n)))
        (_ : (rfind fun n => Part.some (Option.isSome (f n))).Dom)) =
    Option.some a
⊢ Option.isSome (Option.some a) = true

tactic: simpa using s.symm
state_before: α : Type u_1
f : ℕ → Option α
h : ∃ n a, a ∈ f n
h' : ∃ n, Option.isSome (f n) = true
s : Option.isSome (f (Nat.find h')) = true
⊢ true ∈ (fun n => ↑(Option.some (Option.isSome (f n)))) (Nat.find h')