/-- Recursion on `Nat.Partrec.Code` is computable. -/
theorem rec_computable {α σ} [Primcodable α] [Primcodable σ] {c : α → Code} (hc : Computable c)
    {z : α → σ} (hz : Computable z) {s : α → σ} (hs : Computable s) {l : α → σ} (hl : Computable l)
    {r : α → σ} (hr : Computable r) {pr : α → Code × Code × σ × σ → σ} (hpr : Computable₂ pr)
    {co : α → Code × Code × σ × σ → σ} (hco : Computable₂ co) {pc : α → Code × Code × σ × σ → σ}
    (hpc : Computable₂ pc) {rf : α → Code × σ → σ} (hrf : Computable₂ rf) :
    let PR (a) cf cg hf hg := pr a (cf, cg, hf, hg)
    let CO (a) cf cg hf hg := co a (cf, cg, hf, hg)
    let PC (a) cf cg hf hg := pc a (cf, cg, hf, hg)
    let RF (a) cf hf := rf a (cf, hf)
    let F (a : α) (c : Code) : σ :=
      Nat.Partrec.Code.recOn c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a)
    Computable fun a => F a (c a) := by
  -- TODO(Mario): less copy-paste from previous proof
  intros _ _ _ _ F
  let G₁ : (α × List σ) × ℕ × ℕ → Option σ := fun p =>
    let a := p.1.1
    let IH := p.1.2
    let n := p.2.1
    let m := p.2.2
    (IH.get? m).bind fun s =>
      (IH.get? m.unpair.1).bind fun s₁ =>
        (IH.get? m.unpair.2).map fun s₂ =>
          cond n.bodd
            (cond n.div2.bodd (rf a (ofNat Code m, s))
              (pc a (ofNat Code m.unpair.1, ofNat Code m.unpair.2, s₁, s₂)))
            (cond n.div2.bodd (co a (ofNat Code m.unpair.1, ofNat Code m.unpair.2, s₁, s₂))
              (pr a (ofNat Code m.unpair.1, ofNat Code m.unpair.2, s₁, s₂)))
  have : Computable G₁ := by
    refine' option_bind (list_get?.comp (snd.comp fst) (snd.comp snd)) _
    unfold Computable₂
    refine'
      option_bind
        ((list_get?.comp (snd.comp fst)
          (fst.comp <| Computable.unpair.comp (snd.comp snd))).comp fst) _
    unfold Computable₂
    refine'
      option_map
        ((list_get?.comp (snd.comp fst)
          (snd.comp <| Computable.unpair.comp (snd.comp snd))).comp <| fst.comp fst) _
    have a : Computable (fun p : ((((α × List σ) × ℕ × ℕ) × σ) × σ) × σ => p.1.1.1.1.1) :=
      fst.comp (fst.comp <| fst.comp <| fst.comp fst)
    have n : Computable (fun p : ((((α × List σ) × ℕ × ℕ) × σ) × σ) × σ => p.1.1.1.2.1) :=
      fst.comp (snd.comp <| fst.comp <| fst.comp fst)
    have m : Computable (fun p : ((((α × List σ) × ℕ × ℕ) × σ) × σ) × σ => p.1.1.1.2.2) :=
      snd.comp (snd.comp <| fst.comp <| fst.comp fst)
    have m₁ := fst.comp (Computable.unpair.comp m)
    have m₂ := snd.comp (Computable.unpair.comp m)
    have s : Computable (fun p : ((((α × List σ) × ℕ × ℕ) × σ) × σ) × σ => p.1.1.2) :=
      snd.comp (fst.comp fst)
    have s₁ : Computable (fun p : ((((α × List σ) × ℕ × ℕ) × σ) × σ) × σ => p.1.2) :=
      snd.comp fst
    have s₂ : Computable (fun p : ((((α × List σ) × ℕ × ℕ) × σ) × σ) × σ => p.2) :=
      snd
    

