[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Function.OfArity).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
abbrev OfArity (α β : Type u) (n : ℕ) : Type u
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Logic.Function.OfArity.ofArity_zero (L34-L35)
theorem ofArity_zero (α β : Type u) : OfArity α β 0 = β := fromTypes_zero _ _
```

-- snippet 2
```lean
-- Mathlib.Logic.Function.OfArity.ofArity_succ (L37-L42)
theorem ofArity_succ (α β : Type u) (n : ℕ) :
    OfArity α β n.succ = (α → OfArity α β n) := fromTypes_succ _ _
namespace OfArity

/-- Constant `n`-ary function with value `b`. -/
```

-- snippet 3
```lean
-- Mathlib.Logic.Function.OfArity.const (L43-L45)
def const (α : Type u) {β : Type u} (b : β) (n : ℕ) : OfArity α β n :=
FromTypes.const (fun _ => α) b
```

-- snippet 4
```lean
-- Mathlib.Logic.Function.OfArity.const_zero (L47-L49)
theorem const_zero (α : Type u) {β : Type u} (b : β) : const α b 0 = b :=
FromTypes.const_zero (fun _ => α) b
```

-- snippet 5
```lean
-- Mathlib.Logic.Function.OfArity.const_succ (L51-L54)
theorem const_succ (α : Type u) {β : Type u} (b : β) (n : ℕ) :
    const α b n.succ = fun _ => const _ b n :=
FromTypes.const_succ (fun _ => α) b
```

-- snippet 6
```lean
-- Mathlib.Logic.Function.OfArity.const_succ_apply (L55-L57)
theorem const_succ_apply (α : Type u) {β : Type u} (b : β) (n : ℕ) (x : α) :
    const α b n.succ x = const _ b n := FromTypes.const_succ_apply _ b x
```

-- snippet 7
```lean
-- Mathlib.Logic.Function.OfArity.inhabited (L58-L64)
instance inhabited {α β n} [Inhabited β] : Inhabited (OfArity α β n) :=
inferInstanceAs (Inhabited (FromTypes (fun _ => α) β))

end OfArity

namespace FromTypes
```

-- snippet 8
```lean
-- Mathlib.Logic.Function.OfArity.fromTypes_fin_const (L65-L69)
lemma fromTypes_fin_const (α β : Type u) (n : ℕ) :
    FromTypes (fun (_ : Fin n) => α) β = OfArity α β n := rfl
/-- The definitional equality between heterogeneous functions with constant
domain and `n`-ary functions with that domain. -/
```

-- snippet 9
```lean
-- Mathlib.Logic.Function.OfArity.fromTypes_fin_const_equiv (L70-L75)
def fromTypes_fin_const_equiv (α β : Type u) (n : ℕ) :
    FromTypes (fun (_ : Fin n) => α) β ≃ OfArity α β n := .refl _
end FromTypes

end Function
```

-- snippet 10
```lean
-- Mathlib.Logic.Function.Basic.IsPartialInv (L286-L288)
def IsPartialInv {α β} (f : α → β) (g : β → Option α) : Prop :=
∀ x y, g y = some x ↔ f x = y
```

-- snippet 11
```lean
-- Mathlib.Logic.Function.Basic.const_injective (L45-L48)
theorem const_injective [Nonempty α] : Injective (const α : β → α → β) := fun _ _ h ↦
let ⟨x⟩ := ‹Nonempty α›
  congr_fun h x
```

-- snippet 12
```lean
-- Mathlib.Logic.Function.Basic.ne_iff (L64-L66)
theorem ne_iff {β : α → Sort*} {f₁ f₂ : ∀ a, β a} : f₁ ≠ f₂ ↔ ∃ a, f₁ a ≠ f₂ a :=
funext_iff.not.trans not_forall
```

-- snippet 13
```lean
-- Mathlib.Logic.Function.Basic.injective_comp_right_iff_surjective (L201-L213)
theorem injective_comp_right_iff_surjective {γ : Type*} [Nontrivial γ] :
    Injective (fun g : β → γ ↦ g ∘ f) ↔ Surjective f := by
refine ⟨not_imp_not.mp fun not_surj inj ↦ not_subsingleton γ ⟨fun c c' ↦ ?_⟩,
    (·.injective_comp_right)⟩
  have ⟨b₀, hb⟩ := not_forall.mp not_surj
  classical have := inj (a₁ := fun _ ↦ c) (a₂ := (if · = b₀ then c' else c)) ?_
  · simpa using congr_fun this b₀
  ext a; simp only [comp_apply, if_neg fun h ↦ hb ⟨a, h⟩]

protected theorem Surjective.right_cancellable (hf : Surjective f) {g₁ g₂ : β → γ} :
    g₁ ∘ f = g₂ ∘ f ↔ g₁ = g₂ :=
  hf.injective_comp_right.eq_iff
```

-- snippet 14
```lean
-- Mathlib.Logic.Function.Basic.onFun_apply (L53-L55)
theorem onFun_apply (f : β → β → γ) (g : α → β) (a b : α) : onFun f g a b = f (g a) (g b) :=
rfl
```

-- snippet 15
```lean
-- Mathlib.Logic.Function.Basic.Bijective (L229-L238)
theorem Bijective.existsUnique_iff {f : α → β} (hf : Bijective f) {p : β → Prop} :
    (∃! y, p y) ↔ ∃! x, p (f x) :=
⟨fun ⟨y, hpy, hy⟩ ↦
    let ⟨x, hx⟩ := hf.surjective y
    ⟨x, by simpa [hx], fun z (hz : p (f z)) ↦ hf.injective <| hx.symm ▸ hy _ hz⟩,
    fun ⟨x, hpx, hx⟩ ↦
    ⟨f x, hpx, fun y hy ↦
      let ⟨z, hz⟩ := hf.surjective y
      hz ▸ congr_arg f (hx _ (by simpa [hz]))⟩⟩
```

-- snippet 16
```lean
-- Mathlib.Logic.Function.Basic.swap_lt (L73-L73)
theorem swap_lt {α} [LT α] : swap (· < · : α → α → _) = (· > ·) := rfl
```

-- snippet 17
```lean
-- Mathlib.Logic.Function.Basic.injective_comp_left_iff (L126-L130)
theorem injective_comp_left_iff [Nonempty α] {g : β → γ} :
    Injective (g ∘ · : (α → β) → α → γ) ↔ Injective g :=
⟨fun h b₁ b₂ eq ↦ Nonempty.elim ‹_›
    (congr_fun <| h (a₁ := fun _ ↦ b₁) (a₂ := fun _ ↦ b₂) <| funext fun _ ↦ eq), (·.comp_left)⟩
```

-- snippet 18
```lean
-- Mathlib.Logic.Function.Basic.swap_le (L74-L74)
theorem swap_le {α} [LE α] : swap (· ≤ · : α → α → _) = (· ≥ ·) := rfl
```

-- snippet 19
```lean
-- Mathlib.Logic.Function.Basic.bijective_iff_existsUnique (L218-L228)
theorem bijective_iff_existsUnique (f : α → β) : Bijective f ↔ ∀ b : β, ∃! a : α, f a = b :=
⟨fun hf b ↦
      let ⟨a, ha⟩ := hf.surjective b
      ⟨a, ha, fun _ ha' ↦ hf.injective (ha'.trans ha.symm)⟩,
    fun he ↦ ⟨fun {_a a'} h ↦ (he (f a')).unique h rfl, fun b ↦ (he b).exists⟩⟩

/-- Shorthand for using projection notation with `Function.bijective_iff_existsUnique`. -/
protected theorem Bijective.existsUnique {f : α → β} (hf : Bijective f) (b : β) :
    ∃! a : α, f a = b :=
  (bijective_iff_existsUnique f).mp hf b
```

-- snippet 20
```lean
-- Mathlib.Logic.Function.Basic.funext_iff_of_subsingleton (L67-L72)
lemma funext_iff_of_subsingleton [Subsingleton α] {g : α → β} (x y : α) :
    f x = g y ↔ f = g := by
refine ⟨fun h ↦ funext fun z ↦ ?_, fun h ↦ ?_⟩
  · rwa [Subsingleton.elim x z, Subsingleton.elim y z] at h
  · rw [h, Subsingleton.elim x y]
```

-- snippet 21
```lean
-- Mathlib.Logic.Function.Basic.eval_apply (L39-L41)
theorem eval_apply {β : α → Sort*} (x : α) (f : ∀ x, β x) : eval x f = f x :=
rfl
```

-- snippet 22
```lean
-- Mathlib.Logic.Function.Basic.Injective (L95-L97)
theorem Injective.of_comp {g : γ → α} (I : Injective (f ∘ g)) : Injective g :=
fun _ _ h ↦ I <| congr_arg f h
```

-- snippet 23
```lean
-- Mathlib.Logic.Function.Basic.not_surjective_Type (L270-L285)
theorem not_surjective_Type {α : Type u} (f : α → Type max u v) : ¬Surjective f := by
intro hf
  let T : Type max u v := Sigma f
  cases hf (Set T) with | intro U hU =>
  let g : Set T → T := fun s ↦ ⟨U, cast hU.symm s⟩
  have hg : Injective g := by
    intro s t h
    suffices cast hU (g s).2 = cast hU (g t).2 by
      simp only [g, cast_cast, cast_eq] at this
      assumption
    · congr
  exact cantor_injective g hg

/-- `g` is a partial inverse to `f` (an injective but not necessarily
  surjective function) if `g y = some x` implies `f x = y`, and `g y = none`
  implies that `y` is not in the range of `f`. -/
