awhecmu/canonical-drafter-extract-mathlib huggingface dataset:
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
c : Code
zero : ofNatCode Code.zero.encodeCode = Code.zero
succ : ofNatCode Code.succ.encodeCode = Code.succ
left : ofNatCode Code.left.encodeCode = Code.left
right : ofNatCode Code.right.encodeCode = Code.right
pair :
  ∀ (a a_1 : Code),
    ofNatCode a.encodeCode = a → ofNatCode a_1.encodeCode = a_1 → ofNatCode (a.pair a_1).encodeCode = a.pair a_1
comp :
  ∀ (a a_1 : Code),
    ofNatCode a.encodeCode = a → ofNatCode a_1.encodeCode = a_1 → ofNatCode (a.comp a_1).encodeCode = a.comp a_1
⊢ ofNatCode c.encodeCode = c
have prec : ∀ (a a_1 : Code),
  ofNatCode a.encodeCode = a → ofNatCode a_1.encodeCode = a_1 → ofNatCode (a.prec a_1).encodeCode = a.prec a_1
Tactic: induction c
Cleared hypotheses: c
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
c : Code
zero : ofNatCode Code.zero.encodeCode = Code.zero
succ : ofNatCode Code.succ.encodeCode = Code.succ
left : ofNatCode Code.left.encodeCode = Code.left
right : ofNatCode Code.right.encodeCode = Code.right
pair :
  ∀ (a a_1 : Code),
    ofNatCode a.encodeCode = a → ofNatCode a_1.encodeCode = a_1 → ofNatCode (a.pair a_1).encodeCode = a.pair a_1
comp :
  ∀ (a a_1 : Code),
    ofNatCode a.encodeCode = a → ofNatCode a_1.encodeCode = a_1 → ofNatCode (a.comp a_1).encodeCode = a.comp a_1
prec :
  ∀ (a a_1 : Code),
    ofNatCode a.encodeCode = a → ofNatCode a_1.encodeCode = a_1 → ofNatCode (a.prec a_1).encodeCode = a.prec a_1
⊢ ofNatCode c.encodeCode = c
have rfind' : ∀ (a : Code), ofNatCode a.encodeCode = a → ofNatCode a.rfind'.encodeCode = a.rfind'
Tactic: induction c
Cleared hypotheses: c
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
cf cg : Code
⊢ encode cf < encode (cf.pair cg) ∧ encode cg < encode (cf.pair cg)
have simp : cf.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4 ∧
  cg.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4
Tactic: simp only [encodeCode_eq, encodeCode]
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (hypothesis)
Goal:
cf cg : Code
⊢ cf.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4 ∧
    cg.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4
have this : 1 * Nat.pair cf.encodeCode cg.encodeCode ≤ HMul.hMul (α := ℕ) 2 2 * Nat.pair cf.encodeCode cg.encodeCode
Tactic: have := Nat.mul_le_mul_right (Nat.pair cf.encodeCode cg.encodeCode) (by decide : 1 ≤ 2 * 2)
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (hypothesis)
Goal:
cf cg : Code
this : 1 * Nat.pair cf.encodeCode cg.encodeCode ≤ HMul.hMul (α := ℕ) 2 2 * Nat.pair cf.encodeCode cg.encodeCode
⊢ cf.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4 ∧
    cg.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4
have this₁ : Nat.pair cf.encodeCode cg.encodeCode ≤ 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode)
Tactic: rw [one_mul, mul_assoc] at this
Cleared hypotheses: this
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (hypothesis)
Goal:
cf cg : Code
this : Nat.pair cf.encodeCode cg.encodeCode ≤ 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode)
⊢ cf.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4 ∧
    cg.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4
