Module: Mathlib.Computability.PartrecCode

Goal state before:
pp: case comp
k k₂ : ℕ
hl : k + 1 ≤ k₂ + 1
hl' : k ≤ k₂
this :
  ∀ {k k₂ n x : ℕ} {o₁ o₂ : Option ℕ},
    k ≤ k₂ →
      (x ∈ o₁ → x ∈ o₂) →
        (x ∈ do
            guard (n ≤ k)
            o₁) →
          x ∈ do
            guard (n ≤ k₂)
            o₂
a✝¹ a✝ : Code
a_ih✝¹ : ∀ (n x : ℕ), evaln (k + 1) a✝¹ n = some x → evaln (k₂ + 1) a✝¹ n = some x
a_ih✝ : ∀ (n x : ℕ), evaln (k + 1) a✝ n = some x → evaln (k₂ + 1) a✝ n = some x
n x : ℕ
h✝ :
  (fun n ↦ do
        guard (n ≤ k)
        let x ← evaln (k + 1) a✝ n
        evaln (k + 1) a✝¹ x)
      n =
    some x
h :
  x ∈ do
    let x ← evaln (k + 1) a✝ n
    evaln (k + 1) a✝¹ x
⊢ x ∈ do
    let x ← evaln (k₂ + 1) a✝ n
    evaln (k₂ + 1) a✝¹ x

pp: case prec
k k₂ : ℕ
hl : k + 1 ≤ k₂ + 1
hl' : k ≤ k₂
this :
  ∀ {k k₂ n x : ℕ} {o₁ o₂ : Option ℕ},
    k ≤ k₂ →
      (x ∈ o₁ → x ∈ o₂) →
        (x ∈ do
            guard (n ≤ k)
            o₁) →
          x ∈ do
            guard (n ≤ k₂)
            o₂
a✝¹ a✝ : Code
a_ih✝¹ : ∀ (n x : ℕ), evaln (k + 1) a✝¹ n = some x → evaln (k₂ + 1) a✝¹ n = some x
a_ih✝ : ∀ (n x : ℕ), evaln (k + 1) a✝ n = some x → evaln (k₂ + 1) a✝ n = some x
n x : ℕ
h✝ :
  (fun n ↦ do
        guard (n ≤ k)
        unpaired
            (fun a n ↦
              Nat.casesOn n (evaln (k + 1) a✝¹ a) fun y ↦ do
                let i ← evaln k (a✝¹.prec a✝) (Nat.pair a y)
                evaln (k + 1) a✝ (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n ↦
        Nat.casesOn n (evaln (k + 1) a✝¹ a) fun y ↦ do
          let i ← evaln k (a✝¹.prec a✝) (Nat.pair a y)
          evaln (k + 1) a✝ (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n ↦
        Nat.casesOn n (evaln (k₂ + 1) a✝¹ a) fun y ↦ do
          let i ← evaln k₂ (a✝¹.prec a✝) (Nat.pair a y)
          evaln (k₂ + 1) a✝ (Nat.pair a (Nat.pair y i)))
      n

pp: case rfind'
k k₂ : ℕ
hl : k + 1 ≤ k₂ + 1
hl' : k ≤ k₂
this :
  ∀ {k k₂ n x : ℕ} {o₁ o₂ : Option ℕ},
    k ≤ k₂ →
      (x ∈ o₁ → x ∈ o₂) →
        (x ∈ do
            guard (n ≤ k)
            o₁) →
          x ∈ do
            guard (n ≤ k₂)
            o₂
a✝ : Code
a_ih✝ : ∀ (n x : ℕ), evaln (k + 1) a✝ n = some x → evaln (k₂ + 1) a✝ n = some x
n x : ℕ
h✝ :
  (fun n ↦ do
        guard (n ≤ k)
        unpaired
            (fun a m ↦ do
              let x ← evaln (k + 1) a✝ (Nat.pair a m)
              if x = 0 then pure m else evaln k a✝.rfind' (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m ↦ do
        let x ← evaln (k + 1) a✝ (Nat.pair a m)
        if x = 0 then pure m else evaln k a✝.rfind' (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m ↦ do
        let x ← evaln (k₂ + 1) a✝ (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ a✝.rfind' (Nat.pair a (m + 1)))
      n

Tactic:
case comp cf cg hf hg _ =>
      simp? [Bind.bind, Option.bind_eq_some_iff] at h ⊢ says
        simp only [bind, Option.mem_def, Option.bind_eq_some_iff] at h ⊢
      exact h.imp fun a => And.imp (hg _ _) (hf _ _)

Goal state after:
case prec
k k₂ : ℕ
hl : k + 1 ≤ k₂ + 1
hl' : k ≤ k₂
this :
  ∀ {k k₂ n x : ℕ} {o₁ o₂ : Option ℕ},
    k ≤ k₂ →
      (x ∈ o₁ → x ∈ o₂) →
        (x ∈ do
            guard (n ≤ k)
            o₁) →
          x ∈ do
            guard (n ≤ k₂)
            o₂
a✝¹ a✝ : Code
a_ih✝¹ : ∀ (n x : ℕ), evaln (k + 1) a✝¹ n = some x → evaln (k₂ + 1) a✝¹ n = some x
a_ih✝ : ∀ (n x : ℕ), evaln (k + 1) a✝ n = some x → evaln (k₂ + 1) a✝ n = some x
n x : ℕ
h✝ :
  (fun n ↦ do
        guard (n ≤ k)
        unpaired
            (fun a n ↦
              Nat.casesOn n (evaln (k + 1) a✝¹ a) fun y ↦ do
                let i ← evaln k (a✝¹.prec a✝) (Nat.pair a y)
                evaln (k + 1) a✝ (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n ↦
        Nat.casesOn n (evaln (k + 1) a✝¹ a) fun y ↦ do
          let i ← evaln k (a✝¹.prec a✝) (Nat.pair a y)
          evaln (k + 1) a✝ (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n ↦
        Nat.casesOn n (evaln (k₂ + 1) a✝¹ a) fun y ↦ do
          let i ← evaln k₂ (a✝¹.prec a✝) (Nat.pair a y)
          evaln (k₂ + 1) a✝ (Nat.pair a (Nat.pair y i)))
      n

case rfind'
k k₂ : ℕ
hl : k + 1 ≤ k₂ + 1
hl' : k ≤ k₂
this :
  ∀ {k k₂ n x : ℕ} {o₁ o₂ : Option ℕ},
    k ≤ k₂ →
      (x ∈ o₁ → x ∈ o₂) →
        (x ∈ do
            guard (n ≤ k)
            o₁) →
          x ∈ do
            guard (n ≤ k₂)
            o₂
a✝ : Code
a_ih✝ : ∀ (n x : ℕ), evaln (k + 1) a✝ n = some x → evaln (k₂ + 1) a✝ n = some x
n x : ℕ
h✝ :
  (fun n ↦ do
        guard (n ≤ k)
        unpaired
            (fun a m ↦ do
              let x ← evaln (k + 1) a✝ (Nat.pair a m)
              if x = 0 then pure m else evaln k a✝.rfind' (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m ↦ do
        let x ← evaln (k + 1) a✝ (Nat.pair a m)
        if x = 0 then pure m else evaln k a✝.rfind' (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m ↦ do
        let x ← evaln (k₂ + 1) a✝ (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ a✝.rfind' (Nat.pair a (m + 1)))
      n