Theorem: LO.FirstOrder.Semiterm.bind_primrec (Logic/FirstOrder/Computability/Term.lean)

State before:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
⊢ Primrec fun x => (Rew.bind (b x) (e x)) (t x)
Tactic:
letI : ∀ n, Primcodable { t : UTerm L μ₁ // t.bv ≤ n } := fun n => Primcodable.subtype (nat_le.comp UTerm.bv_primrec (Primrec.const n))
State after:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
⊢ Primrec fun x => (Rew.bind (b x) (e x)) (t x)

State before:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
⊢ Primrec fun x => (Rew.bind (b x) (e x)) (t x)
Tactic:
letI : ∀ n, Primcodable { t : UTerm L μ₂ // t.bv ≤ n } := fun n => Primcodable.subtype (nat_le.comp UTerm.bv_primrec (Primrec.const n))
State after:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this✝ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
⊢ Primrec fun x => (Rew.bind (b x) (e x)) (t x)

State before:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this✝ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
⊢ Primrec fun x => (Rew.bind (b x) (e x)) (t x)
Tactic:
have : Primrec (fun z =>
    UTerm.bind (fun x => if hx : x < n₁ then subtEquiv (b z ⟨x, hx⟩) else default) (fun x => subtEquiv $ e z x) (subtEquiv $ t z)
    : α → UTerm L μ₂) :=
  UTerm.bind_primrec_param (brew_primrec hb)
    (subtype_val.comp₂ $ of_equiv.comp₂ $ he.comp₂ Primrec₂.left Primrec₂.right)
    (subtype_val.comp $ of_equiv.comp ht)
State after:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this✝¹ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this✝ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this :
  Primrec fun z =>
    UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b z ⟨x, hx⟩)) else default) (fun x => ↑(subtEquiv (e z x)))
      ↑(subtEquiv (t z))
⊢ Primrec fun x => (Rew.bind (b x) (e x)) (t x)

State before:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this✝¹ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this✝ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this :
  Primrec fun z =>
    UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b z ⟨x, hx⟩)) else default) (fun x => ↑(subtEquiv (e z x)))
      ↑(subtEquiv (t z))
⊢ Primrec fun x => (Rew.bind (b x) (e x)) (t x)
Tactic:
exact encode_iff.mp <| (Primrec.encode.comp this).of_eq <| by
  intro a
  simp[Encodable.encode_ofEquiv subtEquiv, Encodable.Subtype.encode_eq, subtEquiv_bind_eq_bind]
State after:
no goals

State before:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this✝¹ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this✝ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this :
  Primrec fun z =>
    UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b z ⟨x, hx⟩)) else default) (fun x => ↑(subtEquiv (e z x)))
      ↑(subtEquiv (t z))
⊢ ∀ (n : α),
    encode
        (UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b n ⟨x, hx⟩)) else default)
          (fun x => ↑(subtEquiv (e n x))) ↑(subtEquiv (t n))) =
      encode ((Rew.bind (b n) (e n)) (t n))
Tactic:
intro a
State after:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this✝¹ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this✝ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this :
  Primrec fun z =>
    UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b z ⟨x, hx⟩)) else default) (fun x => ↑(subtEquiv (e z x)))
      ↑(subtEquiv (t z))
a : α
⊢ encode
      (UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b a ⟨x, hx⟩)) else default) (fun x => ↑(subtEquiv (e a x)))
        ↑(subtEquiv (t a))) =
    encode ((Rew.bind (b a) (e a)) (t a))

State before:
L : Language
μ : Type v
α : Type u_1
inst✝⁶ : Primcodable α
inst✝⁵ : Primcodable μ
inst✝⁴ : (k : ℕ) → Primcodable (L.Func k)
inst✝³ : UniformlyPrimcodable L.Func
σ : Type u_2
μ₁ : Type u_3
μ₂ : Type u_4
inst✝² : Primcodable μ₁
inst✝¹ : Primcodable μ₂
inst✝ : Primcodable σ
n₁ n₂ : ℕ
b : α → Fin n₁ → Semiterm L μ₂ n₂
e : α → μ₁ → Semiterm L μ₂ n₂
t : α → Semiterm L μ₁ n₁
hb : Primrec b
he : Primrec₂ e
ht : Primrec t
this✝¹ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this✝ : (n : ℕ) → Primcodable { t // t.bv ≤ n } := fun n => Primcodable.subtype ⋯
this :
  Primrec fun z =>
    UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b z ⟨x, hx⟩)) else default) (fun x => ↑(subtEquiv (e z x)))
      ↑(subtEquiv (t z))
a : α
⊢ encode
      (UTerm.bind (fun x => if hx : x < n₁ then ↑(subtEquiv (b a ⟨x, hx⟩)) else default) (fun x => ↑(subtEquiv (e a x)))
        ↑(subtEquiv (t a))) =
    encode ((Rew.bind (b a) (e a)) (t a))
Tactic:
simp[Encodable.encode_ofEquiv subtEquiv, Encodable.Subtype.encode_eq, subtEquiv_bind_eq_bind]
State after:
no goals