no goals
k₂ : ℕ
c : Code
n x : ℕ
x✝ : 0 ≤ k₂
h : x ∈ evaln 0 c n
⊢ x ∈ evaln k₂ c n
simp [evaln] at h
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
hl' : k ≤ k₂
⊢ x ∈ evaln (k₂ + 1) c n
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
⊢ x ∈ evaln (k₂ + 1) c n
have hl' := Nat.le_of_succ_le_succ hl
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
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₂
⊢ x ∈ evaln (k₂ + 1) c n
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
hl' : k ≤ k₂
⊢ x ∈ evaln (k₂ + 1) c n
have :
  ∀ {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₂ } := by
  simp [Bind.bind]
  introv h h₁ h₂ h₃
  exact ⟨le_trans h₂ h, h₁ h₃⟩
k k₂ : ℕ
c : Code
n x : ℕ
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₂
h : evaln (k + 1) c n = some x
⊢ evaln (k₂ + 1) c n = some x
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
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₂
⊢ x ∈ evaln (k₂ + 1) c n
simp at h ⊢
case zero
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure 0)
      n =
    some x
h : x ∈ pure 0
⊢ x ∈ pure 0

case succ
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure (Nat.succ n))
      n =
    some x
h : x ∈ pure (Nat.succ n)
⊢ x ∈ pure (Nat.succ n)

case left
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure (unpair n).fst)
      n =
    some x
h : x ∈ pure (unpair n).fst
⊢ x ∈ pure (unpair n).fst

case right
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure (unpair n).snd)
      n =
    some x
h : x ∈ pure (unpair n).snd
⊢ x ∈ pure (unpair n).snd

case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : x ∈ Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n
⊢ x ∈ Seq.seq (Nat.pair <$> evaln (k₂ + 1) cf n) fun x => evaln (k₂ + 1) cg n

case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h :
  x ∈ do
    let x ← evaln (k + 1) cg n
    evaln (k + 1) cf x
⊢ x ∈ do
    let x ← evaln (k₂ + 1) cg n
    evaln (k₂ + 1) cf x

case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k + 1) cf a) fun y => do
          let i ← evaln k (prec cf cg) (Nat.pair a y)
          evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
          let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
          evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
      n

case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k₂ + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ (rfind' cf) (Nat.pair a (m + 1)))
      n
k k₂ : ℕ
c : Code
n x : ℕ
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₂
h : evaln (k + 1) c n = some x
⊢ evaln (k₂ + 1) c n = some x
induction' c with cf cg hf hg cf cg hf hg cf cg hf hg cf hf generalizing x n <;>
  rw [evaln] at h ⊢ <;> refine' this hl' (fun h => _) h
case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : x ∈ Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n
⊢ x ∈ Seq.seq (Nat.pair <$> evaln (k₂ + 1) cf n) fun x => evaln (k₂ + 1) cg n

case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h :
  x ∈ do
    let x ← evaln (k + 1) cg n
    evaln (k + 1) cf x
⊢ x ∈ do
    let x ← evaln (k₂ + 1) cg n
    evaln (k₂ + 1) cf x

case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k + 1) cf a) fun y => do
          let i ← evaln k (prec cf cg) (Nat.pair a y)
          evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
          let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
          evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
      n

case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k₂ + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ (rfind' cf) (Nat.pair a (m + 1)))
      n
case zero
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure 0)
      n =
    some x
h : x ∈ pure 0
⊢ x ∈ pure 0

case succ
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure (Nat.succ n))
      n =
    some x
h : x ∈ pure (Nat.succ n)
⊢ x ∈ pure (Nat.succ n)

case left
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure (unpair n).fst)
      n =
    some x
h : x ∈ pure (unpair n).fst
⊢ x ∈ pure (unpair n).fst

case right
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure (unpair n).snd)
      n =
    some x
h : x ∈ pure (unpair n).snd
⊢ x ∈ pure (unpair n).snd

case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : x ∈ Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n
⊢ x ∈ Seq.seq (Nat.pair <$> evaln (k₂ + 1) cf n) fun x => evaln (k₂ + 1) cg n

case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h :
  x ∈ do
    let x ← evaln (k + 1) cg n
    evaln (k + 1) cf x
⊢ x ∈ do
    let x ← evaln (k₂ + 1) cg n
    evaln (k₂ + 1) cf x

case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k + 1) cf a) fun y => do
          let i ← evaln k (prec cf cg) (Nat.pair a y)
          evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
          let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
          evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
      n