have this₁ : Nat.pair cf.encodeCode cg.encodeCode < 2 * (2 * Nat.pair cf.encodeCode cg.encodeCode) + 4
Tactic: have := lt_of_le_of_lt this (lt_add_of_pos_right _ (by decide : 0 < 4))
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (hypothesis)
Goal:
cf cg : Code
⊢ encode cf < encode (cf.comp cg) ∧ encode cg < encode (cf.comp cg)
have this : encode (cf.pair cg) < encode (cf.comp cg)
Tactic: have : encode (pair cf cg) < encode (comp cf cg) := by simp [encodeCode_eq, encodeCode]
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (hypothesis)
Goal:
cf cg : Code
⊢ encode cf < encode (cf.prec cg) ∧ encode cg < encode (cf.prec cg)
have this : encode (cf.pair cg) < encode (cf.prec cg)
Tactic: have : encode (pair cf cg) < encode (prec cf cg) := by simp [encodeCode_eq, encodeCode]
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
cf : Code
⊢ encode cf < encode cf.rfind'
have simp : cf.encodeCode < 2 * (2 * cf.encodeCode + 1) + 1 + 4
Tactic: simp only [encodeCode_eq, encodeCode]
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (hypothesis)
Goal:
α : Type u_1
σ : Type u_2
inst : Primcodable α
inst_1 : Primcodable σ
c : α → Code
hc : Primrec c
z : α → σ
hz : Primrec z
s : α → σ
hs : Primrec s
l : α → σ
hl : Primrec l
r : α → σ
hr : Primrec r
pr : α → Code × Code × σ × σ → σ
hpr : Primrec₂ pr
co : α → Code × Code × σ × σ → σ
hco : Primrec₂ co
pc : α → Code × Code × σ × σ → σ
hpc : Primrec₂ pc
rf : α → Code × σ → σ
hrf : Primrec₂ rf
PR : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pr a (cf, cg, hf, hg)
CO : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ co a (cf, cg, hf, hg)
PC : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pc a (cf, cg, hf, hg)
RF : (a : α) → (cf : Code) → (hf : σ) → σ := fun (a : α) (cf : Code) (hf : σ) ↦ rf a (cf, hf)
F : (a : α) → (c : Code) → σ :=
  fun (a : α) (c : Code) ↦
    Code.recOn (motive := fun (x : Code) ↦ σ) c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a)
G₁ : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ → Option σ :=
  fun (p : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ) ↦
    (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 p.2.2).bind fun (s : σ) ↦
      (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).1).bind fun (s₁ : σ) ↦
        Option.map
          (fun (s₂ : σ) ↦
            bif p.2.1.bodd then
              bif p.2.1.div2.bodd then rf p.1.1 (ofNat Code p.2.2, s)
              else pc p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
            else
              bif p.2.1.div2.bodd then co p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
              else pr p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂))
          (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).2)
this : Primrec G₁
G : α → List σ → Option σ :=
  fun (a : α) (IH : List σ) ↦
    Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) IH.length (some (z a)) fun (n : ℕ) ↦
      Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (s a)) fun (n : ℕ) ↦
        Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (l a)) fun (n : ℕ) ↦
          Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (r a)) fun (n : ℕ) ↦ G₁ ((a, IH), n, n.div2.div2)
⊢ Primrec.{u_1, u_2} (β := σ) fun (a : α) ↦ F a (c a)
have this₁ : Primrec₂ G
Tactic: have : Primrec₂ G := .mk <|
    nat_casesOn (list_length.comp snd) (option_some_iff.2 (hz.comp fst)) <| .mk <|
    nat_casesOn snd (option_some_iff.2 (hs.comp (fst.comp fst))) <| .mk <|
    nat_casesOn snd (option_some_iff.2 (hl.comp (fst.comp <| fst.comp fst))) <| .mk <|
    nat_casesOn snd (option_some_iff.2 (hr.comp (fst.comp <| fst.comp <| fst.comp fst))) <| .mk <|
    this.comp <|
      ((fst.pair snd).comp <| fst.comp <| fst.comp <| fst.comp <| fst).pair <|
      snd.pair <| nat_div2.comp <| nat_div2.comp snd
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
α : Type u_1
σ : Type u_2
inst : Primcodable α
inst_1 : Primcodable σ
c : α → Code
hc : Primrec c
z : α → σ
hz : Primrec z
s : α → σ
hs : Primrec s
l : α → σ
hl : Primrec l
r : α → σ
hr : Primrec r
pr : α → Code × Code × σ × σ → σ
hpr : Primrec₂ pr
co : α → Code × Code × σ × σ → σ
hco : Primrec₂ co
pc : α → Code × Code × σ × σ → σ
hpc : Primrec₂ pc
rf : α → Code × σ → σ
hrf : Primrec₂ rf
PR : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pr a (cf, cg, hf, hg)
CO : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ co a (cf, cg, hf, hg)
PC : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pc a (cf, cg, hf, hg)
RF : (a : α) → (cf : Code) → (hf : σ) → σ := fun (a : α) (cf : Code) (hf : σ) ↦ rf a (cf, hf)
F : (a : α) → (c : Code) → σ :=
  fun (a : α) (c : Code) ↦
    Code.recOn (motive := fun (x : Code) ↦ σ) c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a)
