l3lab/ntp-mathlib huggingface dataset:
theorem realize_toPrenexImpRight {φ ψ : L.BoundedFormula α n} (hφ : IsQF φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} :
    (φ.toPrenexImpRight ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  induction' hψ with _ _ hψ _ _ _hψ ih _ _ _hψ ih
  · rw [hψ.toPrenexImpRight]
  · refine' _root_.trans (forall_congr' fun _ => ih hφ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    exact ⟨fun h1 a h2 => h1 h2 a, fun h1 h2 a => h1 a h2⟩
  · unfold toPrenexImpRight
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hφ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_ex]
    refine' ⟨_, fun h' => _⟩
    · rintro ⟨a, ha⟩ h
      exact ⟨a, ha h⟩
    · by_cases h : φ.Realize v xs
      · obtain ⟨a, ha⟩ := h' h
        exact ⟨a, fun _ => ha⟩
      · 

Proof state:
case neg
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
ψ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hψ : IsPrenex φ✝
ih :
  ∀ {φ : BoundedFormula L α (n✝ + 1)},
    IsQF φ → ∀ {xs : Fin (n✝ + 1) → M}, Realize (toPrenexImpRight φ φ✝) v xs ↔ Realize (φ ⟹ φ✝) v xs
φ : BoundedFormula L α n✝
hφ : IsQF φ
xs : Fin n✝ → M
h' : Realize φ v xs → ∃ a, Realize φ✝ v (snoc xs a)
h : ¬Realize φ v xs
⊢ ∃ a, Realize φ v xs → Realize φ✝ v (snoc xs a)

Next tactic:
inhabit M
theorem realize_toPrenexImpRight {φ ψ : L.BoundedFormula α n} (hφ : IsQF φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} :
    (φ.toPrenexImpRight ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  induction' hψ with _ _ hψ _ _ _hψ ih _ _ _hψ ih
  · rw [hψ.toPrenexImpRight]
  · refine' _root_.trans (forall_congr' fun _ => ih hφ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    exact ⟨fun h1 a h2 => h1 h2 a, fun h1 h2 a => h1 a h2⟩
  · unfold toPrenexImpRight
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hφ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_ex]
    refine' ⟨_, fun h' => _⟩
    · rintro ⟨a, ha⟩ h
      exact ⟨a, ha h⟩
    · by_cases h : φ.Realize v xs
      · obtain ⟨a, ha⟩ := h' h
        exact ⟨a, fun _ => ha⟩
      · inhabit M
        

Proof state:
case neg
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
ψ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hψ : IsPrenex φ✝
ih :
  ∀ {φ : BoundedFormula L α (n✝ + 1)},
    IsQF φ → ∀ {xs : Fin (n✝ + 1) → M}, Realize (toPrenexImpRight φ φ✝) v xs ↔ Realize (φ ⟹ φ✝) v xs
φ : BoundedFormula L α n✝
hφ : IsQF φ
xs : Fin n✝ → M
h' : Realize φ v xs → ∃ a, Realize φ✝ v (snoc xs a)
h : ¬Realize φ v xs
inhabited_h : Inhabited M
⊢ ∃ a, Realize φ v xs → Realize φ✝ v (snoc xs a)

Next tactic:
exact ⟨default, fun h'' => (h h'').elim⟩
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize 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
n l : ℕ
φ✝ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ ψ : BoundedFormula L α n
hφ : IsPrenex φ
hψ : IsPrenex ψ
v : α → M
xs : Fin n → M
⊢ Realize (toPrenexImp φ ψ) v xs ↔ Realize (φ ⟹ ψ) v xs

Next tactic:
revert ψ
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  

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
n l : ℕ
φ✝ ψ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
hφ : IsPrenex φ
v : α → M
xs : Fin n → M
⊢ ∀ {ψ : BoundedFormula L α n}, IsPrenex ψ → (Realize (toPrenexImp φ ψ) v xs ↔ Realize (φ ⟹ ψ) v xs)

Next tactic:
induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> 

Proof state:
case of_isQF
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
n l : ℕ
φ✝¹ ψ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α n✝
hφ : IsQF φ✝
xs : Fin n✝ → M
⊢ ∀ {ψ : BoundedFormula L α n✝}, IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)

Next tactic:
intro ψ hψ
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> 