case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k₂ + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ (rfind' cf) (Nat.pair a (m + 1)))
      n
iterate 4 exact h
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
hl' : k ≤ k₂
⊢ ∀ {k k₂ n x : ℕ} {o₁ o₂ : Option ℕ}, k ≤ k₂ → (o₁ = some x → o₂ = some x) → n ≤ k → o₁ = some x → n ≤ k₂ ∧ o₂ = some x
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
hl' : k ≤ k₂
⊢ ∀ {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₂
simp [Bind.bind]
k✝ k₂✝ : ℕ
c : Code
n✝ x✝ : ℕ
hl : k✝ + 1 ≤ k₂✝ + 1
h✝ : x✝ ∈ evaln (k✝ + 1) c n✝
hl' : k✝ ≤ k₂✝
k k₂ n x : ℕ
o₁ o₂ : Option ℕ
h : k ≤ k₂
h₁ : o₁ = some x → o₂ = some x
h₂ : n ≤ k
h₃ : o₁ = some x
⊢ n ≤ k₂ ∧ o₂ = some x
k k₂ : ℕ
c : Code
n x : ℕ
hl : k + 1 ≤ k₂ + 1
h : x ∈ evaln (k + 1) c n
hl' : k ≤ k₂
⊢ ∀ {k k₂ n x : ℕ} {o₁ o₂ : Option ℕ}, k ≤ k₂ → (o₁ = some x → o₂ = some x) → n ≤ k → o₁ = some x → n ≤ k₂ ∧ o₂ = some x
introv h h₁ h₂ h₃
no goals
k✝ k₂✝ : ℕ
c : Code
n✝ x✝ : ℕ
hl : k✝ + 1 ≤ k₂✝ + 1
h✝ : x✝ ∈ evaln (k✝ + 1) c n✝
hl' : k✝ ≤ k₂✝
k k₂ n x : ℕ
o₁ o₂ : Option ℕ
h : k ≤ k₂
h₁ : o₁ = some x → o₂ = some x
h₂ : n ≤ k
h₃ : o₁ = some x
⊢ n ≤ k₂ ∧ o₂ = some x
exact ⟨le_trans h₂ h, h₁ h₃⟩
case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : x ∈ Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n
⊢ x ∈ Seq.seq (Nat.pair <$> evaln (k₂ + 1) cf n) fun x => evaln (k₂ + 1) cg n

case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h :
  x ∈ do
    let x ← evaln (k + 1) cg n
    evaln (k + 1) cf x
⊢ x ∈ do
    let x ← evaln (k₂ + 1) cg n
    evaln (k₂ + 1) cf x

case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k + 1) cf a) fun y => do
          let i ← evaln k (prec cf cg) (Nat.pair a y)
          evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
          let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
          evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
      n

case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k₂ + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ (rfind' cf) (Nat.pair a (m + 1)))
      n
case right
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        pure (unpair n).snd)
      n =
    some x
h : x ∈ pure (unpair n).snd
⊢ x ∈ pure (unpair n).snd

case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : x ∈ Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n
⊢ x ∈ Seq.seq (Nat.pair <$> evaln (k₂ + 1) cf n) fun x => evaln (k₂ + 1) cg n

case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h :
  x ∈ do
    let x ← evaln (k + 1) cg n
    evaln (k + 1) cf x
⊢ x ∈ do
    let x ← evaln (k₂ + 1) cg n
    evaln (k₂ + 1) cf x

case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k + 1) cf a) fun y => do
          let i ← evaln k (prec cf cg) (Nat.pair a y)
          evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
          let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
          evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
      n

case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k₂ + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ (rfind' cf) (Nat.pair a (m + 1)))
      n
exact h
case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : ∃ a, evaln (k + 1) cf n = some a ∧ ∃ a_1, evaln (k + 1) cg n = some a_1 ∧ Nat.pair a a_1 = x
⊢ ∃ a, evaln (k₂ + 1) cf n = some a ∧ ∃ a_1, evaln (k₂ + 1) cg n = some a_1 ∧ Nat.pair a a_1 = x
case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : x ∈ Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n
⊢ x ∈ Seq.seq (Nat.pair <$> evaln (k₂ + 1) cf n) fun x => evaln (k₂ + 1) cg n
simp [Seq.seq] at h ⊢
no goals
case pair
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        Seq.seq (Nat.pair <$> evaln (k + 1) cf n) fun x => evaln (k + 1) cg n)
      n =
    some x
