l3lab/ntp-mathlib huggingface dataset:
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  

Proof state:
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n : Primrec Prod.snd
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
⊢ Primrec fun p =>
    (fun p n =>
        (fun k' =>
            Code.recOn (ofNat (ℕ × Code) (List.length p.1)).2 (some 0) (some (Nat.succ p.2)) (some (unpair p.2).1)
              (some (unpair p.2).2)
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) p.2
                let y ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                some (Nat.pair x y))
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) x)
              (fun cf cg x x =>
                let z := (unpair p.2).1;
                Nat.casesOn (unpair p.2).2 (Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) z)
                  fun y => do
                  let i ← Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z y)
                  Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) (Nat.pair z (Nat.pair y i)))
              fun cf x =>
              let z := (unpair p.2).1;
              let m := (unpair p.2).2;
              do
              let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) (Nat.pair z m)
              Nat.casesOn x (some m) fun x =>
                  Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z (m + 1)))
          n)
      p.1 p.2

Next tactic:
have n := n.comp (Primrec.fst (β := ℕ))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  

Proof state:
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝ : Primrec Prod.snd
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n : Primrec fun a => a.1.2
⊢ Primrec fun p =>
    (fun p n =>
        (fun k' =>
            Code.recOn (ofNat (ℕ × Code) (List.length p.1)).2 (some 0) (some (Nat.succ p.2)) (some (unpair p.2).1)
              (some (unpair p.2).2)
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) p.2
                let y ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                some (Nat.pair x y))
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) x)
              (fun cf cg x x =>
                let z := (unpair p.2).1;
                Nat.casesOn (unpair p.2).2 (Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) z)
                  fun y => do
                  let i ← Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z y)
                  Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) (Nat.pair z (Nat.pair y i)))
              fun cf x =>
              let z := (unpair p.2).1;
              let m := (unpair p.2).2;
              do
              let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) (Nat.pair z m)
              Nat.casesOn x (some m) fun x =>
                  Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z (m + 1)))
          n)
      p.1 p.2

Next tactic:
have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  

Proof state:
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝ : Primrec Prod.snd
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n : Primrec fun a => a.1.2
k' : Primrec Prod.snd
⊢ Primrec fun p =>
    (fun p n =>
        (fun k' =>
            Code.recOn (ofNat (ℕ × Code) (List.length p.1)).2 (some 0) (some (Nat.succ p.2)) (some (unpair p.2).1)
              (some (unpair p.2).2)
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) p.2
                let y ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                some (Nat.pair x y))
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) x)
              (fun cf cg x x =>
                let z := (unpair p.2).1;
                Nat.casesOn (unpair p.2).2 (Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) z)
                  fun y => do
                  let i ← Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z y)
                  Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) (Nat.pair z (Nat.pair y i)))
              fun cf x =>
              let z := (unpair p.2).1;
              let m := (unpair p.2).2;
              do
              let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) (Nat.pair z m)
              Nat.casesOn x (some m) fun x =>
                  Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z (m + 1)))
          n)
      p.1 p.2

Next tactic:
have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
  

Proof state:
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝ : Primrec Prod.snd
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n : Primrec fun a => a.1.2
k' : Primrec Prod.snd
c : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).2
⊢ Primrec fun p =>
    (fun p n =>
        (fun k' =>
            Code.recOn (ofNat (ℕ × Code) (List.length p.1)).2 (some 0) (some (Nat.succ p.2)) (some (unpair p.2).1)
              (some (unpair p.2).2)
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) p.2
                let y ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                some (Nat.pair x y))
              (fun cf cg x x => do
                let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) p.2
                Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) x)
              (fun cf cg x x =>
                let z := (unpair p.2).1;
                Nat.casesOn (unpair p.2).2 (Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) z)
                  fun y => do
                  let i ← Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z y)
                  Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cg) (Nat.pair z (Nat.pair y i)))
              fun cf x =>
              let z := (unpair p.2).1;
              let m := (unpair p.2).2;
              do
              let x ← Nat.Partrec.Code.lup p.1 ((ofNat (ℕ × Code) (List.length p.1)).1, cf) (Nat.pair z m)
              Nat.casesOn x (some m) fun x =>
                  Nat.Partrec.Code.lup p.1 (k', (ofNat (ℕ × Code) (List.length p.1)).2) (Nat.pair z (m + 1)))
          n)
      p.1 p.2

