l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem realize_constantsToVars [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L[[α]].Term β} {v : β → M} :
    t.constantsToVars.realize (Sum.elim (fun a => ↑(L.con a)) v) = t.realize v := by
  induction' t with _ n f ts ih
  · simp
  · cases n
    · cases f
      · simp only [realize, ih, Nat.zero_eq, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        rw [withConstants_funMap_sum_inl]
      · 

Proof state:
case func.zero.inr
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
ts : Fin Nat.zero → Term (L[[α]]) β
ih :
  ∀ (a : Fin Nat.zero), realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (ts a)) = realize v (ts a)
val✝ : Functions (constantsOn α) Nat.zero
⊢ realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (func (Sum.inr val✝) ts)) =
    realize v (func (Sum.inr val✝) ts)

Next tactic:
simp only [realize, constantsToVars, Sum.elim_inl, funMap_eq_coe_constants]
@[simp]
theorem realize_constantsToVars [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L[[α]].Term β} {v : β → M} :
    t.constantsToVars.realize (Sum.elim (fun a => ↑(L.con a)) v) = t.realize v := by
  induction' t with _ n f ts ih
  · simp
  · cases n
    · cases f
      · simp only [realize, ih, Nat.zero_eq, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        rw [withConstants_funMap_sum_inl]
      · simp only [realize, constantsToVars, Sum.elim_inl, funMap_eq_coe_constants]
        

Proof state:
case func.zero.inr
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
ts : Fin Nat.zero → Term (L[[α]]) β
ih :
  ∀ (a : Fin Nat.zero), realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (ts a)) = realize v (ts a)
val✝ : Functions (constantsOn α) Nat.zero
⊢ ↑(Language.con L val✝) = ↑(Sum.inr val✝)

Next tactic:
rfl
@[simp]
theorem realize_constantsToVars [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L[[α]].Term β} {v : β → M} :
    t.constantsToVars.realize (Sum.elim (fun a => ↑(L.con a)) v) = t.realize v := by
  induction' t with _ n f ts ih
  · simp
  · cases n
    · cases f
      · simp only [realize, ih, Nat.zero_eq, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        rw [withConstants_funMap_sum_inl]
      · simp only [realize, constantsToVars, Sum.elim_inl, funMap_eq_coe_constants]
        rfl
    · 

Proof state:
case func.succ
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
n✝ : ℕ
f : Functions (L[[α]]) (Nat.succ n✝)
ts : Fin (Nat.succ n✝) → Term (L[[α]]) β
ih :
  ∀ (a : Fin (Nat.succ n✝)),
    realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (ts a)) = realize v (ts a)
⊢ realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (func f ts)) = realize v (func f ts)

Next tactic:
cases' f with _ f
@[simp]
theorem realize_constantsToVars [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L[[α]].Term β} {v : β → M} :
    t.constantsToVars.realize (Sum.elim (fun a => ↑(L.con a)) v) = t.realize v := by
  induction' t with _ n f ts ih
  · simp
  · cases n
    · cases f
      · simp only [realize, ih, Nat.zero_eq, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        rw [withConstants_funMap_sum_inl]
      · simp only [realize, constantsToVars, Sum.elim_inl, funMap_eq_coe_constants]
        rfl
    · cases' f with _ f
      · 

Proof state:
case func.succ.inl
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
n✝ : ℕ
ts : Fin (Nat.succ n✝) → Term (L[[α]]) β
ih :
  ∀ (a : Fin (Nat.succ n✝)),
    realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (ts a)) = realize v (ts a)
val✝ : Functions L (Nat.succ n✝)
⊢ realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (func (Sum.inl val✝) ts)) =
    realize v (func (Sum.inl val✝) ts)

