awhecmu/canonical-drafter-extract-mathlib huggingface dataset:
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
n : ℕ
R : L.Relations n
k : ℕ
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
h :
  ∀ (i : Fin n),
    (getElem? (valid := fun (xs : List (Option ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k)))) (i : Fin n) ↦
            (↑i : ℕ) < xs.length) (List.map Sum.getLeft? l) i).join.isSome =
      true
h' :
  ∀ (i : Fin n),
    ((getElem? (valid := fun (xs : List (Option ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k)))) (i : Fin n) ↦
                  (↑i : ℕ) < xs.length) (List.map Sum.getLeft? l) i).join.get
            ⋯).fst
        (β := fun (k : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin k)) =
      k
i : Fin n
⊢ Term.{u, v, u'} L
      (α ⊕
        Fin
          (((getElem? (valid := fun (xs : List (Option ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k)))) (i : Fin n) ↦
                      (↑i : ℕ) < xs.length) (List.map Sum.getLeft? l) i).join.get
                ⋯).fst
            (β := fun (k : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin k)))) =
    Term.{u, v, u'} L (α ⊕ Fin k)
have rw : Term.{u, v, u'} L (α ⊕ Fin k) = Term.{u, v, u'} L (α ⊕ Fin k)
Tactic: rw [h' i]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
h :
  ∀ (φ : (n : ℕ) × L.BoundedFormula α n)
    (l' : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)),
    listDecode (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++ l') = φ :: listDecode l'
φ : (n : ℕ) × L.BoundedFormula α n
l : List ((n : ℕ) × L.BoundedFormula α n)
ih :
  listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
    l
⊢ listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        (φ :: l)) =
    φ :: l
have cons : listDecode
    (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++
      flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
  φ :: l
Tactic: rw [flatMap_cons, h φ _, ih]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
h :
  ∀ (φ : (n : ℕ) × L.BoundedFormula α n)
    (l' : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)),
    listDecode (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++ l') = φ :: listDecode l'
φ : (n : ℕ) × L.BoundedFormula α n
l : List ((n : ℕ) × L.BoundedFormula α n)
ih :
  listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
    l
cons :
  listDecode
      (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++
        flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
          l) =
    φ :: l
⊢ listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        (φ :: l)) =
    φ :: l
have cons₁ : φ ::
    listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
  φ :: l
Tactic: rw [flatMap_cons, h φ _, ih]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
h :
  ∀ (φ : (n : ℕ) × L.BoundedFormula α n)
    (l' : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)),
    listDecode (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++ l') = φ :: listDecode l'
φ : (n : ℕ) × L.BoundedFormula α n
l : List ((n : ℕ) × L.BoundedFormula α n)
ih :
  listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
    l
cons :
  listDecode
      (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++
        flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
          l) =
    φ :: l
cons₁ :
  φ ::
      listDecode
        (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
          l) =
    φ :: l
⊢ listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        (φ :: l)) =
    φ :: l
have cons₂ : φ :: l = φ :: l
Tactic: rw [flatMap_cons, h φ _, ih]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l : List ((n : ℕ) × L.BoundedFormula α n)
h :
  ∀ (φ : (n : ℕ) × L.BoundedFormula α n)
    (l' : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)),
    listDecode (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++ l') = φ :: listDecode l'
⊢ listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
    l
have nil : Eq (α := List ((n : ℕ) × L.BoundedFormula α n))
  (listDecode
    (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
      []))
  []
Tactic: induction l with
    | nil =>
      simp [listDecode]
    | cons φ l ih => rw [flatMap_cons, h φ _, ih]
Cleared hypotheses: l
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l : List ((n : ℕ) × L.BoundedFormula α n)
h :
  ∀ (φ : (n : ℕ) × L.BoundedFormula α n)
    (l' : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)),
    listDecode (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++ l') = φ :: listDecode l'
nil :
  Eq (α := List ((n : ℕ) × L.BoundedFormula α n))
    (listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        []))
    []
⊢ listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
    l
have cons : ∀ (φ : (n : ℕ) × L.BoundedFormula α n) (l : List ((n : ℕ) × L.BoundedFormula α n))
  (ih :
    listDecode
        (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
          l) =
      l),
  listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        (φ :: l)) =
    φ :: l
Tactic: induction l with
    | nil =>
      simp [listDecode]
    | cons φ l ih => rw [flatMap_cons, h φ _, ih]
Cleared hypotheses: l
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l : List ((n : ℕ) × L.BoundedFormula α n)
⊢ listDecode
      (flatMap (fun (φ : (n : ℕ) × L.BoundedFormula α n) ↦ φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode)
        l) =
    l
have suffices : ∀ (φ : (n : ℕ) × L.BoundedFormula α n)
  (l' : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)),
  listDecode (φ.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n).listEncode ++ l') = φ :: listDecode l'
Tactic: suffices h : ∀ (φ : Σ n, L.BoundedFormula α n)
      (l' : List ((Σ k, L.Term (α ⊕ Fin k)) ⊕ ((Σ n, L.Relations n) ⊕ ℕ))),
      (listDecode (listEncode φ.2 ++ l')) = φ::(listDecode l') by
    induction l with
    | nil =>
      simp [listDecode]
    | cons φ l ih => rw [flatMap_cons, h φ _, ih]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n n_1 : ℕ
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
⊢ listDecode
      (listEncode (n :=
          Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
            (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 falsum))
          (Sigma.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
            (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 falsum)) ++
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 falsum :: listDecode l
have falsum : listDecode
    ([Sum.inr
          (Sum.inr
            (Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
                (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 falsum) +
              2))] ++
      l) =
  Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 falsum :: listDecode l
Tactic: rw [listEncode, singleton_append, listDecode]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n n_1 : ℕ
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
falsum :
  listDecode
      ([Sum.inr
            (Sum.inr
              (Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
                  (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum) +
                2))] ++
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum :: listDecode l
⊢ listDecode
      (listEncode (n :=
          Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
            (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum))
          (Sigma.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
            (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum)) ++
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum :: listDecode l
have falsum₁ : listDecode
    (Sum.inr
        (Sum.inr
          (Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
              (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum) +
            2)) ::
      l) =
  Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum :: listDecode l
Tactic: rw [listEncode, singleton_append, listDecode]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n n_1 : ℕ
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
falsum :
  listDecode
      ([Sum.inr
            (Sum.inr
              (Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
                  (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum) +
                2))] ++
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum :: listDecode l
falsum₁ :
  listDecode
      (Sum.inr
          (Sum.inr
            (Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
                (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum) +
              2)) ::
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum :: listDecode l
⊢ listDecode
      (listEncode (n :=
          Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
            (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum))
          (Sigma.snd (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
            (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum)) ++
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum :: listDecode l
have falsum₂ : Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
      (Sigma.fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
        (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum))
      BoundedFormula.falsum ::
    listDecode l =
  Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 BoundedFormula.falsum :: listDecode l
Tactic: rw [listEncode, singleton_append, listDecode]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n n_1 : ℕ
t₁ t₂ : Term.{u, v, u'} L (α ⊕ Fin n_1)
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
⊢ listDecode
      ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (equal t₁ t₂)).snd (β := fun (n : ℕ) ↦
            L.BoundedFormula α n).listEncode ++
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (equal t₁ t₂) :: listDecode l
have equal : Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
      ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (equal t₁ t₂)).fst (β := fun (n : ℕ) ↦
        L.BoundedFormula α n))
      (equal t₁ (Eq.mp sorry t₂)) ::
    listDecode ([] ++ l) =
  Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (equal t₁ t₂) :: listDecode l
Tactic: rw [listEncode, cons_append, cons_append, listDecode, dif_pos]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n n_1 : ℕ
t₁ t₂ : Term.{u, v, u'} L (α ⊕ Fin n_1)
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
equal :
  Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
        ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (BoundedFormula.equal t₁ t₂)).fst (β := fun (n : ℕ) ↦
          L.BoundedFormula α n))
        (BoundedFormula.equal t₁ (Eq.mp ⋯ t₂)) ::
      listDecode ([] ++ l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (BoundedFormula.equal t₁ t₂) :: listDecode l
⊢ listDecode
      ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (BoundedFormula.equal t₁ t₂)).snd (β := fun (n : ℕ) ↦
            L.BoundedFormula α n).listEncode ++
        l) =
    Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (BoundedFormula.equal t₁ t₂) :: listDecode l
have equal₁ : (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (BoundedFormula.equal t₁ t₂)).fst (β := fun (n : ℕ) ↦
    L.BoundedFormula α n) =
  (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) n_1 (BoundedFormula.equal t₁ t₂)).fst (β := fun (n : ℕ) ↦
    L.BoundedFormula α n)
Tactic: rw [listEncode, cons_append, cons_append, listDecode, dif_pos]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n φ_n φ_l : ℕ
φ_R : L.Relations φ_l
ts : Fin φ_l → Term.{u, v, u'} L (α ⊕ Fin φ_n)
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
i : Fin φ_l
⊢ (getElem? (valid := fun (xs : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : Fin φ_l) ↦
        (↑i : ℕ) < xs.length)
        (List.map Sum.getLeft?
          (List.map
              (fun (i : Fin φ_l) ↦
                Sum.inl
                  (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n))
                    ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) φ_n (rel φ_R ts)).fst (β := fun (n : ℕ) ↦
                      L.BoundedFormula α n))
                    (ts i)))
              (finRange φ_l) ++
            l))
        i).join =
    some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i))
have simp : ∃ (h : (↑i : ℕ) < φ_l + l.length),
  getElem (valid := fun (as : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : ℕ) ↦ i < as.length)
      (List.map
          (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
            fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
          (finRange φ_l) ++
        List.map Sum.getLeft? l)
      (↑i : ℕ) sorry =
    some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i))
Tactic: simp only [Option.join, map_append, map_map, getElem?_fin, id, Option.bind_eq_some_iff,
        getElem?_eq_some_iff, length_append, length_map, length_finRange, exists_eq_right]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n φ_n φ_l : ℕ
φ_R : L.Relations φ_l
ts : Fin φ_l → Term.{u, v, u'} L (α ⊕ Fin φ_n)
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
i : Fin φ_l
⊢ ∃ (h : (↑i : ℕ) < φ_l + l.length),
    getElem (valid := fun (as : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : ℕ) ↦ i < as.length)
        (List.map
            (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
              fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
            (finRange φ_l) ++
          List.map Sum.getLeft? l)
        (↑i : ℕ) ⋯ =
      some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i))
have refine : getElem (valid := fun (as : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : ℕ) ↦ i < as.length)
    (List.map
        (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
          fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
        (finRange φ_l) ++
      List.map Sum.getLeft? l)
    (↑i : ℕ) sorry =
  some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i))
Tactic: refine ⟨lt_of_lt_of_le i.2 le_self_add, ?_⟩
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n φ_n φ_l : ℕ
φ_R : L.Relations φ_l
ts : Fin φ_l → Term.{u, v, u'} L (α ⊕ Fin φ_n)
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
i : Fin φ_l
⊢ getElem (valid := fun (as : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : ℕ) ↦ i < as.length)
      (List.map
          (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
            fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
          (finRange φ_l) ++
        List.map Sum.getLeft? l)
      (↑i : ℕ) ⋯ =
    some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i))
have rw : Eq (α := Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))
  (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
    (fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
    (getElem (valid := fun (as : List (Fin φ_l)) (i : ℕ) ↦ i < as.length) (finRange φ_l) (↑i : ℕ) sorry))
  (some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
Tactic: rw [getElem_append_left, getElem_map]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (goal)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n φ_n φ_l : ℕ
φ_R : L.Relations φ_l
ts : Fin φ_l → Term.{u, v, u'} L (α ⊕ Fin φ_n)
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
i : Fin φ_l
rw :
  Eq (α := Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))
    (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
      (fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
      (getElem (valid := fun (as : List (Fin φ_l)) (i : ℕ) ↦ i < as.length) (finRange φ_l) (↑i : ℕ) ⋯))
    (some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
⊢ getElem (valid := fun (as : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : ℕ) ↦ i < as.length)
      (List.map
          (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
            fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
          (finRange φ_l) ++
        List.map Sum.getLeft? l)
      (↑i : ℕ) ⋯ =
    some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i))
have h : (↑i : ℕ) <
  length (α := Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))
    (List.map
      (Function.comp (β := (n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ) Sum.getLeft?
        fun (i : Fin φ_l) ↦ Sum.inl (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i)))
      (finRange φ_l))
Tactic: rw [getElem_append_left, getElem_map]
-- Lean 4 proof step from Mathlib.ModelTheory.Encoding (hypothesis)
Goal:
L : Language
α : Type u'
l_1 : List ((n : ℕ) × L.BoundedFormula α n)
n φ_n φ_l : ℕ
φ_R : L.Relations φ_l
ts : Fin φ_l → Term.{u, v, u'} L (α ⊕ Fin φ_n)
l : List ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k) ⊕ (n : ℕ) × L.Relations n ⊕ ℕ)
h :
  ∀ (i : Fin φ_l),
    (getElem? (valid := fun (xs : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : Fin φ_l) ↦
          (↑i : ℕ) < xs.length)
          (List.map Sum.getLeft?
            (List.map
                (fun (i : Fin φ_l) ↦
                  Sum.inl
                    (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n))
                      ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) φ_n (rel φ_R ts)).fst (β := fun (n : ℕ) ↦
                        L.BoundedFormula α n))
                      (ts i)))
                (finRange φ_l) ++
              l))
          i).join =
      some (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n)) φ_n (ts i))