Proof state:
case all
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
n l : ℕ
φ✝¹ ψ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
⊢ ∀ {ψ : BoundedFormula L α n✝}, IsPrenex ψ → (Realize (toPrenexImp (∀'φ✝) ψ) v xs ↔ Realize (∀'φ✝ ⟹ ψ) v xs)

Next tactic:
intro ψ hψ
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> 

Proof state:
case ex
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
n l : ℕ
φ✝¹ ψ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
⊢ ∀ {ψ : BoundedFormula L α n✝}, IsPrenex ψ → (Realize (toPrenexImp (∃'φ✝) ψ) v xs ↔ Realize (∃'φ✝ ⟹ ψ) v xs)

Next tactic:
intro ψ hψ
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · 

Proof state:
case of_isQF
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α n✝
hφ : IsQF φ✝
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs

Next tactic:
rw [hφ.toPrenexImp]
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    

Proof state:
case of_isQF
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α n✝
hφ : IsQF φ✝
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ Realize (toPrenexImpRight φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs

Next tactic:
exact realize_toPrenexImpRight hφ hψ
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · 

Proof state:
case all
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ Realize (toPrenexImp (∀'φ✝) ψ) v xs ↔ Realize (∀'φ✝ ⟹ ψ) v xs

Next tactic:
unfold toPrenexImp
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    

Proof state:
case all
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ Realize (∃'toPrenexImp φ✝ (liftAt 1 n✝ ψ)) v xs ↔ Realize (∀'φ✝ ⟹ ψ) v xs

Next tactic:
rw [realize_ex]
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    

Proof state:
case all
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ (∃ a, Realize (toPrenexImp φ✝ (liftAt 1 n✝ ψ)) v (snoc xs a)) ↔ Realize (∀'φ✝ ⟹ ψ) v xs

Next tactic:
refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    

Proof state:
case all
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ (∃ a, Realize (φ✝ ⟹ liftAt 1 n✝ ψ) v (snoc xs a)) ↔ Realize (∀'φ✝ ⟹ ψ) v xs

Next tactic:
simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    

Proof state:
case all
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ (∃ a, Realize φ✝ v (snoc xs a) → Realize ψ v xs) ↔ (∀ (a : M), Realize φ✝ v (snoc xs a)) → Realize ψ v xs

Next tactic:
refine' ⟨_, fun h' => _⟩
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    refine' ⟨_, fun h' => _⟩
    · 

Proof state:
case all.refine'_1
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
⊢ (∃ a, Realize φ✝ v (snoc xs a) → Realize ψ v xs) → (∀ (a : M), Realize φ✝ v (snoc xs a)) → Realize ψ v xs

Next tactic:
rintro ⟨a, ha⟩ h
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    refine' ⟨_, fun h' => _⟩
    · rintro ⟨a, ha⟩ h
      

Proof state:
case all.refine'_1.intro
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
a : M
ha : Realize φ✝ v (snoc xs a) → Realize ψ v xs
h : ∀ (a : M), Realize φ✝ v (snoc xs a)
⊢ Realize ψ v xs

Next tactic:
exact ha (h a)
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    refine' ⟨_, fun h' => _⟩
    · rintro ⟨a, ha⟩ h
      exact ha (h a)
    · 

Proof state:
case all.refine'_2
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
h' : (∀ (a : M), Realize φ✝ v (snoc xs a)) → Realize ψ v xs
⊢ ∃ a, Realize φ✝ v (snoc xs a) → Realize ψ v xs

Next tactic:
by_cases h : ψ.Realize v xs
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    refine' ⟨_, fun h' => _⟩
    · rintro ⟨a, ha⟩ h
      exact ha (h a)
    · by_cases h : ψ.Realize v xs
      · 

Proof state:
case pos
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
h' : (∀ (a : M), Realize φ✝ v (snoc xs a)) → Realize ψ v xs
h : Realize ψ v xs
⊢ ∃ a, Realize φ✝ v (snoc xs a) → Realize ψ v xs

Next tactic:
inhabit M
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    refine' ⟨_, fun h' => _⟩
    · rintro ⟨a, ha⟩ h
      exact ha (h a)
    · by_cases h : ψ.Realize v xs
      · inhabit M
        

Proof state:
case pos
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
h' : (∀ (a : M), Realize φ✝ v (snoc xs a)) → Realize ψ v xs
h : Realize ψ v xs
inhabited_h : Inhabited M
⊢ ∃ a, Realize φ✝ v (snoc xs a) → Realize ψ v xs

Next tactic:
exact ⟨default, fun _h'' => h⟩
theorem realize_toPrenexImp {φ ψ : L.BoundedFormula α n} (hφ : IsPrenex φ) (hψ : IsPrenex ψ)
    {v : α → M} {xs : Fin n → M} : (φ.toPrenexImp ψ).Realize v xs ↔ (φ.imp ψ).Realize v xs := by
  revert ψ
  induction' hφ with _ _ hφ _ _ _hφ ih _ _ _hφ ih <;> intro ψ hψ
  · rw [hφ.toPrenexImp]
    exact realize_toPrenexImpRight hφ hψ
  · unfold toPrenexImp
    rw [realize_ex]
    refine' _root_.trans (exists_congr fun _ => ih hψ.liftAt) _
    simp only [realize_imp, realize_liftAt_one_self, snoc_comp_castSucc, realize_all]
    refine' ⟨_, fun h' => _⟩
    · rintro ⟨a, ha⟩ h
      exact ha (h a)
    · by_cases h : ψ.Realize v xs
      · inhabit M
        exact ⟨default, fun _h'' => h⟩
      · 

Proof state:
case neg
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
n l : ℕ
φ✝¹ ψ✝ : BoundedFormula L α l
θ : BoundedFormula L α (Nat.succ l)
v✝ : α → M
xs✝ : Fin l → M
inst✝ : Nonempty M
φ : BoundedFormula L α n
v : α → M
n✝ : ℕ
φ✝ : BoundedFormula L α (n✝ + 1)
_hφ : IsPrenex φ✝
ih :
  ∀ {xs : Fin (n✝ + 1) → M} {ψ : BoundedFormula L α (n✝ + 1)},
    IsPrenex ψ → (Realize (toPrenexImp φ✝ ψ) v xs ↔ Realize (φ✝ ⟹ ψ) v xs)
xs : Fin n✝ → M
ψ : BoundedFormula L α n✝
hψ : IsPrenex ψ
h' : (∀ (a : M), Realize φ✝ v (snoc xs a)) → Realize ψ v xs
h : ¬Realize ψ v xs
⊢ ∃ a, Realize φ✝ v (snoc xs a) → Realize ψ v xs

Next tactic:
obtain ⟨a, ha⟩ := not_forall.1 (h ∘ h')