Next tactic:
simp only [realize, ih, constantsOn, mk₂_Functions]
@[simp]
theorem realize_constantsToVars [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L[[α]].Term β} {v : β → M} :
    t.constantsToVars.realize (Sum.elim (fun a => ↑(L.con a)) v) = t.realize v := by
  induction' t with _ n f ts ih
  · simp
  · cases n
    · cases f
      · simp only [realize, ih, Nat.zero_eq, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        rw [withConstants_funMap_sum_inl]
      · simp only [realize, constantsToVars, Sum.elim_inl, funMap_eq_coe_constants]
        rfl
    · cases' f with _ f
      · simp only [realize, ih, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        

Proof state:
case func.succ.inl
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
n✝ : ℕ
ts : Fin (Nat.succ n✝) → Term (L[[α]]) β
ih :
  ∀ (a : Fin (Nat.succ n✝)),
    realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (ts a)) = realize v (ts a)
val✝ : Functions L (Nat.succ n✝)
⊢ (funMap val✝ fun i => realize v (ts i)) = funMap (Sum.inl val✝) fun i => realize v (ts i)

Next tactic:
rw [withConstants_funMap_sum_inl]
@[simp]
theorem realize_constantsToVars [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L[[α]].Term β} {v : β → M} :
    t.constantsToVars.realize (Sum.elim (fun a => ↑(L.con a)) v) = t.realize v := by
  induction' t with _ n f ts ih
  · simp
  · cases n
    · cases f
      · simp only [realize, ih, Nat.zero_eq, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        rw [withConstants_funMap_sum_inl]
      · simp only [realize, constantsToVars, Sum.elim_inl, funMap_eq_coe_constants]
        rfl
    · cases' f with _ f
      · simp only [realize, ih, constantsOn, mk₂_Functions]
        --Porting note: below lemma does not work with simp for some reason
        rw [withConstants_funMap_sum_inl]
      · 

Proof state:
case func.succ.inr
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
n✝ : ℕ
ts : Fin (Nat.succ n✝) → Term (L[[α]]) β
ih :
  ∀ (a : Fin (Nat.succ n✝)),
    realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (ts a)) = realize v (ts a)
f : Functions (constantsOn α) (Nat.succ n✝)
⊢ realize (Sum.elim (fun a => ↑(Language.con L a)) v) (constantsToVars (func (Sum.inr f) ts)) =
    realize v (func (Sum.inr f) ts)

Next tactic:
exact isEmptyElim f
@[simp]
theorem realize_varsToConstants [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L.Term (Sum α β)} {v : β → M} :
    t.varsToConstants.realize v = t.realize (Sum.elim (fun a => ↑(L.con a)) v) := by
  

Proof state:
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
t : Term L (α ⊕ β)
v : β → M
⊢ realize v (varsToConstants t) = realize (Sum.elim (fun a => ↑(Language.con L a)) v) t

Next tactic:
induction' t with ab n f ts ih
@[simp]
theorem realize_varsToConstants [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L.Term (Sum α β)} {v : β → M} :
    t.varsToConstants.realize v = t.realize (Sum.elim (fun a => ↑(L.con a)) v) := by
  induction' t with ab n f ts ih
  · 

Proof state:
case var
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
ab : α ⊕ β
⊢ realize v (varsToConstants (var ab)) = realize (Sum.elim (fun a => ↑(Language.con L a)) v) (var ab)

Next tactic:
cases' ab with a b
@[simp]
theorem realize_varsToConstants [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L.Term (Sum α β)} {v : β → M} :
    t.varsToConstants.realize v = t.realize (Sum.elim (fun a => ↑(L.con a)) v) := by
  induction' t with ab n f ts ih
  · cases' ab with a b
    --Porting note: both cases were `simp [Language.con]`
    · 

Proof state:
case var.inl
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
a : α
⊢ realize v (varsToConstants (var (Sum.inl a))) = realize (Sum.elim (fun a => ↑(Language.con L a)) v) (var (Sum.inl a))

Next tactic:
simp [Language.con, realize, constantMap, funMap_eq_coe_constants]
@[simp]
theorem realize_varsToConstants [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L.Term (Sum α β)} {v : β → M} :
    t.varsToConstants.realize v = t.realize (Sum.elim (fun a => ↑(L.con a)) v) := by
  induction' t with ab n f ts ih
  · cases' ab with a b
    --Porting note: both cases were `simp [Language.con]`
    · simp [Language.con, realize, constantMap, funMap_eq_coe_constants]
    · 

Proof state:
case var.inr
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
b : β
⊢ realize v (varsToConstants (var (Sum.inr b))) = realize (Sum.elim (fun a => ↑(Language.con L a)) v) (var (Sum.inr b))

Next tactic:
simp [realize, constantMap]
@[simp]
theorem realize_varsToConstants [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L.Term (Sum α β)} {v : β → M} :
    t.varsToConstants.realize v = t.realize (Sum.elim (fun a => ↑(L.con a)) v) := by
  induction' t with ab n f ts ih
  · cases' ab with a b
    --Porting note: both cases were `simp [Language.con]`
    · simp [Language.con, realize, constantMap, funMap_eq_coe_constants]
    · simp [realize, constantMap]
  · 

Proof state:
case func
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
n : ℕ
f : Functions L n
ts : Fin n → Term L (α ⊕ β)
ih : ∀ (a : Fin n), realize v (varsToConstants (ts a)) = realize (Sum.elim (fun a => ↑(Language.con L a)) v) (ts a)
⊢ realize v (varsToConstants (func f ts)) = realize (Sum.elim (fun a => ↑(Language.con L a)) v) (func f ts)

Next tactic:
simp only [realize, constantsOn, mk₂_Functions, ih]
@[simp]
theorem realize_varsToConstants [L[[α]].Structure M] [(lhomWithConstants L α).IsExpansionOn M]
    {t : L.Term (Sum α β)} {v : β → M} :
    t.varsToConstants.realize v = t.realize (Sum.elim (fun a => ↑(L.con a)) v) := by
  induction' t with ab n f ts ih
  · cases' ab with a b
    --Porting note: both cases were `simp [Language.con]`
    · simp [Language.con, realize, constantMap, funMap_eq_coe_constants]
    · simp [realize, constantMap]
  · simp only [realize, constantsOn, mk₂_Functions, ih]
    --Porting note: below lemma does not work with simp for some reason
    

Proof state:
case func
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
v : β → M
n : ℕ
f : Functions L n
ts : Fin n → Term L (α ⊕ β)
ih : ∀ (a : Fin n), realize v (varsToConstants (ts a)) = realize (Sum.elim (fun a => ↑(Language.con L a)) v) (ts a)
⊢ (funMap (Sum.inl f) fun i => realize (Sum.elim (fun a => ↑(Language.con L a)) v) (ts i)) =
    funMap f fun i => realize (Sum.elim (fun a => ↑(Language.con L a)) v) (ts i)

Next tactic:
rw [withConstants_funMap_sum_inl]
theorem realize_constantsVarsEquivLeft [L[[α]].Structure M]
    [(lhomWithConstants L α).IsExpansionOn M] {n} {t : L[[α]].Term (Sum β (Fin n))} {v : β → M}
    {xs : Fin n → M} :
    (constantsVarsEquivLeft t).realize (Sum.elim (Sum.elim (fun a => ↑(L.con a)) v) xs) =
      t.realize (Sum.elim v xs) := by
  

Proof state:
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
n : ℕ
t : Term (L[[α]]) (β ⊕ Fin n)
v : β → M
xs : Fin n → M
⊢ realize (Sum.elim (Sum.elim (fun a => ↑(Language.con L a)) v) xs) (constantsVarsEquivLeft t) =
    realize (Sum.elim v xs) t

Next tactic:
simp only [constantsVarsEquivLeft, realize_relabel, Equiv.coe_trans, Function.comp_apply,
    constantsVarsEquiv_apply, relabelEquiv_symm_apply]
theorem realize_constantsVarsEquivLeft [L[[α]].Structure M]
    [(lhomWithConstants L α).IsExpansionOn M] {n} {t : L[[α]].Term (Sum β (Fin n))} {v : β → M}
    {xs : Fin n → M} :
    (constantsVarsEquivLeft t).realize (Sum.elim (Sum.elim (fun a => ↑(L.con a)) v) xs) =
      t.realize (Sum.elim v xs) := by
  simp only [constantsVarsEquivLeft, realize_relabel, Equiv.coe_trans, Function.comp_apply,
    constantsVarsEquiv_apply, relabelEquiv_symm_apply]
  

Proof state:
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
n : ℕ
t : Term (L[[α]]) (β ⊕ Fin n)
v : β → M
xs : Fin n → M
⊢ realize (Sum.elim (Sum.elim (fun a => ↑(Language.con L a)) v) xs ∘ ⇑(Equiv.sumAssoc α β (Fin n)).symm)
      (constantsToVars t) =
    realize (Sum.elim v xs) t

Next tactic:
refine' _root_.trans _ realize_constantsToVars
theorem realize_constantsVarsEquivLeft [L[[α]].Structure M]
    [(lhomWithConstants L α).IsExpansionOn M] {n} {t : L[[α]].Term (Sum β (Fin n))} {v : β → M}
    {xs : Fin n → M} :
    (constantsVarsEquivLeft t).realize (Sum.elim (Sum.elim (fun a => ↑(L.con a)) v) xs) =
      t.realize (Sum.elim v xs) := by
  simp only [constantsVarsEquivLeft, realize_relabel, Equiv.coe_trans, Function.comp_apply,
    constantsVarsEquiv_apply, relabelEquiv_symm_apply]
  refine' _root_.trans _ realize_constantsToVars
  

Proof state:
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
n : ℕ
t : Term (L[[α]]) (β ⊕ Fin n)
v : β → M
xs : Fin n → M
⊢ realize (Sum.elim (Sum.elim (fun a => ↑(Language.con L a)) v) xs ∘ ⇑(Equiv.sumAssoc α β (Fin n)).symm)
      (constantsToVars t) =
    realize (Sum.elim (fun a => ↑(Language.con L a)) (Sum.elim v xs)) (constantsToVars t)

Next tactic:
rcongr x
theorem realize_constantsVarsEquivLeft [L[[α]].Structure M]
    [(lhomWithConstants L α).IsExpansionOn M] {n} {t : L[[α]].Term (Sum β (Fin n))} {v : β → M}
    {xs : Fin n → M} :
    (constantsVarsEquivLeft t).realize (Sum.elim (Sum.elim (fun a => ↑(L.con a)) v) xs) =
      t.realize (Sum.elim v xs) := by
  simp only [constantsVarsEquivLeft, realize_relabel, Equiv.coe_trans, Function.comp_apply,
    constantsVarsEquiv_apply, relabelEquiv_symm_apply]
  refine' _root_.trans _ realize_constantsToVars
  rcongr x
  

Proof state:
case e_v.h
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
n : ℕ
t : Term (L[[α]]) (β ⊕ Fin n)
v : β → M
xs : Fin n → M
x : α ⊕ β ⊕ Fin n
⊢ (Sum.elim (Sum.elim (fun a => ↑(Language.con L a)) v) xs ∘ ⇑(Equiv.sumAssoc α β (Fin n)).symm) x =
    Sum.elim (fun a => ↑(Language.con L a)) (Sum.elim v xs) x

Next tactic:
rcases x with (a | (b | i))
theorem realize_constantsVarsEquivLeft [L[[α]].Structure M]
    [(lhomWithConstants L α).IsExpansionOn M] {n} {t : L[[α]].Term (Sum β (Fin n))} {v : β → M}
    {xs : Fin n → M} :
    (constantsVarsEquivLeft t).realize (Sum.elim (Sum.elim (fun a => ↑(L.con a)) v) xs) =
      t.realize (Sum.elim v xs) := by
  simp only [constantsVarsEquivLeft, realize_relabel, Equiv.coe_trans, Function.comp_apply,
    constantsVarsEquiv_apply, relabelEquiv_symm_apply]
  refine' _root_.trans _ realize_constantsToVars
  rcongr x
  rcases x with (a | (b | i)) <;> 

Proof state:
case e_v.h.inl
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
n : ℕ
t : Term (L[[α]]) (β ⊕ Fin n)
v : β → M
xs : Fin n → M
a : α
⊢ (Sum.elim (Sum.elim (fun a => ↑(Language.con L a)) v) xs ∘ ⇑(Equiv.sumAssoc α β (Fin n)).symm) (Sum.inl a) =
    Sum.elim (fun a => ↑(Language.con L a)) (Sum.elim v xs) (Sum.inl a)

Next tactic:
simp
theorem realize_constantsVarsEquivLeft [L[[α]].Structure M]
    [(lhomWithConstants L α).IsExpansionOn M] {n} {t : L[[α]].Term (Sum β (Fin n))} {v : β → M}
    {xs : Fin n → M} :
    (constantsVarsEquivLeft t).realize (Sum.elim (Sum.elim (fun a => ↑(L.con a)) v) xs) =
      t.realize (Sum.elim v xs) := by
  simp only [constantsVarsEquivLeft, realize_relabel, Equiv.coe_trans, Function.comp_apply,
    constantsVarsEquiv_apply, relabelEquiv_symm_apply]
  refine' _root_.trans _ realize_constantsToVars
  rcongr x
  rcases x with (a | (b | i)) <;> 

Proof state:
case e_v.h.inr.inl
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
n : ℕ
t : Term (L[[α]]) (β ⊕ Fin n)
v : β → M
xs : Fin n → M
b : β
⊢ (Sum.elim (Sum.elim (fun a => ↑(Language.con L a)) v) xs ∘ ⇑(Equiv.sumAssoc α β (Fin n)).symm) (Sum.inr (Sum.inl b)) =
    Sum.elim (fun a => ↑(Language.con L a)) (Sum.elim v xs) (Sum.inr (Sum.inl b))

Next tactic:
simp
theorem realize_constantsVarsEquivLeft [L[[α]].Structure M]
    [(lhomWithConstants L α).IsExpansionOn M] {n} {t : L[[α]].Term (Sum β (Fin n))} {v : β → M}
    {xs : Fin n → M} :
    (constantsVarsEquivLeft t).realize (Sum.elim (Sum.elim (fun a => ↑(L.con a)) v) xs) =
      t.realize (Sum.elim v xs) := by
  simp only [constantsVarsEquivLeft, realize_relabel, Equiv.coe_trans, Function.comp_apply,
    constantsVarsEquiv_apply, relabelEquiv_symm_apply]
  refine' _root_.trans _ realize_constantsToVars
  rcongr x
  rcases x with (a | (b | i)) <;> 

Proof state:
case e_v.h.inr.inr
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure (L[[α]]) M
inst✝ : LHom.IsExpansionOn (lhomWithConstants L α) M
n : ℕ
t : Term (L[[α]]) (β ⊕ Fin n)
v : β → M
xs : Fin n → M
i : Fin n
⊢ (Sum.elim (Sum.elim (fun a => ↑(Language.con L a)) v) xs ∘ ⇑(Equiv.sumAssoc α β (Fin n)).symm) (Sum.inr (Sum.inr i)) =
    Sum.elim (fun a => ↑(Language.con L a)) (Sum.elim v xs) (Sum.inr (Sum.inr i))

Next tactic:
simp
@[simp]
theorem realize_onTerm [L'.Structure M] (φ : L →ᴸ L') [φ.IsExpansionOn M] (t : L.Term α)
    (v : α → M) : (φ.onTerm t).realize v = t.realize v := by
  

Proof state:
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure L' M
φ : L →ᴸ L'
inst✝ : IsExpansionOn φ M
t : Term L α
v : α → M
⊢ Term.realize v (onTerm φ t) = Term.realize v t

Next tactic:
induction' t with _ n f ts ih
@[simp]
theorem realize_onTerm [L'.Structure M] (φ : L →ᴸ L') [φ.IsExpansionOn M] (t : L.Term α)
    (v : α → M) : (φ.onTerm t).realize v = t.realize v := by
  induction' t with _ n f ts ih
  · 

Proof state:
case var
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure L' M
φ : L →ᴸ L'
inst✝ : IsExpansionOn φ M
v : α → M
_a✝ : α
⊢ Term.realize v (onTerm φ (var _a✝)) = Term.realize v (var _a✝)

Next tactic:
rfl
@[simp]
theorem realize_onTerm [L'.Structure M] (φ : L →ᴸ L') [φ.IsExpansionOn M] (t : L.Term α)
    (v : α → M) : (φ.onTerm t).realize v = t.realize v := by
  induction' t with _ n f ts ih
  · rfl
  · 

Proof state:
case func
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝⁴ : Structure L M
inst✝³ : Structure L N
inst✝² : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
inst✝¹ : Structure L' M
φ : L →ᴸ L'
inst✝ : IsExpansionOn φ M
v : α → M
n : ℕ
f : Functions L n
ts : Fin n → Term L α
ih : ∀ (a : Fin n), Term.realize v (onTerm φ (ts a)) = Term.realize v (ts a)
⊢ Term.realize v (onTerm φ (func f ts)) = Term.realize v (func f ts)

Next tactic:
simp only [Term.realize, LHom.onTerm, LHom.map_onFunction, ih]
@[simp]
theorem Hom.realize_term (g : M →[L] N) {t : L.Term α} {v : α → M} :
    t.realize (g ∘ v) = g (t.realize v) := by
  

Proof state:
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝² : Structure L M
inst✝¹ : Structure L N
inst✝ : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
g : M →[L] N
t : Term L α
v : α → M
⊢ Term.realize (⇑g ∘ v) t = g (Term.realize v t)

Next tactic:
induction t
@[simp]
theorem Hom.realize_term (g : M →[L] N) {t : L.Term α} {v : α → M} :
    t.realize (g ∘ v) = g (t.realize v) := by
  induction t
  · 

Proof state:
case var
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝² : Structure L M
inst✝¹ : Structure L N
inst✝ : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
g : M →[L] N
v : α → M
_a✝ : α
⊢ Term.realize (⇑g ∘ v) (var _a✝) = g (Term.realize v (var _a✝))

Next tactic:
rfl
@[simp]
theorem Hom.realize_term (g : M →[L] N) {t : L.Term α} {v : α → M} :
    t.realize (g ∘ v) = g (t.realize v) := by
  induction t
  · rfl
  · 

Proof state:
case func
L : Language
L' : Language
M : Type w
N : Type u_1
P : Type u_2
inst✝² : Structure L M
inst✝¹ : Structure L N
inst✝ : Structure L P
α : Type u'
β : Type v'
γ : Type u_3
g : M →[L] N
v : α → M
l✝ : ℕ
_f✝ : Functions L l✝
_ts✝ : Fin l✝ → Term L α
_ts_ih✝ : ∀ (a : Fin l✝), Term.realize (⇑g ∘ v) (_ts✝ a) = g (Term.realize v (_ts✝ a))
⊢ Term.realize (⇑g ∘ v) (func _f✝ _ts✝) = g (Term.realize v (func _f✝ _ts✝))

Next tactic:
rw [Term.realize, Term.realize, g.map_fun]