Next tactic:
apply
    Nat.Partrec.Code.rec_prim c
      (_root_.Primrec.const (some 0))
      (Primrec.option_some.comp (_root_.Primrec.succ.comp n))
      (Primrec.option_some.comp (Primrec.fst.comp <| Primrec.unpair.comp n))
      (Primrec.option_some.comp (Primrec.snd.comp <| Primrec.unpair.comp n))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
  apply
    Nat.Partrec.Code.rec_prim c
      (_root_.Primrec.const (some 0))
      (Primrec.option_some.comp (_root_.Primrec.succ.comp n))
      (Primrec.option_some.comp (Primrec.fst.comp <| Primrec.unpair.comp n))
      (Primrec.option_some.comp (Primrec.snd.comp <| Primrec.unpair.comp n))
  · 

Proof state:
case hpr
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝ : Primrec Prod.snd
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n : Primrec fun a => a.1.2
k' : Primrec Prod.snd
c : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).2
⊢ Primrec fun a => do
    let x ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.1) a.1.1.2
    let y ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.2.1) a.1.1.2
    some (Nat.pair x y)

Next tactic:
have L := (Primrec.fst.comp Primrec.fst).comp
      (Primrec.fst (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
  apply
    Nat.Partrec.Code.rec_prim c
      (_root_.Primrec.const (some 0))
      (Primrec.option_some.comp (_root_.Primrec.succ.comp n))
      (Primrec.option_some.comp (Primrec.fst.comp <| Primrec.unpair.comp n))
      (Primrec.option_some.comp (Primrec.snd.comp <| Primrec.unpair.comp n))
  · have L := (Primrec.fst.comp Primrec.fst).comp
      (Primrec.fst (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    

Proof state:
case hpr
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝ : Primrec Prod.snd
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n : Primrec fun a => a.1.2
k' : Primrec Prod.snd
c : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).2
L : Primrec fun a => a.1.1.1
⊢ Primrec fun a => do
    let x ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.1) a.1.1.2
    let y ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.2.1) a.1.1.2
    some (Nat.pair x y)

Next tactic:
have k := k.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
  apply
    Nat.Partrec.Code.rec_prim c
      (_root_.Primrec.const (some 0))
      (Primrec.option_some.comp (_root_.Primrec.succ.comp n))
      (Primrec.option_some.comp (Primrec.fst.comp <| Primrec.unpair.comp n))
      (Primrec.option_some.comp (Primrec.snd.comp <| Primrec.unpair.comp n))
  · have L := (Primrec.fst.comp Primrec.fst).comp
      (Primrec.fst (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    have k := k.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
    

Proof state:
case hpr
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝¹ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝ : Primrec Prod.snd
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n : Primrec fun a => a.1.2
k' : Primrec Prod.snd
c : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).2
L : Primrec fun a => a.1.1.1
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1.1)).1
⊢ Primrec fun a => do
    let x ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.1) a.1.1.2
    let y ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.2.1) a.1.1.2
    some (Nat.pair x y)

Next tactic:
have n := n.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
  apply
    Nat.Partrec.Code.rec_prim c
      (_root_.Primrec.const (some 0))
      (Primrec.option_some.comp (_root_.Primrec.succ.comp n))
      (Primrec.option_some.comp (Primrec.fst.comp <| Primrec.unpair.comp n))
      (Primrec.option_some.comp (Primrec.snd.comp <| Primrec.unpair.comp n))
  · have L := (Primrec.fst.comp Primrec.fst).comp
      (Primrec.fst (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    have k := k.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
    have n := n.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
    

Proof state:
case hpr
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝¹ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝¹ : Primrec Prod.snd
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n✝ : Primrec fun a => a.1.2
k' : Primrec Prod.snd
c : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).2
L : Primrec fun a => a.1.1.1
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1.1)).1
n : Primrec fun a => a.1.1.2
⊢ Primrec fun a => do
    let x ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.1) a.1.1.2
    let y ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.2.1) a.1.1.2
    some (Nat.pair x y)