i : Fin φ_l
⊢ ((getElem? (valid := fun (xs : List (Option ((k : ℕ) × Term.{u, v, u'} L (α ⊕ Fin k)))) (i : Fin φ_l) ↦
                (↑i : ℕ) < xs.length)
                (List.map Sum.getLeft?
                  (List.map
                      (fun (i : Fin φ_l) ↦
                        Sum.inl
                          (Sigma.mk (β := fun (k : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin k))
                            ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) φ_n (rel φ_R ts)).fst (β :=
                              fun (n : ℕ) ↦ L.BoundedFormula α n))
                            (ts i)))
                      (finRange φ_l) ++
                    l))
                i).join.get
          ⋯).fst
      (β := fun (k : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin k)) =
    (Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) φ_n (rel φ_R ts)).fst (β := fun (n : ℕ) ↦ L.BoundedFormula α n)
have h1 : (getElem? (valid := fun (xs : List (Option ((n : ℕ) × Term.{u, v, u'} L (α ⊕ Fin n)))) (i : Fin φ_l) ↦
        (↑i : ℕ) < xs.length)
        (List.map Sum.getLeft?
          (List.map
              (fun (i : Fin φ_l) ↦
                Sum.inl
                  (Sigma.mk (β := fun (n : ℕ) ↦ Term.{u, v, u'} L (α ⊕ Fin n))
                    ((Sigma.mk (β := fun (n : ℕ) ↦ L.BoundedFormula α n) φ_n (rel φ_R ts)).fst (β := fun (n : ℕ) ↦
                      L.BoundedFormula α n))
                    (ts i)))
              (finRange φ_l) ++
            l))
        i).join.isSome =
  true
Tactic: obtain ⟨h1, h2⟩ := Option.eq_some_iff_get_eq.1 (h i)