-- Module: Mathlib.Computability.TuringMachine.Config
Goal:
n_1 : ℕ
f_1 : List.Vector ℕ n_1 →. ℕ
n_2 : ℕ
f_2 : List.Vector ℕ n_2 → ℕ
n_3 : ℕ
f : List.Vector ℕ n_3 → ℕ
g : List.Vector ℕ (n_3 + 2) → ℕ
h : Nat.Primrec' f
h_1 : Nat.Primrec' g
cf cg : Code
v : List.Vector ℕ (n_3 + 1)
hf : cf.eval (↑v : List ℕ).tail = pure (pure (f v.tail))
hg : ∀ (a b : ℕ), cg.eval (a :: b :: (↑v : List ℕ).tail) = pure (pure (g (a ::ᵥ b ::ᵥ v.tail)))
n : ℕ
h_2 :
  (cf.prec cg).eval (n :: (↑v : List ℕ).tail) =
    pure (pure (Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) n))
b : ℕ
IH :
  ∀ (a : ℕ) (e : a + b = n),
    Membership.mem (γ := Part (List ℕ))
      (PFun.fix
        (fun (v : List ℕ) ↦
          (cg.eval (v.headI :: v.tail.tail)).bind fun (x : List ℕ) ↦
            Part.some
              (if v.tail.headI = 0 then Sum.inl (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail)
              else Sum.inr (v.headI.succ :: v.tail.headI.pred :: x.headI :: v.tail.tail.tail)))
        (a ::
          b ::
            Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
              (↑v : List ℕ).tail))
      (n.succ ::
        0 ::
          g
              (n ::ᵥ
                Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) n ::ᵥ
                  v.tail) ::
            (↑v : List ℕ).tail)
a : ℕ
e : a + (b + 1) = n
prim :
  Sum.inr
      ((a + 1) ::
        b ::
          g
              (a ::ᵥ
                Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::ᵥ
                  v.tail) ::
            (↑v : List ℕ).tail) ∈
    Part.some
      (if
          ((b + 1) ::
                Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                  (↑v : List ℕ).tail).headI =
            0 then
        Sum.inl
          ((a ::
                  (b + 1) ::
                    Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                      (↑v : List ℕ).tail).headI.succ ::
            ((b + 1) ::
                    Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                      (↑v : List ℕ).tail).headI.pred ::
              [g
                      ((a ::
                            (b + 1) ::
                              Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail))
                                  a ::
                                (↑v : List ℕ).tail).headI ::ᵥ
                        Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::ᵥ
                          v.tail)].headI ::
                (↑v : List ℕ).tail)
      else
        Sum.inr
          ((a ::
                  (b + 1) ::
                    Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                      (↑v : List ℕ).tail).headI.succ ::
            ((b + 1) ::
                    Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                      (↑v : List ℕ).tail).headI.pred ::
              [g
                      ((a ::
                            (b + 1) ::
                              Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail))
                                  a ::
                                (↑v : List ℕ).tail).headI ::ᵥ
                        Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::ᵥ
                          v.tail)].headI ::
                (↑v : List ℕ).tail))
⊢ Membership.mem (γ := Part (List ℕ ⊕ List ℕ))
    ((cg.eval
          ((a ::
                (b + 1) ::
                  Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                    (↑v : List ℕ).tail).headI ::
            (a ::
                  (b + 1) ::
                    Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                      (↑v : List ℕ).tail).tail.tail)).bind
      fun (x : List ℕ) ↦
      Part.some
        (if
            (a ::
                    (b + 1) ::
                      Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                        (↑v : List ℕ).tail).tail.headI =
              0 then
          Sum.inl
            ((a ::
                    (b + 1) ::
                      Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                        (↑v : List ℕ).tail).headI.succ ::
              (a ::
                        (b + 1) ::
                          Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                            (↑v : List ℕ).tail).tail.headI.pred ::
                x.headI ::
                  (a ::
                          (b + 1) ::
                            Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail))
                                a ::
                              (↑v : List ℕ).tail).tail.tail.tail)
        else
          Sum.inr
            ((a ::
                    (b + 1) ::
                      Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                        (↑v : List ℕ).tail).headI.succ ::
              (a ::
                        (b + 1) ::
                          Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) a ::
                            (↑v : List ℕ).tail).tail.headI.pred ::
                x.headI ::
                  (a ::
                          (b + 1) ::
                            Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail))
                                a ::
                              (↑v : List ℕ).tail).tail.tail.tail)))
    (Sum.inr
      ((a + 1) ::
        b ::
          Nat.rec (motive := fun (x : ℕ) ↦ ℕ) (f v.tail) (fun (y IH : ℕ) ↦ g (y ::ᵥ IH ::ᵥ v.tail)) (a + 1) ::
            (↑v : List ℕ).tail))

Tactic:
simp only [hg, Part.bind_some, List.tail_cons, pure]

Premises used: Pure.pure, Part.bind_some, List.tail_cons