```

-- snippet 24
```lean
-- Mathlib.Logic.Function.Basic.hfunext (L56-L63)
lemma hfunext {α α' : Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : ∀ a, β a} {f' : ∀ a, β' a}
    (hα : α = α') (h : ∀ a a', a ≍ a' → f a ≍ f' a') : f ≍ f' := by
subst hα
  have : ∀ a, f a ≍ f' a := fun a ↦ h a a (HEq.refl a)
  have : β = β' := by funext a; exact type_eq_of_heq (this a)
  subst this
  grind
```

-- snippet 25
```lean
-- Mathlib.Logic.Function.Basic.swap_gt (L75-L75)
theorem swap_gt {α} [LT α] : swap (· > · : α → α → _) = (· < ·) := rfl
```

-- snippet 26
```lean
-- Mathlib.Logic.Function.Basic.const_inj (L50-L52)
theorem const_inj [Nonempty α] {y₁ y₂ : β} : const α y₁ = const α y₂ ↔ y₁ = y₂ :=
⟨fun h ↦ const_injective h, fun h ↦ h ▸ rfl⟩
```

-- snippet 27
```lean
-- Mathlib.Logic.Function.Basic.exists_fixed_point_of_surjective (L251-L257)
theorem exists_fixed_point_of_surjective {α β : Type*} (f : α → α → β)
    (hf : Surjective f) (g : β → β) : ∃ x, g x = x :=
let ⟨a, ha⟩ := hf fun a => g (f a a)
  ⟨f a a, (congr_fun ha a).symm⟩

/-- **Cantor's diagonal argument** implies that there are no surjective functions from `α`
to `Set α`. -/
```

-- snippet 28
```lean
-- Mathlib.Logic.Function.Basic.decidableEqPFun (L165-L197)
instance decidableEqPFun (p : Prop) [Decidable p] (α : p → Type*) [∀ hp, DecidableEq (α hp)] :
    DecidableEq (∀ hp, α hp)
  | f, g => decidable_of_iff (∀ hp, f hp = g hp) funext_iff.symm

protected theorem Surjective.forall (hf : Surjective f) {p : β → Prop} :
    (∀ y, p y) ↔ ∀ x, p (f x) :=
⟨fun h x ↦ h (f x), fun h y ↦
    let ⟨x, hx⟩ := hf y
    hx ▸ h x⟩

protected theorem Surjective.forall₂ (hf : Surjective f) {p : β → β → Prop} :
    (∀ y₁ y₂, p y₁ y₂) ↔ ∀ x₁ x₂, p (f x₁) (f x₂) :=
  hf.forall.trans <| forall_congr' fun _ ↦ hf.forall

protected theorem Surjective.forall₃ (hf : Surjective f) {p : β → β → β → Prop} :
    (∀ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∀ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=
  hf.forall.trans <| forall_congr' fun _ ↦ hf.forall₂

protected theorem Surjective.exists (hf : Surjective f) {p : β → Prop} :
    (∃ y, p y) ↔ ∃ x, p (f x) :=
  ⟨fun ⟨y, hy⟩ ↦
    let ⟨x, hx⟩ := hf y
    ⟨x, hx.symm ▸ hy⟩,
    fun ⟨x, hx⟩ ↦ ⟨f x, hx⟩⟩

protected theorem Surjective.exists₂ (hf : Surjective f) {p : β → β → Prop} :
    (∃ y₁ y₂, p y₁ y₂) ↔ ∃ x₁ x₂, p (f x₁) (f x₂) :=
  hf.exists.trans <| exists_congr fun _ ↦ hf.exists

protected theorem Surjective.exists₃ (hf : Surjective f) {p : β → β → β → Prop} :
    (∃ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∃ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=
  hf.exists.trans <| exists_congr fun _ ↦ hf.exists₂
```

-- snippet 29
```lean
-- Mathlib.Logic.Function.Basic.not_injective_iff (L81-L83)
theorem not_injective_iff : ¬ Injective f ↔ ∃ a b, f a = f b ∧ a ≠ b := by
simp only [Injective, not_forall, exists_prop]
```

-- snippet 30
```lean
-- Mathlib.Logic.Function.Basic.cantor_surjective (L258-L263)
theorem cantor_surjective {α} (f : α → Set α) : ¬Surjective f := fun h =>
let ⟨_, hx⟩ := exists_fixed_point_of_surjective f h (¬·)
  not_iff_self (iff_of_eq hx)

/-- **Cantor's diagonal argument** implies that there are no injective functions from `Set α`
to `α`. -/
```

-- snippet 31
```lean
-- Mathlib.Logic.Function.Basic.Surjective (L109-L112)
theorem Surjective.bijective₂_of_injective {g : γ → α} (hf : Surjective f) (hg : Surjective g)
    (I : Injective (f ∘ g)) : Bijective f ∧ Bijective g :=
⟨⟨I.of_comp_right hg, hf⟩, I.of_comp, hg⟩
```

-- snippet 32
```lean
-- Mathlib.Logic.Function.Basic.swap_ge (L76-L80)
theorem swap_ge {α} [LE α] : swap (· ≥ · : α → α → _) = (· ≤ ·) := rfl
protected theorem Bijective.injective {f : α → β} (hf : Bijective f) : Injective f := hf.1
protected theorem Bijective.surjective {f : α → β} (hf : Bijective f) : Surjective f := hf.2
```

-- snippet 33
```lean
-- Mathlib.Logic.Function.Basic.const_def (L42-L44)
theorem const_def {y : β} : (fun _ : α ↦ y) = const α y :=
rfl
```

-- snippet 34
```lean
-- Mathlib.Logic.Function.Basic.surjective_of_right_cancellable_Prop (L214-L217)
theorem surjective_of_right_cancellable_Prop (h : ∀ g₁ g₂ : β → Prop, g₁ ∘ f = g₂ ∘ f → g₁ = g₂) :
    Surjective f :=
injective_comp_right_iff_surjective.mp h
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Function.OfArity).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
abbrev OfArity (α β : Type u) (n : ℕ) : Type u
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Logic.Function.OfArity.ofArity_zero (L34-L35)
theorem ofArity_zero (α β : Type u) : OfArity α β 0 = β := fromTypes_zero _ _
```

-- snippet 2
```lean
-- Mathlib.Logic.Function.OfArity.ofArity_succ (L37-L42)
theorem ofArity_succ (α β : Type u) (n : ℕ) :
    OfArity α β n.succ = (α → OfArity α β n) := fromTypes_succ _ _
namespace OfArity

/-- Constant `n`-ary function with value `b`. -/
```

-- snippet 3
```lean
-- Mathlib.Logic.Function.OfArity.const (L43-L45)
def const (α : Type u) {β : Type u} (b : β) (n : ℕ) : OfArity α β n :=
FromTypes.const (fun _ => α) b
```

-- snippet 4
```lean
-- Mathlib.Logic.Function.OfArity.const_zero (L47-L49)
theorem const_zero (α : Type u) {β : Type u} (b : β) : const α b 0 = b :=
FromTypes.const_zero (fun _ => α) b
```

-- snippet 5
```lean
-- Mathlib.Logic.Function.OfArity.const_succ (L51-L54)
theorem const_succ (α : Type u) {β : Type u} (b : β) (n : ℕ) :
    const α b n.succ = fun _ => const _ b n :=
FromTypes.const_succ (fun _ => α) b
```

-- snippet 6
```lean
-- Mathlib.Logic.Function.OfArity.const_succ_apply (L55-L57)
theorem const_succ_apply (α : Type u) {β : Type u} (b : β) (n : ℕ) (x : α) :
    const α b n.succ x = const _ b n := FromTypes.const_succ_apply _ b x
```

-- snippet 7
```lean
-- Mathlib.Logic.Function.OfArity.inhabited (L58-L64)
instance inhabited {α β n} [Inhabited β] : Inhabited (OfArity α β n) :=
inferInstanceAs (Inhabited (FromTypes (fun _ => α) β))

end OfArity

namespace FromTypes
```

-- snippet 8
```lean
-- Mathlib.Logic.Function.OfArity.fromTypes_fin_const (L65-L69)
lemma fromTypes_fin_const (α β : Type u) (n : ℕ) :
    FromTypes (fun (_ : Fin n) => α) β = OfArity α β n := rfl
/-- The definitional equality between heterogeneous functions with constant
domain and `n`-ary functions with that domain. -/
```

-- snippet 9
```lean
-- Mathlib.Logic.Function.OfArity.fromTypes_fin_const_equiv (L70-L75)
def fromTypes_fin_const_equiv (α β : Type u) (n : ℕ) :
    FromTypes (fun (_ : Fin n) => α) β ≃ OfArity α β n := .refl _
end FromTypes

end Function
```

-- snippet 10
```lean
-- Mathlib.Logic.Function.Basic.IsPartialInv (L286-L288)
def IsPartialInv {α β} (f : α → β) (g : β → Option α) : Prop :=
∀ x y, g y = some x ↔ f x = y
```

-- snippet 11
```lean
-- Mathlib.Logic.Function.Basic.const_injective (L45-L48)
theorem const_injective [Nonempty α] : Injective (const α : β → α → β) := fun _ _ h ↦
let ⟨x⟩ := ‹Nonempty α›
  congr_fun h x
```

-- snippet 12
```lean
-- Mathlib.Logic.Function.Basic.ne_iff (L64-L66)
theorem ne_iff {β : α → Sort*} {f₁ f₂ : ∀ a, β a} : f₁ ≠ f₂ ↔ ∃ a, f₁ a ≠ f₂ a :=
funext_iff.not.trans not_forall
```

-- snippet 13
```lean
-- Mathlib.Logic.Function.Basic.injective_comp_right_iff_surjective (L201-L213)
theorem injective_comp_right_iff_surjective {γ : Type*} [Nontrivial γ] :
    Injective (fun g : β → γ ↦ g ∘ f) ↔ Surjective f := by
refine ⟨not_imp_not.mp fun not_surj inj ↦ not_subsingleton γ ⟨fun c c' ↦ ?_⟩,
    (·.injective_comp_right)⟩
  have ⟨b₀, hb⟩ := not_forall.mp not_surj
  classical have := inj (a₁ := fun _ ↦ c) (a₂ := (if · = b₀ then c' else c)) ?_
  · simpa using congr_fun this b₀
  ext a; simp only [comp_apply, if_neg fun h ↦ hb ⟨a, h⟩]

protected theorem Surjective.right_cancellable (hf : Surjective f) {g₁ g₂ : β → γ} :
    g₁ ∘ f = g₂ ∘ f ↔ g₁ = g₂ :=
  hf.injective_comp_right.eq_iff
```

-- snippet 14
```lean
-- Mathlib.Logic.Function.Basic.onFun_apply (L53-L55)
theorem onFun_apply (f : β → β → γ) (g : α → β) (a b : α) : onFun f g a b = f (g a) (g b) :=
rfl
```

-- snippet 15
```lean
-- Mathlib.Logic.Function.Basic.Bijective (L229-L238)
theorem Bijective.existsUnique_iff {f : α → β} (hf : Bijective f) {p : β → Prop} :
    (∃! y, p y) ↔ ∃! x, p (f x) :=
⟨fun ⟨y, hpy, hy⟩ ↦
    let ⟨x, hx⟩ := hf.surjective y
    ⟨x, by simpa [hx], fun z (hz : p (f z)) ↦ hf.injective <| hx.symm ▸ hy _ hz⟩,
    fun ⟨x, hpx, hx⟩ ↦
    ⟨f x, hpx, fun y hy ↦
      let ⟨z, hz⟩ := hf.surjective y
      hz ▸ congr_arg f (hx _ (by simpa [hz]))⟩⟩
```

-- snippet 16
```lean
-- Mathlib.Logic.Function.Basic.swap_lt (L73-L73)
theorem swap_lt {α} [LT α] : swap (· < · : α → α → _) = (· > ·) := rfl
```

-- snippet 17
```lean
-- Mathlib.Logic.Function.Basic.injective_comp_left_iff (L126-L130)
theorem injective_comp_left_iff [Nonempty α] {g : β → γ} :
    Injective (g ∘ · : (α → β) → α → γ) ↔ Injective g :=
⟨fun h b₁ b₂ eq ↦ Nonempty.elim ‹_›
    (congr_fun <| h (a₁ := fun _ ↦ b₁) (a₂ := fun _ ↦ b₂) <| funext fun _ ↦ eq), (·.comp_left)⟩
```

-- snippet 18
```lean
-- Mathlib.Logic.Function.Basic.swap_le (L74-L74)
theorem swap_le {α} [LE α] : swap (· ≤ · : α → α → _) = (· ≥ ·) := rfl
```

-- snippet 19
```lean
-- Mathlib.Logic.Function.Basic.bijective_iff_existsUnique (L218-L228)
theorem bijective_iff_existsUnique (f : α → β) : Bijective f ↔ ∀ b : β, ∃! a : α, f a = b :=
⟨fun hf b ↦
      let ⟨a, ha⟩ := hf.surjective b
      ⟨a, ha, fun _ ha' ↦ hf.injective (ha'.trans ha.symm)⟩,
    fun he ↦ ⟨fun {_a a'} h ↦ (he (f a')).unique h rfl, fun b ↦ (he b).exists⟩⟩

/-- Shorthand for using projection notation with `Function.bijective_iff_existsUnique`. -/
protected theorem Bijective.existsUnique {f : α → β} (hf : Bijective f) (b : β) :
    ∃! a : α, f a = b :=
  (bijective_iff_existsUnique f).mp hf b
```

-- snippet 20
```lean
-- Mathlib.Logic.Function.Basic.funext_iff_of_subsingleton (L67-L72)
lemma funext_iff_of_subsingleton [Subsingleton α] {g : α → β} (x y : α) :
    f x = g y ↔ f = g := by
refine ⟨fun h ↦ funext fun z ↦ ?_, fun h ↦ ?_⟩
  · rwa [Subsingleton.elim x z, Subsingleton.elim y z] at h
  · rw [h, Subsingleton.elim x y]
```

-- snippet 21
```lean
-- Mathlib.Logic.Function.Basic.eval_apply (L39-L41)
theorem eval_apply {β : α → Sort*} (x : α) (f : ∀ x, β x) : eval x f = f x :=
rfl
```

-- snippet 22
```lean
-- Mathlib.Logic.Function.Basic.Injective (L95-L97)
theorem Injective.of_comp {g : γ → α} (I : Injective (f ∘ g)) : Injective g :=
fun _ _ h ↦ I <| congr_arg f h
```

-- snippet 23
```lean
-- Mathlib.Logic.Function.Basic.not_surjective_Type (L270-L285)
theorem not_surjective_Type {α : Type u} (f : α → Type max u v) : ¬Surjective f := by
intro hf
  let T : Type max u v := Sigma f
  cases hf (Set T) with | intro U hU =>
  let g : Set T → T := fun s ↦ ⟨U, cast hU.symm s⟩
  have hg : Injective g := by
    intro s t h
    suffices cast hU (g s).2 = cast hU (g t).2 by
      simp only [g, cast_cast, cast_eq] at this
      assumption
    · congr
  exact cantor_injective g hg

/-- `g` is a partial inverse to `f` (an injective but not necessarily
  surjective function) if `g y = some x` implies `f x = y`, and `g y = none`
  implies that `y` is not in the range of `f`. -/
```

-- snippet 24
```lean
-- Mathlib.Logic.Function.Basic.hfunext (L56-L63)
lemma hfunext {α α' : Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : ∀ a, β a} {f' : ∀ a, β' a}
    (hα : α = α') (h : ∀ a a', a ≍ a' → f a ≍ f' a') : f ≍ f' := by
subst hα
  have : ∀ a, f a ≍ f' a := fun a ↦ h a a (HEq.refl a)
  have : β = β' := by funext a; exact type_eq_of_heq (this a)
  subst this
  grind
```

-- snippet 25
```lean
-- Mathlib.Logic.Function.Basic.swap_gt (L75-L75)
theorem swap_gt {α} [LT α] : swap (· > · : α → α → _) = (· < ·) := rfl
```

-- snippet 26
```lean
-- Mathlib.Logic.Function.Basic.const_inj (L50-L52)
theorem const_inj [Nonempty α] {y₁ y₂ : β} : const α y₁ = const α y₂ ↔ y₁ = y₂ :=
⟨fun h ↦ const_injective h, fun h ↦ h ▸ rfl⟩
```

-- snippet 27
```lean
-- Mathlib.Logic.Function.Basic.exists_fixed_point_of_surjective (L251-L257)
theorem exists_fixed_point_of_surjective {α β : Type*} (f : α → α → β)
    (hf : Surjective f) (g : β → β) : ∃ x, g x = x :=
let ⟨a, ha⟩ := hf fun a => g (f a a)
  ⟨f a a, (congr_fun ha a).symm⟩

/-- **Cantor's diagonal argument** implies that there are no surjective functions from `α`
to `Set α`. -/
```

-- snippet 28
```lean
-- Mathlib.Logic.Function.Basic.decidableEqPFun (L165-L197)
instance decidableEqPFun (p : Prop) [Decidable p] (α : p → Type*) [∀ hp, DecidableEq (α hp)] :
    DecidableEq (∀ hp, α hp)
  | f, g => decidable_of_iff (∀ hp, f hp = g hp) funext_iff.symm

protected theorem Surjective.forall (hf : Surjective f) {p : β → Prop} :
    (∀ y, p y) ↔ ∀ x, p (f x) :=
⟨fun h x ↦ h (f x), fun h y ↦
    let ⟨x, hx⟩ := hf y
    hx ▸ h x⟩

protected theorem Surjective.forall₂ (hf : Surjective f) {p : β → β → Prop} :
    (∀ y₁ y₂, p y₁ y₂) ↔ ∀ x₁ x₂, p (f x₁) (f x₂) :=
  hf.forall.trans <| forall_congr' fun _ ↦ hf.forall

protected theorem Surjective.forall₃ (hf : Surjective f) {p : β → β → β → Prop} :
    (∀ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∀ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=
  hf.forall.trans <| forall_congr' fun _ ↦ hf.forall₂

protected theorem Surjective.exists (hf : Surjective f) {p : β → Prop} :
    (∃ y, p y) ↔ ∃ x, p (f x) :=
  ⟨fun ⟨y, hy⟩ ↦
    let ⟨x, hx⟩ := hf y
    ⟨x, hx.symm ▸ hy⟩,
    fun ⟨x, hx⟩ ↦ ⟨f x, hx⟩⟩

protected theorem Surjective.exists₂ (hf : Surjective f) {p : β → β → Prop} :
    (∃ y₁ y₂, p y₁ y₂) ↔ ∃ x₁ x₂, p (f x₁) (f x₂) :=
  hf.exists.trans <| exists_congr fun _ ↦ hf.exists

protected theorem Surjective.exists₃ (hf : Surjective f) {p : β → β → β → Prop} :
    (∃ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∃ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃) :=
  hf.exists.trans <| exists_congr fun _ ↦ hf.exists₂
```

-- snippet 29
```lean
-- Mathlib.Logic.Function.Basic.not_injective_iff (L81-L83)
theorem not_injective_iff : ¬ Injective f ↔ ∃ a b, f a = f b ∧ a ≠ b := by
simp only [Injective, not_forall, exists_prop]
```

-- snippet 30
```lean
-- Mathlib.Logic.Function.Basic.cantor_surjective (L258-L263)
theorem cantor_surjective {α} (f : α → Set α) : ¬Surjective f := fun h =>
let ⟨_, hx⟩ := exists_fixed_point_of_surjective f h (¬·)
  not_iff_self (iff_of_eq hx)

/-- **Cantor's diagonal argument** implies that there are no injective functions from `Set α`
to `α`. -/
```

-- snippet 31
```lean
-- Mathlib.Logic.Function.Basic.Surjective (L109-L112)
theorem Surjective.bijective₂_of_injective {g : γ → α} (hf : Surjective f) (hg : Surjective g)
    (I : Injective (f ∘ g)) : Bijective f ∧ Bijective g :=
⟨⟨I.of_comp_right hg, hf⟩, I.of_comp, hg⟩
```

-- snippet 32
```lean
-- Mathlib.Logic.Function.Basic.swap_ge (L76-L80)
theorem swap_ge {α} [LE α] : swap (· ≥ · : α → α → _) = (· ≤ ·) := rfl
protected theorem Bijective.injective {f : α → β} (hf : Bijective f) : Injective f := hf.1
protected theorem Bijective.surjective {f : α → β} (hf : Bijective f) : Surjective f := hf.2
```

-- snippet 33
```lean
-- Mathlib.Logic.Function.Basic.const_def (L42-L44)
theorem const_def {y : β} : (fun _ : α ↦ y) = const α y :=
rfl
```

-- snippet 34
```lean
-- Mathlib.Logic.Function.Basic.surjective_of_right_cancellable_Prop (L214-L217)
theorem surjective_of_right_cancellable_Prop (h : ∀ g₁ g₂ : β → Prop, g₁ ∘ f = g₂ ∘ f → g₁ = g₂) :
    Surjective f :=
injective_comp_right_iff_surjective.mp h
```
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Lean.Meta.Simp).

[User]
The following Lean code fails to compile. Fix it.

```lean
def getPropHyps : MetaM (Array FVarId)
:= do _unbalancedParenXYZ
let mut result := #[]
  for localDecl in (← getLCtx) do
    unless localDecl.isAuxDecl do
      if (← isProp localDecl.type) then
        result := result.push localDecl.fvarId
  return result

end Simp

/-- Construct a `SimpTheorems` from a list of names. -/
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=65, messages=[Message(data="Function expected at\n  MetaM\nbut this term has type\n  ?m.1\n\nNote: Expected a function because this term is being applied to the argument\n  (Array FVarId)\n\nHint: The identifier `MetaM` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=1, column=18), pos_end=Position(line=1, column=38), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None), CompilationUnit(i_begin=65, i_end=273, messages=[Message(data="unexpected token 'let'; expected command", pos=Position(line=3, column=0), pos_end=Position(line=3, column=3), severity=<Severity.ERROR: 3>, kind=None), Message(data='Invalid `end`: There is no current scope to end\n\nNote: Scopes are introduced using `namespace` and `section`', pos=Position(line=10, column=0), pos_end=Position(line=10, column=8), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None), CompilationUnit(i_begin=273, i_end=328, messages=[Message(data="unexpected end of input; expected 'lemma'", pos=Position(line=12, column=55), pos_end=None, severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Lean.Meta.Simp).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following Lean code fails to compile. Fix it.

```lean
def getPropHyps : MetaM (Array FVarId)
:= do _unbalancedParenXYZ
let mut result := #[]
  for localDecl in (← getLCtx) do
    unless localDecl.isAuxDecl do
      if (← isProp localDecl.type) then
        result := result.push localDecl.fvarId
  return result

end Simp

/-- Construct a `SimpTheorems` from a list of names. -/
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=65, messages=[Message(data="Function expected at\n  MetaM\nbut this term has type\n  ?m.1\n\nNote: Expected a function because this term is being applied to the argument\n  (Array FVarId)\n\nHint: The identifier `MetaM` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=1, column=18), pos_end=Position(line=1, column=38), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None), CompilationUnit(i_begin=65, i_end=273, messages=[Message(data="unexpected token 'let'; expected command", pos=Position(line=3, column=0), pos_end=Position(line=3, column=3), severity=<Severity.ERROR: 3>, kind=None), Message(data='Invalid `end`: There is no current scope to end\n\nNote: Scopes are introduced using `namespace` and `section`', pos=Position(line=10, column=0), pos_end=Position(line=10, column=8), severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None), CompilationUnit(i_begin=273, i_end=328, messages=[Message(data="unexpected end of input; expected 'lemma'", pos=Position(line=12, column=55), pos_end=None, severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Tactic.Simproc.Factors).

[User]
Complete the following proof.

```lean
theorem FactorsHelper.nil {a : ℕ} : FactorsHelper 1 a []
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Tactic.Simproc.Factors).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Complete the following proof.

```lean
theorem FactorsHelper.nil {a : ℕ} : FactorsHelper 1 a []
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Dynamics.TopologicalEntropy.Subset).

[User]
The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.Dynamics.TopologicalEntropy.Subset.coverEntropy_closure`:
State 0: ⊢ theorem coverEntropy_closure (h : Continuous T) :
    coverEntropy T (closure F) = coverEntropy T F
Tactic: refine (iSup₂_le fun U U_uni ↦ ?_).antisymm (coverEntropy_monotone T subset_closure)
State 1: ⊢ <goal after refine (iSup₂_le fun U U_uni ↦ ?_).antisymm (coverEntropy_monotone T subset_closure)>
Tactic: obtain ⟨V, V_uni, V_U⟩ := comp_mem_uniformity_sets U_uni
State 2: ⊢ <goal after obtain ⟨V, V_uni, V_U⟩ := comp_mem_uniformity_sets U_uni>
Tactic: exact le_iSup₂_of_le V V_uni ((coverEntropyEntourage_antitone T (closure F) V_U).trans  (coverEntropyEntourage_closure h F V V_uni))  end Closure  /-! ### Finite unions -/  section Union
```

Question: what is the next tactic after the last recorded state, and why?

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Dynamics.TopologicalEntropy.Subset).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.Dynamics.TopologicalEntropy.Subset.coverEntropy_closure`:
State 0: ⊢ theorem coverEntropy_closure (h : Continuous T) :
    coverEntropy T (closure F) = coverEntropy T F
Tactic: refine (iSup₂_le fun U U_uni ↦ ?_).antisymm (coverEntropy_monotone T subset_closure)
State 1: ⊢ <goal after refine (iSup₂_le fun U U_uni ↦ ?_).antisymm (coverEntropy_monotone T subset_closure)>
Tactic: obtain ⟨V, V_uni, V_U⟩ := comp_mem_uniformity_sets U_uni
State 2: ⊢ <goal after obtain ⟨V, V_uni, V_U⟩ := comp_mem_uniformity_sets U_uni>
Tactic: exact le_iSup₂_of_le V V_uni ((coverEntropyEntourage_antitone T (closure F) V_U).trans  (coverEntropyEntourage_closure h F V V_uni))  end Closure  /-! ### Finite unions -/  section Union
```

Question: what is the next tactic after the last recorded state, and why?[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Dynamics.TopologicalEntropy.CoverEntropy).

[User]
The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.Dynamics.TopologicalEntropy.CoverEntropy.nonempty_inter_of_coverMincard`:
State 0: ⊢ lemma nonempty_inter_of_coverMincard [U.IsSymm] {s : Finset X} (h : IsDynCoverOf T F U n s)
    (h' : #s = coverMincard T F U n) :
    ∀ x ∈ s, (F ∩ ball x (dynEntourage T U n)).Nonempty
Tactic: have smaller_cover : IsDynCoverOf T F U n (s.erase x) := by
State 1: ⊢ <goal after have smaller_cover : IsDynCoverOf T F U n (s.erase x) := by>
Tactic: intro y y_F  specialize h y_F
State 2: ⊢ <goal after intro y y_F>
Tactic: simp only [s.mem_coe] at h
State 3: ⊢ <goal after simp only [s.mem_coe] at h>
Tactic: simp only [s.coe_erase, mem_diff, s.mem_coe, mem_singleton_iff]
State 4: ⊢ <goal after simp only [s.coe_erase, mem_diff, s.mem_coe, mem_singleton_iff]>
Tactic: obtain ⟨z, z_s, hz⟩ := h
State 5: ⊢ <goal after obtain ⟨z, z_s, hz⟩ := h>
Tactic: refine ⟨z, ⟨z_s, fun z_x ↦ notMem_empty y ?_⟩, hz⟩
State 6: ⊢ <goal after refine ⟨z, ⟨z_s, fun z_x ↦ notMem_empty y ?_⟩, hz⟩>
Tactic: rw [← ball_empt]
State 7: ⊢ <goal after rw [← ball_empt]>
Tactic: rw [z_x] at hz
State 8: ⊢ <goal after rw [z_x] at hz>
Tactic: exact mem_inter y_F <| (dynEntourage T U n).symm hz
State 9: ⊢ <goal after exact mem_inter y_F <| (dynEntourage T U n).symm hz>
Tactic: apply smaller_cover.coverMincard_le_card.not_gt
State 10: ⊢ <goal after apply smaller_cover.coverMincard_le_card.not_gt>
Tactic: rw [← h']  exact_mod_cast s.card_erase_lt_of_mem x_s  /-! ### Cover entropy of entourages -/  open ENNReal EReal ExpGrowth Filter  /-- The entropy of an entourage `U`, defined as the exponential rate of growth of the size  of the smallest `(U, n)`-refined cover of `F`. Takes values in the space of extended real numbers  `[-∞, +∞]`. This first version uses a `limsup`, and is chosen as the default definition. -/  noncomputable def coverEntropyEntourage (T : X → X) (F : Set X) (U : SetRel X X) :=  expGrowthSup fun n : ℕ ↦ coverMincard T F U n  /-- The entropy of an entourage `U`, defined as the exponential rate of growth of the size  of the smallest `(U, n)`-refined cover of `F`. Takes values in the space of extended real numbers  `[-∞, +∞]`. This second version uses a `liminf`, and is chosen as an alternative definition. -/  noncomputable def coverEntropyInfEntourage (T : X → X) (F : Set X) (U : SetRel X X) :=  expGrowthInf fun n : ℕ ↦ coverMincard T F U n
```

Question: what is the next tactic after the last recorded state, and why?

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Dynamics.TopologicalEntropy.CoverEntropy).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.Dynamics.TopologicalEntropy.CoverEntropy.nonempty_inter_of_coverMincard`:
State 0: ⊢ lemma nonempty_inter_of_coverMincard [U.IsSymm] {s : Finset X} (h : IsDynCoverOf T F U n s)
    (h' : #s = coverMincard T F U n) :
    ∀ x ∈ s, (F ∩ ball x (dynEntourage T U n)).Nonempty
Tactic: have smaller_cover : IsDynCoverOf T F U n (s.erase x) := by
State 1: ⊢ <goal after have smaller_cover : IsDynCoverOf T F U n (s.erase x) := by>
Tactic: intro y y_F  specialize h y_F
State 2: ⊢ <goal after intro y y_F>
Tactic: simp only [s.mem_coe] at h
State 3: ⊢ <goal after simp only [s.mem_coe] at h>
Tactic: simp only [s.coe_erase, mem_diff, s.mem_coe, mem_singleton_iff]
State 4: ⊢ <goal after simp only [s.coe_erase, mem_diff, s.mem_coe, mem_singleton_iff]>
Tactic: obtain ⟨z, z_s, hz⟩ := h
State 5: ⊢ <goal after obtain ⟨z, z_s, hz⟩ := h>
Tactic: refine ⟨z, ⟨z_s, fun z_x ↦ notMem_empty y ?_⟩, hz⟩
State 6: ⊢ <goal after refine ⟨z, ⟨z_s, fun z_x ↦ notMem_empty y ?_⟩, hz⟩>
Tactic: rw [← ball_empt]
State 7: ⊢ <goal after rw [← ball_empt]>
Tactic: rw [z_x] at hz
State 8: ⊢ <goal after rw [z_x] at hz>
Tactic: exact mem_inter y_F <| (dynEntourage T U n).symm hz
State 9: ⊢ <goal after exact mem_inter y_F <| (dynEntourage T U n).symm hz>
Tactic: apply smaller_cover.coverMincard_le_card.not_gt
State 10: ⊢ <goal after apply smaller_cover.coverMincard_le_card.not_gt>
Tactic: rw [← h']  exact_mod_cast s.card_erase_lt_of_mem x_s  /-! ### Cover entropy of entourages -/  open ENNReal EReal ExpGrowth Filter  /-- The entropy of an entourage `U`, defined as the exponential rate of growth of the size  of the smallest `(U, n)`-refined cover of `F`. Takes values in the space of extended real numbers  `[-∞, +∞]`. This first version uses a `limsup`, and is chosen as the default definition. -/  noncomputable def coverEntropyEntourage (T : X → X) (F : Set X) (U : SetRel X X) :=  expGrowthSup fun n : ℕ ↦ coverMincard T F U n  /-- The entropy of an entourage `U`, defined as the exponential rate of growth of the size  of the smallest `(U, n)`-refined cover of `F`. Takes values in the space of extended real numbers  `[-∞, +∞]`. This second version uses a `liminf`, and is chosen as an alternative definition. -/  noncomputable def coverEntropyInfEntourage (T : X → X) (F : Set X) (U : SetRel X X) :=  expGrowthInf fun n : ℕ ↦ coverMincard T F U n
```

Question: what is the next tactic after the last recorded state, and why?[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Relation).

[User]
The following Lean code fails to compile. Fix it.

```lean
theorem ReflTransGen.lift {p : β → β → Prop} {a b : α} (f : α → β)
    (h : ∀ a b, r a b → p (f a) (f b)) (hab : ReflTransGen r a b) : ReflTransGen p (f a) (f b)
:= thisIsWrongLemmaNameXYZ
ReflTransGen.trans_induction_on hab (fun _ ↦ refl) (ReflTransGen.single ∘ h _ _) fun _ _ ↦ trans
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=306, messages=[Message(data="Function expected at\n  r\nbut this term has type\n  ?m.3\n\nNote: Expected a function because this term is being applied to the argument\n  a\n\nHint: The identifier `r` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=2, column=16), pos_end=Position(line=2, column=21), severity=<Severity.ERROR: 3>, kind=None), Message(data="Function expected at\n  ReflTransGen\nbut this term has type\n  ?m.4\n\nNote: Expected a function because this term is being applied to the argument\n  r\n\nHint: The identifier `ReflTransGen` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=2, column=46), pos_end=Position(line=2, column=64), severity=<Severity.ERROR: 3>, kind=None), Message(data="Function expected at\n  ReflTransGen\nbut this term has type\n  ?m.4\n\nNote: Expected a function because this term is being applied to the argument\n  p\n\nHint: The identifier `ReflTransGen` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=2, column=68), pos_end=Position(line=2, column=94), severity=<Severity.ERROR: 3>, kind=None), Message(data='Unknown identifier `thisIsWrongLemmaNameXYZ`', pos=Position(line=3, column=3), pos_end=Position(line=3, column=26), severity=<Severity.ERROR: 3>, kind='lean.unknownIdentifier._namedError')], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Relation).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following Lean code fails to compile. Fix it.

```lean
theorem ReflTransGen.lift {p : β → β → Prop} {a b : α} (f : α → β)
    (h : ∀ a b, r a b → p (f a) (f b)) (hab : ReflTransGen r a b) : ReflTransGen p (f a) (f b)
:= thisIsWrongLemmaNameXYZ
ReflTransGen.trans_induction_on hab (fun _ ↦ refl) (ReflTransGen.single ∘ h _ _) fun _ _ ↦ trans
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=306, messages=[Message(data="Function expected at\n  r\nbut this term has type\n  ?m.3\n\nNote: Expected a function because this term is being applied to the argument\n  a\n\nHint: The identifier `r` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=2, column=16), pos_end=Position(line=2, column=21), severity=<Severity.ERROR: 3>, kind=None), Message(data="Function expected at\n  ReflTransGen\nbut this term has type\n  ?m.4\n\nNote: Expected a function because this term is being applied to the argument\n  r\n\nHint: The identifier `ReflTransGen` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=2, column=46), pos_end=Position(line=2, column=64), severity=<Severity.ERROR: 3>, kind=None), Message(data="Function expected at\n  ReflTransGen\nbut this term has type\n  ?m.4\n\nNote: Expected a function because this term is being applied to the argument\n  p\n\nHint: The identifier `ReflTransGen` is unknown, and Lean's `autoImplicit` option causes an unknown identifier to be treated as an implicitly bound variable with an unknown type. However, the unknown type cannot be a function, and a function is what Lean expects here. This is often the result of a typo or a missing `import` or `open` statement.", pos=Position(line=2, column=68), pos_end=Position(line=2, column=94), severity=<Severity.ERROR: 3>, kind=None), Message(data='Unknown identifier `thisIsWrongLemmaNameXYZ`', pos=Position(line=3, column=3), pos_end=Position(line=3, column=26), severity=<Severity.ERROR: 3>, kind='lean.unknownIdentifier._namedError')], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.DoldKan.GammaCompN).

[User]
The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.AlgebraicTopology.DoldKan.GammaCompN.N₁Γ₀_app`:
State 0: ⊢ theorem N₁Γ₀_app (K : ChainComplex C ℕ) :
    N₁Γ₀.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.symm ≪≫
      (toKaroubi _).mapIso (Γ₀NondegComplexIso K)
Tactic: ext
State 1: ⊢ <goal after ext>
Tactic: simp [N₁Γ₀, Γ₀'CompNondegComplexFunctor]
```

Question: what is the next tactic after the last recorded state, and why?

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.DoldKan.GammaCompN).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.AlgebraicTopology.DoldKan.GammaCompN.N₁Γ₀_app`:
State 0: ⊢ theorem N₁Γ₀_app (K : ChainComplex C ℕ) :
    N₁Γ₀.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.symm ≪≫
      (toKaroubi _).mapIso (Γ₀NondegComplexIso K)
Tactic: ext
State 1: ⊢ <goal after ext>
Tactic: simp [N₁Γ₀, Γ₀'CompNondegComplexFunctor]
```

Question: what is the next tactic after the last recorded state, and why?[/INST]


Instruction: Edit `shift` so it still compiles and the proof is simplified where possible. Return the full updated `shift` block.

[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.ExtraDegeneracy).

[User]
You are editing a file in `Mathlib/AlgebraicTopology/ExtraDegeneracy.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.AlgebraicTopology.ExtraDegeneracy.shift`, L170-L225)
```lean
def shift {n : ℕ} {Δ : SimplexCategory} (f : ⦋n⦌ ⟶ Δ) : ⦋n + 1⦌ ⟶ Δ := SimplexCategory.Hom.mk
    { toFun := shiftFun f.toOrderHom
      monotone' := fun i₁ i₂ hi => by
        by_cases h₁ : i₁ = 0
        · subst h₁
          simp only [shiftFun_zero, Fin.zero_le]
        · have h₂ : i₂ ≠ 0 := by
            rintro rfl
            exact h₁ (le_antisymm hi (Fin.zero_le _))
          obtain ⟨j₁, hj₁⟩ := Fin.eq_succ_of_ne_zero h₁
          obtain ⟨j₂, hj₂⟩ := Fin.eq_succ_of_ne_zero h₂
          substs hj₁ hj₂
          simpa only [shiftFun_succ] using f.toOrderHom.monotone (Fin.succ_le_succ_iff.mp hi) }

set_option backward.isDefEq.respectTransparency false in
open SSet.stdSimplex in
/-- The obvious extra degeneracy on the standard simplex. -/
protected noncomputable def extraDegeneracy (Δ : SimplexCategory) :
    SimplicialObject.Augmented.ExtraDegeneracy (stdSimplex.obj Δ) where
  s' _ := objMk (OrderHom.const _ 0)
  s _ f := objEquiv.symm (shift (objEquiv f))
  s'_comp_ε := by
    dsimp
    subsingleton
  s₀_comp_δ₁ := by
    dsimp
    ext1 x
    apply objEquiv.injective
    ext j
    fin_cases j
    rfl
  s_comp_δ₀ n := by
    ext1 φ
    apply objEquiv.injective
    apply SimplexCategory.Hom.ext
    ext i : 2
    dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.stdSimplex,
      objEquiv, Equiv.ulift, uliftFunctor]
  s_comp_δ n i := by
    ext1 φ
    apply objEquiv.injective
    apply SimplexCategory.Hom.ext
    ext j : 2
    dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.stdSimplex,
      objEquiv, Equiv.ulift, uliftFunctor]
    cases j using Fin.cases <;> simp
  s_comp_σ n i := by
    ext1 φ
    apply objEquiv.injective
    apply SimplexCategory.Hom.ext
    ext j : 2
    dsimp [SimplicialObject.σ, SimplexCategory.σ, SSet.stdSimplex, objEquiv, Equiv.ulift,
      uliftFunctor, Function.comp_def]
    cases j using Fin.cases <;> simp
```

## Edit instruction
Edit `shift` so it still compiles and the proof is simplified where possible. Return the full updated `shift` block.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.ExtraDegeneracy).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]You are editing a file in `Mathlib/AlgebraicTopology/ExtraDegeneracy.lean` (mathlib commit 5e932f97dd25535344f80f9dd8da3aab83df0fe6).

## Current excerpt (around `Mathlib.AlgebraicTopology.ExtraDegeneracy.shift`, L170-L225)
```lean
def shift {n : ℕ} {Δ : SimplexCategory} (f : ⦋n⦌ ⟶ Δ) : ⦋n + 1⦌ ⟶ Δ := SimplexCategory.Hom.mk
    { toFun := shiftFun f.toOrderHom
      monotone' := fun i₁ i₂ hi => by
        by_cases h₁ : i₁ = 0
        · subst h₁
          simp only [shiftFun_zero, Fin.zero_le]
        · have h₂ : i₂ ≠ 0 := by
            rintro rfl
            exact h₁ (le_antisymm hi (Fin.zero_le _))
          obtain ⟨j₁, hj₁⟩ := Fin.eq_succ_of_ne_zero h₁
          obtain ⟨j₂, hj₂⟩ := Fin.eq_succ_of_ne_zero h₂
          substs hj₁ hj₂
          simpa only [shiftFun_succ] using f.toOrderHom.monotone (Fin.succ_le_succ_iff.mp hi) }

set_option backward.isDefEq.respectTransparency false in
open SSet.stdSimplex in
/-- The obvious extra degeneracy on the standard simplex. -/
protected noncomputable def extraDegeneracy (Δ : SimplexCategory) :
    SimplicialObject.Augmented.ExtraDegeneracy (stdSimplex.obj Δ) where
  s' _ := objMk (OrderHom.const _ 0)
  s _ f := objEquiv.symm (shift (objEquiv f))
  s'_comp_ε := by
    dsimp
    subsingleton
  s₀_comp_δ₁ := by
    dsimp
    ext1 x
    apply objEquiv.injective
    ext j
    fin_cases j
    rfl
  s_comp_δ₀ n := by
    ext1 φ
    apply objEquiv.injective
    apply SimplexCategory.Hom.ext
    ext i : 2
    dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.stdSimplex,
      objEquiv, Equiv.ulift, uliftFunctor]
  s_comp_δ n i := by
    ext1 φ
    apply objEquiv.injective
    apply SimplexCategory.Hom.ext
    ext j : 2
    dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.stdSimplex,
      objEquiv, Equiv.ulift, uliftFunctor]
    cases j using Fin.cases <;> simp
  s_comp_σ n i := by
    ext1 φ
    apply objEquiv.injective
    apply SimplexCategory.Hom.ext
    ext j : 2
    dsimp [SimplicialObject.σ, SimplexCategory.σ, SSet.stdSimplex, objEquiv, Equiv.ulift,
      uliftFunctor, Function.comp_def]
    cases j using Fin.cases <;> simp
```

## Edit instruction
Edit `shift` so it still compiles and the proof is simplified where possible. Return the full updated `shift` block.
[/INST]


Instruction: Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.SimplicialSet.NerveAdjunction).

[User]
Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
lemma spineEquiv_f₂_arrow_one (x : X _⦋2⦌₂) :
    ((hY.spineEquiv 2) (f₂ f₀ f₁ hδ₁ hδ₀ hY x)).arrow 1 = f₁ (X.map (δ₂ 0).op x)
```

Declaration: `Mathlib.AlgebraicTopology.SimplicialSet.NerveAdjunction.spineEquiv_f₂_arrow_one` (module Mathlib.AlgebraicTopology.SimplicialSet.NerveAdjunction).

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.SimplicialSet.NerveAdjunction).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
lemma spineEquiv_f₂_arrow_one (x : X _⦋2⦌₂) :
    ((hY.spineEquiv 2) (f₂ f₀ f₁ hδ₁ hδ₀ hY x)).arrow 1 = f₁ (X.map (δ₂ 0).op x)
```

Declaration: `Mathlib.AlgebraicTopology.SimplicialSet.NerveAdjunction.spineEquiv_f₂_arrow_one` (module Mathlib.AlgebraicTopology.SimplicialSet.NerveAdjunction).[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Computability.NFA).

[User]
The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.Computability.NFA.disjoint_stepSet_reverse`:
State 0: ⊢ theorem disjoint_stepSet_reverse {a : α} {S S' : Set σ} :
    Disjoint S (M.reverse.stepSet S' a) ↔ Disjoint S' (M.stepSet S a)
Tactic: rw [← not_iff_not]
State 1: ⊢ <goal after rw [← not_iff_not]>
Tactic: simp only [Set.not_disjoint_iff, mem_stepSet, reverse_step, Set.mem_setOf_eq]  tauto
```

Question: what is the next tactic after the last recorded state, and why?

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Computability.NFA).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following proof-state transcript was extracted from a real mathlib proof. Use it to answer the question below.

```text
Proof-state transcript for `Mathlib.Computability.NFA.disjoint_stepSet_reverse`:
State 0: ⊢ theorem disjoint_stepSet_reverse {a : α} {S S' : Set σ} :
    Disjoint S (M.reverse.stepSet S' a) ↔ Disjoint S' (M.stepSet S a)
Tactic: rw [← not_iff_not]
State 1: ⊢ <goal after rw [← not_iff_not]>
Tactic: simp only [Set.not_disjoint_iff, mem_stepSet, reverse_step, Set.mem_setOf_eq]  tauto
```

Question: what is the next tactic after the last recorded state, and why?[/INST]


Instruction: Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Equiv.Option).

[User]
Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
theorem optionCongr_refl : optionCongr (Equiv.refl α) = Equiv.refl _
```

Declaration: `Mathlib.Logic.Equiv.Option.optionCongr_refl` (module Mathlib.Logic.Equiv.Option).

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Equiv.Option).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Explain the Lean statement below in plain mathematical language, then formalize a short related example in Lean 4.

```lean
theorem optionCongr_refl : optionCongr (Equiv.refl α) = Equiv.refl _
```

Declaration: `Mathlib.Logic.Equiv.Option.optionCongr_refl` (module Mathlib.Logic.Equiv.Option).[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Equiv.PartialEquiv).

[User]
Complete the following proof.

```lean
theorem exists_mem_target {p : β → Prop} : (∃ y ∈ e.target, p y) ↔ ∃ x ∈ e.source, p (e x)
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Logic.Equiv.PartialEquiv).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Complete the following proof.

```lean
theorem exists_mem_target {p : β → Prop} : (∃ y ∈ e.target, p y) ↔ ∃ x ∈ e.source, p (e x)
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Computability.TuringMachine.StackTuringMachine).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
def SupportsStmt (S : Finset Λ) : Stmt Γ Λ σ → Prop
  | push _ _ q => SupportsStmt S q
  | peek _ _ q => SupportsStmt S q
  | pop _ _ q => SupportsStmt S q
  | load _ q => SupportsStmt S q
  | branch _ q₁ q₂ => SupportsStmt S q₁ ∧ SupportsStmt S q₂
  | goto l => ∀ v, l v ∈ S
  | halt => True
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.Stmt (L138-L151)
instance Stmt.inhabited : Inhabited (Stmt Γ Λ σ)
```

-- snippet 2
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.Cfg (L152-L156)
instance Cfg.inhabited [Inhabited σ] : Inhabited (Cfg Γ Λ σ)
```

-- snippet 3
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stepAux (L161-L170)
def stepAux : Stmt Γ Λ σ → σ → (∀ k, List (Γ k)) → Cfg Γ Λ σ
  | push k f q, v, S => stepAux q v (update S k (f v :: S k))
  | peek k f q, v, S => stepAux q (f v (S k).head?) S
  | pop k f q, v, S => stepAux q (f v (S k).head?) (update S k (S k).tail)
  | load a q, v, S => stepAux q (a v) S
  | branch f q₁ q₂, v, S => cond (f v) (stepAux q₁ v S) (stepAux q₂ v S)
  | goto f, v, S => ⟨some (f v), v, S⟩
  | halt, v, S => ⟨none, v, S⟩

/-- The step function for the TM2 model. -/
```

-- snippet 4
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.step (L171-L174)
def step (M : Λ → Stmt Γ Λ σ) : Cfg Γ Λ σ → Option (Cfg Γ Λ σ)
  | ⟨none, _, _⟩ => none
  | ⟨some l, v, S⟩ => some (stepAux (M l) v S)
```

-- snippet 5
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.Reaches (L179-L181)
def Reaches (M : Λ → Stmt Γ Λ σ) : Cfg Γ Λ σ → Cfg Γ Λ σ → Prop
```

-- snippet 6
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stmts₁_self (L207-L209)
theorem stmts₁_self {q : Stmt Γ Λ σ} : q ∈ stmts₁ q
```

-- snippet 7
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stmts₁_trans (L210-L229)
theorem stmts₁_trans {q₁ q₂ : Stmt Γ Λ σ} : q₁ ∈ stmts₁ q₂ → stmts₁ q₁ ⊆ stmts₁ q₂
```

-- snippet 8
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stmts₁_supportsStmt_mono (L230-L244)
theorem stmts₁_supportsStmt_mono {S : Finset Λ} {q₁ q₂ : Stmt Γ Λ σ} (h : q₁ ∈ stmts₁ q₂)
    (hs : SupportsStmt S q₂) : SupportsStmt S q₁
```

-- snippet 9
```lean
-- Mathlib.Computability.TuringMachine.Computable.inhabitedσ (L83-L86)
instance inhabitedσ : Inhabited tm.σ
```

-- snippet 10
```lean
-- Mathlib.Computability.TuringMachine.Computable.decidableEqK (L80-L82)
instance decidableEqK : DecidableEq tm.K
```

-- snippet 11
```lean
-- Mathlib.Computability.TuringMachine.Computable.Cfg (L94-L96)
def Cfg : Type
```

-- snippet 12
```lean
-- Mathlib.Computability.TuringMachine.Computable.inhabitedStmt (L90-L93)
instance inhabitedStmt : Inhabited (Stmt tm)
```

-- snippet 13
```lean
-- Mathlib.Computability.TuringMachine.Computable.Stmt (L87-L89)
def Stmt : Type
```

-- snippet 14
```lean
-- Mathlib.Computability.TuringMachine.Computable.inhabitedCfg (L97-L100)
instance inhabitedCfg : Inhabited (Cfg tm)
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Computability.TuringMachine.StackTuringMachine).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
def SupportsStmt (S : Finset Λ) : Stmt Γ Λ σ → Prop
  | push _ _ q => SupportsStmt S q
  | peek _ _ q => SupportsStmt S q
  | pop _ _ q => SupportsStmt S q
  | load _ q => SupportsStmt S q
  | branch _ q₁ q₂ => SupportsStmt S q₁ ∧ SupportsStmt S q₂
  | goto l => ∀ v, l v ∈ S
  | halt => True
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.Stmt (L138-L151)
instance Stmt.inhabited : Inhabited (Stmt Γ Λ σ)
```

-- snippet 2
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.Cfg (L152-L156)
instance Cfg.inhabited [Inhabited σ] : Inhabited (Cfg Γ Λ σ)
```

-- snippet 3
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stepAux (L161-L170)
def stepAux : Stmt Γ Λ σ → σ → (∀ k, List (Γ k)) → Cfg Γ Λ σ
  | push k f q, v, S => stepAux q v (update S k (f v :: S k))
  | peek k f q, v, S => stepAux q (f v (S k).head?) S
  | pop k f q, v, S => stepAux q (f v (S k).head?) (update S k (S k).tail)
  | load a q, v, S => stepAux q (a v) S
  | branch f q₁ q₂, v, S => cond (f v) (stepAux q₁ v S) (stepAux q₂ v S)
  | goto f, v, S => ⟨some (f v), v, S⟩
  | halt, v, S => ⟨none, v, S⟩

/-- The step function for the TM2 model. -/
```

-- snippet 4
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.step (L171-L174)
def step (M : Λ → Stmt Γ Λ σ) : Cfg Γ Λ σ → Option (Cfg Γ Λ σ)
  | ⟨none, _, _⟩ => none
  | ⟨some l, v, S⟩ => some (stepAux (M l) v S)
```

-- snippet 5
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.Reaches (L179-L181)
def Reaches (M : Λ → Stmt Γ Λ σ) : Cfg Γ Λ σ → Cfg Γ Λ σ → Prop
```

-- snippet 6
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stmts₁_self (L207-L209)
theorem stmts₁_self {q : Stmt Γ Λ σ} : q ∈ stmts₁ q
```

-- snippet 7
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stmts₁_trans (L210-L229)
theorem stmts₁_trans {q₁ q₂ : Stmt Γ Λ σ} : q₁ ∈ stmts₁ q₂ → stmts₁ q₁ ⊆ stmts₁ q₂
```

-- snippet 8
```lean
-- Mathlib.Computability.TuringMachine.StackTuringMachine.stmts₁_supportsStmt_mono (L230-L244)
theorem stmts₁_supportsStmt_mono {S : Finset Λ} {q₁ q₂ : Stmt Γ Λ σ} (h : q₁ ∈ stmts₁ q₂)
    (hs : SupportsStmt S q₂) : SupportsStmt S q₁
```

-- snippet 9
```lean
-- Mathlib.Computability.TuringMachine.Computable.inhabitedσ (L83-L86)
instance inhabitedσ : Inhabited tm.σ
```

-- snippet 10
```lean
-- Mathlib.Computability.TuringMachine.Computable.decidableEqK (L80-L82)
instance decidableEqK : DecidableEq tm.K
```

-- snippet 11
```lean
-- Mathlib.Computability.TuringMachine.Computable.Cfg (L94-L96)
def Cfg : Type
```

-- snippet 12
```lean
-- Mathlib.Computability.TuringMachine.Computable.inhabitedStmt (L90-L93)
instance inhabitedStmt : Inhabited (Stmt tm)
```

-- snippet 13
```lean
-- Mathlib.Computability.TuringMachine.Computable.Stmt (L87-L89)
def Stmt : Type
```

-- snippet 14
```lean
-- Mathlib.Computability.TuringMachine.Computable.inhabitedCfg (L97-L100)
instance inhabitedCfg : Inhabited (Cfg tm)
```
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.SimplexCategory.Basic).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
def intervalEdge {n} (j l : ℕ) (hjl : j + l ≤ n) : ⦋1⦌ ⟶ ⦋n⦌
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.congr_toOrderHom_apply (L42-L45)
lemma congr_toOrderHom_apply {a b : SimplexCategory} {f g : a ⟶ b} (h : f = g)
    (x : Fin (a.len + 1)) : f.toOrderHom x = g.toOrderHom x := by rw [h]
/-- The constant morphism from ⦋0⦌. -/
```

-- snippet 2
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const (L46-L48)
def const (x y : SimplexCategory) (i : Fin (y.len + 1)) : x ⟶ y :=
Hom.mk <| ⟨fun _ => i, by tauto⟩
```

-- snippet 3
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_eq_id (L50-L51)
lemma const_eq_id : const ⦋0⦌ ⦋0⦌ 0 = 𝟙 _ := by aesop
```

-- snippet 4
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_apply (L53-L55)
lemma const_apply (x y : SimplexCategory) (i : Fin (y.len + 1)) (a : Fin (x.len + 1)) :
    (const x y i).toOrderHom a = i := rfl
```

-- snippet 5
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_comp (L57-L61)
theorem const_comp (x : SimplexCategory) {y z : SimplexCategory}
    (f : y ⟶ z) (i : Fin (y.len + 1)) :
    const x y i ≫ f = const x z (f.toOrderHom i) :=
rfl
```

-- snippet 6
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_fac_thru_zero (L62-L65)
theorem const_fac_thru_zero (n m : SimplexCategory) (i : Fin (m.len + 1)) :
    const n m i = const n ⦋0⦌ 0 ≫ SimplexCategory.const ⦋0⦌ m i := by
rw [const_comp]; rfl
```

-- snippet 7
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.Hom (L66-L69)
theorem Hom.ext_zero_left {n : SimplexCategory} (f g : ⦋0⦌ ⟶ n)
    (h0 : f.toOrderHom 0 = g.toOrderHom 0 := by rfl) : f = g := by
ext i; match i with | 0 => exact h0 ▸ rfl
```

-- snippet 8
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.eq_const_of_zero (L70-L73)
theorem eq_const_of_zero {n : SimplexCategory} (f : ⦋0⦌ ⟶ n) :
    f = const _ n (f.toOrderHom 0) := by
ext x; match x with | 0 => rfl
```

-- snippet 9
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.exists_eq_const_of_zero (L74-L76)
theorem exists_eq_const_of_zero {n : SimplexCategory} (f : ⦋0⦌ ⟶ n) :
    ∃ a, f = const _ n a := ⟨_, eq_const_of_zero _⟩
```

-- snippet 10
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.eq_const_to_zero (L77-L81)
theorem eq_const_to_zero {n : SimplexCategory} (f : n ⟶ ⦋0⦌) :
    f = const n _ 0 := by
ext : 3
  apply @Subsingleton.elim (Fin 1)
```

-- snippet 11
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.Hom (L82-L90)
theorem Hom.ext_one_left {n : SimplexCategory} (f g : ⦋1⦌ ⟶ n)
    (h0 : f.toOrderHom 0 = g.toOrderHom 0 := by rfl)
(h1 : f.toOrderHom 1 = g.toOrderHom 1 := by rfl) : f = g := by
  ext i
  match i with
  | 0 => exact h0 ▸ rfl
  | 1 => exact h1 ▸ rfl

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 12
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.eq_of_one_to_one (L91-L114)
theorem eq_of_one_to_one (f : ⦋1⦌ ⟶ ⦋1⦌) :
    (∃ a, f = const ⦋1⦌ _ a) ∨ f = 𝟙 _ := by
match e0 : f.toOrderHom 0, e1 : f.toOrderHom 1 with
  | 0, 0 | 1, 1 =>
    refine .inl ⟨f.toOrderHom 0, ?_⟩
    ext i : 3
    match i with
    | 0 => rfl
    | 1 => exact e1.trans e0.symm
  | 0, 1 =>
    right
    ext i : 3
    match i with
    | 0 => exact e0
    | 1 => exact e1
  | 1, 0 =>
    have := f.toOrderHom.monotone (by decide : (0 : Fin 2) ≤ 1)
    rw [e0, e1] at this
    exact Not.elim (by decide) this

/-- Make a morphism `⦋n⦌ ⟶ ⦋m⦌` from a monotone map between fin's.
This is useful for constructing morphisms between `⦋n⦌` directly
without identifying `n` with `⦋n⦌.len`.
-/
```

-- snippet 13
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.mkHom (L116-L119)
def mkHom {n m : ℕ} (f : Fin (n + 1) →o Fin (m + 1)) : ⦋n⦌ ⟶ ⦋m⦌ :=
SimplexCategory.Hom.mk f

/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out a specified `h : i ≤ j` in `Fin (n+1)`. -/
```

-- snippet 14
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.mkOfLe (L120-L127)
def mkOfLe {n} (i j : Fin (n + 1)) (h : i ≤ j) : ⦋1⦌ ⟶ ⦋n⦌ :=
SimplexCategory.mkHom {
    toFun := fun | 0 => i | 1 => j
    monotone' := fun
      | 0, 0, _ | 1, 1, _ => le_rfl
      | 0, 1, _ => h
  }
```

-- snippet 15
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.mkOfLe_refl (L129-L132)
lemma mkOfLe_refl {n} (j : Fin (n + 1)) :
    mkOfLe j j (by lia) = ⦋1⦌.const ⦋n⦌ j := Hom.ext_one_left _ _
/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out the "diagonal composite" edge -/
```

-- snippet 16
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.inclusion (L42-L43)
def inclusion : SimplexCategory ⥤ AugmentedSimplexCategory := WithInitial.incl
```

-- snippet 17
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.id_tensorHom (L136-L139)
lemma id_tensorHom (x : AugmentedSimplexCategory) {y₁ y₂ : AugmentedSimplexCategory}
    (f : y₁ ⟶ y₂) : 𝟙 x ⊗ₘ f = x ◁ f :=
rfl
```

-- snippet 18
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorHom (L79-L93)
def tensorHom {x₁ y₁ x₂ y₂ : AugmentedSimplexCategory} (f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) :
    tensorObj x₁ x₂ ⟶ tensorObj y₁ y₂ :=
match x₁, y₁, x₂, y₂, f₁, f₂ with
  | .of _, .of _, .of _, .of _, f₁, f₂ => tensorHomOf f₁ f₂
  | .of _, .of y₁, .star, .of y₂, f₁, _ =>
    f₁ ≫ ((SimplexCategory.mkHom <| (Fin.castAddOrderEmb (y₂.len + 1)).toOrderHom) ≫
      eqToHom (congrArg _ (Nat.succ_add _ _)) : ⦋y₁.len⦌ ⟶ ⦋y₁.len + y₂.len + 1⦌)
  | .star, .of y₁, .of _, .of y₂, _, f₂ =>
    f₂ ≫ ((SimplexCategory.mkHom <| (Fin.natAddOrderEmb (y₁.len + 1)).toOrderHom) ≫
      eqToHom (congrArg _ (Nat.succ_add _ _)) : ⦋y₂.len⦌ ⟶ ⦋y₁.len + y₂.len + 1⦌)
  | .star, .star, .of _, .of _, _, f₂ => f₂
  | .of _, .of _, .star, .star, f₁, _ => f₁
  | .star, _, .star, _, _, _ => WithInitial.starInitial.to _

/-- The unit for the monoidal structure on `AugmentedSimplexCategory` is the initial object. -/
```

-- snippet 19
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.inl (L157-L161)
def inl (x y : AugmentedSimplexCategory) : x ⟶ x ⊗ y :=
(ρ_ x).inv ≫ _ ◁ (WithInitial.starInitial.to y)

/-- Thanks to `tensorUnit` being initial in `AugmentedSimplexCategory`, we get
a morphism `Δ' ⟶ Δ ⊗ Δ'` for every pair of objects `Δ, Δ'`. -/
```

-- snippet 20
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObject (L87-L93)
def equivAugmentedSimplicialObject :
    (AugmentedSimplexCategoryᵒᵖ ⥤ C) ≌ SimplicialObject.Augmented C :=
WithInitial.opEquiv SimplexCategory |>.congrLeft |>.trans WithTerminal.equivComma

/-- Through the equivalence `(AugmentedSimplexCategoryᵒᵖ ⥤ C) ≌ SimplicialObject.Augmented C`,
dropping the augmentation corresponds to precomposition with
`inclusionᵒᵖ : SimplexCategoryᵒᵖ ⥤ AugmentedSimplexCategoryᵒᵖ`. -/
```

-- snippet 21
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObject (L53-L59)
def equivAugmentedCosimplicialObject :
    (AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C :=
WithInitial.equivComma

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
dropping the augmentation corresponds to precomposition with
`inclusion : SimplexCategory ⥤ AugmentedSimplexCategory`. -/
```

-- snippet 22
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.associator (L97-L111)
def associator (x y z : AugmentedSimplexCategory) :
    tensorObj (tensorObj x y) z ≅ tensorObj x (tensorObj y z) :=
match x, y, z with
  | .of x, .of y, .of z =>
    eqToIso (congrArg (fun j ↦ WithInitial.of <| SimplexCategory.mk j)
      (by simp +arith))
  | .star, .star, .star => Iso.refl _
  | .star, .of _, .star => Iso.refl _
  | .star, .star, .of _ => Iso.refl _
  | .star, .of _, .of _ => Iso.refl _
  | .of _, .star, .star => Iso.refl _
  | .of _, .star, .of _ => Iso.refl _
  | .of _, .of _, .star => Iso.refl _

/-- The left unitor isomorphism for the monoidal structure in `AugmentedSimplexCategory` -/
```

-- snippet 23
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.leftUnitor (L112-L118)
def leftUnitor (x : AugmentedSimplexCategory) :
    tensorObj tensorUnit x ≅ x :=
match x with
  | .of _ => Iso.refl _
  | .star => Iso.refl _

/-- The right unitor isomorphism for the monoidal structure in `AugmentedSimplexCategory` -/
```

-- snippet 24
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObjectFunctorCompDropIso (L95-L101)
def equivAugmentedSimplicialObjectFunctorCompDropIso :
    equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.drop ≅
    (Functor.whiskeringLeft _ _ C).obj inclusion.op :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
taking the point of the augmentation corresponds to evaluation at the initial object. -/
```

-- snippet 25
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.rightUnitor (L119-L124)
def rightUnitor (x : AugmentedSimplexCategory) :
    tensorObj x tensorUnit ≅ x :=
match x with
  | .of _ => Iso.refl _
  | .star => Iso.refl _
```

-- snippet 26
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObjectFunctorCompToArrowIso (L112-L118)
def equivAugmentedSimplicialObjectFunctorCompToArrowIso :
    equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.toArrow ≅
    Functor.mapArrowFunctor _ C ⋙
      (evaluation _ _ |>.obj <| .mk <| .op <| WithInitial.homTo <| .mk 0) :=
.refl _

end AugmentedSimplexCategory
```

-- snippet 27
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObjectFunctorCompDropIso (L61-L67)
def equivAugmentedCosimplicialObjectFunctorCompDropIso :
    equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.drop ≅
    (Functor.whiskeringLeft _ _ C).obj inclusion :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
taking the point of the augmentation corresponds to evaluation at the initial object. -/
```

-- snippet 28
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObjectFunctorCompToArrowIso (L78-L85)
def equivAugmentedCosimplicialObjectFunctorCompToArrowIso :
    equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.toArrow ≅
    Functor.mapArrowFunctor _ C ⋙
      (evaluation _ _ |>.obj <| .mk <| WithInitial.homTo <| .mk 0) :=
.refl _

/-- The equivalence between functors out of `AugmentedSimplexCategory` and augmented simplicial
objects. -/
```

-- snippet 29
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObjectFunctorCompPointIso (L69-L76)
def equivAugmentedCosimplicialObjectFunctorCompPointIso :
    equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.point ≅
    ((evaluation _ _).obj .star : (AugmentedSimplexCategory ⥤ C) ⥤ C) :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
the arrow attached to the cosimplicial object is the one obtained by evaluation at the unique arrow
`star ⟶ of [0]`. -/
```

-- snippet 30
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.AugmentedSimplexCategory (L34-L40)
abbrev AugmentedSimplexCategory := WithInitial SimplexCategory
namespace AugmentedSimplexCategory

variable {C : Type*} [Category* C]

/-- The canonical inclusion from `SimplexCategory` to `AugmentedSimplexCategory`. -/
```

-- snippet 31
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObjectFunctorCompPointIso (L103-L110)
def equivAugmentedSimplicialObjectFunctorCompPointIso :
    equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.point ≅
    (evaluation _ C).obj (.op .star) :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
the arrow attached to the cosimplicial object is the one obtained by evaluation at the unique arrow
`star ⟶ of [0]`. -/
```

-- snippet 32
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.id_star_whiskerRight (L151-L156)
lemma id_star_whiskerRight {x : AugmentedSimplexCategory} : 𝟙 WithInitial.star ▷ x = 𝟙 _ := by
cases x <;>
  rfl

/-- Thanks to `tensorUnit` being initial in `AugmentedSimplexCategory`, we get
a morphism `Δ ⟶ Δ ⊗ Δ'` for every pair of objects `Δ, Δ'`. -/
```

-- snippet 33
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorUnit (L94-L96)
abbrev tensorUnit : AugmentedSimplexCategory := WithInitial.star
/-- The associator isomorphism for the monoidal structure on `AugmentedSimplexCategory` -/
```

-- snippet 34
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.eqToHom_toOrderHom (L40-L49)
lemma eqToHom_toOrderHom {x y : SimplexCategory} (h : WithInitial.of x = WithInitial.of y) :
    SimplexCategory.Hom.toOrderHom (WithInitial.down <| eqToHom h) =
      (Fin.castOrderIso
        (congrArg (fun t ↦ t + 1) (by injection h with h; rw [h]))).toOrderEmbedding.toOrderHom :=
SimplexCategory.eqToHom_toOrderHom (by injection h)

/-- An auxiliary definition for the tensor product of two objects in `AugmentedSimplexCategory`. -/
-- (Impl. note): This definition could easily be inlined in
-- the definition of `tensorObjOf` below, but having it type check directly as an element
-- of `SimplexCategory` avoids having to sprinkle `WithInitial.down` everywhere.
```

-- snippet 35
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorHom_id (L141-L144)
lemma tensorHom_id {x₁ x₂ : AugmentedSimplexCategory} (y : AugmentedSimplexCategory)
    (f : x₁ ⟶ x₂) : f ⊗ₘ 𝟙 y = f ▷ y :=
rfl
```

-- snippet 36
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.inr (L162-L166)
def inr (x y : AugmentedSimplexCategory) : y ⟶ x ⊗ y :=
(λ_ y).inv ≫ (WithInitial.starInitial.to x) ▷ _

/-- To ease type checking, we also provide a version of inl that lives in
`SimplexCategory`. -/
```

-- snippet 37
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.whiskerLeft_id_star (L146-L149)
lemma whiskerLeft_id_star {x : AugmentedSimplexCategory} : x ◁ 𝟙 .star = 𝟙 _ := by
cases x <;>
  rfl
```

-- snippet 38
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorObjOf (L50-L52)
abbrev tensorObjOf (m n : SimplexCategory) : SimplexCategory := .mk (m.len + n.len + 1)
/-- The tensor product of two objects of `AugmentedSimplexCategory`. -/
```

-- snippet 39
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorHomOf (L60-L78)
def tensorHomOf {x₁ y₁ x₂ y₂ : SimplexCategory} (f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) :
    tensorObjOf x₁ x₂ ⟶ tensorObjOf y₁ y₂ :=
letI f₁ : Fin ((x₁.len + 1) + (x₂.len + 1)) →o Fin ((y₁.len + 1) + (y₂.len + 1)) :=
    { toFun i :=
        Fin.addCases
          (motive := fun _ ↦ Fin <| (y₁.len + 1) + (y₂.len + 1))
          (fun i ↦ (f₁.toOrderHom i).castAdd _)
          (fun i ↦ (f₂.toOrderHom i).natAdd _)
          i
      monotone' i j h := by
        cases i using Fin.addCases <;>
        cases j using Fin.addCases <;>
        rw [Fin.le_def] at h ⊢ <;>
        simp at h ⊢ <;>
        grind only [OrderHom.apply_mono] }
  (eqToHom (congrArg _ (Nat.succ_add _ _)).symm ≫ (SimplexCategory.mkHom f₁) ≫
    eqToHom (congrArg _ (Nat.succ_add _ _)) : _ ⟶ ⦋y₁.len + y₂.len + 1⦌)

/-- The action of the tensor product on maps of `AugmentedSimplexCategory`. -/
```

-- snippet 40
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorObj (L53-L59)
def tensorObj (m n : AugmentedSimplexCategory) : AugmentedSimplexCategory :=
match m, n with
  | .of m, .of n => .of <| tensorObjOf m n
  | .star, x => x
  | x, .star => x

/-- The action of the tensor product on maps coming from `SimplexCategory`. -/
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.AlgebraicTopology.SimplexCategory.Basic).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
def intervalEdge {n} (j l : ℕ) (hjl : j + l ≤ n) : ⦋1⦌ ⟶ ⦋n⦌
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.congr_toOrderHom_apply (L42-L45)
lemma congr_toOrderHom_apply {a b : SimplexCategory} {f g : a ⟶ b} (h : f = g)
    (x : Fin (a.len + 1)) : f.toOrderHom x = g.toOrderHom x := by rw [h]
/-- The constant morphism from ⦋0⦌. -/
```

-- snippet 2
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const (L46-L48)
def const (x y : SimplexCategory) (i : Fin (y.len + 1)) : x ⟶ y :=
Hom.mk <| ⟨fun _ => i, by tauto⟩
```

-- snippet 3
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_eq_id (L50-L51)
lemma const_eq_id : const ⦋0⦌ ⦋0⦌ 0 = 𝟙 _ := by aesop
```

-- snippet 4
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_apply (L53-L55)
lemma const_apply (x y : SimplexCategory) (i : Fin (y.len + 1)) (a : Fin (x.len + 1)) :
    (const x y i).toOrderHom a = i := rfl
```

-- snippet 5
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_comp (L57-L61)
theorem const_comp (x : SimplexCategory) {y z : SimplexCategory}
    (f : y ⟶ z) (i : Fin (y.len + 1)) :
    const x y i ≫ f = const x z (f.toOrderHom i) :=
rfl
```

-- snippet 6
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.const_fac_thru_zero (L62-L65)
theorem const_fac_thru_zero (n m : SimplexCategory) (i : Fin (m.len + 1)) :
    const n m i = const n ⦋0⦌ 0 ≫ SimplexCategory.const ⦋0⦌ m i := by
rw [const_comp]; rfl
```

-- snippet 7
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.Hom (L66-L69)
theorem Hom.ext_zero_left {n : SimplexCategory} (f g : ⦋0⦌ ⟶ n)
    (h0 : f.toOrderHom 0 = g.toOrderHom 0 := by rfl) : f = g := by
ext i; match i with | 0 => exact h0 ▸ rfl
```

-- snippet 8
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.eq_const_of_zero (L70-L73)
theorem eq_const_of_zero {n : SimplexCategory} (f : ⦋0⦌ ⟶ n) :
    f = const _ n (f.toOrderHom 0) := by
ext x; match x with | 0 => rfl
```

-- snippet 9
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.exists_eq_const_of_zero (L74-L76)
theorem exists_eq_const_of_zero {n : SimplexCategory} (f : ⦋0⦌ ⟶ n) :
    ∃ a, f = const _ n a := ⟨_, eq_const_of_zero _⟩
```

-- snippet 10
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.eq_const_to_zero (L77-L81)
theorem eq_const_to_zero {n : SimplexCategory} (f : n ⟶ ⦋0⦌) :
    f = const n _ 0 := by
ext : 3
  apply @Subsingleton.elim (Fin 1)
```

-- snippet 11
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.Hom (L82-L90)
theorem Hom.ext_one_left {n : SimplexCategory} (f g : ⦋1⦌ ⟶ n)
    (h0 : f.toOrderHom 0 = g.toOrderHom 0 := by rfl)
(h1 : f.toOrderHom 1 = g.toOrderHom 1 := by rfl) : f = g := by
  ext i
  match i with
  | 0 => exact h0 ▸ rfl
  | 1 => exact h1 ▸ rfl

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 12
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.eq_of_one_to_one (L91-L114)
theorem eq_of_one_to_one (f : ⦋1⦌ ⟶ ⦋1⦌) :
    (∃ a, f = const ⦋1⦌ _ a) ∨ f = 𝟙 _ := by
match e0 : f.toOrderHom 0, e1 : f.toOrderHom 1 with
  | 0, 0 | 1, 1 =>
    refine .inl ⟨f.toOrderHom 0, ?_⟩
    ext i : 3
    match i with
    | 0 => rfl
    | 1 => exact e1.trans e0.symm
  | 0, 1 =>
    right
    ext i : 3
    match i with
    | 0 => exact e0
    | 1 => exact e1
  | 1, 0 =>
    have := f.toOrderHom.monotone (by decide : (0 : Fin 2) ≤ 1)
    rw [e0, e1] at this
    exact Not.elim (by decide) this

/-- Make a morphism `⦋n⦌ ⟶ ⦋m⦌` from a monotone map between fin's.
This is useful for constructing morphisms between `⦋n⦌` directly
without identifying `n` with `⦋n⦌.len`.
-/
```

-- snippet 13
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.mkHom (L116-L119)
def mkHom {n m : ℕ} (f : Fin (n + 1) →o Fin (m + 1)) : ⦋n⦌ ⟶ ⦋m⦌ :=
SimplexCategory.Hom.mk f

/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out a specified `h : i ≤ j` in `Fin (n+1)`. -/
```

-- snippet 14
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.mkOfLe (L120-L127)
def mkOfLe {n} (i j : Fin (n + 1)) (h : i ≤ j) : ⦋1⦌ ⟶ ⦋n⦌ :=
SimplexCategory.mkHom {
    toFun := fun | 0 => i | 1 => j
    monotone' := fun
      | 0, 0, _ | 1, 1, _ => le_rfl
      | 0, 1, _ => h
  }
```

-- snippet 15
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Basic.mkOfLe_refl (L129-L132)
lemma mkOfLe_refl {n} (j : Fin (n + 1)) :
    mkOfLe j j (by lia) = ⦋1⦌.const ⦋n⦌ j := Hom.ext_one_left _ _
/-- The morphism `⦋1⦌ ⟶ ⦋n⦌` that picks out the "diagonal composite" edge -/
```

-- snippet 16
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.inclusion (L42-L43)
def inclusion : SimplexCategory ⥤ AugmentedSimplexCategory := WithInitial.incl
```

-- snippet 17
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.id_tensorHom (L136-L139)
lemma id_tensorHom (x : AugmentedSimplexCategory) {y₁ y₂ : AugmentedSimplexCategory}
    (f : y₁ ⟶ y₂) : 𝟙 x ⊗ₘ f = x ◁ f :=
rfl
```

-- snippet 18
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorHom (L79-L93)
def tensorHom {x₁ y₁ x₂ y₂ : AugmentedSimplexCategory} (f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) :
    tensorObj x₁ x₂ ⟶ tensorObj y₁ y₂ :=
match x₁, y₁, x₂, y₂, f₁, f₂ with
  | .of _, .of _, .of _, .of _, f₁, f₂ => tensorHomOf f₁ f₂
  | .of _, .of y₁, .star, .of y₂, f₁, _ =>
    f₁ ≫ ((SimplexCategory.mkHom <| (Fin.castAddOrderEmb (y₂.len + 1)).toOrderHom) ≫
      eqToHom (congrArg _ (Nat.succ_add _ _)) : ⦋y₁.len⦌ ⟶ ⦋y₁.len + y₂.len + 1⦌)
  | .star, .of y₁, .of _, .of y₂, _, f₂ =>
    f₂ ≫ ((SimplexCategory.mkHom <| (Fin.natAddOrderEmb (y₁.len + 1)).toOrderHom) ≫
      eqToHom (congrArg _ (Nat.succ_add _ _)) : ⦋y₂.len⦌ ⟶ ⦋y₁.len + y₂.len + 1⦌)
  | .star, .star, .of _, .of _, _, f₂ => f₂
  | .of _, .of _, .star, .star, f₁, _ => f₁
  | .star, _, .star, _, _, _ => WithInitial.starInitial.to _

/-- The unit for the monoidal structure on `AugmentedSimplexCategory` is the initial object. -/
```

-- snippet 19
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.inl (L157-L161)
def inl (x y : AugmentedSimplexCategory) : x ⟶ x ⊗ y :=
(ρ_ x).inv ≫ _ ◁ (WithInitial.starInitial.to y)

/-- Thanks to `tensorUnit` being initial in `AugmentedSimplexCategory`, we get
a morphism `Δ' ⟶ Δ ⊗ Δ'` for every pair of objects `Δ, Δ'`. -/
```

-- snippet 20
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObject (L87-L93)
def equivAugmentedSimplicialObject :
    (AugmentedSimplexCategoryᵒᵖ ⥤ C) ≌ SimplicialObject.Augmented C :=
WithInitial.opEquiv SimplexCategory |>.congrLeft |>.trans WithTerminal.equivComma

/-- Through the equivalence `(AugmentedSimplexCategoryᵒᵖ ⥤ C) ≌ SimplicialObject.Augmented C`,
dropping the augmentation corresponds to precomposition with
`inclusionᵒᵖ : SimplexCategoryᵒᵖ ⥤ AugmentedSimplexCategoryᵒᵖ`. -/
```

-- snippet 21
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObject (L53-L59)
def equivAugmentedCosimplicialObject :
    (AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C :=
WithInitial.equivComma

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
dropping the augmentation corresponds to precomposition with
`inclusion : SimplexCategory ⥤ AugmentedSimplexCategory`. -/
```

-- snippet 22
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.associator (L97-L111)
def associator (x y z : AugmentedSimplexCategory) :
    tensorObj (tensorObj x y) z ≅ tensorObj x (tensorObj y z) :=
match x, y, z with
  | .of x, .of y, .of z =>
    eqToIso (congrArg (fun j ↦ WithInitial.of <| SimplexCategory.mk j)
      (by simp +arith))
  | .star, .star, .star => Iso.refl _
  | .star, .of _, .star => Iso.refl _
  | .star, .star, .of _ => Iso.refl _
  | .star, .of _, .of _ => Iso.refl _
  | .of _, .star, .star => Iso.refl _
  | .of _, .star, .of _ => Iso.refl _
  | .of _, .of _, .star => Iso.refl _

/-- The left unitor isomorphism for the monoidal structure in `AugmentedSimplexCategory` -/
```

-- snippet 23
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.leftUnitor (L112-L118)
def leftUnitor (x : AugmentedSimplexCategory) :
    tensorObj tensorUnit x ≅ x :=
match x with
  | .of _ => Iso.refl _
  | .star => Iso.refl _

/-- The right unitor isomorphism for the monoidal structure in `AugmentedSimplexCategory` -/
```

-- snippet 24
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObjectFunctorCompDropIso (L95-L101)
def equivAugmentedSimplicialObjectFunctorCompDropIso :
    equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.drop ≅
    (Functor.whiskeringLeft _ _ C).obj inclusion.op :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
taking the point of the augmentation corresponds to evaluation at the initial object. -/
```

-- snippet 25
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.rightUnitor (L119-L124)
def rightUnitor (x : AugmentedSimplexCategory) :
    tensorObj x tensorUnit ≅ x :=
match x with
  | .of _ => Iso.refl _
  | .star => Iso.refl _
```

-- snippet 26
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObjectFunctorCompToArrowIso (L112-L118)
def equivAugmentedSimplicialObjectFunctorCompToArrowIso :
    equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.toArrow ≅
    Functor.mapArrowFunctor _ C ⋙
      (evaluation _ _ |>.obj <| .mk <| .op <| WithInitial.homTo <| .mk 0) :=
.refl _

end AugmentedSimplexCategory
```

-- snippet 27
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObjectFunctorCompDropIso (L61-L67)
def equivAugmentedCosimplicialObjectFunctorCompDropIso :
    equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.drop ≅
    (Functor.whiskeringLeft _ _ C).obj inclusion :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
taking the point of the augmentation corresponds to evaluation at the initial object. -/
```

-- snippet 28
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObjectFunctorCompToArrowIso (L78-L85)
def equivAugmentedCosimplicialObjectFunctorCompToArrowIso :
    equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.toArrow ≅
    Functor.mapArrowFunctor _ C ⋙
      (evaluation _ _ |>.obj <| .mk <| WithInitial.homTo <| .mk 0) :=
.refl _

/-- The equivalence between functors out of `AugmentedSimplexCategory` and augmented simplicial
objects. -/
```

-- snippet 29
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedCosimplicialObjectFunctorCompPointIso (L69-L76)
def equivAugmentedCosimplicialObjectFunctorCompPointIso :
    equivAugmentedCosimplicialObject.functor ⋙ CosimplicialObject.Augmented.point ≅
    ((evaluation _ _).obj .star : (AugmentedSimplexCategory ⥤ C) ⥤ C) :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
the arrow attached to the cosimplicial object is the one obtained by evaluation at the unique arrow
`star ⟶ of [0]`. -/
```

-- snippet 30
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.AugmentedSimplexCategory (L34-L40)
abbrev AugmentedSimplexCategory := WithInitial SimplexCategory
namespace AugmentedSimplexCategory

variable {C : Type*} [Category* C]

/-- The canonical inclusion from `SimplexCategory` to `AugmentedSimplexCategory`. -/
```

-- snippet 31
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Basic.equivAugmentedSimplicialObjectFunctorCompPointIso (L103-L110)
def equivAugmentedSimplicialObjectFunctorCompPointIso :
    equivAugmentedSimplicialObject.functor ⋙ SimplicialObject.Augmented.point ≅
    (evaluation _ C).obj (.op .star) :=
.refl _

/-- Through the equivalence `(AugmentedSimplexCategory ⥤ C) ≌ CosimplicialObject.Augmented C`,
the arrow attached to the cosimplicial object is the one obtained by evaluation at the unique arrow
`star ⟶ of [0]`. -/
```

-- snippet 32
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.id_star_whiskerRight (L151-L156)
lemma id_star_whiskerRight {x : AugmentedSimplexCategory} : 𝟙 WithInitial.star ▷ x = 𝟙 _ := by
cases x <;>
  rfl

/-- Thanks to `tensorUnit` being initial in `AugmentedSimplexCategory`, we get
a morphism `Δ ⟶ Δ ⊗ Δ'` for every pair of objects `Δ, Δ'`. -/
```

-- snippet 33
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorUnit (L94-L96)
abbrev tensorUnit : AugmentedSimplexCategory := WithInitial.star
/-- The associator isomorphism for the monoidal structure on `AugmentedSimplexCategory` -/
```

-- snippet 34
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.eqToHom_toOrderHom (L40-L49)
lemma eqToHom_toOrderHom {x y : SimplexCategory} (h : WithInitial.of x = WithInitial.of y) :
    SimplexCategory.Hom.toOrderHom (WithInitial.down <| eqToHom h) =
      (Fin.castOrderIso
        (congrArg (fun t ↦ t + 1) (by injection h with h; rw [h]))).toOrderEmbedding.toOrderHom :=
SimplexCategory.eqToHom_toOrderHom (by injection h)

/-- An auxiliary definition for the tensor product of two objects in `AugmentedSimplexCategory`. -/
-- (Impl. note): This definition could easily be inlined in
-- the definition of `tensorObjOf` below, but having it type check directly as an element
-- of `SimplexCategory` avoids having to sprinkle `WithInitial.down` everywhere.
```

-- snippet 35
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorHom_id (L141-L144)
lemma tensorHom_id {x₁ x₂ : AugmentedSimplexCategory} (y : AugmentedSimplexCategory)
    (f : x₁ ⟶ x₂) : f ⊗ₘ 𝟙 y = f ▷ y :=
rfl
```

-- snippet 36
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.inr (L162-L166)
def inr (x y : AugmentedSimplexCategory) : y ⟶ x ⊗ y :=
(λ_ y).inv ≫ (WithInitial.starInitial.to x) ▷ _

/-- To ease type checking, we also provide a version of inl that lives in
`SimplexCategory`. -/
```

-- snippet 37
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.whiskerLeft_id_star (L146-L149)
lemma whiskerLeft_id_star {x : AugmentedSimplexCategory} : x ◁ 𝟙 .star = 𝟙 _ := by
cases x <;>
  rfl
```

-- snippet 38
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorObjOf (L50-L52)
abbrev tensorObjOf (m n : SimplexCategory) : SimplexCategory := .mk (m.len + n.len + 1)
/-- The tensor product of two objects of `AugmentedSimplexCategory`. -/
```

-- snippet 39
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorHomOf (L60-L78)
def tensorHomOf {x₁ y₁ x₂ y₂ : SimplexCategory} (f₁ : x₁ ⟶ y₁) (f₂ : x₂ ⟶ y₂) :
    tensorObjOf x₁ x₂ ⟶ tensorObjOf y₁ y₂ :=
letI f₁ : Fin ((x₁.len + 1) + (x₂.len + 1)) →o Fin ((y₁.len + 1) + (y₂.len + 1)) :=
    { toFun i :=
        Fin.addCases
          (motive := fun _ ↦ Fin <| (y₁.len + 1) + (y₂.len + 1))
          (fun i ↦ (f₁.toOrderHom i).castAdd _)
          (fun i ↦ (f₂.toOrderHom i).natAdd _)
          i
      monotone' i j h := by
        cases i using Fin.addCases <;>
        cases j using Fin.addCases <;>
        rw [Fin.le_def] at h ⊢ <;>
        simp at h ⊢ <;>
        grind only [OrderHom.apply_mono] }
  (eqToHom (congrArg _ (Nat.succ_add _ _)).symm ≫ (SimplexCategory.mkHom f₁) ≫
    eqToHom (congrArg _ (Nat.succ_add _ _)) : _ ⟶ ⦋y₁.len + y₂.len + 1⦌)

/-- The action of the tensor product on maps of `AugmentedSimplexCategory`. -/
```

-- snippet 40
```lean
-- Mathlib.AlgebraicTopology.SimplexCategory.Augmented.Monoidal.tensorObj (L53-L59)
def tensorObj (m n : AugmentedSimplexCategory) : AugmentedSimplexCategory :=
match m, n with
  | .of m, .of n => .of <| tensorObjOf m n
  | .star, x => x
  | x, .star => x

/-- The action of the tensor product on maps coming from `SimplexCategory`. -/
```
[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Dynamics.BirkhoffSum.Basic).

[User]
The following Lean code fails to compile. Fix it.

```lean
theorem birkhoffSum_add' (f : α → α) (g g' : α → M) (n : ℕ) (x : α) :
    birkhoffSum f (g + g') n x = birkhoffSum f g n x + birkhoffSum f g' n x
:= by .someMissingNamespaceXYZ
simpa [birkhoffSum] using sum_add_distrib
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=164, messages=[Message(data='unknown tactic', pos=Position(line=3, column=8), pos_end=None, severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None), CompilationUnit(i_begin=164, i_end=228, messages=[], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Dynamics.BirkhoffSum.Basic).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]The following Lean code fails to compile. Fix it.

```lean
theorem birkhoffSum_add' (f : α → α) (g g' : α → M) (n : ℕ) (x : α) :
    birkhoffSum f (g + g') n x = birkhoffSum f g n x + birkhoffSum f g' n x
:= by .someMissingNamespaceXYZ
simpa [birkhoffSum] using sum_add_distrib
```

## Compiler diagnostic
```
[CompilationUnit(i_begin=0, i_end=164, messages=[Message(data='unknown tactic', pos=Position(line=3, column=8), pos_end=None, severity=<Severity.ERROR: 3>, kind=None)], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None), CompilationUnit(i_begin=164, i_end=228, messages=[], invocations=None, goal_state=None, goal_src_boundaries=None, new_constants=None)]
```

Return a corrected, compiling version of the code.[/INST]


[System] You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Computability.TuringMachine.Tape).

[User]
Complete the following proof.

```lean
theorem Tape.move_right_mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) :
    (Tape.mk' L R).move Dir.right = Tape.mk' (L.cons R.head) R.tail
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Computability.TuringMachine.Tape).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Complete the following proof.

```lean
theorem Tape.move_right_mk' {Γ} [Inhabited Γ] (L R : ListBlank Γ) :
    (Tape.mk' L R).move Dir.right = Tape.mk' (L.cons R.head) R.tail
```

Provide a complete Lean proof for the statement above. Do not include the statement in your answer.[/INST]