G₁ : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ → Option σ :=
  fun (p : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ) ↦
    (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 p.2.2).bind fun (s : σ) ↦
      (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).1).bind fun (s₁ : σ) ↦
        Option.map
          (fun (s₂ : σ) ↦
            bif p.2.1.bodd then
              bif p.2.1.div2.bodd then rf p.1.1 (ofNat Code p.2.2, s)
              else pc p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
            else
              bif p.2.1.div2.bodd then co p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
              else pr p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂))
          (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).2)
this_1 : Primrec G₁
G : α → List σ → Option σ :=
  fun (a : α) (IH : List σ) ↦
    Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) IH.length (some (z a)) fun (n : ℕ) ↦
      Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (s a)) fun (n : ℕ) ↦
        Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (l a)) fun (n : ℕ) ↦
          Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (r a)) fun (n : ℕ) ↦ G₁ ((a, IH), n, n.div2.div2)
this : Primrec₂ G
⊢ Primrec.{u_1, u_2} (β := σ) fun (a : α) ↦ F a (c a)
have refine : ∀ (a : α) (n : ℕ),
  G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range n)).1
      (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range n)).2 =
    some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a n)
Tactic: refine (nat_strong_rec (fun a n => F a (ofNat Code n)) this.to₂ fun a n => ?_)
    |>.comp .id (encode_iff.2 hc) |>.of_eq fun a => by simp
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
α : Type u_1
σ : Type u_2
inst : Primcodable α
inst_1 : Primcodable σ
c : α → Code
hc : Primrec c
z : α → σ
hz : Primrec z
s : α → σ
hs : Primrec s
l : α → σ
hl : Primrec l
r : α → σ
hr : Primrec r
pr : α → Code × Code × σ × σ → σ
hpr : Primrec₂ pr
co : α → Code × Code × σ × σ → σ
hco : Primrec₂ co
pc : α → Code × Code × σ × σ → σ
hpc : Primrec₂ pc
rf : α → Code × σ → σ
hrf : Primrec₂ rf
PR : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pr a (cf, cg, hf, hg)
CO : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ co a (cf, cg, hf, hg)
PC : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pc a (cf, cg, hf, hg)
RF : (a : α) → (cf : Code) → (hf : σ) → σ := fun (a : α) (cf : Code) (hf : σ) ↦ rf a (cf, hf)
F : (a : α) → (c : Code) → σ :=
  fun (a : α) (c : Code) ↦
    Code.recOn (motive := fun (x : Code) ↦ σ) c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a)
G₁ : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ → Option σ :=
  fun (p : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ) ↦
    (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 p.2.2).bind fun (s : σ) ↦
      (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).1).bind fun (s₁ : σ) ↦
        Option.map
          (fun (s₂ : σ) ↦
            bif p.2.1.bodd then
              bif p.2.1.div2.bodd then rf p.1.1 (ofNat Code p.2.2, s)
              else pc p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
            else
              bif p.2.1.div2.bodd then co p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
              else pr p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂))
          (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).2)
this_1 : Primrec G₁
G : α → List σ → Option σ :=
  fun (a : α) (IH : List σ) ↦
    Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) IH.length (some (z a)) fun (n : ℕ) ↦
      Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (s a)) fun (n : ℕ) ↦
        Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (l a)) fun (n : ℕ) ↦
          Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (r a)) fun (n : ℕ) ↦ G₁ ((a, IH), n, n.div2.div2)