Next tactic:
have cf := Primrec.fst.comp (Primrec.snd (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
  apply
    Nat.Partrec.Code.rec_prim c
      (_root_.Primrec.const (some 0))
      (Primrec.option_some.comp (_root_.Primrec.succ.comp n))
      (Primrec.option_some.comp (Primrec.fst.comp <| Primrec.unpair.comp n))
      (Primrec.option_some.comp (Primrec.snd.comp <| Primrec.unpair.comp n))
  · have L := (Primrec.fst.comp Primrec.fst).comp
      (Primrec.fst (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    have k := k.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
    have n := n.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
    have cf := Primrec.fst.comp (Primrec.snd (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    

Proof state:
case hpr
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝¹ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝¹ : Primrec Prod.snd
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n✝ : Primrec fun a => a.1.2
k' : Primrec Prod.snd
c : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).2
L : Primrec fun a => a.1.1.1
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1.1)).1
n : Primrec fun a => a.1.1.2
cf : Primrec fun a => a.2.1
⊢ Primrec fun a => do
    let x ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.1) a.1.1.2
    let y ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.2.1) a.1.1.2
    some (Nat.pair x y)

Next tactic:
have cg := (Primrec.fst.comp Primrec.snd).comp
      (Primrec.snd (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
private theorem hG : Primrec G := by
  have a := (Primrec.ofNat (ℕ × Code)).comp (Primrec.list_length (α := List (Option ℕ)))
  have k := Primrec.fst.comp a
  refine' Primrec.option_some.comp (Primrec.list_map (Primrec.list_range.comp k) (_ : Primrec _))
  replace k := k.comp (Primrec.fst (β := ℕ))
  have n := Primrec.snd (α := List (List (Option ℕ))) (β := ℕ)
  refine' Primrec.nat_casesOn k (_root_.Primrec.const Option.none) (_ : Primrec _)
  have k := k.comp (Primrec.fst (β := ℕ))
  have n := n.comp (Primrec.fst (β := ℕ))
  have k' := Primrec.snd (α := List (List (Option ℕ)) × ℕ) (β := ℕ)
  have c := Primrec.snd.comp (a.comp <| (Primrec.fst (β := ℕ)).comp (Primrec.fst (β := ℕ)))
  apply
    Nat.Partrec.Code.rec_prim c
      (_root_.Primrec.const (some 0))
      (Primrec.option_some.comp (_root_.Primrec.succ.comp n))
      (Primrec.option_some.comp (Primrec.fst.comp <| Primrec.unpair.comp n))
      (Primrec.option_some.comp (Primrec.snd.comp <| Primrec.unpair.comp n))
  · have L := (Primrec.fst.comp Primrec.fst).comp
      (Primrec.fst (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    have k := k.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
    have n := n.comp (Primrec.fst (β := Code × Code × Option ℕ × Option ℕ))
    have cf := Primrec.fst.comp (Primrec.snd (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    have cg := (Primrec.fst.comp Primrec.snd).comp
      (Primrec.snd (α := (List (List (Option ℕ)) × ℕ) × ℕ)
        (β := Code × Code × Option ℕ × Option ℕ))
    

Proof state:
case hpr
a : Primrec fun a => ofNat (ℕ × Code) (List.length a)
k✝¹ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1)).1
n✝¹ : Primrec Prod.snd
k✝ : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).1
n✝ : Primrec fun a => a.1.2
k' : Primrec Prod.snd
c : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1)).2
L : Primrec fun a => a.1.1.1
k : Primrec fun a => (ofNat (ℕ × Code) (List.length a.1.1.1)).1
n : Primrec fun a => a.1.1.2
cf : Primrec fun a => a.2.1
cg : Primrec fun a => a.2.2.1
⊢ Primrec fun a => do
    let x ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.1) a.1.1.2
    let y ← Nat.Partrec.Code.lup a.1.1.1 ((ofNat (ℕ × Code) (List.length a.1.1.1)).1, a.2.2.1) a.1.1.2
    some (Nat.pair x y)

Next tactic:
refine Primrec.option_bind (hlup.comp <| L.pair <| (k.pair cf).pair n) ?_