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

tactic: cases n <;> simp
state_before: this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n : ℕ
⊢ (Nat.rfind fun n_1 =>
      (fun m => decide (m = 0)) <$> ↑(unpaired fun n m => if n = m.succ then 0 else 1) (Nat.pair n n_1)) =
    ↑n.ppred
state_after: case zero
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
⊢ (Nat.rfind fun n => Part.some false) = Part.none

case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ : ℕ
⊢ (Nat.rfind fun n => Part.some (decide (n✝ = n))) = Part.some n✝

tactic: exact
  eq_none_iff.2 fun a ⟨⟨m, h, _⟩, _⟩ => by
    simp [show 0 ≠ m.succ by intro h; injection h] at h
state_before: case zero
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
⊢ (Nat.rfind fun n => Part.some false) = Part.none
state_after: no goals

tactic: simp [show 0 ≠ m.succ by intro h; injection h] at h
state_before: this : Primrec₂ fun n m => if n = m.succ then 0 else 1
a : ℕ
x✝ : a ∈ Nat.rfind fun n => Part.some false
m : ℕ
h : true ∈ (fun n => Part.some false) m
right✝ : ∀ k < m, ((fun n => Part.some false) k).Dom
h✝ : (Nat.rfind fun n => Part.some false).get ⋯ = a
⊢ False
state_after: no goals

tactic: intro h
state_before: this : Primrec₂ fun n m => if n = m.succ then 0 else 1
a : ℕ
x✝ : a ∈ Nat.rfind fun n => Part.some false
m : ℕ
h : true ∈ (fun n => Part.some false) m
right✝ : ∀ k < m, ((fun n => Part.some false) k).Dom
h✝ : (Nat.rfind fun n => Part.some false).get ⋯ = a
⊢ 0 ≠ m.succ
state_after: this : Primrec₂ fun n m => if n = m.succ then 0 else 1
a : ℕ
x✝ : a ∈ Nat.rfind fun n => Part.some false
m : ℕ
h✝¹ : true ∈ (fun n => Part.some false) m
right✝ : ∀ k < m, ((fun n => Part.some false) k).Dom
h✝ : (Nat.rfind fun n => Part.some false).get ⋯ = a
h : 0 = m.succ
⊢ False

tactic: injection h
state_before: this : Primrec₂ fun n m => if n = m.succ then 0 else 1
a : ℕ
x✝ : a ∈ Nat.rfind fun n => Part.some false
m : ℕ
h✝¹ : true ∈ (fun n => Part.some false) m
right✝ : ∀ k < m, ((fun n => Part.some false) k).Dom
h✝ : (Nat.rfind fun n => Part.some false).get ⋯ = a
h : 0 = m.succ
⊢ False
state_after: no goals

tactic: refine eq_some_iff.2 ?_
state_before: case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ : ℕ
⊢ (Nat.rfind fun n => Part.some (decide (n✝ = n))) = Part.some n✝
state_after: case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ : ℕ
⊢ n✝ ∈ Nat.rfind fun n => Part.some (decide (n✝ = n))

tactic: simp only [mem_rfind, not_true, IsEmpty.forall_iff, decide_True, mem_some_iff,
  false_eq_decide_iff, true_and]
state_before: case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ : ℕ
⊢ n✝ ∈ Nat.rfind fun n => Part.some (decide (n✝ = n))
state_after: case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ : ℕ
⊢ ∀ {m : ℕ}, m < n✝ → ¬n✝ = m

tactic: intro m h
state_before: case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ : ℕ
⊢ ∀ {m : ℕ}, m < n✝ → ¬n✝ = m
state_after: case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ m : ℕ
h : m < n✝
⊢ ¬n✝ = m

tactic: simp [ne_of_gt h]
state_before: case succ
this : Primrec₂ fun n m => if n = m.succ then 0 else 1
n✝ m : ℕ
h : m < n✝
⊢ ¬n✝ = m
state_after: no goals