this : Primrec₂ G
a : α
n : ℕ
⊢ G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range n)).1
      (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range n)).2 =
    some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a n)
have zero : G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range 0)).1
    (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range 0)).2 =
  some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a 0)
Tactic: rcases n with - | n
Cleared hypotheses: n
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
α : Type u_1
σ : Type u_2
inst : Primcodable α
inst_1 : Primcodable σ
c : α → Code
hc : Primrec c
z : α → σ
hz : Primrec z
s : α → σ
hs : Primrec s
l : α → σ
hl : Primrec l
r : α → σ
hr : Primrec r
pr : α → Code × Code × σ × σ → σ
hpr : Primrec₂ pr
co : α → Code × Code × σ × σ → σ
hco : Primrec₂ co
pc : α → Code × Code × σ × σ → σ
hpc : Primrec₂ pc
rf : α → Code × σ → σ
hrf : Primrec₂ rf
PR : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pr a (cf, cg, hf, hg)
CO : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ co a (cf, cg, hf, hg)
PC : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pc a (cf, cg, hf, hg)
RF : (a : α) → (cf : Code) → (hf : σ) → σ := fun (a : α) (cf : Code) (hf : σ) ↦ rf a (cf, hf)
F : (a : α) → (c : Code) → σ :=
  fun (a : α) (c : Code) ↦
    Code.recOn (motive := fun (x : Code) ↦ σ) c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a)
G₁ : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ → Option σ :=
  fun (p : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ) ↦
    (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 p.2.2).bind fun (s : σ) ↦
      (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).1).bind fun (s₁ : σ) ↦
        Option.map
          (fun (s₂ : σ) ↦
            bif p.2.1.bodd then
              bif p.2.1.div2.bodd then rf p.1.1 (ofNat Code p.2.2, s)
              else pc p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
            else
              bif p.2.1.div2.bodd then co p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
              else pr p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂))
          (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).2)
this_1 : Primrec G₁
G : α → List σ → Option σ :=
  fun (a : α) (IH : List σ) ↦
    Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) IH.length (some (z a)) fun (n : ℕ) ↦
      Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (s a)) fun (n : ℕ) ↦
        Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (l a)) fun (n : ℕ) ↦
          Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (r a)) fun (n : ℕ) ↦ G₁ ((a, IH), n, n.div2.div2)
this : Primrec₂ G
a : α
n : ℕ
zero :
  G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range 0)).1
      (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range 0)).2 =
    some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a 0)
⊢ G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range n)).1
      (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range n)).2 =
    some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a n)
have succ : ∀ (n : ℕ),
  G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range (n + 1))).1
      (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range (n + 1))).2 =
    some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a (n + 1))
Tactic: rcases n with - | n
Cleared hypotheses: n
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
α : Type u_1
σ : Type u_2
inst : Primcodable α
inst_1 : Primcodable σ
c : α → Code
hc : Primrec c
z : α → σ
hz : Primrec z
s : α → σ
hs : Primrec s
l : α → σ
hl : Primrec l
r : α → σ
hr : Primrec r
pr : α → Code × Code × σ × σ → σ
hpr : Primrec₂ pr
co : α → Code × Code × σ × σ → σ
hco : Primrec₂ co
pc : α → Code × Code × σ × σ → σ
hpc : Primrec₂ pc
rf : α → Code × σ → σ
hrf : Primrec₂ rf
PR : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pr a (cf, cg, hf, hg)
CO : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ co a (cf, cg, hf, hg)
PC : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pc a (cf, cg, hf, hg)
RF : (a : α) → (cf : Code) → (hf : σ) → σ := fun (a : α) (cf : Code) (hf : σ) ↦ rf a (cf, hf)
F : (a : α) → (c : Code) → σ :=
  fun (a : α) (c : Code) ↦
    Code.recOn (motive := fun (x : Code) ↦ σ) c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a)
G₁ : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ → Option σ :=
  fun (p : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ) ↦
    (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 p.2.2).bind fun (s : σ) ↦
      (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).1).bind fun (s₁ : σ) ↦
        Option.map
          (fun (s₂ : σ) ↦
            bif p.2.1.bodd then
              bif p.2.1.div2.bodd then rf p.1.1 (ofNat Code p.2.2, s)
              else pc p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
            else
              bif p.2.1.div2.bodd then co p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
              else pr p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂))
          (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).2)