h : ∃ a, evaln (k + 1) cf n = some a ∧ ∃ a_1, evaln (k + 1) cg n = some a_1 ∧ Nat.pair a a_1 = x
⊢ ∃ a, evaln (k₂ + 1) cf n = some a ∧ ∃ a_1, evaln (k₂ + 1) cg n = some a_1 ∧ Nat.pair a a_1 = x
exact h.imp fun a => And.imp (hf _ _) <| Exists.imp fun b => And.imp_left (hg _ _)
case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h : ∃ a, evaln (k + 1) cg n = some a ∧ evaln (k + 1) cf a = some x
⊢ ∃ a, evaln (k₂ + 1) cg n = some a ∧ evaln (k₂ + 1) cf a = some x
case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h :
  x ∈ do
    let x ← evaln (k + 1) cg n
    evaln (k + 1) cf x
⊢ x ∈ do
    let x ← evaln (k₂ + 1) cg n
    evaln (k₂ + 1) cf x
simp [Bind.bind] at h ⊢
no goals
case comp
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        let x ← evaln (k + 1) cg n
        evaln (k + 1) cf x)
      n =
    some x
h : ∃ a, evaln (k + 1) cg n = some a ∧ evaln (k + 1) cf a = some x
⊢ ∃ a, evaln (k₂ + 1) cg n = some a ∧ evaln (k₂ + 1) cf a = some x
exact h.imp fun a => And.imp (hg _ _) (hf _ _)
case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
⊢ x ∈
      unpaired
        (fun a n =>
          Nat.casesOn n (evaln (k + 1) cf a) fun y => do
            let i ← evaln k (prec cf cg) (Nat.pair a y)
            evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
        n →
    x ∈
      unpaired
        (fun a n =>
          Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
            let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
            evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
        n
case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k + 1) cf a) fun y => do
          let i ← evaln k (prec cf cg) (Nat.pair a y)
          evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
      n