Proof state:
α : Type u_1
σ : Type u_2
inst✝¹ : Primcodable α
inst✝ : Primcodable σ
c : α → Code
hc : Computable c
z : α → σ
hz : Computable z
s✝ : α → σ
hs : Computable s✝
l : α → σ
hl : Computable l
r : α → σ
hr : Computable r
pr : α → Code × Code × σ × σ → σ
hpr : Computable₂ pr
co : α → Code × Code × σ × σ → σ
hco : Computable₂ co
pc : α → Code × Code × σ × σ → σ
hpc : Computable₂ pc
rf : α → Code × σ → σ
hrf : Computable₂ rf
PR✝ : α → Code → Code → σ → σ → σ := fun a cf cg hf hg => pr a (cf, cg, hf, hg)
CO✝ : α → Code → Code → σ → σ → σ := fun a cf cg hf hg => co a (cf, cg, hf, hg)
PC✝ : α → Code → Code → σ → σ → σ := fun a cf cg hf hg => pc a (cf, cg, hf, hg)
RF✝ : α → Code → σ → σ := fun a cf hf => rf a (cf, hf)
F : α → Code → σ := fun a c => Code.recOn c (z a) (s✝ a) (l a) (r a) (PR✝ a) (CO✝ a) (PC✝ a) (RF✝ a)
G₁ : (α × List σ) × ℕ × ℕ → Option σ :=
  fun p =>
    let a := p.1.1;
    let IH := p.1.2;
    let n := p.2.1;
    let m := p.2.2;
    Option.bind (List.get? IH m) fun s =>
      Option.bind (List.get? IH (unpair m).1) fun s₁ =>
        Option.map
          (fun s₂ =>
            bif bodd n then
              bif bodd (div2 n) then rf a (ofNat Code m, s)
              else pc a (ofNat Code (unpair m).1, ofNat Code (unpair m).2, s₁, s₂)
            else
              bif bodd (div2 n) then co a (ofNat Code (unpair m).1, ofNat Code (unpair m).2, s₁, s₂)
              else pr a (ofNat Code (unpair m).1, ofNat Code (unpair m).2, s₁, s₂))
          (List.get? IH (unpair m).2)
a : Computable fun p => p.1.1.1.1.1
n : Computable fun p => p.1.1.1.2.1
m : Computable fun p => p.1.1.1.2.2
m₁ : Computable fun a => (unpair a.1.1.1.2.2).1
m₂ : Computable fun a => (unpair a.1.1.1.2.2).2
s : Computable fun p => p.1.1.2
s₁ : Computable fun p => p.1.2
s₂ : Computable fun p => p.2
⊢ Computable₂ fun p s₂ =>
    bif bodd p.1.1.2.1 then
      bif bodd (div2 p.1.1.2.1) then rf p.1.1.1.1 (ofNat Code p.1.1.2.2, p.1.2)
      else pc p.1.1.1.1 (ofNat Code (unpair p.1.1.2.2).1, ofNat Code (unpair p.1.1.2.2).2, p.2, s₂)
    else
      bif bodd (div2 p.1.1.2.1) then
        co p.1.1.1.1 (ofNat Code (unpair p.1.1.2.2).1, ofNat Code (unpair p.1.1.2.2).2, p.2, s₂)
      else pr p.1.1.1.1 (ofNat Code (unpair p.1.1.2.2).1, ofNat Code (unpair p.1.1.2.2).2, p.2, s₂)

Next tactic:
exact
      (nat_bodd.comp n).cond
        ((nat_bodd.comp <| nat_div2.comp n).cond
          (hrf.comp a (((Computable.ofNat Code).comp m).pair s))
          (hpc.comp a
            (((Computable.ofNat Code).comp m₁).pair <|
              ((Computable.ofNat Code).comp m₂).pair <| s₁.pair s₂)))
        (Computable.cond (nat_bodd.comp <| nat_div2.comp n)
          (hco.comp a
            (((Computable.ofNat Code).comp m₁).pair <|
              ((Computable.ofNat Code).comp m₂).pair <| s₁.pair s₂))
          (hpr.comp a
            (((Computable.ofNat Code).comp m₁).pair <|
              ((Computable.ofNat Code).comp m₂).pair <| s₁.pair s₂)))