this_1 : Primrec G₁
G : α → List σ → Option σ :=
  fun (a : α) (IH : List σ) ↦
    Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) IH.length (some (z a)) fun (n : ℕ) ↦
      Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (s a)) fun (n : ℕ) ↦
        Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (l a)) fun (n : ℕ) ↦
          Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (r a)) fun (n : ℕ) ↦ G₁ ((a, IH), n, n.div2.div2)
this : Primrec₂ G
a : α
⊢ G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range 0)).1
      (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range 0)).2 =
    some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a 0)
have zero : G a [] = some (F a zero)
Tactic: simp [ofNatCode_eq, ofNatCode]
-- Lean 4 proof step from Mathlib.Computability.PartrecCode (goal)
Goal:
α : Type u_1
σ : Type u_2
inst : Primcodable α
inst_1 : Primcodable σ
c : α → Code
hc : Primrec c
z : α → σ
hz : Primrec z
s : α → σ
hs : Primrec s
l : α → σ
hl : Primrec l
r : α → σ
hr : Primrec r
pr : α → Code × Code × σ × σ → σ
hpr : Primrec₂ pr
co : α → Code × Code × σ × σ → σ
hco : Primrec₂ co
pc : α → Code × Code × σ × σ → σ
hpc : Primrec₂ pc
rf : α → Code × σ → σ
hrf : Primrec₂ rf
PR : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pr a (cf, cg, hf, hg)
CO : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ co a (cf, cg, hf, hg)
PC : (a : α) → (cf cg : Code) → (hf hg : σ) → σ := fun (a : α) (cf cg : Code) (hf hg : σ) ↦ pc a (cf, cg, hf, hg)
RF : (a : α) → (cf : Code) → (hf : σ) → σ := fun (a : α) (cf : Code) (hf : σ) ↦ rf a (cf, hf)
F : (a : α) → (c : Code) → σ :=
  fun (a : α) (c : Code) ↦
    Code.recOn (motive := fun (x : Code) ↦ σ) c (z a) (s a) (l a) (r a) (PR a) (CO a) (PC a) (RF a)
G₁ : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ → Option σ :=
  fun (p : Prod.{u_1, u_2} α (List σ) × ℕ × ℕ) ↦
    (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 p.2.2).bind fun (s : σ) ↦
      (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).1).bind fun (s₁ : σ) ↦
        Option.map
          (fun (s₂ : σ) ↦
            bif p.2.1.bodd then
              bif p.2.1.div2.bodd then rf p.1.1 (ofNat Code p.2.2, s)
              else pc p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
            else
              bif p.2.1.div2.bodd then co p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂)
              else pr p.1.1 (ofNat Code (unpair p.2.2).1, ofNat Code (unpair p.2.2).2, s₁, s₂))
          (getElem? (valid := fun (as : List σ) (i : ℕ) ↦ i < as.length) p.1.2 (unpair p.2.2).2)
this_1 : Primrec G₁
G : α → List σ → Option σ :=
  fun (a : α) (IH : List σ) ↦
    Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) IH.length (some (z a)) fun (n : ℕ) ↦
      Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (s a)) fun (n : ℕ) ↦
        Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (l a)) fun (n : ℕ) ↦
          Nat.casesOn (motive := fun (x : ℕ) ↦ Option σ) n (some (r a)) fun (n : ℕ) ↦ G₁ ((a, IH), n, n.div2.div2)
this : Primrec₂ G
a : α
n : ℕ
⊢ G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range (n + 1))).1
      (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range (n + 1))).2 =
    some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a (n + 1))
have succ : G (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range (HAdd.hAdd (α := ℕ) 0 1))).1
    (a, List.map ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a) (List.range (HAdd.hAdd (α := ℕ) 0 1))).2 =
  some ((fun (a : α) (n : ℕ) ↦ F a (ofNat Code n)) a (HAdd.hAdd (α := ℕ) 0 1))
Tactic: rcases n with - | n
Cleared hypotheses: n