⊢ x ∈
    unpaired
      (fun a n =>
        Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
          let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
          evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
      n
revert h
case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
⊢ Nat.rec (evaln (k + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        (unpair n).snd =
      some x →
    Nat.rec (evaln (k₂ + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k₂ (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k₂ + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        (unpair n).snd =
      some x
case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
⊢ x ∈
      unpaired
        (fun a n =>
          Nat.casesOn n (evaln (k + 1) cf a) fun y => do
            let i ← evaln k (prec cf cg) (Nat.pair a y)
            evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
        n →
    x ∈
      unpaired
        (fun a n =>
          Nat.casesOn n (evaln (k₂ + 1) cf a) fun y => do
            let i ← evaln k₂ (prec cf cg) (Nat.pair a y)
            evaln (k₂ + 1) cg (Nat.pair a (Nat.pair y i)))
        n
simp [Bind.bind]
case prec.zero
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
⊢ evaln (k + 1) cf (unpair n).fst = some x → evaln (k₂ + 1) cf (unpair n).fst = some x

case prec.succ
k k₂ : ℕ
c : Code
n✝¹ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝¹ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
n✝ : ℕ
n_ih✝ :
  Nat.rec (evaln (k + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        n✝ =
      some x →
    Nat.rec (evaln (k₂ + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k₂ (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k₂ + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        n✝ =
      some x
⊢ ∀ (x_1 : ℕ),
    evaln k (prec cf cg) (Nat.pair (unpair n).fst n✝) = some x_1 →
      evaln (k + 1) cg (Nat.pair (unpair n).fst (Nat.pair n✝ x_1)) = some x →
        ∃ a,
          evaln k₂ (prec cf cg) (Nat.pair (unpair n).fst n✝) = some a ∧
            evaln (k₂ + 1) cg (Nat.pair (unpair n).fst (Nat.pair n✝ a)) = some x
case prec
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
⊢ Nat.rec (evaln (k + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        (unpair n).snd =
      some x →
    Nat.rec (evaln (k₂ + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k₂ (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k₂ + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        (unpair n).snd =
      some x
induction n.unpair.2 <;> simp
no goals
case prec.zero
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
⊢ evaln (k + 1) cf (unpair n).fst = some x → evaln (k₂ + 1) cf (unpair n).fst = some x
apply hf
no goals
case prec.succ
k k₂ : ℕ
c : Code
n✝¹ x✝ : ℕ
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₂
h✝ : evaln (k + 1) c n✝¹ = some x✝
cf cg : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
hg : ∀ (n x : ℕ), evaln (k + 1) cg n = some x → evaln (k₂ + 1) cg n = some x
n x : ℕ
h :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a n =>
              Nat.casesOn n (evaln (k + 1) cf a) fun y => do
                let i ← evaln k (prec cf cg) (Nat.pair a y)
                evaln (k + 1) cg (Nat.pair a (Nat.pair y i)))
            n)
      n =
    some x
n✝ : ℕ
n_ih✝ :
  Nat.rec (evaln (k + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        n✝ =
      some x →
    Nat.rec (evaln (k₂ + 1) cf (unpair n).fst)
        (fun n_1 n_ih =>
          Option.bind (evaln k₂ (prec cf cg) (Nat.pair (unpair n).fst n_1)) fun i =>
            evaln (k₂ + 1) cg (Nat.pair (unpair n).fst (Nat.pair n_1 i)))
        n✝ =
      some x
⊢ ∀ (x_1 : ℕ),
    evaln k (prec cf cg) (Nat.pair (unpair n).fst n✝) = some x_1 →
      evaln (k + 1) cg (Nat.pair (unpair n).fst (Nat.pair n✝ x_1)) = some x →
        ∃ a,
          evaln k₂ (prec cf cg) (Nat.pair (unpair n).fst n✝) = some a ∧
            evaln (k₂ + 1) cg (Nat.pair (unpair n).fst (Nat.pair n✝ a)) = some x
exact fun y h₁ h₂ => ⟨y, evaln_mono hl' h₁, hg _ _ h₂⟩
case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  ∃ a,
    evaln (k + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x
⊢ ∃ a,
    evaln (k₂ + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k₂ (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x
case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
      n
⊢ x ∈
    unpaired
      (fun a m => do
        let x ← evaln (k₂ + 1) cf (Nat.pair a m)
        if x = 0 then pure m else evaln k₂ (rfind' cf) (Nat.pair a (m + 1)))
      n
simp [Bind.bind] at h ⊢
case rfind'
k k₂ : ℕ
c : Code
n✝ x✝¹ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝¹
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x✝ : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x✝
h :
  ∃ a,
    evaln (k + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x✝
x : ℕ
⊢ (if x = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
      some x✝ →
    (if x = 0 then pure (unpair n).snd else evaln k₂ (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
      some x✝
case rfind'
k k₂ : ℕ
c : Code
n✝ x✝ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x
h :
  ∃ a,
    evaln (k + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x
⊢ ∃ a,
    evaln (k₂ + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k₂ (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x
refine' h.imp fun x => And.imp (hf _ _) _
case neg
k k₂ : ℕ
c : Code
n✝ x✝¹ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝¹
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x✝ : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x✝
h :
  ∃ a,
    evaln (k + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x✝
x : ℕ
x0 : ¬x = 0
⊢ evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1)) = some x✝ →
    evaln k₂ (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1)) = some x✝
case rfind'
k k₂ : ℕ
c : Code
n✝ x✝¹ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝¹
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x✝ : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x✝
h :
  ∃ a,
    evaln (k + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x✝
x : ℕ
⊢ (if x = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
      some x✝ →
    (if x = 0 then pure (unpair n).snd else evaln k₂ (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
      some x✝
by_cases x0 : x = 0 <;> simp [x0]
no goals
case neg
k k₂ : ℕ
c : Code
n✝ x✝¹ : ℕ
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₂
h✝¹ : evaln (k + 1) c n✝ = some x✝¹
cf : Code
hf : ∀ (n x : ℕ), evaln (k + 1) cf n = some x → evaln (k₂ + 1) cf n = some x
n x✝ : ℕ
h✝ :
  (fun n => do
        guard (n ≤ k)
        unpaired
            (fun a m => do
              let x ← evaln (k + 1) cf (Nat.pair a m)
              if x = 0 then pure m else evaln k (rfind' cf) (Nat.pair a (m + 1)))
            n)
      n =
    some x✝
h :
  ∃ a,
    evaln (k + 1) cf n = some a ∧
      (if a = 0 then pure (unpair n).snd else evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1))) =
        some x✝
x : ℕ
x0 : ¬x = 0
⊢ evaln k (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1)) = some x✝ →
    evaln k₂ (rfind' cf) (Nat.pair (unpair n).fst ((unpair n).snd + 1)) = some x✝
exact evaln_mono hl'